diff options
Diffstat (limited to 'src/backend/utils/adt/encode.c')
-rw-r--r-- | src/backend/utils/adt/encode.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/backend/utils/adt/encode.c b/src/backend/utils/adt/encode.c index 027f28eb623..8fd8ede39e5 100644 --- a/src/backend/utils/adt/encode.c +++ b/src/backend/utils/adt/encode.c @@ -35,7 +35,7 @@ static const struct pg_encoding *pg_find_encoding(const char *name); Datum binary_encode(PG_FUNCTION_ARGS) { - bytea *data = PG_GETARG_BYTEA_P(0); + bytea *data = PG_GETARG_BYTEA_PP(0); Datum name = PG_GETARG_DATUM(1); text *result; char *namebuf; @@ -44,7 +44,7 @@ binary_encode(PG_FUNCTION_ARGS) res; const struct pg_encoding *enc; - datalen = VARSIZE(data) - VARHDRSZ; + datalen = VARSIZE_ANY_EXHDR(data); namebuf = TextDatumGetCString(name); @@ -54,10 +54,10 @@ binary_encode(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unrecognized encoding: \"%s\"", namebuf))); - resultlen = enc->encode_len(VARDATA(data), datalen); + resultlen = enc->encode_len(VARDATA_ANY(data), datalen); result = palloc(VARHDRSZ + resultlen); - res = enc->encode(VARDATA(data), datalen, VARDATA(result)); + res = enc->encode(VARDATA_ANY(data), datalen, VARDATA(result)); /* Make this FATAL 'cause we've trodden on memory ... */ if (res > resultlen) @@ -71,7 +71,7 @@ binary_encode(PG_FUNCTION_ARGS) Datum binary_decode(PG_FUNCTION_ARGS) { - text *data = PG_GETARG_TEXT_P(0); + text *data = PG_GETARG_TEXT_PP(0); Datum name = PG_GETARG_DATUM(1); bytea *result; char *namebuf; @@ -80,7 +80,7 @@ binary_decode(PG_FUNCTION_ARGS) res; const struct pg_encoding *enc; - datalen = VARSIZE(data) - VARHDRSZ; + datalen = VARSIZE_ANY_EXHDR(data); namebuf = TextDatumGetCString(name); @@ -90,10 +90,10 @@ binary_decode(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unrecognized encoding: \"%s\"", namebuf))); - resultlen = enc->decode_len(VARDATA(data), datalen); + resultlen = enc->decode_len(VARDATA_ANY(data), datalen); result = palloc(VARHDRSZ + resultlen); - res = enc->decode(VARDATA(data), datalen, VARDATA(result)); + res = enc->decode(VARDATA_ANY(data), datalen, VARDATA(result)); /* Make this FATAL 'cause we've trodden on memory ... */ if (res > resultlen) |