Re: serial increments on failed insert

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: serial increments on failed insert
Дата
Msg-id 20050115015343.GA54856@winnie.fuhr.org
обсуждение исходный текст
Ответ на serial increments on failed insert  (David Kammer <djkammer@u.washington.edu>)
Список pgsql-general
On Fri, Jan 14, 2005 at 04:57:19PM -0800, David Kammer wrote:

> Notice that even though the second insert failed, it still incremented
> the serial value.  This seems counter intuative to the way that serial
> should work.  Is this truly a bug, or is there a good work around?

See the "Sequence Manipulation Functions" section in the "Functions
and Operators" chapter of the documentation.  The page contains
the following note:

    Important:  To avoid blocking of concurrent transactions that obtain
    numbers from the same sequence, a nextval operation is never rolled
    back; that is, once a value has been fetched it is considered used,
    even if the transaction that did the nextval later aborts.  This
    means that aborted transactions may leave unused "holes" in the
    sequence of assigned values.  setval operations are never rolled
    back, either.

Sequences are for obtaining numbers guaranteed to be unique; other
assumptions about their behavior are probably unwarranted.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

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

Предыдущее
От: Steve Atkins
Дата:
Сообщение: Re: serial increments on failed insert
Следующее
От: Tatsuo Ishii
Дата:
Сообщение: Re: pgpool