Re: MERGE vs REPLACE

Поиск
Список
Период
Сортировка
От mark@mark.mielke.cc
Тема Re: MERGE vs REPLACE
Дата
Msg-id 20051111233657.GA13724@mark.mielke.cc
обсуждение исходный текст
Ответ на Re: MERGE vs REPLACE  (Rod Taylor <pg@rbt.ca>)
Ответы Re: MERGE vs REPLACE  (Rod Taylor <pg@rbt.ca>)
Список pgsql-hackers
On Fri, Nov 11, 2005 at 06:00:32PM -0500, Rod Taylor wrote:
> So? That is what save points are for.  You can even skip the select for
> update if you don't mind dead tuples from the attempted insert.
> SELECT ... FOR UPDATE;
> IF not exists THEN
>     SAVEPOINT;
>     INSERT ;
>     IF UNIQUE VIOLATION THEN
>         /* Someone else inserted between the SELECT and our INSERT */
>         ROLLBACK TO SAVEPOINT;
>         UPDATE;
>     ELSE
>         RELEASE SAVEPOINT;
>     FI
> ELSE
>     UPDATE;
> FI

Isn't there still a race between INSERT and UPDATE?

Low probability, for sure, as it would have had to not exist, then
exist, then not exist, but still possible.

I'd like a REPLACE that could be safe, or at least cause a COMMIT to
fail, for this reason.

Cheers,
mark

-- 
mark@mielke.cc / markm@ncf.ca / markm@nortel.com     __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada
 One ring to rule them all, one ring to find them, one ring to bring them all                      and in the darkness
bindthem...
 
                          http://mark.mielke.cc/



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

Предыдущее
От: Gavin Sherry
Дата:
Сообщение: Re: MERGE vs REPLACE
Следующее
От: "Eric Lauzon"
Дата:
Сообщение: (View and SQL) VS plpgsql