Here's a refreshed version of this patch. I have split it up in a largish number of pieces, which hopefully makes it easier to understand what is going on.
pgsql-hackers by date:
Соглашаюсь с условиями обработки персональных данных