Skip to content

Commit 40f42d2

Browse files
committed
Use outerPlanState macro instead of referring to leffttree.
This makes the executor code more consistent. It also removes an apparently superfluous NULL test in nodeGroup.c. Qingqing Zhou, reviewed by Tom Lane, and further revised by me.
1 parent 2503982 commit 40f42d2

File tree

6 files changed

+27
-18
lines changed

6 files changed

+27
-18
lines changed

src/backend/executor/nodeAgg.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,6 +2053,7 @@ void
20532053
ExecReScanAgg(AggState *node)
20542054
{
20552055
ExprContext *econtext = node->ss.ps.ps_ExprContext;
2056+
PlanState *outerPlan = outerPlanState(node);
20562057
int aggno;
20572058

20582059
node->agg_done = false;
@@ -2075,7 +2076,7 @@ ExecReScanAgg(AggState *node)
20752076
* parameter changes, then we can just rescan the existing hash table;
20762077
* no need to build it again.
20772078
*/
2078-
if (node->ss.ps.lefttree->chgParam == NULL)
2079+
if (outerPlan->chgParam == NULL)
20792080
{
20802081
ResetTupleHashIterator(node->hashtable, &node->hashiter);
20812082
return;
@@ -2133,8 +2134,8 @@ ExecReScanAgg(AggState *node)
21332134
* if chgParam of subnode is not null then plan will be re-scanned by
21342135
* first ExecProcNode.
21352136
*/
2136-
if (node->ss.ps.lefttree->chgParam == NULL)
2137-
ExecReScan(node->ss.ps.lefttree);
2137+
if (outerPlan->chgParam == NULL)
2138+
ExecReScan(outerPlan);
21382139
}
21392140

21402141

src/backend/executor/nodeBitmapHeapscan.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ ExecBitmapHeapScan(BitmapHeapScanState *node)
449449
void
450450
ExecReScanBitmapHeapScan(BitmapHeapScanState *node)
451451
{
452+
PlanState *outerPlan = outerPlanState(node);
453+
452454
/* rescan to release any page pin */
453455
heap_rescan(node->ss.ss_currentScanDesc, NULL);
454456

@@ -469,8 +471,8 @@ ExecReScanBitmapHeapScan(BitmapHeapScanState *node)
469471
* if chgParam of subnode is not null then plan will be re-scanned by
470472
* first ExecProcNode.
471473
*/
472-
if (node->ss.ps.lefttree->chgParam == NULL)
473-
ExecReScan(node->ss.ps.lefttree);
474+
if (outerPlan->chgParam == NULL)
475+
ExecReScan(outerPlan);
474476
}
475477

476478
/* ----------------------------------------------------------------

src/backend/executor/nodeGroup.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ ExecEndGroup(GroupState *node)
280280
void
281281
ExecReScanGroup(GroupState *node)
282282
{
283+
PlanState *outerPlan = outerPlanState(node);
284+
283285
node->grp_done = FALSE;
284286
node->ss.ps.ps_TupFromTlist = false;
285287
/* must clear first tuple */
@@ -289,7 +291,6 @@ ExecReScanGroup(GroupState *node)
289291
* if chgParam of subnode is not null then plan will be re-scanned by
290292
* first ExecProcNode.
291293
*/
292-
if (node->ss.ps.lefttree &&
293-
node->ss.ps.lefttree->chgParam == NULL)
294-
ExecReScan(node->ss.ps.lefttree);
294+
if (outerPlan->chgParam == NULL)
295+
ExecReScan(outerPlan);
295296
}

src/backend/executor/nodeMaterial.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ ExecMaterialRestrPos(MaterialState *node)
317317
void
318318
ExecReScanMaterial(MaterialState *node)
319319
{
320+
PlanState *outerPlan = outerPlanState(node);
321+
320322
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
321323

322324
if (node->eflags != 0)
@@ -339,13 +341,13 @@ ExecReScanMaterial(MaterialState *node)
339341
* Otherwise we can just rewind and rescan the stored output. The
340342
* state of the subnode does not change.
341343
*/
342-
if (node->ss.ps.lefttree->chgParam != NULL ||
344+
if (outerPlan->chgParam != NULL ||
343345
(node->eflags & EXEC_FLAG_REWIND) == 0)
344346
{
345347
tuplestore_end(node->tuplestorestate);
346348
node->tuplestorestate = NULL;
347-
if (node->ss.ps.lefttree->chgParam == NULL)
348-
ExecReScan(node->ss.ps.lefttree);
349+
if (outerPlan->chgParam == NULL)
350+
ExecReScan(outerPlan);
349351
node->eof_underlying = false;
350352
}
351353
else
@@ -359,8 +361,8 @@ ExecReScanMaterial(MaterialState *node)
359361
* if chgParam of subnode is not null then plan will be re-scanned by
360362
* first ExecProcNode.
361363
*/
362-
if (node->ss.ps.lefttree->chgParam == NULL)
363-
ExecReScan(node->ss.ps.lefttree);
364+
if (outerPlan->chgParam == NULL)
365+
ExecReScan(outerPlan);
364366
node->eof_underlying = false;
365367
}
366368
}

src/backend/executor/nodeSort.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ ExecSortRestrPos(SortState *node)
290290
void
291291
ExecReScanSort(SortState *node)
292292
{
293+
PlanState *outerPlan = outerPlanState(node);
294+
293295
/*
294296
* If we haven't sorted yet, just return. If outerplan's chgParam is not
295297
* NULL then it will be re-scanned by ExecProcNode, else no reason to
@@ -308,7 +310,7 @@ ExecReScanSort(SortState *node)
308310
*
309311
* Otherwise we can just rewind and rescan the sorted output.
310312
*/
311-
if (node->ss.ps.lefttree->chgParam != NULL ||
313+
if (outerPlan->chgParam != NULL ||
312314
node->bounded != node->bounded_Done ||
313315
node->bound != node->bound_Done ||
314316
!node->randomAccess)
@@ -321,8 +323,8 @@ ExecReScanSort(SortState *node)
321323
* if chgParam of subnode is not null then plan will be re-scanned by
322324
* first ExecProcNode.
323325
*/
324-
if (node->ss.ps.lefttree->chgParam == NULL)
325-
ExecReScan(node->ss.ps.lefttree);
326+
if (outerPlan->chgParam == NULL)
327+
ExecReScan(outerPlan);
326328
}
327329
else
328330
tuplesort_rescan((Tuplesortstate *) node->tuplesortstate);

src/backend/executor/nodeWindowAgg.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,6 +2057,7 @@ ExecEndWindowAgg(WindowAggState *node)
20572057
void
20582058
ExecReScanWindowAgg(WindowAggState *node)
20592059
{
2060+
PlanState *outerPlan = outerPlanState(node);
20602061
ExprContext *econtext = node->ss.ps.ps_ExprContext;
20612062

20622063
node->all_done = false;
@@ -2082,8 +2083,8 @@ ExecReScanWindowAgg(WindowAggState *node)
20822083
* if chgParam of subnode is not null then plan will be re-scanned by
20832084
* first ExecProcNode.
20842085
*/
2085-
if (node->ss.ps.lefttree->chgParam == NULL)
2086-
ExecReScan(node->ss.ps.lefttree);
2086+
if (outerPlan->chgParam == NULL)
2087+
ExecReScan(outerPlan);
20872088
}
20882089

20892090
/*

0 commit comments

Comments
 (0)