aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeSubplan.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-02-22 22:00:26 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-02-22 22:00:26 +0000
commiteab6b8b27eba54b8fd0ad3f64989d12200979c96 (patch)
treeca4fad45c65c60b7900df6e373bd5999993ea2b1 /src/backend/executor/nodeSubplan.c
parent849000c7823d604270094aea76fc530b6cfe9466 (diff)
downloadpostgresql-eab6b8b27eba54b8fd0ad3f64989d12200979c96.tar.gz
postgresql-eab6b8b27eba54b8fd0ad3f64989d12200979c96.zip
Turn the rangetable used by the executor into a flat list, and avoid storing
useless substructure for its RangeTblEntry nodes. (I chose to keep using the same struct node type and just zero out the link fields for unneeded info, rather than making a separate ExecRangeTblEntry type --- it seemed too fragile to have two different rangetable representations.) Along the way, put subplans into a list in the toplevel PlannedStmt node, and have SubPlan nodes refer to them by list index instead of direct pointers. Vadim wanted to do that years ago, but I never understood what he was on about until now. It makes things a *whole* lot more robust, because we can stop worrying about duplicate processing of subplans during expression tree traversals. That's been a constant source of bugs, and it's finally gone. There are some consequent simplifications yet to be made, like not using a separate EState for subplans in the executor, but I'll tackle that later.
Diffstat (limited to 'src/backend/executor/nodeSubplan.c')
-rw-r--r--src/backend/executor/nodeSubplan.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/backend/executor/nodeSubplan.c b/src/backend/executor/nodeSubplan.c
index 32167a94efb..9bc96921f41 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.85 2007/02/06 02:59:11 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeSubplan.c,v 1.86 2007/02/22 22:00:23 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -637,14 +637,10 @@ void
ExecInitSubPlan(SubPlanState *node, EState *estate, int eflags)
{
SubPlan *subplan = (SubPlan *) node->xprstate.expr;
+ Plan *plan = exec_subplan_get_plan(estate->es_plannedstmt, subplan);
EState *sp_estate;
/*
- * Do access checking on the rangetable entries in the subquery.
- */
- ExecCheckRTPerms(subplan->rtable);
-
- /*
* initialize my state
*/
node->needShutdown = false;
@@ -668,18 +664,21 @@ ExecInitSubPlan(SubPlanState *node, EState *estate, int eflags)
* 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);
node->sub_estate = sp_estate;
- sp_estate->es_range_table = subplan->rtable;
+ 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(subplan->plan) + 10);
+ ExecCreateTupleTable(ExecCountSlotsNode(plan) + 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())
@@ -692,7 +691,7 @@ ExecInitSubPlan(SubPlanState *node, EState *estate, int eflags)
if (subplan->parParam == NIL && subplan->setParam == NIL)
eflags |= EXEC_FLAG_REWIND;
- node->planstate = ExecInitNode(subplan->plan, sp_estate, eflags);
+ node->planstate = ExecInitNode(plan, sp_estate, eflags);
node->needShutdown = true; /* now we need to shutdown the subplan */