mirror of
https://github.com/postgres/postgres.git
synced 2025-08-31 17:02:12 +03:00
Use wrappers of PG_DETOAST_DATUM_PACKED() more.
This makes almost all core code follow the policy introduced in the previous commit. Specific decisions: - Text search support functions with char* and length arguments, such as prsstart and lexize, may receive unaligned strings. I doubt maintainers of non-core text search code will notice. - Use plain VARDATA() on values detoasted or synthesized earlier in the same function. Use VARDATA_ANY() on varlenas sourced outside the function, even if they happen to always have four-byte headers. As an exception, retain the universal practice of using VARDATA() on return values of SendFunctionCall(). - Retain PG_GETARG_BYTEA_P() in pageinspect. (Page images are too large for a one-byte header, so this misses no optimization.) Sites that do not call get_page_from_raw() typically need the four-byte alignment. - For now, do not change btree_gist. Its use of four-byte headers in memory is partly entangled with storage of 4-byte headers inside GBT_VARKEY, on disk. - For now, do not change gtrgm_consistent() or gtrgm_distance(). They incorporate the varlena header into a cache, and there are multiple credible implementation strategies to consider.
This commit is contained in:
@@ -124,8 +124,8 @@ pg_file_write(PG_FUNCTION_ARGS)
|
||||
|
||||
requireSuperuser();
|
||||
|
||||
filename = convert_and_check_filename(PG_GETARG_TEXT_P(0), false);
|
||||
data = PG_GETARG_TEXT_P(1);
|
||||
filename = convert_and_check_filename(PG_GETARG_TEXT_PP(0), false);
|
||||
data = PG_GETARG_TEXT_PP(1);
|
||||
|
||||
if (!PG_GETARG_BOOL(2))
|
||||
{
|
||||
@@ -147,8 +147,8 @@ pg_file_write(PG_FUNCTION_ARGS)
|
||||
errmsg("could not open file \"%s\" for writing: %m",
|
||||
filename)));
|
||||
|
||||
count = fwrite(VARDATA(data), 1, VARSIZE(data) - VARHDRSZ, f);
|
||||
if (count != VARSIZE(data) - VARHDRSZ || FreeFile(f))
|
||||
count = fwrite(VARDATA_ANY(data), 1, VARSIZE_ANY_EXHDR(data), f);
|
||||
if (count != VARSIZE_ANY_EXHDR(data) || FreeFile(f))
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not write file \"%s\": %m", filename)));
|
||||
@@ -170,12 +170,12 @@ pg_file_rename(PG_FUNCTION_ARGS)
|
||||
if (PG_ARGISNULL(0) || PG_ARGISNULL(1))
|
||||
PG_RETURN_NULL();
|
||||
|
||||
fn1 = convert_and_check_filename(PG_GETARG_TEXT_P(0), false);
|
||||
fn2 = convert_and_check_filename(PG_GETARG_TEXT_P(1), false);
|
||||
fn1 = convert_and_check_filename(PG_GETARG_TEXT_PP(0), false);
|
||||
fn2 = convert_and_check_filename(PG_GETARG_TEXT_PP(1), false);
|
||||
if (PG_ARGISNULL(2))
|
||||
fn3 = 0;
|
||||
else
|
||||
fn3 = convert_and_check_filename(PG_GETARG_TEXT_P(2), false);
|
||||
fn3 = convert_and_check_filename(PG_GETARG_TEXT_PP(2), false);
|
||||
|
||||
if (access(fn1, W_OK) < 0)
|
||||
{
|
||||
@@ -254,7 +254,7 @@ pg_file_unlink(PG_FUNCTION_ARGS)
|
||||
|
||||
requireSuperuser();
|
||||
|
||||
filename = convert_and_check_filename(PG_GETARG_TEXT_P(0), false);
|
||||
filename = convert_and_check_filename(PG_GETARG_TEXT_PP(0), false);
|
||||
|
||||
if (access(filename, W_OK) < 0)
|
||||
{
|
||||
|
@@ -1502,7 +1502,7 @@ dblink_get_pkey(PG_FUNCTION_ARGS)
|
||||
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
||||
|
||||
/* open target relation */
|
||||
rel = get_rel_from_relname(PG_GETARG_TEXT_P(0), AccessShareLock, ACL_SELECT);
|
||||
rel = get_rel_from_relname(PG_GETARG_TEXT_PP(0), AccessShareLock, ACL_SELECT);
|
||||
|
||||
/* get the array of attnums */
|
||||
results = get_pkey_attnames(rel, &numatts);
|
||||
@@ -1603,7 +1603,7 @@ PG_FUNCTION_INFO_V1(dblink_build_sql_insert);
|
||||
Datum
|
||||
dblink_build_sql_insert(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname_text = PG_GETARG_TEXT_P(0);
|
||||
text *relname_text = PG_GETARG_TEXT_PP(0);
|
||||
int2vector *pkattnums_arg = (int2vector *) PG_GETARG_POINTER(1);
|
||||
int32 pknumatts_arg = PG_GETARG_INT32(2);
|
||||
ArrayType *src_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(3);
|
||||
@@ -1694,7 +1694,7 @@ PG_FUNCTION_INFO_V1(dblink_build_sql_delete);
|
||||
Datum
|
||||
dblink_build_sql_delete(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname_text = PG_GETARG_TEXT_P(0);
|
||||
text *relname_text = PG_GETARG_TEXT_PP(0);
|
||||
int2vector *pkattnums_arg = (int2vector *) PG_GETARG_POINTER(1);
|
||||
int32 pknumatts_arg = PG_GETARG_INT32(2);
|
||||
ArrayType *tgt_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(3);
|
||||
@@ -1771,7 +1771,7 @@ PG_FUNCTION_INFO_V1(dblink_build_sql_update);
|
||||
Datum
|
||||
dblink_build_sql_update(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname_text = PG_GETARG_TEXT_P(0);
|
||||
text *relname_text = PG_GETARG_TEXT_PP(0);
|
||||
int2vector *pkattnums_arg = (int2vector *) PG_GETARG_POINTER(1);
|
||||
int32 pknumatts_arg = PG_GETARG_INT32(2);
|
||||
ArrayType *src_pkattvals_arry = PG_GETARG_ARRAYTYPE_P(3);
|
||||
@@ -2338,7 +2338,7 @@ quote_ident_cstr(char *rawstr)
|
||||
char *result;
|
||||
|
||||
rawstr_text = cstring_to_text(rawstr);
|
||||
result_text = DatumGetTextP(DirectFunctionCall1(quote_ident,
|
||||
result_text = DatumGetTextPP(DirectFunctionCall1(quote_ident,
|
||||
PointerGetDatum(rawstr_text)));
|
||||
result = text_to_cstring(result_text);
|
||||
|
||||
|
@@ -139,7 +139,7 @@ dmetaphone(PG_FUNCTION_ARGS)
|
||||
if (PG_ARGISNULL(0))
|
||||
PG_RETURN_NULL();
|
||||
#endif
|
||||
arg = PG_GETARG_TEXT_P(0);
|
||||
arg = PG_GETARG_TEXT_PP(0);
|
||||
aptr = text_to_cstring(arg);
|
||||
|
||||
DoubleMetaphone(aptr, codes);
|
||||
@@ -168,7 +168,7 @@ dmetaphone_alt(PG_FUNCTION_ARGS)
|
||||
if (PG_ARGISNULL(0))
|
||||
PG_RETURN_NULL();
|
||||
#endif
|
||||
arg = PG_GETARG_TEXT_P(0);
|
||||
arg = PG_GETARG_TEXT_PP(0);
|
||||
aptr = text_to_cstring(arg);
|
||||
|
||||
DoubleMetaphone(aptr, codes);
|
||||
|
@@ -736,7 +736,7 @@ soundex(PG_FUNCTION_ARGS)
|
||||
char outstr[SOUNDEX_LEN + 1];
|
||||
char *arg;
|
||||
|
||||
arg = text_to_cstring(PG_GETARG_TEXT_P(0));
|
||||
arg = text_to_cstring(PG_GETARG_TEXT_PP(0));
|
||||
|
||||
_soundex(arg, outstr);
|
||||
|
||||
@@ -802,8 +802,8 @@ difference(PG_FUNCTION_ARGS)
|
||||
int i,
|
||||
result;
|
||||
|
||||
_soundex(text_to_cstring(PG_GETARG_TEXT_P(0)), sndx1);
|
||||
_soundex(text_to_cstring(PG_GETARG_TEXT_P(1)), sndx2);
|
||||
_soundex(text_to_cstring(PG_GETARG_TEXT_PP(0)), sndx1);
|
||||
_soundex(text_to_cstring(PG_GETARG_TEXT_PP(1)), sndx2);
|
||||
|
||||
result = 0;
|
||||
for (i = 0; i < SOUNDEX_LEN; i++)
|
||||
|
@@ -200,9 +200,9 @@ Datum
|
||||
sort(PG_FUNCTION_ARGS)
|
||||
{
|
||||
ArrayType *a = PG_GETARG_ARRAYTYPE_P_COPY(0);
|
||||
text *dirstr = (fcinfo->nargs == 2) ? PG_GETARG_TEXT_P(1) : NULL;
|
||||
int32 dc = (dirstr) ? VARSIZE(dirstr) - VARHDRSZ : 0;
|
||||
char *d = (dirstr) ? VARDATA(dirstr) : NULL;
|
||||
text *dirstr = (fcinfo->nargs == 2) ? PG_GETARG_TEXT_PP(1) : NULL;
|
||||
int32 dc = (dirstr) ? VARSIZE_ANY_EXHDR(dirstr) : 0;
|
||||
char *d = (dirstr) ? VARDATA_ANY(dirstr) : NULL;
|
||||
int dir = -1;
|
||||
|
||||
CHECKARRVALID(a);
|
||||
|
@@ -159,7 +159,7 @@ GetBTPageStatistics(BlockNumber blkno, Buffer buffer, BTPageStat *stat)
|
||||
Datum
|
||||
bt_page_stats(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
uint32 blkno = PG_GETARG_UINT32(1);
|
||||
Buffer buffer;
|
||||
Relation rel;
|
||||
@@ -256,7 +256,7 @@ struct user_args
|
||||
Datum
|
||||
bt_page_items(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
uint32 blkno = PG_GETARG_UINT32(1);
|
||||
Datum result;
|
||||
char *values[6];
|
||||
@@ -408,7 +408,7 @@ bt_page_items(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
bt_metap(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
Datum result;
|
||||
Relation rel;
|
||||
RangeVar *relrv;
|
||||
|
@@ -45,7 +45,7 @@ PG_FUNCTION_INFO_V1(get_raw_page);
|
||||
Datum
|
||||
get_raw_page(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
uint32 blkno = PG_GETARG_UINT32(1);
|
||||
bytea *raw_page;
|
||||
|
||||
@@ -74,8 +74,8 @@ PG_FUNCTION_INFO_V1(get_raw_page_fork);
|
||||
Datum
|
||||
get_raw_page_fork(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *forkname = PG_GETARG_TEXT_P(1);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
text *forkname = PG_GETARG_TEXT_PP(1);
|
||||
uint32 blkno = PG_GETARG_UINT32(2);
|
||||
bytea *raw_page;
|
||||
ForkNumber forknum;
|
||||
@@ -184,7 +184,7 @@ get_page_from_raw(bytea *raw_page)
|
||||
Page page;
|
||||
int raw_page_size;
|
||||
|
||||
raw_page_size = VARSIZE(raw_page) - VARHDRSZ;
|
||||
raw_page_size = VARSIZE_ANY_EXHDR(raw_page);
|
||||
|
||||
if (raw_page_size != BLCKSZ)
|
||||
ereport(ERROR,
|
||||
@@ -195,7 +195,7 @@ get_page_from_raw(bytea *raw_page)
|
||||
|
||||
page = palloc(raw_page_size);
|
||||
|
||||
memcpy(page, VARDATA(raw_page), raw_page_size);
|
||||
memcpy(page, VARDATA_ANY(raw_page), raw_page_size);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
@@ -79,7 +79,7 @@ pg_prewarm(PG_FUNCTION_ARGS)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
(errmsg("prewarm type cannot be null"))));
|
||||
type = PG_GETARG_TEXT_P(1);
|
||||
type = PG_GETARG_TEXT_PP(1);
|
||||
ttype = text_to_cstring(type);
|
||||
if (strcmp(ttype, "prefetch") == 0)
|
||||
ptype = PREWARM_PREFETCH;
|
||||
@@ -99,7 +99,7 @@ pg_prewarm(PG_FUNCTION_ARGS)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
(errmsg("relation fork cannot be null"))));
|
||||
forkName = PG_GETARG_TEXT_P(2);
|
||||
forkName = PG_GETARG_TEXT_PP(2);
|
||||
forkString = text_to_cstring(forkName);
|
||||
forkNumber = forkname_to_number(forkString);
|
||||
|
||||
|
@@ -35,7 +35,7 @@ gin_extract_trgm(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
gin_extract_value_trgm(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *val = (text *) PG_GETARG_TEXT_P(0);
|
||||
text *val = (text *) PG_GETARG_TEXT_PP(0);
|
||||
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
|
||||
Datum *entries = NULL;
|
||||
TRGM *trg;
|
||||
@@ -43,7 +43,7 @@ gin_extract_value_trgm(PG_FUNCTION_ARGS)
|
||||
|
||||
*nentries = 0;
|
||||
|
||||
trg = generate_trgm(VARDATA(val), VARSIZE(val) - VARHDRSZ);
|
||||
trg = generate_trgm(VARDATA_ANY(val), VARSIZE_ANY_EXHDR(val));
|
||||
trglen = ARRNELEM(trg);
|
||||
|
||||
if (trglen > 0)
|
||||
@@ -70,7 +70,7 @@ gin_extract_value_trgm(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
gin_extract_query_trgm(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *val = (text *) PG_GETARG_TEXT_P(0);
|
||||
text *val = (text *) PG_GETARG_TEXT_PP(0);
|
||||
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
|
||||
StrategyNumber strategy = PG_GETARG_UINT16(2);
|
||||
|
||||
@@ -90,7 +90,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
|
||||
{
|
||||
case SimilarityStrategyNumber:
|
||||
case WordSimilarityStrategyNumber:
|
||||
trg = generate_trgm(VARDATA(val), VARSIZE(val) - VARHDRSZ);
|
||||
trg = generate_trgm(VARDATA_ANY(val), VARSIZE_ANY_EXHDR(val));
|
||||
break;
|
||||
case ILikeStrategyNumber:
|
||||
#ifndef IGNORECASE
|
||||
@@ -103,7 +103,8 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
|
||||
* For wildcard search we extract all the trigrams that every
|
||||
* potentially-matching string must include.
|
||||
*/
|
||||
trg = generate_wildcard_trgm(VARDATA(val), VARSIZE(val) - VARHDRSZ);
|
||||
trg = generate_wildcard_trgm(VARDATA_ANY(val),
|
||||
VARSIZE_ANY_EXHDR(val));
|
||||
break;
|
||||
case RegExpICaseStrategyNumber:
|
||||
#ifndef IGNORECASE
|
||||
@@ -170,7 +171,7 @@ gin_trgm_consistent(PG_FUNCTION_ARGS)
|
||||
bool *check = (bool *) PG_GETARG_POINTER(0);
|
||||
StrategyNumber strategy = PG_GETARG_UINT16(1);
|
||||
|
||||
/* text *query = PG_GETARG_TEXT_P(2); */
|
||||
/* text *query = PG_GETARG_TEXT_PP(2); */
|
||||
int32 nkeys = PG_GETARG_INT32(3);
|
||||
Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
|
||||
bool *recheck = (bool *) PG_GETARG_POINTER(5);
|
||||
@@ -268,7 +269,7 @@ gin_trgm_triconsistent(PG_FUNCTION_ARGS)
|
||||
GinTernaryValue *check = (GinTernaryValue *) PG_GETARG_POINTER(0);
|
||||
StrategyNumber strategy = PG_GETARG_UINT16(1);
|
||||
|
||||
/* text *query = PG_GETARG_TEXT_P(2); */
|
||||
/* text *query = PG_GETARG_TEXT_PP(2); */
|
||||
int32 nkeys = PG_GETARG_INT32(3);
|
||||
Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
|
||||
GinTernaryValue res = GIN_MAYBE;
|
||||
|
@@ -100,9 +100,9 @@ gtrgm_compress(PG_FUNCTION_ARGS)
|
||||
if (entry->leafkey)
|
||||
{ /* trgm */
|
||||
TRGM *res;
|
||||
text *val = DatumGetTextP(entry->key);
|
||||
text *val = DatumGetTextPP(entry->key);
|
||||
|
||||
res = generate_trgm(VARDATA(val), VARSIZE(val) - VARHDRSZ);
|
||||
res = generate_trgm(VARDATA_ANY(val), VARSIZE_ANY_EXHDR(val));
|
||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
||||
gistentryinit(*retval, PointerGetDatum(res),
|
||||
entry->rel, entry->page,
|
||||
@@ -142,7 +142,7 @@ gtrgm_decompress(PG_FUNCTION_ARGS)
|
||||
GISTENTRY *retval;
|
||||
text *key;
|
||||
|
||||
key = DatumGetTextP(entry->key);
|
||||
key = DatumGetTextPP(entry->key);
|
||||
|
||||
if (key != (text *) DatumGetPointer(entry->key))
|
||||
{
|
||||
@@ -200,11 +200,12 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
|
||||
* depends on strategy.
|
||||
*
|
||||
* The cached structure is a single palloc chunk containing the
|
||||
* gtrgm_consistent_cache header, then the input query (starting at a
|
||||
* MAXALIGN boundary), then the TRGM value (also starting at a MAXALIGN
|
||||
* boundary). However we don't try to include the regex graph (if any) in
|
||||
* that struct. (XXX currently, this approach can leak regex graphs
|
||||
* across index rescans. Not clear if that's worth fixing.)
|
||||
* gtrgm_consistent_cache header, then the input query (4-byte length
|
||||
* word, uncompressed, starting at a MAXALIGN boundary), then the TRGM
|
||||
* value (also starting at a MAXALIGN boundary). However we don't try to
|
||||
* include the regex graph (if any) in that struct. (XXX currently, this
|
||||
* approach can leak regex graphs across index rescans. Not clear if
|
||||
* that's worth fixing.)
|
||||
*/
|
||||
cache = (gtrgm_consistent_cache *) fcinfo->flinfo->fn_extra;
|
||||
if (cache == NULL ||
|
||||
|
@@ -878,14 +878,14 @@ trgm2int(trgm *ptr)
|
||||
Datum
|
||||
show_trgm(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *in = PG_GETARG_TEXT_P(0);
|
||||
text *in = PG_GETARG_TEXT_PP(0);
|
||||
TRGM *trg;
|
||||
Datum *d;
|
||||
ArrayType *a;
|
||||
trgm *ptr;
|
||||
int i;
|
||||
|
||||
trg = generate_trgm(VARDATA(in), VARSIZE(in) - VARHDRSZ);
|
||||
trg = generate_trgm(VARDATA_ANY(in), VARSIZE_ANY_EXHDR(in));
|
||||
d = (Datum *) palloc(sizeof(Datum) * (1 + ARRNELEM(trg)));
|
||||
|
||||
for (i = 0, ptr = GETARR(trg); i < ARRNELEM(trg); i++, ptr++)
|
||||
@@ -1053,14 +1053,14 @@ trgm_presence_map(TRGM *query, TRGM *key)
|
||||
Datum
|
||||
similarity(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *in1 = PG_GETARG_TEXT_P(0);
|
||||
text *in2 = PG_GETARG_TEXT_P(1);
|
||||
text *in1 = PG_GETARG_TEXT_PP(0);
|
||||
text *in2 = PG_GETARG_TEXT_PP(1);
|
||||
TRGM *trg1,
|
||||
*trg2;
|
||||
float4 res;
|
||||
|
||||
trg1 = generate_trgm(VARDATA(in1), VARSIZE(in1) - VARHDRSZ);
|
||||
trg2 = generate_trgm(VARDATA(in2), VARSIZE(in2) - VARHDRSZ);
|
||||
trg1 = generate_trgm(VARDATA_ANY(in1), VARSIZE_ANY_EXHDR(in1));
|
||||
trg2 = generate_trgm(VARDATA_ANY(in2), VARSIZE_ANY_EXHDR(in2));
|
||||
|
||||
res = cnt_sml(trg1, trg2, false);
|
||||
|
||||
|
@@ -62,7 +62,7 @@ pg_digest(PG_FUNCTION_ARGS)
|
||||
PX_MD *md;
|
||||
bytea *res;
|
||||
|
||||
name = PG_GETARG_TEXT_P(1);
|
||||
name = PG_GETARG_TEXT_PP(1);
|
||||
|
||||
/* will give error if fails */
|
||||
md = find_provider(name, (PFN) px_find_digest, "Digest", 0);
|
||||
@@ -72,10 +72,10 @@ pg_digest(PG_FUNCTION_ARGS)
|
||||
res = (text *) palloc(hlen + VARHDRSZ);
|
||||
SET_VARSIZE(res, hlen + VARHDRSZ);
|
||||
|
||||
arg = PG_GETARG_BYTEA_P(0);
|
||||
len = VARSIZE(arg) - VARHDRSZ;
|
||||
arg = PG_GETARG_BYTEA_PP(0);
|
||||
len = VARSIZE_ANY_EXHDR(arg);
|
||||
|
||||
px_md_update(md, (uint8 *) VARDATA(arg), len);
|
||||
px_md_update(md, (uint8 *) VARDATA_ANY(arg), len);
|
||||
px_md_finish(md, (uint8 *) VARDATA(res));
|
||||
px_md_free(md);
|
||||
|
||||
@@ -100,7 +100,7 @@ pg_hmac(PG_FUNCTION_ARGS)
|
||||
PX_HMAC *h;
|
||||
bytea *res;
|
||||
|
||||
name = PG_GETARG_TEXT_P(2);
|
||||
name = PG_GETARG_TEXT_PP(2);
|
||||
|
||||
/* will give error if fails */
|
||||
h = find_provider(name, (PFN) px_find_hmac, "HMAC", 0);
|
||||
@@ -110,13 +110,13 @@ pg_hmac(PG_FUNCTION_ARGS)
|
||||
res = (text *) palloc(hlen + VARHDRSZ);
|
||||
SET_VARSIZE(res, hlen + VARHDRSZ);
|
||||
|
||||
arg = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
len = VARSIZE(arg) - VARHDRSZ;
|
||||
klen = VARSIZE(key) - VARHDRSZ;
|
||||
arg = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
len = VARSIZE_ANY_EXHDR(arg);
|
||||
klen = VARSIZE_ANY_EXHDR(key);
|
||||
|
||||
px_hmac_init(h, (uint8 *) VARDATA(key), klen);
|
||||
px_hmac_update(h, (uint8 *) VARDATA(arg), len);
|
||||
px_hmac_init(h, (uint8 *) VARDATA_ANY(key), klen);
|
||||
px_hmac_update(h, (uint8 *) VARDATA_ANY(arg), len);
|
||||
px_hmac_finish(h, (uint8 *) VARDATA(res));
|
||||
px_hmac_free(h);
|
||||
|
||||
@@ -228,20 +228,20 @@ pg_encrypt(PG_FUNCTION_ARGS)
|
||||
klen,
|
||||
rlen;
|
||||
|
||||
type = PG_GETARG_TEXT_P(2);
|
||||
type = PG_GETARG_TEXT_PP(2);
|
||||
c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
dlen = VARSIZE(data) - VARHDRSZ;
|
||||
klen = VARSIZE(key) - VARHDRSZ;
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
dlen = VARSIZE_ANY_EXHDR(data);
|
||||
klen = VARSIZE_ANY_EXHDR(key);
|
||||
|
||||
rlen = px_combo_encrypt_len(c, dlen);
|
||||
res = palloc(VARHDRSZ + rlen);
|
||||
|
||||
err = px_combo_init(c, (uint8 *) VARDATA(key), klen, NULL, 0);
|
||||
err = px_combo_init(c, (uint8 *) VARDATA_ANY(key), klen, NULL, 0);
|
||||
if (!err)
|
||||
err = px_combo_encrypt(c, (uint8 *) VARDATA(data), dlen,
|
||||
err = px_combo_encrypt(c, (uint8 *) VARDATA_ANY(data), dlen,
|
||||
(uint8 *) VARDATA(res), &rlen);
|
||||
px_combo_free(c);
|
||||
|
||||
@@ -277,20 +277,20 @@ pg_decrypt(PG_FUNCTION_ARGS)
|
||||
klen,
|
||||
rlen;
|
||||
|
||||
type = PG_GETARG_TEXT_P(2);
|
||||
type = PG_GETARG_TEXT_PP(2);
|
||||
c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
dlen = VARSIZE(data) - VARHDRSZ;
|
||||
klen = VARSIZE(key) - VARHDRSZ;
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
dlen = VARSIZE_ANY_EXHDR(data);
|
||||
klen = VARSIZE_ANY_EXHDR(key);
|
||||
|
||||
rlen = px_combo_decrypt_len(c, dlen);
|
||||
res = palloc(VARHDRSZ + rlen);
|
||||
|
||||
err = px_combo_init(c, (uint8 *) VARDATA(key), klen, NULL, 0);
|
||||
err = px_combo_init(c, (uint8 *) VARDATA_ANY(key), klen, NULL, 0);
|
||||
if (!err)
|
||||
err = px_combo_decrypt(c, (uint8 *) VARDATA(data), dlen,
|
||||
err = px_combo_decrypt(c, (uint8 *) VARDATA_ANY(data), dlen,
|
||||
(uint8 *) VARDATA(res), &rlen);
|
||||
|
||||
px_combo_free(c);
|
||||
@@ -327,23 +327,23 @@ pg_encrypt_iv(PG_FUNCTION_ARGS)
|
||||
ivlen,
|
||||
rlen;
|
||||
|
||||
type = PG_GETARG_TEXT_P(3);
|
||||
type = PG_GETARG_TEXT_PP(3);
|
||||
c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
iv = PG_GETARG_BYTEA_P(2);
|
||||
dlen = VARSIZE(data) - VARHDRSZ;
|
||||
klen = VARSIZE(key) - VARHDRSZ;
|
||||
ivlen = VARSIZE(iv) - VARHDRSZ;
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
iv = PG_GETARG_BYTEA_PP(2);
|
||||
dlen = VARSIZE_ANY_EXHDR(data);
|
||||
klen = VARSIZE_ANY_EXHDR(key);
|
||||
ivlen = VARSIZE_ANY_EXHDR(iv);
|
||||
|
||||
rlen = px_combo_encrypt_len(c, dlen);
|
||||
res = palloc(VARHDRSZ + rlen);
|
||||
|
||||
err = px_combo_init(c, (uint8 *) VARDATA(key), klen,
|
||||
(uint8 *) VARDATA(iv), ivlen);
|
||||
err = px_combo_init(c, (uint8 *) VARDATA_ANY(key), klen,
|
||||
(uint8 *) VARDATA_ANY(iv), ivlen);
|
||||
if (!err)
|
||||
err = px_combo_encrypt(c, (uint8 *) VARDATA(data), dlen,
|
||||
err = px_combo_encrypt(c, (uint8 *) VARDATA_ANY(data), dlen,
|
||||
(uint8 *) VARDATA(res), &rlen);
|
||||
|
||||
px_combo_free(c);
|
||||
@@ -381,23 +381,23 @@ pg_decrypt_iv(PG_FUNCTION_ARGS)
|
||||
rlen,
|
||||
ivlen;
|
||||
|
||||
type = PG_GETARG_TEXT_P(3);
|
||||
type = PG_GETARG_TEXT_PP(3);
|
||||
c = find_provider(type, (PFN) px_find_combo, "Cipher", 0);
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
iv = PG_GETARG_BYTEA_P(2);
|
||||
dlen = VARSIZE(data) - VARHDRSZ;
|
||||
klen = VARSIZE(key) - VARHDRSZ;
|
||||
ivlen = VARSIZE(iv) - VARHDRSZ;
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
iv = PG_GETARG_BYTEA_PP(2);
|
||||
dlen = VARSIZE_ANY_EXHDR(data);
|
||||
klen = VARSIZE_ANY_EXHDR(key);
|
||||
ivlen = VARSIZE_ANY_EXHDR(iv);
|
||||
|
||||
rlen = px_combo_decrypt_len(c, dlen);
|
||||
res = palloc(VARHDRSZ + rlen);
|
||||
|
||||
err = px_combo_init(c, (uint8 *) VARDATA(key), klen,
|
||||
(uint8 *) VARDATA(iv), ivlen);
|
||||
err = px_combo_init(c, (uint8 *) VARDATA_ANY(key), klen,
|
||||
(uint8 *) VARDATA_ANY(iv), ivlen);
|
||||
if (!err)
|
||||
err = px_combo_decrypt(c, (uint8 *) VARDATA(data), dlen,
|
||||
err = px_combo_decrypt(c, (uint8 *) VARDATA_ANY(data), dlen,
|
||||
(uint8 *) VARDATA(res), &rlen);
|
||||
|
||||
px_combo_free(c);
|
||||
@@ -480,8 +480,8 @@ find_provider(text *name,
|
||||
char *buf;
|
||||
int err;
|
||||
|
||||
buf = downcase_truncate_identifier(VARDATA(name),
|
||||
VARSIZE(name) - VARHDRSZ,
|
||||
buf = downcase_truncate_identifier(VARDATA_ANY(name),
|
||||
VARSIZE_ANY_EXHDR(name),
|
||||
false);
|
||||
|
||||
err = provider_lookup(buf, &res);
|
||||
|
@@ -67,9 +67,9 @@ PG_FUNCTION_INFO_V1(pgp_armor_headers);
|
||||
static text *
|
||||
convert_charset(text *src, int cset_from, int cset_to)
|
||||
{
|
||||
int src_len = VARSIZE(src) - VARHDRSZ;
|
||||
int src_len = VARSIZE_ANY_EXHDR(src);
|
||||
unsigned char *dst;
|
||||
unsigned char *csrc = (unsigned char *) VARDATA(src);
|
||||
unsigned char *csrc = (unsigned char *) VARDATA_ANY(src);
|
||||
text *res;
|
||||
|
||||
dst = pg_do_encoding_conversion(csrc, src_len, cset_from, cset_to);
|
||||
@@ -109,7 +109,7 @@ string_is_ascii(const char *str)
|
||||
static void
|
||||
clear_and_pfree(text *p)
|
||||
{
|
||||
px_memset(p, 0, VARSIZE(p));
|
||||
px_memset(p, 0, VARSIZE_ANY(p));
|
||||
pfree(p);
|
||||
}
|
||||
|
||||
@@ -356,8 +356,8 @@ parse_args(PGP_Context *ctx, uint8 *args, int arg_len,
|
||||
static MBuf *
|
||||
create_mbuf_from_vardata(text *data)
|
||||
{
|
||||
return mbuf_create_from_data((uint8 *) VARDATA(data),
|
||||
VARSIZE(data) - VARHDRSZ);
|
||||
return mbuf_create_from_data((uint8 *) VARDATA_ANY(data),
|
||||
VARSIZE_ANY_EXHDR(data));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -369,8 +369,8 @@ init_work(PGP_Context **ctx_p, int is_text,
|
||||
fill_expect(ex, is_text);
|
||||
|
||||
if (err == 0 && args != NULL)
|
||||
err = parse_args(*ctx_p, (uint8 *) VARDATA(args),
|
||||
VARSIZE(args) - VARHDRSZ, ex);
|
||||
err = parse_args(*ctx_p, (uint8 *) VARDATA_ANY(args),
|
||||
VARSIZE_ANY_EXHDR(args), ex);
|
||||
|
||||
if (err)
|
||||
px_THROW_ERROR(err);
|
||||
@@ -408,7 +408,7 @@ encrypt_internal(int is_pubenc, int is_text,
|
||||
}
|
||||
|
||||
src = create_mbuf_from_vardata(data);
|
||||
dst = mbuf_create(VARSIZE(data) + 128);
|
||||
dst = mbuf_create(VARSIZE_ANY(data) + 128);
|
||||
|
||||
/*
|
||||
* reserve room for header
|
||||
@@ -427,8 +427,8 @@ encrypt_internal(int is_pubenc, int is_text,
|
||||
mbuf_free(kbuf);
|
||||
}
|
||||
else
|
||||
err = pgp_set_symkey(ctx, (uint8 *) VARDATA(key),
|
||||
VARSIZE(key) - VARHDRSZ);
|
||||
err = pgp_set_symkey(ctx, (uint8 *) VARDATA_ANY(key),
|
||||
VARSIZE_ANY_EXHDR(key));
|
||||
|
||||
/*
|
||||
* encrypt
|
||||
@@ -485,9 +485,9 @@ decrypt_internal(int is_pubenc, int need_text, text *data,
|
||||
|
||||
init_work(&ctx, need_text, args, &ex);
|
||||
|
||||
src = mbuf_create_from_data((uint8 *) VARDATA(data),
|
||||
VARSIZE(data) - VARHDRSZ);
|
||||
dst = mbuf_create(VARSIZE(data) + 2048);
|
||||
src = mbuf_create_from_data((uint8 *) VARDATA_ANY(data),
|
||||
VARSIZE_ANY_EXHDR(data));
|
||||
dst = mbuf_create(VARSIZE_ANY(data) + 2048);
|
||||
|
||||
/*
|
||||
* reserve room for header
|
||||
@@ -505,16 +505,16 @@ decrypt_internal(int is_pubenc, int need_text, text *data,
|
||||
|
||||
if (keypsw)
|
||||
{
|
||||
psw = (uint8 *) VARDATA(keypsw);
|
||||
psw_len = VARSIZE(keypsw) - VARHDRSZ;
|
||||
psw = (uint8 *) VARDATA_ANY(keypsw);
|
||||
psw_len = VARSIZE_ANY_EXHDR(keypsw);
|
||||
}
|
||||
kbuf = create_mbuf_from_vardata(key);
|
||||
err = pgp_set_pubkey(ctx, kbuf, psw, psw_len, 1);
|
||||
mbuf_free(kbuf);
|
||||
}
|
||||
else
|
||||
err = pgp_set_symkey(ctx, (uint8 *) VARDATA(key),
|
||||
VARSIZE(key) - VARHDRSZ);
|
||||
err = pgp_set_symkey(ctx, (uint8 *) VARDATA_ANY(key),
|
||||
VARSIZE_ANY_EXHDR(key));
|
||||
|
||||
/* decrypt */
|
||||
if (err >= 0)
|
||||
@@ -571,10 +571,10 @@ pgp_sym_encrypt_bytea(PG_FUNCTION_ARGS)
|
||||
text *arg = NULL;
|
||||
text *res;
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
if (PG_NARGS() > 2)
|
||||
arg = PG_GETARG_BYTEA_P(2);
|
||||
arg = PG_GETARG_BYTEA_PP(2);
|
||||
|
||||
res = encrypt_internal(0, 0, data, key, arg);
|
||||
|
||||
@@ -593,10 +593,10 @@ pgp_sym_encrypt_text(PG_FUNCTION_ARGS)
|
||||
text *arg = NULL;
|
||||
text *res;
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
if (PG_NARGS() > 2)
|
||||
arg = PG_GETARG_BYTEA_P(2);
|
||||
arg = PG_GETARG_BYTEA_PP(2);
|
||||
|
||||
res = encrypt_internal(0, 1, data, key, arg);
|
||||
|
||||
@@ -616,10 +616,10 @@ pgp_sym_decrypt_bytea(PG_FUNCTION_ARGS)
|
||||
text *arg = NULL;
|
||||
text *res;
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
if (PG_NARGS() > 2)
|
||||
arg = PG_GETARG_BYTEA_P(2);
|
||||
arg = PG_GETARG_BYTEA_PP(2);
|
||||
|
||||
res = decrypt_internal(0, 0, data, key, NULL, arg);
|
||||
|
||||
@@ -638,10 +638,10 @@ pgp_sym_decrypt_text(PG_FUNCTION_ARGS)
|
||||
text *arg = NULL;
|
||||
text *res;
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
if (PG_NARGS() > 2)
|
||||
arg = PG_GETARG_BYTEA_P(2);
|
||||
arg = PG_GETARG_BYTEA_PP(2);
|
||||
|
||||
res = decrypt_internal(0, 1, data, key, NULL, arg);
|
||||
|
||||
@@ -664,10 +664,10 @@ pgp_pub_encrypt_bytea(PG_FUNCTION_ARGS)
|
||||
text *arg = NULL;
|
||||
text *res;
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
if (PG_NARGS() > 2)
|
||||
arg = PG_GETARG_BYTEA_P(2);
|
||||
arg = PG_GETARG_BYTEA_PP(2);
|
||||
|
||||
res = encrypt_internal(1, 0, data, key, arg);
|
||||
|
||||
@@ -686,10 +686,10 @@ pgp_pub_encrypt_text(PG_FUNCTION_ARGS)
|
||||
text *arg = NULL;
|
||||
text *res;
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
if (PG_NARGS() > 2)
|
||||
arg = PG_GETARG_BYTEA_P(2);
|
||||
arg = PG_GETARG_BYTEA_PP(2);
|
||||
|
||||
res = encrypt_internal(1, 1, data, key, arg);
|
||||
|
||||
@@ -710,12 +710,12 @@ pgp_pub_decrypt_bytea(PG_FUNCTION_ARGS)
|
||||
*arg = NULL;
|
||||
text *res;
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
if (PG_NARGS() > 2)
|
||||
psw = PG_GETARG_BYTEA_P(2);
|
||||
psw = PG_GETARG_BYTEA_PP(2);
|
||||
if (PG_NARGS() > 3)
|
||||
arg = PG_GETARG_BYTEA_P(3);
|
||||
arg = PG_GETARG_BYTEA_PP(3);
|
||||
|
||||
res = decrypt_internal(1, 0, data, key, psw, arg);
|
||||
|
||||
@@ -737,12 +737,12 @@ pgp_pub_decrypt_text(PG_FUNCTION_ARGS)
|
||||
*arg = NULL;
|
||||
text *res;
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
key = PG_GETARG_BYTEA_P(1);
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
key = PG_GETARG_BYTEA_PP(1);
|
||||
if (PG_NARGS() > 2)
|
||||
psw = PG_GETARG_BYTEA_P(2);
|
||||
psw = PG_GETARG_BYTEA_PP(2);
|
||||
if (PG_NARGS() > 3)
|
||||
arg = PG_GETARG_BYTEA_P(3);
|
||||
arg = PG_GETARG_BYTEA_PP(3);
|
||||
|
||||
res = decrypt_internal(1, 1, data, key, psw, arg);
|
||||
|
||||
@@ -865,8 +865,8 @@ pg_armor(PG_FUNCTION_ARGS)
|
||||
char **keys = NULL,
|
||||
**values = NULL;
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
data_len = VARSIZE(data) - VARHDRSZ;
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
data_len = VARSIZE_ANY_EXHDR(data);
|
||||
if (PG_NARGS() == 3)
|
||||
{
|
||||
num_headers = parse_key_value_arrays(PG_GETARG_ARRAYTYPE_P(1),
|
||||
@@ -880,7 +880,7 @@ pg_armor(PG_FUNCTION_ARGS)
|
||||
|
||||
initStringInfo(&buf);
|
||||
|
||||
pgp_armor_encode((uint8 *) VARDATA(data), data_len, &buf,
|
||||
pgp_armor_encode((uint8 *) VARDATA_ANY(data), data_len, &buf,
|
||||
num_headers, keys, values);
|
||||
|
||||
res = palloc(VARHDRSZ + buf.len);
|
||||
@@ -901,12 +901,12 @@ pg_dearmor(PG_FUNCTION_ARGS)
|
||||
int ret;
|
||||
StringInfoData buf;
|
||||
|
||||
data = PG_GETARG_TEXT_P(0);
|
||||
data_len = VARSIZE(data) - VARHDRSZ;
|
||||
data = PG_GETARG_TEXT_PP(0);
|
||||
data_len = VARSIZE_ANY_EXHDR(data);
|
||||
|
||||
initStringInfo(&buf);
|
||||
|
||||
ret = pgp_armor_decode((uint8 *) VARDATA(data), data_len, &buf);
|
||||
ret = pgp_armor_decode((uint8 *) VARDATA_ANY(data), data_len, &buf);
|
||||
if (ret < 0)
|
||||
px_THROW_ERROR(ret);
|
||||
res = palloc(VARHDRSZ + buf.len);
|
||||
@@ -1004,7 +1004,7 @@ pgp_key_id_w(PG_FUNCTION_ARGS)
|
||||
int res_len;
|
||||
MBuf *buf;
|
||||
|
||||
data = PG_GETARG_BYTEA_P(0);
|
||||
data = PG_GETARG_BYTEA_PP(0);
|
||||
buf = create_mbuf_from_vardata(data);
|
||||
res = palloc(VARHDRSZ + 17);
|
||||
|
||||
|
@@ -94,7 +94,7 @@ pgrowlocks(PG_FUNCTION_ARGS)
|
||||
attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
||||
funcctx->attinmeta = attinmeta;
|
||||
|
||||
relname = PG_GETARG_TEXT_P(0);
|
||||
relname = PG_GETARG_TEXT_PP(0);
|
||||
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
|
||||
rel = heap_openrv(relrv, AccessShareLock);
|
||||
|
||||
|
@@ -143,7 +143,7 @@ static void check_relation_relkind(Relation rel);
|
||||
Datum
|
||||
pgstatindex(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
Relation rel;
|
||||
RangeVar *relrv;
|
||||
|
||||
@@ -168,7 +168,7 @@ pgstatindex(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
pgstatindex_v1_5(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
Relation rel;
|
||||
RangeVar *relrv;
|
||||
|
||||
@@ -377,7 +377,7 @@ pgstatindex_impl(Relation rel, FunctionCallInfo fcinfo)
|
||||
Datum
|
||||
pg_relpages(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
int64 relpages;
|
||||
Relation rel;
|
||||
RangeVar *relrv;
|
||||
@@ -406,7 +406,7 @@ pg_relpages(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
pg_relpages_v1_5(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
int64 relpages;
|
||||
Relation rel;
|
||||
RangeVar *relrv;
|
||||
|
@@ -165,7 +165,7 @@ build_pgstattuple_type(pgstattuple_type *stat, FunctionCallInfo fcinfo)
|
||||
Datum
|
||||
pgstattuple(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
RangeVar *relrv;
|
||||
Relation rel;
|
||||
|
||||
@@ -191,7 +191,7 @@ pgstattuple(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
pgstattuple_v1_5(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *relname = PG_GETARG_TEXT_P(0);
|
||||
text *relname = PG_GETARG_TEXT_PP(0);
|
||||
RangeVar *relrv;
|
||||
Relation rel;
|
||||
|
||||
|
@@ -590,7 +590,7 @@ PG_FUNCTION_INFO_V1(sepgsql_mcstrans_in);
|
||||
Datum
|
||||
sepgsql_mcstrans_in(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *label = PG_GETARG_TEXT_P(0);
|
||||
text *label = PG_GETARG_TEXT_PP(0);
|
||||
char *raw_label;
|
||||
char *result;
|
||||
|
||||
@@ -630,7 +630,7 @@ PG_FUNCTION_INFO_V1(sepgsql_mcstrans_out);
|
||||
Datum
|
||||
sepgsql_mcstrans_out(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *label = PG_GETARG_TEXT_P(0);
|
||||
text *label = PG_GETARG_TEXT_PP(0);
|
||||
char *qual_label;
|
||||
char *result;
|
||||
|
||||
|
@@ -106,7 +106,7 @@ autoinc(PG_FUNCTION_ARGS)
|
||||
newvals[chnattrs] = Int32GetDatum((int32) DatumGetInt64(newvals[chnattrs]));
|
||||
}
|
||||
newnulls[chnattrs] = false;
|
||||
pfree(DatumGetTextP(seqname));
|
||||
pfree(DatumGetTextPP(seqname));
|
||||
chnattrs++;
|
||||
i++;
|
||||
}
|
||||
|
@@ -225,7 +225,7 @@ PG_FUNCTION_INFO_V1(ssl_client_dn_field);
|
||||
Datum
|
||||
ssl_client_dn_field(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *fieldname = PG_GETARG_TEXT_P(0);
|
||||
text *fieldname = PG_GETARG_TEXT_PP(0);
|
||||
Datum result;
|
||||
|
||||
if (!(MyProcPort->peer))
|
||||
@@ -260,7 +260,7 @@ PG_FUNCTION_INFO_V1(ssl_issuer_field);
|
||||
Datum
|
||||
ssl_issuer_field(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *fieldname = PG_GETARG_TEXT_P(0);
|
||||
text *fieldname = PG_GETARG_TEXT_PP(0);
|
||||
Datum result;
|
||||
|
||||
if (!(MyProcPort->peer))
|
||||
|
@@ -384,14 +384,14 @@ unaccent_dict(PG_FUNCTION_ARGS)
|
||||
dictOid = PG_GETARG_OID(0);
|
||||
strArg = 1;
|
||||
}
|
||||
str = PG_GETARG_TEXT_P(strArg);
|
||||
str = PG_GETARG_TEXT_PP(strArg);
|
||||
|
||||
dict = lookup_ts_dictionary_cache(dictOid);
|
||||
|
||||
res = (TSLexeme *) DatumGetPointer(FunctionCall4(&(dict->lexize),
|
||||
PointerGetDatum(dict->dictData),
|
||||
PointerGetDatum(VARDATA(str)),
|
||||
Int32GetDatum(VARSIZE(str) - VARHDRSZ),
|
||||
PointerGetDatum(VARDATA_ANY(str)),
|
||||
Int32GetDatum(VARSIZE_ANY_EXHDR(str)),
|
||||
PointerGetDatum(NULL)));
|
||||
|
||||
PG_FREE_IF_COPY(str, strArg);
|
||||
|
@@ -503,13 +503,13 @@ Datum
|
||||
uuid_generate_v3(PG_FUNCTION_ARGS)
|
||||
{
|
||||
pg_uuid_t *ns = PG_GETARG_UUID_P(0);
|
||||
text *name = PG_GETARG_TEXT_P(1);
|
||||
text *name = PG_GETARG_TEXT_PP(1);
|
||||
|
||||
#ifdef HAVE_UUID_OSSP
|
||||
return uuid_generate_v35_internal(UUID_MAKE_V3, ns, name);
|
||||
#else
|
||||
return uuid_generate_internal(UUID_MAKE_V3, (unsigned char *) ns,
|
||||
VARDATA(name), VARSIZE(name) - VARHDRSZ);
|
||||
VARDATA_ANY(name), VARSIZE_ANY_EXHDR(name));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -525,12 +525,12 @@ Datum
|
||||
uuid_generate_v5(PG_FUNCTION_ARGS)
|
||||
{
|
||||
pg_uuid_t *ns = PG_GETARG_UUID_P(0);
|
||||
text *name = PG_GETARG_TEXT_P(1);
|
||||
text *name = PG_GETARG_TEXT_PP(1);
|
||||
|
||||
#ifdef HAVE_UUID_OSSP
|
||||
return uuid_generate_v35_internal(UUID_MAKE_V5, ns, name);
|
||||
#else
|
||||
return uuid_generate_internal(UUID_MAKE_V5, (unsigned char *) ns,
|
||||
VARDATA(name), VARSIZE(name) - VARHDRSZ);
|
||||
VARDATA_ANY(name), VARSIZE_ANY_EXHDR(name));
|
||||
#endif
|
||||
}
|
||||
|
@@ -95,9 +95,9 @@ PG_FUNCTION_INFO_V1(xml_is_well_formed);
|
||||
Datum
|
||||
xml_is_well_formed(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *t = PG_GETARG_TEXT_P(0); /* document buffer */
|
||||
text *t = PG_GETARG_TEXT_PP(0); /* document buffer */
|
||||
bool result = false;
|
||||
int32 docsize = VARSIZE(t) - VARHDRSZ;
|
||||
int32 docsize = VARSIZE_ANY_EXHDR(t);
|
||||
xmlDocPtr doctree;
|
||||
PgXmlErrorContext *xmlerrcxt;
|
||||
|
||||
@@ -105,7 +105,7 @@ xml_is_well_formed(PG_FUNCTION_ARGS)
|
||||
|
||||
PG_TRY();
|
||||
{
|
||||
doctree = xmlParseMemory((char *) VARDATA(t), docsize);
|
||||
doctree = xmlParseMemory((char *) VARDATA_ANY(t), docsize);
|
||||
|
||||
result = (doctree != NULL);
|
||||
|
||||
@@ -133,7 +133,7 @@ PG_FUNCTION_INFO_V1(xml_encode_special_chars);
|
||||
Datum
|
||||
xml_encode_special_chars(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *tin = PG_GETARG_TEXT_P(0);
|
||||
text *tin = PG_GETARG_TEXT_PP(0);
|
||||
text *tout;
|
||||
xmlChar *ts,
|
||||
*tt;
|
||||
@@ -248,10 +248,10 @@ PG_FUNCTION_INFO_V1(xpath_nodeset);
|
||||
Datum
|
||||
xpath_nodeset(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *document = PG_GETARG_TEXT_P(0);
|
||||
text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
|
||||
xmlChar *toptag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(2));
|
||||
xmlChar *septag = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(3));
|
||||
text *document = PG_GETARG_TEXT_PP(0);
|
||||
text *xpathsupp = PG_GETARG_TEXT_PP(1); /* XPath expression */
|
||||
xmlChar *toptag = pgxml_texttoxmlchar(PG_GETARG_TEXT_PP(2));
|
||||
xmlChar *septag = pgxml_texttoxmlchar(PG_GETARG_TEXT_PP(3));
|
||||
xmlChar *xpath;
|
||||
text *xpres;
|
||||
xmlXPathObjectPtr res;
|
||||
@@ -281,9 +281,9 @@ PG_FUNCTION_INFO_V1(xpath_list);
|
||||
Datum
|
||||
xpath_list(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *document = PG_GETARG_TEXT_P(0);
|
||||
text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
|
||||
xmlChar *plainsep = pgxml_texttoxmlchar(PG_GETARG_TEXT_P(2));
|
||||
text *document = PG_GETARG_TEXT_PP(0);
|
||||
text *xpathsupp = PG_GETARG_TEXT_PP(1); /* XPath expression */
|
||||
xmlChar *plainsep = pgxml_texttoxmlchar(PG_GETARG_TEXT_PP(2));
|
||||
xmlChar *xpath;
|
||||
text *xpres;
|
||||
xmlXPathObjectPtr res;
|
||||
@@ -310,15 +310,15 @@ PG_FUNCTION_INFO_V1(xpath_string);
|
||||
Datum
|
||||
xpath_string(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *document = PG_GETARG_TEXT_P(0);
|
||||
text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
|
||||
text *document = PG_GETARG_TEXT_PP(0);
|
||||
text *xpathsupp = PG_GETARG_TEXT_PP(1); /* XPath expression */
|
||||
xmlChar *xpath;
|
||||
int32 pathsize;
|
||||
text *xpres;
|
||||
xmlXPathObjectPtr res;
|
||||
xpath_workspace workspace;
|
||||
|
||||
pathsize = VARSIZE(xpathsupp) - VARHDRSZ;
|
||||
pathsize = VARSIZE_ANY_EXHDR(xpathsupp);
|
||||
|
||||
/*
|
||||
* We encapsulate the supplied path with "string()" = 8 chars + 1 for NUL
|
||||
@@ -328,7 +328,7 @@ xpath_string(PG_FUNCTION_ARGS)
|
||||
|
||||
xpath = (xmlChar *) palloc(pathsize + 9);
|
||||
memcpy((char *) xpath, "string(", 7);
|
||||
memcpy((char *) (xpath + 7), VARDATA(xpathsupp), pathsize);
|
||||
memcpy((char *) (xpath + 7), VARDATA_ANY(xpathsupp), pathsize);
|
||||
xpath[pathsize + 7] = ')';
|
||||
xpath[pathsize + 8] = '\0';
|
||||
|
||||
@@ -351,8 +351,8 @@ PG_FUNCTION_INFO_V1(xpath_number);
|
||||
Datum
|
||||
xpath_number(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *document = PG_GETARG_TEXT_P(0);
|
||||
text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
|
||||
text *document = PG_GETARG_TEXT_PP(0);
|
||||
text *xpathsupp = PG_GETARG_TEXT_PP(1); /* XPath expression */
|
||||
xmlChar *xpath;
|
||||
float4 fRes;
|
||||
xmlXPathObjectPtr res;
|
||||
@@ -383,8 +383,8 @@ PG_FUNCTION_INFO_V1(xpath_bool);
|
||||
Datum
|
||||
xpath_bool(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *document = PG_GETARG_TEXT_P(0);
|
||||
text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */
|
||||
text *document = PG_GETARG_TEXT_PP(0);
|
||||
text *xpathsupp = PG_GETARG_TEXT_PP(1); /* XPath expression */
|
||||
xmlChar *xpath;
|
||||
int bRes;
|
||||
xmlXPathObjectPtr res;
|
||||
@@ -413,7 +413,7 @@ xpath_bool(PG_FUNCTION_ARGS)
|
||||
static xmlXPathObjectPtr
|
||||
pgxml_xpath(text *document, xmlChar *xpath, xpath_workspace *workspace)
|
||||
{
|
||||
int32 docsize = VARSIZE(document) - VARHDRSZ;
|
||||
int32 docsize = VARSIZE_ANY_EXHDR(document);
|
||||
PgXmlErrorContext *xmlerrcxt;
|
||||
xmlXPathCompExprPtr comppath;
|
||||
|
||||
@@ -425,7 +425,7 @@ pgxml_xpath(text *document, xmlChar *xpath, xpath_workspace *workspace)
|
||||
|
||||
PG_TRY();
|
||||
{
|
||||
workspace->doctree = xmlParseMemory((char *) VARDATA(document),
|
||||
workspace->doctree = xmlParseMemory((char *) VARDATA_ANY(document),
|
||||
docsize);
|
||||
if (workspace->doctree != NULL)
|
||||
{
|
||||
|
@@ -49,8 +49,8 @@ xslt_process(PG_FUNCTION_ARGS)
|
||||
{
|
||||
#ifdef USE_LIBXSLT
|
||||
|
||||
text *doct = PG_GETARG_TEXT_P(0);
|
||||
text *ssheet = PG_GETARG_TEXT_P(1);
|
||||
text *doct = PG_GETARG_TEXT_PP(0);
|
||||
text *ssheet = PG_GETARG_TEXT_PP(1);
|
||||
text *result;
|
||||
text *paramstr;
|
||||
const char **params;
|
||||
@@ -66,7 +66,7 @@ xslt_process(PG_FUNCTION_ARGS)
|
||||
|
||||
if (fcinfo->nargs == 3)
|
||||
{
|
||||
paramstr = PG_GETARG_TEXT_P(2);
|
||||
paramstr = PG_GETARG_TEXT_PP(2);
|
||||
params = parse_params(paramstr);
|
||||
}
|
||||
else
|
||||
@@ -85,16 +85,16 @@ xslt_process(PG_FUNCTION_ARGS)
|
||||
bool xslt_sec_prefs_error;
|
||||
|
||||
/* Parse document */
|
||||
doctree = xmlParseMemory((char *) VARDATA(doct),
|
||||
VARSIZE(doct) - VARHDRSZ);
|
||||
doctree = xmlParseMemory((char *) VARDATA_ANY(doct),
|
||||
VARSIZE_ANY_EXHDR(doct));
|
||||
|
||||
if (doctree == NULL)
|
||||
xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION,
|
||||
"error parsing XML document");
|
||||
|
||||
/* Same for stylesheet */
|
||||
ssdoc = xmlParseMemory((char *) VARDATA(ssheet),
|
||||
VARSIZE(ssheet) - VARHDRSZ);
|
||||
ssdoc = xmlParseMemory((char *) VARDATA_ANY(ssheet),
|
||||
VARSIZE_ANY_EXHDR(ssheet));
|
||||
|
||||
if (ssdoc == NULL)
|
||||
xml_ereport(xmlerrcxt, ERROR, ERRCODE_EXTERNAL_ROUTINE_EXCEPTION,
|
||||
|
Reference in New Issue
Block a user