Commit 0230d51b authored by unknown's avatar unknown

Fix a buildbot memory leak due to JOIN::destroy() not being called for EXPLAIN

query:
- When subquery is located in ORDER BY, EXPLAIN will run as follows:
  select_describe() will run JOIN::prepare()/optimize() for the subquery;
  then at some point subselect_single_select_engine::prepare() will be called,
  which will create another join and run join->prepare().

  In mainline mysql this is not a problem because subquery's join will be 
  destroyed after the first call. 
  In MariaDB, it won't (table elimination needs to keep JOIN objects around
  for longer in order to know which tables were eliminated when constructing
  EXPLAIN EXTENDED warning).

  Fix the problem of memory leak by calling select_lex->cleanup() in 
  subselect_single_select_engine::prepare().
parent 214edde8
...@@ -1776,6 +1776,10 @@ int subselect_single_select_engine::prepare() ...@@ -1776,6 +1776,10 @@ int subselect_single_select_engine::prepare()
{ {
if (prepared) if (prepared)
return 0; return 0;
if (select_lex->join)
{
select_lex->cleanup();
}
join= new JOIN(thd, select_lex->item_list, join= new JOIN(thd, select_lex->item_list,
select_lex->options | SELECT_NO_UNLOCK, result); select_lex->options | SELECT_NO_UNLOCK, result);
if (!join || !result) if (!join || !result)
......
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