[MDEV-32073] SELECT behavior has changed between 10.11.4 and 10.11.5 Created: 2023-09-01 Updated: 2023-09-02 Resolved: 2023-09-01 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.5.22 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | Renaud Grand | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
The statement
Results in one row `NULL, NULL, NULL`, in 10.5.22 or 10.11.5 After trying various Docker images for MariaDB I can confirm with certainty that this behavior has been introduced between 10.5.21 and 10.5.22. Also tested last version 10.11.5 and 10.11.4 and same behavior has been introduced between those two versions. Interestingly, same `NULL, NULL, NULL` behavior happens in 10.5.0. So this might be a regression. Feels like `158, NULL, 1` is the non buggy behavior: it's strange that `SELECT p0_.id AS sclr_0` returns `NULL` given the fact the data is given in the WHERE clause. Engine is InnoDB. Version on server indicates 10.5.22-MariaDB-1:10.5.22+maria~deb10-log so Debian, but I could reproduce the issue easily on both MacOS (last public OS on M1 Pro) and Ubuntu 22.04 (On an AMD 5950x) Note: if the `SUM()` is removed such as:
No data is returned on 10.5.22, 10.5.21, 10.5.12, 10.11.4, 10.11.5 So the problem arises when results are aggregated I guess? |
| Comments |
| Comment by Sergei Golubchik [ 2023-09-01 ] |
|
The new result is correct. There are no rows after the WHERE clause, so the result of the non-aggregated query is an empty set, no rows.
so the new result is correct. The old incorrect result was due to a bug |
| Comment by Renaud Grand [ 2023-09-01 ] |
|
Hi! The result of the non-aggregated query has seemingly always been an empty set. The problem arises when the query is aggregated, where we have either:
Which I feel you responded that the new behavior is correct by describing the standard but I want to make sure I've understood well? |
| Comment by Sergei Golubchik [ 2023-09-01 ] |
|
Yes. Empty set was also before the fix. The bug was that in the presence of aggregate functions some columns were showing values that were not part of the result set (which was empty). This was fixed as |
| Comment by Renaud Grand [ 2023-09-02 ] |
|
Instead of returning a row with NULL, NULL, NULL, wouldn't have it made more sense to return no data? |
| Comment by Sergei Golubchik [ 2023-09-02 ] |
|
SQL Standard (quoted above) says that SUM() of the empty set is NULL. |