Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:
Description
Not repeatable in maria-5.2,maria-5.1,mysql-5.5
Even after the fix for 813447, the following query:
SELECT t2.b FROM t1
LEFT JOIN t2
ON t1.col_int_nokey = t2.a
AND ( t2.b , t1.b ) IN ( SELECT 'c' , 'd' );
returns "a" which is wrong since the second part of the ON predicate is FALSE for all rows.
explain:
| 1 | PRIMARY | t1 | system | NULL | NULL | NULL | NULL | 1 | |
| 1 | PRIMARY | t2 | const | PRIMARY | PRIMARY | 4 | const | 1 | |
| 2 | DEPENDENT SUBQUERY | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
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=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=off,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-07-25 21:52:15 -0700
build-date: 2011-07-28 11:26:14 +0300
revno: 3005
branch-nick: maria-5.2
test case:
CREATE TABLE t1 ( c int NOT NULL , b varchar(32) NOT NULL ) ;
INSERT INTO t1 VALUES (1,'b');
CREATE TABLE t2 ( a int NOT NULL , b varchar(32) NOT NULL , PRIMARY KEY (a)) ;
INSERT INTO t2 VALUES (1,'a');
SELECT t2.b FROM t1
LEFT JOIN t2
ON t1.c = t2.a
AND ( t2.b , t1.b ) IN (SELECT 'c' , 'd' );
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Re: Wrong result with outer join + subquery in ON clause +unique key in maria-5.3
Slightly more general example:
CREATE TABLE t1 ( c int NOT NULL , b char(1) NOT NULL ) ;
INSERT INTO t1 VALUES (1,'b');
CREATE TABLE t2 ( a int NOT NULL , b char(1) NOT NULL , PRIMARY KEY (a)) ;
INSERT INTO t2 VALUES (1,'a');
create table t3 (c1 char(1), c2 char(2));
insert into t3 values ('c','d');
insert into t3 values ('c','d');
SELECT t2.b
FROM t1 LEFT JOIN t2 ON t1.c = t2.a AND ( t2.b , t1.b ) IN (SELECT * from t3);