Re: [HACKERS] select order by for update

Поиск
Список
Период
Сортировка
От Vadim Mikheev
Тема Re: [HACKERS] select order by for update
Дата
Msg-id 375FD687.6D9394AB@krs.ru
обсуждение исходный текст
Ответ на Re: [HACKERS] select order by for update  ("Mark Wright" <mwright@pro-ns.net>)
Список pgsql-hackers
Mark Wright wrote:
> 
> |SELECT * FROM test_attendees
> |WHERE print_status = 'R'
> |AND id_number = (select min(id_number) from test_attendees  )
   ^^^
 
Ops - add "AND print_status = 'R'" here!

> |FOR UPDATE OF test_attendees
> |
> |and run it in loop.
> 
> That would only work the first time, since after updating print_status to
> 'C', the record where id_number = (select min(id_number) from
> test_attendees) would no longer have print_status = 'R', so no records would
> match the query.

And this is why I said "run select in loop": if no one row will
be returned (i.e. row returned by subselect is already updated
by concurrent xaction) then re-run select!

Vadim


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