List:Commits« Previous MessageNext Message »
From:Jorgen Loland Date:June 15 2011 10:50am
Subject:bzr commit into mysql-trunk branch (jorgen.loland:3384) Bug#12608157
View as plain text  
#At file:///export/home/jl208045/mysql/mysql-next-mr-opt-backporting-12608157/ based on revid:guilhem.bichot@stripped

 3384 Jorgen Loland	2011-06-15
      Bug#12608157 - ASSERT IN FIELD_LONG::VAL_INT WHEN USING 
                     MEMORY ENGINE
      
      Item_in_subselect does not have it's own implementation of 
      walk(), but rather inherits Item_subselect::walk(). This is a
      problem because Item_in_subselect has Item *left_expression 
      which Item_subselect does not have.
      
      Due to this, cond->walk() would not walk 
      Item_in_subselect::left_expression which resulted in an ASSERT
      because the column in left_expression was not marked in the 
      read_set. The reason why memory storage engine was required 
      to trigger the bug is that with this engine, filesort does 
      not use addon_fields. In the case of engines like MyISAM and 
      InnoDB, the column not registered in the read set was found 
      during preparation of addon fields in register_used_fields().
      
      The fix is to implement Item_in_subselect::walk() which calls
      both left_expr->walk() and Item_subselect::walk().
     @ mysql-test/include/subquery_sj.inc
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_all.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_all_jcl6.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_all_jcl7.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_dupsweed.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_dupsweed_jcl6.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_dupsweed_jcl7.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_firstmatch.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_firstmatch_jcl6.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_firstmatch_jcl7.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_loosescan.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_loosescan_jcl6.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_loosescan_jcl7.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_mat.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_mat_jcl6.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_mat_jcl7.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_mat_nosj.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_none.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_none_jcl6.result
        Add test for BUG#12608157
     @ mysql-test/r/subquery_sj_none_jcl7.result
        Add test for BUG#12608157
     @ sql/item_subselect.cc
        Add Item_in_subselect::walk() and Item_subselect::walk_body()
     @ sql/item_subselect.h
        Add Item_in_subselect::walk() and Item_subselect::walk_body()

    modified:
      mysql-test/include/subquery_sj.inc
      mysql-test/r/subquery_sj_all.result
      mysql-test/r/subquery_sj_all_jcl6.result
      mysql-test/r/subquery_sj_all_jcl7.result
      mysql-test/r/subquery_sj_dupsweed.result
      mysql-test/r/subquery_sj_dupsweed_jcl6.result
      mysql-test/r/subquery_sj_dupsweed_jcl7.result
      mysql-test/r/subquery_sj_firstmatch.result
      mysql-test/r/subquery_sj_firstmatch_jcl6.result
      mysql-test/r/subquery_sj_firstmatch_jcl7.result
      mysql-test/r/subquery_sj_loosescan.result
      mysql-test/r/subquery_sj_loosescan_jcl6.result
      mysql-test/r/subquery_sj_loosescan_jcl7.result
      mysql-test/r/subquery_sj_mat.result
      mysql-test/r/subquery_sj_mat_jcl6.result
      mysql-test/r/subquery_sj_mat_jcl7.result
      mysql-test/r/subquery_sj_mat_nosj.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/subquery_sj_none_jcl6.result
      mysql-test/r/subquery_sj_none_jcl7.result
      sql/item_subselect.cc
      sql/item_subselect.h
=== modified file 'mysql-test/include/subquery_sj.inc'
--- a/mysql-test/include/subquery_sj.inc	2011-06-12 14:04:09 +0000
+++ b/mysql-test/include/subquery_sj.inc	2011-06-15 10:50:48 +0000
@@ -3595,3 +3595,25 @@ where table1.col_int_nokey in 
 );
 
 DROP TABLE t1,t2,t3;
