Re: BUG: IS NOT NULL on RECORD variable fails in 17.5-dev

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Praxmarer <ppraxmarer(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG: IS NOT NULL on RECORD variable fails in 17.5-dev
Date: 2025-08-07 19:53:55
Message-ID: 1603234.1754596435@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Peter Praxmarer <ppraxmarer(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2025-08-07 19:54:07 Re: BUG: IS NOT NULL on RECORD variable fails in 17.5-dev
Previous Message Peter Praxmarer 2025-08-07 19:43:54 BUG: IS NOT NULL on RECORD variable fails in 17.5-dev