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

From Francisco J. Ossandón
Subject Re: BUG #18594: CASE WHEN ELSE failing to return the expected output when the same colum is used in WHEN and ELSE
Date
Msg-id CAEgp-NcMuFEXF7_-_wRhGBXxu2dK35pbM54o_RwQcMn7Wg219w@mail.gmail.com
Whole thread Raw
In response to Re: BUG #18594: CASE WHEN ELSE failing to return the expected output when the same colum is used in WHEN and ELSE  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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ó:
Francisco J. Ossandón <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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18594: CASE WHEN ELSE failing to return the expected output when the same colum is used in WHEN and ELSE
Next
From: Richard Guo
Date:
Subject: Re: BUG #18589: pg_get_viewdef returns wrong query