Fix EXPLAIN ANALYZE SELECT INTO not to choose a parallel plan.
authorRobert Haas
Mon, 14 Mar 2016 23:48:46 +0000 (19:48 -0400)
committerRobert Haas
Mon, 14 Mar 2016 23:48:46 +0000 (19:48 -0400)
We don't support any parallel write operations at present, so choosing
a parallel plan causes us to error out.  Also, add a new regression
test that uses EXPLAIN ANALYZE SELECT INTO; if we'd had this previously,
force_parallel_mode testing would have caught this issue.

Mithun Cy and Robert Haas

src/backend/commands/explain.c
src/test/regress/expected/select_into.out
src/test/regress/sql/select_into.sql

index ee13136b7fd6c11c3529d86c590ac98c0cfef835..9cd31279379d3ef8689bc01f3e8998663e3f721a 100644 (file)
@@ -347,7 +347,7 @@ ExplainOneQuery(Query *query, IntoClause *into, ExplainState *es,
        INSTR_TIME_SET_CURRENT(planstart);
 
        /* plan the query */
-       plan = pg_plan_query(query, CURSOR_OPT_PARALLEL_OK, params);
+       plan = pg_plan_query(query, into ? 0 : CURSOR_OPT_PARALLEL_OK, params);
 
        INSTR_TIME_SET_CURRENT(planduration);
        INSTR_TIME_SUBTRACT(planduration, planstart);
index 9d3f04758e91c66295b47d4a23624bb963ab748b..b577d1b3ccb6eb73110e62e1df7e93e0105015ac 100644 (file)
@@ -74,7 +74,14 @@ SELECT * FROM created_table;
  4567890123456789 | -4567890123456789
 (5 rows)
 
+-- Try EXPLAIN ANALYZE SELECT INTO, but hide the output since it won't
+-- be stable.
+DO $$
+BEGIN
+   EXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl';
+END$$;
 DROP TABLE created_table;
+DROP TABLE easi;
 --
 -- Disallowed uses of SELECT ... INTO.  All should fail
 --
index 4d1cc86556b4a9899c84ca93863d695c971f199e..e4460aea2fd5162441356f59165fe3ac22ee2d77 100644 (file)
@@ -66,7 +66,15 @@ SELECT make_table();
 
 SELECT * FROM created_table;
 
+-- Try EXPLAIN ANALYZE SELECT INTO, but hide the output since it won't
+-- be stable.
+DO $$
+BEGIN
+   EXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl';
+END$$;
+
 DROP TABLE created_table;
+DROP TABLE easi;
 
 --
 -- Disallowed uses of SELECT ... INTO.  All should fail