Re: Type and CAST error on lowest negative integer values for smallint, int and bigint

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Type and CAST error on lowest negative integer values for smallint, int and bigint
Дата
Msg-id CAApHDvq0iECqPDrbjyBPJAiywPmdWSAM-ppBtnNOpoL3_=SjWQ@mail.gmail.com
обсуждение исходный текст
Ответ на Type and CAST error on lowest negative integer values for smallint, int and bigint  (Hans Buschmann <buschmann@nidsa.net>)
Ответы AW: Type and CAST error on lowest negative integer values for smallint, int and bigint
Список pgsql-hackers
On Thu, 2 May 2024 at 23:25, Hans Buschmann <buschmann@nidsa.net> wrote:
> postgres=# select -32768::smallint;
> ERROR:  smallint out of range

The precedence order of operations applies the cast before the unary
minus operator.

Any of the following will work:

postgres=# select cast(-32768 as smallint), (-32768)::smallint,
'-32768'::smallint;
  int2  |  int2  |  int2
--------+--------+--------
 -32768 | -32768 | -32768
(1 row)

David



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

Предыдущее
От: Hans Buschmann
Дата:
Сообщение: Type and CAST error on lowest negative integer values for smallint, int and bigint
Следующее
От: Alexander Lakhin
Дата:
Сообщение: Re: Typos in the code and README