2021-10-31 08:51:20 +00:00
|
|
|
#include <Parsers/Access/parseUserName.h>
|
2021-11-26 16:19:47 +00:00
|
|
|
|
2021-10-31 08:51:20 +00:00
|
|
|
#include <Parsers/Access/ASTUserNameWithHost.h>
|
|
|
|
#include <Parsers/Access/ParserUserNameWithHost.h>
|
2020-02-04 22:37:04 +00:00
|
|
|
#include <Parsers/CommonParsers.h>
|
|
|
|
|
2020-04-05 19:18:30 +00:00
|
|
|
|
2020-02-04 22:37:04 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2020-05-30 14:18:08 +00:00
|
|
|
|
|
|
|
bool parseUserName(IParser::Pos & pos, Expected & expected, String & user_name)
|
2020-02-04 22:37:04 +00:00
|
|
|
{
|
2020-05-30 14:18:08 +00:00
|
|
|
ASTPtr ast;
|
|
|
|
if (!ParserUserNameWithHost{}.parse(pos, ast, expected))
|
2020-04-05 19:18:30 +00:00
|
|
|
return false;
|
2020-05-30 14:18:08 +00:00
|
|
|
user_name = ast->as<const ASTUserNameWithHost &>().toString();
|
2020-04-05 19:18:30 +00:00
|
|
|
return true;
|
2020-02-04 22:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-30 14:18:08 +00:00
|
|
|
bool parseUserNames(IParser::Pos & pos, Expected & expected, Strings & user_names)
|
2020-02-04 22:37:04 +00:00
|
|
|
{
|
2020-05-30 14:18:08 +00:00
|
|
|
ASTPtr ast;
|
|
|
|
if (!ParserUserNamesWithHost{}.parse(pos, ast, expected))
|
|
|
|
return false;
|
|
|
|
user_names = ast->as<const ASTUserNamesWithHost &>().toStrings();
|
|
|
|
return true;
|
2020-02-04 22:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-30 14:18:08 +00:00
|
|
|
bool parseCurrentUserTag(IParser::Pos & pos, Expected & expected)
|
2020-02-04 22:37:04 +00:00
|
|
|
{
|
2020-05-30 14:18:08 +00:00
|
|
|
return IParserBase::wrapParseImpl(pos, [&]
|
2020-02-04 22:37:04 +00:00
|
|
|
{
|
2020-05-30 14:18:08 +00:00
|
|
|
if (!ParserKeyword{"CURRENT_USER"}.ignore(pos, expected) && !ParserKeyword{"currentUser"}.ignore(pos, expected))
|
|
|
|
return false;
|
|
|
|
|
2020-02-04 22:37:04 +00:00
|
|
|
if (ParserToken{TokenType::OpeningRoundBracket}.ignore(pos, expected))
|
|
|
|
{
|
|
|
|
if (!ParserToken{TokenType::ClosingRoundBracket}.ignore(pos, expected))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2020-05-30 14:18:08 +00:00
|
|
|
});
|
2020-02-04 22:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|