MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Petrunia Date:April 23 2008 10:01pm
Subject:bk commit into 6.0 tree (sergefp:1.2625) BUG#36128
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of sergefp.  When sergefp does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-04-24 02:01:12+04:00, sergefp@stripped +3 -0
  BUG#36128: not in subquery causes crash in cleanup..
  - Handle temporary tables created by NL-semijoin runtime in the same way
    as grouping/sorting temporary tables are handled:
    = delete temptable contents in JOIN::reinit()
    = delete the temptables in JOIN::destroy() 
  (the bug was that we would destroy the temptable after the first join 
   execution and then crash on the next join execution)

  mysql-test/r/subselect_sj2.result@stripped, 2008-04-24 02:01:04+04:00, sergefp@stripped +10 -0
    BUG#36128: not in subquery causes crash in cleanup..
    - Testcase

  mysql-test/t/subselect_sj2.test@stripped, 2008-04-24 02:01:04+04:00, sergefp@stripped +11 -0
    BUG#36128: not in subquery causes crash in cleanup..
    - Testcase

  sql/sql_select.cc@stripped, 2008-04-24 02:01:05+04:00, sergefp@stripped +29 -4
    BUG#36128: not in subquery causes crash in cleanup..
    - Handle temporary tables created by NL-semijoin runtime in the same way
      as grouping/sorting temporary tables are handled:
      = delete temptable contents in JOIN::reinit()
      = delete the temptables in JOIN::destroy() 

diff -Nrup a/mysql-test/r/subselect_sj2.result b/mysql-test/r/subselect_sj2.result
--- a/mysql-test/r/subselect_sj2.result	2008-04-23 09:26:25 +04:00
+++ b/mysql-test/r/subselect_sj2.result	2008-04-24 02:01:04 +04:00
@@ -445,3 +445,13 @@ where 
 t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by  t1.a);
 a
 drop table t1;
+create table t1(a int,b int,key(a),key(b));
+insert into t1 values (1,1),(2,2),(3,3);
+select 1 from t1 
+where t1.a not in (select 1 from t1 
+where t1.a in (select 1 from t1) 
+group by  t1.b);
+1
+1
+1
+drop table t1;
diff -Nrup a/mysql-test/t/subselect_sj2.test b/mysql-test/t/subselect_sj2.test
--- a/mysql-test/t/subselect_sj2.test	2008-04-23 09:26:25 +04:00
+++ b/mysql-test/t/subselect_sj2.test	2008-04-24 02:01:04 +04:00
@@ -601,3 +601,14 @@ where 
   t1.a in (select 1 from t1 where t1.a in (select 1 from t1) group by  t1.a);
 drop table t1;
 
+#
+# BUG#36128: not in subquery causes crash in cleanup..
+#
+create table t1(a int,b int,key(a),key(b)); 
+insert into t1 values (1,1),(2,2),(3,3);
+select 1 from t1 
+where t1.a not in (select 1 from t1 
+                  where t1.a in (select 1 from t1) 
+                  group by  t1.b);
+drop table t1;
+
diff -Nrup a/sql/sql_select.cc b/sql/sql_select.cc
--- a/sql/sql_select.cc	2008-04-23 17:13:09 +04:00
+++ b/sql/sql_select.cc	2008-04-24 02:01:05 +04:00
@@ -1278,19 +1278,42 @@ int setup_semijoin_dups_elimination(JOIN
 }
 
 
-static void cleanup_sj_tmp_tables(JOIN *join)
+/*
+  Destroy all temporary tables created by NL-semijoin runtime.
+*/
+
+static void destroy_sj_tmp_tables(JOIN *join)
 {
   for (SJ_TMP_TABLE *sj_tbl= join->sj_tmp_tables; sj_tbl; 
        sj_tbl= sj_tbl->next)
   {
     if (sj_tbl->tmp_table)
-    {
       free_tmp_table(join->thd, sj_tbl->tmp_table);
-    }
   }
   join->sj_tmp_tables= NULL;
 }
 
+
+/*
+  Remove all records from all temp tables used by NL-semijoin runtime
+*/
+
+static int clear_sj_tmp_tables(JOIN *join)
+{
+  int res;
+  for (SJ_TMP_TABLE *sj_tbl= join->sj_tmp_tables; sj_tbl; 
+       sj_tbl= sj_tbl->next)
+  {
+    if (sj_tbl->tmp_table)
+    {
+      if ((res= sj_tbl->tmp_table->file->ha_delete_all_rows()))
+        return res;
+    }
+  }
+  return 0;
+}
+
+
 uint make_join_orderinfo(JOIN *join);
 
 /**
@@ -2128,6 +2151,7 @@ JOIN::reinit()
     free_io_cache(exec_tmp_table2);
     filesort_free_buffers(exec_tmp_table2,0);
   }
+  clear_sj_tmp_tables(this);
   if (items0)
     set_items_ref_array(items0);
 
@@ -2799,6 +2823,7 @@ JOIN::destroy()
     free_tmp_table(thd, exec_tmp_table1);
   if (exec_tmp_table2)
     free_tmp_table(thd, exec_tmp_table2);
+  destroy_sj_tmp_tables(this);
   delete select;
   delete_dynamic(&keyuse);
   delete procedure;
@@ -8585,7 +8610,7 @@ void JOIN::cleanup(bool full)
           tab->table->file->ha_index_or_rnd_end();
       }
     }
-    cleanup_sj_tmp_tables(this);//
+    //was: cleanup_sj_tmp_tables(this);//
   }
   /*
     We are not using tables anymore
Thread
bk commit into 6.0 tree (sergefp:1.2625) BUG#36128Sergey Petrunia24 Apr