Skip to content

Unexpected results when using LEFT JOIN and UNION #1250

Description

@suyZhong

Consider the test case below. It is unexpected that the third query return 1 'a', as the first query return 1 NULL, and the second query also return 1 NULL.

DROP TABLE t0;
DROP TABLE t1;

CREATE TABLE t0(c0 INT);
CREATE TABLE t1(c0 VARCHAR(500));
INSERT INTO t0 (c0) VALUES (1);
INSERT INTO t1 (c0) VALUES ('a');

SELECT * FROM t0 LEFT  JOIN t1 ON (NULL IN ('')); -- 1 NULL
SELECT * FROM t0 LEFT  JOIN t1 ON (NULL IN ('')) WHERE 1; -- 1 NULL
SELECT * FROM t0 LEFT  JOIN t1 ON (NULL IN ('')) WHERE 1 UNION ALL SELECT * FROM t0 LEFT  JOIN t1 ON (NULL IN ('')) WHERE (NOT 1);
-- Expected: 1 NULL
-- Actual: 1 'a'

Here's the version: Version 7.2.13-dev.3239-pthreads as of Mar 13 2024 (bb53b41)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions