Skip to content

Commit d104677

Browse files
robertmhaaskelvich
authored andcommitted
Fix EXPLAIN ANALYZE SELECT INTO not to choose a parallel plan.
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
1 parent 3599636 commit d104677

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/backend/commands/explain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ ExplainOneQuery(Query *query, IntoClause *into, ExplainState *es,
347347
INSTR_TIME_SET_CURRENT(planstart);
348348

349349
/* plan the query */
350-
plan = pg_plan_query(query, CURSOR_OPT_PARALLEL_OK, params);
350+
plan = pg_plan_query(query, into ? 0 : CURSOR_OPT_PARALLEL_OK, params);
351351

352352
INSTR_TIME_SET_CURRENT(planduration);
353353
INSTR_TIME_SUBTRACT(planduration, planstart);

src/test/regress/expected/select_into.out

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ SELECT * FROM created_table;
7474
4567890123456789 | -4567890123456789
7575
(5 rows)
7676

77+
-- Try EXPLAIN ANALYZE SELECT INTO, but hide the output since it won't
78+
-- be stable.
79+
DO $$
80+
BEGIN
81+
EXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl';
82+
END$$;
7783
DROP TABLE created_table;
84+
DROP TABLE easi;
7885
--
7986
-- Disallowed uses of SELECT ... INTO. All should fail
8087
--

src/test/regress/sql/select_into.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,15 @@ SELECT make_table();
6666

6767
SELECT * FROM created_table;
6868

69+
-- Try EXPLAIN ANALYZE SELECT INTO, but hide the output since it won't
70+
-- be stable.
71+
DO $$
72+
BEGIN
73+
EXECUTE 'EXPLAIN ANALYZE SELECT * INTO TABLE easi FROM int8_tbl';
74+
END$$;
75+
6976
DROP TABLE created_table;
77+
DROP TABLE easi;
7078

7179
--
7280
-- Disallowed uses of SELECT ... INTO. All should fail

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy