Bug #70466 | No results when filesorting with a correlation in subquery's HAVING clause | ||
---|---|---|---|
Submitted: | 30 Sep 2013 7:24 | Modified: | 30 Sep 2013 8:42 |
Reporter: | Alan Egerton | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 5.5,5.6 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | correlated, filesort, having, regression, subquery |
[30 Sep 2013 7:24]
Alan Egerton
[30 Sep 2013 7:44]
Valeriy Kravchuk
Same with 5.5.32, so it does not seem a new problem: mysql> select * from t; +------+ | x | +------+ | 0 | +------+ 1 row in set (0.00 sec) mysql> SELECT a.x -> FROM t a, (SELECT NULL) b -> WHERE EXISTS ( -> SELECT * -> FROM (SELECT NULL) c -> HAVING a.x IS NOT NULL -> ) -> ; +------+ | x | +------+ | 0 | +------+ 1 row in set (0.00 sec) mysql> SELECT a.x -> FROM t a, (SELECT NULL) b -> WHERE EXISTS ( -> SELECT * -> FROM (SELECT NULL) c -> HAVING a.x IS NOT NULL -> ) -> ORDER BY RAND() -> ; Empty set (0.00 sec) mysql> select version(); +-----------+ | version() | +-----------+ | 5.5.32 | +-----------+ 1 row in set (0.00 sec)
[30 Sep 2013 8:42]
MySQL Verification Team
Hello Alan, Thank you for the bug report and test case. Verified as described. Thanks, Umesh
[30 Sep 2013 17:13]
MySQL Verification Team
Yes, definitely a bug, but not a serious nor urgent, due to several reasons. Usage of HAVING instead of WHERE, Cartesian product, usage of column from upper node in the inner node etc ...
[30 Sep 2013 17:54]
MySQL Verification Team
Another testcase: ---- drop table if exists t; create table t (x int)engine=innodb; insert into t values (0); select * from t where exists(select 1 from t having t.x=0) order by rand(); select * from t where exists(select 1 from t having t.x=0); ----
[2 Oct 2013 11:36]
MySQL Verification Team
It seems my testcase affects 4.1, 5.0, 5.1, 5.5, 5.6, 5.7. But original testcase from reporter only affects 5.5+. Not sure if there are two bugs. Let's let developers decide.