X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 4411A9DC9E6 for ; Tue, 27 Dec 2005 20:25:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23750-03 for ; Tue, 27 Dec 2005 20:25:43 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 152239DC891 for ; Tue, 27 Dec 2005 20:25:37 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jBS0PeWW009417; Tue, 27 Dec 2005 19:25:40 -0500 (EST) To: elein cc: George Pavlov , pgsql-sql@postgresql.org Subject: Re: "large" IN/NOT IN subqueries result in query returning wrong data In-reply-to: <20051228001251.GB20674@varlena.com> References: <3697.1135712691@sss.pgh.pa.us> <20051228001251.GB20674@varlena.com> Comments: In-reply-to elein message dated "Tue, 27 Dec 2005 16:12:51 -0800" Date: Tue, 27 Dec 2005 19:25:40 -0500 Message-ID: <9416.1135729540@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.049 required=5 tests=[AWL=0.049] X-Spam-Score: 0.049 X-Spam-Level: X-Archive-Number: 200512/215 X-Sequence-Number: 23757 elein 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