Re: Partial update on an postgres upsert violates constraint

Поиск
Список
Период
Сортировка
От John R Pierce
Тема Re: Partial update on an postgres upsert violates constraint
Дата
Msg-id 88657daf-fa5c-d728-93b6-d53dcfb10abd@hogranch.com
обсуждение исходный текст
Ответ на Re: Partial update on an postgres upsert violates constraint  (Andreas Terrius <gotenwinz99@gmail.com>)
Список pgsql-general
On 11/21/2016 2:32 AM, Andreas Terrius wrote:
> Is there any way to check whether the row already exists before
> checking constraints ? I still want it to fail if it turns out to be a
> new row (which would violate the not null constraint), but updates the
> row if it already exists.

just do an update.  if the row doesn't exist, it will fail, you then
rollback the transaction or savepoint.

> Since if that is not possible, I would need to do a query to determine
> whether the row exists in the database which kinda eliminates the use
> of upsert. (in this case, partial upsert).

in general, anything that relies on those sorts of checks will fail
under concurrent loads.



--
john r pierce, recycling bits in santa cruz



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

Предыдущее
От: Scott Mead
Дата:
Сообщение: Re: Methods to quiesce PostgreSQL DB without configuring log archival
Следующее
От: Israel Brewster
Дата:
Сообщение: Backup "Best Practices"