aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeFunctionscan.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2018-02-16 21:17:38 -0800
committerAndres Freund <andres@anarazel.de>2018-02-16 21:17:38 -0800
commitad7dbee368a7cd9e595d2a957be784326b08c943 (patch)
treea4846e24bf9f2d78b7c8dfb04323ef984aede517 /src/backend/executor/nodeFunctionscan.c
parentbf6c614a2f2c58312b3be34a47e7fb7362e07bcb (diff)
downloadpostgresql-ad7dbee368a7cd9e595d2a957be784326b08c943.tar.gz
postgresql-ad7dbee368a7cd9e595d2a957be784326b08c943.zip
Allow tupleslots to have a fixed tupledesc, use in executor nodes.
The reason for doing so is that it will allow expression evaluation to optimize based on the underlying tupledesc. In particular it will allow to JIT tuple deforming together with the expression itself. For that expression initialization needs to be moved after the relevant slots are initialized - mostly unproblematic, except in the case of nodeWorktablescan.c. After doing so there's no need for ExecAssignResultType() and ExecAssignResultTypeFromTL() anymore, as all former callers have been converted to create a slot with a fixed descriptor. When creating a slot with a fixed descriptor, tts_values/isnull can be allocated together with the main slot, reducing allocation overhead and increasing cache density a bit. Author: Andres Freund Discussion: https://postgr.es/m/20171206093717.vqdxe5icqttpxs3p@alap3.anarazel.de
Diffstat (limited to 'src/backend/executor/nodeFunctionscan.c')
-rw-r--r--src/backend/executor/nodeFunctionscan.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c
index 69f8d3e8145..fb7c9f67875 100644
--- a/src/backend/executor/nodeFunctionscan.c
+++ b/src/backend/executor/nodeFunctionscan.c
@@ -334,18 +334,6 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags)
*/
ExecAssignExprContext(estate, &scanstate->ss.ps);
- /*
- * tuple table initialization
- */
- ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
- ExecInitScanTupleSlot(estate, &scanstate->ss);
-
- /*
- * initialize child expressions
- */
- scanstate->ss.ps.qual =
- ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
-
scanstate->funcstates = palloc(nfuncs * sizeof(FunctionScanPerFuncState));
natts = 0;
@@ -436,8 +424,7 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags)
*/
if (!scanstate->simple)
{
- fs->func_slot = ExecInitExtraTupleSlot(estate);
- ExecSetSlotDescriptor(fs->func_slot, fs->tupdesc);
+ fs->func_slot = ExecInitExtraTupleSlot(estate, fs->tupdesc);
}
else
fs->func_slot = NULL;
@@ -492,15 +479,24 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags)
Assert(attno == natts);
}
- ExecAssignScanType(&scanstate->ss, scan_tupdesc);
+ /*
+ * Initialize scan slot and type.
+ */
+ ExecInitScanTupleSlot(estate, &scanstate->ss, scan_tupdesc);
/*
- * Initialize result tuple type and projection info.
+ * Initialize result slot, type and projection.
*/
- ExecAssignResultTypeFromTL(&scanstate->ss.ps);
+ ExecInitResultTupleSlotTL(estate, &scanstate->ss.ps);
ExecAssignScanProjectionInfo(&scanstate->ss);
/*
+ * initialize child expressions
+ */
+ scanstate->ss.ps.qual =
+ ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
+
+ /*
* Create a memory context that ExecMakeTableFunctionResult can use to
* evaluate function arguments in. We can't use the per-tuple context for
* this because it gets reset too often; but we don't want to leak