Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d8d666

Browse files
committed
Clean up plantree representation of SubPlan-s --- SubLink does not appear
in the planned representation of a subplan at all any more, only SubPlan.This means subselect.c doesn't scribble on its input anymore, which seemslike a good thing; and there are no longer three different possibleinterpretations of a SubLink. Simplify node naming and improve commentsin primnodes.h. No change to stored rules, though.
1 parent29cdab3 commit2d8d666

File tree

24 files changed

+357
-358
lines changed

24 files changed

+357
-358
lines changed

‎src/backend/commands/explain.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994-5, Regents of the University of California
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.97 2002/12/13 19:45:49 tgl Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.98 2002/12/14 00:17:50 tgl Exp $
99
*
1010
*/
1111

@@ -589,8 +589,8 @@ explain_outNode(StringInfo str,
589589
appendStringInfo(str," InitPlan\n");
590590
foreach(lst,planstate->initPlan)
591591
{
592-
SubPlanExprState*sps= (SubPlanExprState*)lfirst(lst);
593-
SubPlanExpr*sp= (SubPlanExpr*)sps->xprstate.expr;
592+
SubPlanState*sps= (SubPlanState*)lfirst(lst);
593+
SubPlan*sp= (SubPlan*)sps->xprstate.expr;
594594

595595
es->rtable=sp->rtable;
596596
for (i=0;i<indent;i++)
@@ -687,8 +687,8 @@ explain_outNode(StringInfo str,
687687
appendStringInfo(str," SubPlan\n");
688688
foreach(lst,planstate->subPlan)
689689
{
690-
SubPlanExprState*sps= (SubPlanExprState*)lfirst(lst);
691-
SubPlanExpr*sp= (SubPlanExpr*)sps->xprstate.expr;
690+
SubPlanState*sps= (SubPlanState*)lfirst(lst);
691+
SubPlan*sp= (SubPlan*)sps->xprstate.expr;
692692

693693
es->rtable=sp->rtable;
694694
for (i=0;i<indent;i++)

‎src/backend/executor/execAmi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.67 2002/12/13 19:45:52 tgl Exp $
9+
*$Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.68 2002/12/14 00:17:50 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -61,7 +61,7 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
6161

6262
foreach(lst,node->initPlan)
6363
{
64-
SubPlanExprState*sstate= (SubPlanExprState*)lfirst(lst);
64+
SubPlanState*sstate= (SubPlanState*)lfirst(lst);
6565
PlanState*splan=sstate->planstate;
6666

6767
if (splan->plan->extParam!=NIL)/* don't care about child
@@ -72,7 +72,7 @@ ExecReScan(PlanState *node, ExprContext *exprCtxt)
7272
}
7373
foreach(lst,node->subPlan)
7474
{
75-
SubPlanExprState*sstate= (SubPlanExprState*)lfirst(lst);
75+
SubPlanState*sstate= (SubPlanState*)lfirst(lst);
7676
PlanState*splan=sstate->planstate;
7777

7878
if (splan->plan->extParam!=NIL)

‎src/backend/executor/execProcnode.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.33 2002/12/13 19:45:52 tgl Exp $
15+
* $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.34 2002/12/14 00:17:50 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -228,10 +228,10 @@ ExecInitNode(Plan *node, EState *estate)
228228
subps=NIL;
229229
foreach(subp,node->initPlan)
230230
{
231-
SubPlanExpr*subplan= (SubPlanExpr*)lfirst(subp);
232-
SubPlanExprState*sstate;
231+
SubPlan*subplan= (SubPlan*)lfirst(subp);
232+
SubPlanState*sstate;
233233

234-
Assert(IsA(subplan,SubPlanExpr));
234+
Assert(IsA(subplan,SubPlan));
235235
sstate=ExecInitExprInitPlan(subplan,result);
236236
ExecInitSubPlan(sstate,estate);
237237
subps=lappend(subps,sstate);
@@ -247,9 +247,9 @@ ExecInitNode(Plan *node, EState *estate)
247247
subps=NIL;
248248
foreach(subp,result->subPlan)
249249
{
250-
SubPlanExprState*sstate= (SubPlanExprState*)lfirst(subp);
250+
SubPlanState*sstate= (SubPlanState*)lfirst(subp);
251251

252-
Assert(IsA(sstate,SubPlanExprState));
252+
Assert(IsA(sstate,SubPlanState));
253253
ExecInitSubPlan(sstate,estate);
254254
subps=lappend(subps,sstate);
255255
}
@@ -500,9 +500,9 @@ ExecEndNode(PlanState *node)
500500

501501
/* Clean up initPlans and subPlans */
502502
foreach(subp,node->initPlan)
503-
ExecEndSubPlan((SubPlanExprState*)lfirst(subp));
503+
ExecEndSubPlan((SubPlanState*)lfirst(subp));
504504
foreach(subp,node->subPlan)
505-
ExecEndSubPlan((SubPlanExprState*)lfirst(subp));
505+
ExecEndSubPlan((SubPlanState*)lfirst(subp));
506506

507507
if (node->chgParam!=NIL)
508508
{

‎src/backend/executor/execQual.c

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.119 2002/12/13 19:45:52 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.120 2002/12/14 00:17:50 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1794,8 +1794,8 @@ ExecEvalExpr(ExprState *expression,
17941794
}
17951795
break;
17961796
}
1797-
caseT_SubPlanExpr:
1798-
retDatum=ExecSubPlan((SubPlanExprState*)expression,
1797+
caseT_SubPlan:
1798+
retDatum=ExecSubPlan((SubPlanState*)expression,
17991799
econtext,
18001800
isNull);
18011801
break;
@@ -1883,7 +1883,7 @@ ExecEvalExprSwitchContext(ExprState *expression,
18831883
* executions of the expression are needed. Typically the context will be
18841884
* the same as the per-query context of the associated ExprContext.
18851885
*
1886-
* Any Aggref andSubplanExpr nodes found in the tree are added to the lists
1886+
* Any Aggref andSubPlan nodes found in the tree are added to the lists
18871887
* of such nodes held by the parent PlanState. Otherwise, we do very little
18881888
* initialization here other than building the state-node tree. Any nontrivial
18891889
* work associated with initializing runtime info for a node should happen
@@ -2003,31 +2003,26 @@ ExecInitExpr(Expr *node, PlanState *parent)
20032003
state= (ExprState*)bstate;
20042004
}
20052005
break;
2006-
caseT_SubPlanExpr:
2006+
caseT_SubPlan:
20072007
{
20082008
/* Keep this in sync with ExecInitExprInitPlan, below */
2009-
SubPlanExpr*subplanexpr= (SubPlanExpr*)node;
2010-
SubLink*sublink=subplanexpr->sublink;
2011-
SubPlanExprState*sstate=makeNode(SubPlanExprState);
2009+
SubPlan*subplan= (SubPlan*)node;
2010+
SubPlanState*sstate=makeNode(SubPlanState);
20122011

2013-
Assert(IsA(sublink,SubLink));
20142012
if (!parent)
2015-
elog(ERROR,"ExecInitExpr:SubPlanExpr not expected here");
2013+
elog(ERROR,"ExecInitExpr:SubPlan not expected here");
20162014

20172015
/*
2018-
* Here we just add theSubPlanExprState nodes to
2016+
* Here we just add theSubPlanState nodes to
20192017
* parent->subPlan. The subplans will be initialized later.
20202018
*/
20212019
parent->subPlan=lcons(sstate,parent->subPlan);
20222020
sstate->planstate=NULL;
20232021

2024-
sstate->args= (List*)
2025-
ExecInitExpr((Expr*)subplanexpr->args,parent);
2026-
2027-
if (sublink->lefthand)
2028-
elog(ERROR,"ExecInitExpr: sublink has not been transformed");
20292022
sstate->oper= (List*)
2030-
ExecInitExpr((Expr*)sublink->oper,parent);
2023+
ExecInitExpr((Expr*)subplan->oper,parent);
2024+
sstate->args= (List*)
2025+
ExecInitExpr((Expr*)subplan->args,parent);
20312026

20322027
state= (ExprState*)sstate;
20332028
}
@@ -2145,26 +2140,20 @@ ExecInitExpr(Expr *node, PlanState *parent)
21452140
* subplan expr, except we do NOT want to add the node to the parent's
21462141
* subplan list.
21472142
*/
2148-
SubPlanExprState*
2149-
ExecInitExprInitPlan(SubPlanExpr*node,PlanState*parent)
2143+
SubPlanState*
2144+
ExecInitExprInitPlan(SubPlan*node,PlanState*parent)
21502145
{
2151-
SubLink*sublink=node->sublink;
2152-
SubPlanExprState*sstate=makeNode(SubPlanExprState);
2146+
SubPlanState*sstate=makeNode(SubPlanState);
21532147

2154-
Assert(IsA(sublink,SubLink));
21552148
if (!parent)
2156-
elog(ERROR,"ExecInitExpr:SubPlanExpr not expected here");
2149+
elog(ERROR,"ExecInitExpr:SubPlan not expected here");
21572150

21582151
/* The subplan's state will be initialized later */
21592152
sstate->planstate=NULL;
21602153

2154+
sstate->oper= (List*)ExecInitExpr((Expr*)node->oper,parent);
21612155
sstate->args= (List*)ExecInitExpr((Expr*)node->args,parent);
21622156

2163-
if (sublink->lefthand)
2164-
elog(ERROR,"ExecInitExpr: sublink has not been transformed");
2165-
2166-
sstate->oper= (List*)ExecInitExpr((Expr*)sublink->oper,parent);
2167-
21682157
sstate->xprstate.expr= (Expr*)node;
21692158

21702159
returnsstate;

‎src/backend/executor/nodeSubplan.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.37 2002/12/13 19:45:55 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.38 2002/12/14 00:17:50 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -30,15 +30,14 @@
3030
* ----------------------------------------------------------------
3131
*/
3232
Datum
33-
ExecSubPlan(SubPlanExprState*node,
33+
ExecSubPlan(SubPlanState*node,
3434
ExprContext*econtext,
3535
bool*isNull)
3636
{
37+
SubPlan*subplan= (SubPlan*)node->xprstate.expr;
3738
PlanState*planstate=node->planstate;
38-
SubPlanExpr*subplan= (SubPlanExpr*)node->xprstate.expr;
39-
SubLink*sublink=subplan->sublink;
40-
SubLinkTypesubLinkType=sublink->subLinkType;
41-
booluseor=sublink->useor;
39+
SubLinkTypesubLinkType=subplan->subLinkType;
40+
booluseor=subplan->useor;
4241
MemoryContextoldcontext;
4342
TupleTableSlot*slot;
4443
Datumresult;
@@ -292,56 +291,56 @@ ExecSubPlan(SubPlanExprState *node,
292291
* ----------------------------------------------------------------
293292
*/
294293
void
295-
ExecInitSubPlan(SubPlanExprState*sstate,EState*estate)
294+
ExecInitSubPlan(SubPlanState*node,EState*estate)
296295
{
297-
SubPlanExpr*expr= (SubPlanExpr*)sstate->xprstate.expr;
296+
SubPlan*subplan= (SubPlan*)node->xprstate.expr;
298297
EState*sp_estate;
299298

300299
/*
301300
* Do access checking on the rangetable entries in the subquery.
302301
* Here, we assume the subquery is a SELECT.
303302
*/
304-
ExecCheckRTPerms(expr->rtable,CMD_SELECT);
303+
ExecCheckRTPerms(subplan->rtable,CMD_SELECT);
305304

306305
/*
307306
* initialize state
308307
*/
309-
sstate->needShutdown= false;
310-
sstate->curTuple=NULL;
308+
node->needShutdown= false;
309+
node->curTuple=NULL;
311310

312311
/*
313312
* create an EState for the subplan
314313
*/
315314
sp_estate=CreateExecutorState();
316315

317-
sp_estate->es_range_table=expr->rtable;
316+
sp_estate->es_range_table=subplan->rtable;
318317
sp_estate->es_param_list_info=estate->es_param_list_info;
319318
sp_estate->es_param_exec_vals=estate->es_param_exec_vals;
320319
sp_estate->es_tupleTable=
321-
ExecCreateTupleTable(ExecCountSlotsNode(expr->plan)+10);
320+
ExecCreateTupleTable(ExecCountSlotsNode(subplan->plan)+10);
322321
sp_estate->es_snapshot=estate->es_snapshot;
323322
sp_estate->es_instrument=estate->es_instrument;
324323

325324
/*
326325
* Start up the subplan
327326
*/
328-
sstate->planstate=ExecInitNode(expr->plan,sp_estate);
327+
node->planstate=ExecInitNode(subplan->plan,sp_estate);
329328

330-
sstate->needShutdown= true;/* now we need to shutdown the subplan */
329+
node->needShutdown= true;/* now we need to shutdown the subplan */
331330

332331
/*
333332
* If this plan is un-correlated or undirect correlated one and want
334333
* to set params for parent plan then prepare parameters.
335334
*/
336-
if (expr->setParam!=NIL)
335+
if (subplan->setParam!=NIL)
337336
{
338337
List*lst;
339338

340-
foreach(lst,expr->setParam)
339+
foreach(lst,subplan->setParam)
341340
{
342341
ParamExecData*prm=&(estate->es_param_exec_vals[lfirsti(lst)]);
343342

344-
prm->execPlan=sstate;
343+
prm->execPlan=node;
345344
}
346345

347346
/*
@@ -366,11 +365,11 @@ ExecInitSubPlan(SubPlanExprState *sstate, EState *estate)
366365
* ----------------------------------------------------------------
367366
*/
368367
void
369-
ExecSetParamPlan(SubPlanExprState*node,ExprContext*econtext)
368+
ExecSetParamPlan(SubPlanState*node,ExprContext*econtext)
370369
{
370+
SubPlan*subplan= (SubPlan*)node->xprstate.expr;
371371
PlanState*planstate=node->planstate;
372-
SubPlanExpr*subplan= (SubPlanExpr*)node->xprstate.expr;
373-
SubLinkTypesubLinkType=subplan->sublink->subLinkType;
372+
SubLinkTypesubLinkType=subplan->subLinkType;
374373
MemoryContextoldcontext;
375374
TupleTableSlot*slot;
376375
List*lst;
@@ -473,7 +472,7 @@ ExecSetParamPlan(SubPlanExprState *node, ExprContext *econtext)
473472
* ----------------------------------------------------------------
474473
*/
475474
void
476-
ExecEndSubPlan(SubPlanExprState*node)
475+
ExecEndSubPlan(SubPlanState*node)
477476
{
478477
if (node->needShutdown)
479478
{
@@ -488,10 +487,10 @@ ExecEndSubPlan(SubPlanExprState *node)
488487
}
489488

490489
void
491-
ExecReScanSetParamPlan(SubPlanExprState*node,PlanState*parent)
490+
ExecReScanSetParamPlan(SubPlanState*node,PlanState*parent)
492491
{
493492
PlanState*planstate=node->planstate;
494-
SubPlanExpr*subplan= (SubPlanExpr*)node->xprstate.expr;
493+
SubPlan*subplan= (SubPlan*)node->xprstate.expr;
495494
EState*estate=parent->state;
496495
List*lst;
497496

‎src/backend/nodes/copyfuncs.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.232 2002/12/13 19:45:56 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.233 2002/12/14 00:17:50 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -818,21 +818,22 @@ _copySubLink(SubLink *from)
818818
}
819819

820820
/*
821-
*_copySubPlanExpr
821+
*_copySubPlan
822822
*/
823-
staticSubPlanExpr*
824-
_copySubPlanExpr(SubPlanExpr*from)
823+
staticSubPlan*
824+
_copySubPlan(SubPlan*from)
825825
{
826-
SubPlanExpr*newnode=makeNode(SubPlanExpr);
826+
SubPlan*newnode=makeNode(SubPlan);
827827

828-
COPY_SCALAR_FIELD(typeOid);
828+
COPY_SCALAR_FIELD(subLinkType);
829+
COPY_SCALAR_FIELD(useor);
830+
COPY_NODE_FIELD(oper);
829831
COPY_NODE_FIELD(plan);
830832
COPY_SCALAR_FIELD(plan_id);
831833
COPY_NODE_FIELD(rtable);
832834
COPY_INTLIST_FIELD(setParam);
833835
COPY_INTLIST_FIELD(parParam);
834836
COPY_NODE_FIELD(args);
835-
COPY_NODE_FIELD(sublink);
836837

837838
returnnewnode;
838839
}
@@ -2431,8 +2432,8 @@ copyObject(void *from)
24312432
caseT_SubLink:
24322433
retval=_copySubLink(from);
24332434
break;
2434-
caseT_SubPlanExpr:
2435-
retval=_copySubPlanExpr(from);
2435+
caseT_SubPlan:
2436+
retval=_copySubPlan(from);
24362437
break;
24372438
caseT_FieldSelect:
24382439
retval=_copyFieldSelect(from);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp