Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 11.8.6
Description
The derived table `SELECT 'x' AS c2 FROM t3` is empty because `t3` is empty, and `LEFT JOIN ... ON (0=1)` guarantees that the only output row sees `subq0.c2 = NULL`. Therefore `COUNT(subq0.c2) OVER ()` must be `0`. MariaDB instead counts that NULL-extended constant as if it were non-NULL and returns `1`.
How to repeat:
CREATE TABLE t0(c0 INT);
CREATE TABLE t3(c0 INT);
INSERT INTO t0 VALUES (0);
SELECT COUNT(subq0.c2) OVER ()
FROM t0
LEFT JOIN (SELECT 'x' AS c2 FROM t3) AS subq0
ON (0=1); – Expected correct result: 0 – actual Wrong result: 1
Attachments
Issue Links
- is duplicated by
-
MDEV-39864 Window SUM over an empty left-joined derived table returns 0 instead of NULL
-
- Closed
-
- relates to
-
MDEV-39865 A grouped NULL-extended RIGHT JOIN row survives a false HAVING predicate
-
- Confirmed
-
-
MDEV-39866 MIN over an empty Aria-backed derived table leaks the inner COALESCE fallback value'
-
- Confirmed
-
-
MDEV-39867 Qualifying rows disappear when a constant derived-table column drives both filtering and window MIN
-
- Confirmed
-