Re: Generate user/group sysids from a sequence?

From: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Generate user/group sysids from a sequence?
Date: 2003-01-17 17:20:12
Message-ID: 20030117172012.GD15778@wallace.ece.rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 17, 2003 at 11:38:24AM -0500, Bruce Momjian wrote:
> Tom Lane wrote:
> >
> > A small difficulty is that explicitly-specified sysids could conflict
> > with sysids generated later by the sequence. We could perhaps fix this
> > by forcing up the sequence setting to be at least as large as an
> > explicitly-given ID (compare the handling of explicitly loaded OIDs).
>
> A sequence sounds like a good idea. When we create a user, we can use
> MAX() to find the maximum, and if that is less than the sequence value,
> bump up the sequence to equal max and add the row, again incrementing
> the sequence. Another idea would be to put a trigger on the column so
> that any INSERT/UPDATE would automatically bump up the sequence with
> setval().
>

Hmm, unlike the OID case, I'd think there's unlikely to be many 'preused'
userids. Why not just retry if the sequence hits an existing entry?

Ross

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-01-17 17:31:23 Re: Generate user/group sysids from a sequence?
Previous Message Tom Lane 2003-01-17 17:01:01 Re: Generate user/group sysids from a sequence?