Re: a SELECT FOR UPDATE question

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: a SELECT FOR UPDATE question
Дата
Msg-id 20050208010941.GA43902@winnie.fuhr.org
обсуждение исходный текст
Ответ на a SELECT FOR UPDATE question  (Tim Vadnais <tvadnais@bwks.com>)
Ответы Re: a SELECT FOR UPDATE question
Список pgsql-general
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/


В списке pgsql-general по дате отправления:

Предыдущее
От: Steve Atkins
Дата:
Сообщение: Re: Creating an index-type for LIKE '%value%'
Следующее
От: Larry Rosenman
Дата:
Сообщение: Re: Creating an index-type for LIKE '%value%'