[Commits] Rev 4132: MDEV-5991: crash in Item_field::used_tables in file:///home/bell/maria/bzr/work-maria-5.5-MDEV-5991/

sanja at askmonty.org sanja at askmonty.org
Sat Apr 12 18:40:07 EEST 2014


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

------------------------------------------------------------
revno: 4132
revision-id: sanja at askmonty.org-20140412153945-f9rdwkscai9l2yd5
parent: elenst at wheezy-64.home-20140403175856-51s8w5ihls5vkwta
committer: sanja at askmonty.org
branch nick: work-maria-5.5-MDEV-5991
timestamp: Sat 2014-04-12 18:39:45 +0300
message:
  MDEV-5991: crash in Item_field::used_tables
  
  Units of subqueroes from excluded expressions should be excluded from select_lex/select_unit tree.
-------------- next part --------------
=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2014-02-22 21:51:20 +0000
+++ b/mysql-test/r/subselect.result	2014-04-12 15:39:45 +0000
@@ -7007,3 +7007,11 @@ id	select_type	table	type	possible_keys
 2	SUBQUERY	t1	index	a	a	5	NULL	2	Using where; Using index
 2	SUBQUERY	t2	ref	b	b	5	test.t1.a	2	Using index
 DROP TABLE t1,t2;
+#
+# MDEV-5991: crash in Item_field::used_tables
+#
+create table t1 (c int);
+select exists(select 1 from t1 group by `c` in (select `c` from t1));
+exists(select 1 from t1 group by `c` in (select `c` from t1))
+0
+drop table t1;

=== modified file 'mysql-test/r/subselect_no_mat.result'
--- a/mysql-test/r/subselect_no_mat.result	2014-02-22 21:51:20 +0000
+++ b/mysql-test/r/subselect_no_mat.result	2014-04-12 15:39:45 +0000
@@ -7004,6 +7004,14 @@ id	select_type	table	type	possible_keys
 2	SUBQUERY	t1	index	a	a	5	NULL	2	Using where; Using index
 2	SUBQUERY	t2	ref	b	b	5	test.t1.a	2	Using index
 DROP TABLE t1,t2;
+#
+# MDEV-5991: crash in Item_field::used_tables
+#
+create table t1 (c int);
+select exists(select 1 from t1 group by `c` in (select `c` from t1));
+exists(select 1 from t1 group by `c` in (select `c` from t1))
+0
+drop table t1;
 set optimizer_switch=default;
 select @@optimizer_switch like '%materialization=on%';
 @@optimizer_switch like '%materialization=on%'

=== modified file 'mysql-test/r/subselect_no_opts.result'
--- a/mysql-test/r/subselect_no_opts.result	2014-02-22 21:51:20 +0000
+++ b/mysql-test/r/subselect_no_opts.result	2014-04-12 15:39:45 +0000
@@ -7002,4 +7002,12 @@ id	select_type	table	type	possible_keys
 2	SUBQUERY	t1	index	a	a	5	NULL	2	Using where; Using index
 2	SUBQUERY	t2	ref	b	b	5	test.t1.a	2	Using index
 DROP TABLE t1,t2;
+#
+# MDEV-5991: crash in Item_field::used_tables
+#
+create table t1 (c int);
+select exists(select 1 from t1 group by `c` in (select `c` from t1));
+exists(select 1 from t1 group by `c` in (select `c` from t1))
+0
+drop table t1;
 set @optimizer_switch_for_subselect_test=null;

=== modified file 'mysql-test/r/subselect_no_scache.result'
--- a/mysql-test/r/subselect_no_scache.result	2014-02-22 21:51:20 +0000
+++ b/mysql-test/r/subselect_no_scache.result	2014-04-12 15:39:45 +0000
@@ -7013,6 +7013,14 @@ id	select_type	table	type	possible_keys
 2	SUBQUERY	t1	index	a	a	5	NULL	2	Using where; Using index
 2	SUBQUERY	t2	ref	b	b	5	test.t1.a	2	Using index
 DROP TABLE t1,t2;
