Re: BUG #6064: != NULL, <> NULL do not work - Mailing list pgsql-bugs

From Kevin Grittner
Subject Re: BUG #6064: != NULL, <> NULL do not work
Date
Msg-id 4DFB1C6F020000250003E7D4@gw.wicourts.gov
Whole thread Raw
In response to BUG #6064: != NULL, <> NULL do not work  ("Michael Pilling" <Michael.Pilling@dsto.defence.gov.au>)
Responses Re: BUG #6064: != NULL, <> NULL do not work
List pgsql-bugs
"Michael Pilling" <Michael.Pilling@dsto.defence.gov.au> wrote:

> A reasonable programmer would expect != NULL, <> NULL and IS NOT
> NULL to be synonyms.

Only if that programmer was not aware of the SQL standard and had
not worked much with a standard-conforming database.

NULL is conceptually intended to indicate "unknown" or "not
applicable".  If you have a person table with a date_of_birth
column, which contains NULL for a number of rows for which the date
of birth is unknown, can you say that all such people have the same
date of birth?  No; for any such person, the result of comparing
their date of birth to anyone else's (whether or not the other one
is NULL) is UNKNOWN.

You might want to read up on IS [NOT] DISTINCT FROM.  In the SQL
language, while NULL is not known to be equal to NULL, you *can* say
that NULL IS NOT DISTINCT FROM NULL.

This is most definitely not a bug in the software.  The
documentation does cover it here:

http://www.postgresql.org/docs/9.0/interactive/functions-comparison.html

Is there something you would add to that?

-Kevin

pgsql-bugs by date:

Previous
From: Антон Степаненко
Date:
Subject: Re: could not read block XXXXX in file "base/YYYYY/ZZZZZZ": read only 160 of 8192 bytes
Next
From: Alvaro Herrera
Date:
Subject: Re: BUG #6066: [PATCH] Mark more strings as c-format