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

From: Vik Fearing <vik(at)postgresfriends(dot)org>
To: Chris BSomething <xpusostomos(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL Bug List <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: 2025-02-19 19:02:34
Message-ID: b980ef30-29ce-4dec-b5cd-64e961bec3b0@postgresfriends.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


On 19/02/2025 13:50, Chris BSomething wrote:
>
> On Tue, 18 Feb 2025 at 10:12, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> I think such a rule would be pretty dangerous, even if we could
> implement it easily.  As an example, if you entered something you
> meant as a timestamp, but you fat-fingered the punctuation or
> something, it'd likely fall back to being considered just "text",
>
>
> I don't get that, I thought timestamps have to be preceded by "TIMESTAMP".

The SQL standard requires you to do that, but PostgreSQL is a bit more
lax about it (and in my humble opinion, thankfully so). If you did
prefix your literals with their type, you wouldn't be having these
problems in the first place. The problem stems from postgres treating
your unmarked literal as "unknown" and then trying to figure out what
the heck it is.

--

Vik Fearing

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Jose Fco. Mojada 2025-02-19 19:14:03 Re: Possible bug ¿? missing "ucol.h" in postgre installation
Previous Message Greg Sabino Mullane 2025-02-19 17:48:47 Re: BUG #18817: Security Bug Report: Plaintext Password Exposure in Logs