diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index 7f5773024ca..d1d4dae59a7 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -1471,7 +1471,6 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, const S if (old_metadata.hasSettingsChanges()) { - const auto current_changes = old_metadata.getSettingsChanges()->as().changes; const auto & new_changes = new_metadata.settings_changes->as().changes; for (const auto & changed_setting : new_changes) @@ -1619,6 +1618,7 @@ void MergeTreeData::changeSettings( const auto & new_changes = new_settings->as().changes; for (const auto & change : new_changes) + { if (change.name == "storage_policy") { StoragePolicyPtr new_storage_policy = global_context.getStoragePolicy(change.value.safeGet()); @@ -1653,9 +1653,13 @@ void MergeTreeData::changeSettings( has_storage_policy_changed = true; } } + } MergeTreeSettings copy = *getSettings(); copy.applyChanges(new_changes); + + copy.sanityCheck(global_context.getSettingsRef()); + storage_settings.set(std::make_unique(copy)); StorageInMemoryMetadata new_metadata = getInMemoryMetadata(); new_metadata.setSettingsChanges(new_settings); diff --git a/tests/queries/0_stateless/01415_inconsistent_merge_tree_settings.sql b/tests/queries/0_stateless/01415_inconsistent_merge_tree_settings.sql index f3bf24193a8..2ce0575c4ad 100644 --- a/tests/queries/0_stateless/01415_inconsistent_merge_tree_settings.sql +++ b/tests/queries/0_stateless/01415_inconsistent_merge_tree_settings.sql @@ -1,7 +1,7 @@ DROP TABLE IF EXISTS t; SET mutations_sync = 1; -CREATE TABLE t (x UInt8, s String) ENGINE = MergeTree ORDER BY x SETTINGS number_of_free_entries_in_pool_to_execute_mutation = 1000; +CREATE TABLE t (x UInt8, s String) ENGINE = MergeTree ORDER BY x SETTINGS number_of_free_entries_in_pool_to_execute_mutation = 15; INSERT INTO t VALUES (1, 'hello'); SELECT * FROM t; diff --git a/tests/queries/0_stateless/01419_merge_tree_settings_sanity_check.sql b/tests/queries/0_stateless/01419_merge_tree_settings_sanity_check.sql index 525fff9b256..686594f435d 100644 --- a/tests/queries/0_stateless/01419_merge_tree_settings_sanity_check.sql +++ b/tests/queries/0_stateless/01419_merge_tree_settings_sanity_check.sql @@ -1,3 +1,5 @@ +DROP TABLE IF EXISTS mytable_local; + CREATE TABLE mytable_local ( created DateTime, @@ -19,3 +21,17 @@ ENGINE = MergeTree() PARTITION BY toYYYYMM(eventday) ORDER BY (eventday, user_id) SETTINGS number_of_free_entries_in_pool_to_lower_max_size_of_merge = 100; -- { serverError 36 } + +CREATE TABLE mytable_local +( + created DateTime, + eventday Date, + user_id UInt32 +) +ENGINE = MergeTree() +PARTITION BY toYYYYMM(eventday) +ORDER BY (eventday, user_id); + +ALTER TABLE mytable_local MODIFY SETTING number_of_free_entries_in_pool_to_execute_mutation = 100; -- { serverError 36 } + +DROP TABLE mytable_local;