Check ALTERs; update test

This commit is contained in:
Alexey Milovidov 2020-07-31 00:42:55 +03:00
parent b9f49d31df
commit 2c40539df6
3 changed files with 22 additions and 2 deletions

View File

@ -1471,7 +1471,6 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, const S
if (old_metadata.hasSettingsChanges()) if (old_metadata.hasSettingsChanges())
{ {
const auto current_changes = old_metadata.getSettingsChanges()->as<const ASTSetQuery &>().changes; const auto current_changes = old_metadata.getSettingsChanges()->as<const ASTSetQuery &>().changes;
const auto & new_changes = new_metadata.settings_changes->as<const ASTSetQuery &>().changes; const auto & new_changes = new_metadata.settings_changes->as<const ASTSetQuery &>().changes;
for (const auto & changed_setting : new_changes) for (const auto & changed_setting : new_changes)
@ -1619,6 +1618,7 @@ void MergeTreeData::changeSettings(
const auto & new_changes = new_settings->as<const ASTSetQuery &>().changes; const auto & new_changes = new_settings->as<const ASTSetQuery &>().changes;
for (const auto & change : new_changes) for (const auto & change : new_changes)
{
if (change.name == "storage_policy") if (change.name == "storage_policy")
{ {
StoragePolicyPtr new_storage_policy = global_context.getStoragePolicy(change.value.safeGet<String>()); StoragePolicyPtr new_storage_policy = global_context.getStoragePolicy(change.value.safeGet<String>());
@ -1653,9 +1653,13 @@ void MergeTreeData::changeSettings(
has_storage_policy_changed = true; has_storage_policy_changed = true;
} }
} }
}
MergeTreeSettings copy = *getSettings(); MergeTreeSettings copy = *getSettings();
copy.applyChanges(new_changes); copy.applyChanges(new_changes);
copy.sanityCheck(global_context.getSettingsRef());
storage_settings.set(std::make_unique<const MergeTreeSettings>(copy)); storage_settings.set(std::make_unique<const MergeTreeSettings>(copy));
StorageInMemoryMetadata new_metadata = getInMemoryMetadata(); StorageInMemoryMetadata new_metadata = getInMemoryMetadata();
new_metadata.setSettingsChanges(new_settings); new_metadata.setSettingsChanges(new_settings);

View File

@ -1,7 +1,7 @@
DROP TABLE IF EXISTS t; DROP TABLE IF EXISTS t;
SET mutations_sync = 1; 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'); INSERT INTO t VALUES (1, 'hello');
SELECT * FROM t; SELECT * FROM t;

View File

@ -1,3 +1,5 @@
DROP TABLE IF EXISTS mytable_local;
CREATE TABLE mytable_local CREATE TABLE mytable_local
( (
created DateTime, created DateTime,
@ -19,3 +21,17 @@ ENGINE = MergeTree()
PARTITION BY toYYYYMM(eventday) PARTITION BY toYYYYMM(eventday)
ORDER BY (eventday, user_id) ORDER BY (eventday, user_id)
SETTINGS number_of_free_entries_in_pool_to_lower_max_size_of_merge = 100; -- { serverError 36 } 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;