Skip to content

Commit

Permalink
Merge pull request #3916 from fancyqlx/kill-query-fix
Browse files Browse the repository at this point in the history
Fixed Segment Fault Caused by 'KILL QUERY SYNC'
  • Loading branch information
alexey-milovidov authored Dec 24, 2018
2 parents 082e6e0 + 416d6aa commit e0eb527
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions dbms/src/Interpreters/InterpreterKillQueryQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,11 @@ BlockIO InterpreterKillQueryQuery::execute()

Block InterpreterKillQueryQuery::getSelectFromSystemProcessesResult()
{
String system_processes_query = "SELECT query_id, user, query FROM system.processes WHERE "
+ queryToString(static_cast<ASTKillQueryQuery &>(*query_ptr).where_expression);
String system_processes_query = "SELECT query_id, user, query FROM system.processes";
auto & where_expression = static_cast<ASTKillQueryQuery &>(*query_ptr).where_expression;
if (where_expression)
system_processes_query += " WHERE " + queryToString(where_expression);


BlockIO system_processes_io = executeQuery(system_processes_query, context, true);
Block res = system_processes_io.in->read();
Expand Down
8 changes: 6 additions & 2 deletions dbms/src/Parsers/ASTKillQueryQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ class ASTKillQueryQuery : public ASTQueryWithOutput, public ASTQueryWithOnCluste
ASTPtr clone() const override
{
auto clone = std::make_shared<ASTKillQueryQuery>(*this);
clone->where_expression = where_expression->clone();
clone->children = {clone->where_expression};
if (where_expression)
{
clone->where_expression = where_expression->clone();
clone->children = {clone->where_expression};
}

return clone;
}

Expand Down
3 changes: 2 additions & 1 deletion dbms/src/Parsers/ParserKillQueryQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ bool ParserKillQueryQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expect
query->test = true;

query->cluster = cluster_str;
query->children.emplace_back(query->where_expression);
if (query->where_expression)
query->children.emplace_back(query->where_expression);
node = std::move(query);
return true;
}
Expand Down

0 comments on commit e0eb527

Please sign in to comment.