1#include <Parsers/IAST.h>
2#include <Parsers/ASTQueryWithOutput.h>
3#include <Parsers/ASTQueryWithOnCluster.h>
4
5namespace DB
6{
7
8class ASTKillQueryQuery : public ASTQueryWithOutput, public ASTQueryWithOnCluster
9{
10public:
11 enum class Type
12 {
13 Query, /// KILL QUERY
14 Mutation, /// KILL MUTATION
15 };
16
17 Type type = Type::Query;
18 ASTPtr where_expression; // expression to filter processes from system.processes table
19 bool sync = false; // SYNC or ASYNC mode
20 bool test = false; // does it TEST mode? (doesn't cancel queries just checks and shows them)
21
22 ASTPtr clone() const override
23 {
24 auto clone = std::make_shared<ASTKillQueryQuery>(*this);
25 if (where_expression)
26 {
27 clone->where_expression = where_expression->clone();
28 clone->children = {clone->where_expression};
29 }
30
31 return clone;
32 }
33
34 String getID(char) const override;
35
36 void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
37
38 ASTPtr getRewrittenASTWithoutOnCluster(const std::string &) const override
39 {
40 return removeOnCluster<ASTKillQueryQuery>(clone());
41 }
42};
43
44}
45