Bug #120640 WHERE NULLIF(...) IS NULL returns rows when NULLIF is non-NULL
| Submitted: | 9 Jun 10:13 | Modified: | 9 Jun 10:59 |
|---|---|---|---|
| Reporter: | mu mu | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
| Version: | 9.6.0 | OS: | Ubuntu (22.04) |
| Assigned to: | CPU Architecture: | Any |
[9 Jun 10:59]
Roy Lyseng
Thank you for the bug report. Verified as described.
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.
Description: In MySQL 9.6.0, a WHERE clause using NULLIF(...) IS NULL may return rows even when NULLIF evaluates to a non-NULL value. The same expression in a SELECT evaluates correctly (0 for IS NULL). MariaDB 12.3.0 returns no rows, which is consistent with expected SQL semantics. CREATE TABLE t1(c0 INT); INSERT INTO t1 VALUES (1); -- NULLIF returns -1 (non-NULL) SELECT NULLIF(-1, c0) FROM t1; -- Result: -1 SELECT NULLIF(-1, c0) IS NULL FROM t1; -- Result: 0 -- Expected: no rows SELECT * FROM t1 WHERE NULLIF(-1, c0) IS NULL; -- MySQL 9.6.0: returns 1 row (wrong) -- MariaDB 12.3.0: returns 0 rows (correct) How to repeat: CREATE TABLE t0(c0 INT, c1 VARCHAR(500), PRIMARY KEY(c0)); INSERT INTO t0 VALUES (1, NULL), (2, ''), (3, 'x'); SELECT c0, NULLIF(-1641423514, c1) AS p, (NULLIF(-1641423514, c1) IS NULL) AS p_is_null FROM t0; -- All rows: p = -1641423514, p_is_null = 0 SELECT COUNT(*) FROM t0 WHERE NULLIF(-1641423514, c1) IS NULL; -- MySQL 9.6.0: 3 -- MariaDB 12.3.0: 0