In a fictional reporting service, the pool connects as report_pool and changes role for the request. A query on reporting.daily_sales fails. Use the same role setup in an authorized reproduction and query the session identity just before the equivalent read.
SELECT current_database(), session_user, current_user;
If the result is reports, report_pool, report_guest, investigate report_guest on the target table. For SQL executed inside a security-definer function, inspect the function's owner and security mode. A query run outside the function reports the outer role. When the failure is inside an aborted transaction, read the role in a fresh controlled reproduction or from diagnostics captured before the error. PostgreSQL session information functions ยท CREATE FUNCTION security modes