From fc18f8218906738a9ee5133bc55931da24646d90 Mon Sep 17 00:00:00 2001 From: alesapin Date: Fri, 28 Feb 2020 15:44:50 +0300 Subject: [PATCH] Fix stupid bug with settings alter --- dbms/src/Storages/AlterCommands.cpp | 5 +++++ .../0_stateless/00980_merge_alter_settings.sql | 2 +- .../01089_alter_settings_old_format.reference | 1 + .../01089_alter_settings_old_format.sql | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/01089_alter_settings_old_format.reference create mode 100644 dbms/tests/queries/0_stateless/01089_alter_settings_old_format.sql diff --git a/dbms/src/Storages/AlterCommands.cpp b/dbms/src/Storages/AlterCommands.cpp index 4948d884647..cebc4a4b2ba 100644 --- a/dbms/src/Storages/AlterCommands.cpp +++ b/dbms/src/Storages/AlterCommands.cpp @@ -628,6 +628,11 @@ void AlterCommands::validate(const StorageInMemoryMetadata & metadata, const Con ErrorCodes::NOT_FOUND_COLUMN_IN_BLOCK}; } } + else if (command.type == AlterCommand::MODIFY_SETTING) + { + if (metadata.settings_ast == nullptr) + throw Exception{"Cannot alter settings, because table engine doesn't support settings changes", ErrorCodes::BAD_ARGUMENTS}; + } } } diff --git a/dbms/tests/queries/0_stateless/00980_merge_alter_settings.sql b/dbms/tests/queries/0_stateless/00980_merge_alter_settings.sql index d650218e99a..6bf043fe4c8 100644 --- a/dbms/tests/queries/0_stateless/00980_merge_alter_settings.sql +++ b/dbms/tests/queries/0_stateless/00980_merge_alter_settings.sql @@ -5,7 +5,7 @@ CREATE TABLE log_for_alter ( Data String ) ENGINE = Log(); -ALTER TABLE log_for_alter MODIFY SETTING aaa=123; -- { serverError 48 } +ALTER TABLE log_for_alter MODIFY SETTING aaa=123; -- { serverError 36 } DROP TABLE IF EXISTS log_for_alter; diff --git a/dbms/tests/queries/0_stateless/01089_alter_settings_old_format.reference b/dbms/tests/queries/0_stateless/01089_alter_settings_old_format.reference new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01089_alter_settings_old_format.reference @@ -0,0 +1 @@ +1 diff --git a/dbms/tests/queries/0_stateless/01089_alter_settings_old_format.sql b/dbms/tests/queries/0_stateless/01089_alter_settings_old_format.sql new file mode 100644 index 00000000000..15d3ac508cb --- /dev/null +++ b/dbms/tests/queries/0_stateless/01089_alter_settings_old_format.sql @@ -0,0 +1,15 @@ +DROP TABLE IF EXISTS old_format_mt; + +CREATE TABLE old_format_mt ( + event_date Date, + key UInt64, + value1 UInt64, + value2 String +) +ENGINE = MergeTree(event_date, (key, value1), 8192); + +ALTER TABLE old_format_mt MODIFY SETTING enable_mixed_granularity_parts = 1; --{serverError 36} + +SELECT 1; + +DROP TABLE IF EXISTS old_format_mt;