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

Commit2fd26b2

Browse files
committed
Assume deconstruct_array() outputs are untoasted.
In functions that issue a deconstruct_array() call, consistently useplain VARSIZE()/VARDATA() on the array elements. Prior practice wasdivided between those and VARSIZE_ANY_EXHDR()/VARDATA_ANY().
1 parent9e09264 commit2fd26b2

File tree

6 files changed

+33
-30
lines changed

6 files changed

+33
-30
lines changed

‎contrib/hstore/hstore_io.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -611,19 +611,22 @@ hstore_from_arrays(PG_FUNCTION_ARGS)
611611

612612
if (!value_nulls||value_nulls[i])
613613
{
614-
pairs[i].key=VARDATA_ANY(key_datums[i]);
614+
pairs[i].key=VARDATA(key_datums[i]);
615615
pairs[i].val=NULL;
616-
pairs[i].keylen=hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(key_datums[i]));
616+
pairs[i].keylen=
617+
hstoreCheckKeyLen(VARSIZE(key_datums[i])-VARHDRSZ);
617618
pairs[i].vallen=4;
618619
pairs[i].isnull= true;
619620
pairs[i].needfree= false;
620621
}
621622
else
622623
{
623-
pairs[i].key=VARDATA_ANY(key_datums[i]);
624-
pairs[i].val=VARDATA_ANY(value_datums[i]);
625-
pairs[i].keylen=hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(key_datums[i]));
626-
pairs[i].vallen=hstoreCheckValLen(VARSIZE_ANY_EXHDR(value_datums[i]));
624+
pairs[i].key=VARDATA(key_datums[i]);
625+
pairs[i].val=VARDATA(value_datums[i]);
626+
pairs[i].keylen=
627+
hstoreCheckKeyLen(VARSIZE(key_datums[i])-VARHDRSZ);
628+
pairs[i].vallen=
629+
hstoreCheckValLen(VARSIZE(value_datums[i])-VARHDRSZ);
627630
pairs[i].isnull= false;
628631
pairs[i].needfree= false;
629632
}
@@ -704,19 +707,22 @@ hstore_from_array(PG_FUNCTION_ARGS)
704707

705708
if (in_nulls[i*2+1])
706709
{
707-
pairs[i].key=VARDATA_ANY(in_datums[i*2]);
710+
pairs[i].key=VARDATA(in_datums[i*2]);
708711
pairs[i].val=NULL;
709-
pairs[i].keylen=hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(in_datums[i*2]));
712+
pairs[i].keylen=
713+
hstoreCheckKeyLen(VARSIZE(in_datums[i*2])-VARHDRSZ);
710714
pairs[i].vallen=4;
711715
pairs[i].isnull= true;
712716
pairs[i].needfree= false;
713717
}
714718
else
715719
{
716-
pairs[i].key=VARDATA_ANY(in_datums[i*2]);
717-
pairs[i].val=VARDATA_ANY(in_datums[i*2+1]);
718-
pairs[i].keylen=hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(in_datums[i*2]));
719-
pairs[i].vallen=hstoreCheckValLen(VARSIZE_ANY_EXHDR(in_datums[i*2+1]));
720+
pairs[i].key=VARDATA(in_datums[i*2]);
721+
pairs[i].val=VARDATA(in_datums[i*2+1]);
722+
pairs[i].keylen=
723+
hstoreCheckKeyLen(VARSIZE(in_datums[i*2])-VARHDRSZ);
724+
pairs[i].vallen=
725+
hstoreCheckValLen(VARSIZE(in_datums[i*2+1])-VARHDRSZ);
720726
pairs[i].isnull= false;
721727
pairs[i].needfree= false;
722728
}

