Re: Type and CAST error on lowest negative integer values for smallint, int and bigint
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Hans Buschmann <buschmann@nidsa.net>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2024-05-02T11:33:55Z
Lists: 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