Re: Can I prevent a sequence from being updated when a transaction fail?

Поиск
Список
Период
Сортировка
От Haroldo Stenger
Тема Re: Can I prevent a sequence from being updated when a transaction fail?
Дата
Msg-id 393AEFA5.9CA8EDD6@adinet.com.uy
обсуждение исходный текст
Ответ на Can I prevent a sequence from being updated when a transaction fail?  (Thomas Holmgren <thm@cs.auc.dk>)
Список pgsql-general
Thomas Holmgren wrote:
> How come sequences are not rolled back when a transaction is aborted, and
> can I do anything to prevent a failing statement from updating the
> involved sequence?

No. You can't. To achieve what you want, the sequence counter should be
locked. That would mean that parallel insertions in the same table from
other transactions, should wait for the first to end. And that is not
acceptable.

If you don care about it, i.e., either your aplication never inserts
parallelly in a table, or a second insert can wait for the first to end,
then use your own counter in an auxiliary table. This will do what you
asked.

Haroldo.

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

Предыдущее
От: Thomas Holmgren
Дата:
Сообщение: Can I prevent a sequence from being updated when a transaction fail?
Следующее
От: Lincoln Yeoh
Дата:
Сообщение: Re: index problem