Re: BUG #2109: NULL=NULL is false

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: BUG #2109: NULL=NULL is false
Дата
Msg-id 20051214013502.GA28021@winnie.fuhr.org
обсуждение исходный текст
Ответ на BUG #2109: NULL=NULL is false  ("Michał Szeląg" <msz@szel.pl>)
Список pgsql-bugs
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/interactive/functions-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_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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Michał Szeląg"
Дата:
Сообщение: BUG #2109: NULL=NULL is false
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #2111: Error parsing 'infinity' under some versions of glibc