that error is correct:
> CREATE TABLE test.test
> a int4 NOT NULL DEFAULT nextval('test.test_a_seq'::regclass),
> CONSTRAINT pk PRIMARY KEY (a)
> WITHOUT OIDS;
> And then try an update:
> lstore=> select * from test.test;
> lstore=> update test.test set a = a + 2 where a >= 3;
> ERROR: duplicate key violates unique constraint "pk"
it starts anywhere in the table and updates line by line. So if it starts
with, say, a=4, it trys to set a=4+2, giving 6 which is allready present.
possible solution: create a temp table from a select with that a+x, and then
freshen your data from there.
On a side node ... if you have to change your PRIMARY KEY in this fashion,
there is propably a design error within your database scheme / application.
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
PostgreSQL - supported by a community that does not put you on hold
In response to
pgsql-bugs by date
|Next:||From: T.J. Ferraro||Date: 2006-04-15 13:56:13|
|Subject: Re: BUG #2393: update fails with unique constraint violation|
|Previous:||From: Peter Brant||Date: 2006-04-14 19:48:06|
|Subject: Re: Permission denied on fsync / Win32 (was right|