pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mike Porter <mike@udel.edu>
To: Andres Freund <andres@2ndquadrant.com>
Cc: Kevin Perais <kevin.perais@trivia-marketing.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #12556: Clause IN and NOT IN buggy
Date: Fri, 16 Jan 2015 11:55:01 -0500 (EST)
Message-ID: <alpine.OSX.2.00.1501161149340.64154@enva> (raw)
In-Reply-To: <20150116155531.GF21581@alap3.anarazel.de>
References: <20150115112720.2502.55131@wrigleys.postgresql.org>
	<6445.1421341526@sss.pgh.pa.us>
	<46C6B6B27EF7AA489BBDF478BF05B5D2BD886818@server.exchange.local>
	<20150116155531.GF21581@alap3.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On Fri, 16 Jan 2015, Andres Freund wrote:

> On 2015-01-16 09:17:43 +0000, Kevin Perais wrote:
>> There is enough info to understand what goes wrong. I've run enough queries to inspect data.
>
> *You* want something. The likelihood of getting something fixed is far
> larger if you present an example that we can actually run. We obviously
> haven't seen the problem ourselves so far, so a testcase is crucial.
>
> We don't even have the actual table definitions, so we really can't say
> much. We really need a SQL script that allows us to reproduce these
> cases.
>
>> The fact that the query with IN does not returns the same result as
>> the JOIN knowing that there are NULL values proves it.
>
> I guess you mean 'no NULL values'? The second problem is perfectly
> explained by Tom's remark about NOT IN(...) returning NULL if *any* of
> the contained values are NULL. E.g. SELECT 1 WHERE 1 NOT IN (1, NULL);
> won't return any rows.

To the original poster:

Perhaps this example makes the correct behavior of postgres more
obvious:

net=# SELECT 1 WHERE 1 NOT IN (2);
  ?column?
----------
         1
(1 row)

net=# SELECT 1 WHERE 1 NOT IN (2, NULL);
  ?column?
----------
(0 rows)

(We can't say 1 is NOT IN (2, NULL) because the NULL value could be a
1.  We don't know what a NULL value is.  That's what NULL means.

Mike

>
> Greetings,
>
> Andres Freund
>
> -- 
> Andres Freund	                   http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>
>
> -- 
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

-
Mike Porter
PGP Fingerprint: F4 AE E1 9F 67 F7 DA EA  2F D2 37 F3 99 ED D1 C2


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (6+ messages)

Message-ID: <alpine.OSX.2.00.1501161149340.64154@enva>
Permalink:  ../alpine.OSX.2.00.1501161149340.64154@enva/
Also on:    postgresql.org/message-id/alpine.OSX.2.00.1501161149340.64154@enva

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: mike@udel.edu, andres@2ndquadrant.com, kevin.perais@trivia-marketing.com, tgl@sss.pgh.pa.us
  Subject: Re: BUG #12556: Clause IN and NOT IN buggy
  In-Reply-To: <alpine.OSX.2.00.1501161149340.64154@enva>
  References: <20150115112720.2502.55131@wrigleys.postgresql.org> <6445.1421341526@sss.pgh.pa.us> <46C6B6B27EF7AA489BBDF478BF05B5D2BD886818@server.exchange.local> <20150116155531.GF21581@alap3.anarazel.de> <alpine.OSX.2.00.1501161149340.64154@enva>

* 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