From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Praxmarer <ppraxmarer@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG: IS NOT NULL on RECORD variable fails in 17.5-dev
Date: Thu, 07 Aug 2025 15:53:55 -0400
Message-ID: <1603234.1754596435@sss.pgh.pa.us> (raw)
In-Reply-To: <CABBx1iF9pQfB3pOP9EBBHe0uyQo2oPRR-iWv0d_OOB-vn3rD+A@mail.gmail.com>
References: <CABBx1iF9pQfB3pOP9EBBHe0uyQo2oPRR-iWv0d_OOB-vn3rD+A@mail.gmail.com>
Peter Praxmarer <ppraxmarer@gmail.com> writes:
> I have discovered what appears to be a severe bug in a development version
> of PostgreSQL 17 where a populated RECORD variable incorrectly fails an IS
> NOT NULL check.
No, that's behaving per SQL standard, and the same as many PG versions
before it. Per [1]:
If the expression is row-valued, then IS NULL is true when the row
expression itself is null or when all the row's fields are null,
while IS NOT NULL is true when the row expression itself is
non-null and all the row's fields are non-null. Because of this
behavior, IS NULL and IS NOT NULL do not always return inverse
results for row-valued expressions; in particular, a row-valued
expression that contains both null and non-null fields will return
false for both tests.
IMHO this wasn't one of the SQL committee's better ideas, but we're
stuck with it.
regards, tom lane
[1] https://www.postgresql.org/docs/current/functions-comparison.html
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, ppraxmarer@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG: IS NOT NULL on RECORD variable fails in 17.5-dev
In-Reply-To: <1603234.1754596435@sss.pgh.pa.us>
* 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