The bug can be reproduced with all optimizer switches set to OFF.
Slightly simplified example:
CREATE TABLE t1 ( f1 int NOT NULL , f2 int, f3 int, KEY (f3,f2), PRIMARY KEY (f1)) ;
INSERT IGNORE INTO t1 VALUES (19,1,NULL),(20,5,'r');
CREATE TABLE t2 ( f1 int NOT NULL , f2 int, f3 int, KEY (f3,f2), PRIMARY KEY (f1)) ;
INSERT IGNORE INTO t2 VALUES (19,1,NULL),(20,5,'r');
SELECT * FROM t1, t2
WHERE (t1.f1 > 238 OR t1.f2 NOT BETWEEN 238 AND 238 ) AND t1.f3 != 'y' AND t1.f2 BETWEEN 238 AND 238 AND
( t1.f3 = 'u' OR t1.f1 = 245 );
The bug can be reproduced with all optimizer switches set to OFF.
Slightly simplified example:
CREATE TABLE t1 ( f1 int NOT NULL , f2 int, f3 int, KEY (f3,f2), PRIMARY KEY (f1)) ; ,(20,5, 'r'); ,(20,5, 'r');
INSERT IGNORE INTO t1 VALUES (19,1,NULL)
CREATE TABLE t2 ( f1 int NOT NULL , f2 int, f3 int, KEY (f3,f2), PRIMARY KEY (f1)) ;
INSERT IGNORE INTO t2 VALUES (19,1,NULL)
SELECT * FROM t1, t2
t1.f3 != 'y' AND
t1.f2 BETWEEN 238 AND 238 AND
WHERE (t1.f1 > 238 OR t1.f2 NOT BETWEEN 238 AND 238 ) AND
( t1.f3 = 'u' OR t1.f1 = 245 );