Re: XML column causes record to be both NULL and NOT NULL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Wilm Hoyer <W(dot)Hoyer(at)dental-vision(dot)de>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: XML column causes record to be both NULL and NOT NULL
Date: 2023-07-04 18:59:24
Message-ID: 881845.1688497164@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Wilm Hoyer <W(dot)Hoyer(at)dental-vision(dot)de> writes:
> i found a strange behavior and hope it's not a pilot error.

Well, it is strange, but it's acting per SQL spec.
As stated at [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.

The fact that the added column is of XML type isn't relevant here;
what's relevant is that it has a null value.

regards, tom lane

[1] https://www.postgresql.org/docs/current/functions-comparison.html

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Masahiko Sawada 2023-07-05 01:23:22 Re: BUG #17695: Failed Assert in logical replication snapbuild.
Previous Message Wilm Hoyer 2023-07-04 18:46:23 XML column causes record to be both NULL and NOT NULL