In a fictional reporting database, report_job has SELECT on reporting.daily_sales. A newly prepared query is rejected at schema lookup. An authorized operator can inspect the grants by role. Use the table OID from the catalogs to avoid relying on the job role to resolve the relation by name.
SELECT has_schema_privilege('report_job', n.oid, 'USAGE') AS schema_usage,
has_table_privilege('report_job', c.oid, 'SELECT') AS table_select
FROM pg_catalog.pg_class AS c
JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace
WHERE n.nspname = 'reporting' AND c.relname = 'daily_sales';
False and true support a schema-usage diagnosis for that role. Ask the schema owner to consider USAGE if the role should resolve objects there. Object privileges still apply. If the query uses an unqualified table name, check search_path and the intended relation as well. PostgreSQL schema privileges ยท Privilege inquiry functions