pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stuart Rison <rison@biochemistry.ucl.ac.uk>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: [GENERAL] UPDATE feature or bug?
Date: Wed, 22 Sep 1999 13:35:51 +0100 (BST)
Message-ID: <Pine.LNX.4.10.9909221327290.23732-100000@bsmlx17> (raw)

Dear all,

Consider the following table;

functions=> select * from prova order by a,b,c,d;
a|b|c|d
-+-+-+-
4|0|0|0
4|1|0|0
4|1|1|0
4|1|2|0
4|1|3|0
4|1|4|0
4|3|0|0
4|3|1|0
4|3|2|0
4|4|0|0
4|4|1|0
4|4|2|0
4|4|3|0
(13 rows)

with a unique index on (a,b,c,d)

and note that there is a gap in the continuity of b (from 4.1 to 4.3).

If I try

UPDATE prova SET b=b-1 WHERE b>2;

I get:

ERROR:  Cannot insert a duplicate key into a unique index

but if I try:

functions=> update prova set b=b-1 where b=3;
UPDATE 3
functions=> update prova set b=b-1 where b=4;
UPDATE 4

it works.

Now I've sussed this out as the update must be dealing with rows where b=4
first, trying to UPDATE them to b=3 and failing because these are already
'occupied'.

Is this a bug? is this a feature? is there a way of telling the UPDATE
what order to UPDATE in?

Regards,

Stuart.

Stuart C. G. Rison
Department of Biochemistry and Molecular Biology
6th floor, Darwin Building, University College London (UCL)
Gower Street, London, WC1E 6BT, United Kingdom
Tel. 0207 504 2303, Fax. 0207 380 7033
e-mail: rison@biochem.ucl.ac.uk




view thread (2+ messages)  latest in thread

Message-ID: <Pine.LNX.4.10.9909221327290.23732-100000@bsmlx17>
Permalink:  ../Pine.LNX.4.10.9909221327290.23732-100000@bsmlx17/
Also on:    postgresql.org/message-id/Pine.LNX.4.10.9909221327290.23732-100000@bsmlx17

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: rison@biochemistry.ucl.ac.uk
  Subject: Re: [GENERAL] UPDATE feature or bug?
  In-Reply-To: <Pine.LNX.4.10.9909221327290.23732-100000@bsmlx17>
  References: <Pine.LNX.4.10.9909221327290.23732-100000@bsmlx17>

* 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