Commit ed92f915 authored by Davi Arnaut's avatar Davi Arnaut

Bug#47761: crash when killing a query during subquery execution...

The problem was that killing a query during the optimization
phase of a subselect would lead to crashes. The root of the
problem is that the subselect execution engine ignores failures
(eg: killed) during the optimization phase (JOIN::optimize),
leading to a crash once the subquery is executed due to
partially initialized structures (in this case a join tab).

The optimal solution would be to cleanup certain optimizer
structures if the optimization phase fails, but currently
there is no infrastructure to properly to track and cleanup
the structures. To workaround the whole problem one somewhat
good solution is to avoid executing a subselect if the query
has been killed. Cutting short any problems caused by failures
during the optimization phase.

sql/item_subselect.cc:
  Do not execute a subselect if the session or query has been killed.
parent ae42e96d
......@@ -249,9 +249,13 @@ bool Item_subselect::exec()
{
int res;
if (thd->is_error())
/* Do not execute subselect in case of a fatal error */
/*
Do not execute subselect in case of a fatal error
or if the query has been killed.
*/
if (thd->is_error() || thd->killed)
return 1;
/*
Simulate a failure in sub-query execution. Used to test e.g.
out of memory or query being killed conditions.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment