Ludwig Lim <lud_nowhere_man@yahoo.com> writes:
> Is there a way to emulate a SELECT..FOR UPDATE to
> series of LOCK/SELECT statement.
No. LOCK can only acquire table-level locks; the point of SELECT FOR
UPDATE is to acquire row-level locks.
> I am surprised because according to the docs
> (version 7.2), it says:
> ROW SHARE MODE
> Note: Automatically acquired by SELECT ... FOR
> UPDATE.
SELECT FOR UPDATE gets a table-level lock just to ensure that the table
doesn't disappear from under it while it's doing its scan. The ROW
SHARE lock is pretty weak though, and doesn't block anything less
drastic than DROP/ALTER TABLE or VACUUM FULL.
The 7.3 development docs are perhaps clearer about this; try
http://developer.postgresql.org/docs/postgres/explicit-locking.html
regards, tom lane