Re: BUG or strange behaviour of update on primary key

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG or strange behaviour of update on primary key
Дата
Msg-id 20984.1318892356@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG or strange behaviour of update on primary key  (desmodemone <desmodemone@gmail.com>)
Ответы Re: BUG or strange behaviour of update on primary key
Список pgsql-hackers
desmodemone <desmodemone@gmail.com> writes:
> create table testup ( a int ) ;

> alter table testup add primary key (a ) ;

> insert into testup values (1);

> insert into testup values (2);

>  update  testup set a=a+1 ;
> ERROR:  duplicate key value violates unique constraint "testup_pkey"
> DETTAGLI: Key (a)=(2) already exists.

If you want that to work reliably, you need to mark the primary key
constraint as deferred.  By default, uniqueness is checked immediately
when a row is inserted or updated --- and here, when you update 1 to 2,
it's not unique because the second row hasn't been visited yet.
        regards, tom lane


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

Предыдущее
От: desmodemone
Дата:
Сообщение: BUG or strange behaviour of update on primary key
Следующее
От: desmodemone
Дата:
Сообщение: Re: BUG or strange behaviour of update on primary key