+
+--echo #
+--echo # Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+--echo #
+
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+      IN ( SELECT PARENT1.i2
+           FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+           WHERE 
+              GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+           ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+
+DROP TABLE t1,t2;

=== modified file 'mysql-test/r/subquery_sj_all.result'
--- a/mysql-test/r/subquery_sj_all.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_all.result	2011-06-15 10:50:48 +0000
@@ -5485,4 +5485,23 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_all_jcl6.result'
--- a/mysql-test/r/subquery_sj_all_jcl6.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_all_jcl6.result	2011-06-15 10:50:48 +0000
@@ -5489,5 +5489,24 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_join_cache_level=default;

=== modified file 'mysql-test/r/subquery_sj_all_jcl7.result'
--- a/mysql-test/r/subquery_sj_all_jcl7.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_all_jcl7.result	2011-06-15 10:50:48 +0000
@@ -5489,5 +5489,24 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_join_cache_level=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed.result'
--- a/mysql-test/r/subquery_sj_dupsweed.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed.result	2011-06-15 10:50:48 +0000
@@ -5484,4 +5484,23 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed_jcl6.result'
--- a/mysql-test/r/subquery_sj_dupsweed_jcl6.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed_jcl6.result	2011-06-15 10:50:48 +0000
@@ -5488,5 +5488,24 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_join_cache_level=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed_jcl7.result'
--- a/mysql-test/r/subquery_sj_dupsweed_jcl7.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed_jcl7.result	2011-06-15 10:50:48 +0000
@@ -5488,5 +5488,24 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_join_cache_level=default;

=== modified file 'mysql-test/r/subquery_sj_firstmatch.result'
--- a/mysql-test/r/subquery_sj_firstmatch.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch.result	2011-06-15 10:50:48 +0000
@@ -5486,6 +5486,25 @@ col_int_key
 6
 DROP TABLE t1,t2,t3;
 #
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
+#
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for
 #           certain query plans
 #

=== modified file 'mysql-test/r/subquery_sj_firstmatch_jcl6.result'
--- a/mysql-test/r/subquery_sj_firstmatch_jcl6.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch_jcl6.result	2011-06-15 10:50:48 +0000
@@ -5490,6 +5490,25 @@ col_int_key
 6
 DROP TABLE t1,t2,t3;
 #
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
+#
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for
 #           certain query plans
 #

=== modified file 'mysql-test/r/subquery_sj_firstmatch_jcl7.result'
--- a/mysql-test/r/subquery_sj_firstmatch_jcl7.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch_jcl7.result	2011-06-15 10:50:48 +0000
@@ -5490,6 +5490,25 @@ col_int_key
 6
 DROP TABLE t1,t2,t3;
 #
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
+#
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for
 #           certain query plans
 #

=== modified file 'mysql-test/r/subquery_sj_loosescan.result'
--- a/mysql-test/r/subquery_sj_loosescan.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_loosescan.result	2011-06-15 10:50:48 +0000
@@ -5485,4 +5485,23 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_loosescan_jcl6.result'
--- a/mysql-test/r/subquery_sj_loosescan_jcl6.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_loosescan_jcl6.result	2011-06-15 10:50:48 +0000
@@ -5489,5 +5489,24 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_join_cache_level=default;

=== modified file 'mysql-test/r/subquery_sj_loosescan_jcl7.result'
--- a/mysql-test/r/subquery_sj_loosescan_jcl7.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_loosescan_jcl7.result	2011-06-15 10:50:48 +0000
@@ -5489,5 +5489,24 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_join_cache_level=default;

=== modified file 'mysql-test/r/subquery_sj_mat.result'
--- a/mysql-test/r/subquery_sj_mat.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_mat.result	2011-06-15 10:50:48 +0000
@@ -5485,4 +5485,23 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat_jcl6.result'
--- a/mysql-test/r/subquery_sj_mat_jcl6.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_mat_jcl6.result	2011-06-15 10:50:48 +0000
@@ -5489,5 +5489,24 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_join_cache_level=default;

=== modified file 'mysql-test/r/subquery_sj_mat_jcl7.result'
--- a/mysql-test/r/subquery_sj_mat_jcl7.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_mat_jcl7.result	2011-06-15 10:50:48 +0000
@@ -5489,5 +5489,24 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_join_cache_level=default;

=== modified file 'mysql-test/r/subquery_sj_mat_nosj.result'
--- a/mysql-test/r/subquery_sj_mat_nosj.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_mat_nosj.result	2011-06-15 10:50:48 +0000
@@ -5707,4 +5707,23 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_none.result'
--- a/mysql-test/r/subquery_sj_none.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_none.result	2011-06-15 10:50:48 +0000
@@ -5630,4 +5630,23 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_none_jcl6.result'
--- a/mysql-test/r/subquery_sj_none_jcl6.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_none_jcl6.result	2011-06-15 10:50:48 +0000
@@ -5634,5 +5634,24 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_join_cache_level=default;

=== modified file 'mysql-test/r/subquery_sj_none_jcl7.result'
--- a/mysql-test/r/subquery_sj_none_jcl7.result	2011-06-12 14:04:09 +0000
+++ b/mysql-test/r/subquery_sj_none_jcl7.result	2011-06-15 10:50:48 +0000
@@ -5634,5 +5634,24 @@ col_int_key
 6
 6
 DROP TABLE t1,t2,t3;
+#
+# Bug#12608157: ASSERT IN FIELD_LONG::VAL_INT WHEN USING MEMORY ENGINE
+#
+CREATE TABLE t1 (i1 int);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (i1 int, i2 int) ENGINE=memory;
+INSERT INTO t2 VALUES (1, 2),(7, 3);
+SELECT GRANDPARENT1.i1
+FROM t2 AS GRANDPARENT1 
+WHERE GRANDPARENT1.i2
+IN ( SELECT PARENT1.i2
+FROM t2 AS PARENT1 JOIN t1 AS PARENT2 ON (PARENT1.i1 = PARENT2.i1)
+WHERE 
+GRANDPARENT1.i1 IN ( SELECT CHILD1.i1 FROM t2 AS CHILD1 )
+ORDER BY PARENT1.i1)
+ORDER BY GRANDPARENT1.i2 ;
+i1
+1
+DROP TABLE t1,t2;
 set optimizer_switch=default;
 set optimizer_join_cache_level=default;

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2011-06-11 14:09:39 +0000
+++ b/sql/item_subselect.cc	2011-06-15 10:50:48 +0000
@@ -250,11 +250,12 @@ err:
   return res;
 }
 
