mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
use enum for KILL query type [#CLICKHOUSE-3912]
This commit is contained in:
parent
d482f3e5d0
commit
4b4539139b
@ -182,7 +182,9 @@ BlockIO InterpreterKillQueryQuery::execute()
|
||||
return executeDDLQueryOnCluster(query_ptr, context, {"system"});
|
||||
|
||||
BlockIO res_io;
|
||||
if (!query.is_kill_mutation)
|
||||
switch (query.type)
|
||||
{
|
||||
case ASTKillQueryQuery::Type::Query:
|
||||
{
|
||||
Block processes_block = getSelectResult("query_id, user, query", "system.processes");
|
||||
if (!processes_block)
|
||||
@ -217,8 +219,10 @@ BlockIO InterpreterKillQueryQuery::execute()
|
||||
res_io.in = std::make_shared<SyncKillQueryInputStream>(
|
||||
process_list, std::move(queries_to_stop), std::move(processes_block), header);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
case ASTKillQueryQuery::Type::Mutation:
|
||||
{
|
||||
/// TODO: check permissions
|
||||
|
||||
@ -255,6 +259,9 @@ BlockIO InterpreterKillQueryQuery::execute()
|
||||
}
|
||||
|
||||
res_io.in = std::make_shared<OneBlockInputStream>(header.cloneWithColumns(std::move(res_columns)));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res_io;
|
||||
|
@ -11,7 +11,7 @@ String ASTKillQueryQuery::getID(char delim) const
|
||||
void ASTKillQueryQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
||||
{
|
||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << "KILL "
|
||||
<< (is_kill_mutation ? "MUTATION" : "QUERY");
|
||||
<< (type == Type::Query ? "QUERY" : "MUTATION");
|
||||
|
||||
formatOnCluster(settings);
|
||||
|
||||
|
@ -8,7 +8,13 @@ namespace DB
|
||||
class ASTKillQueryQuery : public ASTQueryWithOutput, public ASTQueryWithOnCluster
|
||||
{
|
||||
public:
|
||||
bool is_kill_mutation = false; // if the query is KILL MUTATION.
|
||||
enum class Type
|
||||
{
|
||||
Query, /// KILL QUERY
|
||||
Mutation, /// KILL MUTATION
|
||||
};
|
||||
|
||||
Type type = Type::Query;
|
||||
ASTPtr where_expression; // expression to filter processes from system.processes table
|
||||
bool sync = false; // SYNC or ASYNC mode
|
||||
bool test = false; // does it TEST mode? (doesn't cancel queries just checks and shows them)
|
||||
|
@ -28,9 +28,9 @@ bool ParserKillQueryQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expect
|
||||
return false;
|
||||
|
||||
if (p_query.ignore(pos, expected))
|
||||
query->is_kill_mutation = false;
|
||||
query->type = ASTKillQueryQuery::Type::Query;
|
||||
else if (p_mutation.ignore(pos, expected))
|
||||
query->is_kill_mutation = true;
|
||||
query->type = ASTKillQueryQuery::Type::Mutation;
|
||||
else
|
||||
return false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user