Updates not atomic with respect to indexes

From: Ben Young <ben(at)transversal(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Updates not atomic with respect to indexes
Date: 2004-04-28 08:33:34
Message-ID: 200404280933.34378.ben@transversal.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there, I am having a problem with the following code:

CREATE TABLE temp ( num integer UNIQUE );

INSERT INTO temp (num) VALUES (1);
INSERT INTO temp (num) VALUES (2);
INSERT INTO temp (num) VALUES (3);

UPDATE temp SET num = num+1;

If the update is really meant to be atomic then this should work, as the
column is still unique afterwards. However, I get a
ERROR: duplicate key violates unique constraint "temp_num_key"

Is this something I misunderstand about SQL & ACID in general, a known problem
in Posgresql, or bug which will be fixed sometime. Should I report this as a
bug?

Thanks for your help in advance!

Ben Young

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Sidney-Woollett 2004-04-28 09:00:31 Re: Updates not atomic with respect to indexes
Previous Message Mark Kirkwood 2004-04-28 08:10:53 Re: TPC H data