Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
The following query:
SELECT *
FROM t1 , t2
WHERE ( t1.f4 ) IN ( SELECT f4 FROM t3 )
AND t2.f4 != t1.f3 ;
returns no rows when executed with semijoin+materialization, even though the correct result is:
| x | x | g |
| x | x | g |
as those rows do match the WHERE predicate.
Explain:
| 1 | PRIMARY | t2 | ALL | NULL | NULL | NULL | NULL | 1 | |
| 1 | PRIMARY | <subquery2> | ALL | distinct_key | NULL | NULL | NULL | 1 | Using where |
| 1 | PRIMARY | t1 | ALL | NULL | NULL | NULL | NULL | 2 | Using where; Using join buffer (flat, BNL join) |
| 2 | SUBQUERY | t3 | ALL | NULL | NULL | NULL | NULL | 1 |
minimal optimizer switch:semijoin=on,materialization=on
full optimizer switch:
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,index_condition_pushdown=off,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on
bzr version-info:
revision-id: <email address hidden>
date: 2011-10-06 01:21:15 +0400
build-date: 2011-10-06 12:19:12 +0300
revno: 3213
branch-nick: maria-5.3
test case:
--source include/have_innodb.inc
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (f3 varchar(1) , f4 varchar(1) ) engine=InnoDB;
INSERT IGNORE INTO t1 VALUES ('x','x'),('x','x');
DROP TABLE IF EXISTS t2;
CREATE TABLE t2 ( f4 varchar(1) ) ;
INSERT IGNORE INTO t2 VALUES ('g');
DROP TABLE IF EXISTS t3;
CREATE TABLE t3 (f4 varchar(1) ) Engine=InnoDB;
INSERT IGNORE INTO t3 VALUES ('x');
SET SESSION optimizer_switch='semijoin=on,materialization=on';
SELECT *
FROM t1 , t2
WHERE ( t1.f4 ) IN ( SELECT f4 FROM t3 )
AND t2.f4 != t1.f3 ;