I've finished testing the patch. I confirm that the patch solves the problem and works just as fast. Thanks, Alexey Orlov.
pgsql-hackers by date:
Соглашаюсь с условиями обработки персональных данных