Braum Meakes <braum@telus.net> writes:
> I have a function that I've written in plpgsql. In it I lock a table
> before selecting a value and, depending on the value, either update the
> record selected or insert a new one. It works perfectly when I run it as a
> super-user or as the owner of the table. However, as a standard user I am
> unable to lock the table.
[ eyeballs code ] LOCK ... IN ACCESS SHARE MODE (ie, read lock)
requires SELECT privileges; all stronger forms of LOCK require UPDATE
and/or DELETE privileges. This seems to be undocumented :-(. Am
fixing the LOCK reference page now.
Per subsequent discussion, it's not real clear that you need LOCK at
all ... but the docs need to explain the privilege rules, since they're
not exactly obvious.
regards, tom lane