Sergey,
It looks like this bug is also a legacy bug in multiple equalities:
MariaDB [test]> EXPLAIN EXTENDED SELECT * FROM t1 outer_t1 LEFT JOIN t2 ON (c2 = c1 OR c1 > 'z') WHERE outer_t1.c1 IN ( SELECT c1 FROM t1, t3 WHERE c3 = c1);
--------------------------------------------------------------------------------------------------------------------------------
id |
select_type |
table |
type |
possible_keys |
key |
key_len |
ref |
rows |
filtered |
Extra |
--------------------------------------------------------------------------------------------------------------------------------
1 |
PRIMARY |
outer_t1 |
ALL |
NULL |
NULL |
NULL |
NULL |
2 |
100.00 |
|
1 |
PRIMARY |
<subquery2> |
eq_ref |
distinct_key |
distinct_key |
4 |
func |
1 |
100.00 |
|
1 |
PRIMARY |
t2 |
ALL |
NULL |
NULL |
NULL |
NULL |
2 |
100.00 |
Using where; Using join buffer (flat, BNL join) |
2 |
MATERIALIZED |
t1 |
ALL |
NULL |
NULL |
NULL |
NULL |
2 |
100.00 |
|
2 |
MATERIALIZED |
t3 |
ALL |
NULL |
NULL |
NULL |
NULL |
10 |
100.00 |
Using where; Using join buffer (flat, BNL join) |
--------------------------------------------------------------------------------------------------------------------------------
5 rows in set, 1 warning (0.00 sec)
MariaDB [test]> show warnings;
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Note |
1003 |
select `test`.`outer_t1`.`i1` AS `i1`,`test`.`outer_t1`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` `outer_t1` semi join (`test`.`t1` join `test`.`t3`) left join `test`.`t2` on((((`test`.`t3`.`c3` = `test`.`t1`.`c1`) and (`test`.`t2`.`c2` = `test`.`outer_t1`.`c1`)) or (`test`.`outer_t1`.`c1` > 'z'))) where (`test`.`t3`.`c3` = `test`.`t1`.`c1`) |
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I will investigate the problem.
transformed join (without semi-join) produces more or less expected results ...
select `test`.`outer_t1`.`i1` AS `i1`,`test`.`outer_t1`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2` from `test`.`t1` `outer_t1` join (`test`.`t1` join `test`.`t3`) left join `test`.`t2` on((((`test`.`t3`.`c3` = `test`.`t1`.`c1`) and (`test`.`t2`.`c2` = `test`.`outer_t1`.`c1`)) or (`test`.`outer_t1`.`c1` > 'z'))) where (`test`.`t3`.`c3` = `test`.`t1`.`c1`);
i1 c1 c2
3 y y
3 y y
3 y y
3 y y
7 v NULL
7 v NULL