mirror of https://github.com/citusdata/citus.git
Cleanup from dropping PG14
parent
95e00fd2c3
commit
12c6268845
|
|
@ -1,13 +1,3 @@
|
|||
--
|
||||
-- PG15
|
||||
--
|
||||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
|
||||
\gset
|
||||
\if :server_version_ge_15
|
||||
\else
|
||||
\q
|
||||
\endif
|
||||
-- create/drop database for pg >= 15
|
||||
set citus.enable_create_database_propagation=on;
|
||||
CREATE DATABASE mydatabase
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
--
|
||||
-- PG15
|
||||
--
|
||||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
|
||||
\gset
|
||||
\if :server_version_ge_15
|
||||
\else
|
||||
\q
|
||||
|
|
@ -2,7 +2,6 @@ SHOW server_version \gset
|
|||
SELECT CASE
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int >= 17 THEN '17+'
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int IN (15, 16) THEN '15_16'
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int = 14 THEN '14'
|
||||
ELSE 'Unsupported version'
|
||||
END AS version_category;
|
||||
version_category
|
||||
|
|
@ -10,12 +9,6 @@ SELECT CASE
|
|||
17+
|
||||
(1 row)
|
||||
|
||||
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
|
||||
\gset
|
||||
\if :server_version_ge_15
|
||||
\else
|
||||
\q
|
||||
\endif
|
||||
--
|
||||
-- MERGE test from PG community (adapted to Citus by converting all tables to Citus local)
|
||||
--
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ SHOW server_version \gset
|
|||
SELECT CASE
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int >= 17 THEN '17+'
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int IN (15, 16) THEN '15_16'
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int = 14 THEN '14'
|
||||
ELSE 'Unsupported version'
|
||||
END AS version_category;
|
||||
version_category
|
||||
|
|
@ -10,12 +9,6 @@ SELECT CASE
|
|||
15_16
|
||||
(1 row)
|
||||
|
||||
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
|
||||
\gset
|
||||
\if :server_version_ge_15
|
||||
\else
|
||||
\q
|
||||
\endif
|
||||
--
|
||||
-- MERGE test from PG community (adapted to Citus by converting all tables to Citus local)
|
||||
--
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
SHOW server_version \gset
|
||||
SELECT CASE
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int >= 17 THEN '17+'
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int IN (15, 16) THEN '15_16'
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int = 14 THEN '14'
|
||||
ELSE 'Unsupported version'
|
||||
END AS version_category;
|
||||
version_category
|
||||
---------------------------------------------------------------------
|
||||
14
|
||||
(1 row)
|
||||
|
||||
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
|
||||
\gset
|
||||
\if :server_version_ge_15
|
||||
\else
|
||||
\q
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,167 +0,0 @@
|
|||
--
|
||||
-- MULTI_MX_INSERT_SELECT_REPARTITION
|
||||
--
|
||||
-- Test behaviour of repartitioned INSERT ... SELECT in MX setup
|
||||
--
|
||||
-- This test file has an alternative output because of the change in the
|
||||
-- display of SQL-standard function's arguments in INSERT/SELECT in PG15.
|
||||
-- The alternative output can be deleted when we drop support for PG14
|
||||
--
|
||||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15;
|
||||
server_version_ge_15
|
||||
---------------------------------------------------------------------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
CREATE SCHEMA multi_mx_insert_select_repartition;
|
||||
SET search_path TO multi_mx_insert_select_repartition;
|
||||
SET citus.next_shard_id TO 4213581;
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
SET citus.shard_count TO 4;
|
||||
CREATE TABLE source_table(a int, b int);
|
||||
SELECT create_distributed_table('source_table', 'a');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
INSERT INTO source_table SELECT floor(i/4), i*i FROM generate_series(1, 20) i;
|
||||
SET citus.shard_count TO 3;
|
||||
CREATE TABLE target_table(a int, b int);
|
||||
SELECT create_distributed_table('target_table', 'a');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE FUNCTION square(int) RETURNS INT
|
||||
AS $$ SELECT $1 * $1 $$
|
||||
LANGUAGE SQL;
|
||||
select create_distributed_function('square(int)');
|
||||
NOTICE: procedure multi_mx_insert_select_repartition.square is already distributed
|
||||
DETAIL: Citus distributes procedures with CREATE [PROCEDURE|FUNCTION|AGGREGATE] commands
|
||||
create_distributed_function
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select public.colocate_proc_with_table('square', 'source_table'::regclass, 0);
|
||||
colocate_proc_with_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- Test along with function delegation
|
||||
-- function delegation only happens for "SELECT f()", and we don't use
|
||||
-- repartitioned INSERT/SELECT when task count is 1, so the following
|
||||
-- should go via coordinator
|
||||
EXPLAIN (costs off) INSERT INTO target_table(a) SELECT square(4);
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------
|
||||
Custom Scan (Citus INSERT ... SELECT)
|
||||
INSERT/SELECT method: pull to coordinator
|
||||
-> Result
|
||||
(3 rows)
|
||||
|
||||
INSERT INTO target_table(a) SELECT square(4);
|
||||
SELECT * FROM target_table;
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
16 |
|
||||
(1 row)
|
||||
|
||||
TRUNCATE target_table;
|
||||
--
|
||||
-- Test repartitioned INSERT/SELECT from MX worker
|
||||
--
|
||||
\c - - - :worker_1_port
|
||||
SET search_path TO multi_mx_insert_select_repartition;
|
||||
EXPLAIN (costs off) INSERT INTO target_table SELECT a, max(b) FROM source_table GROUP BY a;
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------
|
||||
Custom Scan (Citus INSERT ... SELECT)
|
||||
INSERT/SELECT method: repartition
|
||||
-> Custom Scan (Citus Adaptive)
|
||||
Task Count: 4
|
||||
Tasks Shown: One of 4
|
||||
-> Task
|
||||
Node: host=localhost port=xxxxx dbname=regression
|
||||
-> HashAggregate
|
||||
Group Key: a
|
||||
-> Seq Scan on source_table_4213581 source_table
|
||||
(10 rows)
|
||||
|
||||
INSERT INTO target_table SELECT a, max(b) FROM source_table GROUP BY a;
|
||||
SET citus.log_local_commands to on;
|
||||
-- INSERT .. SELECT via repartitioning with local execution
|
||||
BEGIN;
|
||||
select count(*) from source_table WHERE a = 1;
|
||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM multi_mx_insert_select_repartition.source_table_4213581 source_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
-- we omit the "SELECT bytes FROM fetch_intermediate_results..." line since it is flaky
|
||||
SET LOCAL citus.grep_remote_commands TO '%multi_mx_insert_select_repartition%';
|
||||
insert into target_table SELECT a*2 FROM source_table RETURNING a;
|
||||
NOTICE: executing the command locally: SELECT partition_index, 'repartitioned_results_xxxxx_from_4213581_to' || '_' || partition_index::text , rows_written FROM worker_partition_query_result('repartitioned_results_xxxxx_from_4213581_to','SELECT (a OPERATOR(pg_catalog.*) 2) AS a FROM multi_mx_insert_select_repartition.source_table_4213581 source_table WHERE true',0,'hash','{-2147483648,-715827883,715827882}'::text[],'{-715827884,715827881,2147483647}'::text[],true) WHERE rows_written > 0
|
||||
NOTICE: executing the command locally: SELECT partition_index, 'repartitioned_results_xxxxx_from_4213583_to' || '_' || partition_index::text , rows_written FROM worker_partition_query_result('repartitioned_results_xxxxx_from_4213583_to','SELECT (a OPERATOR(pg_catalog.*) 2) AS a FROM multi_mx_insert_select_repartition.source_table_4213583 source_table WHERE true',0,'hash','{-2147483648,-715827883,715827882}'::text[],'{-715827884,715827881,2147483647}'::text[],true) WHERE rows_written > 0
|
||||
NOTICE: executing the command locally: INSERT INTO multi_mx_insert_select_repartition.target_table_4213585 AS citus_table_alias (a) SELECT a FROM read_intermediate_results('{repartitioned_results_xxxxx_from_4213581_to_0,repartitioned_results_xxxxx_from_4213582_to_0,repartitioned_results_xxxxx_from_4213584_to_0}'::text[], 'binary'::citus_copy_format) intermediate_result(a integer) RETURNING citus_table_alias.a
|
||||
NOTICE: executing the command locally: INSERT INTO multi_mx_insert_select_repartition.target_table_4213587 AS citus_table_alias (a) SELECT a FROM read_intermediate_results('{repartitioned_results_xxxxx_from_4213581_to_2}'::text[], 'binary'::citus_copy_format) intermediate_result(a integer) RETURNING citus_table_alias.a
|
||||
a
|
||||
---------------------------------------------------------------------
|
||||
0
|
||||
0
|
||||
0
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
4
|
||||
4
|
||||
4
|
||||
4
|
||||
6
|
||||
6
|
||||
6
|
||||
6
|
||||
8
|
||||
8
|
||||
8
|
||||
8
|
||||
10
|
||||
(20 rows)
|
||||
|
||||
ROLLBACK;
|
||||
BEGIN;
|
||||
select count(*) from source_table WHERE a = 1;
|
||||
NOTICE: executing the command locally: SELECT count(*) AS count FROM multi_mx_insert_select_repartition.source_table_4213581 source_table WHERE (a OPERATOR(pg_catalog.=) 1)
|
||||
count
|
||||
---------------------------------------------------------------------
|
||||
4
|
||||
(1 row)
|
||||
|
||||
insert into target_table SELECT a FROM source_table LIMIT 10;
|
||||
NOTICE: executing the command locally: SELECT a FROM multi_mx_insert_select_repartition.source_table_4213581 source_table WHERE true LIMIT '10'::bigint
|
||||
NOTICE: executing the command locally: SELECT a FROM multi_mx_insert_select_repartition.source_table_4213583 source_table WHERE true LIMIT '10'::bigint
|
||||
NOTICE: executing the copy locally for shard xxxxx
|
||||
ROLLBACK;
|
||||
\c - - - :master_port
|
||||
SET search_path TO multi_mx_insert_select_repartition;
|
||||
SELECT * FROM target_table ORDER BY a;
|
||||
a | b
|
||||
---------------------------------------------------------------------
|
||||
0 | 9
|
||||
1 | 49
|
||||
2 | 121
|
||||
3 | 225
|
||||
4 | 361
|
||||
5 | 400
|
||||
(6 rows)
|
||||
|
||||
RESET client_min_messages;
|
||||
\set VERBOSITY terse
|
||||
DROP SCHEMA multi_mx_insert_select_repartition CASCADE;
|
||||
NOTICE: drop cascades to 3 other objects
|
||||
|
|
@ -1,276 +0,0 @@
|
|||
CREATE SCHEMA publication;
|
||||
CREATE SCHEMA "publication-1";
|
||||
SET search_path TO publication;
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
CREATE OR REPLACE FUNCTION activate_node_snapshot()
|
||||
RETURNS text[]
|
||||
LANGUAGE C STRICT
|
||||
AS 'citus';
|
||||
COMMENT ON FUNCTION activate_node_snapshot()
|
||||
IS 'commands to activate node snapshot';
|
||||
\c - - - :worker_1_port
|
||||
SET citus.enable_ddl_propagation TO off;
|
||||
CREATE OR REPLACE FUNCTION activate_node_snapshot()
|
||||
RETURNS text[]
|
||||
LANGUAGE C STRICT
|
||||
AS 'citus';
|
||||
COMMENT ON FUNCTION activate_node_snapshot()
|
||||
IS 'commands to activate node snapshot';
|
||||
\c - - - :worker_2_port
|
||||
SET citus.enable_ddl_propagation TO off;
|
||||
CREATE OR REPLACE FUNCTION activate_node_snapshot()
|
||||
RETURNS text[]
|
||||
LANGUAGE C STRICT
|
||||
AS 'citus';
|
||||
COMMENT ON FUNCTION activate_node_snapshot()
|
||||
IS 'commands to activate node snapshot';
|
||||
-- create some publications with conflicting names on worker node
|
||||
-- publication will be different from coordinator
|
||||
CREATE PUBLICATION "pub-all";
|
||||
-- publication will be same as coordinator
|
||||
CREATE PUBLICATION "pub-all-insertupdateonly" FOR ALL TABLES WITH (publish = 'insert, update');;
|
||||
\c - - - :master_port
|
||||
SET search_path TO publication;
|
||||
SET citus.shard_replication_factor TO 1;
|
||||
-- do not create publications on worker 2 initially
|
||||
SELECT citus_remove_node('localhost', :worker_2_port);
|
||||
citus_remove_node
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- create a non-distributed publication
|
||||
SET citus.enable_ddl_propagation TO off;
|
||||
CREATE PUBLICATION pubnotdistributed WITH (publish = 'delete');
|
||||
RESET citus.enable_ddl_propagation;
|
||||
ALTER PUBLICATION pubnotdistributed SET (publish = 'truncate');
|
||||
-- create regular, distributed publications
|
||||
CREATE PUBLICATION pubempty;
|
||||
CREATE PUBLICATION pubinsertonly WITH (publish = 'insert');
|
||||
CREATE PUBLICATION "pub-all" FOR ALL TABLES;
|
||||
CREATE PUBLICATION "pub-all-insertupdateonly" FOR ALL TABLES WITH (publish = 'insert, update');
|
||||
-- add worker 2 with publications
|
||||
SELECT 1 FROM citus_add_node('localhost', :worker_2_port);
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
-- Check publications on all the nodes, if we see the same publication name twice then its definition differs
|
||||
-- Note that publications are special in the sense that the coordinator object might differ from
|
||||
-- worker objects due to the presence of regular tables.
|
||||
SELECT DISTINCT c FROM (
|
||||
SELECT unnest(result::text[]) c
|
||||
FROM run_command_on_workers($$
|
||||
SELECT array_agg(c) FROM (SELECT c FROM unnest(activate_node_snapshot()) c WHERE c LIKE '%CREATE PUBLICATION%' ORDER BY 1) s$$)
|
||||
ORDER BY c) s;
|
||||
c
|
||||
---------------------------------------------------------------------
|
||||
SELECT worker_create_or_replace_object('CREATE PUBLICATION "pub-all" FOR ALL TABLES WITH (publish_via_partition_root = ''false'', publish = ''insert, update, delete, truncate'')');
|
||||
SELECT worker_create_or_replace_object('CREATE PUBLICATION "pub-all-insertupdateonly" FOR ALL TABLES WITH (publish_via_partition_root = ''false'', publish = ''insert, update'')');
|
||||
SELECT worker_create_or_replace_object('CREATE PUBLICATION pubempty WITH (publish_via_partition_root = ''false'', publish = ''insert, update, delete, truncate'')');
|
||||
SELECT worker_create_or_replace_object('CREATE PUBLICATION pubinsertonly WITH (publish_via_partition_root = ''false'', publish = ''insert'')');
|
||||
(4 rows)
|
||||
|
||||
CREATE TABLE test (x int primary key, y int, "column-1" int, doc xml);
|
||||
CREATE TABLE "test-pubs" (x int primary key, y int, "column-1" int);
|
||||
CREATE TABLE "publication-1"."test-pubs" (x int primary key, y int, "column-1" int);
|
||||
-- various operations on a publication with only local tables
|
||||
CREATE PUBLICATION pubtables_orig FOR TABLE test, "test-pubs", "publication-1"."test-pubs" WITH (publish = 'insert, truncate');
|
||||
ALTER PUBLICATION pubtables_orig DROP TABLE test;
|
||||
ALTER PUBLICATION pubtables_orig ADD TABLE test;
|
||||
-- publication will be empty on worker nodes, since all tables are local
|
||||
SELECT DISTINCT c FROM (
|
||||
SELECT unnest(result::text[]) c
|
||||
FROM run_command_on_workers($$
|
||||
SELECT array_agg(c) FROM (SELECT c FROM unnest(activate_node_snapshot()) c WHERE c LIKE '%CREATE PUBLICATION%' AND c LIKE '%pubtables%' ORDER BY 1) s$$)
|
||||
ORDER BY c) s;
|
||||
c
|
||||
---------------------------------------------------------------------
|
||||
SELECT worker_create_or_replace_object('CREATE PUBLICATION pubtables_orig WITH (publish_via_partition_root = ''false'', publish = ''insert, truncate'')');
|
||||
(1 row)
|
||||
|
||||
-- distribute a table and create a tenant schema, creating a mixed publication
|
||||
SELECT create_distributed_table('test','x', colocate_with := 'none');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SET citus.enable_schema_based_sharding TO ON;
|
||||
CREATE SCHEMA citus_schema_1;
|
||||
CREATE TABLE citus_schema_1.test (x int primary key, y int, "column-1" int, doc xml);
|
||||
SET citus.enable_schema_based_sharding TO OFF;
|
||||
ALTER PUBLICATION pubtables_orig ADD TABLE citus_schema_1.test;
|
||||
-- some generic operations
|
||||
ALTER PUBLICATION pubtables_orig RENAME TO pubtables;
|
||||
ALTER PUBLICATION pubtables SET (publish = 'insert, update, delete');
|
||||
ALTER PUBLICATION pubtables OWNER TO postgres;
|
||||
ALTER PUBLICATION pubtables SET (publish = 'inert, update, delete');
|
||||
ERROR: unrecognized "publish" value: "inert"
|
||||
ALTER PUBLICATION pubtables ADD TABLE notexist;
|
||||
ERROR: relation "notexist" does not exist
|
||||
-- operations with a distributed table
|
||||
ALTER PUBLICATION pubtables DROP TABLE test;
|
||||
ALTER PUBLICATION pubtables ADD TABLE test;
|
||||
ALTER PUBLICATION pubtables SET TABLE test, "test-pubs", "publication-1"."test-pubs", citus_schema_1.test;
|
||||
-- operations with a tenant schema table
|
||||
ALTER PUBLICATION pubtables DROP TABLE citus_schema_1.test;
|
||||
ALTER PUBLICATION pubtables ADD TABLE citus_schema_1.test;
|
||||
ALTER PUBLICATION pubtables SET TABLE test, "test-pubs", "publication-1"."test-pubs", citus_schema_1.test;
|
||||
-- operations with a local table in a mixed publication
|
||||
ALTER PUBLICATION pubtables DROP TABLE "test-pubs";
|
||||
ALTER PUBLICATION pubtables ADD TABLE "test-pubs";
|
||||
SELECT create_distributed_table('"test-pubs"', 'x');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- test and test-pubs will show up in worker nodes
|
||||
SELECT DISTINCT c FROM (
|
||||
SELECT unnest(result::text[]) c
|
||||
FROM run_command_on_workers($$
|
||||
SELECT array_agg(c) FROM (SELECT c FROM unnest(activate_node_snapshot()) c WHERE c LIKE '%CREATE PUBLICATION%' AND c LIKE '%pubtables%' ORDER BY 1) s$$)
|
||||
ORDER BY c) s;
|
||||
c
|
||||
---------------------------------------------------------------------
|
||||
SELECT worker_create_or_replace_object('CREATE PUBLICATION pubtables FOR TABLE publication.test, citus_schema_1.test, publication."test-pubs" WITH (publish_via_partition_root = ''false'', publish = ''insert, update, delete'')');
|
||||
(1 row)
|
||||
|
||||
-- operations with a strangely named distributed table in a mixed publication
|
||||
ALTER PUBLICATION pubtables DROP TABLE "test-pubs";
|
||||
ALTER PUBLICATION pubtables ADD TABLE "test-pubs";
|
||||
-- create a publication with distributed and local tables
|
||||
DROP PUBLICATION pubtables;
|
||||
CREATE PUBLICATION pubtables FOR TABLE test, "test-pubs", "publication-1"."test-pubs", citus_schema_1.test;
|
||||
-- change distributed tables
|
||||
SELECT alter_distributed_table('test', shard_count := 5, cascade_to_colocated := true);
|
||||
NOTICE: creating a new table for publication.test
|
||||
NOTICE: moving the data of publication.test
|
||||
NOTICE: dropping the old publication.test
|
||||
NOTICE: renaming the new table to publication.test
|
||||
NOTICE: creating a new table for publication."test-pubs"
|
||||
NOTICE: moving the data of publication."test-pubs"
|
||||
NOTICE: dropping the old publication."test-pubs"
|
||||
NOTICE: renaming the new table to publication."test-pubs"
|
||||
alter_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT undistribute_table('test');
|
||||
NOTICE: creating a new table for publication.test
|
||||
NOTICE: moving the data of publication.test
|
||||
NOTICE: dropping the old publication.test
|
||||
NOTICE: renaming the new table to publication.test
|
||||
undistribute_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT citus_add_local_table_to_metadata('test');
|
||||
citus_add_local_table_to_metadata
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT create_distributed_table_concurrently('test', 'x');
|
||||
create_distributed_table_concurrently
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT undistribute_table('"test-pubs"');
|
||||
NOTICE: creating a new table for publication."test-pubs"
|
||||
NOTICE: moving the data of publication."test-pubs"
|
||||
NOTICE: dropping the old publication."test-pubs"
|
||||
NOTICE: renaming the new table to publication."test-pubs"
|
||||
undistribute_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT create_reference_table('"test-pubs"');
|
||||
create_reference_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- publications are unchanged despite various tranformations
|
||||
SELECT DISTINCT c FROM (
|
||||
SELECT unnest(result::text[]) c
|
||||
FROM run_command_on_workers($$
|
||||
SELECT array_agg(c) FROM (SELECT c FROM unnest(activate_node_snapshot()) c WHERE c LIKE '%CREATE PUBLICATION%' AND c LIKE '%pubtables%' ORDER BY 1) s$$)
|
||||
ORDER BY c) s;
|
||||
c
|
||||
---------------------------------------------------------------------
|
||||
SELECT worker_create_or_replace_object('CREATE PUBLICATION pubtables FOR TABLE citus_schema_1.test, publication.test, publication."test-pubs" WITH (publish_via_partition_root = ''false'', publish = ''insert, update, delete, truncate'')');
|
||||
(1 row)
|
||||
|
||||
-- partitioned table
|
||||
CREATE TABLE testpub_partitioned (a int, b text, c text) PARTITION BY RANGE (a);
|
||||
CREATE TABLE testpub_partitioned_0 PARTITION OF testpub_partitioned FOR VALUES FROM (1) TO (10);
|
||||
ALTER TABLE testpub_partitioned_0 ADD PRIMARY KEY (a);
|
||||
ALTER TABLE testpub_partitioned_0 REPLICA IDENTITY USING INDEX testpub_partitioned_0_pkey;
|
||||
CREATE TABLE testpub_partitioned_1 PARTITION OF testpub_partitioned FOR VALUES FROM (11) TO (20);
|
||||
ALTER TABLE testpub_partitioned_1 ADD PRIMARY KEY (a);
|
||||
ALTER TABLE testpub_partitioned_1 REPLICA IDENTITY USING INDEX testpub_partitioned_1_pkey;
|
||||
CREATE PUBLICATION pubpartitioned FOR TABLE testpub_partitioned WITH (publish_via_partition_root = 'true');
|
||||
SELECT create_distributed_table('testpub_partitioned', 'a');
|
||||
create_distributed_table
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT DISTINCT c FROM (
|
||||
SELECT unnest(result::text[]) c
|
||||
FROM run_command_on_workers($$
|
||||
SELECT array_agg(c) FROM (SELECT c FROM unnest(activate_node_snapshot()) c WHERE c LIKE '%CREATE PUBLICATION%' AND c LIKE '%pubpartitioned%' ORDER BY 1) s$$)
|
||||
ORDER BY c) s;
|
||||
c
|
||||
---------------------------------------------------------------------
|
||||
SELECT worker_create_or_replace_object('CREATE PUBLICATION pubpartitioned FOR TABLE publication.testpub_partitioned WITH (publish_via_partition_root = ''true'', publish = ''insert, update, delete, truncate'')');
|
||||
(1 row)
|
||||
|
||||
DROP PUBLICATION pubpartitioned;
|
||||
CREATE PUBLICATION pubpartitioned FOR TABLE testpub_partitioned WITH (publish_via_partition_root = 'true');
|
||||
-- add a partition
|
||||
ALTER PUBLICATION pubpartitioned ADD TABLE testpub_partitioned_1;
|
||||
SELECT DISTINCT c FROM (
|
||||
SELECT unnest(result::text[]) c
|
||||
FROM run_command_on_workers($$
|
||||
SELECT array_agg(c) FROM (SELECT c FROM unnest(activate_node_snapshot()) c WHERE c LIKE '%CREATE PUBLIATION%' AND c LIKE '%pubpartitioned%' ORDER BY 1) s$$)
|
||||
ORDER BY c) s;
|
||||
ERROR: malformed array literal: ""
|
||||
DETAIL: Array value must start with "{" or dimension information.
|
||||
-- make sure we can sync all the publication metadata
|
||||
SELECT start_metadata_sync_to_all_nodes();
|
||||
start_metadata_sync_to_all_nodes
|
||||
---------------------------------------------------------------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
DROP PUBLICATION pubempty;
|
||||
DROP PUBLICATION pubtables;
|
||||
DROP PUBLICATION pubinsertonly;
|
||||
DROP PUBLICATION "pub-all-insertupdateonly";
|
||||
DROP PUBLICATION "pub-all";
|
||||
DROP PUBLICATION pubpartitioned;
|
||||
DROP PUBLICATION pubnotdistributed;
|
||||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
|
||||
\gset
|
||||
\if :server_version_ge_15
|
||||
\else
|
||||
SET client_min_messages TO ERROR;
|
||||
DROP SCHEMA publication CASCADE;
|
||||
DROP SCHEMA "publication-1" CASCADE;
|
||||
DROP SCHEMA citus_schema_1 CASCADE;
|
||||
SELECT public.wait_for_resource_cleanup();
|
||||
wait_for_resource_cleanup
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\q
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,14 +1,3 @@
|
|||
--
|
||||
-- PG15
|
||||
--
|
||||
SHOW server_version \gset
|
||||
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
|
||||
\gset
|
||||
\if :server_version_ge_15
|
||||
\else
|
||||
\q
|
||||
\endif
|
||||
|
||||
-- create/drop database for pg >= 15
|
||||
|
||||
set citus.enable_create_database_propagation=on;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,9 @@
|
|||
|
||||
|
||||
SHOW server_version \gset
|
||||
SELECT CASE
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int >= 17 THEN '17+'
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int IN (15, 16) THEN '15_16'
|
||||
WHEN substring(current_setting('server_version'), '\d+')::int = 14 THEN '14'
|
||||
ELSE 'Unsupported version'
|
||||
END AS version_category;
|
||||
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
|
||||
\gset
|
||||
\if :server_version_ge_15
|
||||
\else
|
||||
\q
|
||||
\endif
|
||||
|
||||
--
|
||||
-- MERGE test from PG community (adapted to Citus by converting all tables to Citus local)
|
||||
|
|
|
|||
Loading…
Reference in New Issue