Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Not a Bug
-
10.5.22
-
None
Description
The statement
SELECT p0_.id AS sclr_0, SUM(p1_.quantity) AS sclr_1, p0_.minimum_guaranteed_quantity AS sclr_2 FROM order_product o2_ |
LEFT JOIN placed_order p3_ ON o2_.placed_order_id = p3_.id |
LEFT JOIN product_edit p1_ ON o2_.placed_product_edit_id = p1_.id |
LEFT JOIN product p0_ ON o2_.product_id = p0_.id WHERE p3_.preparation_date = '2023-09-02 00:00:00' AND p0_.id = 158 |
Results in one row `NULL, NULL, NULL`, in 10.5.22 or 10.11.5
Results in one row `158, NULL, 1` in 10.5.12, 10.5.21, 10.11.4
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:
SELECT p0_.id AS sclr_0, p0_.minimum_guaranteed_quantity AS sclr_2 FROM order_product o2_ |
LEFT JOIN placed_order p3_ ON o2_.placed_order_id = p3_.id |
LEFT JOIN product p0_ ON o2_.product_id = p0_.id WHERE p3_.preparation_date = '2023-09-02 00:00:00' AND p0_.id = 158 |
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?
Attachments
Issue Links
- is caused by
-
MDEV-6768 Wrong result with aggregate with join with no result set
- Closed