pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sandro Santilli <strk@kbt.io>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: lower integer bound not supported
Date: Wed, 8 Jun 2016 18:43:19 +0200
Message-ID: <20160608164319.GA5590@localhost> (raw)
In-Reply-To: <20160608163759.GA9544@alvherre.pgsql>
References: <20160608160800.GB13838@localhost>
	<20160608163759.GA9544@alvherre.pgsql>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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



view thread (3+ messages)

Message-ID: <20160608164319.GA5590@localhost>
Permalink:  ../20160608164319.GA5590@localhost/
Also on:    postgresql.org/message-id/20160608164319.GA5590@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: strk@kbt.io, alvherre@2ndquadrant.com
  Subject: Re: lower integer bound not supported
  In-Reply-To: <20160608164319.GA5590@localhost>
  References: <20160608160800.GB13838@localhost> <20160608163759.GA9544@alvherre.pgsql> <20160608164319.GA5590@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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