Re: is an explicit lock necessary? - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: is an explicit lock necessary?
Date
Msg-id 20060504114708.I61331@megazone.bigpanda.com
Whole thread Raw
In response to is an explicit lock necessary?  (Ash Grove <ash_grv7@yahoo.com>)
List pgsql-sql
On Thu, 4 May 2006, Ash Grove wrote:

> Hi,
>
> Does beginning a transaction put locks on the tables
> queried within the transaction?
>
> In the example below, is #2 necessary? My thought was
> that I would need to use an explicit lock to make sure
> that the sequence value I'm selecting in #4 is the
> same one that is generated from #3. I'm worried about
> another instance of the application doing an insert on
> table1 between #3 and #4.

If you have 1 session per instance and #3 and #4 are done after each
other without any intervening commands, the behavior of nextval/currval
should guarantee that (currval gives the value from this session's
nextval, not any other).



pgsql-sql by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: is an explicit lock necessary?
Next
From: Ragnar
Date:
Subject: Re: is an explicit lock necessary?