Bug #111415 | Correlated group query wrong result | ||
---|---|---|---|
Submitted: | 14 Jun 2023 9:39 | Modified: | 19 Jun 2023 11:31 |
Reporter: | Pedro Ferreira | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | count, GROUP BY, order by |
[14 Jun 2023 9:39]
Pedro Ferreira
[14 Jun 2023 9:39]
Pedro Ferreira
Added tags
[14 Jun 2023 13:12]
MySQL Verification Team
Hi Mr. Ferreira, Thank you for your bug report. However, this is not a bug. The query returns the correct result, since the inner query: SELECT (SELECT NULL GROUP BY t0.c0 ORDER BY COUNT(t0.c0)) IS NULL FROM t0; returns 1. This is correct since, the internal query returns only one result , which is true, id est 1; Simply, SELECT NULL IS NULL , returns 1; Not a bug.
[15 Jun 2023 1:49]
Pedro Ferreira
If I remove `ORDER BY COUNT(t0.c0)` which is cosmetic here, I get the right result: 2. I still believe the query result is wrong.
[15 Jun 2023 12:43]
MySQL Verification Team
Hi, This is still not a bug. If you have ORDER BY a column or expression that is not present in the SELECT list, then it is automatically added there. Hence, this makes a totally different query and totally different result.
[19 Jun 2023 11:31]
MySQL Verification Team
HI Mr. Ferreira, This turns out to be a low severity bug , but still a bug. Removing ORDER BY from a query should not affect the number of rows output from it, so this is certainly a bug. Verified.