pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedlower integer bound not supported
3+ messages / 2 participants
[nested] [flat]
* lower integer bound not supported
@ 2016-06-08 16:08 Sandro Santilli <strk@kbt.io>
2016-06-08 16:37 ` Re: lower integer bound not supported Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 3+ messages in thread
From: Sandro Santilli @ 2016-06-08 16:08 UTC (permalink / raw)
To: pgsql-bugs
According to documentation (from 9.1 to 9.5) the supported
integer ranges are these ones:
smallint 2 bytes -32768 to +32767
integer 4 bytes -2147483648 to +2147483647
bigint 8 bytes -9223372036854775808 to +9223372036854775807
But the lowest bound is not really supported:
# select -32768::int2;
ERROR: smallint out of range
# select -2147483648::int4;
ERROR: integer out of range
# select -9223372036854775808::int8;
ERROR: bigint out of range
This happens with server versions 9.1.22, 9.3.6 and 9.5(unspecified).
Is it the code or the documentation being broken ?
To me, the documentation makes the most sense, and the code is broken.
--strk;
() Free GIS & Flash consultant/developer
/\ https://strk.kbt.io/services.html
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: lower integer bound not supported
2016-06-08 16:08 lower integer bound not supported Sandro Santilli <strk@kbt.io>
@ 2016-06-08 16:37 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-06-08 16:43 ` Re: lower integer bound not supported Sandro Santilli <strk@kbt.io>
0 siblings, 1 reply; 3+ messages in thread
From: Alvaro Herrera @ 2016-06-08 16:37 UTC (permalink / raw)
To: Sandro Santilli <strk@kbt.io>; +Cc: pgsql-bugs
Sandro Santilli wrote:
> According to documentation (from 9.1 to 9.5) the supported
> integer ranges are these ones:
>
> smallint 2 bytes -32768 to +32767
> integer 4 bytes -2147483648 to +2147483647
> bigint 8 bytes -9223372036854775808 to +9223372036854775807
>
> But the lowest bound is not really supported:
>
> # select -32768::int2;
> ERROR: smallint out of range
> # select -2147483648::int4;
> ERROR: integer out of range
> # select -9223372036854775808::int8;
> ERROR: bigint out of range
This is reported every once in a while. It's not a bug, just an
operator precedence issue: the :: binds more tightly than the unary - so
the number is interpreted as a positive value first, which is indeed out
of range. Try "(-32768)::int2".
Maybe it would be clearer if the error message indicated what's the
value that's out of range, so that the lack of the minus might make the
problem more evident; and perhaps add a HINT suggesting to add the
parens?
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: lower integer bound not supported
2016-06-08 16:08 lower integer bound not supported Sandro Santilli <strk@kbt.io>
2016-06-08 16:37 ` Re: lower integer bound not supported Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2016-06-08 16:43 ` Sandro Santilli <strk@kbt.io>
0 siblings, 0 replies; 3+ messages in thread
From: Sandro Santilli @ 2016-06-08 16:43 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-bugs
On Wed, Jun 08, 2016 at 12:37:59PM -0400, Alvaro Herrera wrote:
> Sandro Santilli wrote:
> > According to documentation (from 9.1 to 9.5) the supported
> > integer ranges are these ones:
> >
> > smallint 2 bytes -32768 to +32767
> > integer 4 bytes -2147483648 to +2147483647
> > bigint 8 bytes -9223372036854775808 to +9223372036854775807
> >
> > But the lowest bound is not really supported:
> >
> > # select -32768::int2;
> > ERROR: smallint out of range
> > # select -2147483648::int4;
> > ERROR: integer out of range
> > # select -9223372036854775808::int8;
> > ERROR: bigint out of range
>
> This is reported every once in a while. It's not a bug, just an
> operator precedence issue: the :: binds more tightly than the unary - so
> the number is interpreted as a positive value first, which is indeed out
> of range. Try "(-32768)::int2".
That explains!
> Maybe it would be clearer if the error message indicated what's the
> value that's out of range, so that the lack of the minus might make the
> problem more evident; and perhaps add a HINT suggesting to add the
> parens?
An HINT suggesting parens would be very very helpful.
--strk;
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2016-06-08 16:43 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-06-08 16:08 lower integer bound not supported Sandro Santilli <strk@kbt.io>
2016-06-08 16:37 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-06-08 16:43 ` Sandro Santilli <strk@kbt.io>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox