Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.11, 11.4, 11.8, 12.3, 11.8.6
Description
The derived side contributes exactly one value `10`, because `t2` has one row and both predicates `t2.c0 > 0` and `t2.c0 != 5` are true. With the only surviving outer row `t3.c0 = 20`, both join predicates `t3.c0 != subq0.subq0_c0` and `t3.c0 >= subq0.subq0_c0` are true, so the query must return the single row `1 | 1 | 10 | 20`. MariaDB does return that row if the temp table preserves `t2`'s primary-key metadata, but returns an empty result when the same value `10` is read from a keyless temp table.
How to repeat:
CREATE TABLE t2(c0 INT PRIMARY KEY);
CREATE TABLE t3(c0 INT UNIQUE NOT NULL);
INSERT INTO t2 VALUES (10);
INSERT INTO t3 VALUES (20),(-1);
CREATE TEMPORARY TABLE predicate_temp_0 (t2_c0 INT NOT NULL);
INSERT INTO predicate_temp_0 SELECT t2.c0 FROM t2 WHERE (t2.c0 > 0);
SELECT DISTINCT COUNT(1) OVER (), COUNT(subq0.subq0_c0) OVER (), subq0.subq0_c0, t3.c0
FROM t3
INNER JOIN t2 ON (t3.c0 > t2.c0)
LEFT JOIN
(SELECT predicate_temp_0.t2_c0 AS subq0_c0 FROM predicate_temp_0 WHERE (predicate_temp_0.t2_c0 != 5)) AS subq0
ON (t3.c0 != subq0.subq0_c0)
WHERE (t3.c0 >= subq0.subq0_c0); – Expected correct result: 1 | 1 | 10 | 20 – actual Wrong result: <empty>
Attachments
Issue Links
- relates to
-
MDEV-39787 A self-join over an OR-filtered derived table computes MAX() OVER(PARTITION BY ...) as 2,3,3 instead of 3,3,3
-
- Confirmed
-