Replace access types "TRUNCATE_VIEW" and "TRUNCATE_TABLE" with "TRUNCATE".

This commit is contained in:
Vitaly Baranov 2020-04-02 21:56:56 +03:00
parent e5d8f05251
commit f53b4ad3a8
3 changed files with 4 additions and 10 deletions

View File

@ -49,8 +49,7 @@ namespace
const AccessFlags create_temporary_table_flag = AccessType::CREATE_TEMPORARY_TABLE; const AccessFlags create_temporary_table_flag = AccessType::CREATE_TEMPORARY_TABLE;
const AccessFlags alter_table_flag = AccessType::ALTER_TABLE; const AccessFlags alter_table_flag = AccessType::ALTER_TABLE;
const AccessFlags alter_view_flag = AccessType::ALTER_VIEW; const AccessFlags alter_view_flag = AccessType::ALTER_VIEW;
const AccessFlags truncate_table_flag = AccessType::TRUNCATE_TABLE; const AccessFlags truncate_flag = AccessType::TRUNCATE;
const AccessFlags truncate_view_flag = AccessType::TRUNCATE_VIEW;
const AccessFlags drop_table_flag = AccessType::DROP_TABLE; const AccessFlags drop_table_flag = AccessType::DROP_TABLE;
const AccessFlags drop_view_flag = AccessType::DROP_VIEW; const AccessFlags drop_view_flag = AccessType::DROP_VIEW;
}; };
@ -426,9 +425,6 @@ private:
if (access & helper.alter_table_flag) if (access & helper.alter_table_flag)
implicit_access |= helper.alter_view_flag; implicit_access |= helper.alter_view_flag;
if (access & helper.truncate_table_flag)
implicit_access |= helper.truncate_view_flag;
} }
final_access = access | implicit_access; final_access = access | implicit_access;

View File

@ -76,9 +76,7 @@ enum class AccessType
M(DROP_DICTIONARY, "", DICTIONARY, DROP) /* allows to execute {DROP|DETACH} DICTIONARY */\ M(DROP_DICTIONARY, "", DICTIONARY, DROP) /* allows to execute {DROP|DETACH} DICTIONARY */\
M(DROP, "", GROUP, ALL) /* allows to execute {DROP|DETACH} */\ M(DROP, "", GROUP, ALL) /* allows to execute {DROP|DETACH} */\
\ \
M(TRUNCATE_VIEW, "", VIEW, TRUNCATE) \ M(TRUNCATE, "TRUNCATE TABLE", TABLE, ALL) \
M(TRUNCATE_TABLE, "", TABLE, TRUNCATE) \
M(TRUNCATE, "", GROUP, ALL) \
M(OPTIMIZE, "OPTIMIZE TABLE", TABLE, ALL) \ M(OPTIMIZE, "OPTIMIZE TABLE", TABLE, ALL) \
\ \
M(KILL_QUERY, "", GLOBAL, ALL) /* allows to kill a query started by another user (anyone can kill his own queries) */\ M(KILL_QUERY, "", GLOBAL, ALL) /* allows to kill a query started by another user (anyone can kill his own queries) */\

View File

@ -99,7 +99,7 @@ BlockIO InterpreterDropQuery::executeToTable(
} }
else if (kind == ASTDropQuery::Kind::Truncate) else if (kind == ASTDropQuery::Kind::Truncate)
{ {
context.checkAccess(table->isView() ? AccessType::TRUNCATE_VIEW : AccessType::TRUNCATE_TABLE, table_id); context.checkAccess(AccessType::TRUNCATE, table_id);
table->checkTableCanBeDropped(); table->checkTableCanBeDropped();
/// If table was already dropped by anyone, an exception will be thrown /// If table was already dropped by anyone, an exception will be thrown
@ -316,7 +316,7 @@ AccessRightsElements InterpreterDropQuery::getRequiredAccessForDDLOnCluster() co
if (drop.kind == ASTDropQuery::Kind::Drop) if (drop.kind == ASTDropQuery::Kind::Drop)
required_access.emplace_back(AccessType::DROP_TABLE | AccessType::DROP_VIEW, drop.database, drop.table); required_access.emplace_back(AccessType::DROP_TABLE | AccessType::DROP_VIEW, drop.database, drop.table);
else if (drop.kind == ASTDropQuery::Kind::Truncate) else if (drop.kind == ASTDropQuery::Kind::Truncate)
required_access.emplace_back(AccessType::TRUNCATE_TABLE | AccessType::TRUNCATE_VIEW, drop.database, drop.table); required_access.emplace_back(AccessType::TRUNCATE, drop.database, drop.table);
else if (drop.kind == ASTDropQuery::Kind::Detach) else if (drop.kind == ASTDropQuery::Kind::Detach)
required_access.emplace_back(AccessType::DROP_TABLE | AccessType::DROP_VIEW, drop.database, drop.table); required_access.emplace_back(AccessType::DROP_TABLE | AccessType::DROP_VIEW, drop.database, drop.table);
} }