dbTalk Databases Forums  

Re: [BUGS] BUG #2109: NULL=NULL is false

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] BUG #2109: NULL=NULL is false in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: [BUGS] BUG #2109: NULL=NULL is false - 12-13-2005 , 07:35 PM






On Mon, Dec 12, 2005 at 01:38:37PM +0000, Micha Szelg wrote:
Quote:
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/i...omparison.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_equals
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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.