Here's a rebased version of this patch (it had a trivial conflict).No further changes.
-- Álvaro Herrera https://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services