Re: duplicate key violates unique on a nextval() field

Поиск
Список
Период
Сортировка
От Scott Ribe
Тема Re: duplicate key violates unique on a nextval() field
Дата
Msg-id 2EB07ECE-7EC9-48C7-9B1C-A308B5CDA90D@elevated-dev.com
обсуждение исходный текст
Ответ на duplicate key violates unique on a nextval() field  (Peter Warasin <peter@endian.com>)
Ответы Re: duplicate key violates unique on a nextval() field  (Peter Warasin <peter@endian.com>)
Список pgsql-general
On Aug 30, 2011, at 10:19 AM, Peter Warasin wrote:

> The message tells me furthermore that freeradius tries to insert a
> record with a radacctid which already exists.
>
> But how can that happen when it is bigserial?

Postgres only assigns the value if it is not explicitly provided. Any client, freeradius included, could be assigning
idsand could have bugs. Allowing pg to assign the value is safe, using nextval is safe--I'd look for client code that
triesto get ranges ahead of time & cache... 

> The error message posted above tells me that the insert statement does
> even not succeed after the reconnect. (failed after reconnect)

If freeradius is trying to insert a record with an id that already exists, after a re-connect there's no reason at all
toassume that the previously existing record is gone and that the insert with the same id will now succeed. 

That DDL is also kind of nasty... Why the big effort to set the sequence to 1 immediately after creating the table? Why
thecreation of a unique index when the "primary key" attribute already causes a unique index to be created on the id?
Ugh.

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice





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

Предыдущее
От: Peter Warasin
Дата:
Сообщение: duplicate key violates unique on a nextval() field
Следующее
От: JD Wong
Дата:
Сообщение: IDLE queries taking up space