Re: serialization errors

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: serialization errors
Дата
Msg-id 20701.1043776040@sss.pgh.pa.us
обсуждение исходный текст
Ответ на serialization errors  (Ryan VanderBijl <rvbijl-pgsql@vanderbijlfamily.com>)
Ответы Re: serialization errors  (Ryan VanderBijl <rvbijl@vanderbijlfamily.com>)
Список pgsql-general
Ryan VanderBijl <rvbijl-pgsql@vanderbijlfamily.com> writes:
> There are many reasons that the INSERT statement could fail (e.g. syntax,
> database connection dropped, conflicting concurrent update, unique constraint).

An INSERT statement can *never* fail because of a concurrent conflicting
update, because it isn't an update.  Any INSERT is, logically speaking,
creating a unique new entity (row) in the database; there is no conflict
against other insertions, unless by way of violation of a unique constraint.

> If I receive the legal error "duplicate key" error, how am I supposed to
> detect if that error is due to a concurrent update, or because of some
> other error elsewhere?

What difference does it make if the other guy got there ten microseconds
or ten years earlier?  He inserted before you did.  Whether it's
"concurrent" or not shouldn't matter that I can see.  Perhaps more to
the point, there is no reason to expect that a duplicate-key failure
will succeed if you retry the same insertion.

            regards, tom lane

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

Предыдущее
От: Tilo Schwarz
Дата:
Сообщение: Q: Rename constraint
Следующее
От: Gordan Bobic
Дата:
Сообщение: How do I unsubscribe?