Re: [Q] Sequences, last_value and inserts

Поиск
Список
Период
Сортировка
От Gregory Wood
Тема Re: [Q] Sequences, last_value and inserts
Дата
Msg-id 01f101c281e7$fbf65ad0$7889ffcc@comstock.com
обсуждение исходный текст
Ответ на Re: [Q] Sequences, last_value and inserts  ("Marie G. Tuite" <marie.tuite@edisonaffiliates.com>)
Список pgsql-general
> select last_value from domain_info_tbl_key_seq;
>
> This returns the same value as currval.

In most cases, yes. However:

"Also, last_value will reflect the latest value reserved by any backend,
whether or not it has yet been returned by nextval."

http://www.postgresql.org/idocs/index.php?sql-createsequence.html

It is possible that someone else has changed the sequence value before you
read it, meaning you will not get the value you just inserted (like you
would with currval), but the value of the *other* insert.

This is precisely the problem that the original question was posed to avoid.

Greg



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

Предыдущее
От: "Marie G. Tuite"
Дата:
Сообщение: Re: [Q] Sequences, last_value and inserts
Следующее
От: "Paul Ottar Tornes"
Дата:
Сообщение: Norwegian Letters