From: J. Roeleveld <joost@antarean.org>
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> (raw)
In-Reply-To: <CAApHDvqh_LOKwKFaSUk83ELnftvYxobKaxOdTEruUmezuGM6PA@mail.gmail.com>
References: <5820573.lOV4Wx5bFT@iris>
<2245474.ElGaqSPkdT@iris>
<CAApHDvqh_LOKwKFaSUk83ELnftvYxobKaxOdTEruUmezuGM6PA@mail.gmail.com>
On Monday, April 4, 2022 10:47:51 PM CEST David Rowley wrote:
> On Tue, 5 Apr 2022 at 01:21, J. Roeleveld <joost@antarean.org> 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
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-general@postgresql.org
Cc: joost@antarean.org
Subject: Re: Select .... where id not in (....) returns 0 incorrectly
In-Reply-To: <5578298.DvuYhMxLoT@iris>
References: <5820573.lOV4Wx5bFT@iris> <2245474.ElGaqSPkdT@iris> <CAApHDvqh_LOKwKFaSUk83ELnftvYxobKaxOdTEruUmezuGM6PA@mail.gmail.com> <5578298.DvuYhMxLoT@iris>
* 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