Re: SELECT FOR UPDATE NOWAIT

From: "Jim C(dot) Nasby" <jim(at)nasby(dot)net>
To: Mathias Laurent <e1lauren(at)hotmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: SELECT FOR UPDATE NOWAIT
Date: 2006-09-28 19:23:17
Message-ID: 20060928192317.GY34238@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Thu, Sep 28, 2006 at 03:26:36PM +0000, Mathias Laurent wrote:
> If I do :
> Session 1:
> decibel=# begin;

Does decibel have some meaning in some language other than english?

> BEGIN
> decibel=# select * from i where i=1 for update nowait;
> i
> ---
> 1
> (1 row)
>
> decibel=# begin;
> BEGIN
> decibel=# select * from i where i=2 for update nowait;
> i
> ---
> 2
> (1 row)
>
> Session 2 :
>
> decibel=# select * from i where i=1 for update nowait;
> ERROR: could not obtain lock on row in relation "i"
> decibel=# select * from i where i=3 for update nowait;
> ERROR: current transaction is aborted, commands ignored until end of
> transaction block
> decibel=# ==> Why ? :'(
>
> Why i can't do any "Select for update" (current transaction aborted) after
> having receive a not obtain lock ???
> Thank you for your answer !

Because as soon as there is an error in a transaction, the entire
transaction is void. You have to rollback the transaction (or return to
a savepoint).
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Jim C. Nasby 2006-09-28 19:29:10 Re: transaction id wraparound
Previous Message Brad Nicholson 2006-09-28 19:18:05 Re: What Are Last Steps Performed When PostgreSQL