Hi!
Attached draft version of fix for [1].
[1] https://www.postgresql.org/message-id/86b4f1e3-0b5d-315c-9225-19860d64d685%40gmail.com
-- With best regards,Dmitry Koval
Postgres Professional: http://postgrespro.com