Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 5627C632C3B for ; Wed, 23 Jun 2010 12:06:16 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 03015-10 for ; Wed, 23 Jun 2010 15:06:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gw0-f46.google.com (mail-gw0-f46.google.com [74.125.83.46]) by mail.postgresql.org (Postfix) with ESMTP id 259A7632B5C for ; Wed, 23 Jun 2010 12:06:09 -0300 (ADT) Received: by gwaa18 with SMTP id a18so19095gwa.19 for ; Wed, 23 Jun 2010 08:06:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=9h1Op26NbsmdonE3VwmBS0t/1cCQGe9FRdYT/3Xw2dE=; b=OJmdqM5DCCD3Yyk8f5FGkybrc/MQ1hyTXnmzeFC7xvKIK/mgyle8WXdwag74wPakGz T9r6ZSuxczGj+l2G23CvRJVkPpphU0WaB5txjc+HuN1Fs9Ej5wCiaiXgo5YYcMcV9Ry6 763H/pnhi7BX0slS9CAv3hctI06gZS2w/gudc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=WsZDT4Oksf/awp+wWEvAAqh9ybvaTczzINtv28wLgWOmfWs08L8WTOekGYnPT9OB5K ekaWJP0EO6ORKa3ISNh3S5MlQ8TNuvwTpiEXaeQl4PTxzvTX7jyGiFzALh15gANs7uS3 LOkyiaYBEapBKaTvlp3VWdqfM0tyTUXZ15pM8= MIME-Version: 1.0 Received: by 10.90.10.40 with SMTP id 40mr5096491agj.168.1277305567985; Wed, 23 Jun 2010 08:06:07 -0700 (PDT) Received: by 10.231.34.139 with HTTP; Wed, 23 Jun 2010 08:06:07 -0700 (PDT) In-Reply-To: References: <4C207403.3080103@gmail.com> <20100622230754.GE15203@fetter.org> <11645.1277257777@sss.pgh.pa.us> Date: Wed, 23 Jun 2010 11:06:07 -0400 Message-ID: Subject: Re: INTEGER range ("-2147483648" is not accepted.) From: Robert Haas To: Mike Toews Cc: Tom Lane , Thom Brown , David Fetter , Satoshi Nagayasu , pgsql-docs@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201006/60 X-Sequence-Number: 5628 On Wed, Jun 23, 2010 at 10:29 AM, Mike Toews wrote: > On 22 June 2010 18:49, Tom Lane wrote: >> Thom Brown writes: >>> Is that the right behaviour though? =A0Shouldn't the signed value reach >>> the cast step rather than the absolute value? =A0Or maybe Postgres coul= d >>> implicitly accept -12345::integer to be (-12345)::integer. =A0Is there = a >>> blocking reason as to why it must work this way? >> >> Yes. =A0There is no reason to assume that - means the same thing for eve= ry >> datatype. =A0In general, :: should (and does) bind tighter than *every* >> operator, to ensure that the appropriately typed operator is applied. >> > > Sorry for adding to the non-DOC drift, but why is - assumed to be a > unary operator on an unsigned integer, rather than parsed as part of > an integer? Integers have digits with an optional - or + prefix (not > unary operators). E.g., ([+\-]?[0-9]+) You can't assume that a dash followed by digits is always a negative number. Consider: SELECT 10-4; If you we interpret this as "10" followed by "-4", it's a syntax error. You have to treat it as a separate token and work out later whether it's a binary operator or a prefix operator. --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise Postgres Company