Home > Archive > PostgreSQL Bugs > December 2005 > BUG #2109: NULL=NULL is false









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author BUG #2109: NULL=NULL is false
MichaÅ SzelÄg

2005-12-13, 8:25 pm


The following bug has been logged online:

Bug reference: 2109
Logged by: Michał Szeląg
Email address: msz@szel.pl
PostgreSQL version: 7.4
Operating system: Linux / debian sarge
Description: NULL=NULL is false
Details:

select case when NULL=NULL then true else false end as column;

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Michael Fuhr

2005-12-13, 8:25 pm

On Mon, Dec 12, 2005 at 01:38:37PM +0000, Micha Szelg wrote:
> Description: NULL=NULL is false


No, the result is NULL, not false. See "Comparison Operators" in
the documentation:

http://www.postgresql.org/docs/7.4/...comparison.html

"Do not write expression = NULL because NULL is not 'equal to' NULL.
(The null value represents an unknown value, and it is not known
whether two unknown values are equal.)"

You could change the behavior with the transform_null_equal
s
configuration setting, but as the documentation says, "this option
is not a general fix for bad programming." It would be better to
use standard-conforming expressions such as IS DISTINCT FROM (standard
since SQL:1999, as I recall).

test=> SELECT NULL = NULL;
?column?
----------

(1 row)

test=> SELECT NULL IS DISTINCT FROM NULL;
?column?
----------
f
(1 row)

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com