Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd746021

Browse files
committed
Add construct_array_builtin, deconstruct_array_builtin
There were many calls to construct_array() and deconstruct_array() forbuilt-in types, for example, when dealing with system catalog columns.These all hardcoded the type attributes necessary to pass to thesefunctions.To simplify this a bit, add construct_array_builtin(),deconstruct_array_builtin() as wrappers that centralize this hardcodedknowledge. This simplifies many call sites and reduces the amount ofhardcoded stuff that is spread around.Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://www.postgresql.org/message-id/flat/2914356f-9e5f-8c59-2995-5997fc48bcba%40enterprisedb.com
1 parent7c2d6f8 commitd746021

File tree

51 files changed

+284
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+284
-298
lines changed

‎contrib/hstore/hstore_gin.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ gin_extract_hstore_query(PG_FUNCTION_ARGS)
118118
j;
119119
text*item;
120120

121-
deconstruct_array(query,
122-
TEXTOID,-1, false,TYPALIGN_INT,
123-
&key_datums,&key_nulls,&key_count);
121+
deconstruct_array_builtin(query,TEXTOID,&key_datums,&key_nulls,&key_count);
124122

125123
entries= (Datum*)palloc(sizeof(Datum)*key_count);
126124

‎contrib/hstore/hstore_gist.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,7 @@ ghstore_consistent(PG_FUNCTION_ARGS)
560560
intkey_count;
561561
inti;
562562

563-
deconstruct_array(query,
564-
TEXTOID,-1, false,TYPALIGN_INT,
565-
&key_datums,&key_nulls,&key_count);
563+
deconstruct_array_builtin(query,TEXTOID,&key_datums,&key_nulls,&key_count);
566564

567565
for (i=0;res&&i<key_count;++i)
568566
{
@@ -583,9 +581,7 @@ ghstore_consistent(PG_FUNCTION_ARGS)
583581
intkey_count;
584582
inti;
585583

586-
deconstruct_array(query,
587-
TEXTOID,-1, false,TYPALIGN_INT,
588-
&key_datums,&key_nulls,&key_count);
584+
deconstruct_array_builtin(query,TEXTOID,&key_datums,&key_nulls,&key_count);
589585

590586
res= false;
591587

‎contrib/hstore/hstore_io.c‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,7 @@ hstore_from_arrays(PG_FUNCTION_ARGS)
567567
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
568568
errmsg("wrong number of array subscripts")));
569569

570-
deconstruct_array(key_array,
571-
TEXTOID,-1, false,TYPALIGN_INT,
572-
&key_datums,&key_nulls,&key_count);
570+
deconstruct_array_builtin(key_array,TEXTOID,&key_datums,&key_nulls,&key_count);
573571

574572
/* see discussion in hstoreArrayToPairs() */
575573
if (key_count>MaxAllocSize /sizeof(Pairs))
@@ -606,9 +604,7 @@ hstore_from_arrays(PG_FUNCTION_ARGS)
606604
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
607605
errmsg("arrays must have same bounds")));
608606

609-
deconstruct_array(value_array,
610-
TEXTOID,-1, false,TYPALIGN_INT,
611-
&value_datums,&value_nulls,&value_count);
607+
deconstruct_array_builtin(value_array,TEXTOID,&value_datums,&value_nulls,&value_count);
612608

613609
Assert(key_count==value_count);
614610
}
@@ -696,9 +692,7 @@ hstore_from_array(PG_FUNCTION_ARGS)
696692
errmsg("wrong number of array subscripts")));
697693
}
698694

699-
deconstruct_array(in_array,
700-
TEXTOID,-1, false,TYPALIGN_INT,
701-
&in_datums,&in_nulls,&in_count);
695+
deconstruct_array_builtin(in_array,TEXTOID,&in_datums,&in_nulls,&in_count);
702696

703697
count=in_count /2;
704698

‎contrib/hstore/hstore_op.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ hstoreArrayToPairs(ArrayType *a, int *npairs)
8080
inti,
8181
j;
8282

83-
deconstruct_array(a,
84-
TEXTOID,-1, false,TYPALIGN_INT,
85-
&key_datums,&key_nulls,&key_count);
83+
deconstruct_array_builtin(a,TEXTOID,&key_datums,&key_nulls,&key_count);
8684

8785
if (key_count==0)
8886
{
@@ -582,9 +580,7 @@ hstore_slice_to_array(PG_FUNCTION_ARGS)
582580
intkey_count;
583581
inti;
584582

585-
deconstruct_array(key_array,
586-
TEXTOID,-1, false,TYPALIGN_INT,
587-
&key_datums,&key_nulls,&key_count);
583+
deconstruct_array_builtin(key_array,TEXTOID,&key_datums,&key_nulls,&key_count);
588584

589585
if (key_count==0)
590586
{
@@ -719,8 +715,7 @@ hstore_akeys(PG_FUNCTION_ARGS)
719715
d[i]=PointerGetDatum(t);
720716
}
721717

722-
a=construct_array(d,count,
723-
TEXTOID,-1, false,TYPALIGN_INT);
718+
a=construct_array_builtin(d,count,TEXTOID);
724719

725720
PG_RETURN_POINTER(a);
726721
}

