Diagnostic Queries
Symptoms
A statement referenced a role (user/group) that does not exist in the cluster. PostgreSQL raises SQLSTATE 42704 (undefined_object).
- Common in GRANT/ALTER/SET ROLE referencing a missing role.
- Also appears when connecting as a role that was never created.
- Role names are case-folded unless quoted.
What the server log shows
ERROR: role "reporting" does not exist
Why PostgreSQL raises this — what the manual says
Chapter 21 Database Roles:
“PostgreSQL manages database access permissions using the concept of roles.”
Roles live in the shared catalog pg_authid/pg_roles. When a command names a role that is not present, PostgreSQL cannot resolve it and reports 42704.
Common causes
- Typo or wrong case in the role name.
- The role was dropped or never created.
- Granting to a role that exists only in another cluster.
How to fix it
- List roles:
\duin psql orSELECT rolname FROM pg_roles;. - Create the role:
CREATE ROLE reporting;(add LOGIN/privileges as needed). - Fix the name/case in the statement.
Related & next steps
Reference: PostgreSQL 18 Section 22.1 “Database Roles”.
Thanks — noted. This helps keep the database accurate.