mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-09 10:00:54 +00:00
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
|
#include <Parsers/ParserSystemQuery.h>
|
||
|
#include <Parsers/ASTSystemQuery.h>
|
||
|
#include <Parsers/CommonParsers.h>
|
||
|
#include <Parsers/ASTIdentifier.h>
|
||
|
#include <Parsers/ASTLiteral.h>
|
||
|
#include <Interpreters/evaluateConstantExpression.h>
|
||
|
#include "ASTSystemQuery.h"
|
||
|
|
||
|
|
||
|
namespace ErrorCodes
|
||
|
{
|
||
|
extern const int NOT_IMPLEMENTED;
|
||
|
}
|
||
|
|
||
|
|
||
|
namespace DB
|
||
|
{
|
||
|
|
||
|
|
||
|
bool ParserSystemQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
||
|
{
|
||
|
if (!ParserKeyword{"SYSTEM"}.ignore(pos))
|
||
|
return false;
|
||
|
|
||
|
using Type = ASTSystemQuery::Type;
|
||
|
|
||
|
auto res = std::make_shared<ASTSystemQuery>();
|
||
|
|
||
|
bool found = false;
|
||
|
for (int i = static_cast<int>(Type::SHUTDOWN); i < static_cast<int>(Type::_END); ++i)
|
||
|
{
|
||
|
Type t = static_cast<Type>(i);
|
||
|
if (ParserKeyword{ASTSystemQuery::typeToString(t)}.ignore(pos))
|
||
|
{
|
||
|
res->type = t;
|
||
|
found = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!found)
|
||
|
return false;
|
||
|
|
||
|
if (res->type == Type::RELOAD_DICTIONARY)
|
||
|
{
|
||
|
if (!parseIdentifierOrStringLiteral(pos, expected, res->target_dictionary))
|
||
|
return false;
|
||
|
}
|
||
|
else if (res->type == Type::SYNC_REPLICA)
|
||
|
{
|
||
|
throw Exception("SYNC REPLICA is not supported yet", ErrorCodes::NOT_IMPLEMENTED);
|
||
|
}
|
||
|
|
||
|
node = std::move(res);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
}
|