‎contrib/pageinspect/btreefuncs.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,7 @@ bt_page_print_tuples(struct user_args *uargs)
425425
tids_datum= (Datum*)palloc(nposting*sizeof(Datum));
426426
for (inti=0;i<nposting;i++)
427427
tids_datum[i]=ItemPointerGetDatum(&tids[i]);
428-
values[j++]=PointerGetDatum(construct_array(tids_datum,
429-
nposting,
430-
TIDOID,
431-
sizeof(ItemPointerData),
432-
false,TYPALIGN_SHORT));
428+
values[j++]=PointerGetDatum(construct_array_builtin(tids_datum,nposting,TIDOID));
433429
pfree(tids_datum);
434430
}
435431
else

‎contrib/pageinspect/ginfuncs.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ gin_page_opaque_info(PG_FUNCTION_ARGS)
166166

167167
values[0]=Int64GetDatum(opaq->rightlink);
168168
values[1]=Int32GetDatum(opaq->maxoff);
169-
values[2]=PointerGetDatum(construct_array(flags,nflags,
170-
TEXTOID,
171-
-1, false,TYPALIGN_INT));
169+
values[2]=PointerGetDatum(construct_array_builtin(flags,nflags,TEXTOID));
172170

173171
/* Build and return the result tuple. */
174172
resultTuple=heap_form_tuple(tupdesc,values,nulls);
@@ -273,11 +271,7 @@ gin_leafpage_items(PG_FUNCTION_ARGS)
273271
tids_datum= (Datum*)palloc(ndecoded*sizeof(Datum));
274272
for (i=0;i<ndecoded;i++)
275273
tids_datum[i]=ItemPointerGetDatum(&tids[i]);
276-
values[2]=PointerGetDatum(construct_array(tids_datum,
277-
ndecoded,
278-
TIDOID,
279-
sizeof(ItemPointerData),
280-
false,TYPALIGN_SHORT));
274+
values[2]=PointerGetDatum(construct_array_builtin(tids_datum,ndecoded,TIDOID));
281275
pfree(tids_datum);
282276
pfree(tids);
283277

‎contrib/pageinspect/gistfuncs.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ gist_page_opaque_info(PG_FUNCTION_ARGS)
104104
values[0]=LSNGetDatum(PageGetLSN(page));
105105
values[1]=LSNGetDatum(GistPageGetNSN(page));
106106
values[2]=Int64GetDatum(opaq->rightlink);
107-
values[3]=PointerGetDatum(construct_array(flags,nflags,
108-
TEXTOID,
109-
-1, false,TYPALIGN_INT));
107+
values[3]=PointerGetDatum(construct_array_builtin(flags,nflags,TEXTOID));
110108

111109
/* Build and return the result tuple. */
112110
resultTuple=heap_form_tuple(tupdesc,values,nulls);

‎contrib/pageinspect/hashfuncs.c‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -564,21 +564,11 @@ hash_metapage_info(PG_FUNCTION_ARGS)
564564

565565
for (i=0;i<HASH_MAX_SPLITPOINTS;i++)
566566
spares[i]=Int64GetDatum((int64)metad->hashm_spares[i]);
567-
values[j++]=PointerGetDatum(construct_array(spares,
568-
HASH_MAX_SPLITPOINTS,
569-
INT8OID,
570-
sizeof(int64),
571-
FLOAT8PASSBYVAL,
572-
TYPALIGN_DOUBLE));
567+
values[j++]=PointerGetDatum(construct_array_builtin(spares,HASH_MAX_SPLITPOINTS,INT8OID));
573568

574569
for (i=0;i<HASH_MAX_BITMAPS;i++)
575570
mapp[i]=Int64GetDatum((int64)metad->hashm_mapp[i]);
576-
values[j++]=PointerGetDatum(construct_array(mapp,
577-
HASH_MAX_BITMAPS,
578-
INT8OID,
579-
sizeof(int64),
580-
FLOAT8PASSBYVAL,
581-
TYPALIGN_DOUBLE));
571+
values[j++]=PointerGetDatum(construct_array_builtin(mapp,HASH_MAX_BITMAPS,INT8OID));
582572

583573
tuple=heap_form_tuple(tupleDesc,values,nulls);
584574

‎contrib/pageinspect/heapfuncs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ heap_tuple_infomask_flags(PG_FUNCTION_ARGS)
590590

591591
/* build value */
592592
Assert(cnt <=bitcnt);
593-
a=construct_array(flags,cnt,TEXTOID,-1, false,TYPALIGN_INT);
593+
a=construct_array_builtin(flags,cnt,TEXTOID);
594594
values[0]=PointerGetDatum(a);
595595

596596
/*
@@ -612,7 +612,7 @@ heap_tuple_infomask_flags(PG_FUNCTION_ARGS)
612612
if (cnt==0)
613613
a=construct_empty_array(TEXTOID);
614614
else
615-
a=construct_array(flags,cnt,TEXTOID,-1, false,TYPALIGN_INT);
615+
a=construct_array_builtin(flags,cnt,TEXTOID);
616616
pfree(flags);
617617
values[1]=PointerGetDatum(a);
618618

‎contrib/pg_trgm/trgm_op.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -977,12 +977,7 @@ show_trgm(PG_FUNCTION_ARGS)
977977
d[i]=PointerGetDatum(item);
978978
}
979979

980-
a=construct_array(d,
981-
ARRNELEM(trg),
982-
TEXTOID,
983-
-1,
984-
false,
985-
TYPALIGN_INT);
980+
a=construct_array_builtin(d,ARRNELEM(trg),TEXTOID);
986981

987982
for (i=0;i<ARRNELEM(trg);i++)
988983
pfree(DatumGetPointer(d[i]));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp