Assume deconstruct_array() outputs are untoasted.
In functions that issue a deconstruct_array() call, consistently use plain VARSIZE()/VARDATA() on the array elements. Prior practice was divided between those and VARSIZE_ANY_EXHDR()/VARDATA_ANY().
This commit is contained in:
parent
9e0926468a
commit
2fd26b23b6
@ -611,19 +611,22 @@ hstore_from_arrays(PG_FUNCTION_ARGS)
|
||||
|
||||
if (!value_nulls || value_nulls[i])
|
||||
{
|
||||
pairs[i].key = VARDATA_ANY(key_datums[i]);
|
||||
pairs[i].key = VARDATA(key_datums[i]);
|
||||
pairs[i].val = NULL;
|
||||
pairs[i].keylen = hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(key_datums[i]));
|
||||
pairs[i].keylen =
|
||||
hstoreCheckKeyLen(VARSIZE(key_datums[i]) - VARHDRSZ);
|
||||
pairs[i].vallen = 4;
|
||||
pairs[i].isnull = true;
|
||||
pairs[i].needfree = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pairs[i].key = VARDATA_ANY(key_datums[i]);
|
||||
pairs[i].val = VARDATA_ANY(value_datums[i]);
|
||||
pairs[i].keylen = hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(key_datums[i]));
|
||||
pairs[i].vallen = hstoreCheckValLen(VARSIZE_ANY_EXHDR(value_datums[i]));
|
||||
pairs[i].key = VARDATA(key_datums[i]);
|
||||
pairs[i].val = VARDATA(value_datums[i]);
|
||||
pairs[i].keylen =
|
||||
hstoreCheckKeyLen(VARSIZE(key_datums[i]) - VARHDRSZ);
|
||||
pairs[i].vallen =
|
||||
hstoreCheckValLen(VARSIZE(value_datums[i]) - VARHDRSZ);
|
||||
pairs[i].isnull = false;
|
||||
pairs[i].needfree = false;
|
||||
}
|
||||
@ -704,19 +707,22 @@ hstore_from_array(PG_FUNCTION_ARGS)
|
||||
|
||||
if (in_nulls[i * 2 + 1])
|
||||
{
|
||||
pairs[i].key = VARDATA_ANY(in_datums[i * 2]);
|
||||
pairs[i].key = VARDATA(in_datums[i * 2]);
|
||||
pairs[i].val = NULL;
|
||||
pairs[i].keylen = hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(in_datums[i * 2]));
|
||||
pairs[i].keylen =
|
||||
hstoreCheckKeyLen(VARSIZE(in_datums[i * 2]) - VARHDRSZ);
|
||||
pairs[i].vallen = 4;
|
||||
pairs[i].isnull = true;
|
||||
pairs[i].needfree = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pairs[i].key = VARDATA_ANY(in_datums[i * 2]);
|
||||
pairs[i].val = VARDATA_ANY(in_datums[i * 2 + 1]);
|
||||
pairs[i].keylen = hstoreCheckKeyLen(VARSIZE_ANY_EXHDR(in_datums[i * 2]));
|
||||
pairs[i].vallen = hstoreCheckValLen(VARSIZE_ANY_EXHDR(in_datums[i * 2 + 1]));
|
||||
pairs[i].key = VARDATA(in_datums[i * 2]);
|
||||
pairs[i].val = VARDATA(in_datums[i * 2 + 1]);
|
||||
pairs[i].keylen =
|
||||
hstoreCheckKeyLen(VARSIZE(in_datums[i * 2]) - VARHDRSZ);
|
||||
pairs[i].vallen =
|
||||
hstoreCheckValLen(VARSIZE(in_datums[i * 2 + 1]) - VARHDRSZ);
|
||||
pairs[i].isnull = false;
|
||||
pairs[i].needfree = false;
|
||||
}
|
||||
|
@ -760,9 +760,8 @@ transformRelOptions(Datum oldOptions, List *defList, char *namspace,
|
||||
|
||||
for (i = 0; i < noldoptions; i++)
|
||||
{
|
||||
text *oldoption = DatumGetTextP(oldoptions[i]);
|
||||
char *text_str = VARDATA(oldoption);
|
||||
int text_len = VARSIZE(oldoption) - VARHDRSZ;
|
||||
char *text_str = VARDATA(oldoptions[i]);
|
||||
int text_len = VARSIZE(oldoptions[i]) - VARHDRSZ;
|
||||
|
||||
/* Search for a match in defList */
|
||||
foreach(cell, defList)
|
||||
@ -1055,9 +1054,8 @@ parseRelOptions(Datum options, bool validate, relopt_kind kind,
|
||||
|
||||
for (i = 0; i < noptions; i++)
|
||||
{
|
||||
text *optiontext = DatumGetTextP(optiondatums[i]);
|
||||
char *text_str = VARDATA(optiontext);
|
||||
int text_len = VARSIZE(optiontext) - VARHDRSZ;
|
||||
char *text_str = VARDATA(optiondatums[i]);
|
||||
int text_len = VARSIZE(optiondatums[i]) - VARHDRSZ;
|
||||
int j;
|
||||
|
||||
/* Search for a match in reloptions */
|
||||
|
@ -172,8 +172,8 @@ gin_extract_jsonb_query(PG_FUNCTION_ARGS)
|
||||
if (key_nulls[i])
|
||||
continue;
|
||||
entries[j++] = make_text_key(JGINFLAG_KEY,
|
||||
VARDATA_ANY(key_datums[i]),
|
||||
VARSIZE_ANY_EXHDR(key_datums[i]));
|
||||
VARDATA(key_datums[i]),
|
||||
VARSIZE(key_datums[i]) - VARHDRSZ);
|
||||
}
|
||||
|
||||
*nentries = j;
|
||||
|
@ -1240,8 +1240,8 @@ get_jsonb_path_all(FunctionCallInfo fcinfo, bool as_text)
|
||||
{
|
||||
jbvp = findJsonbValueFromContainerLen(container,
|
||||
JB_FOBJECT,
|
||||
VARDATA_ANY(pathtext[i]),
|
||||
VARSIZE_ANY_EXHDR(pathtext[i]));
|
||||
VARDATA(pathtext[i]),
|
||||
VARSIZE(pathtext[i]) - VARHDRSZ);
|
||||
}
|
||||
else if (have_array)
|
||||
{
|
||||
|
@ -163,8 +163,7 @@ binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS)
|
||||
&textDatums, NULL, &ndatums);
|
||||
for (i = 0; i < ndatums; i++)
|
||||
{
|
||||
text *txtname = DatumGetTextPP(textDatums[i]);
|
||||
char *extName = text_to_cstring(txtname);
|
||||
char *extName = TextDatumGetCString(textDatums[i]);
|
||||
Oid extOid = get_extension_oid(extName, false);
|
||||
|
||||
requiredExtensions = lappend_oid(requiredExtensions, extOid);
|
||||
|
@ -323,7 +323,7 @@ tsvector_setweight_by_filter(PG_FUNCTION_ARGS)
|
||||
errmsg("lexeme array may not contain nulls")));
|
||||
|
||||
lex = VARDATA(dlexemes[i]);
|
||||
lex_len = VARSIZE_ANY_EXHDR(dlexemes[i]);
|
||||
lex_len = VARSIZE(dlexemes[i]) - VARHDRSZ;
|
||||
lex_pos = tsvector_bsearch(tsout, lex, lex_len);
|
||||
|
||||
if (lex_pos >= 0 && (j = POSDATALEN(tsout, entry + lex_pos)) != 0)
|
||||
@ -609,8 +609,8 @@ tsvector_delete_arr(PG_FUNCTION_ARGS)
|
||||
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||
errmsg("lexeme array may not contain nulls")));
|
||||
|
||||
lex = VARDATA_ANY(dlexemes[i]);
|
||||
lex_len = VARSIZE_ANY_EXHDR(dlexemes[i]);
|
||||
lex = VARDATA(dlexemes[i]);
|
||||
lex_len = VARSIZE(dlexemes[i]) - VARHDRSZ;
|
||||
lex_pos = tsvector_bsearch(tsin, lex, lex_len);
|
||||
|
||||
if (lex_pos >= 0)
|
||||
@ -793,7 +793,7 @@ array_to_tsvector(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Calculate space needed for surviving lexemes. */
|
||||
for (i = 0; i < nitems; i++)
|
||||
datalen += VARSIZE_ANY_EXHDR(dlexemes[i]);
|
||||
datalen += VARSIZE(dlexemes[i]) - VARHDRSZ;
|
||||
tslen = CALCDATASIZE(nitems, datalen);
|
||||
|
||||
/* Allocate and fill tsvector. */
|
||||
@ -805,8 +805,8 @@ array_to_tsvector(PG_FUNCTION_ARGS)
|
||||
cur = STRPTR(tsout);
|
||||
for (i = 0; i < nitems; i++)
|
||||
{
|
||||
char *lex = VARDATA_ANY(dlexemes[i]);
|
||||
int lex_len = VARSIZE_ANY_EXHDR(dlexemes[i]);
|
||||
char *lex = VARDATA(dlexemes[i]);
|
||||
int lex_len = VARSIZE(dlexemes[i]) - VARHDRSZ;
|
||||
|
||||
memcpy(cur, lex, lex_len);
|
||||
arrout[i].haspos = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user