-
-bool Item_subselect::walk(Item_processor processor, bool walk_subquery,
-                          uchar *argument)
+/**
+  Workaround for bug in gcc 4.1. @See Item_in_subselect::walk()
+*/
+bool Item_subselect::walk_body(Item_processor processor, bool walk_subquery,
+                               uchar *argument)
 {
-
   if (walk_subquery)
   {
     for (SELECT_LEX *lex= unit->first_select(); lex; lex= lex->next_select())
@@ -289,6 +290,12 @@ bool Item_subselect::walk(Item_processor
   return (this->*processor)(argument);
 }
 
+bool Item_subselect::walk(Item_processor processor, bool walk_subquery,
+                          uchar *argument)
+{
+  return walk_body(processor, walk_subquery, argument);
+}
+
 
 bool Item_subselect::exec()
 {
@@ -383,6 +390,18 @@ void Item_subselect::fix_after_pullout(s
   }
 }
 
+bool Item_in_subselect::walk(Item_processor processor, bool walk_subquery,
+                             uchar *argument)
+{
+  if (left_expr->walk(processor, walk_subquery, argument))
+    return true;
+  /*
+    Cannot call "Item_subselect::walk(...)" because with gcc 4.1
+    Item_in_subselect::walk() was incorrectly called instead.
+    Using Item_subselect::walk_body() instead is a workaround.
+  */
+  return walk_body(processor, walk_subquery, argument);
+}
 
 /*
   Compute the IN predicate if the left operand's cache changed.

=== modified file 'sql/item_subselect.h'
--- a/sql/item_subselect.h	2011-06-11 14:09:39 +0000
+++ b/sql/item_subselect.h	2011-06-15 10:50:48 +0000
@@ -152,6 +152,7 @@ public:
   */
   virtual void reset_value_registration() {}
   enum_parsing_place place() { return parsing_place; }
+  bool walk_body(Item_processor processor, bool walk_subquery, uchar *arg);
   bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
 
   /**
@@ -390,6 +391,7 @@ public:
   trans_res single_value_in_to_exists_transformer(JOIN * join,
                                                   Comp_creator *func);
   trans_res row_value_in_to_exists_transformer(JOIN * join);
+  bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
   virtual bool exec();
   longlong val_int();
   double val_real();


Attachment: [text/bzr-bundle] bzr/jorgen.loland@oracle.com-20110615105048-yhbq58b26glco915.bundle
Thread
bzr commit into mysql-trunk branch (jorgen.loland:3384) Bug#12608157Jorgen Loland16 Jun