Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YCAB0-0004W6-RF for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Jan 2015 16:55:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YCAB0-0000ax-Bq for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Jan 2015 16:55:14 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YCAAz-0000ZP-9b for pgsql-bugs@postgresql.org; Fri, 16 Jan 2015 16:55:13 +0000 Received: from mail-qc0-f177.google.com ([209.85.216.177]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YCAAr-0001BG-5O for pgsql-bugs@postgresql.org; Fri, 16 Jan 2015 16:55:10 +0000 Received: by mail-qc0-f177.google.com with SMTP id x3so17874387qcv.8 for ; Fri, 16 Jan 2015 08:55:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; bh=/pXTr4seAjo9VrNkygyujUUHKRbcrpzYZivlyUvqMdU=; b=ZlneGANB4bkD/qAPPid6qFBPJxIXj05LcMkl0CNegRxspqEuk8/FHe2qFdTFY/rmYH HBHCWN1gj7NCDUAe2L6LP7z+gaKVIhu2PGDXXjuGk30ppCPtqosTdI86Hgl4n1iPJPEM SuYF53z1QStGM5dlMk2FwjW6rGh6nrLCpgQC0ukuRmyULRQ+/JxQu0S2h+o3uZA4WOc8 ZgWj2fiSLzHZkSwLkESi/Ox2Omz4DhizaXpZcpYc3qIgIUQSNSYb/MjexaZardo7qdII zpT6dmJB5Z91Do8c4JtyKmj9lV6IYk03geu/NhhFOFwNZXCYxBFsh2mrHcctIhXtjBja iO3A== X-Gm-Message-State: ALoCoQmtdjgPEF71bk/KcqgBWTyLsbye37GLfkYeyXUlvTZz56bXeVoCg6BguvYzaMJriHsPIBjr X-Received: by 10.140.32.166 with SMTP id h35mr24922062qgh.22.1421427303890; Fri, 16 Jan 2015 08:55:03 -0800 (PST) Received: from rain.nss.udel.edu (rain.nss.udel.edu. [128.175.2.33]) by mx.google.com with ESMTPSA id u20sm4624972qaj.5.2015.01.16.08.55.02 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 08:55:03 -0800 (PST) Date: Fri, 16 Jan 2015 11:55:01 -0500 (EST) From: Mike Porter X-X-Sender: mike@rain To: Andres Freund cc: Kevin Perais , Tom Lane , "pgsql-bugs@postgresql.org" Subject: Re: BUG #12556: Clause IN and NOT IN buggy In-Reply-To: <20150116155531.GF21581@alap3.anarazel.de> Message-ID: References: <20150115112720.2502.55131@wrigleys.postgresql.org> <6445.1421341526@sss.pgh.pa.us> <46C6B6B27EF7AA489BBDF478BF05B5D2BD886818@server.exchange.local> <20150116155531.GF21581@alap3.anarazel.de> User-Agent: Alpine 2.00 (OSX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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