Unix Technical Forum

Table Truncate and Locks

This is a discussion on Table Truncate and Locks within the pgsql Admins forums, part of the PostgreSQL category; --> What sort of lock does truncate require? If it is not an access exclusive lock, what locks would block ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 07:41 AM
Chris Hoover
 
Posts: n/a
Default Table Truncate and Locks

What sort of lock does truncate require? If it is not an access exclusive
lock, what locks would block the truncate?

Thanks,

Chris

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 07:41 AM
Mathias Laurent
 
Posts: n/a
Default SELECT FOR UPDATE NOWAIT

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/


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 07:41 AM
Jim C. Nasby
 
Posts: n/a
Default Re: SELECT FOR UPDATE NOWAIT

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)

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:53 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com