Re: BUG #18594: CASE WHEN ELSE failing to return the expected output when the same colum is used in WHEN and ELSE

Francisco J. Ossandón <fco.j.ossandon@gmail.com>

From: Francisco J. Ossandón <fco.j.ossandon@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andrew Dunstan <andrew@dunslane.net>, pgsql-bugs@lists.postgresql.org
Date: 2024-08-29T00:33:34Z
Lists: pgsql-bugs
Hello Tom,
Thanks for the explanation and the link to the documentation. I understand
now what happened.
So it was a mistake on my side.
Thanks again for the patience and replies.

Best regards,

Francisco


El mié, 28 ago 2024 a las 20:11, Tom Lane (<tgl@sss.pgh.pa.us>) escribió:

> =?UTF-8?Q?Francisco_J=2E_Ossand=C3=B3n?= <fco.j.ossandon@gmail.com>
> writes:
> > So is the ELSE column hijacking the data type of the whole expression?
>
> It's the only CASE result that is supplying a definite type at all.
> But see
>
> https://www.postgresql.org/docs/current/typeconv-union-case.html
>
> particularly the footnote to the bit about "Select the first
> non-unknown input type as the candidate type, then consider
> each other non-unknown input type, left to right."
>
> The WHEN clauses have exactly nothing to do with the result type
> of the CASE: it's the THEN and ELSE clauses that supply the result.
>
>                         regards, tom lane
>


-- 
Francisco J. Ossandon
Bioinformatician
Ph.D. in Biotechnology