PG16 compatibility - some test outputs (#7100)

PG16 compatibility - Part 3

Check out part 1 42d956888d
and part 2 0d503dd5ac

This commit is in the series of PG compatibility. It makes some changes
to our tests in order to be compatible with the following in PG16:

Use debug_parallel_query in PG16+, force_parallel_mode otherwise 
Relevant PG commit
5352ca22e0
5352ca22e0012d48055453ca9992a9515d811291

HINT changed to DETAIL in PG16 
Relevant PG commit:
56d0ed3b75
56d0ed3b756b2e3799a7bbc0ac89bc7657ca2c33

Fix removed read-only server setting lc_collate 
Relevant PG commit:
b0f6c43716
b0f6c437160db640d4ea3e49398ebc3ba39d1982

Fix unsupported join alias expression in sqlancer_failures 
Relevant PG commit:
2489d76c49
2489d76c4906f4461a364ca8ad7e0751ead8aa0d

More PG16 compatibility commits are coming soon ...
pull/7097/head
Naisila Puka 2023-08-04 13:03:15 +03:00 committed by GitHub
parent 4ae3982d14
commit 907d72e60d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 168 additions and 28 deletions

View File

@ -1,5 +1,6 @@
-- test for Postgres version
-- should error before PG12
--
-- ALTER_TABLE_SET_ACCESS_METHOD
--
CREATE TABLE alter_am_pg_version_table (a INT);
SELECT alter_table_set_access_method('alter_am_pg_version_table', 'columnar');
NOTICE: creating a new table for public.alter_am_pg_version_table
@ -770,8 +771,15 @@ RESET client_min_messages;
create table events (event_id bigserial, event_time timestamptz default now(), payload text);
create index on events (event_id);
insert into events (payload) select 'hello-'||s from generate_series(1,10) s;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
BEGIN;
\if :server_version_ge_16
SET LOCAL debug_parallel_query = regress;
\else
SET LOCAL force_parallel_mode = regress;
\endif
SET LOCAL min_parallel_table_scan_size = 1;
SET LOCAL parallel_tuple_cost = 0;
SET LOCAL max_parallel_workers = 4;

View File

@ -21,7 +21,14 @@ select count(*), min(i), max(i), avg(i) from fallback_scan;
-- Negative test: try to force a parallel plan with at least two
-- workers, but columnar should reject it and use a non-parallel scan.
--
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
\if :server_version_ge_16
set debug_parallel_query = regress;
\else
set force_parallel_mode = regress;
\endif
set min_parallel_table_scan_size = 1;
set parallel_tuple_cost = 0;
set max_parallel_workers = 4;
@ -39,7 +46,11 @@ select count(*), min(i), max(i), avg(i) from fallback_scan;
150000 | 1 | 150000 | 75000.500000000000
(1 row)
set force_parallel_mode to default;
\if :server_version_ge_16
set debug_parallel_query = default;
\else
set force_parallel_mode = default;
\endif
set min_parallel_table_scan_size to default;
set parallel_tuple_cost to default;
set max_parallel_workers to default;

View File

@ -1,4 +1,6 @@
--
-- COLUMNAR_INDEXES
--
-- Testing indexes on on columnar tables.
--
CREATE SCHEMA columnar_indexes;
@ -598,6 +600,9 @@ create table events (event_id bigserial, event_time timestamptz default now(), p
BEGIN;
-- this wouldn't flush any data
insert into events (payload) select 'hello-'||s from generate_series(1, 10) s;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
-- Since table is large enough, normally postgres would prefer using
-- parallel workers when building the index.
--
@ -609,7 +614,11 @@ BEGIN;
-- by postgres and throws an error. For this reason, here we don't expect
-- following commnad to fail since we prevent using parallel workers for
-- columnar tables.
\if :server_version_ge_16
SET LOCAL debug_parallel_query = regress;
\else
SET LOCAL force_parallel_mode = regress;
\endif
SET LOCAL min_parallel_table_scan_size = 1;
SET LOCAL parallel_tuple_cost = 0;
SET LOCAL max_parallel_workers = 4;

View File

@ -1,3 +1,6 @@
--
-- COLUMNAR_PARTITIONING
--
CREATE TABLE parent(ts timestamptz, i int, n numeric, s text)
PARTITION BY RANGE (ts);
-- row partitions
@ -17,8 +20,15 @@ INSERT INTO parent SELECT '2020-03-15', 30, 300, 'three thousand'
FROM generate_series(1,100000);
INSERT INTO parent SELECT '2020-04-15', 30, 300, 'three thousand'
FROM generate_series(1,100000);
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
-- run parallel plans
\if :server_version_ge_16
SET debug_parallel_query = regress;
\else
SET force_parallel_mode = regress;
\endif
SET min_parallel_table_scan_size = 1;
SET parallel_tuple_cost = 0;
SET max_parallel_workers = 4;
@ -121,7 +131,11 @@ SELECT count(*), sum(i), min(i), max(i) FROM parent;
(1 row)
SET columnar.enable_custom_scan TO DEFAULT;
\if :server_version_ge_16
SET debug_parallel_query TO DEFAULT;
\else
SET force_parallel_mode TO DEFAULT;
\endif
SET min_parallel_table_scan_size TO DEFAULT;
SET parallel_tuple_cost TO DEFAULT;
SET max_parallel_workers TO DEFAULT;

View File

@ -53,7 +53,16 @@ CREATE OPERATOR citus_mx_test_schema.=== (
HASHES, MERGES
);
SET search_path TO public;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
\if :server_version_ge_16
-- In PG16, read-only server settings lc_collate and lc_ctype are removed
-- Relevant PG commit: b0f6c437160db640d4ea3e49398ebc3ba39d1982
SELECT quote_ident((SELECT CASE WHEN datlocprovider='i' THEN daticulocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) as current_locale \gset
\else
SELECT quote_ident(current_setting('lc_collate')) as current_locale \gset
\endif
CREATE COLLATION citus_mx_test_schema.english (LOCALE=:current_locale);
CREATE TYPE citus_mx_test_schema.new_composite_type as (key1 text, key2 text);
CREATE TYPE order_side_mx AS ENUM ('buy', 'sell');

View File

@ -347,7 +347,16 @@ SELECT * FROM nation_hash ORDER BY 1,2,3,4;
--test COLLATION with schema
SET search_path TO public;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
\if :server_version_ge_16
-- In PG16, read-only server settings lc_collate and lc_ctype are removed
-- Relevant PG commit: b0f6c437160db640d4ea3e49398ebc3ba39d1982
SELECT quote_ident((SELECT CASE WHEN datlocprovider='i' THEN daticulocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) as current_locale \gset
\else
SELECT quote_ident(current_setting('lc_collate')) as current_locale \gset
\endif
CREATE COLLATION test_schema_support.english (LOCALE = :current_locale);
\c - - - :master_port
SET citus.shard_replication_factor TO 2;

View File

@ -1089,9 +1089,10 @@ SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one' ORDER BY
1 | 4 | one | -1
(1 row)
\set VERBOSITY terse
SELECT * FROM (J1_TBL JOIN J2_TBL USING (i)) AS x WHERE J1_TBL.t = 'one' ORDER BY 1,2,3,4; -- error
ERROR: invalid reference to FROM-clause entry for table "j1_tbl"
HINT: There is an entry for table "j1_tbl", but it cannot be referenced from this part of the query.
ERROR: invalid reference to FROM-clause entry for table "j1_tbl" at character 57
\set VERBOSITY default
SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.i = 1 ORDER BY 1,2,3,4; -- ok
i | j | t | k
---------------------------------------------------------------------

View File

@ -226,13 +226,14 @@ WHEN NOT MATCHED THEN
ERROR: permission denied for table target2
-- check if the target can be accessed from source relation subquery; we should
-- not be able to do so
\set VERBOSITY terse
MERGE INTO target t
USING (SELECT * FROM source WHERE t.tid > sid) s
ON t.tid = s.sid
WHEN NOT MATCHED THEN
INSERT DEFAULT VALUES;
ERROR: invalid reference to FROM-clause entry for table "t"
HINT: There is an entry for table "t", but it cannot be referenced from this part of the query.
ERROR: invalid reference to FROM-clause entry for table "t" at character 55
\set VERBOSITY default
--
-- initial tests
--
@ -660,13 +661,13 @@ SELECT * FROM target ORDER BY tid;
ROLLBACK;
-- and again with a subtle error: referring to non-existent target row for NOT MATCHED
\set VERBOSITY terse
MERGE INTO target t
USING source AS s
ON t.tid = s.sid
WHEN NOT MATCHED THEN
INSERT (tid, balance) VALUES (t.tid, s.delta);
ERROR: invalid reference to FROM-clause entry for table "t"
HINT: There is an entry for table "t", but it cannot be referenced from this part of the query.
ERROR: invalid reference to FROM-clause entry for table "t" at character 109
-- and again with a constant ON clause
BEGIN;
MERGE INTO target t
@ -674,8 +675,7 @@ USING source AS s
ON (SELECT true)
WHEN NOT MATCHED THEN
INSERT (tid, balance) VALUES (t.tid, s.delta);
ERROR: invalid reference to FROM-clause entry for table "t"
HINT: There is an entry for table "t", but it cannot be referenced from this part of the query.
ERROR: invalid reference to FROM-clause entry for table "t" at character 109
SELECT * FROM target ORDER BY tid;
ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK;
@ -779,11 +779,11 @@ MERGE INTO wq_target t
USING wq_source s ON t.tid = s.sid
WHEN NOT MATCHED AND t.balance = 100 THEN
INSERT (tid) VALUES (s.sid);
ERROR: invalid reference to FROM-clause entry for table "t"
HINT: There is an entry for table "t", but it cannot be referenced from this part of the query.
ERROR: invalid reference to FROM-clause entry for table "t" at character 80
SELECT * FROM wq_target;
ERROR: current transaction is aborted, commands ignored until end of transaction block
ROLLBACK;
\set VERBOSITY default
MERGE INTO wq_target t
USING wq_source s ON t.tid = s.sid
WHEN NOT MATCHED AND s.balance = 100 THEN

View File

@ -416,11 +416,11 @@ ON (true);
SELECT
COUNT(unsupported_join.*)
FROM
(distributed_table a
((distributed_table a
LEFT JOIN reference_table b ON (true)
RIGHT JOIN reference_table c ON (false)) as unsupported_join
RIGHT JOIN reference_table c ON (false))
RIGHT JOIN
(reference_table d JOIN reference_table e ON(true)) ON (true);
(reference_table d JOIN reference_table e ON(true)) ON (true)) as unsupported_join;
count
---------------------------------------------------------------------
125
@ -429,9 +429,9 @@ RIGHT JOIN
SELECT
COUNT(unsupported_join.*)
FROM
(distributed_table a
((distributed_table a
LEFT JOIN (SELECT * FROM reference_table OFFSET 0) b ON (true)
RIGHT JOIN (SELECT * FROM reference_table OFFSET 0) c ON (false)) as unsupported_join
RIGHT JOIN (SELECT * FROM reference_table OFFSET 0) c ON (false))
RIGHT JOIN
(
(SELECT * FROM reference_table OFFSET 0) d
@ -439,7 +439,7 @@ RIGHT JOIN
(SELECT * FROM reference_table OFFSET 0) e
ON(true)
)
ON (true);
ON (true)) as unsupported_join;
count
---------------------------------------------------------------------
125

View File

@ -1,5 +1,7 @@
-- test for Postgres version
-- should error before PG12
--
-- ALTER_TABLE_SET_ACCESS_METHOD
--
CREATE TABLE alter_am_pg_version_table (a INT);
SELECT alter_table_set_access_method('alter_am_pg_version_table', 'columnar');
DROP TABLE alter_am_pg_version_table;
@ -258,8 +260,16 @@ create table events (event_id bigserial, event_time timestamptz default now(), p
create index on events (event_id);
insert into events (payload) select 'hello-'||s from generate_series(1,10) s;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
BEGIN;
\if :server_version_ge_16
SET LOCAL debug_parallel_query = regress;
\else
SET LOCAL force_parallel_mode = regress;
\endif
SET LOCAL min_parallel_table_scan_size = 1;
SET LOCAL parallel_tuple_cost = 0;
SET LOCAL max_parallel_workers = 4;

View File

@ -20,7 +20,16 @@ select count(*), min(i), max(i), avg(i) from fallback_scan;
-- Negative test: try to force a parallel plan with at least two
-- workers, but columnar should reject it and use a non-parallel scan.
--
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
\if :server_version_ge_16
set debug_parallel_query = regress;
\else
set force_parallel_mode = regress;
\endif
set min_parallel_table_scan_size = 1;
set parallel_tuple_cost = 0;
set max_parallel_workers = 4;
@ -28,7 +37,11 @@ set max_parallel_workers_per_gather = 4;
explain (costs off) select count(*), min(i), max(i), avg(i) from fallback_scan;
select count(*), min(i), max(i), avg(i) from fallback_scan;
set force_parallel_mode to default;
\if :server_version_ge_16
set debug_parallel_query = default;
\else
set force_parallel_mode = default;
\endif
set min_parallel_table_scan_size to default;
set parallel_tuple_cost to default;
set max_parallel_workers to default;

View File

@ -1,4 +1,6 @@
--
-- COLUMNAR_INDEXES
--
-- Testing indexes on on columnar tables.
--
@ -448,6 +450,10 @@ BEGIN;
-- this wouldn't flush any data
insert into events (payload) select 'hello-'||s from generate_series(1, 10) s;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
-- Since table is large enough, normally postgres would prefer using
-- parallel workers when building the index.
--
@ -459,7 +465,12 @@ BEGIN;
-- by postgres and throws an error. For this reason, here we don't expect
-- following commnad to fail since we prevent using parallel workers for
-- columnar tables.
\if :server_version_ge_16
SET LOCAL debug_parallel_query = regress;
\else
SET LOCAL force_parallel_mode = regress;
\endif
SET LOCAL min_parallel_table_scan_size = 1;
SET LOCAL parallel_tuple_cost = 0;
SET LOCAL max_parallel_workers = 4;

View File

@ -1,3 +1,6 @@
--
-- COLUMNAR_PARTITIONING
--
CREATE TABLE parent(ts timestamptz, i int, n numeric, s text)
PARTITION BY RANGE (ts);
@ -21,8 +24,16 @@ INSERT INTO parent SELECT '2020-03-15', 30, 300, 'three thousand'
INSERT INTO parent SELECT '2020-04-15', 30, 300, 'three thousand'
FROM generate_series(1,100000);
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
-- run parallel plans
\if :server_version_ge_16
SET debug_parallel_query = regress;
\else
SET force_parallel_mode = regress;
\endif
SET min_parallel_table_scan_size = 1;
SET parallel_tuple_cost = 0;
SET max_parallel_workers = 4;
@ -46,7 +57,11 @@ EXPLAIN (costs off) SELECT count(*), sum(i), min(i), max(i) FROM parent;
SELECT count(*), sum(i), min(i), max(i) FROM parent;
SET columnar.enable_custom_scan TO DEFAULT;
\if :server_version_ge_16
SET debug_parallel_query TO DEFAULT;
\else
SET force_parallel_mode TO DEFAULT;
\endif
SET min_parallel_table_scan_size TO DEFAULT;
SET parallel_tuple_cost TO DEFAULT;
SET max_parallel_workers TO DEFAULT;

View File

@ -51,7 +51,19 @@ CREATE OPERATOR citus_mx_test_schema.=== (
);
SET search_path TO public;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
\if :server_version_ge_16
-- In PG16, read-only server settings lc_collate and lc_ctype are removed
-- Relevant PG commit: b0f6c437160db640d4ea3e49398ebc3ba39d1982
SELECT quote_ident((SELECT CASE WHEN datlocprovider='i' THEN daticulocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) as current_locale \gset
\else
SELECT quote_ident(current_setting('lc_collate')) as current_locale \gset
\endif
CREATE COLLATION citus_mx_test_schema.english (LOCALE=:current_locale);
CREATE TYPE citus_mx_test_schema.new_composite_type as (key1 text, key2 text);

View File

@ -293,7 +293,19 @@ SELECT * FROM nation_hash ORDER BY 1,2,3,4;
--test COLLATION with schema
SET search_path TO public;
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 16 AS server_version_ge_16
\gset
\if :server_version_ge_16
-- In PG16, read-only server settings lc_collate and lc_ctype are removed
-- Relevant PG commit: b0f6c437160db640d4ea3e49398ebc3ba39d1982
SELECT quote_ident((SELECT CASE WHEN datlocprovider='i' THEN daticulocale ELSE datcollate END FROM pg_database WHERE datname = current_database())) as current_locale \gset
\else
SELECT quote_ident(current_setting('lc_collate')) as current_locale \gset
\endif
CREATE COLLATION test_schema_support.english (LOCALE = :current_locale);
\c - - - :master_port

View File

@ -509,7 +509,9 @@ SELECT create_distributed_table('J2_TBL','i');
-- test join using aliases
SELECT * FROM J1_TBL JOIN J2_TBL USING (i) WHERE J1_TBL.t = 'one' ORDER BY 1,2,3,4; -- ok
SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one' ORDER BY 1,2,3,4; -- ok
\set VERBOSITY terse
SELECT * FROM (J1_TBL JOIN J2_TBL USING (i)) AS x WHERE J1_TBL.t = 'one' ORDER BY 1,2,3,4; -- error
\set VERBOSITY default
SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.i = 1 ORDER BY 1,2,3,4; -- ok
SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.t = 'one' ORDER BY 1,2,3,4; -- error
SELECT * FROM (J1_TBL JOIN J2_TBL USING (i) AS x) AS xx WHERE x.i = 1 ORDER BY 1,2,3,4; -- error (XXX could use better hint)

View File

@ -180,11 +180,13 @@ WHEN NOT MATCHED THEN
-- check if the target can be accessed from source relation subquery; we should
-- not be able to do so
\set VERBOSITY terse
MERGE INTO target t
USING (SELECT * FROM source WHERE t.tid > sid) s
ON t.tid = s.sid
WHEN NOT MATCHED THEN
INSERT DEFAULT VALUES;
\set VERBOSITY default
--
-- initial tests
--
@ -431,6 +433,7 @@ SELECT * FROM target ORDER BY tid;
ROLLBACK;
-- and again with a subtle error: referring to non-existent target row for NOT MATCHED
\set VERBOSITY terse
MERGE INTO target t
USING source AS s
ON t.tid = s.sid
@ -520,6 +523,7 @@ WHEN NOT MATCHED AND t.balance = 100 THEN
INSERT (tid) VALUES (s.sid);
SELECT * FROM wq_target;
ROLLBACK;
\set VERBOSITY default
MERGE INTO wq_target t
USING wq_source s ON t.tid = s.sid

View File

@ -237,18 +237,18 @@ ON (true);
SELECT
COUNT(unsupported_join.*)
FROM
(distributed_table a
((distributed_table a
LEFT JOIN reference_table b ON (true)
RIGHT JOIN reference_table c ON (false)) as unsupported_join
RIGHT JOIN reference_table c ON (false))
RIGHT JOIN
(reference_table d JOIN reference_table e ON(true)) ON (true);
(reference_table d JOIN reference_table e ON(true)) ON (true)) as unsupported_join;
SELECT
COUNT(unsupported_join.*)
FROM
(distributed_table a
((distributed_table a
LEFT JOIN (SELECT * FROM reference_table OFFSET 0) b ON (true)
RIGHT JOIN (SELECT * FROM reference_table OFFSET 0) c ON (false)) as unsupported_join
RIGHT JOIN (SELECT * FROM reference_table OFFSET 0) c ON (false))
RIGHT JOIN
(
(SELECT * FROM reference_table OFFSET 0) d
@ -256,7 +256,7 @@ RIGHT JOIN
(SELECT * FROM reference_table OFFSET 0) e
ON(true)
)
ON (true);
ON (true)) as unsupported_join;
EXPLAIN (COSTS OFF) SELECT
unsupported_join.*