ClickHouse/src/Parsers/ASTShowGrantsQuery.cpp
Vitaly Baranov 9fe47df2e8 Support multiple users/roles in SHOW CREATE USER(ROLE, etc.) and SHOW GRANTS FOR commands.
Support syntax "SHOW CREATE USER ALL" and "SHOW GRANTS FOR ALL".
2020-06-15 22:07:47 +03:00

37 lines
939 B
C++

#include <Parsers/ASTShowGrantsQuery.h>
#include <Parsers/ASTRolesOrUsersSet.h>
#include <Common/quoteString.h>
namespace DB
{
String ASTShowGrantsQuery::getID(char) const
{
return "ShowGrantsQuery";
}
ASTPtr ASTShowGrantsQuery::clone() const
{
return std::make_shared<ASTShowGrantsQuery>(*this);
}
void ASTShowGrantsQuery::formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << "SHOW GRANTS"
<< (settings.hilite ? hilite_none : "");
if (for_roles->current_user && !for_roles->all && for_roles->names.empty() && for_roles->except_names.empty()
&& !for_roles->except_current_user)
{
}
else
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << " FOR "
<< (settings.hilite ? hilite_none : "");
for_roles->format(settings);
}
}
}