Postgres unique index checking and atomic transactions

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Postgres unique index checking and atomic transactions
Дата
Msg-id 871xwfrivu.fsf@stark.dyndns.tv
обсуждение исходный текст
Ответы Re: Postgres unique index checking and atomic transactions  ("scott.marlowe" <scott.marlowe@ihs.com>)
Re: Postgres unique index checking and atomic transactions  (Mike Mascari <mascarm@mascari.com>)
Re: Postgres unique index checking and atomic transactions  (Dmitry Tkach <dmitry@openratings.com>)
Список pgsql-general
So I have to adjust a primary key by adding one to every existing record.
Obviously this isn't a routine operation, my data model isn't that messed up.
It's a one-time manual operation.

However when I tried to do the equivalent of:

  update tab set pk = pk + 1

I got

  ERROR:  Cannot insert a duplicate key into unique index tab_pkey

Is that right? Obviously after completing the query there would be no
duplicate keys. Is this a case where I would need deferred constraints to
allow this? Even for immediate constraints shouldn't a single sql update be
able to go ahead as long as it leaves things in a consistent state?

--
greg

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

Предыдущее
От: nolan@celery.tssi.com
Дата:
Сообщение: Re: psql -et
Следующее
От: Andrew Ayers
Дата:
Сообщение: Re: Limited varchar, unlimited varchar, or text?