Re: duplicate key violates unique constraint

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: duplicate key violates unique constraint
Дата
Msg-id 13812.1178810921@sss.pgh.pa.us
обсуждение исходный текст
Ответ на duplicate key violates unique constraint  ("Spiegelberg, Greg" <gspiegelberg@isodxsolutions.com>)
Ответы Re: duplicate key violates unique constraint  ("Spiegelberg, Greg" <gspiegelberg@isodxsolutions.com>)
Список pgsql-admin
"Spiegelberg, Greg" <gspiegelberg@isodxsolutions.com> writes:
> As you can see, it's only providing the key1 column and the sequence is
> providing the value for the column with the constraint.  How can this be
> happening?

Perhaps at some point you manually inserted an id value past the
then-current sequence value?

> Now, I don't know if this just hasn't been tested or is a documented
> feature (a.k.a. bug) but something does not seem right here.  In this
> test case I'm able to get the same sequence ID's via two psql
> connections to the same database on the same sequence.

No, you've misunderstood currval().  That gives the value most recently
obtained by nextval() within your own session; it is not affected by any
subsequent manipulation of the sequence.

            regards, tom lane

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

Предыдущее
От: "Peter Koczan"
Дата:
Сообщение: Re: upgrade 8.0.3 -> 8.2.4
Следующее
От: "Mikko Partio"
Дата:
Сообщение: Re: duplicate key violates unique constraint