Bug #121001 Incorrect evaluation of NOT (A AND NOT A AND (A IS NOT NULL)) drops NULL rows due to invalid ternary logic simplificatio
Submitted: 23 Jul 16:12
Reporter: Xiaoyuan Xie Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S2 (Serious)
Version:9.6.0,9.7.0 OS:Ubuntu
Assigned to: CPU Architecture:Any

[23 Jul 16:12] Xiaoyuan Xie
Description:
A query result divergence occurs when evaluating an equivalent expression containing three-valued logic and IS NOT NULL checks on a DOUBLE column containing NULL.

How to repeat:
DROP TABLE IF EXISTS t;
CREATE TABLE t(c DOUBLE);

INSERT INTO t VALUES
    (0),
    (NULL);

-- Baseline Query (Returns 2 rows: 0, NULL)
SELECT * FROM t;

-- EET Equivalent Query (Incorrectly returns only 1 row: 0)
SELECT *
FROM t
WHERE NOT (
    (
        (
            (c <=> NULLIF(-1, c))
            OR
            (c <= c)
        )
        AND NOT (
            (c <=> NULLIF(-1, c))
            OR
            (c <= c)
        )
        AND (
            (
                (c <=> NULLIF(-1, c))
                OR
                (c <= c)
            ) IS NOT NULL
        )
    )
);
Expected Result:

The EET transformed query should return exactly 2 rows (0 and NULL), matching the baseline table count.

Actual Result:

The query returns only 1 row (0), incorrectly omitting the NULL row.