From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Havasvölgyi Ottó <h.otto@freemail.hu>
Cc: pgsql-sql@postgresql.org
Subject: Re: NULL in IN clause
Date: Wed, 19 Oct 2005 14:00:03 -0700 (PDT)
Message-ID: <20051019135459.D99528@megazone.bigpanda.com> (raw)
In-Reply-To: <001a01c5d4ea$243a1830$6400a8c0@OTTO>
References: <00cc01c5d00b$3a67dc70$1102a8c0@dream>
<1129681803.15546.21.camel@state.g2switchworks.com>
<001a01c5d4ea$243a1830$6400a8c0@OTTO>
On Wed, 19 Oct 2005, [iso-8859-2] Havasvölgyi Ottó wrote:
> Hi,
>
> I have just run this command on 8.0.4 :
>
> SELECT 'foo' WHERE 0 NOT IN (NULL, 1);
>
> And it resulted is zero rows.
> Without NULL it is OK.
> Is this a bug, or the standard has such a rule?
This is standard behavior.
Seeing if I can do this from memory...
a NOT IN b is equivalent in the spec to NOT(a IN b). a IN b is equivalent
to a =ANY b. a =ANY b returns true if a = x is true for any x in b. a =ANY
b returns false if a = x is false for all x in b. Otherwise it returns
unknown.
0 = NULL returns unknown
0 = 1 returns false
So, 0 IN (NULL,1) returns unknown.
NOT(unknown) is unknown.
WHERE clauses only return rows for which the search condition is true, so
a row is not returned.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone.bigpanda.com, h.otto@freemail.hu
Subject: Re: NULL in IN clause
In-Reply-To: <20051019135459.D99528@megazone.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox