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

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Greg Stark <stark(at)mit(dot)edu>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, binoternary(at)gmail(dot)com, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14986: -2147483648 is minimum value of integer but -2147483648::integer fails (out of range).
Date: 2017-12-21 14:27:09
Message-ID: 20171221142709.3uddkvcrxtlb6mhy@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Kapila 2017-12-21 14:28:08 Re: vacuum vs heap_update_tuple() and multixactids
Previous Message Andres Freund 2017-12-21 14:13:15 Re: BUG #14986: -2147483648 is minimum value of integer but -2147483648::integer fails (out of range).