From ddc5c65333a4add28907ccb82054ecba0ff6b873 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Thu, 22 Mar 2018 03:01:53 +0530 Subject: MDEV-14779: using left join causes incorrect results with materialization and derived tables Conversion of a subquery to a semi-join is blocked when we have an IN subquery predicate in the on_expr of an outer join. Currently this scenario is handled but the cases when an IN subquery predicate is wrapped inside a Item_in_optimizer item then this blocking is not done. --- mysql-test/r/join_outer.result | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'mysql-test/r/join_outer.result') diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 74580e67499..67b22ca86b2 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -2346,11 +2346,27 @@ CREATE TABLE t1 (b1 BIT NOT NULL); INSERT INTO t1 VALUES (0),(1); CREATE TABLE t2 (b2 BIT NOT NULL); INSERT INTO t2 VALUES (0),(1); -SET SESSION JOIN_CACHE_LEVEL = 3; +set @save_join_cache_level= @@join_cache_level; +SET @@join_cache_level = 3; SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2; t1.b1+'0' t2.b2 + '0' 0 0 1 1 DROP TABLE t1, t2; +set @join_cache_level= @save_join_cache_level; +# +# MDEV-14779: using left join causes incorrect results with materialization and derived tables +# +create table t1(id int); +insert into t1 values (1),(2); +create table t2(sid int, id int); +insert into t2 values (1,1),(2,2); +select * from t1 t +left join (select * from t2 where sid in (select max(sid) from t2 where 0=1 group by id)) r +on t.id=r.id ; +id sid id +1 NULL NULL +2 NULL NULL +drop table t1, t2; # end of 5.5 tests SET optimizer_switch=@save_optimizer_switch; -- cgit v1.2.1