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().
This commit is contained in:
unknown 2010-03-09 20:29:05 +01:00
parent 214edde888
commit 0230d51be8

View File

@ -1776,6 +1776,10 @@ int subselect_single_select_engine::prepare()
{
if (prepared)
return 0;
if (select_lex->join)
{
select_lex->cleanup();
}
join= new JOIN(thd, select_lex->item_list,
select_lex->options | SELECT_NO_UNLOCK, result);
if (!join || !result)