Re: Updates not atomic with respect to indexes

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: Ben Young <ben(at)transversal(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Updates not atomic with respect to indexes
Date: 2004-04-28 09:34:44
Message-ID: ncuu809i4hk7bt2qd644mp79icsprdhbkv@email.aon.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 28 Apr 2004 09:33:34 +0100, Ben Young <ben(at)transversal(dot)com>
wrote:
>UPDATE temp SET num = num+1;
>ERROR: duplicate key violates unique constraint "temp_num_key"

>Is this [...] a known problem in Posgresql,

Yes.

> or bug which will be fixed sometime.

Don't know.

If you need a workaround for now, do it in two steps:

UPDATE temp SET num = -num;
UPDATE temp SET num = -num+1;

This assumes you have a range of numbers that is normally not used.

Servus
Manfred

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ian Ribas 2004-04-28 12:11:36 Optimizer choosing smaller index instead of right one
Previous Message Bogdan Vatkov 2004-04-28 09:33:15 BUG ? or SQL miss understanding ?