Skip to content

acl

ACL Data type

pg_acl · ACL Data type

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3820aclpg_acl1.0.4TYPEBSD-2-ClauseC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno
+cast pg_uuid_t

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.0.419 18 17 16 15pg_acl-
RPMPIGSTY1.0.419 18 17 16 15acl_$v-
DEBPIGSTY1.0.419 18 17 16 15postgresql-$v-acl-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
el8.aarch64N/APIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
el9.x86_64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
el9.aarch64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
el10.x86_64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
el10.aarch64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
d12.x86_64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
d12.aarch64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
d13.x86_64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
d13.aarch64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
u22.x86_64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
u22.aarch64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
u24.x86_64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
u24.aarch64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
u26.x86_64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4
u26.aarch64PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4PIGSTY 1.0.4

Source

pig build pkg pg_acl;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_acl;		# install by package name
pig install acl;		# install by extension name

pig install acl -v 19;   # install for PG 19
pig install acl -v 18;   # install for PG 18
pig install acl -v 17;   # install for PG 17
pig install acl -v 16;   # install for PG 16
pig install acl -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION acl;

Usage

acl: access control list data type for PostgreSQL

The acl extension provides Access Control List types for row-level security based on application users, without requiring separate database accounts.

CREATE EXTENSION acl;

Data Types

  • ace: Standard role-based ACE using PostgreSQL OIDs
  • ace_int4: ACE with 32-bit integer identifiers
  • ace_int8: ACE with 64-bit integer identifiers
  • ace_uuid: ACE with UUID identifiers

ACLs are stored as PostgreSQL arrays of ACE types (e.g., ace[]).

ACE Format

[type]/[flags]/[who]=[mask]
  • Type: a (allow) or d (deny)
  • Flags: i (inherit only), o (object inherit), c (container inherit), p (no propagate), h (inherited)
  • Who: Role name, OID, integer, UUID, or "" (everyone)
  • Permissions: r (read), w (write), d (delete), c (read ACL), s (write ACL), plus 16 custom permissions (0-F)

Checking Permissions

-- Check current user's access
SELECT acl_check_access(acl_column, 'rw', false) FROM my_table;

-- Check specific role
SELECT acl_check_access(acl_column, 'r', 'username'::name, false);

-- Check custom int4 roles
SELECT acl_check_access(acl_column, 'rw', ARRAY[1001, 1002]::int4[], false);

ACL Inheritance

-- Compute child ACL from parent
SELECT acl_merge(parent_acl, child_acl, true, true);

Row-Level Security Example

CREATE TABLE file_system (
    id   int PRIMARY KEY,
    name text,
    acl  ace[]
);

ALTER TABLE file_system ENABLE ROW LEVEL SECURITY;

CREATE POLICY read_policy ON file_system FOR SELECT TO PUBLIC
    USING (acl_check_access(acl, 'r', false) = 'r');

CREATE POLICY write_policy ON file_system FOR UPDATE TO PUBLIC
    USING (acl_check_access(acl, 'w', false) = 'w');

Table reader