From 8c1d9d56e9a00680a035b8b333a98ea16b121eb7 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 16 Jun 2016 12:00:55 -0400 Subject: [PATCH] Add regression test for 04ae11f62e643e07c411c4935ea6af46cb112aa9. The code in this area needs further revision, and it would be best not to re-break the things we've already fixed. Per a gripe from Tom Lane. --- src/test/regress/expected/select_parallel.out | 48 +++++++++++++++++++ src/test/regress/sql/select_parallel.sql | 18 +++++++ 2 files changed, 66 insertions(+) diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out index 709e64e038..b51c20c449 100644 --- a/src/test/regress/expected/select_parallel.out +++ b/src/test/regress/expected/select_parallel.out @@ -1,12 +1,21 @@ -- -- PARALLEL -- +create or replace function parallel_restricted(int) returns int as $$ +begin + perform * from pg_stat_activity where client_port is null; + if (found) then + raise 'parallel restricted function run in worker'; + end if; + return $1; +end$$ language plpgsql parallel restricted; -- Serializable isolation would disable parallel query, so explicitly use an -- arbitrary other level. begin isolation level repeatable read; -- setup parallel test set parallel_setup_cost=0; set parallel_tuple_cost=0; +set max_parallel_workers_per_gather=4; explain (costs off) select count(*) from a_star; QUERY PLAN @@ -30,6 +39,45 @@ select count(*) from a_star; 50 (1 row) +-- test that parallel_restricted function doesn't run in worker +alter table tenk1 set (parallel_workers = 4); +explain (verbose, costs off) +select parallel_restricted(unique1) from tenk1 + where stringu1 = 'GRAAAA' order by 1; + QUERY PLAN +--------------------------------------------------------- + Sort + Output: (parallel_restricted(unique1)) + Sort Key: (parallel_restricted(tenk1.unique1)) + -> Gather + Output: parallel_restricted(unique1) + Workers Planned: 4 + -> Parallel Seq Scan on public.tenk1 + Output: unique1 + Filter: (tenk1.stringu1 = 'GRAAAA'::name) +(9 rows) + +select parallel_restricted(unique1) from tenk1 + where stringu1 = 'GRAAAA' order by 1; + parallel_restricted +--------------------- + 448 + 1124 + 1800 + 2476 + 3152 + 3828 + 4504 + 5180 + 5856 + 6532 + 7208 + 7884 + 8560 + 9236 + 9912 +(15 rows) + set force_parallel_mode=1; explain (costs off) select stringu1::int2 from tenk1 where unique1 = 1; diff --git a/src/test/regress/sql/select_parallel.sql b/src/test/regress/sql/select_parallel.sql index ef18848957..22dfb184c8 100644 --- a/src/test/regress/sql/select_parallel.sql +++ b/src/test/regress/sql/select_parallel.sql @@ -2,6 +2,15 @@ -- PARALLEL -- +create or replace function parallel_restricted(int) returns int as $$ +begin + perform * from pg_stat_activity where client_port is null; + if (found) then + raise 'parallel restricted function run in worker'; + end if; + return $1; +end$$ language plpgsql parallel restricted; + -- Serializable isolation would disable parallel query, so explicitly use an -- arbitrary other level. begin isolation level repeatable read; @@ -9,11 +18,20 @@ begin isolation level repeatable read; -- setup parallel test set parallel_setup_cost=0; set parallel_tuple_cost=0; +set max_parallel_workers_per_gather=4; explain (costs off) select count(*) from a_star; select count(*) from a_star; +-- test that parallel_restricted function doesn't run in worker +alter table tenk1 set (parallel_workers = 4); +explain (verbose, costs off) +select parallel_restricted(unique1) from tenk1 + where stringu1 = 'GRAAAA' order by 1; +select parallel_restricted(unique1) from tenk1 + where stringu1 = 'GRAAAA' order by 1; + set force_parallel_mode=1; explain (costs off) -- 2.40.0