mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 04:22:03 +00:00
9fe47df2e8
Support syntax "SHOW CREATE USER ALL" and "SHOW GRANTS FOR ALL".
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#include <Parsers/ParserShowGrantsQuery.h>
|
|
#include <Parsers/ParserRolesOrUsersSet.h>
|
|
#include <Parsers/ASTRolesOrUsersSet.h>
|
|
#include <Parsers/ASTShowGrantsQuery.h>
|
|
#include <Parsers/CommonParsers.h>
|
|
#include <Parsers/parseUserName.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
bool ParserShowGrantsQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
|
{
|
|
if (!ParserKeyword{"SHOW GRANTS"}.ignore(pos, expected))
|
|
return false;
|
|
|
|
std::shared_ptr<ASTRolesOrUsersSet> for_roles;
|
|
|
|
if (ParserKeyword{"FOR"}.ignore(pos, expected))
|
|
{
|
|
ASTPtr for_roles_ast;
|
|
ParserRolesOrUsersSet for_roles_p;
|
|
for_roles_p.allowUserNames().allowRoleNames().allowAll().allowCurrentUser();
|
|
if (!for_roles_p.parse(pos, for_roles_ast, expected))
|
|
return false;
|
|
|
|
for_roles = typeid_cast<std::shared_ptr<ASTRolesOrUsersSet>>(for_roles_ast);
|
|
}
|
|
else
|
|
{
|
|
for_roles = std::make_shared<ASTRolesOrUsersSet>();
|
|
for_roles->current_user = true;
|
|
}
|
|
|
|
auto query = std::make_shared<ASTShowGrantsQuery>();
|
|
query->for_roles = std::move(for_roles);
|
|
node = query;
|
|
|
|
return true;
|
|
}
|
|
}
|