Re: Wrong result for comparing ROW(...) with IS NOT NULL

From: Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>
To: Wolfgang Walther <walther(at)technowledgy(dot)de>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Wrong result for comparing ROW(...) with IS NOT NULL
Date: 2020-11-05 13:48:23
Message-ID: CALT9ZEEN9x-OoFqixs-Gs9XXhJ3uUJzMerEJ-d3Lo4geWFzAMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>
> Ok, I can see how this explanation is somehow consistent. The link you
> gave is just another observation of that, though. Can I infer from
> anywhere in the official docs, that this is correct and expected behaviour?
>

Sure, it is described here:
https://www.postgresql.org/docs/13/functions-comparison.html

"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. In some cases, it may be
preferable to write *row* IS DISTINCT FROM NULL or *row* IS NOT DISTINCT
FROM NULL, which will simply check whether the overall row value is null
without any additional tests on the row fields."

--
Best regards,
Pavel Borisov

Postgres Professional: http://postgrespro.com <http://www.postgrespro.com>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Wolfgang Walther 2020-11-05 14:09:32 Re: Wrong result for comparing ROW(...) with IS NOT NULL
Previous Message Wolfgang Walther 2020-11-05 13:40:53 Re: Wrong result for comparing ROW(...) with IS NOT NULL