I cleaned up the patch a bit -- result is v11, attached. I'll give it
another look tomorrow and hopefully commit it.
--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support