Re: cast of integer to bool doesn't work (anymore?)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: cast of integer to bool doesn't work (anymore?)
Дата
Msg-id 12627.1048259267@sss.pgh.pa.us
обсуждение исходный текст
Ответ на cast of integer to bool doesn't work (anymore?)  (Eric Veldhuyzen <ericv@xs4all.net>)
Список pgsql-sql
Eric Veldhuyzen <ericv@xs4all.net> writes:
> # select 0::boolean;
>  bool=20
> ------
>  f
> (1 row)

> Perfect.

Not so perfect as you think --- 7.2 does not allow casting from int to
bool any more than 7.3 does.  Try this:

regression=# select 1::int::boolean;
ERROR:  Cannot cast type 'integer' to 'boolean'

7.2 is interpreting your query like

regression=# select '1'::boolean;bool
------t
(1 row)

which still works in 7.3 --- but we tightened up the other case, for
reasons I don't recall at the moment but you can find in the mailing
list archives.
        regards, tom lane


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

Предыдущее
От: Eric Veldhuyzen
Дата:
Сообщение: Re: cast of integer to bool doesn't work (anymore?)
Следующее
От: Achilleus Mantzios
Дата:
Сообщение: Re: cast of integer to bool doesn't work (anymore?)