I sent my version of patch in parallel. I think we don't need to do the relation open like you did, all the info is in syscache.
pgsql-hackers by date:
Соглашаюсь с условиями обработки персональных данных