Re: BUG #15071: Error in PostgreSQL-specific :: type cast

Поиск
Список
Период
Сортировка
Искать
От
Francisco Olarte
Тема
Re: BUG #15071: Error in PostgreSQL-specific :: type cast
Дата
Msg-id
CA+bJJbxJuBag4+gW+nTJkuL=-ic+8fO5kdcip3KeEL-nBQ5K5A@mail.gmail.com
Ответ на
Список
Дерево обсуждения
BUG #15071: Error in PostgreSQL-specific :: type cast PG Bug reporting form <noreply@postgresql.org>
Re: BUG #15071: Error in PostgreSQL-specific :: type cast Daniel Gustafsson <daniel@yesql.se>
Re: BUG #15071: Error in PostgreSQL-specific :: type cast Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #15071: Error in PostgreSQL-specific :: type cast Francisco Olarte <folarte@peoplecall.com>
On Fri, Feb 16, 2018 at 12:57 PM, PG Bug reporting form
 wrote:

...
> SELECT -32768::smallint
> ^ERROR:  smallint out of range

This is interpreted as -(32768::smallint)

...
> Standard-syntax type casts are workes correctly:
> SELECT cast(-32768 as smallint)

This is not.

When in doubt, put parenthesis

postgres=# select (-32768)::smallint;
  int2
--------
 -32768
(1 row)

postgres=# select -(32768::smallint);
ERROR:  smallint out of range
postgres=# select -32768::smallint;
ERROR:  smallint out of range

And IIRC, expression with implicit casts ( like when comparing
constnat to columns) work because they use the conversion from
text/unknown...

postgres=# select '-32768'::smallint;
  int2
--------
 -32768
(1 row)

Francisco Olarte.

В списке pgsql-bugs по дате отправления
От: Tom Lane
Дата:
От: Bradley Ayers
Дата:
FAQ