Simpler fix

This commit is contained in:
joelynch 2023-12-04 20:13:53 +01:00
parent b312a9f4ee
commit f346667956
No known key found for this signature in database
2 changed files with 18 additions and 28 deletions

View File

@ -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;

View File

@ -11,9 +11,9 @@ class ServerType
public:
enum Type
{
TCP,
TCP_WITH_PROXY,
TCP_SECURE,
TCP,
HTTP,
HTTPS,
MYSQL,