From: Jorgen Loland Date: January 10 2011 9:04am Subject: bzr push into mysql-trunk branch (jorgen.loland:3470 to 3471) Bug#58837 List-Archive: http://lists.mysql.com/commits/128255 X-Bug: 58837 Message-Id: <20110110090449.B7BC97A9@atum21.norway.sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3471 Jorgen Loland 2011-01-10 BUG#58837: ICP crash or valgrind error due to uninitialized value in innobase_index_cond The problem was that ICP pushed a condition to an InnoDB table accessed through the primary key, and handler::end_range was not initialized in this case. This problem emerged now because ICP on InnoDB primary index has recently been enabled. @ mysql-test/include/icp_tests.inc Added test case for BUG#58837 @ mysql-test/r/innodb_icp.result Added test case for BUG#58837 @ mysql-test/r/innodb_icp_none.result Added test case for BUG#58837 @ mysql-test/r/myisam_icp.result Added test case for BUG#58837 @ mysql-test/r/myisam_icp_none.result Added test case for BUG#58837 @ sql/handler.h Initialize handler::end_range in ha_rnd_init() and ha_rnd_end() modified: mysql-test/include/icp_tests.inc mysql-test/r/innodb_icp.result mysql-test/r/innodb_icp_none.result mysql-test/r/myisam_icp.result mysql-test/r/myisam_icp_none.result sql/handler.h 3470 Vasil Dimov 2011-01-08 [merge] Merge mysql-5.5 -> mysql-trunk (empty) === modified file 'mysql-test/include/icp_tests.inc' --- a/mysql-test/include/icp_tests.inc 2010-12-13 15:22:45 +0000 +++ b/mysql-test/include/icp_tests.inc 2011-01-10 09:04:20 +0000 @@ -653,3 +653,47 @@ create table t1 (a char(2) charset utf8, insert into t1 values ('',1); select 1 from t1 where b <= 1 and a <> ''; drop table t1; + +--echo # +--echo # Bug#58837: ICP crash or valgrind error due to uninitialized +--echo # value in innobase_index_cond +--echo # + +CREATE TABLE t1 ( + t1_int INT, + t1_time TIME +); + +CREATE TABLE t2 ( + t2_int int PRIMARY KEY, + t2_int2 INT +); + +--disable_warnings +INSERT INTO t2 VALUES (); +INSERT INTO t1 VALUES (); +--enable_warnings + +let $query= +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS + (SELECT * + FROM t1 AS t1b + WHERE t1b.t1_int NOT IN + (SELECT t2.t2_int + FROM t2 + WHERE t1b.t1_time LIKE t1b.t1_int + OR t1b.t1_time <> t2.t2_int2 + AND 6=7 + ) +) +; + +--echo +--eval $query; +--echo +--eval EXPLAIN $query; +--echo + +DROP TABLE t1,t2; === modified file 'mysql-test/r/innodb_icp.result' --- a/mysql-test/r/innodb_icp.result 2010-12-13 15:22:45 +0000 +++ b/mysql-test/r/innodb_icp.result 2011-01-10 09:04:20 +0000 @@ -598,5 +598,56 @@ insert into t1 values ('',1); select 1 from t1 where b <= 1 and a <> ''; 1 drop table t1; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT INTO t2 VALUES (); +INSERT INTO t1 VALUES (); + +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +t1_int t1_time + +EXPLAIN SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1b ALL NULL NULL NULL NULL 1 Using where +3 DEPENDENT SUBQUERY t2 unique_subquery PRIMARY PRIMARY 4 func 1 Using where; Full scan on NULL key + +DROP TABLE t1,t2; set default_storage_engine= @save_storage_engine; set optimizer_switch=default; === modified file 'mysql-test/r/innodb_icp_none.result' --- a/mysql-test/r/innodb_icp_none.result 2010-12-13 15:22:45 +0000 +++ b/mysql-test/r/innodb_icp_none.result 2011-01-10 09:04:20 +0000 @@ -597,5 +597,56 @@ insert into t1 values ('',1); select 1 from t1 where b <= 1 and a <> ''; 1 drop table t1; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT INTO t2 VALUES (); +INSERT INTO t1 VALUES (); + +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +t1_int t1_time + +EXPLAIN SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1b ALL NULL NULL NULL NULL 1 Using where +3 DEPENDENT SUBQUERY t2 unique_subquery PRIMARY PRIMARY 4 func 1 Using where; Full scan on NULL key + +DROP TABLE t1,t2; set default_storage_engine= @save_storage_engine; set optimizer_switch=default; === modified file 'mysql-test/r/myisam_icp.result' --- a/mysql-test/r/myisam_icp.result 2010-12-13 15:22:45 +0000 +++ b/mysql-test/r/myisam_icp.result 2011-01-10 09:04:20 +0000 @@ -596,4 +596,55 @@ insert into t1 values ('',1); select 1 from t1 where b <= 1 and a <> ''; 1 drop table t1; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT INTO t2 VALUES (); +INSERT INTO t1 VALUES (); + +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +t1_int t1_time + +EXPLAIN SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1b system NULL NULL NULL NULL 1 +3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE + +DROP TABLE t1,t2; set optimizer_switch=default; === modified file 'mysql-test/r/myisam_icp_none.result' --- a/mysql-test/r/myisam_icp_none.result 2010-12-13 15:22:45 +0000 +++ b/mysql-test/r/myisam_icp_none.result 2011-01-10 09:04:20 +0000 @@ -595,4 +595,55 @@ insert into t1 values ('',1); select 1 from t1 where b <= 1 and a <> ''; 1 drop table t1; +# +# Bug#58837: ICP crash or valgrind error due to uninitialized +# value in innobase_index_cond +# +CREATE TABLE t1 ( +t1_int INT, +t1_time TIME +); +CREATE TABLE t2 ( +t2_int int PRIMARY KEY, +t2_int2 INT +); +INSERT INTO t2 VALUES (); +INSERT INTO t1 VALUES (); + +SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +t1_int t1_time + +EXPLAIN SELECT * +FROM t1 AS t1a +WHERE NOT EXISTS +(SELECT * +FROM t1 AS t1b +WHERE t1b.t1_int NOT IN +(SELECT t2.t2_int +FROM t2 +WHERE t1b.t1_time LIKE t1b.t1_int +OR t1b.t1_time <> t2.t2_int2 +AND 6=7 +) +) +;; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +2 SUBQUERY t1b system NULL NULL NULL NULL 1 +3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE + +DROP TABLE t1,t2; set optimizer_switch=default; === modified file 'sql/handler.h' --- a/sql/handler.h 2010-11-18 16:34:56 +0000 +++ b/sql/handler.h 2011-01-10 09:04:20 +0000 @@ -1556,6 +1556,7 @@ public: DBUG_ENTER("ha_rnd_init"); DBUG_ASSERT(inited==NONE || (inited==RND && scan)); inited= (result= rnd_init(scan)) ? NONE: RND; + end_range= NULL; DBUG_RETURN(result); } int ha_rnd_end() @@ -1563,6 +1564,7 @@ public: DBUG_ENTER("ha_rnd_end"); DBUG_ASSERT(inited==RND); inited=NONE; + end_range= NULL; DBUG_RETURN(rnd_end()); } int ha_rnd_next(uchar *buf); No bundle (reason: useless for push emails).