Re: Dumb question about serial's upper limit

From: "Dann Corbit" <DCorbit(at)connx(dot)com>
To: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "CSN" <cool_screen_name90001(at)yahoo(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Dumb question about serial's upper limit
Date: 2005-10-11 06:52:40
Message-ID: D425483C2C5C9F49B5B7A41F8944154757D1A8@postal.corporate.connx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

How about something like:

CREATE DOMAIN unsigned_small AS smallint check (VALUE >= 0)

CREATE DOMAIN unsigned_int AS integer check (VALUE >= 0)

CREATE DOMAIN unsigned_big AS bigint check (VALUE >= 0)

The objection might be that we lose one bit of field width.
But the extra safety is probably worth it if you really need unsigned
and want to avoid ambiguity.

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
> owner(at)postgresql(dot)org] On Behalf Of Jim C. Nasby
> Sent: Monday, October 10, 2005 11:12 PM
> To: Tom Lane
> Cc: CSN; pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Dumb question about serial's upper limit
>
> On Mon, Oct 10, 2005 at 10:59:03PM -0400, Tom Lane wrote:
> > CSN <cool_screen_name90001(at)yahoo(dot)com> writes:
> > > If integer's range is -2147483648 to +2147483647, why
> > > is serial's range only 1 to 2147483647 instead of 1 to
> > > about 4294967294?
> >
> > How are you going to stuff 4294967294 into an integer field, which
as
> > you just stated has an upper limit of 2147483647?
> >
> > If we had an unsigned int type, we could use it for serial and get
> > that result, but we do not.
>
> Out of curiosity... why don't we have unsigned ints? I for one would
> certainly use them for id fields, as well as some other places where I
> knew negative numbers weren't valid.
> --
> Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
> Pervasive Software http://pervasive.com work: 512-231-6117
> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461
>
> ---------------------------(end of
broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2005-10-11 07:59:45 Re: PostgreSQL's bug tracker
Previous Message Michael Glaesemann 2005-10-11 06:29:22 Re: Dumb question about serial's upper limit