pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: elein <elein@varlena.com>
Cc: George Pavlov <gpavlov@mynewplace.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: "large" IN/NOT IN subqueries result in query returning wrong data
Date: Tue, 27 Dec 2005 19:25:40 -0500
Message-ID: <9416.1135729540@sss.pgh.pa.us> (raw)
In-Reply-To: <20051228001251.GB20674@varlena.com>
References: <CCB89282FCE1024EA3DCE687A96A5164039EBD13@ehost010-6.exch010.intermedia.net>
	<3697.1135712691@sss.pgh.pa.us>
	<20051228001251.GB20674@varlena.com>

elein <elein@varlena.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



view thread (8+ messages)  latest in thread

Message-ID: <9416.1135729540@sss.pgh.pa.us>
Permalink:  ../9416.1135729540@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9416.1135729540@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, elein@varlena.com, gpavlov@mynewplace.com
  Subject: Re: "large" IN/NOT IN subqueries result in query returning wrong data
  In-Reply-To: <9416.1135729540@sss.pgh.pa.us>

* 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