Fix tests: multi-1 and MX

talha_tes1
Ahmet Gedemenli 2021-09-24 17:19:50 +03:00
parent e07d5c8530
commit cdcb2c4049
6 changed files with 11 additions and 81 deletions

View File

@ -424,7 +424,7 @@ BEGIN;
(1 row)
-- should not see any citus local tables
-- should see only local_table_3, since it's the only one that is converted by the user
SELECT logicalrelid::regclass::text FROM pg_dist_partition, pg_tables
WHERE tablename=logicalrelid::regclass::text AND
schemaname='citus_local_tables_test_schema' AND
@ -432,7 +432,8 @@ BEGIN;
ORDER BY 1;
logicalrelid
---------------------------------------------------------------------
(0 rows)
local_table_3
(1 row)
ROLLBACK;
-- define foreign keys between dummy_reference_table and citus local tables

View File

@ -329,49 +329,6 @@ BEGIN;
-- show that we validate foreign key constraints, errors out
INSERT INTO local_table_5 VALUES (300);
ERROR: insert or update on table "local_table_5_1518073" violates foreign key constraint "local_table_5_col_1_fkey1_1518073"
ROLLBACK;
BEGIN;
CREATE SCHEMA another_schema_fkeys_between_local_ref;
CREATE TABLE another_schema_fkeys_between_local_ref.local_table_6 (col_1 INT PRIMARY KEY);
-- first convert local tables to citus local tables in graph
ALTER TABLE local_table_2 ADD CONSTRAINT fkey_11 FOREIGN KEY (col_1) REFERENCES reference_table_1(col_1) ON DELETE CASCADE;
CREATE TABLE local_table_5 (
col_1 INT UNIQUE REFERENCES another_schema_fkeys_between_local_ref.local_table_6(col_1) CHECK (col_1 > 0),
col_2 INT REFERENCES local_table_3(col_1),
FOREIGN KEY (col_1) REFERENCES local_table_5(col_1));
-- Now show that we converted local_table_5 & 6 to citus local tables
-- as local_table_5 has foreign key to a citus local table too
SELECT logicalrelid::text AS tablename, partmethod, repmodel FROM pg_dist_partition
WHERE logicalrelid::text IN (SELECT tablename FROM pg_tables WHERE schemaname='fkeys_between_local_ref' UNION
SELECT 'another_schema_fkeys_between_local_ref.local_table_6')
ORDER BY tablename;
tablename | partmethod | repmodel
---------------------------------------------------------------------
another_schema_fkeys_between_local_ref.local_table_6 | n | s
distributed_table | h | s
local_table_1 | n | s
local_table_2 | n | s
local_table_3 | n | s
local_table_4 | n | s
local_table_5 | n | s
reference_table_1 | n | t
(8 rows)
DROP TABLE local_table_3 CASCADE;
DROP SCHEMA another_schema_fkeys_between_local_ref CASCADE;
-- now we shouldn't see local_table_5 since now it is not connected to any reference tables
SELECT logicalrelid::text AS tablename, partmethod, repmodel FROM pg_dist_partition
WHERE logicalrelid::text IN (SELECT tablename FROM pg_tables WHERE schemaname='fkeys_between_local_ref')
ORDER BY tablename;
tablename | partmethod | repmodel
---------------------------------------------------------------------
distributed_table | h | s
local_table_1 | n | s
local_table_2 | n | s
local_table_4 | n | s
reference_table_1 | n | t
(5 rows)
ROLLBACK;
BEGIN;
CREATE TABLE local_table_6 (col_1 INT PRIMARY KEY);

View File

