Bug #72840 | Wrong result (extra rows) with subquery in HAVING clause | ||
---|---|---|---|
Submitted: | 2 Jun 2014 19:33 | Modified: | 9 Oct 2019 7:58 |
Reporter: | Elena Stepanova | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.1, 5.5 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[2 Jun 2014 19:33]
Elena Stepanova
[3 Jun 2014 8:00]
MySQL Verification Team
Hello Elena, Thank you for the bug report and test case. Verified as described. Thanks, Umesh Shastry
[3 Jun 2014 8:01]
MySQL Verification Team
// 5.7.5 - Not affected mysql> use test Database changed mysql> CREATE TABLE t1 (a INT); Query OK, 0 rows affected (0.02 sec) mysql> INSERT INTO t1 VALUES (8),(3); Query OK, 2 rows affected (0.01 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> SELECT a FROM t1 GROUP BY a HAVING a IN ( SELECT 3 ); +------+ | a | +------+ | 3 | +------+ 1 row in set (0.01 sec) // 5.6.20 - Not affected mysql> select version(); +-------------------------------------------------+ | version() | +-------------------------------------------------+ | 5.6.20-enterprise-commercial-advanced-debug-log | +-------------------------------------------------+ 1 row in set (0.00 sec) mysql> CREATE TABLE t1 (a INT); Query OK, 0 rows affected (0.04 sec) mysql> INSERT INTO t1 VALUES (8),(3); Query OK, 2 rows affected (0.01 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> SELECT a FROM t1 GROUP BY a HAVING a IN ( SELECT 3 ); +------+ | a | +------+ | 3 | +------+ 1 row in set (0.00 sec) // 5.5.38 - affected mysql> select version(); +------------------+ | version() | +------------------+ | 5.5.38-debug-log | +------------------+ 1 row in set (0.00 sec) mysql> CREATE TABLE t1 (a INT); Query OK, 0 rows affected (0.01 sec) mysql> INSERT INTO t1 VALUES (8),(3); Query OK, 2 rows affected (0.01 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> SELECT a FROM t1 GROUP BY a HAVING a IN ( SELECT 3 ); +------+ | a | +------+ | 3 | | 8 | +------+ 2 rows in set (0.00 sec)
[9 Oct 2019 7:58]
Knut Anders Hatlen
This is the same problem as bug#71244, which was fixed in MySQL 5.6.17. Closing.