Detect Locked Row Without Blocking

From: Joe Lester <joe_lester(at)sweetwater(dot)com>
To: postgres list <pgsql-general(at)postgresql(dot)org>
Subject: Detect Locked Row Without Blocking
Date: 2005-11-08 13:53:50
Message-ID: b88164e8e1d59d4801253516ae3987a3@sweetwater.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is there a recommended "postgres way" to determine if a certain row is
locked... without blocking?

In my custom postgres client app I'd like to be able to determine if
another user is "modifying" a given record. If so, I would present a
dialog to the user such as "Record Locked. Sam Smith is already
modifying this record. Try again later."

I've looked at SELECT FOR UPDATE which looks good except for that it
blocks. I don't want my UI to freeze up... I just want to notify the
user that it's locked and move on. Any thoughts?

Thanks.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gerard O Connor 2005-11-08 14:09:43 Re: [ANNOUNCE] PostgreSQL 8.1.0 Release Candidate 1
Previous Message Richard Huxton 2005-11-08 13:48:26 Re: Beyond the 1600 columns limit on windows