--1. prepare data and table
--source data
create table x1(a int, b int, c int);
create index on x1(a);
insert into x1 select generate_series(1,200000000),floor(random()*(10001-1)+1),floor(random()*(10001-1)+1);

create or replace function func_restricted ()
returns int language plpgsql parallel restricted as $$
begin
	RETURN 10;
end $$;

--begin test
--CTAS test on master
--1. parallel select, max_parallel_workers_per_gather =2(default)
drop table if exists test;
set max_parallel_workers_per_gather = 2 ;
explain analyze verbose create table test as select func_restricted(),b,c from x1 where a%2=0 or a%3=0;

--2. parallel select, max_parallel_workers_per_gather =4
drop table if exists test;
set max_parallel_workers_per_gather = 4 ;
explain analyze verbose create table test as select func_restricted(),b,c from x1 where a%2=0 or a%3=0;

--3. parallel select, max_parallel_workers_per_gather =8
drop table if exists test;
set max_parallel_workers_per_gather = 8 ;
explain analyze verbose create table test as select func_restricted(),b,c from x1 where a%2=0 or a%3=0;

--4. serial select, max_parallel_workers_per_gather =0
drop table if exists test;
set max_parallel_workers_per_gather = 0 ;
explain analyze verbose create table test as select func_restricted(),b,c from x1 where a%2=0 or a%3=0;