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

Поиск
Список
Период
Сортировка
От Joseph Shraibman
Тема Re: BUG #5028: CASE returns ELSE value always when type is "char"
Дата
Msg-id 4A9D5340.7040408@selectacast.net
обсуждение исходный текст
Ответ на Re: BUG #5028: CASE returns ELSE value always when type is "char"  (Sam Mason <sam@samason.me.uk>)
Ответы Re: BUG #5028: CASE returns ELSE value always when type is "char"
Список pgsql-bugs
Sam Mason wrote:
> On Tue, Sep 01, 2009 at 04:36:25PM +0000, Joseph Shraibman wrote:
>> Description:        CASE returns ELSE value always when type is "char"
>
> I think it's just silently truncating the literal to a single character.
>
>> [local]:playpen=> select c.relkind, CASE c.relkind WHEN 'r' THEN 'table'
>> WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's'
>> THEN 'special' WHEN 'c' THEN 'composite type' WHEN 't' THEN 'toast' ELSE
>> c.relkind
>> playpen->  END from (select 'r'::"char" AS relkind) c;
>>  relkind | relkind
>> ---------+---------
>>  r       | t

Ah, OK it seems I didn't pay close enough attention.

>
> Here, 'r' maps to the "char" literal 'table' which PG interprets as the
> value 't'--i.e. PG silently chops of the 'able'.

So the type of what is in the ELSE clause determines the type of the output?

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Joseph Shraibman
Дата:
Сообщение: Re: BUG #5028: CASE returns ELSE value always when type is "char"
Следующее
От: "Alan Rubin"
Дата:
Сообщение: BUG #5029: Download Trouble