Re: Help with pre-loaded arbitrary key sequences

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "James B(dot) Byrne" <byrnejb(at)harte-lyne(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Help with pre-loaded arbitrary key sequences
Date: 2008-01-17 15:31:38
Message-ID: dcc563d10801170731h455de400t2b59642f3c005b78@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Jan 17, 2008 9:19 AM, James B. Byrne <byrnejb(at)harte-lyne(dot)ca> wrote:
>
> On Thu, January 17, 2008 10:15, Scott Marlowe wrote:
> >
> > If race conditions are a possible issue, you use a sequence and
> > increment that until you get a number that isn't used. That way two
> > clients connecting at the same time can get different, available
> > numbers.
> >
>
> That is close to the idea that I originally had. I was simply wondering
> if the built-in sequencer could handle this case or whether I need to roll
> my own.

Yeah, the built in sequencer just increments by one, nothing else.
But it should be pretty easy to write a pl/pgsql function that grabs
the next value and loop until it finds one that's available.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2008-01-17 15:47:22 Re: Can't make backup (again)
Previous Message James B. Byrne 2008-01-17 15:19:21 Re: Help with pre-loaded arbitrary key sequences