Re: SELECT FOR SHARE and FOR UPDATE

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
Cc: Ilja Golshtein <ilejn(at)yandex(dot)ru>, pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT FOR SHARE and FOR UPDATE
Date: 2005-10-08 02:35:44
Message-ID: 20051008023544.GA10866@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 07, 2005 at 09:18:00PM -0500, Jim C. Nasby wrote:
> On Fri, Oct 07, 2005 at 01:18:03PM +0400, Ilja Golshtein wrote:
> > I want to select data from two tables obtaining
> > exclusive lock for records of the first table and
> > nonexclusive lock for records of the second one.
> >
> > In other words, I need something like
> > select a.f, b.f from a,b for update of a for share of b.
>
> From http://www.postgresql.org/docs/8.0/interactive/sql-select.html:
> FOR UPDATE [ OF table_name [, ...] ]
>
> I'm assuming that the syntax is the same for FOR SHARE.

It sounds like Ilja wants to do both FOR UPDATE and FOR SHARE in
the same SELECT statement. According to the 8.1 documentation
that's not allowed:

http://developer.postgresql.org/docs/postgres/sql-select.html#SQL-FOR-UPDATE-SHARE

"It is currently not allowed for a single SELECT statement to include
both FOR UPDATE and FOR SHARE, nor can different parts of the statement
use both NOWAIT and normal waiting mode."

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Kings-Lynne 2005-10-08 07:52:52 Re: Shell script to extract a table from a plain text dump
Previous Message Qingqing Zhou 2005-10-08 02:34:52 Re: copy data between database