Search Postgresql Archives

Re: a SELECT FOR UPDATE question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux