From: | Roman Neuhauser <neuhauser(at)sigpipe(dot)cz> |
---|---|
To: | David Fetter <david(at)fetter(dot)org> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: set-level update fails with unique constraint violation |
Date: | 2010-01-02 08:40:42 |
Message-ID: | 20100102084041.GD1484@isis.sigpipe.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
# david(at)fetter(dot)org / 2009-12-31 08:04:58 -0800:
> On Thu, Dec 31, 2009 at 10:52:20AM +0100, neuhauser+pgsql-general#postgresql(dot)org(at)sigpipe(dot)cz wrote:
> > Hello,
> >
> > this fails with "duplicate key value":
> >
> > CREATE TABLE x (
> > i INT NOT NULL UNIQUE
> > );
> > INSERT INTO x (i) VALUES (1), (2), (3);
> > UPDATE x SET i = i + 1;
> >
> > are there any plans to make this work?
>
> This will work in 8.5:
>
> CREATE TABLE x (
> i int NOT NULL UNIQUE DEFERRABLE INITIALLY DEFERRED
> );
> INSERT INTO x (i) VALUES (1), (2), (3);
> UPDATE x SET i = i + 1;
thanks, this might be a bearable workaround in some cases
provided there's also SET CONSTRAINTS ... DEFERRED / IMMEDIATE.
what I really want is a mode that fires the constraint check
at the end of the statement.
--
Roman Neuhauser
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Cave-Ayland | 2010-01-02 09:33:12 | Re: Error during make when installing geos for postgis install...still trying |
Previous Message | Tom Lane | 2010-01-02 00:00:14 | Re: Looking for professionals for a PG server move |