[Commits] Rev 3681: MDEV-4908: Assertion `((Item_cond *) cond)->functype() == ((Item_cond *) new_item)->functype()' fails on a query with IN and equal conditions, AND/OR, materialization+semijoin in file:///home/bell/maria/bzr/work-maria-5.3-MDEV-4908/

sanja at montyprogram.com sanja at montyprogram.com
Wed Aug 21 17:42:57 EEST 2013


At file:///home/bell/maria/bzr/work-maria-5.3-MDEV-4908/

------------------------------------------------------------
revno: 3681
revision-id: sanja at montyprogram.com-20130821144209-iqswms0ua5j8ja9x
parent: igor at askmonty.org-20130820204713-98acrb6ezfz0fdbm
committer: sanja at montyprogram.com
branch nick: work-maria-5.3-MDEV-4908
timestamp: Wed 2013-08-21 17:42:09 +0300
message:
  MDEV-4908: Assertion `((Item_cond *) cond)->functype() == ((Item_cond *) new_item)->functype()' fails on a query with IN and equal conditions, AND/OR, materialization+semijoin
  
  A new AND Item should be prepared (fix_field() call) before using.
-------------- next part --------------
=== modified file 'mysql-test/r/subselect_mat.result'
--- a/mysql-test/r/subselect_mat.result	2013-02-21 02:01:36 +0000
+++ b/mysql-test/r/subselect_mat.result	2013-08-21 14:42:09 +0000
@@ -2002,6 +2002,20 @@ DROP TABLE t1,t2;
 # This must be at the end:
 set optimizer_switch=@subselect_sj_mat_tmp;
 set join_cache_level=@save_join_cache_level;
+#
+# MDEV-4908: Assertion `((Item_cond *) cond)->functype() == 
+# ((Item_cond *) new_item)->functype()' fails on a query with
+# IN and equal conditions, AND/OR, materialization+semijoin
+# 
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch = 'materialization=on,semijoin=on';
+CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,3,5),(2,4,6);
+SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b );
+pk	a	b
+drop table t1;
+SET optimizer_switch=@save_optimizer_switch;
+# End of 5.3 tests
 set @subselect_mat_test_optimizer_switch_value=null;
 set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
 set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';

=== modified file 'mysql-test/r/subselect_sj_mat.result'
--- a/mysql-test/r/subselect_sj_mat.result	2013-02-21 02:01:36 +0000
+++ b/mysql-test/r/subselect_sj_mat.result	2013-08-21 14:42:09 +0000
@@ -2042,3 +2042,17 @@ DROP TABLE t1,t2;
 # This must be at the end:
 set optimizer_switch=@subselect_sj_mat_tmp;
 set join_cache_level=@save_join_cache_level;
+#
+# MDEV-4908: Assertion `((Item_cond *) cond)->functype() == 
+# ((Item_cond *) new_item)->functype()' fails on a query with
+# IN and equal conditions, AND/OR, materialization+semijoin
+# 
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch = 'materialization=on,semijoin=on';
+CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,3,5),(2,4,6);
+SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b );
+pk	a	b
+drop table t1;
+SET optimizer_switch=@save_optimizer_switch;
+# End of 5.3 tests

=== modified file 'mysql-test/t/subselect_sj_mat.test'
--- a/mysql-test/t/subselect_sj_mat.test	2012-05-18 12:24:12 +0000
+++ b/mysql-test/t/subselect_sj_mat.test	2013-08-21 14:42:09 +0000
@@ -1681,3 +1681,21 @@ DROP TABLE t1,t2;
 set optimizer_switch=@subselect_sj_mat_tmp;
 set join_cache_level=@save_join_cache_level;
 
+--echo #
+--echo # MDEV-4908: Assertion `((Item_cond *) cond)->functype() == 
+--echo # ((Item_cond *) new_item)->functype()' fails on a query with
+--echo # IN and equal conditions, AND/OR, materialization+semijoin
+--echo # 
+
+
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch = 'materialization=on,semijoin=on';
+
+CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1,3,5),(2,4,6);
+SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b );
+
+drop table t1;
+SET optimizer_switch=@save_optimizer_switch;
+
+--echo # End of 5.3 tests

=== modified file 'sql/opt_subselect.cc'
--- a/sql/opt_subselect.cc	2013-03-29 15:27:06 +0000
+++ b/sql/opt_subselect.cc	2013-08-21 14:42:09 +0000
@@ -5154,10 +5154,12 @@ bool setup_jtbm_semi_joins(JOIN *join, L
           {
             eq_cond= new Item_func_eq(subq_pred->left_expr->element_index(i),
                                       new_sink->row[i]);
-            if (!eq_cond || eq_cond->fix_fields(join->thd, &eq_cond))
+            if (!eq_cond)
               DBUG_RETURN(1);
 
-            (*join_where)= and_items(*join_where, eq_cond);
+            if (!((*join_where)= and_items(*join_where, eq_cond)) ||
+                (*join_where)->fix_fields(join->thd, join_where))
+              DBUG_RETURN(1);
           }
         }
         else



More information about the commits mailing list