From ef09ba0d060be0bee877834d6cd33d96ee014483 Mon Sep 17 00:00:00 2001 From: Halil Ozan Akgul Date: Fri, 3 Dec 2021 13:28:12 +0300 Subject: [PATCH] Fix metadata sync fails of multi_table_ddl --- src/test/regress/expected/multi_table_ddl.out | 13 ++++++++----- src/test/regress/multi_1_schedule | 2 +- src/test/regress/sql/multi_table_ddl.sql | 9 +++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/test/regress/expected/multi_table_ddl.out b/src/test/regress/expected/multi_table_ddl.out index 4c991dfcb..fb2fe49d8 100644 --- a/src/test/regress/expected/multi_table_ddl.out +++ b/src/test/regress/expected/multi_table_ddl.out @@ -100,8 +100,9 @@ SELECT create_distributed_table('testserialtable', 'group_id', 'hash'); (1 row) --- can add additional serial columns +-- cannot add additional serial columns when metadata is synced ALTER TABLE testserialtable ADD COLUMN other_id serial; +ERROR: cannot execute ADD COLUMN commands involving serial pseudotypes when metadata is synchronized to workers -- and we shouldn't be able to change a distributed sequence's owner ALTER SEQUENCE testserialtable_id_seq OWNED BY NONE; ERROR: cannot alter OWNED BY option of a sequence already owned by a distributed table @@ -115,8 +116,9 @@ HINT: Use a sequence in a distributed table by specifying a serial column type -- or even change a manual sequence to be owned by a distributed table CREATE SEQUENCE standalone_sequence; ALTER SEQUENCE standalone_sequence OWNED BY testserialtable.group_id; --- an edge case, but it's OK to change an owner to the same distributed table +-- cannot even change owner to the same distributed table if the sequence is distributed ALTER SEQUENCE testserialtable_id_seq OWNED BY testserialtable.id; +ERROR: Altering a distributed sequence is currently not supported. -- drop distributed table \c - - - :master_port DROP TABLE testserialtable; @@ -146,7 +148,6 @@ ERROR: cannot execute ALTER TABLE command involving partition column ALTER TABLE test_table ADD COLUMN id2 int DEFAULT nextval('test_sequence_1'); ALTER TABLE test_table ALTER COLUMN id2 DROP DEFAULT; ALTER TABLE test_table ALTER COLUMN id2 SET DEFAULT nextval('test_sequence_1'); -ALTER TABLE test_table ADD COLUMN id3 bigserial; -- shouldn't work since the above operations should be the only subcommands ALTER TABLE test_table ADD COLUMN id4 int DEFAULT nextval('test_sequence_1') CHECK (id4 > 0); ERROR: cannot execute ADD COLUMN .. DEFAULT nextval('..') command with other subcommands/constraints @@ -157,9 +158,11 @@ HINT: You can issue each subcommand separately ALTER TABLE test_table ALTER COLUMN id3 SET DEFAULT nextval('test_sequence_1'), ALTER COLUMN id2 DROP DEFAULT; ERROR: cannot execute ALTER COLUMN COLUMN .. SET DEFAULT nextval('..') command with other subcommands HINT: You can issue each subcommand separately +-- shouldn't work because of metadata syncing +ALTER TABLE test_table ADD COLUMN id3 bigserial; +ERROR: cannot execute ADD COLUMN commands involving serial pseudotypes when metadata is synchronized to workers ALTER TABLE test_table ADD COLUMN id4 bigserial CHECK (id4 > 0); -ERROR: cannot execute ADD COLUMN commands involving serial pseudotypes with other subcommands/constraints -HINT: You can issue each subcommand separately +ERROR: cannot execute ADD COLUMN commands involving serial pseudotypes when metadata is synchronized to workers DROP TABLE test_table CASCADE; DROP SEQUENCE test_sequence_0; DROP SEQUENCE test_sequence_1; diff --git a/src/test/regress/multi_1_schedule b/src/test/regress/multi_1_schedule index 841e4d57f..c69dc9447 100644 --- a/src/test/regress/multi_1_schedule +++ b/src/test/regress/multi_1_schedule @@ -32,9 +32,9 @@ test: ref_citus_local_fkeys test: alter_database_owner test: multi_test_catalog_views +test: multi_table_ddl test: check_mx test: turn_mx_off -test: multi_table_ddl test: multi_sequence_default test: multi_name_lengths test: turn_mx_on diff --git a/src/test/regress/sql/multi_table_ddl.sql b/src/test/regress/sql/multi_table_ddl.sql index 1b903217b..1fa5b3a61 100644 --- a/src/test/regress/sql/multi_table_ddl.sql +++ b/src/test/regress/sql/multi_table_ddl.sql @@ -68,7 +68,7 @@ SET citus.shard_count TO 2; SET citus.shard_replication_factor TO 1; SELECT create_distributed_table('testserialtable', 'group_id', 'hash'); --- can add additional serial columns +-- cannot add additional serial columns when metadata is synced ALTER TABLE testserialtable ADD COLUMN other_id serial; -- and we shouldn't be able to change a distributed sequence's owner @@ -85,7 +85,7 @@ CREATE SEQUENCE standalone_sequence OWNED BY testserialtable.group_id; CREATE SEQUENCE standalone_sequence; ALTER SEQUENCE standalone_sequence OWNED BY testserialtable.group_id; --- an edge case, but it's OK to change an owner to the same distributed table +-- cannot even change owner to the same distributed table if the sequence is distributed ALTER SEQUENCE testserialtable_id_seq OWNED BY testserialtable.id; -- drop distributed table @@ -113,12 +113,13 @@ ALTER TABLE test_table ADD COLUMN id2 int DEFAULT nextval('test_sequence_1'); ALTER TABLE test_table ALTER COLUMN id2 DROP DEFAULT; ALTER TABLE test_table ALTER COLUMN id2 SET DEFAULT nextval('test_sequence_1'); -ALTER TABLE test_table ADD COLUMN id3 bigserial; - -- shouldn't work since the above operations should be the only subcommands ALTER TABLE test_table ADD COLUMN id4 int DEFAULT nextval('test_sequence_1') CHECK (id4 > 0); ALTER TABLE test_table ADD COLUMN id4 int, ADD COLUMN id5 int DEFAULT nextval('test_sequence_1'); ALTER TABLE test_table ALTER COLUMN id3 SET DEFAULT nextval('test_sequence_1'), ALTER COLUMN id2 DROP DEFAULT; + +-- shouldn't work because of metadata syncing +ALTER TABLE test_table ADD COLUMN id3 bigserial; ALTER TABLE test_table ADD COLUMN id4 bigserial CHECK (id4 > 0); DROP TABLE test_table CASCADE;