mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
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.
This commit is contained in:
parent
9901d8ac2e
commit
8c1d9d56e9
@ -1,12 +1,21 @@
|
|||||||
--
|
--
|
||||||
-- PARALLEL
|
-- 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
|
-- Serializable isolation would disable parallel query, so explicitly use an
|
||||||
-- arbitrary other level.
|
-- arbitrary other level.
|
||||||
begin isolation level repeatable read;
|
begin isolation level repeatable read;
|
||||||
-- setup parallel test
|
-- setup parallel test
|
||||||
set parallel_setup_cost=0;
|
set parallel_setup_cost=0;
|
||||||
set parallel_tuple_cost=0;
|
set parallel_tuple_cost=0;
|
||||||
|
set max_parallel_workers_per_gather=4;
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
select count(*) from a_star;
|
select count(*) from a_star;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
@ -30,6 +39,45 @@ select count(*) from a_star;
|
|||||||
50
|
50
|
||||||
(1 row)
|
(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;
|
set force_parallel_mode=1;
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
select stringu1::int2 from tenk1 where unique1 = 1;
|
select stringu1::int2 from tenk1 where unique1 = 1;
|
||||||
|
@ -2,6 +2,15 @@
|
|||||||
-- PARALLEL
|
-- 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
|
-- Serializable isolation would disable parallel query, so explicitly use an
|
||||||
-- arbitrary other level.
|
-- arbitrary other level.
|
||||||
begin isolation level repeatable read;
|
begin isolation level repeatable read;
|
||||||
@ -9,11 +18,20 @@ begin isolation level repeatable read;
|
|||||||
-- setup parallel test
|
-- setup parallel test
|
||||||
set parallel_setup_cost=0;
|
set parallel_setup_cost=0;
|
||||||
set parallel_tuple_cost=0;
|
set parallel_tuple_cost=0;
|
||||||
|
set max_parallel_workers_per_gather=4;
|
||||||
|
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
select count(*) from a_star;
|
select count(*) from a_star;
|
||||||
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;
|
set force_parallel_mode=1;
|
||||||
|
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user