On Mon, Feb 07, 2005 at 03:08:12PM -0800, Tim Vadnais wrote:
>
> If I select a row for update, is there anyway that someone can query to see
> if that row has been 'selected for update' and by whom?
I think you can infer that a process is working with a row in some
manner (UPDATE, SELECT FOR UPDATE) by looking at the row's xmax
column and checking pg_locks to see if any process is holding a
lock on the indicated transaction ID. But why do you need to know?
What are you trying to do?
> Then I'd like to know if the session that 'SELECT(ed) FOR UPDATE' dies, will
> the server release the locked row?
Locks should be released when the holding transaction terminates.
I'm not sure if it's possible for a connection to end and leave a
lock behind, but if it is, I suspect it would be considered a bug
in the server that needed to be fixed.
(This sounds familiar, like I've participated in a thread on this
topic before. I get the feeling Tom Lane is going to step in and
provide The Real Answer, and that my radio is about to start playing
"I Got You, Babe"....)
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/