From ac426c3da641644144e76f730fdbb5d044d01e04 Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Thu, 14 Jan 2021 15:32:20 +0300 Subject: [PATCH] restrict MODIFY TTL for tables created in old syntax --- src/Storages/MergeTree/MergeTreeData.cpp | 6 ++++++ tests/queries/0_stateless/01652_ttl_old_syntax.reference | 0 tests/queries/0_stateless/01652_ttl_old_syntax.sql | 6 ++++++ 3 files changed, 12 insertions(+) create mode 100644 tests/queries/0_stateless/01652_ttl_old_syntax.reference create mode 100644 tests/queries/0_stateless/01652_ttl_old_syntax.sql diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index 897aea4363a..f84de847acd 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -1506,6 +1506,12 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, const S "ALTER MODIFY ORDER BY is not supported for default-partitioned tables created with the old syntax", ErrorCodes::BAD_ARGUMENTS); } + if (command.type == AlterCommand::MODIFY_TTL && !is_custom_partitioned) + { + throw Exception( + "ALTER MODIFY TTL is not supported for default-partitioned tables created with the old syntax", + ErrorCodes::BAD_ARGUMENTS); + } if (command.type == AlterCommand::MODIFY_SAMPLE_BY) { if (!is_custom_partitioned) diff --git a/tests/queries/0_stateless/01652_ttl_old_syntax.reference b/tests/queries/0_stateless/01652_ttl_old_syntax.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01652_ttl_old_syntax.sql b/tests/queries/0_stateless/01652_ttl_old_syntax.sql new file mode 100644 index 00000000000..05c391b85e5 --- /dev/null +++ b/tests/queries/0_stateless/01652_ttl_old_syntax.sql @@ -0,0 +1,6 @@ +DROP TABLE IF EXISTS ttl_old_syntax; + +CREATE TABLE ttl_old_syntax (d Date, i Int) ENGINE = MergeTree(d, i, 8291); +ALTER TABLE ttl_old_syntax MODIFY TTL toDate('2020-01-01'); -- { serverError 36 } + +DROP TABLE ttl_old_syntax;