ClickHouse/src/Parsers/ParserKillQueryQuery.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.9 KiB
C++
Raw Normal View History

#include <Parsers/ParserKillQueryQuery.h>
#include <Parsers/ASTKillQueryQuery.h>
#include <Parsers/CommonParsers.h>
#include <Parsers/ExpressionListParsers.h>
2016-11-30 17:31:05 +00:00
namespace DB
{
bool ParserKillQueryQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
2016-11-30 17:31:05 +00:00
{
String cluster_str;
2017-01-24 13:39:39 +00:00
auto query = std::make_shared<ASTKillQueryQuery>();
2016-11-30 17:31:05 +00:00
ParserKeyword p_kill{Keyword::KILL};
ParserKeyword p_query{Keyword::QUERY};
ParserKeyword p_mutation{Keyword::MUTATION};
ParserKeyword p_part_move_to_shard{Keyword::PART_MOVE_TO_SHARD};
ParserKeyword p_transaction{Keyword::TRANSACTION};
ParserKeyword p_on{Keyword::ON};
ParserKeyword p_test{Keyword::TEST};
ParserKeyword p_sync{Keyword::SYNC};
ParserKeyword p_async{Keyword::ASYNC};
ParserKeyword p_where{Keyword::WHERE};
ParserExpression p_where_expression;
2016-11-30 17:31:05 +00:00
if (!p_kill.ignore(pos, expected))
return false;
if (p_query.ignore(pos, expected))
query->type = ASTKillQueryQuery::Type::Query;
else if (p_mutation.ignore(pos, expected))
query->type = ASTKillQueryQuery::Type::Mutation;
else if (p_part_move_to_shard.ignore(pos, expected))
query->type = ASTKillQueryQuery::Type::PartMoveToShard;
2022-03-10 21:29:58 +00:00
else if (p_transaction.ignore(pos, expected))
query->type = ASTKillQueryQuery::Type::Transaction;
else
2016-11-30 17:31:05 +00:00
return false;
if (p_on.ignore(pos, expected) && !ASTQueryWithOnCluster::parse(pos, cluster_str, expected))
2016-11-30 17:31:05 +00:00
return false;
if (!p_where.ignore(pos, expected) || !p_where_expression.parse(pos, query->where_expression, expected))
return false;
if (p_sync.ignore(pos, expected))
2016-11-30 17:31:05 +00:00
query->sync = true;
else if (p_async.ignore(pos, expected))
2016-11-30 17:31:05 +00:00
query->sync = false;
else if (p_test.ignore(pos, expected))
query->test = true;
2016-11-30 17:31:05 +00:00
query->cluster = cluster_str;
query->children.emplace_back(query->where_expression);
2016-11-30 17:31:05 +00:00
node = std::move(query);
return true;
}
}