Received: from mail-b.bcc.ac.uk (mail-b.bcc.ac.uk [144.82.100.22]) by hub.org (8.9.3/8.9.3) with ESMTP id IAA47836 for ; Wed, 22 Sep 1999 08:32:25 -0400 (EDT) (envelope-from rison@biochemistry.ucl.ac.uk) Received: from biochem.ucl.ac.uk (actually host bsmori1.biochem.ucl.ac.uk) by mail-b.bcc.ac.uk with SMTP (XT-PP) with ESMTP; Wed, 22 Sep 1999 13:31:52 +0100 Received: from bsmlx17.biochem.ucl.ac.uk (bsmlx17 [128.40.46.142]) by biochem.ucl.ac.uk (8.9.2/8.9.1) with ESMTP id NAA18752 for ; Wed, 22 Sep 1999 13:31:57 +0100 (BST) Received: from localhost (rison@localhost) by bsmlx17.biochem.ucl.ac.uk (8.9.3/8.6.6) with ESMTP id NAA23748 for ; Wed, 22 Sep 1999 13:35:51 +0100 X-Authentication-Warning: bsmlx17.biochem.ucl.ac.uk: rison owned process doing -bs Date: Wed, 22 Sep 1999 13:35:51 +0100 (BST) From: Stuart Rison X-Sender: rison@bsmlx17 To: pgsql-sql Subject: [GENERAL] UPDATE feature or bug? Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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