pg.ddx.io  pgsql-patches@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jaime Casanova <jcasanov@systemguards.com.ec>
Cc: Ryan Bradetich <rbradetich@gmail.com>
Cc: pgsql-patches <pgsql-patches@postgresql.org>
Subject: Re: [PgFoundry] Unsigned Data Types [1 of 2]
Date: Sat, 06 Sep 2008 20:10:04 -0400
Message-ID: <27485.1220746204@sss.pgh.pa.us> (raw)
In-Reply-To: <3073cc9b0809061610s149ef06ah5bb601b081b29db6@mail.gmail.com>
References: <e739902b0808311335l1ad5d425r2704429c386f2f88@mail.gmail.com>
	<3073cc9b0809061341q5c747488i85491e4c8e2420ba@mail.gmail.com>
	<25089.1220734677@sss.pgh.pa.us>
	<3073cc9b0809061610s149ef06ah5bb601b081b29db6@mail.gmail.com>

"Jaime Casanova" <jcasanov@systemguards.com.ec> writes:
> On Sat, Sep 6, 2008 at 3:57 PM, Tom Lane <tgl@sss.pgh.pa.us> 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



view thread (26+ messages)  latest in thread

Message-ID: <27485.1220746204@sss.pgh.pa.us>
Permalink:  ../27485.1220746204@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27485.1220746204@sss.pgh.pa.us

 · 

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-patches@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jcasanov@systemguards.com.ec, rbradetich@gmail.com
  Subject: Re: [PgFoundry] Unsigned Data Types [1 of 2]
  In-Reply-To: <27485.1220746204@sss.pgh.pa.us>
  References: <e739902b0808311335l1ad5d425r2704429c386f2f88@mail.gmail.com> <3073cc9b0809061341q5c747488i85491e4c8e2420ba@mail.gmail.com> <25089.1220734677@sss.pgh.pa.us> <3073cc9b0809061610s149ef06ah5bb601b081b29db6@mail.gmail.com> <27485.1220746204@sss.pgh.pa.us>

* 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