Re: UPDATE w/ subselect doing locking

Поиск
Список
Период
Сортировка
От Brent Verner
Тема Re: UPDATE w/ subselect doing locking
Дата
Msg-id 20011115151841.A3393@rcfile.org
обсуждение исходный текст
Ответ на Re: UPDATE w/ subselect doing locking  (David Ford <david@blue-labs.org>)
Список pgsql-general
On 15 Nov 2001 at 12:12 (-0500), David Ford wrote:
| Yes, I know that works.  I want to figure out how to use SELECT ... FOR
| UPDATE with UPDATE because I will have a need to lock these certain rows
| and do a bit more than just 'count'.

AFAIK, you need to do the following the use the SELECT ... FOR UPDATE

 BEGIN;
  SELECT ... FOR UPDATE;
  UPDATE ... SET ...;
 COMMIT;

Any other session attempting an update on the selected for update rows
will block on the locked rows until the end of that xact.

hth.
  brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing."  -- Duane Allman

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

Предыдущее
От: Fernando San Martín Woerner
Дата:
Сообщение: Create Rule
Следующее
От: Peter Losher
Дата:
Сообщение: Compiling v7.1.3 w/OpenSSL and Krb5 support...