Skip site navigation (1) Skip section navigation (2)

Re: Skipping numbers in a sequence.

From: ghaverla(at)freenet(dot)edmonton(dot)ab(dot)ca
To: GH <grasshacker(at)over-yonder(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Skipping numbers in a sequence.
Date: 2000-11-24 12:54:12
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-generalpgsql-novice
On Fri, 24 Nov 2000, GH wrote:
> On Fri, Nov 24, 2000 at 04:07:25AM -0600, some SMTP stream spewed forth: 
> > On Fri, Nov 24, 2000 at 09:59:17PM +1300, some SMTP stream spewed forth: 
> > > GH wrote:
> > > > Hello all.
> > > > It's like this. ;-)
> > > > I have a table with a column that has a default nextval('sequence').
> > > > The sequence is a standard increment 1 cycle sequence.
> > > > What happens when
> > > >         the sequence wraps after inserting the
> > > >                 2-million-and-whatever-th row
> *snippity snip snip*

> > > I usually leave the sequence to error at 4 billion, and if that hits me
> > > before the heat-death of the universe I will sort it out then :-)
> Hell, do you suppose I could just set the column to float8 and let the
> sequence run for the next several years? I would be happy if the sequence
> buys me 3 or more years. ;-)
> (Just get me to Morrocco, baby. ;-))
> There would not be any problems with a sequence as high as max(float8), would
> there?

What happens when you try to increment by 1, a number stored in
a float 8 which is (much) bigger than MAXVAL, but still smaller than
what a float 8 can hold?  Absolutely nothing.  A numerical test
of equality shows the 2 numbers are equal.  You have to stick with
some kind of integer, but it will have to be spread across multiple
words.  If int4 isn't big enough, int6 (your home-made int 6 that
is) would probably be big enough.  If heat death really bothers
you, try int 8.  There should be stuff in the GNU multi-precision
library or perl (bit vectors I think) which would let you write
this sort of stuff.


Matter Realisations
Gordon Haverland, B.Sc. M.Eng. President
101  9504 182 St. NW    Edmonton, AB, CA  T5T 3A7
780/481-8019            ghaverla @
780/993-1274 (cell)

In response to

pgsql-novice by date

Next:From: Tom LaneDate: 2000-11-24 17:02:33
Subject: Re: Re: re : PHP and persistent connections
Previous:From: GHDate: 2000-11-24 12:18:04
Subject: Re: Re: re : PHP and persistent connections

pgsql-general by date

Next:From: Pawel DubinDate: 2000-11-24 13:48:27
Previous:From: GHDate: 2000-11-24 12:42:16
Subject: Re: Automatic Addslashes

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group