← Back to team overview

maria-developers team mailing list archive

Rev 2798: Fix a buildbot memory leak due to JOIN::destroy() not being called for EXPLAIN in file:///home/psergey/dev/mariadb-5.1-knielsen/

 

At file:///home/psergey/dev/mariadb-5.1-knielsen/

------------------------------------------------------------
revno: 2798
revision-id: psergey@xxxxxxxxxxxx-20100309185356-ns7o30p75xjjby35
parent: knielsen@xxxxxxxxxxxxxxx-20100309150559-07zcnnz8dh54m2ug
committer: Sergey Petrunya <psergey@xxxxxxxxxxxx>
branch nick: mariadb-5.1-knielsen
timestamp: Tue 2010-03-09 21:53:56 +0300
message:
  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 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 18:53:56 +0000
@@ -1776,6 +1776,10 @@
 {
   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)