I added this patch to commitfest in order to get more opinions, particularly on whether to backpatch this. I might commit sooner than that if others care to comment.
-- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services