From 86f43c30771cdfbb38f1a958de0e7f131451a988 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 29 Apr 2013 20:31:40 -0700 Subject: Fixed bug mdev-4274. This bug was the result of incompleteness of the patch for bug mdev-4177. When an OR condition is simplified to a single conjunct it is merged into the embedding AND condition. Multiple equalities are also merged, and any field item involved in those equality should acquire a pointer to a the multiple equality formed by this merge. --- mysql-test/t/select.test | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'mysql-test/t/select.test') diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index e202e013377..54168332664 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -4241,6 +4241,7 @@ SELECT f1 FROM t1 GROUP BY 1; SELECT f1 FROM t1 GROUP BY '123' = 'abc'; SELECT 1 FROM t1 GROUP BY 1; drop table t1; +set sql_buffer_result= 0; --echo End of 5.1 tests @@ -4305,4 +4306,40 @@ WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1) OR Time_zone_id <> Time_zone_id ) AND Use_leap_seconds <> 'N'; +--echo # +--echo # Bug mdev-4274: result of simplification of OR badly merged +--echo # into embedding AND +--echo # + +CREATE TABLE t1 (a int, b int, INDEX idx(b)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (8,8); + +CREATE TABLE t2 (c int, INDEX idx(c)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (8), (9); + +EXPLAIN EXTENDED +SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) + WHERE 1 IS NULL OR b < 33 AND b = c; +SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) + WHERE 1 IS NULL OR b < 33 AND b = c; + +DROP TABLE t1,t2; + +--echo # +--echo # Bug mdev-4413: another manifestations of bug mdev-2474 +--echo # (valgrind complains) +--echo # + +CREATE TABLE t1 (a int, b int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (7,1); + +CREATE TABLE t2 (c int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0), (8); + +SELECT * FROM t1, t2 + WHERE c = a AND + ( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c ); + +DROP TABLE t1, t2; + --echo End of 5.3 tests -- cgit v1.2.1