From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | jacekp(at)poczta(dot)wprost(dot)pl |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: update vs unique index |
Date: | 2005-07-25 16:52:49 |
Message-ID: | 20050725165249.GA29395@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Mon, Jul 25, 2005 at 05:58:43AM -0700, jacekp(at)poczta(dot)wprost(dot)pl wrote:
> I can imagine why it fails. Update operates on first row, making 2 out
> of 1 and that collides with second row (which has 2 as its value
> already). However, when you look at the update efect as a whole
> uniqueness is preserved, so index schould not veto update.
>
> My question is: is there a chance to bypass this behaviour? Something
> like controlling the order in which rows go into update. If update
> would start from last row, it would be successful for sure.
Yeah, this is a known limitation. Usual workaround is issue two
updates instead of one,
update foo set a = -a where <condition>;
update foo set a = -a + 1 where <condition>;
The point is to move all unique keys to an unused interval and then
move them back, changed all at a time.
It'll eventually be fixed, but don't hold your breath.
--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"No hay ausente sin culpa ni presente sin disculpa" (Prov. francés)
From | Date | Subject | |
---|---|---|---|
Next Message | Christian Rusa | 2005-07-25 17:31:11 | Closes Match |
Previous Message | Bruno Wolff III | 2005-07-25 16:14:35 | Re: int to date |