diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-02-27 01:11:26 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-02-27 01:11:26 +0000 |
commit | c7ff7663e47fc4e295700101912f2b7dd53c1f4b (patch) | |
tree | 13e987e4894faca0086b78568b08b79cf124e8a1 /src/backend/executor/nodeSubqueryscan.c | |
parent | 4756ff3dca903dfc525d1c27fd00fad8ca328188 (diff) | |
download | postgresql-c7ff7663e47fc4e295700101912f2b7dd53c1f4b.tar.gz postgresql-c7ff7663e47fc4e295700101912f2b7dd53c1f4b.zip |
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.
Diffstat (limited to 'src/backend/executor/nodeSubqueryscan.c')
-rw-r--r-- | src/backend/executor/nodeSubqueryscan.c | 59 |
1 files changed, 8 insertions, 51 deletions
diff --git a/src/backend/executor/nodeSubqueryscan.c b/src/backend/executor/nodeSubqueryscan.c index 6d58a8cad4e..159ee1b34d7 100644 --- a/src/backend/executor/nodeSubqueryscan.c +++ b/src/backend/executor/nodeSubqueryscan.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.36 2007/02/22 22:00:23 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeSubqueryscan.c,v 1.37 2007/02/27 01:11:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -45,17 +45,9 @@ static TupleTableSlot *SubqueryNext(SubqueryScanState *node); static TupleTableSlot * SubqueryNext(SubqueryScanState *node) { - EState *estate; - ScanDirection direction; TupleTableSlot *slot; /* - * get information from the estate and scan state - */ - estate = node->ss.ps.state; - direction = estate->es_direction; - - /* * We need not support EvalPlanQual here, since we are not scanning a real * relation. */ @@ -63,8 +55,6 @@ SubqueryNext(SubqueryScanState *node) /* * Get the next tuple from the sub-query. */ - node->sss_SubEState->es_direction = direction; - slot = ExecProcNode(node->subplan); /* @@ -103,7 +93,6 @@ SubqueryScanState * ExecInitSubqueryScan(SubqueryScan *node, EState *estate, int eflags) { SubqueryScanState *subquerystate; - EState *sp_estate; /* check for unsupported flags */ Assert(!(eflags & EXEC_FLAG_MARK)); @@ -150,44 +139,16 @@ ExecInitSubqueryScan(SubqueryScan *node, EState *estate, int eflags) /* * initialize subquery - * - * This should agree with ExecInitSubPlan - * - * The subquery needs its own EState because it has its own rangetable. It - * shares our Param ID space and es_query_cxt, however. XXX if rangetable - * access were done differently, the subquery could share our EState, - * which would eliminate some thrashing about in this module... - * - * XXX make that happen! */ - sp_estate = CreateSubExecutorState(estate); - subquerystate->sss_SubEState = sp_estate; - - sp_estate->es_range_table = estate->es_range_table; - sp_estate->es_param_list_info = estate->es_param_list_info; - sp_estate->es_param_exec_vals = estate->es_param_exec_vals; - sp_estate->es_tupleTable = - ExecCreateTupleTable(ExecCountSlotsNode(node->subplan) + 10); - sp_estate->es_snapshot = estate->es_snapshot; - sp_estate->es_crosscheck_snapshot = estate->es_crosscheck_snapshot; - sp_estate->es_instrument = estate->es_instrument; - sp_estate->es_plannedstmt = estate->es_plannedstmt; - - /* - * Start up the subplan (this is a very cut-down form of InitPlan()) - */ - subquerystate->subplan = ExecInitNode(node->subplan, sp_estate, eflags); + subquerystate->subplan = ExecInitNode(node->subplan, estate, eflags); subquerystate->ss.ps.ps_TupFromTlist = false; /* - * Initialize scan tuple type (needed by ExecAssignScanProjectionInfo). - * Because the subplan is in its own memory context, we need to copy its - * result tuple type not just link to it; else the tupdesc will disappear - * too soon during shutdown. + * Initialize scan tuple type (needed by ExecAssignScanProjectionInfo) */ ExecAssignScanType(&subquerystate->ss, - CreateTupleDescCopy(ExecGetResultType(subquerystate->subplan))); + ExecGetResultType(subquerystate->subplan)); /* * Initialize result tuple type and projection info. @@ -201,11 +162,9 @@ ExecInitSubqueryScan(SubqueryScan *node, EState *estate, int eflags) int ExecCountSlotsSubqueryScan(SubqueryScan *node) { - /* - * The subplan has its own tuple table and must not be counted here! - */ - return ExecCountSlotsNode(outerPlan(node)) + - ExecCountSlotsNode(innerPlan(node)) + + Assert(outerPlan(node) == NULL); + Assert(innerPlan(node) == NULL); + return ExecCountSlotsNode(node->subplan) + SUBQUERYSCAN_NSLOTS; } @@ -232,9 +191,7 @@ ExecEndSubqueryScan(SubqueryScanState *node) /* * close down subquery */ - ExecEndPlan(node->subplan, node->sss_SubEState); - - FreeExecutorState(node->sss_SubEState); + ExecEndNode(node->subplan); } /* ---------------------------------------------------------------- |