Bug #6106 | Views: SELECT of 2 views with RIGHT JOIN returns wrong result | ||
---|---|---|---|
Submitted: | 14 Oct 2004 20:16 | Modified: | 21 Apr 2005 1:12 |
Reporter: | Trudy Pelzer | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 5.0.2-alpha-debug | OS: | Any (*) |
Assigned to: | Igor Babaev | CPU Architecture: | Any |
[14 Oct 2004 20:16]
Trudy Pelzer
[13 Apr 2005 23:13]
Igor Babaev
The problem can be demonstrated with a simpler query: mysql> SELECT a.col1,a.col2,b.col2,b.col3 -> FROM vt1 a LEFT JOIN t2 b ON a.col1=b.col1 -> WHERE b.col2 IS NULL OR -> b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1); +------+---------+------+------+ | col1 | col2 | col2 | col3 | +------+---------+------+------+ | 1 | trudy | NULL | NULL | | 2 | peter | NULL | NULL | | 3 | sanja | NULL | NULL | | 4 | monty | NULL | NULL | | 5 | david | NULL | NULL | | 6 | kent | NULL | NULL | | 7 | carsten | NULL | NULL | | 8 | ranger | NULL | NULL | | 10 | matt | NULL | NULL | +------+---------+------+------+ The result must be the same as for the following equivalent query that does not use views: mysql> SELECT a.col1,a.col2,b.col2,b.col3 -> FROM t1 a LEFT JOIN t2 b ON a.col1=b.col1 -> WHERE b.col2 IS NULL OR -> b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1); +------+---------+------+------+ | col1 | col2 | col2 | col3 | +------+---------+------+------+ | 1 | trudy | 2 | y | | 2 | peter | 1 | n | | 3 | sanja | 1 | n | | 4 | monty | 3 | n | | 5 | david | NULL | NULL | | 6 | kent | 1 | n | | 7 | carsten | NULL | NULL | | 8 | ranger | 1 | y | | 10 | matt | NULL | NULL | +------+---------+------+------+
[14 Apr 2005 6:18]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/24001
[16 Apr 2005 7:33]
Igor Babaev
The fix will appear in version 5.0.5. ChangeSet 1.1826 05/04/13 23:06:37 igor@rurik.mysql.com +6 -0 information_schema.result, information_schema.test: Added a test in connection with the fix for bug #6106. view.result, view.test: Added test cases for bugs #6106/6107. sql_show.cc: The addition of the case for items of the type REF_ITEM in the function uses_only_table_name_fields became necessary after the fix for bug #6106. sql_base.cc: The problem was due to the fact that two different column references were glued together though one of them belonged to a subquery while another to an outer query. This caused eventually a wrong calculation of values for the used_tables attribute.
[21 Apr 2005 1:12]
Paul DuBois
Noted in 5.0.5 changelog.