Re: CASE w/out ELSE hides typmod (was: How define a view that use a case operator for geometry field)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: CASE w/out ELSE hides typmod (was: How define a view that use a case operator for geometry field)
Дата
Msg-id 29850.1319835625@sss.pgh.pa.us
обсуждение исходный текст
Ответ на CASE w/out ELSE hides typmod (was: How define a view that use a case operator for geometry field)  (Sandro Santilli <strk@keybit.net>)
Список pgsql-hackers
Sandro Santilli <strk@keybit.net> writes:
> The same happens with any type, can be reproduced with something like this:

> =# CREATE VIEW test1 AS SELECT
>   CASE WHEN random() < 0.5 THEN 1::numeric(10, 0)
>   END;

> =# \d test1
>        View "test.test1"
>  Column |  Type   | Modifiers
> --------+---------+-----------
>  case   | numeric |

> =# CREATE VIEW test2 AS SELECT
>   CASE WHEN random() < 0.5 THEN 1::numeric(10, 0)
>   ELSE 0::numeric(10, 0)
>   END;

> =# \d test2
>          View "test.test2"
>  Column |     Type      | Modifiers
> --------+---------------+-----------
>  case   | numeric(10,0) |

> Maybe someone on pgsql-hackers can tell us more about this.

IIRC, the result of a CASE is only considered to have a defined typmod
if all arms of the CASE ... including ELSE ... have the identical
typmod.
        regards, tom lane


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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: So where are we on the open commitfest?
Следующее
От: Robert Haas
Дата:
Сообщение: Re: So, is COUNT(*) fast now?