Re: BUG #14986: -2147483648 is minimum value of integer but-2147483648::integer fails (out of range). - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #14986: -2147483648 is minimum value of integer but-2147483648::integer fails (out of range).
Date
Msg-id 20171221142709.3uddkvcrxtlb6mhy@alvherre.pgsql
Whole thread Raw
In response to Re: BUG #14986: -2147483648 is minimum value of integer but-2147483648::integer fails (out of range).  (Greg Stark <stark@mit.edu>)
List pgsql-bugs
Greg Stark wrote:

> The LOCATION line even gives a hint what's going on. 2147483648 was
> read as an int8 constant and the - operator returned an int8 and then
> the cast (being run during explain as part of preparing the plan)
> overflowed.

So this is because this is tokenized as four tokens -- minus, the
numeric value, :: and the identifier type name.  This whole thing be
made simpler by turning the literal as one of the unknown type, with the
minus sign inside it.  This ends up as two tokens:

select integer '-2147483648';

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-bugs by date:

Previous
From: Andres Freund
Date:
Subject: Re: BUG #14986: -2147483648 is minimum value of integer but-2147483648::integer fails (out of range).
Next
From: Amit Kapila
Date:
Subject: Re: vacuum vs heap_update_tuple() and multixactids