pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Francisco J. Ossandón <fco.j.ossandon@gmail.com>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: pgsql-bugs@lists.postgresql.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: Wed, 28 Aug 2024 20:11:28 -0400
Message-ID: <3501446.1724890288@sss.pgh.pa.us> (raw)
In-Reply-To: <CAEgp-NfU3G_9ynpY4n0hUvYjW2eLLqmGJ5_ejtS5hPi131Jg5g@mail.gmail.com>
References: <18594-af265c6988d431d8@postgresql.org>
	<0838f16a-8b3d-4c39-9ad8-5d27791e9dec@dunslane.net>
	<CAEgp-NfU3G_9ynpY4n0hUvYjW2eLLqmGJ5_ejtS5hPi131Jg5g@mail.gmail.com>

=?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





view thread (14+ messages)  latest in thread

Message-ID: <3501446.1724890288@sss.pgh.pa.us>
Permalink:  ../3501446.1724890288@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3501446.1724890288@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, fco.j.ossandon@gmail.com, andrew@dunslane.net, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18594: CASE WHEN ELSE failing to return the expected output when the same colum is used in WHEN and ELSE
  In-Reply-To: <3501446.1724890288@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox