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

From: Francisco J(dot) Ossandón <fco(dot)j(dot)ossandon(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18594: CASE WHEN ELSE failing to return the expected output when the same colum is used in WHEN and ELSE
Date: 2024-08-29 00:33:34
Message-ID: CAEgp-NcMuFEXF7_-_wRhGBXxu2dK35pbM54o_RwQcMn7Wg219w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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(at)sss(dot)pgh(dot)pa(dot)us>) escribió:

> =?UTF-8?Q?Francisco_J=2E_Ossand=C3=B3n?= <fco(dot)j(dot)ossandon(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Guo 2024-08-29 07:19:43 Re: BUG #18589: pg_get_viewdef returns wrong query
Previous Message Tom Lane 2024-08-29 00:11:28 Re: BUG #18594: CASE WHEN ELSE failing to return the expected output when the same colum is used in WHEN and ELSE