[Commits] Rev 3583: Fix of MDEV-3874: Server crashes in Item_field::print on a SELECT from a MERGE view with materialization+semijoin, subquery, ORDER BY. in file:///home/bell/maria/bzr/work-maria-5.5-MDEV-3874/

sanja at montyprogram.com sanja at montyprogram.com
Mon Nov 26 20:39:25 EET 2012


At file:///home/bell/maria/bzr/work-maria-5.5-MDEV-3874/

------------------------------------------------------------
revno: 3583
revision-id: sanja at montyprogram.com-20121126183922-idbih8qudwkdyt2h
parent: sergii at pisem.net-20121122104355-tivqceyimgljbdxc
committer: sanja at montyprogram.com
branch nick: work-maria-5.5-MDEV-3874
timestamp: Mon 2012-11-26 20:39:22 +0200
message:
  Fix of MDEV-3874: Server crashes in Item_field::print on a SELECT from a MERGE view with materialization+semijoin, subquery, ORDER BY.
  
  The problem was that in debugging binaries it try to print item to assign human readable name to the item.
  But subquery item was already freed (join_free/cleanup with full cleanup) so Item_field refers to temporary
  table which memory had been already freed.
-------------- next part --------------
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2012-11-22 09:19:31 +0000
+++ b/sql/sql_select.cc	2012-11-26 18:39:22 +0000
@@ -2074,6 +2074,7 @@ JOIN::reinit()
                                     ULL(0));
 
   first_record= 0;
+  cleaned= false;
 
   if (exec_tmp_table1)
   {
@@ -10623,6 +10624,7 @@ void JOIN::cleanup(bool full)
       {
 	tab->cleanup();
       }
+      cleaned= true;
     }
     else
     {
@@ -22409,6 +22411,17 @@ void st_select_lex::print(THD *thd, Stri
 
   str->append(STRING_WITH_LEN("select "));
 
+  if (join && join->cleaned)
+  {
+    /*
+      JOIN already cleaned up so it is dangerous to print items
+      because temporary tables they pointed on could be freed.
+    */
+    str->append('#');
+    str->append(select_number);
+    return;
+  }
+
   /* First add options */
   if (options & SELECT_STRAIGHT_JOIN)
     str->append(STRING_WITH_LEN("straight_join "));

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2012-11-04 15:09:46 +0000
+++ b/sql/sql_select.h	2012-11-26 18:39:22 +0000
@@ -1141,6 +1141,8 @@ public:
   bool          skip_sort_order;
 
   bool need_tmp, hidden_group_fields;
+  /* TRUE if there was full cleunap of the JOIN */
+  bool cleaned;
   DYNAMIC_ARRAY keyuse;
   Item::cond_result cond_value, having_value;
   List<Item> all_fields; ///< to store all fields that used in query
@@ -1268,6 +1270,7 @@ public:
     zero_result_cause= 0;
     optimized= 0;
     initialized= 0;
+    cleaned= 0;
     cond_equal= 0;
     having_equal= 0;
     exec_const_cond= 0;



More information about the commits mailing list