fix_parallel_mode_nested_execution_v1.patch
application/octet-stream
Filename: fix_parallel_mode_nested_execution_v1.patch
Type: application/octet-stream
Part: 2
Message:
Parallel safety for extern params
Patch
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| src/backend/executor/execMain.c | 19 | 0 |
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 8359beb..28164c1 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1684,6 +1684,7 @@ ExecutePlan(EState *estate,
{
TupleTableSlot *slot;
uint64 current_tuple_count;
+ bool exit_parallel_mode = false;
/*
* initialize local variables
@@ -1700,8 +1701,20 @@ ExecutePlan(EState *estate,
* it to run without parallelism, because we might exit early.
*/
if (!execute_once)
+ {
use_parallel_mode = false;
+ /*
+ * If we are already in parallel mode, then temporarily exit from that
+ * mode and renter in it once the execution is complete.
+ */
+ if (IsInParallelMode())
+ {
+ ExitParallelMode();
+ exit_parallel_mode = true;
+ }
+ }
+
if (use_parallel_mode)
EnterParallelMode();
@@ -1777,6 +1790,12 @@ ExecutePlan(EState *estate,
}
}
+ if (exit_parallel_mode)
+ {
+ Assert(!use_parallel_mode);
+ EnterParallelMode();
+ }
+
if (use_parallel_mode)
ExitParallelMode();
}