Here is the patch rebased to a852cfe9.
-- Alexander KuzmenkovPostgres Professional: http://www.postgrespro.comThe Russian Postgres Company