Permissions Management

Permission Overview

Permissions are used to control whether a user is allowed to access a database object (including schemas, tables, functions, and sequences) to perform operations such as adding, deleting, modifying, querying, and creating a database object.

Permission management in GaussDB(DWS) falls into three categories:

Hierarchical Permission Management

GaussDB(DWS) implements a hierarchical permission management on databases, schemas, and data objects.

Figure 1 Hierarchical Permission Management

Roles

The permission management model of GaussDB(DWS) is a typical implementation of the role-based permission control (RBAC). It manages users, roles, and permissions through this model.

A role is a set of permissions.

To view all roles, query the system catalog PG_ROLES.

1
SELECT * FROM PG_ROLES;

For how to create, modify, and delete a role, see "CREARE ROLE/ALTER ROLE/DROP ROLE" in SQL Syntax Reference.

Preset Roles

GaussDB(DWS) provides a group of preset roles. Their names start with gs_role_. These roles allow access to operations that require high permissions. You can grant these roles to other users or roles in the database for them to access or use specific information and functions. Exercise caution and ensure security when using preset roles.

The following table describes the permissions of preset roles.

Table 1 Permissions of preset roles

Role

Permission

gs_role_signal_backend

Invokes functions such as pg_cancel_backend, pg_terminate_backend, pg_terminate_query, pg_cancel_query, pgxc_terminate_query, and pgxc_cancel_query to cancel or terminate sessions, excluding those of the initial users.

gs_role_read_all_stats

Reads the system status view and uses various extension-related statistics, including information that is usually visible only to system administrators. For example:

Resource management views:

  • pgxc_wlm_operator_history
  • pgxc_wlm_operator_info
  • pgxc_wlm_operator_statistics
  • pgxc_wlm_session_info
  • pgxc_wlm_session_statistics
  • pgxc_wlm_workload_records
  • pgxc_workload_sql_count
  • pgxc_workload_sql_elapse_time
  • pgxc_workload_transaction

Status information views:

  • pgxc_stat_activity
  • pgxc_get_table_skewness
  • table_distribution
  • pgxc_total_memory_detail
  • pgxc_os_run_info
  • pg_nodes_memory
  • pgxc_instance_time
  • pgxc_redo_stat

gs_role_analyze_any

A user with the system-level ANALYZE permission can skip the schema permission check and perform ANALYZE on all tables.

gs_role_vacuum_any

A user with the system-level VACUUM permission can skip the schema permission check and perform ANALYZE on all tables.

Restrictions on using preset roles:

Granting or Revoking Permissions

A user who creates an object is the owner of this object. By default, Separation of Permissions is disabled after cluster installation. A database system administrator has the same permissions as object owners.

After an object is created, only the object owner or system administrator can query, modify, and delete the object, and grant permissions for the object to other users through GRANT by default. To enable a user to use an object, the object owner or administrator can run the GRANT or REVOKE command to grant permissions to or revoke permissions from the user or role.