mirror of https://github.com/citusdata/citus.git
Add test for sequence dependency creation
parent
534ee5b6ca
commit
748abd02cf
|
@ -637,3 +637,23 @@ CREATE TABLE referenced_table(i int UNIQUE);
|
|||
SELECT create_distributed_table('referenced_table', 'i');
|
||||
ALTER TABLE test_table_1 ADD COLUMN test_col int REFERENCES referenced_table(i);
|
||||
DROP TABLE referenced_table, test_table_1;
|
||||
|
||||
-- Check sequence propagate its own dependencies while adding a column
|
||||
CREATE TABLE table_without_sequence(a int);
|
||||
SELECT create_distributed_table('table_without_sequence', 'a');
|
||||
|
||||
CREATE SCHEMA test_schema_for_sequence_propagation;
|
||||
CREATE SEQUENCE test_schema_for_sequence_propagation.seq_10;
|
||||
|
||||
-- Both should have zero rows
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_propagation.seq_10'::regclass);
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_propagation'::regnamespace);
|
||||
|
||||
ALTER TABLE table_without_sequence ADD COLUMN x BIGINT DEFAULT nextval('test_schema_for_sequence_propagation.seq_10');
|
||||
|
||||
-- Should be distributed along with the sequence
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_propagation.seq_10'::regclass);
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_propagation'::regnamespace);
|
||||
|
||||
DROP SCHEMA test_schema_for_sequence_propagation CASCADE;
|
||||
DROP TABLE table_without_sequence;
|
||||
|
|
|
@ -437,7 +437,26 @@ SELECT nextval('seq_14');
|
|||
|
||||
\c - - - :master_port
|
||||
|
||||
-- Show that sequence and its dependency schema will be propagated if a distributed
|
||||
-- table with default column is added
|
||||
CREATE SCHEMA test_schema_for_sequence_default_propagation;
|
||||
CREATE SEQUENCE test_schema_for_sequence_default_propagation.seq_10;
|
||||
|
||||
-- Both should return 0 rows
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_default_propagation.seq_10'::regclass);
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_default_propagation'::regnamespace);
|
||||
|
||||
-- Create distributed table with default column to propagate dependencies
|
||||
CREATE TABLE test_seq_dist(a int, x BIGINT DEFAULT nextval('test_schema_for_sequence_default_propagation.seq_10'));
|
||||
SELECT create_distributed_table('test_seq_dist', 'a');
|
||||
|
||||
-- Both sequence and dependency schema should be distributed
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_default_propagation.seq_10'::regclass);
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from citus.pg_dist_object WHERE objid IN ('test_schema_for_sequence_default_propagation'::regnamespace);
|
||||
|
||||
-- clean up
|
||||
DROP SCHEMA test_schema_for_sequence_default_propagation CASCADE;
|
||||
DROP TABLE test_seq_dist;
|
||||
DROP TABLE sequence_default.seq_test_7_par;
|
||||
SET client_min_messages TO error; -- suppress cascading objects dropping
|
||||
DROP SCHEMA sequence_default CASCADE;
|
||||
|
|
Loading…
Reference in New Issue