1 | #include <Parsers/ParserKillQueryQuery.h> |
2 | #include <Parsers/ASTKillQueryQuery.h> |
3 | |
4 | #include <Parsers/CommonParsers.h> |
5 | #include <Parsers/ExpressionListParsers.h> |
6 | |
7 | |
8 | namespace DB |
9 | { |
10 | |
11 | |
12 | bool ParserKillQueryQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) |
13 | { |
14 | String cluster_str; |
15 | auto query = std::make_shared<ASTKillQueryQuery>(); |
16 | |
17 | ParserKeyword p_kill{"KILL" }; |
18 | ParserKeyword p_query{"QUERY" }; |
19 | ParserKeyword p_mutation{"MUTATION" }; |
20 | ParserKeyword p_on{"ON" }; |
21 | ParserKeyword p_test{"TEST" }; |
22 | ParserKeyword p_sync{"SYNC" }; |
23 | ParserKeyword p_async{"ASYNC" }; |
24 | ParserKeyword p_where{"WHERE" }; |
25 | ParserExpression p_where_expression; |
26 | |
27 | if (!p_kill.ignore(pos, expected)) |
28 | return false; |
29 | |
30 | if (p_query.ignore(pos, expected)) |
31 | query->type = ASTKillQueryQuery::Type::Query; |
32 | else if (p_mutation.ignore(pos, expected)) |
33 | query->type = ASTKillQueryQuery::Type::Mutation; |
34 | else |
35 | return false; |
36 | |
37 | if (p_on.ignore(pos, expected) && !ASTQueryWithOnCluster::parse(pos, cluster_str, expected)) |
38 | return false; |
39 | |
40 | if (!p_where.ignore(pos, expected) || !p_where_expression.parse(pos, query->where_expression, expected)) |
41 | return false; |
42 | |
43 | if (p_sync.ignore(pos, expected)) |
44 | query->sync = true; |
45 | else if (p_async.ignore(pos, expected)) |
46 | query->sync = false; |
47 | else if (p_test.ignore(pos, expected)) |
48 | query->test = true; |
49 | |
50 | query->cluster = cluster_str; |
51 | query->children.emplace_back(query->where_expression); |
52 | node = std::move(query); |
53 | return true; |
54 | } |
55 | |
56 | } |
57 | |