Re: someone working to add merge?

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Jan Wieck <JanWieck(at)Yahoo(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org, Josh Berkus <josh(at)agliodbs(dot)com>, Jaime Casanova <systemguards(at)gmail(dot)com>
Subject: Re: someone working to add merge?
Date: 2005-11-24 06:30:37
Message-ID: 20051124063034.GA18750@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 23, 2005 at 04:55:25PM -0500, Jan Wieck wrote:
> The largest problem I see with MERGE is the question of BEFORE triggers.
> Consider a BEFORE INSERT trigger that modifies a third table, after
> which the constraint or whatever post-heap_insert-attempt we might use
> detects a conflict. How do we undo the actions of the BEFORE trigger?
> The only way to do that is to plan the query as a nestloop, with the
> USING part as the outer loop. If the (updating) scan of the INTO
> relation did not hit any tuple, then do the INSERT. We can only undo the
> side effects of any BEFORE trigger by wrapping each and evey nested INTO
> relation insert attempt into its own subtransaction.

Umm, if there are any errors you abort the transaction, just like any
other case. ACID requires that either the whole statement is done, or
none. If a trigger causes the INSERT or UPDATE to fail you have no
choice but to abort the transaction.

Besides, someone posted an example on Oracle, they don't require an
index so I don't think we realistically can say that people need one.
If two concurrent MERGEs, which can't see eachothers output, both end
up INSERTing, that not an error unless the user has a UNIQUE
constraint, so the problem vanishes.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Harald Armin Massa 2005-11-24 07:25:15 Re: Private email requests
Previous Message Bruce Momjian 2005-11-24 04:47:48 Private email requests