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: Pine.A41.3.95.1001124055005.24354A-100000@freenet.edmonton.ab.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-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.

Gord

Matter Realisations http://www.materialisations.com/
Gordon Haverland, B.Sc. M.Eng. President
101 9504 182 St. NW Edmonton, AB, CA T5T 3A7
780/481-8019 ghaverla @ freenet.edmonton.ab.ca
780/993-1274 (cell)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pawel Dubin 2000-11-24 13:48:27 Re: plz, Help!! HOW CAN I GET THE ROWNUM IN POSTGRES TABLE AS I DID WITH ORACLE!!
Previous Message GH 2000-11-24 12:42:16 Re: Automatic Addslashes

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2000-11-24 17:02:33 Re: Re: re : PHP and persistent connections
Previous Message GH 2000-11-24 12:18:04 Re: Re: re : PHP and persistent connections