Re: Select for update

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Select for update
Дата
Msg-id 1549336.1622050610@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Select for update  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-sql
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wed, May 26, 2021, 08:20 Yambu <hyambu@gmail.com> wrote:
>> UPDATE table1 set status_id=13 WHERE id= ( SELECT id FROM table2 where
>> status_id=1 LIMIT 1 *FOR UPDATE*) RETURNING id into v_id;

> I don't think there is a point in saying for update when you are executing
> an update command.

The FOR UPDATE is in a subselect, so what it's doing is locking
rows of table2.  That seems fairly sensible if what you want to
do is make sure those rows don't change before the UPDATE
commits.

            regards, tom lane



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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Select for update
Следующее
От: Ron Clarke
Дата:
Сообщение: Postgresql - Json syntax in INSERT RETURNING clause with INTO