2017-08-04 15:54:00 +00:00
|
|
|
#include <Parsers/ParserSystemQuery.h>
|
|
|
|
#include <Parsers/ASTSystemQuery.h>
|
|
|
|
#include <Parsers/CommonParsers.h>
|
|
|
|
#include <Parsers/ASTLiteral.h>
|
|
|
|
#include <Interpreters/evaluateConstantExpression.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
bool ParserSystemQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
|
|
|
{
|
2017-08-24 18:19:06 +00:00
|
|
|
auto begin = pos;
|
|
|
|
|
2017-08-04 15:54:00 +00:00
|
|
|
if (!ParserKeyword{"SYSTEM"}.ignore(pos))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
using Type = ASTSystemQuery::Type;
|
|
|
|
|
|
|
|
auto res = std::make_shared<ASTSystemQuery>();
|
|
|
|
|
|
|
|
bool found = false;
|
2017-08-31 12:55:19 +00:00
|
|
|
for (int i = static_cast<int>(Type::UNKNOWN) + 1; i < static_cast<int>(Type::END); ++i)
|
2017-08-04 15:54:00 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-08-24 18:19:06 +00:00
|
|
|
res->range = {begin, pos};
|
2017-08-04 15:54:00 +00:00
|
|
|
node = std::move(res);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|