Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 13752632C0A for ; Tue, 22 Jun 2010 20:08:03 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 44783-04 for ; Tue, 22 Jun 2010 23:07:54 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from fetter.org (unknown [64.81.66.25]) by mail.postgresql.org (Postfix) with ESMTP id DDD7E632288 for ; Tue, 22 Jun 2010 20:07:55 -0300 (ADT) Received: by fetter.org (Postfix, from userid 500) id 5ABB4FBC12E; Tue, 22 Jun 2010 16:07:54 -0700 (PDT) Date: Tue, 22 Jun 2010 16:07:54 -0700 From: David Fetter To: Thom Brown Cc: Satoshi Nagayasu , pgsql-docs@postgresql.org Subject: Re: INTEGER range ("-2147483648" is not accepted.) Message-ID: <20100622230754.GE15203@fetter.org> References: <4C207403.3080103@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-12-10) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.107 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RDNS_NONE=0.793 X-Spam-Level: X-Archive-Number: 201006/55 X-Sequence-Number: 5623 On Tue, Jun 22, 2010 at 09:36:30AM +0100, Thom Brown wrote: > 2010/6/22 Satoshi Nagayasu : > > Hi all, > > > > I've found a bit strange thing on the INTEGER range in the official manual. > > > > http://www.postgresql.org/docs/8.4/interactive/datatype-numeric.html > > > > According to the official manual, the INTEGER range is "-2147483648 to +2147483647". > > However, my example in below shows that "-2147483648" is not accepted. > > > > Is this correct? Any suggestions? > > > > Regards, > > > > --------------------------------------------------------------------- > > template1=# SELECT version(); > >                                                  version > > ------------------------------------------------------------------------------------------------------------ > >  PostgreSQL 8.4.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42), 32-bit > > (1 row) > > > > template1=# SELECT -2147483647::integer; > >  ?column? > > ------------- > >  -2147483647 > > (1 row) > > > > template1=# SELECT -2147483648::integer; > > ERROR:  integer out of range > > template1=# SELECT +2147483648::integer; > > ERROR:  integer out of range > > template1=# SELECT +2147483647::integer; > >  ?column? > > ------------ > >  2147483647 > > (1 row) > > > > template1=# > > --------------------------------------------------------------------- > > > > Hmm... yes, that's not what I'd expect either: > > postgres=# SELECT -32768::smallint; > ERROR: smallint out of range > postgres=# SELECT -9223372036854775808::bigint; > ERROR: bigint out of range > > I think those min values are all out by 1. Nope. Same problem. SELECT (-32768)::smallint; -32768 SELECT (-9223372036854775808)::bigint; -9223372036854775808 I agree that the appropriate error message should complain about the actual error, which is that 32768, or 2147483648, or 9223372036854775808, as the case may be, is out of range in the positive direction. Possibly the "hint" might mention that :: binds tighter than - does. Cheers, David. -- David Fetter http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@gmail.com iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate