Revamp documentation for predefined roles.
authorNathan Bossart
Wed, 10 Jul 2024 21:35:25 +0000 (16:35 -0500)
committerNathan Bossart
Wed, 10 Jul 2024 21:35:25 +0000 (16:35 -0500)
Presently, the page for predefined roles contains a table with
brief descriptions of what each role allows.  Below the table,
there is a separate section with more detailed information about
some of the roles.  As the set of predefined roles has grown over
the years, this page has (IMHO) become less readable.

This commit attempts to improve the predefined roles documentation
by abandoning the table in favor of listing each role with its own
complete description, similar to how we document GUCs.  Besides
merging the information that was split between the table and the
section below it, this commit also alphabetizes the roles.  The
alphabetization is imperfect because some of the roles are grouped
(e.g., pg_read_all_data and pg_write_all_data), and we order such
groups by the first role mentioned, but that seemed like a better
choice than breaking the groups apart.  Finally, this commit makes
some stylistic adjustments to the text.

Reviewed-by: David G. Johnston, Robert Haas
Discussion: https://postgr.es/m/ZmtM-4-eRtq8DRf6%40nathan

doc/src/sgml/config.sgml
doc/src/sgml/monitoring.sgml
doc/src/sgml/ref/checkpoint.sgml
doc/src/sgml/ref/reindex.sgml
doc/src/sgml/user-manag.sgml

index 4a0c9ba97dd728b677d0eb93aa138b740364191e..b14c5d81a1578127de953f5e2f9364edaa3ee99f 100644 (file)
@@ -731,7 +731,7 @@ include_dir 'conf.d'
        
         Determines the number of connection slots that are
         reserved for connections by roles with privileges of the
-        <link linkend="predefined-roles-table">pg_use_reserved_connections>
+        <xref linkend="predefined-role-pg-use-reserved-connections"/>
         role.  Whenever the number of free connection slots is greater than
          but less than or
         equal to the sum of superuser_reserved_connections
index 9ca74348c7fbc67602c664d8b02e8e1cab72f2ad..55417a6fa9d1981fab9be5142e077da39800cd77 100644 (file)
@@ -286,8 +286,8 @@ postgres   27093  0.0  0.0  30096  2752 ?        Ss   11:34   0:00 postgres: ser
    other sessions, many columns will be null.  Note, however, that the
    existence of a session and its general properties such as its sessions user
    and database are visible to all users.  Superusers and roles with privileges of
-   built-in role teral>pg_read_all_stats (see also 
-   linkend="predefined-roles"/>) can see all the information about all sessions.
+   built-in role nk linkend="predefined-role-pg-monitor">pg_read_all_stats
+   can see all the information about all sessions.
   
 
   
index 28a1d717b87eb28fb8ff236cb8c3e8b890f8bf1d..db011a47d0458a2ebf6c3c28d6d8cbe77786f76c 100644 (file)
@@ -53,7 +53,7 @@ CHECKPOINT
 
   
    Only superusers or users with the privileges of
-   the <link linkend="predefined-roles-table">pg_checkpoint>
+   the <xref linkend="predefined-role-pg-checkpoint"/>
    role can call CHECKPOINT.
   
  
