Thread: Clarification on Role Access Rights to Table Indexes
Hi PostgreSQL Community,
I am currently exploring the behavior of pg_prewarm
and encountered an issue related to role
access rights that I was hoping you could help clarify.
Here is the scenario I observed:
postgres=# CREATE ROLE alpha;
CREATE ROLE
postgres=# GRANT SELECT ON pg_class TO alpha;
GRANT
postgres=# SET ROLE alpha;
SET
postgres=> SELECT pg_prewarm('pg_class');
pg_prewarm
------------
14
(1 row)
postgres=> SELECT pg_prewarm('pg_class_oid_index');
ERROR: permission denied for index pg_class_oid_index
postgres=> RESET ROLE;
RESET
postgres=# GRANT SELECT ON pg_class_oid_index TO alpha;
ERROR: "pg_class_oid_index" is an index
Based on this, I have few questions:
1. Can a role have access rights to a table without having access to its index?
2. If yes, how can we explicitly grant access to the index?
3. If no, and the role inherently gets access to the index when granted access to the table, why
does the pg_prewarm
call fail [1] in the above scenario?
[1] https://github.com/postgres/postgres/blob/master/contrib/pg_prewarm/pg_prewarm.c#L108-L110
Regards,
Ayush Vatsa
SDE AWS
On Mon, 2025-02-17 at 23:31 +0530, Ayush Vatsa wrote: > postgres=> SELECT pg_prewarm('pg_class_oid_index'); > ERROR: permission denied for index pg_class_oid_index > postgres=> RESET ROLE; > RESET > > postgres=# GRANT SELECT ON pg_class_oid_index TO alpha; > ERROR: "pg_class_oid_index" is an index > Based on this, I have few questions: > 1. Can a role have access rights to a table without having access to its index? > 2. If yes, how can we explicitly grant access to the index? > 3. If no, and the role inherently gets access to the index when granted access to the table, why > does the pg_prewarm call fail [1] in the above scenario? I have seen a complaint about this bug before: https://dba.stackexchange.com/a/344603/176905 Yours, Laurenz Albe -- *E-Mail Disclaimer* Der Inhalt dieser E-Mail ist ausschliesslich fuer den bezeichneten Adressaten bestimmt. Wenn Sie nicht der vorgesehene Adressat dieser E-Mail oder dessen Vertreter sein sollten, so beachten Sie bitte, dass jede Form der Kenntnisnahme, Veroeffentlichung, Vervielfaeltigung oder Weitergabe des Inhalts dieser E-Mail unzulaessig ist. Wir bitten Sie, sich in diesem Fall mit dem Absender der E-Mail in Verbindung zu setzen. *CONFIDENTIALITY NOTICE & DISCLAIMER *This message and any attachment are confidential and may be privileged or otherwise protected from disclosure and solely for the use of the person(s) or entity to whom it is intended. If you have received this message in error and are not the intended recipient, please notify the sender immediately and delete this message and any attachment from your system. If you are not the intended recipient, be advised that any use of this message is prohibited and may be unlawful, and you must not copy this message or attachment or disclose the contents to any other person.