← Back to team overview

maria-developers team mailing list archive

bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2826)

 

#At lp:maria

 2826 knielsen@xxxxxxxxxxxxxxx	2010-03-09
      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().
      modified:
        sql/item_subselect.cc

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2010-03-09 15:03:54 +0000
+++ b/sql/item_subselect.cc	2010-03-09 19:29:05 +0000
@@ -1776,6 +1776,10 @@ int subselect_single_select_engine::prep
 {
   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)