pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
SELECT FOR UPDATE NOWAIT
2+ messages / 2 participants
[nested] [flat]

* SELECT FOR UPDATE NOWAIT
@ 2006-09-28 15:26  Mathias Laurent <e1lauren@hotmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Mathias Laurent @ 2006-09-28 15:26 UTC (permalink / raw)
  To: pgsql-admin

If I do :
Session 1:
decibel=# begin;
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 !

_________________________________________________________________
Windows Live Messenger sur i-modeā„¢ : dialoguez avec vos amis depuis votre 
mobile comme sur PC ! http://mobile.live.fr/messenger/bouygues/




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: SELECT FOR UPDATE NOWAIT
@ 2006-09-28 19:23  Jim C. Nasby <jim@nasby.net>
  parent: Mathias Laurent <e1lauren@hotmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Jim C. Nasby @ 2006-09-28 19:23 UTC (permalink / raw)
  To: Mathias Laurent <e1lauren@hotmail.com>; +Cc: 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@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-09-28 19:23 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-09-28 15:26 SELECT FOR UPDATE NOWAIT Mathias Laurent <e1lauren@hotmail.com>
2006-09-28 19:23 ` Jim C. Nasby <jim@nasby.net>

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