Bug #4480 Queries with STRAIGHT_JOIN ... RIGHT JOIN produce wrong results
Submitted: 9 Jul 2004 8:34 Modified: 20 Dec 2004 23:22
Reporter: Sergey Petrunya Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0-bk OS:
Assigned to: Sergey Petrunya CPU Architecture:Any

[9 Jul 2004 8:34] Sergey Petrunya
Description:
Queries with STRAIGHT_JOIN and RIGHT JOIN produce wrong query results.

How to repeat:
create table t1 (a int, b int);
insert into t1 values (1,1),(2,2),(3,3);
create table t2 (a int, b int);
insert into t2 values (1,1), (2,2);

mysql> select * from t2 right join t1 on t2.a=t1.a;
+------+------+------+------+
| a    | b    | a    | b    |
+------+------+------+------+
|    1 |    1 |    1 |    1 |
|    2 |    2 |    2 |    2 |
| NULL | NULL |    3 |    3 |
+------+------+------+------+
3 rows in set (0.00 sec)

mysql> select straight_join * from t2 right join t1 on t2.a=t1.a;
+------+------+------+------+
| a    | b    | a    | b    |
+------+------+------+------+
|    1 |    1 |    1 |    1 |
|    2 |    2 |    1 |    1 |
|    1 |    1 |    2 |    2 |
|    2 |    2 |    2 |    2 |
|    1 |    1 |    3 |    3 |
|    2 |    2 |    3 |    3 |
+------+------+------+------+
6 rows in set (0.01 sec)
[13 Jul 2004 10:24] Hartmut Holzgraefe
5.0.0-alpha was ok, bk of July 12th is still broken
[21 Nov 2004 8:48] Sergey Petrunya
ChangeSet@1.1646, 2004-11-21 11:36:06+03:00, sergefp@mysql.com
[20 Dec 2004 23:22] Sergey Petrunya
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html