The bug in https://redmine.postgresql.org/issues/4179 seems to be due to pg_type being projected from but not selected, the attached patch adds a FROM clause entry and also adds projection of typname. This makes the query work on 5X_STABLE for me.
cheers ./daniel
from_pg_type.patch
Description: Binary data