List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:November 10 2011 7:43am
Subject:bzr push into mysql-trunk branch (sergey.glukhov:3482 to 3483) Bug#13358379
View as plain text  
 3483 Sergey Glukhov	2011-11-10
      Bug#13358379 EXPLAIN SELECT ... PROCEDURE ANALYZE CRASHES THE SERVER
      Problem: code which is realted to PROCEDURE resultpreparation
               is missing in JOIN::explain().
      Fix:     code which is related to PROCEDURE result preparation
               is moved into JOIN::prepare_result.
     @ mysql-test/r/func_analyse.result
        test case
     @ mysql-test/t/func_analyse.test
        test case
     @ sql/sql_select.cc
        Problem: code which is realted to PROCEDURE result preparation
                 is missing in JOIN::explain().
        Fix:     code which is related to PROCEDURE result preparation
                 is moved into JOIN::prepare_result().

    modified:
      mysql-test/r/func_analyse.result
      mysql-test/t/func_analyse.test
      sql/sql_select.cc
      sql/sql_select.h
 3482 Roy Lyseng	2011-11-09
      Bug#13334882: assertion table->sort.record_pointers == __null
      
      When assigning ref access methods for a join operation, references
      to expressions in an outer query context are also considered.
      However, such expressions are not available when materializing a
      semi-join nest, so they have to be masked away. This happened only
      half-way: OUTER_REF_TABLE_BIT was masked away in
      JOIN::set_access_methods() when calling create_ref_for_key(), but it was
      not masked away when analyzing ref expressions in best_access_path().
      The results was that the ref access object was incomplete when
      accessing the storage layer, and an assert was raised.
      
      mysql-test/include/subquery_sj.inc
        Added test case for bug#13334882
      
      mysql-test/r/subquery_sj_all.result
      mysql-test/r/subquery_sj_all_bka.result
      mysql-test/r/subquery_sj_all_bka_nixbnl.result
      mysql-test/r/subquery_sj_all_bkaunique.result
      mysql-test/r/subquery_sj_dupsweed.result
      mysql-test/r/subquery_sj_dupsweed_bka.result
      mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result
      mysql-test/r/subquery_sj_dupsweed_bkaunique.result
      mysql-test/r/subquery_sj_firstmatch.result
      mysql-test/r/subquery_sj_firstmatch_bka.result
      mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result
      mysql-test/r/subquery_sj_firstmatch_bkaunique.result
      mysql-test/r/subquery_sj_loosescan.result
      mysql-test/r/subquery_sj_loosescan_bka.result
      mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result
      mysql-test/r/subquery_sj_loosescan_bkaunique.result
      mysql-test/r/subquery_sj_mat.result
      mysql-test/r/subquery_sj_mat_bka.result
      mysql-test/r/subquery_sj_mat_bka_nixbnl.result
      mysql-test/r/subquery_sj_mat_bkaunique.result
      mysql-test/r/subquery_sj_mat_nosj.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/subquery_sj_none_bka.result
      mysql-test/r/subquery_sj_none_bka_nixbnl.result
      mysql-test/r/subquery_sj_none_bkaunique.result
        Added test case results for bug#13334882
      
      sql/sql_select.cc
        When initializing excluded_tables in Optimize_table_order, add
        OUTER_REF_TABLE_BIT as an excluded table.
        Also in make_join_select(): make sure that outer tables are not
        available when pushing condition parts into a materialized semi-join
        nests.

    modified:
      mysql-test/include/subquery_sj.inc
      mysql-test/r/subquery_sj_all.result
      mysql-test/r/subquery_sj_all_bka.result
      mysql-test/r/subquery_sj_all_bka_nixbnl.result
      mysql-test/r/subquery_sj_all_bkaunique.result
      mysql-test/r/subquery_sj_dupsweed.result
      mysql-test/r/subquery_sj_dupsweed_bka.result
      mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result
      mysql-test/r/subquery_sj_dupsweed_bkaunique.result
      mysql-test/r/subquery_sj_firstmatch.result
      mysql-test/r/subquery_sj_firstmatch_bka.result
      mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result
      mysql-test/r/subquery_sj_firstmatch_bkaunique.result
      mysql-test/r/subquery_sj_loosescan.result
      mysql-test/r/subquery_sj_loosescan_bka.result
      mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result
      mysql-test/r/subquery_sj_loosescan_bkaunique.result
      mysql-test/r/subquery_sj_mat.result
      mysql-test/r/subquery_sj_mat_bka.result
      mysql-test/r/subquery_sj_mat_bka_nixbnl.result
      mysql-test/r/subquery_sj_mat_bkaunique.result
      mysql-test/r/subquery_sj_mat_nosj.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/subquery_sj_none_bka.result
      mysql-test/r/subquery_sj_none_bka_nixbnl.result
      mysql-test/r/subquery_sj_none_bkaunique.result
      sql/sql_select.cc