index 2942dccf1e2e198a5ff7d836cea62afbb7fb4914..dcf70d14bc36042c41f58db920b90f02ad66fc08 100644 (file)
@@ -305,7 +305,7 @@ REINDEX [ ( option [, ...] ) ] { DA
    partitioned table, such commands skip the privilege checks when processing
    the individual partitions.  Reindexing a schema or database requires being the
    owner of that schema or database or having privileges of the
-   <link linkend="predefined-roles-table">pg_maintain>
+   <xref linkend="predefined-role-pg-maintain"/>
    role.  Note specifically that it's thus
    possible for non-superusers to rebuild indexes of tables owned by
    other users.  However, as a special exception,
index 340cefff705925e80759e13cebe888ca22693cf7..0a005481d1bf2e63282269fbfae58099db42e1a5 100644 (file)
@@ -590,106 +590,73 @@ DROP ROLE doomed_role;
    and information.  Administrators (including roles that have the
    CREATEROLE privilege) can GRANT these
    roles to users and/or other roles in their environment, providing those
-   users with access to the specified capabilities and information.
+   users with access to the specified capabilities and information.  For
+   example:
+
+
+GRANT pg_signal_backend TO admin_user;
+
   
 
+  
+   
+    Care should be taken when granting these roles to ensure they are only used
+    where needed and with the understanding that these roles grant access to
+    privileged information.
+   
+  
+
   
-   The predefined roles are described in .
+   The predefined roles are described below.
    Note that the specific permissions for each of the roles may change in
    the future as additional capabilities are added.  Administrators
    should monitor the release notes for changes.
-  
 
-   
-    Predefined Roles
-    
-     
-     
-     
-      
-       Role
-       Allowed Access
-      
-     
-     
-      
-       pg_read_all_data
-       Read all data (tables, views, sequences), as if having
-       SELECT rights on those objects, and USAGE rights on
-       all schemas, even without having it explicitly.  This role does not have
-       the role attribute BYPASSRLS set.  If RLS is being
-       used, an administrator may wish to set BYPASSRLS on
-       roles which this role is GRANTed to.
-      
-      
-       pg_write_all_data
-       Write all data (tables, views, sequences), as if having
-       INSERTUPDATE, and
-       DELETE rights on those objects, and USAGE rights on
-       all schemas, even without having it explicitly.  This role does not have
-       the role attribute BYPASSRLS set.  If RLS is being
-       used, an administrator may wish to set BYPASSRLS on
-       roles which this role is GRANTed to.
-      
-      
-       pg_read_all_settings
-       Read all configuration variables, even those normally visible only to
-       superusers.
-      
-      
-       pg_read_all_stats
-       Read all pg_stat_* views and use various statistics related extensions,
-       even those normally visible only to superusers.
-      
-      
-       pg_stat_scan_tables
-       Execute monitoring functions that may take ACCESS SHARE locks on tables,
-       potentially for a long time.
-      
-      
-       pg_monitor
-       Read/execute various monitoring views and functions.
-       This role is a member of pg_read_all_settings,
-       pg_read_all_stats and
-       pg_stat_scan_tables.
-      
-      
-       pg_database_owner
-       None.  Membership consists, implicitly, of the current database owner.
-      
-      
-       pg_signal_backend
-       Signal another backend to cancel a query or terminate its session.
-      
-      
-       pg_signal_autovacuum_worker
-       Signal an autovacuum worker to cancel the current table's vacuum
-       or terminate its session.
-      
-      
-       pg_read_server_files
-       Allow reading files from any location the database can access on the server with COPY and
-       other file-access functions.
-      
-      
-       pg_write_server_files
-       Allow writing to files in any location the database can access on the server with COPY and
-       other file-access functions.
-      
-      
-       pg_execute_server_program
-       Allow executing programs on the database server as the user the database runs as with
-       COPY and other functions which allow executing a server-side program.
-      
-      
-       pg_checkpoint
-       Allow executing
-       the CHECKPOINT
-       command.
-      
-      
-       pg_maintain
-       Allow executing
+   
+    
+     pg_checkpoint
+     
+      
+       pg_checkpoint allows executing the
+       CHECKPOINT command.
+      
+     
+    
+
+    
+     pg_create_subscription
+     
+      
+       pg_create_subscription allows users with
+       CREATE permission on the database to issue
+       CREATE SUBSCRIPTION.
+      
+     
+    
+
+    
+     pg_database_owner
+     
+      
+       pg_database_owner always has exactly one implicit
+       member: the current database owner.  It cannot be granted membership in
+       any role, and no role can be granted membership in
+       pg_database_owner.  However, like any other role, it
+       can own objects and receive grants of access privileges.  Consequently,
+       once pg_database_owner has rights within a template
+       database, each owner of a database instantiated from that template will
+       possess those rights.  Initially, this role owns the
+       public schema, so each database owner governs local
+       use of that schema.
+      
+     
+    
+
+    
+     pg_maintain
+     
+      
+       pg_maintain allows executing
        VACUUM,
        ANALYZE,
        CLUSTER,
@@ -697,76 +664,138 @@ DROP ROLE doomed_role;
        REINDEX,
        and LOCK TABLE on all
        relations, as if having MAINTAIN rights on those
-       objects, even without having it explicitly.
-      
-      
-       pg_use_reserved_connections
-       Allow use of connection slots reserved via
-       .
-      
-      
-       pg_create_subscription
-       Allow users with CREATE permission on the
-       database to issue
-       CREATE SUBSCRIPTION.
-      
-     
-    
-   
-
-  
-  The pg_monitorpg_read_all_settings,
-  pg_read_all_stats and pg_stat_scan_tables
-  roles are intended to allow administrators to easily configure a role for the
-  purpose of monitoring the database server. They grant a set of common privileges
-  allowing the role to read various useful configuration settings, statistics and
-  other system information normally restricted to superusers.
-  
-
-  
-  The pg_database_owner role has one implicit,
-  situation-dependent member, namely the owner of the current database.  Like
-  any role, it can own objects or receive grants of access privileges.
-  Consequently, once pg_database_owner has rights within a
-  template database, each owner of a database instantiated from that template
-  will exercise those rights.  pg_database_owner cannot be
-  a member of any role, and it cannot have non-implicit members.  Initially,
-  this role owns the public schema, so each database owner
-  governs local use of the schema.
-  
-
-  
-  The pg_signal_backend role is intended to allow
-  administrators to enable trusted, but non-superuser, roles to send signals
-  to other backends. Currently this role enables sending of signals for
-  canceling a query on another backend or terminating its session. A user
-  granted this role cannot however send signals to a backend owned by a
-  superuser.  See .
-  
-
-  
-  The pg_read_server_filespg_write_server_files and
-  pg_execute_server_program roles are intended to allow administrators to have
-  trusted, but non-superuser, roles which are able to access files and run programs on the
-  database server as the user the database runs as.  As these roles are able to access any file on
-  the server file system, they bypass all database-level permission checks when accessing files
-  directly and they could be used to gain superuser-level access, therefore
-  great care should be taken when granting these roles to users.
-  
-
-  
-  Care should be taken when granting these roles to ensure they are only used where
-  needed and with the understanding that these roles grant access to privileged
-  information.
-  
-
-  
-   Administrators can grant access to these roles to users using the
-   GRANT command, for example:
-
-
-GRANT pg_signal_backend TO admin_user;
-
+       objects.
+      
+     
+    
+
+    
+     pg_monitor
+     pg_read_all_settings
+     pg_read_all_stats
+     pg_stat_scan_tables
+     
+      
+       These roles are intended to allow administrators to easily configure a
+       role for the purpose of monitoring the database server.  They grant a
+       set of common privileges allowing the role to read various useful
+       configuration settings, statistics, and other system information
+       normally restricted to superusers.
+      
+      
+       pg_monitor allows reading/executing various
+       monitoring views and functions.  This role is a member of
+       pg_read_all_settings,
+       pg_read_all_stats and
+       pg_stat_scan_tables.
+      
+      
+       pg_read_all_settings allows reading all configuration
+       variables, even those normally visible only to superusers.
+      
+      
+       pg_read_all_stats allows reading all pg_stat_* views
+       and use various statistics related extensions, even those normally
+       visible only to superusers.
+      
+      
+       pg_stat_scan_tables allows executing monitoring
+       functions that may take ACCESS SHARE locks on tables,
+       potentially for a long time (e.g., pgrowlocks(text)
+       in the  extension).
+      
+     
+    
+
+    
+     pg_read_all_data
+     pg_write_all_data
+     
+      
+       pg_read_all_data allows reading all data (tables,
+       views, sequences), as if having SELECT rights on
+       those objects and USAGE rights on all schemas.  This
+       role does not bypass row-level security (RLS) policies.  If RLS is being
+       used, an administrator may wish to set BYPASSRLS on
+       roles which this role is granted to.
+      
+      
+       pg_write_all_data allows writing all data (tables,
+       views, sequences), as if having INSERT,
+       UPDATE, and DELETE rights on those
+       objects and USAGE rights on all schemas.  This role
+       does not bypass row-level security (RLS) policies.  If RLS is being
+       used, an administrator may wish to set BYPASSRLS on
+       roles which this role is granted to.
+      
+     
+    
+
+    
+     pg_read_server_files
+     pg_write_server_files
+     pg_execute_server_program
+     
+      
+       These roles are intended to allow administrators to have trusted, but
+       non-superuser, roles which are able to access files and run programs on
+       the database server as the user the database runs as.  They bypass all
+       database-level permission checks when accessing files directly and they
+       could be used to gain superuser-level access.  Therefore, great care
+       should be taken when granting these roles to users.
+      
+      
+       pg_read_server_files allows reading files from any
+       location the database can access on the server using
+       COPY and other file-access functions.
+      
+      
+       pg_write_server_files allows writing to files in any
+       location the database can access on the server using
+       COPY and other file-access functions.
+      
+      
+       pg_execute_server_program allows executing programs
+       on the database server as the user the database runs as using
+       COPY and other functions which allow executing a
+       server-side program.
+      
+     
+    
+
+    
+     pg_signal_autovacuum_worker
+     
+      
+       pg_signal_autovacuum_worker allows signaling
+       autovacuum workers to cancel the current table's vacuum or terminate its
+       session.  See .
+      
+     
+    
+
+    
+     pg_signal_backend
+     
+      
+       pg_signal_backend allows signaling another backend to
+       cancel a query or terminate its session.  Note that this role does not
+       permit signaling backends owned by a superuser.  See
+       .
+      
+     
+    
+
+    
+     pg_use_reserved_connections
+     
+      
+       pg_use_reserved_connections allows use of connection
+       slots reserved via .
+      
+     
+    
+