I am encountering an issue in PostgreSQL where a specific user cannot see all the tables in information_schema.tables, even though all tables belong to the same database and schema.
Context:
- PostgreSQL version: 14.5
- All tables are in a single database (not the postgres database).
- The user has been granted access to the schema and tables using:
GRANT USAGE ON SCHEMA public TO my_user;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO my_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO my_user;
- The user can see some tables in information_schema.tables, but others are missing.
What I’ve checked:
- Verified privileges on the missing tables using information_schema.role_table_grants:
SELECT table_schema, table_name, grantee, privilege_typeFROM information_schema.role_table_grants
WHERE table_name = 'missing_table';
- Ensured the user has USAGE privileges on the public schema:
SELECT schema_name, grantee, privilege_type
FROM information_schema.role_usage_grants
WHERE schema_name = 'public';
- Verified that the missing tables are owned by the same user as the visible ones:
SELECT table_schema, table_name, table_owner
FROM information_schema.tables
WHERE table_name IN ('visible_table', 'missing_table');
- Checked the user’s roles and privileges using:
SELECT * FROM information_schema.role_table_grants WHERE grantee = 'my_user';
Observations:
- The user can query the visible tables without issues.
- The user can also query the missing tables directly, e.g.:
SELECT * FROM public.missing_table;
This works without any errors, suggesting that the user does have sufficient privileges on the table itself. However, the tables do not appear in information_schema.tables.
Question:
- What could cause certain tables to be invisible in information_schema.tables for a user, even though they belong to the same schema and the same GRANT commands were applied?
- How can I troubleshoot this further to identify the root cause?
Additional Information:
- All tables are part of the public schema.
- I have administrative access to the database and can execute any necessary queries or provide more details.
Any help or guidance on resolving this would be greatly appreciated!
reindex schema pg_catalog;and the queryinformation_schema.tables.psqldo\dn+and add the result as text to the question text. 2) Again inpsqldo\dp missing_tableand add result to question text.pg_dump -sa problem table from the database.