You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpected result when using multiple RIGHT JOIN #17089
Consider the following test case. The second query returns an unexpected result: The first query returns 1 row, and the second query with the filter which will be evaluated to NULL should return an empty set. However, one row is fetched.
PostgreSQL returns an empty result. Besides, the third query also returns one row; the expression t0.c1 != t0.c1 and (t0.c1 != t0.c1) IS NULL should not be evaluated to TRUE at the same time.
Not sure if there's any misunderstanding and if it's related to #16951
Steps to Reproduce
DROPTABLE IF EXISTS t0;
DROPTABLE IF EXISTS t1;
CREATETABLEt0(c0 BOOLEAN , c1 INT );
CREATETABLEt1(c0 BOOLEAN);
INSERT INTO t0(c0, c1) VALUES (false, NULL);
REFRESH TABLE t0;
REFRESH TABLE t1;
SELECTt0.c0FROM t1 RIGHT JOIN (SELECTt0.c0AS col0 FROM t0) AS sub0 ON true, t0 RIGHT JOIN (SELECT true) AS sub1 ONt0.c0; -- NULLSELECTt0.c0FROM t1 RIGHT JOIN (SELECTt0.c0AS col0 FROM t0) AS sub0 ON true, t0 RIGHT JOIN (SELECT true) AS sub1 ONt0.c0WHEREt0.c1!=t0.c1;
-- Expected: empty result set-- Actual: NULL-- PostgreSQL: empty result setSELECTt0.c0FROM t1 RIGHT JOIN (SELECTt0.c0AS col0 FROM t0) AS sub0 ON true, t0 RIGHT JOIN (SELECT true) AS sub1 ONt0.c0WHERE ((t0.c1!=t0.c1) IS NULL); -- NULL
I've tried also to see if there can be an easy fix for this, but it seems we indeed need a bigger refactoring to be able to assign priorities to explicit joins and to outer joins before any implicit ones. Since there is already a PR out towards this direction, I'm re-assigning the issue to @mkleen who has been working on this.
Activity
matriv commentedon Jan 24, 2025
I've tried also to see if there can be an easy fix for this, but it seems we indeed need a bigger refactoring to be able to assign priorities to explicit joins and to outer joins before any implicit ones. Since there is already a PR out towards this direction, I'm re-assigning the issue to @mkleen who has been working on this.
mkleen commentedon Feb 6, 2025
Fixed by #17100