Re: pg_locks "at-a-glance" view - Mailing list pgsql-general

From David Fetter
Subject Re: pg_locks "at-a-glance" view
Date
Msg-id 20080619130709.GA30331@fetter.org
Whole thread Raw
In response to pg_locks "at-a-glance" view  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: pg_locks "at-a-glance" view  ("Merlin Moncure" <mmoncure@gmail.com>)
Re: pg_locks "at-a-glance" view  (Jeff Davis <pgsql@j-davis.com>)
Re: pg_locks "at-a-glance" view  (Decibel! <decibel@decibel.org>)
List pgsql-general
On Wed, Jun 18, 2008 at 05:39:59PM -0700, Jeff Davis wrote:
> I was trying to create a more "at-a-glance" view of the pg_locks table.
> I included the SQL I came up with (after talking to Merlin) at the
> bottom of this message.
>
> The idea is to show any queries that are waiting on a lock, and the
> query that currently holds the lock on which those queries are waiting.
>
> Is my logic correct?

I'm not exactly sure, but it appears to match, at first blush, what's
in src/backend/storage/lmgr/lock.c:
    static const LOCKMASK LockConflicts[] = {

> Does anyone have any suggestions?

The function could be in SQL, with one minor bit in PL/PgSQL.  File
attached.

> I couldn't find a generally accepted way to do this, although I'm sure
> someone must have done something like this before.

There's stuff in the aforementioned lock.c, but I don't see anything
visible to SQL.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Attachment

pgsql-general by date:

Previous
From: Steve Clark
Date:
Subject: Re: renumber table
Next
From: Dimitri Fontaine
Date:
Subject: Re: Inter-app communication via DB