Unix Technical Forum

Re: Dumb question about serial's upper limit

This is a discussion on Re: Dumb question about serial's upper limit within the Pgsql General forums, part of the PostgreSQL category; --> How about something like: CREATE DOMAIN unsigned_small AS smallint check (VALUE >= 0) CREATE DOMAIN unsigned_int AS integer check ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 06:21 AM
Dann Corbit
 
Posts: n/a
Default Re: Dumb question about serial's upper limit

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@postgresql.org [mailtogsql-general-
> owner@postgresql.org] On Behalf Of Jim C. Nasby
> Sent: Monday, October 10, 2005 11:12 PM
> To: Tom Lane
> Cc: CSN; pgsql-general@postgresql.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@yahoo.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@pervasive.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


---------------------------(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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 06:22 AM
Jim C. Nasby
 
Posts: n/a
Default Re: Dumb question about serial's upper limit

On Mon, Oct 10, 2005 at 11:52:40PM -0700, Dann Corbit wrote:
> 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.


Certainly. But I was more interested in the space. :P
--
Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.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 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com