aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeSubplan.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-03-17 01:02:24 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-03-17 01:02:24 +0000
commitc1352052ef1d4eeb2eb1d822a207ddc2d106cb13 (patch)
treecc396212df36959c1220a953a009636477c615b2 /src/backend/executor/nodeSubplan.c
parent2c7e47343449e2a4f7694d04a5a4284d89246699 (diff)
downloadpostgresql-c1352052ef1d4eeb2eb1d822a207ddc2d106cb13.tar.gz
postgresql-c1352052ef1d4eeb2eb1d822a207ddc2d106cb13.zip
Replace the switching function ExecEvalExpr() with a macro that jumps
directly to the appropriate per-node execution function, using a function pointer stored by ExecInitExpr. This speeds things up by eliminating one level of function call. The function-pointer technique also enables further small improvements such as only making one-time tests once (and then changing the function pointer). Overall this seems to gain about 10% on evaluation of simple expressions, which isn't earthshaking but seems a worthwhile gain for a relatively small hack. Per recent discussion on pghackers.
Diffstat (limited to 'src/backend/executor/nodeSubplan.c')
-rw-r--r--src/backend/executor/nodeSubplan.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c
index 1624f41fd54..8c667b70e78 100644
--- a/src/backend/executor/nodeSubplan.c
+++ b/src/backend/executor/nodeSubplan.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.60 2004/01/14 23:01:54 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.61 2004/03/17 01:02:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,10 +47,16 @@ static bool tupleAllNulls(HeapTuple tuple);
Datum
ExecSubPlan(SubPlanState *node,
ExprContext *econtext,
- bool *isNull)
+ bool *isNull,
+ ExprDoneCond *isDone)
{
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
+ /* Set default values for result flags: non-null, not a set result */
+ *isNull = false;
+ if (isDone)
+ *isDone = ExprSingleResult;
+
if (subplan->setParam != NIL)
elog(ERROR, "cannot set parent params from subquery");
@@ -819,6 +825,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
expr);
tlestate = makeNode(GenericExprState);
tlestate->xprstate.expr = (Expr *) tle;
+ tlestate->xprstate.evalfunc = NULL;
tlestate->arg = exstate;
lefttlist = lappend(lefttlist, tlestate);
leftptlist = lappend(leftptlist, tle);
@@ -834,6 +841,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate)
expr);
tlestate = makeNode(GenericExprState);
tlestate->xprstate.expr = (Expr *) tle;
+ tlestate->xprstate.evalfunc = NULL;
tlestate->arg = exstate;
righttlist = lappend(righttlist, tlestate);
rightptlist = lappend(rightptlist, tle);