Re: someone working to add merge? - Mailing list pgsql-hackers

From Csaba Nagy
Subject Re: someone working to add merge?
Date
Msg-id 1131730292.8979.93.camel@coppola.muc.ecircle.de
Whole thread Raw
In response to Re: someone working to add merge?  (Jaime Casanova <systemguards@gmail.com>)
List pgsql-hackers
On Fri, 2005-11-11 at 18:15, Jaime Casanova wrote:
> On 11/11/05, Josh Berkus <josh@agliodbs.com> wrote:
> > Jaime,
> >
> > > so i suppose we can reuse many of the code breaking the merge in 3
> > > pieces... for now they are just thougths, i will think more in this
> > > and try to implement it...
> > >
> > > comments? ideas? suggestions?
> >
> > Funny, we were just discussing this at OpenDBCon.   Seems that you can't do a
> > full implementation of MERGE without Predicate Locking (the ability to say
> > "lock this table against inserts or updates of any row with key=5").
> 
> it isn't what select for update does?

Select for update only works if the row is already there. If there's no
row, you can't lock it. So you want then to insert it, but then it is
possible that somebody inserted it before you, immediately after your
update... so the solution would be more like:
 - try insert; - if insert fails, do update;

You can already do that, but you have to place a save-point before the
insert, so you can continue your transaction even if the insert fails.
Without knowledge of postgres internals, the simplest would be to be
able to do the "continue transaction if insert fails" with the cheapest
prise to pay. This would mean wrap up existing code, except that
"continue transaction after failure of insert" part.

All this might be completely bull*it of course, I don't know too much
about postgres internals.

[snip]

Cheers,
Csaba.





pgsql-hackers by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: 8.1 substring bug?
Next
From: Peter Eisentraut
Date:
Subject: Re: someone working to add merge?