Bug #102101 | COUNT(*) returns null in nested query | ||
---|---|---|---|
Submitted: | 31 Dec 2020 13:48 | Modified: | 11 Jan 2021 19:40 |
Reporter: | Eduardo Ubide | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 8.0.22 | OS: | Any |
Assigned to: | CPU Architecture: | x86 | |
Tags: | regression |
[31 Dec 2020 13:48]
Eduardo Ubide
[31 Dec 2020 13:58]
MySQL Verification Team
Hello Eduardo Ubide, Thank you for the report and test case. regards, Umesh
[11 Jan 2021 19:40]
Jon Stephens
Fix documented in the MySQL 8.0.24 changelog, as follows: When the aggregate iterator finds no rows, it calls on each item in its SELECT list to inform them of this (for example, so that COUNT(*) can set itself to zero, or SUM(foo) can set itself to NULL). After internal work done in MySQL 8.0.22, it could also inadvertently call hidden items. In some queries with doubly nested subqueries, one such hidden item could become its own parent subquery (and scalar subqueries in MySQL have special legacy handling of this call, for queries which are not ONLY_FULL_GROUP_BY), causing the entire subquery to return NULL when it should not have done so. This is fixed by making the call only on visible items, as in MySQL 8.0.21 and earlier. Closed.