Re: Direct converting numeric types to bool

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Direct converting numeric types to bool
Дата
Msg-id 26668.1522077222@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Direct converting numeric types to bool  (n.zhuchkov@postgrespro.ru)
Список pgsql-hackers
n.zhuchkov@postgrespro.ru writes:
> Yes, in postgres already exists int::boolean casting and in case:
> select 10::bigint::int::boolean;
> it will perfectly work. But if you want to cast more significant number:
> select (2^32)::bigint::int::boolean;
> you receive the boundary value error.

Right.  I don't see a reason why we shouldn't create a bigint-to-bool
cast to fix that, and smallint-to-bool maybe for completeness.  However,
I'm less excited about float or numeric to bool, because I don't think
there is any very principled argument about what such a cast should do
with infinities, NaNs, or denormalized numbers.  Somebody who knows
what should happen for their own application can create their own cast
that handles those cases ... but I'm unsure that there's a one-size-
fits-all answer that we could put into a default behavior.

            regards, tom lane


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: bugfifx: a minor mistake in brin_inclusion.c comment
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Why does load_external_function() return PGFunction?