[MDEV-3618] LP:823237 - Wrong result + view + outer join + correlated subquery Created: 2011-08-09 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: | Major |
| Reporter: | Philip Stoev (Inactive) | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
This query: SELECT * FROM t3 , v4 returns no rows when v4 is a view, but returns rows when v4 is a base table. PostgreSQL reports that the correct result is to return rows. Test case: CREATE TABLE t1 ( a int ) ; CREATE TABLE t2 ( b int, d int, e int); CREATE TABLE t3 ( c int) ; CREATE TABLE t4 ( a int , b int, c int) ; CREATE VIEW v4 AS SELECT * FROM t4; SELECT * FROM t3 , v4 explain in 5.3 with a view: MariaDB [test]> explain SELECT * FROM t3 , v4 WHERE v4.c <= ( SELECT t2.e FROM t2 LEFT JOIN t1 ON ( t1.a = t2.d ) WHERE t2.b > v4.b );
---
--- explain in 5.3 with a table: ---
---
--- Repeatable in maria-5.3, maria-5.2, mysql-5.5. |
| Comments |
| Comment by Igor Babaev [ 2012-10-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Wrong result + view + outer join + correlated subquery This is exactly what happened for the query from the test case for bug #823237. Before the fix for bug #823189 EXPLAIN extended for the query returned: MariaDB [test]> EXPLAIN EXTENDED SELECT * FROM t3 , v4 WHERE v4.c <= ( SELECT t2.e FROM t2 LEFT JOIN t1 ON ( t1.a = t2.d ) WHERE t2.b > v4.b );
---
--- MariaDB [test]> show warnings;
------
------ We see that outer join in the subquery was converted into an inner join. This was incorrect. After the fix EXPLAIN EXTENDED returned: MariaDB [test]> EXPLAIN EXTENDED SELECT * FROM t3 , v4 WHERE v4.c <= ( SELECT t2.e FROM t2 LEFT JOIN t1 ON ( t1.a = t2.d ) WHERE t2.b > v4.b );
---
--- MariaDB [test]> show warnings;
------
------ The test case from this report will be added in to the regression test suite in mariadb-5.3.10. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Rasmus Johansson (Inactive) [ 2012-10-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Launchpad bug id: 823237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2012-10-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Re: Wrong result + view + outer join + correlated subquery |