aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/executor/execMain.c1
-rw-r--r--src/backend/executor/execUtils.c2
-rw-r--r--src/backend/executor/nodeGather.c2
-rw-r--r--src/backend/executor/nodeGatherMerge.c2
-rw-r--r--src/include/nodes/execnodes.h2
5 files changed, 7 insertions, 2 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index ac7e0fb48b3..684470928a4 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1704,6 +1704,7 @@ ExecutePlan(EState *estate,
if (!execute_once || dest->mydest == DestIntoRel)
use_parallel_mode = false;
+ estate->es_use_parallel_mode = use_parallel_mode;
if (use_parallel_mode)
EnterParallelMode();
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index c3988468795..a5925ca7e3b 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -156,6 +156,8 @@ CreateExecutorState(void)
estate->es_epqScanDone = NULL;
estate->es_sourceText = NULL;
+ estate->es_use_parallel_mode = false;
+
/*
* Return the executor state structure
*/
diff --git a/src/backend/executor/nodeGather.c b/src/backend/executor/nodeGather.c
index 3be735f5c33..89f592828c1 100644
--- a/src/backend/executor/nodeGather.c
+++ b/src/backend/executor/nodeGather.c
@@ -149,7 +149,7 @@ ExecGather(PlanState *pstate)
* Sometimes we might have to run without parallelism; but if parallel
* mode is active then we can try to fire up some workers.
*/
- if (gather->num_workers > 0 && IsInParallelMode())
+ if (gather->num_workers > 0 && estate->es_use_parallel_mode)
{
ParallelContext *pcxt;
diff --git a/src/backend/executor/nodeGatherMerge.c b/src/backend/executor/nodeGatherMerge.c
index c0c285bd611..6b173543564 100644
--- a/src/backend/executor/nodeGatherMerge.c
+++ b/src/backend/executor/nodeGatherMerge.c
@@ -193,7 +193,7 @@ ExecGatherMerge(PlanState *pstate)
* Sometimes we might have to run without parallelism; but if parallel
* mode is active then we can try to fire up some workers.
*/
- if (gm->num_workers > 0 && IsInParallelMode())
+ if (gm->num_workers > 0 && estate->es_use_parallel_mode)
{
ParallelContext *pcxt;
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 9c790baaaa5..4f5da00c863 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -507,6 +507,8 @@ typedef struct EState
bool *es_epqTupleSet; /* true if EPQ tuple is provided */
bool *es_epqScanDone; /* true if EPQ tuple has been fetched */
+ bool es_use_parallel_mode; /* can we use parallel workers? */
+
/* The per-query shared memory area to use for parallel execution. */
struct dsa_area *es_query_dsa;
} EState;