2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: long, replica
|
|
|
|
|
2019-08-14 19:51:03 +00:00
|
|
|
DROP TABLE IF EXISTS replicated_constraints1;
|
|
|
|
DROP TABLE IF EXISTS replicated_constraints2;
|
|
|
|
|
|
|
|
CREATE TABLE replicated_constraints1
|
|
|
|
(
|
|
|
|
a UInt32,
|
|
|
|
b UInt32,
|
|
|
|
CONSTRAINT a_constraint CHECK a < 10
|
2021-08-05 06:55:07 +00:00
|
|
|
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test_00988/alter_constraints', 'r1') ORDER BY (a);
|
2019-08-14 19:51:03 +00:00
|
|
|
|
|
|
|
CREATE TABLE replicated_constraints2
|
|
|
|
(
|
|
|
|
a UInt32,
|
|
|
|
b UInt32,
|
|
|
|
CONSTRAINT a_constraint CHECK a < 10
|
2021-08-05 06:55:07 +00:00
|
|
|
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test_00988/alter_constraints', 'r2') ORDER BY (a);
|
2019-08-14 19:51:03 +00:00
|
|
|
|
|
|
|
INSERT INTO replicated_constraints1 VALUES (1, 2);
|
|
|
|
INSERT INTO replicated_constraints2 VALUES (3, 4);
|
|
|
|
|
|
|
|
SYSTEM SYNC REPLICA replicated_constraints1;
|
|
|
|
SYSTEM SYNC REPLICA replicated_constraints2;
|
|
|
|
|
|
|
|
INSERT INTO replicated_constraints1 VALUES (10, 10); -- { serverError 469 }
|
|
|
|
|
|
|
|
ALTER TABLE replicated_constraints1 DROP CONSTRAINT a_constraint;
|
|
|
|
|
|
|
|
SYSTEM SYNC REPLICA replicated_constraints2;
|
|
|
|
|
|
|
|
INSERT INTO replicated_constraints1 VALUES (10, 10);
|
|
|
|
INSERT INTO replicated_constraints2 VALUES (10, 10);
|
|
|
|
|
|
|
|
ALTER TABLE replicated_constraints1 ADD CONSTRAINT b_constraint CHECK b > 10;
|
2020-08-15 09:37:05 +00:00
|
|
|
|
|
|
|
-- Otherwise "Metadata on replica is not up to date with common metadata in Zookeeper. Cannot alter." is possible.
|
|
|
|
SYSTEM SYNC REPLICA replicated_constraints1;
|
|
|
|
SYSTEM SYNC REPLICA replicated_constraints2;
|
|
|
|
|
2019-08-14 19:51:03 +00:00
|
|
|
ALTER TABLE replicated_constraints2 ADD CONSTRAINT a_constraint CHECK a < 10;
|
|
|
|
|
|
|
|
SYSTEM SYNC REPLICA replicated_constraints1;
|
|
|
|
SYSTEM SYNC REPLICA replicated_constraints2;
|
|
|
|
|
|
|
|
INSERT INTO replicated_constraints1 VALUES (10, 11); -- { serverError 469 }
|
|
|
|
INSERT INTO replicated_constraints2 VALUES (9, 10); -- { serverError 469 }
|
|
|
|
|
|
|
|
DROP TABLE replicated_constraints1;
|
2020-08-15 09:37:05 +00:00
|
|
|
DROP TABLE replicated_constraints2;
|