Re: "large" IN/NOT IN subqueries result in query returning wrong data

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: elein <elein(at)varlena(dot)com>
Cc: George Pavlov <gpavlov(at)mynewplace(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: "large" IN/NOT IN subqueries result in query returning wrong data
Date: 2005-12-28 00:25:40
Message-ID: 9416.1135729540@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

elein <elein(at)varlena(dot)com> writes:
> In 8.0 we get:

> elein=# select 1 in (NULL, 1, 2);
> ?column?
> ----------
> t
> (1 row)

> elein=# select 3 not in (NULL, 1, 2);
> ?column?
> ----------

> (1 row)

> For consistency, either both should return NULL or
> both return true/false.

The above behavior is correct per spec. Feel free to argue its
consistency with the SQL committee ;-)

Note that the above are not inverses because you changed the lefthand
input. You do get consistent results when you just add or omit NOT:

regression=# select 1 not in (NULL, 1, 2);
?column?
----------
f
(1 row)

regression=# select 3 in (NULL, 1, 2);
?column?
----------

(1 row)

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message elein 2005-12-28 00:35:03 Re: "large" IN/NOT IN subqueries result in query returning wrong data
Previous Message elein 2005-12-28 00:12:51 Re: "large" IN/NOT IN subqueries result in query returning wrong data