Re: COALESCE documentation - Mailing list pgsql-docs

From Peter Eisentraut
Subject Re: COALESCE documentation
Date
Msg-id 62f888dc-1ee5-48cf-b76c-6a75dcfa8b10@eisentraut.org
Whole thread Raw
In response to COALESCE documentation  (Navrátil, Ondřej <onavratil@monetplus.cz>)
Responses Re: COALESCE documentation
Re: COALESCE documentation
List pgsql-docs
On 02.07.24 12:45, Navrátil, Ondřej wrote:
> Hello,
> 
> as per documentation 
> <https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL>
>  > The |COALESCE| function returns the first of its arguments that is 
> not null. Null is returned only if all arguments are null.
> 
> This is not exactly true. In fact:
> The |COALESCE| function returns the first of its arguments that *is 
> distinct* *from *null. Null is returned only if all arguments *are not 
> distinct from* null.
> 
> See my stack overflow question here 
> <https://stackoverflow.com/questions/78691097/postgres-null-on-composite-types>.
> 
> Long story short
> 
> |select coalesce((null, null), (10, 20)) as magic; |
> 
> returns
> 
> |magic ------- (,) (1 row)|
> 
> However, this is true:
> 
> |select (null, null) is null;|

I think this is actually a bug in the implementation, not in the 
documentation.  That is, the implementation should behave like the 
documentation suggests.




pgsql-docs by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: COALESCE documentation
Next
From: Laurenz Albe
Date:
Subject: Re: COALESCE documentation