Josh Berkus <josh@agliodbs.com> writes:
> 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").
> However, Peter suggested that we could do a proof-of-concept implementation,
> working out syntax and trigger issues, based on a full table lock and do the
> hard work once it was proved to be feasable.
If you don't have any better idea how to do it than a full table lock,
you might as well not do it at all. A "proof of concept" that doesn't
solve the hard part of the problem is no proof :-(
My first guess about a real implementation would involve extending the
index AM API to offer a function "insert this key, or return the
existing match if there already is one". This might tie into
refactoring the existing implementation of unique indexes, in which all
the problem is put on the AM's head (which is why only btree copes at
the moment).
regards, tom lane