Re: Confused about CASE

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Confused about CASE
Дата
Msg-id 21048.1204337057@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Confused about CASE  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-general
Stephan Szabo <sszabo@megazone.bigpanda.com> writes:
> It looks like the problem is that relkind is of the somewhat odd
> PostgreSQL type "char" not an actual char(1), so with the else in there it
> appears to try to force the unknown literals into that type which only
> takes the first character. It will probably work if you cast in the else,
> like "else CAST(c.relkind as CHAR(1))".

Right, the problem is that all the string literals are "unknown" and
don't force a type decision, so the "char" type gets chosen as the
result type of the CASE, and then the literals get coerced to that.

If you explicitly cast any one of the CASE output expressions to text
--- either relkind, or any of the constants --- the behavior is as the
OP expects.

            regards, tom lane

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

Предыдущее
От: "Scott Marlowe"
Дата:
Сообщение: Re: SERIAL and Primary Key
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Querying Headers