public inbox for [email protected]help / color / mirror / Atom feed
[PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup 644+ messages / 1 participants [nested] [flat]
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.46.0.519.g2e7b89e038 --benhmb75h34eqzc4 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="va1-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch" ^ permalink raw reply [nested|flat] 644+ messages in thread
* [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup @ 2026-05-06 15:41 Andres Freund <[email protected]> 0 siblings, 0 replies; 644+ messages in thread From: Andres Freund @ 2026-05-06 15:41 UTC (permalink / raw) Should probably be done similarly for COPY --- src/backend/access/common/printtup.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 616bdafd395..6fa93a6798a 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -50,6 +50,8 @@ typedef struct bool typisvarlena; /* is it varlena (ie possibly toastable)? */ int16 format; /* format code for this column */ FmgrInfo finfo; /* Precomputed call info for output fn */ + /* XXX: Would probably be faster to allocate "inline" */ + FunctionCallInfo outstate; /* Prepared FCI for slightly faster calls */ } PrinttupAttrInfo; typedef struct @@ -291,6 +293,10 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("unsupported format code: %d", format))); + + /* both out and send funcs have one argument */ + thisState->outstate = palloc0(SizeForFunctionCallInfo(1)); + thisState->outstate->flinfo = &thisState->finfo; } } @@ -353,12 +359,16 @@ printtup(TupleTableSlot *slot, DestReceiver *self) VALGRIND_CHECK_MEM_IS_DEFINED(DatumGetPointer(attr), VARSIZE_ANY(DatumGetPointer(attr))); + /* fill in argument for output / send function */ + thisState->outstate->args[0].value = attr; + if (thisState->format == 0) { /* Text output */ char *outputstr; - outputstr = OutputFunctionCall(&thisState->finfo, attr); + outputstr = DatumGetCString(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendcountedtext(buf, outputstr, strlen(outputstr)); } else @@ -366,7 +376,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) /* Binary output */ bytea *outputbytes; - outputbytes = SendFunctionCall(&thisState->finfo, attr); + outputbytes = DatumGetByteaP(FunctionCallInvoke(thisState->outstate)); + Assert(!thisState->outstate->isnull); pq_sendint32(buf, VARSIZE(outputbytes) - VARHDRSZ); pq_sendbytes(buf, VARDATA(outputbytes), VARSIZE(outputbytes) - VARHDRSZ); -- 2.43.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0002-Mega-WIP-Optimized-out-send-path-for-printtup.patch ^ permalink raw reply [nested|flat] 644+ messages in thread
end of thread, other threads:[~2026-05-06 15:41 UTC | newest] Thread overview: 644+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH v2 1/4] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]> 2026-05-06 15:41 [PATCH va1 1/2] WIP: Use permanent FunctionCallInfo in printtup Andres Freund <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox