pgx_permission_sync
pgx_permission_sync · Permission DDL synchronization with dblink, drift detection and reviewed reconciliation.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102345 | pgx_permission_sync | pgx_permission_sync | 1.2 | SEC | PostgreSQL | SQL |
PostgreSQL · 14, 15, 16, 17, 18
Usage
Sources:
pgx_permission_sync 1.2 synchronizes permission DDL to configured PostgreSQL databases through dblink and provides drift detection, reconciliation, audit logs and retries. It is pure SQL/PL/pgSQL, supports PostgreSQL 14 and later, and requires dblink, pgcrypto and a superuser to install. It has no shared-preload requirement.
Install and configure
The fixed schema is dba_pgx_permission_sync. Installation starts from 1.0 SQL and follows the supplied upgrade chain to 1.2. Disable live synchronization while configuring targets. Set an encryption key of at least 16 characters before storing passwords; without a key, the implementation warns and stores the password without encryption. In psql, supply encryption_key and sync_password variables privately. The target account needs CREATEROLE and relevant grant privileges.
Review drift before applying
detect_drift() compares roles, memberships, object privileges and default privileges. reconcile() defaults to a dry run. Only an administrator may apply it; the global dry-run setting also forces a rehearsal. Revocation requires a separate opt-in, target-only roles are never dropped, and privileged attributes remain blocked unless explicitly allowed. Missing roles are created without passwords.
Live synchronization and operations
Live event triggers cover supported privilege, policy and schema commands. CREATE ROLE, ALTER ROLE and DROP ROLE are cluster-wide and do not fire these triggers; use drift reconciliation or reviewed manual_sync() calls. After reviewing rules and dry-run results, enable actual delivery. Remote calls are synchronous inside the source DDL transaction; a slow target delays it. dblink changes on remote databases are not a distributed atomic transaction with the source.
Access and limitations
Treat pgsync_admin and pgsync_operator as trusted administrative roles: operators can invoke manual remote SQL. pgsync_reader has read-only visibility. Encryption keys are held in the restricted secrets table; encryption does not protect them from its owner. Drift comparison excludes ownership, database privileges, large objects, passwords, per-role settings and PostgreSQL 16 membership options. role_pattern does not filter grantees of grant/revoke commands. Retry and log cleanup require explicit invocation or an independently configured scheduler.