Steve Atkins <steve@blighty.com> writes:
>> test=> select -2147483648::int;
>> ERROR: integer out of range
There is no bug here. You are mistakenly assuming that the above
represents
select (-2147483648)::int;
But actually the :: operator binds more tightly than unary minus,
so Postgres reads it as
select -(2147483648::int);
and quite rightly fails to convert the int8 literal to int.
If you write it with the correct parenthesization it works:
regression=# select -2147483648::int;
ERROR: integer out of range
regression=# select (-2147483648)::int;
int4
-------------
-2147483648
(1 row)
regards, tom lane