On Fri, Feb 16, 2018 at 12:57 PM, PG Bug reporting form
<noreply@postgresql.org> 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.