mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Simpler fix
This commit is contained in:
parent
b312a9f4ee
commit
f346667956
@ -481,40 +481,30 @@ bool ParserSystemQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected &
|
||||
{
|
||||
type = ServerType::Type::END;
|
||||
custom_name = "";
|
||||
ParserKeyword except("EXCEPT");
|
||||
|
||||
for (const auto & cur_type : magic_enum::enum_values<ServerType::Type>())
|
||||
{
|
||||
// Backtracking is required here in the case of TCP, TCP SECURE and TCP WITH PROXY
|
||||
Pos pos_copy = pos;
|
||||
ParserKeyword keyword(ServerType::serverTypeToString(cur_type));
|
||||
if (keyword.ignore(pos_copy, expected))
|
||||
if (ParserKeyword{ServerType::serverTypeToString(cur_type)}.ignore(pos, expected))
|
||||
{
|
||||
if (cur_type == ServerType::CUSTOM)
|
||||
{
|
||||
ASTPtr ast;
|
||||
keyword.ignore(pos, expected);
|
||||
type = cur_type;
|
||||
if (!ParserStringLiteral{}.parse(pos, ast, expected))
|
||||
return false;
|
||||
|
||||
custom_name = ast->as<ASTLiteral &>().value.get<const String &>();
|
||||
break;
|
||||
}
|
||||
|
||||
if (pos_copy.get().type == TokenType::EndOfStream
|
||||
|| pos_copy.get().type == TokenType::Comma
|
||||
|| except.checkWithoutMoving(pos_copy, expected))
|
||||
{
|
||||
keyword.ignore(pos, expected);
|
||||
type = cur_type;
|
||||
break;
|
||||
}
|
||||
|
||||
type = cur_type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return type != ServerType::Type::END;
|
||||
if (type == ServerType::Type::END)
|
||||
return false;
|
||||
|
||||
if (type == ServerType::CUSTOM)
|
||||
{
|
||||
ASTPtr ast;
|
||||
|
||||
if (!ParserStringLiteral{}.parse(pos, ast, expected))
|
||||
return false;
|
||||
|
||||
custom_name = ast->as<ASTLiteral &>().value.get<const String &>();
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
ServerType::Type base_type;
|
||||
|
@ -11,9 +11,9 @@ class ServerType
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
TCP,
|
||||
TCP_WITH_PROXY,
|
||||
TCP_SECURE,
|
||||
TCP,
|
||||
HTTP,
|
||||
HTTPS,
|
||||
MYSQL,
|
||||
|
Loading…
Reference in New Issue
Block a user