=== modified file 'mysql-test/r/func_analyse.result'
--- a/mysql-test/r/func_analyse.result	2011-04-14 09:32:17 +0000
+++ b/mysql-test/r/func_analyse.result	2011-11-10 07:42:43 +0000
@@ -163,3 +163,11 @@ test.t1	analyze	status	OK
 SELECT f1,f2 FROM t1 A WHERE f1 BETWEEN 0 AND 1;
 f1	f2
 drop table t1;
+#
+# Bug #13358379   EXPLAIN SELECT ... PROCEDURE ANALYZE CRASHES THE SERVER
+#
+CREATE TABLE t1 (i INT);
+EXPLAIN SELECT * FROM t1 PROCEDURE ANALYSE();
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	1	
+DROP TABLE t1;

=== modified file 'mysql-test/t/func_analyse.test'
--- a/mysql-test/t/func_analyse.test	2011-04-14 09:32:17 +0000
+++ b/mysql-test/t/func_analyse.test	2011-11-10 07:42:43 +0000
@@ -180,3 +180,11 @@ ANALYZE TABLE t1;
 SELECT f1,f2 FROM t1 A WHERE f1 BETWEEN 0 AND 1; 
 
 drop table t1;
+
+--echo #
+--echo # Bug #13358379   EXPLAIN SELECT ... PROCEDURE ANALYZE CRASHES THE SERVER
+--echo #
+
+CREATE TABLE t1 (i INT);
+EXPLAIN SELECT * FROM t1 PROCEDURE ANALYSE();
+DROP TABLE t1;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-11-09 09:04:15 +0000
+++ b/sql/sql_select.cc	2011-11-10 07:42:43 +0000
@@ -2921,7 +2921,7 @@ disable_sorted_access(JOIN_TAB* join_tab
     FALSE Ok
 */
 
-bool JOIN::prepare_result()
+bool JOIN::prepare_result(List<Item> **columns_list)
 {
   DBUG_ENTER("JOIN::prepare_result");
 
@@ -2936,6 +2936,19 @@ bool JOIN::prepare_result()
       get_schema_tables_result(this, PROCESSED_BY_JOIN_EXEC))
     goto err;
 
+  if (procedure)
+  {
+    procedure_fields_list= fields_list;
+    if (procedure->change_columns(procedure_fields_list) ||
+	result->prepare(procedure_fields_list, unit))
+    {
+      thd->set_examined_row_count(0);
+      thd->limit_found_rows= 0;
+      goto err;
+    }
+    *columns_list= &procedure_fields_list;
+  }
+
   DBUG_RETURN(FALSE);
 
 err:
@@ -2956,12 +2969,12 @@ JOIN::explain()
   Opt_trace_object trace_exec(trace, "join_explain");
   trace_exec.add_select_number(select_lex->select_number);
   Opt_trace_array trace_steps(trace, "steps");
-
+  List<Item> *columns_list= &fields_list;
   DBUG_ENTER("JOIN::explain");
 
   THD_STAGE_INFO(thd, stage_explaining);
 
-  if (prepare_result())
+  if (prepare_result(&columns_list))
     DBUG_VOID_RETURN;
 
   if (!tables_list && (tables || !select_lex->with_sum_func))
@@ -3048,22 +3061,9 @@ JOIN::exec()
 
   THD_STAGE_INFO(thd, stage_executing);
 
-  if (prepare_result())
+  if (prepare_result(&columns_list))
     DBUG_VOID_RETURN;
 
-  if (procedure)
-  {
-    procedure_fields_list= fields_list;
-    if (procedure->change_columns(procedure_fields_list) ||
-	result->prepare(procedure_fields_list, unit))
-    {
-      thd->set_examined_row_count(0);
-      thd->limit_found_rows= 0;
-      DBUG_VOID_RETURN;
-    }
-    columns_list= &procedure_fields_list;
-  }
-
   if (!tables_list && (tables || !select_lex->with_sum_func))
   {                                           // Only test of functions
     if (result->send_result_set_metadata(*columns_list,

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2011-11-08 11:37:54 +0000
+++ b/sql/sql_select.h	2011-11-10 07:42:43 +0000
@@ -2066,7 +2066,7 @@ public:
   int optimize();
   void reset();
   void exec();
-  bool prepare_result();
+  bool prepare_result(List<Item> **columns_list);
   void explain();
   bool destroy();
   void restore_tmp();

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (sergey.glukhov:3482 to 3483) Bug#13358379Sergey Glukhov11 Nov