Tomas Vondra <tv@fuzzy.cz> writes:
> That might explain why it fails at first and then works just fine,
> although it's a bit strange. Wouldn't that mean you can't access any
> catalogs from the auth hook?
It should be possible to access shared catalogs from an auth hook.
pg_stat_activity is neither shared nor a catalog. Like Robert,
I find it astonishing that this works ever, because the info needed
simply isn't available until you've connected to a particular database.
The fact that the view is actually defined the same in every database
doesn't enter into that ...
regards, tom lane