From: Luis Neves <lneves@netcabo.pt>
To: pgsql-sql@postgresql.org
Subject: Strange behaviour updating primary key column.
Date: Mon, 21 Jun 2004 07:29:06 +0100
Message-ID: <200406210729.07185.lneves@netcabo.pt> (raw)
[Sorry if this is a double post.]
Hello all,
[Postgresql 7.4.2]
CREATE TABLE "story" (
"id" int4 NOT NULL,
"title" varchar (100) NOT NULL,
"body" text NOT NULL,
"entryDate" timestamptz NOT NULL,
CONSTRAINT "story_pkey" PRIMARY KEY (id)
);
In the above table why does the query:
UPDATE "story"
SET id = (id + 1500);
fails with:
"ERROR: duplicate key violates unique constraint 'story_pkey'"
(I have 6000 records in the table with "id" spanning from 1 to 6000)
I find this behaviour strange, SQL is a set based language, but
PostgreSQL is acting like is changing the values in sequence.
Can anyone with a better understanding of PostgreSQL explain to me why this
happens?
Are my expectations wrong?
Best regards,
Luis Neves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: lneves@netcabo.pt
Subject: Re: Strange behaviour updating primary key column.
In-Reply-To: <200406210729.07185.lneves@netcabo.pt>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox