Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbbsk-0004U7-Ou for pgsql-general@arkaria.postgresql.org; Tue, 05 Apr 2022 05:37:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbbsj-0007H6-7l for pgsql-general@arkaria.postgresql.org; Tue, 05 Apr 2022 05:37:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nbbsi-0007Gw-OJ for pgsql-general@lists.postgresql.org; Tue, 05 Apr 2022 05:37:32 +0000 Received: from gw1.antarean.org ([194.145.200.214]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbbsc-0004s6-1g for pgsql-general@lists.postgresql.org; Tue, 05 Apr 2022 05:37:31 +0000 Received: from localhost (localhost [127.0.0.1]) by gw1.antarean.org (Postfix) with ESMTP id 4KXbjr5FKjzyTf for ; Tue, 5 Apr 2022 07:26:56 +0200 (CEST) X-Virus-Scanned: amavisd-new at antarean.org Received: from gw1.antarean.org ([127.0.0.1]) by localhost (gw1.antarean.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Kw85MaLQMUu0 for ; Tue, 5 Apr 2022 07:26:56 +0200 (CEST) Received: from mailstore1.adm.antarean.org (localhost [127.0.0.1]) by gw1.antarean.org (Postfix) with ESMTP id 4KXbjr3Lk7zyQ1 for ; Tue, 5 Apr 2022 07:26:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mailstore1.adm.antarean.org (Postfix) with ESMTP id 4KXbxw1Jp2z15 for ; Tue, 5 Apr 2022 07:37:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at antarean.org Received: from mailstore1.adm.antarean.org ([127.0.0.1]) by localhost (mailstore1.adm.antarean.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fYvrn_zhZ0NB for ; Tue, 5 Apr 2022 07:37:24 +0200 (CEST) Received: from iris.localnet (iris.adm.antarean.org [10.55.16.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mailstore1.adm.antarean.org (Postfix) with ESMTPSA id 4KXbxv6sN8z13 for ; Tue, 5 Apr 2022 07:37:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=antarean.org; s=default; t=1649137043; bh=ETXOT5c7nFpkwe4qwv7gMte+kmqxCUWnRijnXDCptPY=; h=From:To:Subject:Date:In-Reply-To:References; b=NyIPqpx/lQ5scAjN1vNOBkdqH6JOZ6oAtfJskGskfiIDxn1fh3dwi+SAHeBv0j5bj awNy2jrJQE9vxMcmLc7ALT87tmmaTmrpJ8W3YPUbZMLQL48S8i0jWv1017JFxax8ix 0H/eSqE4fNBvHcpSVzgtMATBEfBpIHUfwuYIBuw8= From: "J. Roeleveld" To: pgsql-general@lists.postgresql.org Subject: Re: Select .... where id not in (....) returns 0 incorrectly Date: Tue, 05 Apr 2022 07:37:23 +0200 Message-ID: <5578298.DvuYhMxLoT@iris> In-Reply-To: References: <5820573.lOV4Wx5bFT@iris> <2245474.ElGaqSPkdT@iris> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Monday, April 4, 2022 10:47:51 PM CEST David Rowley wrote: > On Tue, 5 Apr 2022 at 01:21, J. Roeleveld wrote: > > Personally, I think NULL should be treated as a seperate value and not > > lead to strange behaviour. > > I think the rationale behind IN and NOT IN are that c IN(1,2,3) is > equivalent of writing: c = 1 OR c = 2 OR c = 3, whereas NOT IN(1,2,3) > would be the same as c <> 1 AND c <> 2 AND c <> 3. You can imagine > what would happen in the latter case if you replaced 3 with NULL. "c > <> NULL" is NULL therefore, due to the quals being ANDed, will cause > the WHERE clause not to match anything. > > In any case, it's what the SQL standard says, so that's the way we do it. I agree with following the standard. If I would feel really strongly about this (I don't), it would be up to me to try and convince others. And I have got better things to do with my time. :) -- Joost