Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:
Description
The following query:
SELECT alias2.b, alias2.c, t1.a
FROM t1 , (
SELECT t3.* FROM t2
RIGHT JOIN t3
ON ( t3.a = t2.b )
) AS alias2
WHERE alias2.b
AND alias2.c = t1.a;
returns no rows with derived_merge=ON (impossible where, even though the WHERE clause is true) and 1 row with derived_merge=ON (which is the correct result:
EXPLAIN with derived_merge=ON:
| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Impossible WHERE noticed after reading const tables |
| Note | 1003 | select 8 AS `b`,'c' AS `c`,'c' AS `a` from `test`.`t1` join `test`.`t3` join `test`.`t2` where 0 |
EXPLAIN with derived_merge=off:
| 1 | PRIMARY | t1 | system | NULL | NULL | NULL | NULL | 1 | 100.00 | |
| 1 | PRIMARY | <derived2> | system | NULL | NULL | NULL | NULL | 1 | 100.00 | |
| 2 | DERIVED | t2 | system | NULL | NULL | NULL | NULL | 0 | 0.00 | const row not found |
| 2 | DERIVED | t3 | system | NULL | NULL | NULL | NULL | 1 | 100.00 |
select 8 AS `b`,'c' AS `c`,'c' AS `a` from `test`.`t1` join (select 29 AS `a`,8 AS `b`,'c' AS `c` from `test`.`t3` left join `test`.`t2` on(0)) `alias2` where (8)
minimal optimizer switch: derived_merge=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=on,derived_merge=on,derived_with_keys=on,firstmatch=off,loosescan=off,materialization=off,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=off,mrr=on,mrr_cost_based=off,mrr_sort_keys=on,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
test case:
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( a varchar(1)) engine=myisam ;
INSERT INTO t1 VALUES ('c');
DROP TABLE IF EXISTS t2;
CREATE TABLE t2 ( b int) engine=myisam;
DROP TABLE IF EXISTS t3;
CREATE TABLE t3 ( a int(11) NOT NULL , b int, c varchar(1)) engine=myisam;
INSERT INTO t3 VALUES (29,8,'c');
SELECT alias2.b, alias2.c, t1.a
FROM t1 , (
SELECT t3.* FROM t2
RIGHT JOIN t3
ON ( t3.a = t2.b )
) AS alias2
WHERE alias2.b
AND alias2.c = t1.a;
This particular test case contains a degenerate WHERE condition, however the bug was also observed with a WHERE condition containing x IN (SELECT y), so I think it is a valid bug.
bzr version-info:
revision-id: <email address hidden>
date: 2011-10-22 00:14:27 -0700
build-date: 2011-10-22 15:04:21 +0300
revno: 3246
branch-nick: maria-5.3
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Launchpad bug id: 879882