Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAgZl-0006Yx-9t for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Jun 2016 16:43:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bAgZk-0006c6-SK for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Jun 2016 16:43:28 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bAgZk-0006bh-1H for pgsql-bugs@postgresql.org; Wed, 08 Jun 2016 16:43:28 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bAgZh-0005sA-AG for pgsql-bugs@postgresql.org; Wed, 08 Jun 2016 16:43:26 +0000 Received: from mfilter37-d.gandi.net (mfilter37-d.gandi.net [217.70.178.168]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id A704D17209C; Wed, 8 Jun 2016 18:43:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter37-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter37-d.gandi.net (mfilter37-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 3JHaoh5zNlym; Wed, 8 Jun 2016 18:43:22 +0200 (CEST) X-Originating-IP: 46.232.148.34 Received: from localhost (ip-46-232-148-34.static.adsl.cheapnet.it [46.232.148.34]) (Authenticated sender: strk@kbt.io) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id AF8E61720C2; Wed, 8 Jun 2016 18:43:21 +0200 (CEST) Date: Wed, 8 Jun 2016 18:43:19 +0200 From: Sandro Santilli To: Alvaro Herrera Cc: pgsql-bugs@postgresql.org Subject: Re: lower integer bound not supported Message-ID: <20160608164319.GA5590@localhost> References: <20160608160800.GB13838@localhost> <20160608163759.GA9544@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160608163759.GA9544@alvherre.pgsql> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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