| Bug #51492 | STRAIGHT_JOIN in combination with 'RIGHT OUTER JOIN' produce incorrect result. | ||
|---|---|---|---|
| Submitted: | 25 Feb 2010 8:59 | Modified: | 25 Feb 2010 11:47 |
| Reporter: | Ole John Aske | Email Updates: | |
| Status: | Duplicate | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S1 (Critical) |
| Version: | 5.1.41, 5.1.45 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[25 Feb 2010 8:59]
Ole John Aske
[25 Feb 2010 11:47]
Valeriy Kravchuk
The same wrong results are produced by current 5.1.45:
openxs@suse:/home2/openxs/dbs/5.1> bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.45-debug Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> drop table t;
\Query OK, 0 rows affected (0.22 sec)
mysql> create table t (pk int primary key, i32 int);
Query OK, 0 rows affected (0.02 sec)
mysql> insert into t values (1,9), (2,9), (3,9);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> SELECT STRAIGHT_JOIN *
-> FROM t as t1
-> RIGHT OUTER JOIN (t as t2 JOIN t as t3 ON t2.pk = t3.pk)
-> ON t1.i32 = t3.pk
-> WHERE t2.pk > 2;
+------+------+----+------+----+------+
| pk | i32 | pk | i32 | pk | i32 |
+------+------+----+------+----+------+
| 1 | 9 | 3 | 9 | 3 | 9 |
| 2 | 9 | 3 | 9 | 3 | 9 |
| 3 | 9 | 3 | 9 | 3 | 9 |
+------+------+----+------+----+------+
3 rows in set (0.00 sec)
mysql> SELECT * FROM t as t1 RIGHT OUTER JOIN (t as t2 JOIN t as t3 ON t2.pk = t3.pk) ON t1.i32 = t3.pk WHERE t2.pk > 2;
+------+------+----+------+----+------+
| pk | i32 | pk | i32 | pk | i32 |
+------+------+----+------+----+------+
| NULL | NULL | 3 | 9 | 3 | 9 |
+------+------+----+------+----+------+
1 row in set (0.00 sec)
and indeed, this looks like a duplicate of bug #46091.
