Re: Proper Method for using LockAcquire

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Chris Bowlby <excalibur(at)accesswave(dot)ca>
Cc: pgsql-hackers list <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proper Method for using LockAcquire
Date: 2006-07-13 18:53:05
Message-ID: 20060713185305.GD14177@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2006-07-13 18:54:26 Re: Three weeks left until feature freeze
Previous Message Tom Lane 2006-07-13 18:49:47 Re: Proper Method for using LockAcquire