Also ... the visibility issue doesn't seem to explain the other symptom
you reported:
> With the original function, the log messages were slightly different and
> usually caused the server to reset:
> ERROR: duplicate key violates unique constraint
> "pg_type_typname_nsp_index"
What was the "original function" exactly?
regards, tom lane