Here's a rebase of Simon/Pavan's MERGE patch to current sources. Icleaned up some minor things in it, but aside from rebasing, it's prettymuch their work (even the commit message is Simon's).
Adding to commitfest.
-- Álvaro Herrera