Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
11.8.8
-
None
-
Not for Release Notes
Description
the derived table `SELECT FALSE AS c0, t2.c0 AS c1 FROM t0, t2` is empty because `t0` is empty, so the outer `LEFT JOIN` produces exactly one NULL-extended row. On that row `s.c0` is NULL, therefore `SUM(s.c0) OVER (PARTITION BY t2.c0)` must also be NULL. MariaDB instead leaks the missing inner constant `FALSE/0` into the window aggregate and returns `0 | NULL`.
CREATE TABLE t0(x INT);
CREATE TABLE t2(c0 BOOLEAN);
INSERT INTO t2 VALUES (FALSE);
SELECT SUM(s.c0) OVER (PARTITION BY t2.c0), s.c0
FROM t2
LEFT JOIN (SELECT FALSE AS c0, t2.c0 AS c1 FROM t0, t2) AS s
ON (t2.c0 = s.c1)
WHERE s.c1 IS NULL; – Expected correct result: NULL | NULL – actual Wrong result: 0 | NULL
Attachments
Issue Links
- duplicates
-
MDEV-39730 COUNT(expr) OVER() counts a NULL-extended constant from an empty derived table
-
- Confirmed
-