>> SELECT -2147483648::integer;
>> ERROR: integer out of range
>
> It's just a precedence issue. :: binds with higher precedence, so the
> above is actually -(2147483648::integer), rather than
> (-2147483648)::integer. Therefore you get an overflow.
The error message may be nicer by expliciting the offending string, and/or
locating it precisely within the query?
--
Fabien.