@ -19,7 +19,7 @@ COMMENT ON FUNCTION master_metadata_snapshot()
IS 'commands to create the metadata snapshot';
-- Show that none of the existing tables are qualified to be MX tables
SELECT * FROM pg_dist_partition WHERE partmethod='h' AND repmodel='s';
logicalrelid | partmethod | partkey | colocationid | repmodel
logicalrelid | partmethod | partkey | colocationid | repmodel | autoconverted
---------------------------------------------------------------------
(0 rows)
@ -273,9 +273,9 @@ SELECT * FROM pg_dist_node ORDER BY nodeid;
(4 rows)
SELECT * FROM pg_dist_partition ORDER BY logicalrelid;
logicalrelid | partmethod | partkey | colocationid | repmodel
logicalrelid | partmethod | partkey | colocationid | repmodel | autoconverted
---------------------------------------------------------------------
mx_testing_schema.mx_test_table | h | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 0 | s
mx_testing_schema.mx_test_table | h | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 0 | s | f
(1 row)
SELECT * FROM pg_dist_shard ORDER BY shardid;
@ -410,9 +410,9 @@ SELECT * FROM pg_dist_node ORDER BY nodeid;
(4 rows)
SELECT * FROM pg_dist_partition ORDER BY logicalrelid;
logicalrelid | partmethod | partkey | colocationid | repmodel
logicalrelid | partmethod | partkey | colocationid | repmodel | autoconverted
---------------------------------------------------------------------
mx_testing_schema.mx_test_table | h | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 0 | s
mx_testing_schema.mx_test_table | h | {VAR :varno 1 :varattno 1 :vartype 23 :vartypmod -1 :varcollid 0 :varlevelsup 0 :varnoold 1 :varoattno 1 :location -1} | 0 | s | f
(1 row)
SELECT * FROM pg_dist_shard ORDER BY shardid;
@ -731,7 +731,7 @@ ORDER BY
\d mx_test_schema_1.mx_table_1
\d mx_test_schema_2.mx_table_2
SELECT * FROM pg_dist_partition;
logicalrelid | partmethod | partkey | colocationid | repmodel
logicalrelid | partmethod | partkey | colocationid | repmodel | autoconverted
---------------------------------------------------------------------
(0 rows)

View File

@ -60,7 +60,7 @@ DROP TABLE testtableddl;
RESET citus.shard_replication_factor;
-- ensure no metadata of distributed tables are remaining
SELECT * FROM pg_dist_partition;
logicalrelid | partmethod | partkey | colocationid | repmodel
logicalrelid | partmethod | partkey | colocationid | repmodel | autoconverted
---------------------------------------------------------------------
(0 rows)

View File

@ -1248,7 +1248,7 @@ NOTICE: renaming the new table to single_node.test_2
(1 row)
SELECT * FROM pg_dist_partition WHERE logicalrelid = 'test_2'::regclass;
logicalrelid | partmethod | partkey | colocationid | repmodel
logicalrelid | partmethod | partkey | colocationid | repmodel | autoconverted
---------------------------------------------------------------------
(0 rows)

View File

@ -245,34 +245,6 @@ BEGIN;
INSERT INTO local_table_5 VALUES (300);
ROLLBACK;
BEGIN;
CREATE SCHEMA another_schema_fkeys_between_local_ref;
CREATE TABLE another_schema_fkeys_between_local_ref.local_table_6 (col_1 INT PRIMARY KEY);
-- first convert local tables to citus local tables in graph
ALTER TABLE local_table_2 ADD CONSTRAINT fkey_11 FOREIGN KEY (col_1) REFERENCES reference_table_1(col_1) ON DELETE CASCADE;
CREATE TABLE local_table_5 (
col_1 INT UNIQUE REFERENCES another_schema_fkeys_between_local_ref.local_table_6(col_1) CHECK (col_1 > 0),
col_2 INT REFERENCES local_table_3(col_1),
FOREIGN KEY (col_1) REFERENCES local_table_5(col_1));
-- Now show that we converted local_table_5 & 6 to citus local tables
-- as local_table_5 has foreign key to a citus local table too
SELECT logicalrelid::text AS tablename, partmethod, repmodel FROM pg_dist_partition
WHERE logicalrelid::text IN (SELECT tablename FROM pg_tables WHERE schemaname='fkeys_between_local_ref' UNION
SELECT 'another_schema_fkeys_between_local_ref.local_table_6')
ORDER BY tablename;
DROP TABLE local_table_3 CASCADE;
DROP SCHEMA another_schema_fkeys_between_local_ref CASCADE;
-- now we shouldn't see local_table_5 since now it is not connected to any reference tables
SELECT logicalrelid::text AS tablename, partmethod, repmodel FROM pg_dist_partition
WHERE logicalrelid::text IN (SELECT tablename FROM pg_tables WHERE schemaname='fkeys_between_local_ref')
ORDER BY tablename;
ROLLBACK;
BEGIN;
CREATE TABLE local_table_6 (col_1 INT PRIMARY KEY);
-- first convert local tables to citus local tables in graph