2017-04-01 09:19:00 +00:00
|
|
|
#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
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
bool ParserKillQueryQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
2016-11-30 17:31:05 +00:00
|
|
|
{
|
2018-07-20 05:46:48 +00:00
|
|
|
String cluster_str;
|
2017-04-01 07:20:54 +00:00
|
|
|
auto query = std::make_shared<ASTKillQueryQuery>();
|
2016-11-30 17:31:05 +00:00
|
|
|
|
2019-01-10 18:19:29 +00:00
|
|
|
ParserKeyword p_kill{"KILL"};
|
|
|
|
ParserKeyword p_query{"QUERY"};
|
|
|
|
ParserKeyword p_mutation{"MUTATION"};
|
2021-09-16 16:03:31 +00:00
|
|
|
ParserKeyword p_part_move_to_shard{"PART_MOVE_TO_SHARD"};
|
2022-03-10 21:29:58 +00:00
|
|
|
ParserKeyword p_transaction{"TRANSACTION"};
|
2018-07-20 05:46:48 +00:00
|
|
|
ParserKeyword p_on{"ON"};
|
|
|
|
ParserKeyword p_test{"TEST"};
|
|
|
|
ParserKeyword p_sync{"SYNC"};
|
|
|
|
ParserKeyword p_async{"ASYNC"};
|
|
|
|
ParserKeyword p_where{"WHERE"};
|
|
|
|
ParserExpression p_where_expression;
|
2016-11-30 17:31:05 +00:00
|
|
|
|
2019-01-10 18:19:29 +00:00
|
|
|
if (!p_kill.ignore(pos, expected))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (p_query.ignore(pos, expected))
|
2019-02-05 13:15:11 +00:00
|
|
|
query->type = ASTKillQueryQuery::Type::Query;
|
2019-01-10 18:19:29 +00:00
|
|
|
else if (p_mutation.ignore(pos, expected))
|
2019-02-05 13:15:11 +00:00
|
|
|
query->type = ASTKillQueryQuery::Type::Mutation;
|
2021-09-16 16:03:31 +00:00
|
|
|
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;
|
2019-01-10 18:19:29 +00:00
|
|
|
else
|
2017-04-01 07:20:54 +00:00
|
|
|
return false;
|
2016-11-30 17:31:05 +00:00
|
|
|
|
2018-07-20 05:46:48 +00:00
|
|
|
if (p_on.ignore(pos, expected) && !ASTQueryWithOnCluster::parse(pos, cluster_str, expected))
|
2017-04-01 07:20:54 +00:00
|
|
|
return false;
|
2016-11-30 17:31:05 +00:00
|
|
|
|
2018-12-24 11:08:09 +00:00
|
|
|
if (!p_where.ignore(pos, expected) || !p_where_expression.parse(pos, query->where_expression, expected))
|
2018-07-20 05:46:48 +00:00
|
|
|
return false;
|
2018-05-17 13:33:28 +00:00
|
|
|
|
2018-07-20 05:46:48 +00:00
|
|
|
if (p_sync.ignore(pos, expected))
|
2017-04-01 07:20:54 +00:00
|
|
|
query->sync = true;
|
2018-07-20 05:46:48 +00:00
|
|
|
else if (p_async.ignore(pos, expected))
|
2017-04-01 07:20:54 +00:00
|
|
|
query->sync = false;
|
2018-07-20 05:46:48 +00:00
|
|
|
else if (p_test.ignore(pos, expected))
|
2017-04-01 07:20:54 +00:00
|
|
|
query->test = true;
|
2016-11-30 17:31:05 +00:00
|
|
|
|
2018-07-20 05:46:48 +00:00
|
|
|
query->cluster = cluster_str;
|
2018-12-24 11:08:09 +00:00
|
|
|
query->children.emplace_back(query->where_expression);
|
2017-04-01 07:20:54 +00:00
|
|
|
node = std::move(query);
|
|
|
|
return true;
|
2016-11-30 17:31:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|