Controlling access to Sequences

From: Matthew Horoschun <mhoroschun(at)canprint(dot)com(dot)au>
To: pgsql-sql(at)postgresql(dot)org
Subject: Controlling access to Sequences
Date: 2003-01-31 12:47:27
Message-ID: 2759DB60-351A-11D7-92E5-000393B3A702@canprint.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi All,

I'm implementing a system where I need to be reasonably careful about
security. One thing that worries me is SEQUENCES.

My understanding is that I need to GRANT the UPDATE privilege on the
SEQUENCE if I want a user to be able to to use nextval() on it. The
trouble is, if they can do a nextval() they can also do a setval()
which would allow them to set the sequence to any value they felt like
and potentially cause problems for other user's use of the SEQUENCE.

I've considered forcing the user to use the nextval() by using a RULE
on a VIEW, but it appear as though the nextval() function still runs as
the logged-in user not the owner of the VIEW.

Is there any effective method for controlling access to a SEQUENCE? or
should I do something like in the view:

INSERT INTO x VALUES ( ( SELECT MAX( id ) + 1 FROM x ), some_field );

Is this safe to do? Or might this lead to undesirable problems if
called concurrently?

Any assistance would be appreciated.

Matthew.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Huub 2003-01-31 14:42:45 Server access thru webmin
Previous Message PRAGATI SAVAIKAR 2003-01-31 11:29:29 Index File growing big.