Bug #5595 NULLIF() IS NULL returns false if NULLIF() returns NULL

Submitted: 15 Sep 2004 15:30 Modified: 18 Sep 2004 7:58
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.0.20, 5.0.1 OS:Windows (Win XP, Win 2000/Linux)
Assigned to: Sergei Glukhov CPU Architecture:Any

[15 Sep 2004 15:30] [ name withheld ]
Description:
If NULLIF() returns NULL the expression NULLIF() IS NULL returns false and the expression NULLIF() IS NOT NULL returns true.

Consider the following examples:

mysql> SELECT NULLIF(5,5), NULLIF(5,5) IS NULL, NULL IS NULL;
+-------------+---------------------+--------------+
| NULLIF(5,5) | NULLIF(5,5) IS NULL | NULL IS NULL |
+-------------+---------------------+--------------+
|        NULL |                   0 |            1 |
+-------------+---------------------+--------------+

mysql> SELECT NULLIF(5,5), NULLIF(5,5) IS NOT NULL, NULL IS NOT NULL;
+-------------+-------------------------+------------------+
| NULLIF(5,5) | NULLIF(5,5) IS NOT NULL | NULL IS NOT NULL |
+-------------+-------------------------+------------------+
|        NULL |                       1 |                0 |
+-------------+-------------------------+------------------+

How to repeat:
Enter the following query in the MySQL client:

SELECT NULLIF(5,5), NULLIF(5,5) IS NULL, NULL IS NULL;

Suggested fix:
Use the following workaround until the bug is fixed: IFNULL(NULLIF(),NULL).
[16 Sep 2004 17:16] MySQL Verification Team
Verified against latest 4.0 BK source.
[17 Sep 2004 12:15] Sergei Glukhov
ChangeSet
  1.2022 04/09/17
  Fix for bug #5595:NULLIF() IS NULL returns false if NULLIF() returns NULL

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

Page generated in 0.051 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.