Re: Solution to UPDATE...INSERT problem

Поиск
Список
Период
Сортировка
От Christopher Kings-Lynne
Тема Re: Solution to UPDATE...INSERT problem
Дата
Msg-id 001901c2f42d$e8fd5f60$6500a8c0@fhp.internal
обсуждение исходный текст
Ответ на Solution to UPDATE...INSERT problem  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
Ответы Re: Solution to UPDATE...INSERT problem  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
> Uh, why exactly do you think this is race-free?
>
> It looks fancy, but AFAICS the SELECT will return info that is correct
> as of its starting timestamp; which is not enough to guarantee that the
> INSERT won't conflict with another transaction doing the same thing
> concurrently.

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?

Chris



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Solution to UPDATE...INSERT problem
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Solution to UPDATE...INSERT problem