[MDEV-2550] LP:884184 - Wrong result with RIGHT JOIN + derived_merge Created: 2011-10-31 Updated: 2015-02-02 Resolved: 2012-10-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Philip Stoev (Inactive) | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
The following query: SELECT alias1.* returns the following incorrect result when executed with derived_merge=on: a b the correct result is (NULL , NULL) as the subquery does not return any rows and therefore the RIGHT JOIN between the subquery and a table can not include any rows from the subquery. explain: id select_type table type possible_keys key key_len ref rows filtered Extra select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t3` left join (`test`.`t1`) on(((`test`.`t2`.`a` <> 0) and (`test`.`t1`.`b` = 'g'))) where 1 minimal switch: derived_merge=on bzr version-info test case: DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t3; DROP TABLE IF EXISTS t2; SET SESSION optimizer_swtich='derived_merge=on'; SELECT alias1.* |
| Comments |
| Comment by Sergei Petrunia [ 2011-11-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Wrong result with RIGHT JOIN + derived_merge SELECT alias1.* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2011-11-01 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Wrong result with RIGHT JOIN + derived_merge
The bug is reproducible in 5.2 (and most probably in 5.1): igor@sophia:~/maria/maria-5.2/mysql-test> ../client/mysql test MariaDB [test]> DROP TABLE IF EXISTS t1; MariaDB [test]> CREATE TABLE t1 ( a int(11), b varchar(1)) ; MariaDB [test]> INSERT IGNORE INTO t1 VALUES (0,'g'); MariaDB [test]> MariaDB [test]> CREATE TABLE t3 ( a varchar(1)) ; MariaDB [test]> INSERT IGNORE INTO t3 VALUES ('g'); MariaDB [test]> MariaDB [test]> CREATE TABLE t2 ( a int(11) NOT NULL, PRIMARY KEY (a)) ; MariaDB [test]> create view v1 as SELECT t1.* FROM t1 LEFT JOIN t2 ON ( t1.a = t2.a ) WHERE t2.a <> 0; MariaDB [test]> SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b );
-----
----- MariaDB [test]> EXPLAIN SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b );
---
--- This is a bug of table elimination: MariaDB [test]> set optimizer_switch='table_elimination=off'; MariaDB [test]> EXPLAIN SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b );
---
--- MariaDB [test]> SELECT alias1.* FROM t3 LEFT JOIN v1 as alias1 ON ( t3.a = alias1.b );
-----
----- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Rasmus Johansson (Inactive) [ 2011-12-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Launchpad bug id: 884184 |