From 9707796869a9d994a6401bab3f2838d45a09bb08 Mon Sep 17 00:00:00 2001 From: Antonio Andelic Date: Mon, 27 Nov 2023 12:25:41 +0000 Subject: [PATCH] Ignore comments when comparing column descriptions --- src/Storages/ColumnsDescription.cpp | 2 - .../test_replicated_database/test.py | 45 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/Storages/ColumnsDescription.cpp b/src/Storages/ColumnsDescription.cpp index 5b21b8f120b..2ae5d177de0 100644 --- a/src/Storages/ColumnsDescription.cpp +++ b/src/Storages/ColumnsDescription.cpp @@ -60,7 +60,6 @@ bool ColumnDescription::identical(const ColumnDescription & other) const return name == other.name && type->identical(*other.type) && default_desc == other.default_desc - && comment == other.comment && ast_to_str(codec) == ast_to_str(other.codec) && ast_to_str(ttl) == ast_to_str(other.ttl); } @@ -72,7 +71,6 @@ bool ColumnDescription::operator==(const ColumnDescription & other) const return name == other.name && type->equals(*other.type) && default_desc == other.default_desc - && comment == other.comment && ast_to_str(codec) == ast_to_str(other.codec) && ast_to_str(ttl) == ast_to_str(other.ttl); } diff --git a/tests/integration/test_replicated_database/test.py b/tests/integration/test_replicated_database/test.py index f45841124d9..a591c93d264 100644 --- a/tests/integration/test_replicated_database/test.py +++ b/tests/integration/test_replicated_database/test.py @@ -1351,3 +1351,48 @@ def test_replicated_table_structure_alter(started_cluster): assert "1\t2\t3\t0\n1\t2\t3\t4\n" == dummy_node.query( "SELECT * FROM table_structure.rmt ORDER BY k" ) + + +def test_modify_comment(started_cluster): + main_node.query( + "CREATE DATABASE modify_comment_db ENGINE = Replicated('/test/modify_comment', 'shard1', 'replica' || '1');" + ) + + dummy_node.query( + "CREATE DATABASE modify_comment_db ENGINE = Replicated('/test/modify_comment', 'shard1', 'replica' || '2');" + ) + + main_node.query( + "CREATE TABLE modify_comment_db.modify_comment_table (d Date, k UInt64, i32 Int32) ENGINE=ReplicatedMergeTree ORDER BY k PARTITION BY toYYYYMM(d);" + ) + + def restart_verify_not_readonly(): + main_node.restart_clickhouse() + assert ( + main_node.query( + "SELECT is_readonly FROM system.replicas WHERE table = 'modify_comment_table'" + ) + == "0\n" + ) + dummy_node.restart_clickhouse() + assert ( + dummy_node.query( + "SELECT is_readonly FROM system.replicas WHERE table = 'modify_comment_table'" + ) + == "0\n" + ) + + main_node.query( + "ALTER TABLE modify_comment_db.modify_comment_table COMMENT COLUMN d 'Some comment'" + ) + + restart_verify_not_readonly() + + main_node.query( + "ALTER TABLE modify_comment_db.modify_comment_table MODIFY COMMENT 'Some error comment'" + ) + + restart_verify_not_readonly() + + main_node.query("DROP DATABASE modify_comment_db SYNC") + dummy_node.query("DROP DATABASE modify_comment_db SYNC")