Merge pull request #12727 from ClickHouse/add-test-for-alter-after-freeze

Add a test for ALTER after FREEZE
This commit is contained in:
alexey-milovidov 2020-07-23 23:33:46 +03:00 committed by GitHub
commit e7ec08615e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,26 @@
1 hello
2 world
all_1_1_0 0
---
all_1_1_0 1
---
1 goodbye
2 world
all_1_1_0 1
all_1_1_0_2 0
---
1 goodbye
2 world
all_1_1_0 1
all_1_1_0_2 0
all_1_1_0_3 0
---
all_1_1_0 1
all_1_1_0_2 0
all_1_1_0_3 1
---
1 hello
2 world
all_1_1_0 1
all_1_1_0_2 0
all_1_1_0_3 1

View File

@ -0,0 +1,35 @@
-- In previous ClickHouse versions, parts were not 100% immutable and FREEZE may prevent subsequent ALTERs.
-- It's not longer the case. Let's prove it.
DROP TABLE IF EXISTS t;
CREATE TABLE t (k UInt64, s String) ENGINE = MergeTree ORDER BY k;
INSERT INTO t VALUES (1, 'hello'), (2, 'world');
SELECT * FROM t;
SELECT name, is_frozen FROM system.parts WHERE database = currentDatabase() AND table = 't';
SELECT '---';
ALTER TABLE t FREEZE;
SELECT name, is_frozen FROM system.parts WHERE database = currentDatabase() AND table = 't';
SELECT '---';
SET mutations_sync = 1;
ALTER TABLE t UPDATE s = 'goodbye' WHERE k = 1;
SELECT * FROM t;
SELECT name, is_frozen FROM system.parts WHERE database = currentDatabase() AND table = 't';
SELECT '---';
ALTER TABLE t MODIFY COLUMN s Enum('goodbye' = 1, 'world' = 2);
SELECT * FROM t;
SELECT name, is_frozen FROM system.parts WHERE database = currentDatabase() AND table = 't';
SELECT '---';
ALTER TABLE t FREEZE;
SELECT name, is_frozen FROM system.parts WHERE database = currentDatabase() AND table = 't';
SELECT '---';
ALTER TABLE t MODIFY COLUMN s Enum('hello' = 1, 'world' = 2);
SELECT * FROM t;
SELECT name, is_frozen FROM system.parts WHERE database = currentDatabase() AND table = 't';
DROP TABLE t;