1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

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.
This commit is contained in:
Robert Haas
2015-05-04 16:13:07 -04:00
parent 2503982be4
commit 40f42d2a34
6 changed files with 27 additions and 18 deletions

View File

@ -2053,6 +2053,7 @@ void
ExecReScanAgg(AggState *node) ExecReScanAgg(AggState *node)
{ {
ExprContext *econtext = node->ss.ps.ps_ExprContext; ExprContext *econtext = node->ss.ps.ps_ExprContext;
PlanState *outerPlan = outerPlanState(node);
int aggno; int aggno;
node->agg_done = false; node->agg_done = false;
@ -2075,7 +2076,7 @@ ExecReScanAgg(AggState *node)
* parameter changes, then we can just rescan the existing hash table; * parameter changes, then we can just rescan the existing hash table;
* no need to build it again. * no need to build it again.
*/ */
if (node->ss.ps.lefttree->chgParam == NULL) if (outerPlan->chgParam == NULL)
{ {
ResetTupleHashIterator(node->hashtable, &node->hashiter); ResetTupleHashIterator(node->hashtable, &node->hashiter);
return; return;
@ -2133,8 +2134,8 @@ ExecReScanAgg(AggState *node)
* if chgParam of subnode is not null then plan will be re-scanned by * if chgParam of subnode is not null then plan will be re-scanned by
* first ExecProcNode. * first ExecProcNode.
*/ */
if (node->ss.ps.lefttree->chgParam == NULL) if (outerPlan->chgParam == NULL)
ExecReScan(node->ss.ps.lefttree); ExecReScan(outerPlan);
} }

View File

@ -449,6 +449,8 @@ ExecBitmapHeapScan(BitmapHeapScanState *node)
void void
ExecReScanBitmapHeapScan(BitmapHeapScanState *node) ExecReScanBitmapHeapScan(BitmapHeapScanState *node)
{ {
PlanState *outerPlan = outerPlanState(node);
/* rescan to release any page pin */ /* rescan to release any page pin */
heap_rescan(node->ss.ss_currentScanDesc, NULL); heap_rescan(node->ss.ss_currentScanDesc, NULL);
@ -469,8 +471,8 @@ ExecReScanBitmapHeapScan(BitmapHeapScanState *node)
* if chgParam of subnode is not null then plan will be re-scanned by * if chgParam of subnode is not null then plan will be re-scanned by
* first ExecProcNode. * first ExecProcNode.
*/ */
if (node->ss.ps.lefttree->chgParam == NULL) if (outerPlan->chgParam == NULL)
ExecReScan(node->ss.ps.lefttree); ExecReScan(outerPlan);
} }
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------

View File

@ -280,6 +280,8 @@ ExecEndGroup(GroupState *node)
void void
ExecReScanGroup(GroupState *node) ExecReScanGroup(GroupState *node)
{ {
PlanState *outerPlan = outerPlanState(node);
node->grp_done = FALSE; node->grp_done = FALSE;
node->ss.ps.ps_TupFromTlist = false; node->ss.ps.ps_TupFromTlist = false;
/* must clear first tuple */ /* must clear first tuple */
@ -289,7 +291,6 @@ ExecReScanGroup(GroupState *node)
* if chgParam of subnode is not null then plan will be re-scanned by * if chgParam of subnode is not null then plan will be re-scanned by
* first ExecProcNode. * first ExecProcNode.
*/ */
if (node->ss.ps.lefttree && if (outerPlan->chgParam == NULL)
node->ss.ps.lefttree->chgParam == NULL) ExecReScan(outerPlan);
ExecReScan(node->ss.ps.lefttree);
} }

View File

@ -317,6 +317,8 @@ ExecMaterialRestrPos(MaterialState *node)
void void
ExecReScanMaterial(MaterialState *node) ExecReScanMaterial(MaterialState *node)
{ {
PlanState *outerPlan = outerPlanState(node);
ExecClearTuple(node->ss.ps.ps_ResultTupleSlot); ExecClearTuple(node->ss.ps.ps_ResultTupleSlot);
if (node->eflags != 0) if (node->eflags != 0)
@ -339,13 +341,13 @@ ExecReScanMaterial(MaterialState *node)
* Otherwise we can just rewind and rescan the stored output. The * Otherwise we can just rewind and rescan the stored output. The
* state of the subnode does not change. * state of the subnode does not change.
*/ */
if (node->ss.ps.lefttree->chgParam != NULL || if (outerPlan->chgParam != NULL ||
(node->eflags & EXEC_FLAG_REWIND) == 0) (node->eflags & EXEC_FLAG_REWIND) == 0)
{ {
tuplestore_end(node->tuplestorestate); tuplestore_end(node->tuplestorestate);
node->tuplestorestate = NULL; node->tuplestorestate = NULL;
if (node->ss.ps.lefttree->chgParam == NULL) if (outerPlan->chgParam == NULL)
ExecReScan(node->ss.ps.lefttree); ExecReScan(outerPlan);
node->eof_underlying = false; node->eof_underlying = false;
} }
else else
@ -359,8 +361,8 @@ ExecReScanMaterial(MaterialState *node)
* if chgParam of subnode is not null then plan will be re-scanned by * if chgParam of subnode is not null then plan will be re-scanned by
* first ExecProcNode. * first ExecProcNode.
*/ */
if (node->ss.ps.lefttree->chgParam == NULL) if (outerPlan->chgParam == NULL)
ExecReScan(node->ss.ps.lefttree); ExecReScan(outerPlan);
node->eof_underlying = false; node->eof_underlying = false;
} }
} }

