From: Bruno Wolff III <bruno@wolff.to>
To: Markus Bertheau <twanger@bluetwanger.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: SELECT MAX(c) FROM (SELECT ... FOR UPDATE) AS foo
Date: Tue, 17 Aug 2004 09:12:29 -0500
Message-ID: <20040817141229.GA15770@wolff.to> (raw)
In-Reply-To: <1092740863.2627.17.camel@dicaprio.akademie1.de>
References: <1092740863.2627.17.camel@dicaprio.akademie1.de>
On Tue, Aug 17, 2004 at 13:07:43 +0200,
Markus Bertheau <twanger@bluetwanger.de> wrote:
> Hi,
>
> why is the following query not allowed:
>
> SELECT MAX(position) FROM (SELECT position FROM classes WHERE name =
> 'foo' FOR UPDATE OF classes) AS foo
>
> It's clear which rows should be locked here, I think.
Even if it was allowed, it probably wouldn't be good enough because it won't
protect against newly inserted records. You really want to lock the table
against concurrent updates when doing this if concurrent updates can cause
a problem. You really want predicate locking, to lock any old or new rows
with name = 'foo', but postgres doesn't have that capability.
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: bruno@wolff.to, twanger@bluetwanger.de
Subject: Re: SELECT MAX(c) FROM (SELECT ... FOR UPDATE) AS foo
In-Reply-To: <20040817141229.GA15770@wolff.to>
* 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