aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2016-12-06 11:11:54 -0500
committerRobert Haas <rhaas@postgresql.org>2016-12-06 11:11:54 -0500
commit4212cb73262bbdd164727beffa4c4744b4ead92d (patch)
tree6c1190d09f2783722cc8f31643f414dc95d1d3c5 /src
parentcb9dcbc1eebd8cccf98d7236b2c9bb82caf8b45d (diff)
downloadpostgresql-4212cb73262bbdd164727beffa4c4744b4ead92d.tar.gz
postgresql-4212cb73262bbdd164727beffa4c4744b4ead92d.zip
Fix interaction of parallel query with prepared statements.
Previously, a prepared statement created via a Parse message could get a parallel plan, but one created with a PREPARE statement could not. This state of affairs was due to confusion on my (rhaas) part: I erroneously believed that a CREATE TABLE .. AS EXECUTE statement could only be performed with a prepared statement by PREPARE, but in fact one created by a Prepare message works just as well. Therefore, it makes no sense to allow parallel query in one case but not the other. To fix, allow parallel query with all prepared statements, but run the parallel plan serially (i.e. without workers) in the case of CREATE TABLE .. AS EXECUTE. Also, document this. Amit Kapila and Tobias Bussman, plus an extra sentence of documentation by me.
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/prepare.c2
-rw-r--r--src/backend/executor/execMain.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index cec37ce0405..b01051df9d2 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -159,7 +159,7 @@ PrepareQuery(PrepareStmt *stmt, const char *queryString)
nargs,
NULL,
NULL,
- 0, /* default cursor options */
+ CURSOR_OPT_PARALLEL_OK, /* allow parallel mode */
true); /* fixed result */
/*
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 32bb3f92054..71c07288a19 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1540,10 +1540,11 @@ ExecutePlan(EState *estate,
estate->es_direction = direction;
/*
- * If a tuple count was supplied, we must force the plan to run without
- * parallelism, because we might exit early.
+ * If a tuple count was supplied or data is being written to relation, we
+ * must force the plan to run without parallelism, because we might exit
+ * early.
*/
- if (numberTuples)
+ if (numberTuples || dest->mydest == DestIntoRel)
use_parallel_mode = false;
/*