Commit d31d7ea6 authored by Sergey Petrunya's avatar Sergey Petrunya

Merge fix for BUG#869012

parents e3abb86c 0fb82ea1
......@@ -802,4 +802,24 @@ WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1
f12
y
DROP TABLE t1,t2,t3;
#
# BUG#869012: Wrong result with semijoin + materialization + AND in WHERE
#
CREATE TABLE t1 (f3 varchar(1) , f4 varchar(1) ) engine=InnoDB;
INSERT IGNORE INTO t1 VALUES ('x','x'),('x','x');
CREATE TABLE t2 ( f4 varchar(1) ) ;
INSERT IGNORE INTO t2 VALUES ('g');
CREATE TABLE t3 (f4 varchar(1) ) Engine=InnoDB;
INSERT IGNORE INTO t3 VALUES ('x');
set @tmp_869012=@@optimizer_switch;
SET optimizer_switch='semijoin=on,materialization=on';
SELECT *
FROM t1 , t2
WHERE ( t1.f4 ) IN ( SELECT f4 FROM t3 )
AND t2.f4 != t1.f3 ;
f3 f4 f4
x x g
x x g
set optimizer_switch= @tmp_869012;
# This must be the last in the file:
set optimizer_switch=@subselect_sj2_tmp;
......@@ -813,6 +813,26 @@ WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1
f12
y
DROP TABLE t1,t2,t3;
#
# BUG#869012: Wrong result with semijoin + materialization + AND in WHERE
#
CREATE TABLE t1 (f3 varchar(1) , f4 varchar(1) ) engine=InnoDB;
INSERT IGNORE INTO t1 VALUES ('x','x'),('x','x');
CREATE TABLE t2 ( f4 varchar(1) ) ;
INSERT IGNORE INTO t2 VALUES ('g');
CREATE TABLE t3 (f4 varchar(1) ) Engine=InnoDB;
INSERT IGNORE INTO t3 VALUES ('x');
set @tmp_869012=@@optimizer_switch;
SET optimizer_switch='semijoin=on,materialization=on';
SELECT *
FROM t1 , t2
WHERE ( t1.f4 ) IN ( SELECT f4 FROM t3 )
AND t2.f4 != t1.f3 ;
f3 f4 f4
x x g
x x g
set optimizer_switch= @tmp_869012;
# This must be the last in the file:
set optimizer_switch=@subselect_sj2_tmp;
set join_cache_level=default;
show variables like 'join_cache_level';
......
This diff is collapsed.
This diff is collapsed.
......@@ -988,5 +988,25 @@ WHERE f12 IN (SELECT alias2.f12 FROM t1 AS alias1, t2 AS alias2, t1 WHERE alias1
DROP TABLE t1,t2,t3;
--echo #
--echo # BUG#869012: Wrong result with semijoin + materialization + AND in WHERE
--echo #
CREATE TABLE t1 (f3 varchar(1) , f4 varchar(1) ) engine=InnoDB;
INSERT IGNORE INTO t1 VALUES ('x','x'),('x','x');
CREATE TABLE t2 ( f4 varchar(1) ) ;
INSERT IGNORE INTO t2 VALUES ('g');
CREATE TABLE t3 (f4 varchar(1) ) Engine=InnoDB;
INSERT IGNORE INTO t3 VALUES ('x');
set @tmp_869012=@@optimizer_switch;
SET optimizer_switch='semijoin=on,materialization=on';
SELECT *
FROM t1 , t2
WHERE ( t1.f4 ) IN ( SELECT f4 FROM t3 )
AND t2.f4 != t1.f3 ;
set optimizer_switch= @tmp_869012;
--echo # This must be the last in the file:
set optimizer_switch=@subselect_sj2_tmp;
......@@ -7969,7 +7969,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
*/
JOIN_TAB *first_inner_tab= tab->first_inner;
if (tab->table)
if (!tab->bush_children)
current_map= tab->table->map;
else
current_map= tab->bush_children->start->emb_sj_nest->sj_inner_tables;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment