Re: Proper Method for using LockAcquire - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Proper Method for using LockAcquire
Date
Msg-id 20060713185305.GD14177@svana.org
Whole thread Raw
In response to Proper Method for using LockAcquire  (Chris Bowlby <excalibur@accesswave.ca>)
List pgsql-hackers
On Thu, Jul 13, 2006 at 03:01:31PM -0300, Chris Bowlby wrote:
> Hi All,
>
> I've been working on a small module that I will be pluging into my
> local PostreSQL 8.x database and am in need of doing some table locking.
> At this time, I've used various other examples to no avail and was
> wondering what the proper method for aquiring a table lock within the
> module would be?

Firstly, why? Most operations in PostgreSQL acquire the appropriate
locks for you, so you don't need to do it yourself. Explicit locking
opens you up to deadlocks.

Secondly, what's wrong with LockRelation(rel, lockmode)? I grabbed that
from relation_open in access/heap/heapam.c.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Proper Method for using LockAcquire
Next
From: "Marc G. Fournier"
Date:
Subject: Re: Three weeks left until feature freeze