View File

@ -290,6 +290,8 @@ ExecSortRestrPos(SortState *node)
void void
ExecReScanSort(SortState *node) ExecReScanSort(SortState *node)
{ {
PlanState *outerPlan = outerPlanState(node);
/* /*
* If we haven't sorted yet, just return. If outerplan's chgParam is not * If we haven't sorted yet, just return. If outerplan's chgParam is not
* NULL then it will be re-scanned by ExecProcNode, else no reason to * NULL then it will be re-scanned by ExecProcNode, else no reason to
@ -308,7 +310,7 @@ ExecReScanSort(SortState *node)
* *
* Otherwise we can just rewind and rescan the sorted output. * Otherwise we can just rewind and rescan the sorted output.
*/ */
if (node->ss.ps.lefttree->chgParam != NULL || if (outerPlan->chgParam != NULL ||
node->bounded != node->bounded_Done || node->bounded != node->bounded_Done ||
node->bound != node->bound_Done || node->bound != node->bound_Done ||
!node->randomAccess) !node->randomAccess)
@ -321,8 +323,8 @@ ExecReScanSort(SortState *node)
* if chgParam of subnode is not null then plan will be re-scanned by * if chgParam of subnode is not null then plan will be re-scanned by
* first ExecProcNode. * first ExecProcNode.
*/ */
if (node->ss.ps.lefttree->chgParam == NULL) if (outerPlan->chgParam == NULL)
ExecReScan(node->ss.ps.lefttree); ExecReScan(outerPlan);
} }
else else
tuplesort_rescan((Tuplesortstate *) node->tuplesortstate); tuplesort_rescan((Tuplesortstate *) node->tuplesortstate);

View File

@ -2057,6 +2057,7 @@ ExecEndWindowAgg(WindowAggState *node)
void void
ExecReScanWindowAgg(WindowAggState *node) ExecReScanWindowAgg(WindowAggState *node)
{ {
PlanState *outerPlan = outerPlanState(node);
ExprContext *econtext = node->ss.ps.ps_ExprContext; ExprContext *econtext = node->ss.ps.ps_ExprContext;
node->all_done = false; node->all_done = false;
@ -2082,8 +2083,8 @@ ExecReScanWindowAgg(WindowAggState *node)
* if chgParam of subnode is not null then plan will be re-scanned by * if chgParam of subnode is not null then plan will be re-scanned by
* first ExecProcNode. * first ExecProcNode.
*/ */
if (node->ss.ps.lefttree->chgParam == NULL) if (outerPlan->chgParam == NULL)
ExecReScan(node->ss.ps.lefttree); ExecReScan(outerPlan);
} }
/* /*