Here's v8 of this patch.
Tests are ok: https://cirrus-ci.com/build/5744512465633280
My next step is to write the complete commit message to explain it in
detail and put it to sleep on November's commitfest.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/