Bug #119110 Incorrect NULL filtering in CTE with UNION ALL over view containing LEFT JOIN on FALSE

Submitted: 7 Oct 2025 5:19 Modified: 2 Apr 9:45
Reporter: Runyuan He Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S2 (Serious)
Version:9.4.0 OS:Linux
Assigned to: CPU Architecture:x86

[7 Oct 2025 5:19] Runyuan He
Description:
A query combining a CTE (Common Table Expression) with UNION ALL produces an incorrect empty result set when filtering for NULL values. The expected result should return one row with NULL.

How to repeat:
CREATE  TABLE  t0(c BOOLEAN);
CREATE  TABLE  t1(c BOOLEAN);
INSERT INTO t0 VALUES (TRUE);
INSERT INTO t1 VALUES (TRUE);

CREATE VIEW v AS SELECT
    (NULL AND t1.c) AS c
FROM t0 LEFT JOIN t1 ON FALSE;

WITH s AS (
  SELECT c FROM v
  UNION ALL
  SELECT c FROM v WHERE FALSE
)
SELECT c
FROM s
WHERE c IS NULL;
-- Empty set, should be NULL
[15 Dec 2025 11:22] Øystein Grøvlen
Thank you for your report.  Verified as described.

Workaround: 
set optimizer_switch='derived_condition_pushdown=off';
[2 Apr 9:45] Chaithra Marsur Gopala Reddy
This is identified as duplicate of https://bugs.mysql.com/bug.php?id=119780

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.