Skip to content

pg_circuit

Runtime observation, warnings and blocking for dangerous SQL statements

Overview

PackageVersionCategoryLicenseLanguage
pg_circuit0.1.0ADMINApache-2.0C
IDExtensionBinLibLoadCreateTrustRelocSchema
5815pg_circuitNoYesYesYesNoNo-

Requires shared_preload_libraries and restart; Community runtime pressure is informational.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.1.01817161514pg_circuit-
RPMPIGSTY0.1.01817161514pg_circuit_$v-
DEBPIGSTY0.1.01817161514postgresql-$v-pg-circuit-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64N/AN/A
el8.aarch64N/AN/A
el9.x86_64N/AN/A
el9.aarch64N/AN/A
el10.x86_64N/AN/A
el10.aarch64N/AN/A
d12.x86_64N/AN/A
d12.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
N/AN/A
d13.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
N/AN/A
d13.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
N/AN/A
u22.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
N/AN/A
u22.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
N/AN/A
u24.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
N/AN/A
u24.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
N/AN/A
u26.x86_64N/AN/A
u26.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
N/AN/A

Build

You can build the RPM / DEB packages for pg_circuit using pig build:

pig build pkg pg_circuit         # build RPM / DEB packages

Install

You can install pg_circuit directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

Install
pig install pg_circuit;          # Install for current active PG version
pig
pig ext install -y pg_circuit -v 18  # PG 18
pig ext install -y pg_circuit -v 17  # PG 17
pig ext install -y pg_circuit -v 16  # PG 16
dnf
dnf install -y pg_circuit_18       # PG 18
dnf install -y pg_circuit_17       # PG 17
dnf install -y pg_circuit_16       # PG 16
apt
apt install -y postgresql-18-pg-circuit   # PG 18
apt install -y postgresql-17-pg-circuit   # PG 17
apt install -y postgresql-16-pg-circuit   # PG 16

Preload:

shared_preload_libraries = 'pg_circuit';

Create Extension:

CREATE EXTENSION pg_circuit;

Usage

Sources:

pg_circuit inspects potentially dangerous DML and DDL on PostgreSQL 16–18. The Community edition can observe, warn or block statements. Add it to shared_preload_libraries, restart PostgreSQL, then create the extension as a superuser.

Basic protection

shared_preload_libraries = 'pg_circuit'
CREATE EXTENSION pg_circuit;
CREATE TABLE circuit_demo (id integer);
INSERT INTO circuit_demo VALUES (1);
SET pg_circuit.mode = 'enforce';
DELETE FROM circuit_demo; -- blocked
DELETE FROM circuit_demo WHERE id = 1;
SELECT * FROM pg_circuit_status();

Configuration and diagnostics

pg_circuit.mode defaults to warn; observe collects risk without warnings, and enforce blocks scores at or above the configured threshold. pg_circuit_runtime_state() reports pressure signals and pg_circuit_events() exposes recent events.

Community always reports effective runtime mode NORMAL. Pressure readings do not automatically escalate enforcement. This is a policy aid; application transactions, authorization and backups still determine data protection. Review rules and thresholds on representative queries before enabling enforcement.

Was this page helpful?