Here's an updated patch addressing David's points.
I haven't had a chance to test it yet, on win2k8 or win2k12 due topgconf.eu .
-- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services