Re: BUG #5028: CASE returns ELSE value always when type is "char"

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: Sam Mason <sam(at)samason(dot)me(dot)uk>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5028: CASE returns ELSE value always when type is "char"
Date: 2009-09-04 16:37:01
Message-ID: 603c8f070909040937i2b65ea95w7ff7dddc61102bd4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Sep 4, 2009 at 11:59 AM, Kevin
Grittner<Kevin(dot)Grittner(at)wicourts(dot)gov> wrote:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> I certainly don't want to have "char" emulate the misbegotten
>> decision to have explicit and implicit coercions behave differently.
>> So it looks to me like the argument to make "char" work like char(1)
>> doesn't actually help us much to decide if an error should be thrown
>> here or not.  On the whole, throwing an error seems better from a
>> usability perspective.
>
> I feel that the behavior of "char" in at least this case should match
> char(1) (or just plain char):
>
> test=# select case when true then 'xxx' else 'a'::"char" end from t;
>  case
> ------
>  x
> (1 row)
>
> test=# select case when true then 'xxx' else 'a'::char(1) end from t;
>  case
> ------
>  xxx
> (1 row)
>
> test=# select case when true then 'xxx' else 'a'::char end from t;
>  case
> ------
>  xxx
> (1 row)
>
> Much as the reason for the behavior of "char" may seem clear when
> inside the code looking out, it is astonishing for someone writing
> application code.
>
> -Kevin

Yeah, I agree. That's really confusing.

...Robert

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sam Mason 2009-09-04 17:03:29 Re: BUG #5028: CASE returns ELSE value always when type is "char"
Previous Message Kevin Grittner 2009-09-04 15:59:48 Re: BUG #5028: CASE returns ELSE value always when type is "char"