PostgreSQL – Permission Denied Using to_regclass() on Table Partitions

permissionspostgresql

I have a partitioned table public.events owned by user web. Running this query:

SELECT to_regclass('public.events_52642b42e4b0889a77dcd6db')

(to confirm that a partition is present for a given partition key) I get:

ERROR:  permission denied for schema public
SQL state: 42501

If I run the same command as the postgres user (superuser) I get the expected result:

public.events_52642b42e4b0889a77dcd6db

I likewise get the same result if I make the web user a superuser, however that's not a viable approach. This was working under PG 11, not sure what changed and the docs don't provide detail (that I could find anyway) as far as what permissions are required for the "System Catalog Information Functions". What am I missing?

Best Answer

The user that got the error does not have the USAGE permission on schema PUBLIC.

I recommend to grant that to everyone:

GRANT USAGE ON SCHEMA public TO PUBLIC;