aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeGather.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor/nodeGather.c')
-rw-r--r--src/backend/executor/nodeGather.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/backend/executor/nodeGather.c b/src/backend/executor/nodeGather.c
index e8d94ee6f38..3aa819f450a 100644
--- a/src/backend/executor/nodeGather.c
+++ b/src/backend/executor/nodeGather.c
@@ -430,6 +430,9 @@ ExecShutdownGather(GatherState *node)
void
ExecReScanGather(GatherState *node)
{
+ Gather *gather = (Gather *) node->ps.plan;
+ PlanState *outerPlan = outerPlanState(node);
+
/*
* Re-initialize the parallel workers to perform rescan of relation. We
* want to gracefully shutdown all the workers so that they should be able
@@ -443,5 +446,22 @@ ExecReScanGather(GatherState *node)
if (node->pei)
ExecParallelReinitialize(node->pei);
- ExecReScan(node->ps.lefttree);
+ /*
+ * Set child node's chgParam to tell it that the next scan might deliver a
+ * different set of rows within the leader process. (The overall rowset
+ * shouldn't change, but the leader process's subset might; hence nodes
+ * between here and the parallel table scan node mustn't optimize on the
+ * assumption of an unchanging rowset.)
+ */
+ if (gather->rescan_param >= 0)
+ outerPlan->chgParam = bms_add_member(outerPlan->chgParam,
+ gather->rescan_param);
+
+
+ /*
+ * if chgParam of subnode is not null then plan will be re-scanned by
+ * first ExecProcNode.
+ */
+ if (outerPlan->chgParam == NULL)
+ ExecReScan(outerPlan);
}