Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 29610650109 for ; Sat, 6 Sep 2008 21:10:41 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 66384-07 for ; Sat, 6 Sep 2008 21:10:29 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 72A3364FF9A for ; Sat, 6 Sep 2008 21:10:07 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m870A4Ve027486; Sat, 6 Sep 2008 20:10:05 -0400 (EDT) To: "Jaime Casanova" cc: "Ryan Bradetich" , pgsql-patches Subject: Re: [PgFoundry] Unsigned Data Types [1 of 2] In-reply-to: <3073cc9b0809061610s149ef06ah5bb601b081b29db6@mail.gmail.com> References: <3073cc9b0809061341q5c747488i85491e4c8e2420ba@mail.gmail.com> <25089.1220734677@sss.pgh.pa.us> <3073cc9b0809061610s149ef06ah5bb601b081b29db6@mail.gmail.com> Comments: In-reply-to "Jaime Casanova" message dated "Sat, 06 Sep 2008 18:10:25 -0500" Date: Sat, 06 Sep 2008 20:10:04 -0400 Message-ID: <27485.1220746204@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/78 X-Sequence-Number: 7093 "Jaime Casanova" writes: > On Sat, Sep 6, 2008 at 3:57 PM, Tom Lane wrote: >>> postgres=# select -256::uint1; >>> ERROR: uint1 out of range >> >> No, that's just because this is parsed as -(256::uint1) > actually, i thought that case is right but the -255::uint1 returning a > negative number (aka -255) is what bothers me Well, again, that's -(255::uint1). I suppose uint1 hasn't got a negation operator (what would it do??), so probably the sequence of events is to form 255::uint1, then implicitly promote it to some signed type or other (most likely int4), then negate. Not much to be done about this unless you want to get rid of the implicit coercion to signed types, which would probably defeat most of the purpose. Now, if (-255)::uint1 fails to throw error, that would be a bug IMHO. Casting any negative value to uint ought to fail, no? regards, tom lane