From cf86df99660fb8ad28f719d532a6578bb7eec9fe Mon Sep 17 00:00:00 2001 From: pufit Date: Fri, 8 Nov 2024 01:47:11 -0500 Subject: [PATCH] Make use of `ALTER_MOVE_PARTITION` privilege. --- src/Access/ContextAccess.cpp | 6 ++++++ src/Interpreters/InterpreterAlterQuery.cpp | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Access/ContextAccess.cpp b/src/Access/ContextAccess.cpp index 06e89d78339..0ed9186d918 100644 --- a/src/Access/ContextAccess.cpp +++ b/src/Access/ContextAccess.cpp @@ -168,6 +168,12 @@ AccessRights ContextAccess::addImplicitAccessRights(const AccessRights & access, res |= show_databases; } + static const AccessFlags alter_delete = AccessType::ALTER_DELETE; + static const AccessFlags select = AccessType::SELECT; + static const AccessFlags move_partition = AccessType::ALTER_MOVE_PARTITION; + if ((res & alter_delete) && (res & select) && level <= 2) + res |= move_partition; + max_flags |= res; return res; diff --git a/src/Interpreters/InterpreterAlterQuery.cpp b/src/Interpreters/InterpreterAlterQuery.cpp index 907026c73a3..1725f3aa065 100644 --- a/src/Interpreters/InterpreterAlterQuery.cpp +++ b/src/Interpreters/InterpreterAlterQuery.cpp @@ -467,11 +467,11 @@ AccessRightsElements InterpreterAlterQuery::getRequiredAccessForCommand(const AS required_access.emplace_back(AccessType::ALTER_MOVE_PARTITION, database, table); break; case DataDestinationType::TABLE: - required_access.emplace_back(AccessType::SELECT | AccessType::ALTER_DELETE, database, table); + required_access.emplace_back(AccessType::ALTER_MOVE_PARTITION, database, table); required_access.emplace_back(AccessType::INSERT, command.to_database, command.to_table); break; case DataDestinationType::SHARD: - required_access.emplace_back(AccessType::SELECT | AccessType::ALTER_DELETE, database, table); + required_access.emplace_back(AccessType::ALTER_MOVE_PARTITION, database, table); required_access.emplace_back(AccessType::MOVE_PARTITION_BETWEEN_SHARDS); break; case DataDestinationType::DELETE: