pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stuart Rison <rison@biochemistry.ucl.ac.uk>
Cc: pgsql-sql <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] [GENERAL] UPDATE feature or bug?
Date: Wed, 22 Sep 1999 11:13:31 -0400
Message-ID: <222.938013211@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.10.9909221327290.23732-100000@bsmlx17>

Stuart Rison <rison@biochemistry.ucl.ac.uk> writes:
> 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?

It's a bug, but I doubt it's likely to get fixed any time soon, since
unique indexes would get a LOT slower if they did this "right".  As you
say, the update must be hitting some of the b=4 rows first.  At that
point, the system has no idea that the existing b=3 rows are going to be
invalidated in the same transaction, so its uniqueness check fails.  To
do this right, the uniqueness check would have to be applied at the end
of the transaction, which would mean remembering every tuple that's been
inserted/updated in the current transaction and going back to check its
uniqueness.

There is a running discussion on the hackers list about implementing
referential integrity constraints, which have this same problem that
you can't really apply (some kinds of) checks until you see the entire
transaction results.  It'll get done but it's not simple.  I'm not
sure whether anyone is thinking of applying that mechanism to unique-
index checks...

			regards, tom lane



view thread (2+ messages)

Message-ID: <222.938013211@sss.pgh.pa.us>
Permalink:  ../222.938013211@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/222.938013211@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, rison@biochemistry.ucl.ac.uk
  Subject: Re: [SQL] [GENERAL] UPDATE feature or bug?
  In-Reply-To: <222.938013211@sss.pgh.pa.us>
  References: <Pine.LNX.4.10.9909221327290.23732-100000@bsmlx17> <222.938013211@sss.pgh.pa.us>

* 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