‎src/backend/access/common/reloptions.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,8 @@ transformRelOptions(Datum oldOptions, List *defList, char *namspace,
760760

761761
for (i=0;i<noldoptions;i++)
762762
{
763-
text*oldoption=DatumGetTextP(oldoptions[i]);
764-
char*text_str=VARDATA(oldoption);
765-
inttext_len=VARSIZE(oldoption)-VARHDRSZ;
763+
char*text_str=VARDATA(oldoptions[i]);
764+
inttext_len=VARSIZE(oldoptions[i])-VARHDRSZ;
766765

767766
/* Search for a match in defList */
768767
foreach(cell,defList)
@@ -1055,9 +1054,8 @@ parseRelOptions(Datum options, bool validate, relopt_kind kind,
10551054

10561055
for (i=0;i<noptions;i++)
10571056
{
1058-
text*optiontext=DatumGetTextP(optiondatums[i]);
1059-
char*text_str=VARDATA(optiontext);
1060-
inttext_len=VARSIZE(optiontext)-VARHDRSZ;
1057+
char*text_str=VARDATA(optiondatums[i]);
1058+
inttext_len=VARSIZE(optiondatums[i])-VARHDRSZ;
10611059
intj;
10621060

10631061
/* Search for a match in reloptions */

‎src/backend/utils/adt/jsonb_gin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ gin_extract_jsonb_query(PG_FUNCTION_ARGS)
172172
if (key_nulls[i])
173173
continue;
174174
entries[j++]=make_text_key(JGINFLAG_KEY,
175-
VARDATA_ANY(key_datums[i]),
176-
VARSIZE_ANY_EXHDR(key_datums[i]));
175+
VARDATA(key_datums[i]),
176+
VARSIZE(key_datums[i])-VARHDRSZ);
177177
}
178178

179179
*nentries=j;

‎src/backend/utils/adt/jsonfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,8 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
12401240
{
12411241
jbvp=findJsonbValueFromContainerLen(container,
12421242
JB_FOBJECT,
1243-
VARDATA_ANY(pathtext[i]),
1244-
VARSIZE_ANY_EXHDR(pathtext[i]));
1243+
VARDATA(pathtext[i]),
1244+
VARSIZE(pathtext[i])-VARHDRSZ);
12451245
}
12461246
elseif (have_array)
12471247
{

‎src/backend/utils/adt/pg_upgrade_support.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS)
163163
&textDatums,NULL,&ndatums);
164164
for (i=0;i<ndatums;i++)
165165
{
166-
text*txtname=DatumGetTextPP(textDatums[i]);
167-
char*extName=text_to_cstring(txtname);
166+
char*extName=TextDatumGetCString(textDatums[i]);
168167
OidextOid=get_extension_oid(extName, false);
169168

170169
requiredExtensions=lappend_oid(requiredExtensions,extOid);

‎src/backend/utils/adt/tsvector_op.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ tsvector_setweight_by_filter(PG_FUNCTION_ARGS)
323323
errmsg("lexeme array may not contain nulls")));
324324

325325
lex=VARDATA(dlexemes[i]);
326-
lex_len=VARSIZE_ANY_EXHDR(dlexemes[i]);
326+
lex_len=VARSIZE(dlexemes[i])-VARHDRSZ;
327327
lex_pos=tsvector_bsearch(tsout,lex,lex_len);
328328

329329
if (lex_pos >=0&& (j=POSDATALEN(tsout,entry+lex_pos))!=0)
@@ -609,8 +609,8 @@ tsvector_delete_arr(PG_FUNCTION_ARGS)
609609
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
610610
errmsg("lexeme array may not contain nulls")));
611611

612-
lex=VARDATA_ANY(dlexemes[i]);
613-
lex_len=VARSIZE_ANY_EXHDR(dlexemes[i]);
612+
lex=VARDATA(dlexemes[i]);
613+
lex_len=VARSIZE(dlexemes[i])-VARHDRSZ;
614614
lex_pos=tsvector_bsearch(tsin,lex,lex_len);
615615

616616
if (lex_pos >=0)
@@ -793,7 +793,7 @@ array_to_tsvector(PG_FUNCTION_ARGS)
793793

794794
/* Calculate space needed for surviving lexemes. */
795795
for (i=0;i<nitems;i++)
796-
datalen+=VARSIZE_ANY_EXHDR(dlexemes[i]);
796+
datalen+=VARSIZE(dlexemes[i])-VARHDRSZ;
797797
tslen=CALCDATASIZE(nitems,datalen);
798798

799799
/* Allocate and fill tsvector. */
@@ -805,8 +805,8 @@ array_to_tsvector(PG_FUNCTION_ARGS)
805805
cur=STRPTR(tsout);
806806
for (i=0;i<nitems;i++)
807807
{
808-
char*lex=VARDATA_ANY(dlexemes[i]);
809-
intlex_len=VARSIZE_ANY_EXHDR(dlexemes[i]);
808+
char*lex=VARDATA(dlexemes[i]);
809+
intlex_len=VARSIZE(dlexemes[i])-VARHDRSZ;
810810

811811
memcpy(cur,lex,lex_len);
812812
arrout[i].haspos=0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp