Re: most idiomatic way to "update or insert"?

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: most idiomatic way to "update or insert"?
Дата
Msg-id 871xili91z.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на Re: most idiomatic way to "update or insert"?  (Matteo Beccati <php@beccati.com>)
Список pgsql-general
Matteo Beccati <php@beccati.com> writes:

> I added the error check with a second UPDATE try after INSERT to increase
> accuracy. In fact, INSERTs were sometimes failing because of concurrency, and
> this was the only viable solution I found to avoid losing data.

in the general case you could have someone else delete the record again before
you get the chance to update it again. to handle this case you would actually
have to make it a loop.

this is the main reason a built-in merge command could be nice, it would avoid
the need to loop, since it can take the lock on the existing record if it's
there or perform the insert if not.

--
greg

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

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: PQunescapeBytea Question
Следующее
От: ruben
Дата:
Сообщение: Slow after VACUUM, fast after DROP-CREATE INDEX