aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execParallel.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2015-10-16 11:56:02 -0400
committerRobert Haas <rhaas@postgresql.org>2015-10-16 11:56:02 -0400
commitbfc78d7196eb28cd4e3d6c24f7e607bacecf1129 (patch)
treee13e9937fcfc2666def5dfad1aa8cdd6038fdd78 /src/backend/executor/execParallel.c
parent816e336f12ecabdc834d4cc31bcf966b2dd323dc (diff)
downloadpostgresql-bfc78d7196eb28cd4e3d6c24f7e607bacecf1129.tar.gz
postgresql-bfc78d7196eb28cd4e3d6c24f7e607bacecf1129.zip
Rewrite interaction of parallel mode with parallel executor support.
In the previous coding, before returning from ExecutorRun, we'd shut down all parallel workers. This was dead wrong if ExecutorRun was called with a non-zero tuple count; it had the effect of truncating the query output. To fix, give ExecutePlan control over whether to enter parallel mode, and have it refuse to do so if the tuple count is non-zero. Rewrite the Gather logic so that it can cope with being called outside parallel mode. Commit 7aea8e4f2daa4b39ca9d1309a0c4aadb0f7ed81b is largely to blame for this problem, though this patch modifies some subsequently-committed code which relied on the guarantees it purported to make.
Diffstat (limited to 'src/backend/executor/execParallel.c')
-rw-r--r--src/backend/executor/execParallel.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c
index e6930c1d51c..3bb820692d2 100644
--- a/src/backend/executor/execParallel.c
+++ b/src/backend/executor/execParallel.c
@@ -443,6 +443,23 @@ ExecParallelFinish(ParallelExecutorInfo *pei)
}
/*
+ * Clean up whatever ParallelExecutreInfo resources still exist after
+ * ExecParallelFinish. We separate these routines because someone might
+ * want to examine the contents of the DSM after ExecParallelFinish and
+ * before calling this routine.
+ */
+void
+ExecParallelCleanup(ParallelExecutorInfo *pei)
+{
+ if (pei->pcxt != NULL)
+ {
+ DestroyParallelContext(pei->pcxt);
+ pei->pcxt = NULL;
+ }
+ pfree(pei);
+}
+
+/*
* Create a DestReceiver to write tuples we produce to the shm_mq designated
* for that purpose.
*/