Re: BUG #18451: NULL fails to coerce to string when performing string comparison

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Darryl Dixon <darryl(dot)dixon(at)gmail(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #18451: NULL fails to coerce to string when performing string comparison
Date: 2024-04-30 22:09:06
Message-ID: CAKFQuwZvPW+EH1cDCjti8EC_ke5-84Z6HBPjxfos4q4QUxuv-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tuesday, April 30, 2024, Darryl Dixon <darryl(dot)dixon(at)gmail(dot)com> wrote:

> Hi,
>
> There are a couple of notes regarding this:
> 1) There is an explicit CAST of NULL->text that silently fails (see
> original example)
>

It doesn’t fail. Casting null still results in null.
(Null::integer)::text is valid, you end up with a null integer converted
to a null of type text.

2) This behaviour, if expected, is not well documented/contradicted by
> existing documentation. See the note here:
> https://www.postgresql.org/docs/current/functions-string.html
>

Fair, we don’t explicitly document that ‘…’ || NULL yields NULL. It’s more
of “unless otherwise noted doing stuff with null results in unknown/null
outcomes”.

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Darryl Dixon 2024-04-30 22:11:58 Re: BUG #18451: NULL fails to coerce to string when performing string comparison
Previous Message David Rowley 2024-04-30 22:08:41 Re: BUG #18451: NULL fails to coerce to string when performing string comparison