From ef607093d6ed72cb9b6198403f8c9fb03fb969f1 Mon Sep 17 00:00:00 2001 From: Shinya Kato Date: Tue, 1 Dec 2026 10:41:55 +0900 Subject: [PATCH v2 4/4] Convert built-in send functions to write into the caller's buffer Convert the send functions of the built-in data types from pq_begintypsend() and pq_endtypsend() to pq_begintypsend_fcinfo() and pq_endtypsend_fcinfo(). When called through SendFunctionCallInto(), as printtup, COPY TO and the container types now do, they append to the caller's buffer instead of allocating a bytea per value. The aggregate serialization functions keep using pq_begintypsend(), since they are not called through SendFunctionCallInto(). Author: Andres Freund Author: Shinya Kato Discussion: https://postgr.es/m/20240218015955.rmw5mcmobt5hbene@awork3.anarazel.de Discussion: https://postgr.es/m/CAOzEurReWaX8i72CBbBzYZzNSP=XRQdp1=cB+rYhir1CB9DUUg@mail.gmail.com --- src/backend/utils/adt/arrayfuncs.c | 20 +++--- src/backend/utils/adt/bool.c | 8 +-- src/backend/utils/adt/cash.c | 8 +-- src/backend/utils/adt/char.c | 8 +-- src/backend/utils/adt/date.c | 26 ++++---- src/backend/utils/adt/enum.c | 8 +-- src/backend/utils/adt/float.c | 16 ++--- src/backend/utils/adt/geo_ops.c | 88 ++++++++++++------------- src/backend/utils/adt/int.c | 16 ++--- src/backend/utils/adt/int8.c | 8 +-- src/backend/utils/adt/json.c | 8 +-- src/backend/utils/adt/jsonb.c | 10 +-- src/backend/utils/adt/jsonpath.c | 10 +-- src/backend/utils/adt/mac.c | 20 +++--- src/backend/utils/adt/mac8.c | 26 ++++---- src/backend/utils/adt/multirangetypes.c | 10 +-- src/backend/utils/adt/name.c | 8 +-- src/backend/utils/adt/network.c | 22 +++---- src/backend/utils/adt/numeric.c | 16 ++--- src/backend/utils/adt/oid.c | 8 +-- src/backend/utils/adt/oid8.c | 8 +-- src/backend/utils/adt/pg_lsn.c | 8 +-- src/backend/utils/adt/pseudotypes.c | 14 ++-- src/backend/utils/adt/rangetypes.c | 12 ++-- src/backend/utils/adt/rowtypes.c | 14 ++-- src/backend/utils/adt/tid.c | 10 +-- src/backend/utils/adt/timestamp.c | 28 ++++---- src/backend/utils/adt/tsquery.c | 20 +++--- src/backend/utils/adt/tsvector.c | 16 ++--- src/backend/utils/adt/uuid.c | 8 +-- src/backend/utils/adt/varbit.c | 10 +-- src/backend/utils/adt/varlena.c | 16 ++--- src/backend/utils/adt/xid.c | 24 +++---- src/backend/utils/adt/xid8funcs.c | 14 ++-- src/backend/utils/adt/xml.c | 8 +-- 35 files changed, 277 insertions(+), 277 deletions(-) diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 3c25a9b5da7..5289c1b4524 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -1557,7 +1557,7 @@ array_send(PG_FUNCTION_ARGS) int ndim, *dim, *lb; - StringInfoData buf; + StringInfo buf; array_iter iter; ArrayMetaState *my_extra; @@ -1600,16 +1600,16 @@ array_send(PG_FUNCTION_ARGS) lb = AARR_LBOUND(v); nitems = ArrayGetNItems(ndim, dim); - pq_begintypsend(&buf); + buf = pq_begintypsend_fcinfo(fcinfo); /* Send the array header information */ - pq_sendint32(&buf, ndim); - pq_sendint32(&buf, AARR_HASNULL(v) ? 1 : 0); - pq_sendint32(&buf, element_type); + pq_sendint32(buf, ndim); + pq_sendint32(buf, AARR_HASNULL(v) ? 1 : 0); + pq_sendint32(buf, element_type); for (i = 0; i < ndim; i++) { - pq_sendint32(&buf, dim[i]); - pq_sendint32(&buf, lb[i]); + pq_sendint32(buf, dim[i]); + pq_sendint32(buf, lb[i]); } /* Send the array elements using the element's own sendproc */ @@ -1626,13 +1626,13 @@ array_send(PG_FUNCTION_ARGS) if (isnull) { /* -1 length means a NULL */ - pq_sendint32(&buf, -1); + pq_sendint32(buf, -1); } else - SendFunctionCallInto(&my_extra->proc, itemvalue, &buf); + SendFunctionCallInto(&my_extra->proc, itemvalue, buf); } - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/bool.c b/src/backend/utils/adt/bool.c index 090ad7df9ca..c89f74360e2 100644 --- a/src/backend/utils/adt/bool.c +++ b/src/backend/utils/adt/bool.c @@ -188,11 +188,11 @@ Datum boolsend(PG_FUNCTION_ARGS) { bool arg1 = PG_GETARG_BOOL(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendbyte(&buf, arg1 ? 1 : 0); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendbyte(buf, arg1 ? 1 : 0); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 0820187b8e6..775aaa4faae 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -623,11 +623,11 @@ Datum cash_send(PG_FUNCTION_ARGS) { Cash arg1 = PG_GETARG_CASH(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint64(&buf, arg1); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint64(buf, arg1); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/char.c b/src/backend/utils/adt/char.c index 698863924ee..23f6118fd2c 100644 --- a/src/backend/utils/adt/char.c +++ b/src/backend/utils/adt/char.c @@ -105,11 +105,11 @@ Datum charsend(PG_FUNCTION_ARGS) { char arg1 = PG_GETARG_CHAR(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendbyte(&buf, arg1); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendbyte(buf, arg1); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /***************************************************************************** diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 7f746dd84c9..cb274c4f22d 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -227,11 +227,11 @@ Datum date_send(PG_FUNCTION_ARGS) { DateADT date = PG_GETARG_DATEADT(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint32(&buf, date); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint32(buf, date); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* @@ -1652,11 +1652,11 @@ Datum time_send(PG_FUNCTION_ARGS) { TimeADT time = PG_GETARG_TIMEADT(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint64(&buf, time); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint64(buf, time); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } Datum @@ -2490,12 +2490,12 @@ Datum timetz_send(PG_FUNCTION_ARGS) { TimeTzADT *time = PG_GETARG_TIMETZADT_P(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint64(&buf, time->time); - pq_sendint32(&buf, time->zone); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint64(buf, time->time); + pq_sendint32(buf, time->zone); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } Datum diff --git a/src/backend/utils/adt/enum.c b/src/backend/utils/adt/enum.c index 9b87373e0e9..80b90adc4c9 100644 --- a/src/backend/utils/adt/enum.c +++ b/src/backend/utils/adt/enum.c @@ -221,7 +221,7 @@ Datum enum_send(PG_FUNCTION_ARGS) { Oid enumval = PG_GETARG_OID(0); - StringInfoData buf; + StringInfo buf; HeapTuple tup; Form_pg_enum en; @@ -233,12 +233,12 @@ enum_send(PG_FUNCTION_ARGS) enumval))); en = (Form_pg_enum) GETSTRUCT(tup); - pq_begintypsend(&buf); - pq_sendtext(&buf, NameStr(en->enumlabel), strlen(NameStr(en->enumlabel))); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendtext(buf, NameStr(en->enumlabel), strlen(NameStr(en->enumlabel))); ReleaseSysCache(tup); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* Comparison functions and related */ diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 49ce8c1bd6d..b53d4bbaafe 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -391,11 +391,11 @@ Datum float4send(PG_FUNCTION_ARGS) { float4 num = PG_GETARG_FLOAT4(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendfloat4(&buf, num); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendfloat4(buf, num); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* @@ -605,11 +605,11 @@ Datum float8send(PG_FUNCTION_ARGS) { float8 num = PG_GETARG_FLOAT8(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendfloat8(&buf, num); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendfloat8(buf, num); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 73324b91fe5..c60f01ac855 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -504,14 +504,14 @@ Datum box_send(PG_FUNCTION_ARGS) { BOX *box = PG_GETARG_BOX_P(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendfloat8(&buf, box->high.x); - pq_sendfloat8(&buf, box->high.y); - pq_sendfloat8(&buf, box->low.x); - pq_sendfloat8(&buf, box->low.y); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendfloat8(buf, box->high.x); + pq_sendfloat8(buf, box->high.y); + pq_sendfloat8(buf, box->low.x); + pq_sendfloat8(buf, box->low.y); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } @@ -1107,13 +1107,13 @@ Datum line_send(PG_FUNCTION_ARGS) { LINE *line = PG_GETARG_LINE_P(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendfloat8(&buf, line->A); - pq_sendfloat8(&buf, line->B); - pq_sendfloat8(&buf, line->C); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendfloat8(buf, line->A); + pq_sendfloat8(buf, line->B); + pq_sendfloat8(buf, line->C); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } @@ -1575,18 +1575,18 @@ Datum path_send(PG_FUNCTION_ARGS) { PATH *path = PG_GETARG_PATH_P(0); - StringInfoData buf; + StringInfo buf; int32 i; - pq_begintypsend(&buf); - pq_sendbyte(&buf, path->closed ? 1 : 0); - pq_sendint32(&buf, path->npts); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendbyte(buf, path->closed ? 1 : 0); + pq_sendint32(buf, path->npts); for (i = 0; i < path->npts; i++) { - pq_sendfloat8(&buf, path->p[i].x); - pq_sendfloat8(&buf, path->p[i].y); + pq_sendfloat8(buf, path->p[i].x); + pq_sendfloat8(buf, path->p[i].y); } - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } @@ -1919,12 +1919,12 @@ Datum point_send(PG_FUNCTION_ARGS) { Point *pt = PG_GETARG_POINT_P(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendfloat8(&buf, pt->x); - pq_sendfloat8(&buf, pt->y); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendfloat8(buf, pt->x); + pq_sendfloat8(buf, pt->y); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } @@ -2173,14 +2173,14 @@ Datum lseg_send(PG_FUNCTION_ARGS) { LSEG *ls = PG_GETARG_LSEG_P(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendfloat8(&buf, ls->p[0].x); - pq_sendfloat8(&buf, ls->p[0].y); - pq_sendfloat8(&buf, ls->p[1].x); - pq_sendfloat8(&buf, ls->p[1].y); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendfloat8(buf, ls->p[0].x); + pq_sendfloat8(buf, ls->p[0].y); + pq_sendfloat8(buf, ls->p[1].x); + pq_sendfloat8(buf, ls->p[1].y); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } @@ -3594,17 +3594,17 @@ Datum poly_send(PG_FUNCTION_ARGS) { POLYGON *poly = PG_GETARG_POLYGON_P(0); - StringInfoData buf; + StringInfo buf; int32 i; - pq_begintypsend(&buf); - pq_sendint32(&buf, poly->npts); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint32(buf, poly->npts); for (i = 0; i < poly->npts; i++) { - pq_sendfloat8(&buf, poly->p[i].x); - pq_sendfloat8(&buf, poly->p[i].y); + pq_sendfloat8(buf, poly->p[i].x); + pq_sendfloat8(buf, poly->p[i].y); } - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } @@ -4829,13 +4829,13 @@ Datum circle_send(PG_FUNCTION_ARGS) { CIRCLE *circle = PG_GETARG_CIRCLE_P(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendfloat8(&buf, circle->center.x); - pq_sendfloat8(&buf, circle->center.y); - pq_sendfloat8(&buf, circle->radius); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendfloat8(buf, circle->center.x); + pq_sendfloat8(buf, circle->center.y); + pq_sendfloat8(buf, circle->radius); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index 68fecbfe2ed..ef1a7f7aec4 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -98,11 +98,11 @@ Datum int2send(PG_FUNCTION_ARGS) { int16 arg1 = PG_GETARG_INT16(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint16(&buf, arg1); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint16(buf, arg1); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* @@ -351,11 +351,11 @@ Datum int4send(PG_FUNCTION_ARGS) { int32 arg1 = PG_GETARG_INT32(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint32(&buf, arg1); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint32(buf, arg1); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 1a8bddd6bb1..1860f200b5d 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -96,11 +96,11 @@ Datum int8send(PG_FUNCTION_ARGS) { int64 arg1 = PG_GETARG_INT64(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint64(&buf, arg1); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint64(buf, arg1); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c index 1e273160b25..b419e21418e 100644 --- a/src/backend/utils/adt/json.c +++ b/src/backend/utils/adt/json.c @@ -140,11 +140,11 @@ Datum json_send(PG_FUNCTION_ARGS) { text *t = PG_GETARG_TEXT_PP(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendtext(&buf, VARDATA_ANY(t), VARSIZE_ANY_EXHDR(t)); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendtext(buf, VARDATA_ANY(t), VARSIZE_ANY_EXHDR(t)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c index 8a22d177414..e2380e717f2 100644 --- a/src/backend/utils/adt/jsonb.c +++ b/src/backend/utils/adt/jsonb.c @@ -118,19 +118,19 @@ Datum jsonb_send(PG_FUNCTION_ARGS) { Jsonb *jb = PG_GETARG_JSONB_P(0); - StringInfoData buf; + StringInfo buf; StringInfoData jtext; int version = 1; initStringInfo(&jtext); (void) JsonbToCString(&jtext, &jb->root, VARSIZE(jb)); - pq_begintypsend(&buf); - pq_sendint8(&buf, version); - pq_sendtext(&buf, jtext.data, jtext.len); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint8(buf, version); + pq_sendtext(buf, jtext.data, jtext.len); pfree(jtext.data); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/jsonpath.c b/src/backend/utils/adt/jsonpath.c index 7bfc18c9888..7bd3d85dcd8 100644 --- a/src/backend/utils/adt/jsonpath.c +++ b/src/backend/utils/adt/jsonpath.c @@ -147,19 +147,19 @@ Datum jsonpath_send(PG_FUNCTION_ARGS) { JsonPath *in = PG_GETARG_JSONPATH_P(0); - StringInfoData buf; + StringInfo buf; StringInfoData jtext; int version = JSONPATH_VERSION; initStringInfo(&jtext); (void) jsonPathToCstring(&jtext, in, VARSIZE(in)); - pq_begintypsend(&buf); - pq_sendint8(&buf, version); - pq_sendtext(&buf, jtext.data, jtext.len); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint8(buf, version); + pq_sendtext(buf, jtext.data, jtext.len); pfree(jtext.data); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/mac.c b/src/backend/utils/adt/mac.c index 3edaac8bb53..9406d860440 100644 --- a/src/backend/utils/adt/mac.c +++ b/src/backend/utils/adt/mac.c @@ -150,16 +150,16 @@ Datum macaddr_send(PG_FUNCTION_ARGS) { macaddr *addr = PG_GETARG_MACADDR_P(0); - StringInfoData buf; - - pq_begintypsend(&buf); - pq_sendbyte(&buf, addr->a); - pq_sendbyte(&buf, addr->b); - pq_sendbyte(&buf, addr->c); - pq_sendbyte(&buf, addr->d); - pq_sendbyte(&buf, addr->e); - pq_sendbyte(&buf, addr->f); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + StringInfo buf; + + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendbyte(buf, addr->a); + pq_sendbyte(buf, addr->b); + pq_sendbyte(buf, addr->c); + pq_sendbyte(buf, addr->d); + pq_sendbyte(buf, addr->e); + pq_sendbyte(buf, addr->f); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/mac8.c b/src/backend/utils/adt/mac8.c index 0425ea473a5..131ab966be2 100644 --- a/src/backend/utils/adt/mac8.c +++ b/src/backend/utils/adt/mac8.c @@ -287,19 +287,19 @@ Datum macaddr8_send(PG_FUNCTION_ARGS) { macaddr8 *addr = PG_GETARG_MACADDR8_P(0); - StringInfoData buf; - - pq_begintypsend(&buf); - pq_sendbyte(&buf, addr->a); - pq_sendbyte(&buf, addr->b); - pq_sendbyte(&buf, addr->c); - pq_sendbyte(&buf, addr->d); - pq_sendbyte(&buf, addr->e); - pq_sendbyte(&buf, addr->f); - pq_sendbyte(&buf, addr->g); - pq_sendbyte(&buf, addr->h); - - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + StringInfo buf; + + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendbyte(buf, addr->a); + pq_sendbyte(buf, addr->b); + pq_sendbyte(buf, addr->c); + pq_sendbyte(buf, addr->d); + pq_sendbyte(buf, addr->e); + pq_sendbyte(buf, addr->f); + pq_sendbyte(buf, addr->g); + pq_sendbyte(buf, addr->h); + + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/multirangetypes.c b/src/backend/utils/adt/multirangetypes.c index d2b31aec0b7..a41ed42d3d6 100644 --- a/src/backend/utils/adt/multirangetypes.c +++ b/src/backend/utils/adt/multirangetypes.c @@ -378,7 +378,7 @@ multirange_send(PG_FUNCTION_ARGS) { MultirangeType *multirange = PG_GETARG_MULTIRANGE_P(0); Oid mltrngtypoid = MultirangeTypeGetOid(multirange); - StringInfoData buf; + StringInfo buf; RangeType **ranges; int32 range_count; MultirangeIOData *cache; @@ -386,9 +386,9 @@ multirange_send(PG_FUNCTION_ARGS) cache = get_multirange_io_data(fcinfo, mltrngtypoid, IOFunc_send); /* construct output */ - pq_begintypsend(&buf); + buf = pq_begintypsend_fcinfo(fcinfo); - pq_sendint32(&buf, multirange->rangeCount); + pq_sendint32(buf, multirange->rangeCount); multirange_deserialize(cache->typcache->rngtype, multirange, &range_count, &ranges); for (int i = 0; i < range_count; i++) @@ -396,10 +396,10 @@ multirange_send(PG_FUNCTION_ARGS) Datum range; range = RangeTypePGetDatum(ranges[i]); - SendFunctionCallInto(&cache->typioproc, range, &buf); + SendFunctionCallInto(&cache->typioproc, range, buf); } - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c index cbd1808bb5c..88e67224bbb 100644 --- a/src/backend/utils/adt/name.c +++ b/src/backend/utils/adt/name.c @@ -106,11 +106,11 @@ Datum namesend(PG_FUNCTION_ARGS) { Name s = PG_GETARG_NAME(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendtext(&buf, NameStr(*s), strlen(NameStr(*s))); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendtext(buf, NameStr(*s), strlen(NameStr(*s))); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 52a3540cf9e..f26ccf9a2f6 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -265,23 +265,23 @@ cidr_recv(PG_FUNCTION_ARGS) * network_send - converts inet to binary format */ static bytea * -network_send(inet *addr, bool is_cidr) +network_send(FunctionCallInfo fcinfo, inet *addr, bool is_cidr) { - StringInfoData buf; + StringInfo buf; char *addrptr; int nb, i; - pq_begintypsend(&buf); - pq_sendbyte(&buf, ip_family(addr)); - pq_sendbyte(&buf, ip_bits(addr)); - pq_sendbyte(&buf, is_cidr); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendbyte(buf, ip_family(addr)); + pq_sendbyte(buf, ip_bits(addr)); + pq_sendbyte(buf, is_cidr); nb = ip_addrsize(addr); - pq_sendbyte(&buf, nb); + pq_sendbyte(buf, nb); addrptr = (char *) ip_addr(addr); for (i = 0; i < nb; i++) - pq_sendbyte(&buf, addrptr[i]); - return pq_endtypsend(&buf); + pq_sendbyte(buf, addrptr[i]); + return pq_endtypsend_fcinfo(fcinfo, buf); } Datum @@ -289,7 +289,7 @@ inet_send(PG_FUNCTION_ARGS) { inet *addr = PG_GETARG_INET_PP(0); - PG_RETURN_BYTEA_P(network_send(addr, false)); + PG_RETURN_BYTEA_P(network_send(fcinfo, addr, false)); } Datum @@ -297,7 +297,7 @@ cidr_send(PG_FUNCTION_ARGS) { inet *addr = PG_GETARG_INET_PP(0); - PG_RETURN_BYTEA_P(network_send(addr, true)); + PG_RETURN_BYTEA_P(network_send(fcinfo, addr, true)); } diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index ff6dec42010..e0828dd4e43 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -1147,21 +1147,21 @@ numeric_send(PG_FUNCTION_ARGS) { Numeric num = PG_GETARG_NUMERIC(0); NumericVar x; - StringInfoData buf; + StringInfo buf; int i; init_var_from_num(num, &x); - pq_begintypsend(&buf); + buf = pq_begintypsend_fcinfo(fcinfo); - pq_sendint16(&buf, x.ndigits); - pq_sendint16(&buf, x.weight); - pq_sendint16(&buf, x.sign); - pq_sendint16(&buf, x.dscale); + pq_sendint16(buf, x.ndigits); + pq_sendint16(buf, x.weight); + pq_sendint16(buf, x.sign); + pq_sendint16(buf, x.dscale); for (i = 0; i < x.ndigits; i++) - pq_sendint16(&buf, x.digits[i]); + pq_sendint16(buf, x.digits[i]); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c index a3419728971..27587309f9e 100644 --- a/src/backend/utils/adt/oid.c +++ b/src/backend/utils/adt/oid.c @@ -71,11 +71,11 @@ Datum oidsend(PG_FUNCTION_ARGS) { Oid arg1 = PG_GETARG_OID(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint32(&buf, arg1); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint32(buf, arg1); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/oid8.c b/src/backend/utils/adt/oid8.c index cfebcb13428..bfc9c9f80f6 100644 --- a/src/backend/utils/adt/oid8.c +++ b/src/backend/utils/adt/oid8.c @@ -72,11 +72,11 @@ Datum oid8send(PG_FUNCTION_ARGS) { Oid8 arg1 = PG_GETARG_OID8(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint64(&buf, arg1); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint64(buf, arg1); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /***************************************************************************** diff --git a/src/backend/utils/adt/pg_lsn.c b/src/backend/utils/adt/pg_lsn.c index 3ec2c2b650e..4387b94c362 100644 --- a/src/backend/utils/adt/pg_lsn.c +++ b/src/backend/utils/adt/pg_lsn.c @@ -77,11 +77,11 @@ Datum pg_lsn_send(PG_FUNCTION_ARGS) { XLogRecPtr lsn = PG_GETARG_LSN(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint64(&buf, lsn); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint64(buf, lsn); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/pseudotypes.c b/src/backend/utils/adt/pseudotypes.c index 4581c4b1697..f82155dd343 100644 --- a/src/backend/utils/adt/pseudotypes.c +++ b/src/backend/utils/adt/pseudotypes.c @@ -134,11 +134,11 @@ Datum cstring_send(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendtext(&buf, str, strlen(str)); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendtext(buf, str, strlen(str)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* @@ -284,11 +284,11 @@ void_recv(PG_FUNCTION_ARGS) Datum void_send(PG_FUNCTION_ARGS) { - StringInfoData buf; + StringInfo buf; /* send an empty string */ - pq_begintypsend(&buf); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c index 4629d935c62..c5e63e83134 100644 --- a/src/backend/utils/adt/rangetypes.c +++ b/src/backend/utils/adt/rangetypes.c @@ -269,7 +269,7 @@ Datum range_send(PG_FUNCTION_ARGS) { RangeType *range = PG_GETARG_RANGE_P(0); - StringInfoData buf; + StringInfo buf; RangeIOData *cache; char flags; RangeBound lower; @@ -285,17 +285,17 @@ range_send(PG_FUNCTION_ARGS) flags = range_get_flags(range); /* construct output */ - pq_begintypsend(&buf); + buf = pq_begintypsend_fcinfo(fcinfo); - pq_sendbyte(&buf, flags); + pq_sendbyte(buf, flags); if (RANGE_HAS_LBOUND(flags)) - SendFunctionCallInto(&cache->typioproc, lower.val, &buf); + SendFunctionCallInto(&cache->typioproc, lower.val, buf); if (RANGE_HAS_UBOUND(flags)) - SendFunctionCallInto(&cache->typioproc, upper.val, &buf); + SendFunctionCallInto(&cache->typioproc, upper.val, buf); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c index e7ca05a3d57..9f38ba76468 100644 --- a/src/backend/utils/adt/rowtypes.c +++ b/src/backend/utils/adt/rowtypes.c @@ -697,7 +697,7 @@ record_send(PG_FUNCTION_ARGS) int i; Datum *values; bool *nulls; - StringInfoData buf; + StringInfo buf; check_stack_depth(); /* recurses for record-type columns */ @@ -748,7 +748,7 @@ record_send(PG_FUNCTION_ARGS) heap_deform_tuple(&tuple, tupdesc, values, nulls); /* And build the result string */ - pq_begintypsend(&buf); + buf = pq_begintypsend_fcinfo(fcinfo); /* Need to scan to count nondeleted columns */ validcols = 0; @@ -757,7 +757,7 @@ record_send(PG_FUNCTION_ARGS) if (!TupleDescAttr(tupdesc, i)->attisdropped) validcols++; } - pq_sendint32(&buf, validcols); + pq_sendint32(buf, validcols); for (i = 0; i < ncolumns; i++) { @@ -770,12 +770,12 @@ record_send(PG_FUNCTION_ARGS) if (att->attisdropped) continue; - pq_sendint32(&buf, column_type); + pq_sendint32(buf, column_type); if (nulls[i]) { /* emit -1 data length to signify a NULL */ - pq_sendint32(&buf, -1); + pq_sendint32(buf, -1); continue; } @@ -793,14 +793,14 @@ record_send(PG_FUNCTION_ARGS) } attr = values[i]; - SendFunctionCallInto(&column_info->proc, attr, &buf); + SendFunctionCallInto(&column_info->proc, attr, buf); } pfree(values); pfree(nulls); ReleaseTupleDesc(tupdesc); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index 1fc2f75cc98..418a95fa482 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -159,12 +159,12 @@ Datum tidsend(PG_FUNCTION_ARGS) { ItemPointer itemPtr = PG_GETARG_ITEMPOINTER(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint32(&buf, ItemPointerGetBlockNumberNoCheck(itemPtr)); - pq_sendint16(&buf, ItemPointerGetOffsetNumberNoCheck(itemPtr)); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint32(buf, ItemPointerGetBlockNumberNoCheck(itemPtr)); + pq_sendint16(buf, ItemPointerGetOffsetNumberNoCheck(itemPtr)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /***************************************************************************** diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 81f93ae2c26..26d1424cce4 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -286,11 +286,11 @@ Datum timestamp_send(PG_FUNCTION_ARGS) { Timestamp timestamp = PG_GETARG_TIMESTAMP(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint64(&buf, timestamp); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint64(buf, timestamp); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } Datum @@ -835,11 +835,11 @@ Datum timestamptz_send(PG_FUNCTION_ARGS) { TimestampTz timestamp = PG_GETARG_TIMESTAMPTZ(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint64(&buf, timestamp); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint64(buf, timestamp); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } Datum @@ -1023,13 +1023,13 @@ Datum interval_send(PG_FUNCTION_ARGS) { Interval *interval = PG_GETARG_INTERVAL_P(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint64(&buf, interval->time); - pq_sendint32(&buf, interval->day); - pq_sendint32(&buf, interval->month); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint64(buf, interval->time); + pq_sendint32(buf, interval->day); + pq_sendint32(buf, interval->month); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/tsquery.c b/src/backend/utils/adt/tsquery.c index 228fa6276be..eb717159e6c 100644 --- a/src/backend/utils/adt/tsquery.c +++ b/src/backend/utils/adt/tsquery.c @@ -1133,28 +1133,28 @@ Datum tsquerysend(PG_FUNCTION_ARGS) { TSQuery query = PG_GETARG_TSQUERY(0); - StringInfoData buf; + StringInfo buf; int i; QueryItem *item = GETQUERY(query); - pq_begintypsend(&buf); + buf = pq_begintypsend_fcinfo(fcinfo); - pq_sendint32(&buf, query->size); + pq_sendint32(buf, query->size); for (i = 0; i < query->size; i++) { - pq_sendint8(&buf, item->type); + pq_sendint8(buf, item->type); switch (item->type) { case QI_VAL: - pq_sendint8(&buf, item->qoperand.weight); - pq_sendint8(&buf, item->qoperand.prefix); - pq_sendstring(&buf, GETOPERAND(query) + item->qoperand.distance); + pq_sendint8(buf, item->qoperand.weight); + pq_sendint8(buf, item->qoperand.prefix); + pq_sendstring(buf, GETOPERAND(query) + item->qoperand.distance); break; case QI_OPR: - pq_sendint8(&buf, item->qoperator.oper); + pq_sendint8(buf, item->qoperator.oper); if (item->qoperator.oper == OP_PHRASE) - pq_sendint16(&buf, item->qoperator.distance); + pq_sendint16(buf, item->qoperator.distance); break; default: elog(ERROR, "unrecognized tsquery node type: %d", item->type); @@ -1164,7 +1164,7 @@ tsquerysend(PG_FUNCTION_ARGS) PG_FREE_IF_COPY(query, 0); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } Datum diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c index 2fe782374e7..02d6b655a4b 100644 --- a/src/backend/utils/adt/tsvector.c +++ b/src/backend/utils/adt/tsvector.c @@ -407,14 +407,14 @@ Datum tsvectorsend(PG_FUNCTION_ARGS) { TSVector vec = PG_GETARG_TSVECTOR(0); - StringInfoData buf; + StringInfo buf; int i, j; WordEntry *weptr = ARRPTR(vec); - pq_begintypsend(&buf); + buf = pq_begintypsend_fcinfo(fcinfo); - pq_sendint32(&buf, vec->size); + pq_sendint32(buf, vec->size); for (i = 0; i < vec->size; i++) { uint16 npos; @@ -423,23 +423,23 @@ tsvectorsend(PG_FUNCTION_ARGS) * the strings in the TSVector array are not null-terminated, so we * have to send the null-terminator separately */ - pq_sendtext(&buf, STRPTR(vec) + weptr->pos, weptr->len); - pq_sendbyte(&buf, '\0'); + pq_sendtext(buf, STRPTR(vec) + weptr->pos, weptr->len); + pq_sendbyte(buf, '\0'); npos = POSDATALEN(vec, weptr); - pq_sendint16(&buf, npos); + pq_sendint16(buf, npos); if (npos > 0) { WordEntryPos *wepptr = POSDATAPTR(vec, weptr); for (j = 0; j < npos; j++) - pq_sendint16(&buf, wepptr[j]); + pq_sendint16(buf, wepptr[j]); } weptr++; } - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } Datum diff --git a/src/backend/utils/adt/uuid.c b/src/backend/utils/adt/uuid.c index 49e59e7c75a..0faaa47a1a8 100644 --- a/src/backend/utils/adt/uuid.c +++ b/src/backend/utils/adt/uuid.c @@ -300,11 +300,11 @@ Datum uuid_send(PG_FUNCTION_ARGS) { pg_uuid_t *uuid = PG_GETARG_UUID_P(0); - StringInfoData buffer; + StringInfo buffer; - pq_begintypsend(&buffer); - pq_sendbytes(&buffer, uuid->data, UUID_LEN); - PG_RETURN_BYTEA_P(pq_endtypsend(&buffer)); + buffer = pq_begintypsend_fcinfo(fcinfo); + pq_sendbytes(buffer, uuid->data, UUID_LEN); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buffer)); } /* internal uuid compare function */ diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 00ee1535208..0ae4853f412 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -681,12 +681,12 @@ Datum varbit_send(PG_FUNCTION_ARGS) { VarBit *s = PG_GETARG_VARBIT_P(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint32(&buf, VARBITLEN(s)); - pq_sendbytes(&buf, VARBITS(s), VARBITBYTES(s)); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint32(buf, VARBITLEN(s)); + pq_sendbytes(buf, VARBITS(s), VARBITBYTES(s)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 74d863e3ff2..c83d0485025 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -318,11 +318,11 @@ Datum textsend(PG_FUNCTION_ARGS) { text *t = PG_GETARG_TEXT_PP(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendtext(&buf, VARDATA_ANY(t), VARSIZE_ANY_EXHDR(t)); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendtext(buf, VARDATA_ANY(t), VARSIZE_ANY_EXHDR(t)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } @@ -373,11 +373,11 @@ unknownsend(PG_FUNCTION_ARGS) { /* representation is same as cstring */ char *str = PG_GETARG_CSTRING(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendtext(&buf, str, strlen(str)); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendtext(buf, str, strlen(str)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } diff --git a/src/backend/utils/adt/xid.c b/src/backend/utils/adt/xid.c index f746a5f97dd..634e897300b 100644 --- a/src/backend/utils/adt/xid.c +++ b/src/backend/utils/adt/xid.c @@ -67,11 +67,11 @@ Datum xidsend(PG_FUNCTION_ARGS) { TransactionId arg1 = PG_GETARG_TRANSACTIONID(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint32(&buf, arg1); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint32(buf, arg1); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* @@ -225,11 +225,11 @@ Datum xid8send(PG_FUNCTION_ARGS) { FullTransactionId arg1 = PG_GETARG_FULLTRANSACTIONID(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint64(&buf, (uint64) U64FromFullTransactionId(arg1)); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint64(buf, (uint64) U64FromFullTransactionId(arg1)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } Datum @@ -384,11 +384,11 @@ Datum cidsend(PG_FUNCTION_ARGS) { CommandId arg1 = PG_GETARG_COMMANDID(0); - StringInfoData buf; + StringInfo buf; - pq_begintypsend(&buf); - pq_sendint32(&buf, arg1); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint32(buf, arg1); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } Datum diff --git a/src/backend/utils/adt/xid8funcs.c b/src/backend/utils/adt/xid8funcs.c index c607e78d9ac..46fb7723c40 100644 --- a/src/backend/utils/adt/xid8funcs.c +++ b/src/backend/utils/adt/xid8funcs.c @@ -535,16 +535,16 @@ Datum pg_snapshot_send(PG_FUNCTION_ARGS) { pg_snapshot *snap = (pg_snapshot *) PG_GETARG_VARLENA_P(0); - StringInfoData buf; + StringInfo buf; uint32 i; - pq_begintypsend(&buf); - pq_sendint32(&buf, snap->nxip); - pq_sendint64(&buf, (int64) U64FromFullTransactionId(snap->xmin)); - pq_sendint64(&buf, (int64) U64FromFullTransactionId(snap->xmax)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendint32(buf, snap->nxip); + pq_sendint64(buf, (int64) U64FromFullTransactionId(snap->xmin)); + pq_sendint64(buf, (int64) U64FromFullTransactionId(snap->xmax)); for (i = 0; i < snap->nxip; i++) - pq_sendint64(&buf, (int64) U64FromFullTransactionId(snap->xip[i])); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + pq_sendint64(buf, (int64) U64FromFullTransactionId(snap->xip[i])); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } /* diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index 44a3a21d135..b8b754ee519 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -438,7 +438,7 @@ xml_send(PG_FUNCTION_ARGS) { xmltype *x = PG_GETARG_XML_P(0); char *outval; - StringInfoData buf; + StringInfo buf; /* * xml_out_internal doesn't convert the encoding, it just prints the right @@ -446,10 +446,10 @@ xml_send(PG_FUNCTION_ARGS) */ outval = xml_out_internal(x, pg_get_client_encoding()); - pq_begintypsend(&buf); - pq_sendtext(&buf, outval, strlen(outval)); + buf = pq_begintypsend_fcinfo(fcinfo); + pq_sendtext(buf, outval, strlen(outval)); pfree(outval); - PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); + PG_RETURN_BYTEA_P(pq_endtypsend_fcinfo(fcinfo, buf)); } -- 2.47.3