Add test for marking converted table as autoConverted=false

talha_tes1
Ahmet Gedemenli 2021-10-21 19:29:58 +03:00
parent 546b3d2c06
commit 02d77fb04e
2 changed files with 60 additions and 3 deletions

View File

@ -493,6 +493,44 @@ SELECT logicalrelid, autoconverted FROM pg_dist_partition
citus_local_table_3 | f
(3 rows)
-- verify that tables that are connected to reference tables are marked as autoConverted = true
CREATE TABLE ref_test(a int UNIQUE);
SELECT create_reference_table('ref_test');
create_reference_table
---------------------------------------------------------------------
(1 row)
CREATE TABLE auto_local_table_1(a int UNIQUE);
CREATE TABLE auto_local_table_2(a int UNIQUE REFERENCES auto_local_table_1(a));
ALTER TABLE auto_local_table_1 ADD CONSTRAINT fkey_to_ref_tbl FOREIGN KEY (a) REFERENCES ref_test(a);
SELECT logicalrelid, autoconverted FROM pg_dist_partition
WHERE logicalrelid IN ('auto_local_table_1'::regclass,
'auto_local_table_2'::regclass)
ORDER BY logicalrelid;
logicalrelid | autoconverted
---------------------------------------------------------------------
auto_local_table_1 | t
auto_local_table_2 | t
(2 rows)
-- verify that we can mark both of them with autoConverted = false, by converting one of them manually
SELECT citus_add_local_table_to_metadata('auto_local_table_1');
citus_add_local_table_to_metadata
---------------------------------------------------------------------
(1 row)
SELECT logicalrelid, autoconverted FROM pg_dist_partition
WHERE logicalrelid IN ('auto_local_table_1'::regclass,
'auto_local_table_2'::regclass)
ORDER BY logicalrelid;
logicalrelid | autoconverted
---------------------------------------------------------------------
auto_local_table_1 | f
auto_local_table_2 | f
(2 rows)
-- a single drop table cascades into multiple undistributes
DROP TABLE IF EXISTS citus_local_table_1, citus_local_table_2, citus_local_table_3, citus_local_table_2, reference_table_1;
CREATE TABLE reference_table_1(r1 int UNIQUE, r2 int);
@ -530,9 +568,9 @@ ALTER TABLE reference_table_1 OWNER TO another_user;
SELECT run_command_on_placements('reference_table_1', 'ALTER TABLE %s OWNER TO another_user');
run_command_on_placements
---------------------------------------------------------------------
(localhost,57636,1810042,t,"ALTER TABLE")
(localhost,57637,1810042,t,"ALTER TABLE")
(localhost,57638,1810042,t,"ALTER TABLE")
(localhost,57636,1810045,t,"ALTER TABLE")
(localhost,57637,1810045,t,"ALTER TABLE")
(localhost,57638,1810045,t,"ALTER TABLE")
(3 rows)
SET citus.enable_ddl_propagation to ON;

View File

@ -230,6 +230,25 @@ SELECT logicalrelid, autoconverted FROM pg_dist_partition
'citus_local_table_3'::regclass)
ORDER BY logicalrelid;
-- verify that tables that are connected to reference tables are marked as autoConverted = true
CREATE TABLE ref_test(a int UNIQUE);
SELECT create_reference_table('ref_test');
CREATE TABLE auto_local_table_1(a int UNIQUE);
CREATE TABLE auto_local_table_2(a int UNIQUE REFERENCES auto_local_table_1(a));
ALTER TABLE auto_local_table_1 ADD CONSTRAINT fkey_to_ref_tbl FOREIGN KEY (a) REFERENCES ref_test(a);
SELECT logicalrelid, autoconverted FROM pg_dist_partition
WHERE logicalrelid IN ('auto_local_table_1'::regclass,
'auto_local_table_2'::regclass)
ORDER BY logicalrelid;
-- verify that we can mark both of them with autoConverted = false, by converting one of them manually
SELECT citus_add_local_table_to_metadata('auto_local_table_1');
SELECT logicalrelid, autoconverted FROM pg_dist_partition
WHERE logicalrelid IN ('auto_local_table_1'::regclass,
'auto_local_table_2'::regclass)
ORDER BY logicalrelid;
-- a single drop table cascades into multiple undistributes
DROP TABLE IF EXISTS citus_local_table_1, citus_local_table_2, citus_local_table_3, citus_local_table_2, reference_table_1;
CREATE TABLE reference_table_1(r1 int UNIQUE, r2 int);