pg_permissions
pg_permissions : view object permissions and compare them with the desired state
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 5140 | pg_permissions | pg_permissions | 1.4.1 |
ADMIN | BSD-2-Clause | SQL |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| See Also | set_user pg_roast pg_readonly pgaudit pg_command_fw acl pg_auditor pg_snakeoil |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 1.4.1 |
18 17 16 15 14 | pg_permissions |
- |
| RPM | PGDG | 1.4.1 |
18 17 16 15 14 | pg_permissions_$v |
- |
| DEB | PGDG | 1.4 |
18 17 16 15 14 | postgresql-$v-pg-permissions |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 1.4 | PGDG 1.4.1 | PGDG 1.4.1 | PGDG 1.4.1 | PGDG 1.4.1 |
| el8.aarch64 | PGDG 1.4 | PGDG 1.4.1 | PGDG 1.4.1 | PGDG 1.4.1 | PGDG 1.4.1 |
| el9.x86_64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| el9.aarch64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| el10.x86_64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| el10.aarch64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| d12.x86_64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| d12.aarch64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| d13.x86_64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| d13.aarch64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| u22.x86_64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| u22.aarch64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| u24.x86_64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| u24.aarch64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| u26.x86_64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
| u26.aarch64 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 | PGDG 1.4 |
Source
github.com/cybertec-postgresql/pg_permissions
Install
Make sure PGDG repo available:
Install this extension with pig:
Create this extension with:
Usage
pg_permissions: view object permissions and compare them with the desired state
pg_permissions lets you review actual permissions on database objects and compare them against a desired permission state.
Define Desired Permissions
Insert entries into permission_target to describe what permissions should exist:
Set object_name or column_name to NULL to apply to all objects of that type in the schema.
Find Permission Differences
Returns rows where missing = TRUE (permission should exist but doesn’t) or missing = FALSE (extra permission that shouldn’t exist).
Review Actual Permissions
Available views (all with the same column structure):
database_permissions– permissions on the current databaseschema_permissions– permissions on schemastable_permissions– permissions on tablesview_permissions– permissions on viewscolumn_permissions– permissions on table/view columnsfunction_permissions– permissions on functionssequence_permissions– permissions on sequencesall_permissions– UNION of all above
Grant/Revoke via Views
The granted column of the permission views is updatable – updating it executes the appropriate GRANT or REVOKE command.
Note: superusers are not shown in the views (they automatically have all permissions).