select matviewname from pg_matviews I get all materialized views in the database. How can I filter the result to get only those the current user has select grant (= read permission) on?
You can use the function
has_table_privilege() to check that:
select mv.* from pg_catalog.pg_matviews mv where has_table_privilege(format('%I.%I', mv.schemaname, mv.matviewname), 'select')
The version with two parameters checks this for the current user. Alternatively you can use the version with three parameters and pass the user name explicitly.