From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ludwig Lim <lud_nowhere_man@yahoo.com>
Cc: PostgreSQL Mailing List <pgsql-sql@postgresql.org>
Subject: Re: Simulating a SELECT..FOR UPDATE to LOCK and SELECT statement
Date: Thu, 24 Oct 2002 09:42:46 -0400
Message-ID: <11292.1035466966@sss.pgh.pa.us> (raw)
In-Reply-To: <20021024041032.93394.qmail@web80313.mail.yahoo.com>
References: <20021024041032.93394.qmail@web80313.mail.yahoo.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, lud_nowhere_man@yahoo.com
Subject: Re: Simulating a SELECT..FOR UPDATE to LOCK and SELECT statement
In-Reply-To: <11292.1035466966@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox