Re: BUG #5028: CASE returns ELSE value always when type is "char" - Mailing list pgsql-bugs

From Kevin Grittner
Subject Re: BUG #5028: CASE returns ELSE value always when type is "char"
Date
Msg-id 4AA0F324020000250002AABE@gw.wicourts.gov
Whole thread Raw
In response to Re: BUG #5028: CASE returns ELSE value always when type is "char"  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #5028: CASE returns ELSE value always when type is "char"  (Robert Haas <robertmhaas@gmail.com>)
Re: BUG #5028: CASE returns ELSE value always when type is "char"  (Sam Mason <sam@samason.me.uk>)
List pgsql-bugs
Tom Lane <tgl@sss.pgh.pa.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

pgsql-bugs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: BUG #5036: Advisory locks have unexpected behavior
Next
From: Robert Haas
Date:
Subject: Re: BUG #5028: CASE returns ELSE value always when type is "char"