Re: Enforcing serial uniqueness?

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Steven Brown <swbrown(at)ucsd(dot)edu>, kleptog(at)svana(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: Enforcing serial uniqueness?
Date: 2006-03-22 14:29:44
Message-ID: 87y7z2lfhj.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> Steven Brown <swbrown(at)ucsd(dot)edu> writes:
> > Martijn van Oosterhout wrote:
> >> IIRC you can set the permissions on a sequence to allow nextval but not
> >> setval.
>
> > I've not been able to find a way - granting UPDATE grants the use of
> > both.
>
> Yes. This is intentional, on the grounds that being able to do NEXTVAL
> enough times is equivalent to SETVAL. (Only strictly true for a CYCLE
> sequence, but the point is that if you don't want to allow SETVAL you
> shouldn't want to allow unrestricted use of NEXTVAL either.)

What if you don't mind someone being able to use up unused values but don't
want someone to be able to rewind the sequence and generate duplicate key
violations breaking the application?

--
greg

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-03-22 14:40:15 Re: pg 8.1.3 on AIX
Previous Message Tom Lane 2006-03-22 14:29:26 Re: back slash separated values