Re: Solution to UPDATE...INSERT problem

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Solution to UPDATE...INSERT problem
Дата
Msg-id 9715.1048749208@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Solution to UPDATE...INSERT problem  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
Список pgsql-hackers
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
>> Uh, why exactly do you think this is race-free?

> How about:

> INSERT INTO table SELECT 1, 'foo' WHERE NOT EXISTS (SELECT TRUE FROM table
> WHERE pkcol=1 FOR UPDATE);

> It's a lot more straightforward and has a FOR UPDATE.  Can this still cause
> unique constraint failures?

Certainly.  FOR UPDATE locks an existing row; it cannot lock the
condition of non-existence of a row.
        regards, tom lane



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

Предыдущее
От: "Christopher Kings-Lynne"
Дата:
Сообщение: Re: Solution to UPDATE...INSERT problem
Следующее
От: Hiroshi Inoue
Дата:
Сообщение: Re: updateable cursors & visibility