From c7ff7663e47fc4e295700101912f2b7dd53c1f4b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 27 Feb 2007 01:11:26 +0000 Subject: Get rid of the separate EState for subplans, and just let them share the parent query's EState. Now that there's a single flat rangetable for both the main plan and subplans, there's no need anymore for a separate EState, and removing it allows cleaning up some crufty code in nodeSubplan.c and nodeSubqueryscan.c. Should be a tad faster too, although any difference will probably be hard to measure. This is the last bit of subsidiary mop-up work from changing to a flat rangetable. --- src/backend/executor/execQual.c | 47 +++++------------------------------------ 1 file changed, 5 insertions(+), 42 deletions(-) (limited to 'src/backend/executor/execQual.c') diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index 3c0536eb8a..234441c0f6 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.213 2007/02/06 17:35:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.214 2007/02/27 01:11:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -3723,27 +3723,16 @@ ExecInitExpr(Expr *node, PlanState *parent) break; case T_SubPlan: { - /* Keep this in sync with ExecInitExprInitPlan, below */ SubPlan *subplan = (SubPlan *) node; - SubPlanState *sstate = makeNode(SubPlanState); - - sstate->xprstate.evalfunc = (ExprStateEvalFunc) ExecSubPlan; + SubPlanState *sstate; if (!parent) elog(ERROR, "SubPlan found with no parent plan"); - /* - * Here we just add the SubPlanState nodes to parent->subPlan. - * The subplans will be initialized later. - */ - parent->subPlan = lcons(sstate, parent->subPlan); - sstate->sub_estate = NULL; - sstate->planstate = NULL; + sstate = ExecInitSubPlan(subplan, parent); - sstate->testexpr = - ExecInitExpr((Expr *) subplan->testexpr, parent); - sstate->args = (List *) - ExecInitExpr((Expr *) subplan->args, parent); + /* Add SubPlanState nodes to parent->subPlan */ + parent->subPlan = lcons(sstate, parent->subPlan); state = (ExprState *) sstate; } @@ -4157,32 +4146,6 @@ ExecInitExpr(Expr *node, PlanState *parent) return state; } -/* - * ExecInitExprInitPlan --- initialize a subplan expr that's being handled - * as an InitPlan. This is identical to ExecInitExpr's handling of a regular - * subplan expr, except we do NOT want to add the node to the parent's - * subplan list. - */ -SubPlanState * -ExecInitExprInitPlan(SubPlan *node, PlanState *parent) -{ - SubPlanState *sstate = makeNode(SubPlanState); - - if (!parent) - elog(ERROR, "SubPlan found with no parent plan"); - - /* The subplan's state will be initialized later */ - sstate->sub_estate = NULL; - sstate->planstate = NULL; - - sstate->testexpr = ExecInitExpr((Expr *) node->testexpr, parent); - sstate->args = (List *) ExecInitExpr((Expr *) node->args, parent); - - sstate->xprstate.expr = (Expr *) node; - - return sstate; -} - /* * ExecPrepareExpr --- initialize for expression execution outside a normal * Plan tree context. -- cgit v1.2.1