+#
+# MDEV-5991: crash in Item_field::used_tables
+#
+create table t1 (c int);
+select exists(select 1 from t1 group by `c` in (select `c` from t1));
+exists(select 1 from t1 group by `c` in (select `c` from t1))
+0
+drop table t1;
 set optimizer_switch=default;
 select @@optimizer_switch like '%subquery_cache=on%';
 @@optimizer_switch like '%subquery_cache=on%'

=== modified file 'mysql-test/r/subselect_no_semijoin.result'
--- a/mysql-test/r/subselect_no_semijoin.result	2014-02-22 21:51:20 +0000
+++ b/mysql-test/r/subselect_no_semijoin.result	2014-04-12 15:39:45 +0000
@@ -7002,5 +7002,13 @@ id	select_type	table	type	possible_keys
 2	SUBQUERY	t1	index	a	a	5	NULL	2	Using where; Using index
 2	SUBQUERY	t2	ref	b	b	5	test.t1.a	2	Using index
 DROP TABLE t1,t2;
+#
+# MDEV-5991: crash in Item_field::used_tables
+#
+create table t1 (c int);
+select exists(select 1 from t1 group by `c` in (select `c` from t1));
+exists(select 1 from t1 group by `c` in (select `c` from t1))
+0
+drop table t1;
 set @optimizer_switch_for_subselect_test=null;
 set @join_cache_level_for_subselect_test=NULL;

=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test	2012-11-22 09:19:31 +0000
+++ b/mysql-test/t/subselect.test	2014-04-12 15:39:45 +0000
@@ -5884,3 +5884,9 @@ EXPLAIN SELECT * FROM t1 WHERE EXISTS (
 
 DROP TABLE t1,t2;
 
+--echo #
+--echo # MDEV-5991: crash in Item_field::used_tables
+--echo #
+create table t1 (c int);
+select exists(select 1 from t1 group by `c` in (select `c` from t1));
+drop table t1;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2014-03-25 10:09:12 +0000
+++ b/sql/sql_select.cc	2014-04-12 15:39:45 +0000
@@ -496,6 +496,7 @@ fix_inner_refs(THD *thd, List<Item> &all
 static
 void remove_redundant_subquery_clauses(st_select_lex *subq_select_lex)
 {
+  DBUG_ENTER("remove_redundant_subquery_clauses");
   Item_subselect *subq_predicate= subq_select_lex->master_unit()->item;
   /*
     The removal should happen for IN, ALL, ANY and EXISTS subqueries,
@@ -505,7 +506,7 @@ void remove_redundant_subquery_clauses(s
        b) SELECT a, (<single row subquery) FROM t1
    */
   if (subq_predicate->substype() == Item_subselect::SINGLEROW_SUBS)
-    return;
+    DBUG_VOID_RETURN;
 
   /* A subquery that is not single row should be one of IN/ALL/ANY/EXISTS. */
   DBUG_ASSERT (subq_predicate->substype() == Item_subselect::EXISTS_SUBS ||
@@ -515,6 +516,7 @@ void remove_redundant_subquery_clauses(s
   {
     subq_select_lex->join->select_distinct= false;
     subq_select_lex->options&= ~SELECT_DISTINCT;
+    DBUG_PRINT("info", ("DISTINCT removed"));
   }
 
   /*
@@ -524,8 +526,13 @@ void remove_redundant_subquery_clauses(s
   if (subq_select_lex->group_list.elements &&
       !subq_select_lex->with_sum_func && !subq_select_lex->join->having)
   {
+    for (ORDER *ord= subq_select_lex->group_list.first; ord; ord= ord->next)
+    {
+      (*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL);
+    }
     subq_select_lex->join->group_list= NULL;
     subq_select_lex->group_list.empty();
+    DBUG_PRINT("info", ("GROUP BY removed"));
   }
 
   /*
@@ -540,6 +547,7 @@ void remove_redundant_subquery_clauses(s
     subq_select_lex->group_list.empty();
   }
   */
+  DBUG_VOID_RETURN;
 }
 
 



More information about the commits mailing list