Skip to content
pg_strict

pg_strict

pg_strict : Prevent dangerous UPDATE and DELETE without WHERE clause

Overview

ID Extension Package Version Category License Language
5830
pg_strict
pg_strict
1.0.5
ADMIN
MIT
Rust
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd--
No
Yes
Yes
Yes
no
no
Relationships
See Also
safeupdate
pg_savior
pg_upless
pg_drop_events
pg_readonly
table_log
pgaudit
pg_permissions

manually upgraded PGRX from 0.16.1 to 0.17.0 by Vonng

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.0.5
18
17
16
15
14
pg_strict -
RPM
PIGSTY
1.0.5
18
17
16
15
14
pg_strict_$v -
DEB
PIGSTY
1.0.5
18
17
16
15
14
postgresql-$v-pg-strict -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
el8.aarch64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
el9.x86_64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
el9.aarch64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
el10.x86_64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
el10.aarch64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
d12.x86_64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
d12.aarch64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
d13.x86_64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
d13.aarch64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
u22.x86_64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
u22.aarch64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
u24.x86_64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
u24.aarch64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
u26.x86_64
MISS
MISS
MISS
MISS
MISS
u26.aarch64
MISS
MISS
MISS
MISS
MISS
Package Version OS ORG SIZE File URL
pg_strict_18 1.0.5 el8.x86_64 pigsty 328.1 KiB pg_strict_18-1.0.5-1PIGSTY.el8.x86_64.rpm
pg_strict_18 1.0.5 el8.aarch64 pigsty 220.8 KiB pg_strict_18-1.0.5-1PIGSTY.el8.aarch64.rpm
pg_strict_18 1.0.5 el9.x86_64 pigsty 344.2 KiB pg_strict_18-1.0.5-1PIGSTY.el9.x86_64.rpm
pg_strict_18 1.0.5 el9.aarch64 pigsty 236.3 KiB pg_strict_18-1.0.5-1PIGSTY.el9.aarch64.rpm
pg_strict_18 1.0.5 el10.x86_64 pigsty 344.4 KiB pg_strict_18-1.0.5-1PIGSTY.el10.x86_64.rpm
pg_strict_18 1.0.5 el10.aarch64 pigsty 236.1 KiB pg_strict_18-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-strict 1.0.5 d12.x86_64 pigsty 269.8 KiB postgresql-18-pg-strict_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-strict 1.0.5 d12.aarch64 pigsty 170.7 KiB postgresql-18-pg-strict_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-strict 1.0.5 d13.x86_64 pigsty 270.2 KiB postgresql-18-pg-strict_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-strict 1.0.5 d13.aarch64 pigsty 170.7 KiB postgresql-18-pg-strict_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-strict 1.0.5 u22.x86_64 pigsty 306.2 KiB postgresql-18-pg-strict_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-strict 1.0.5 u22.aarch64 pigsty 198.2 KiB postgresql-18-pg-strict_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-strict 1.0.5 u24.x86_64 pigsty 303.1 KiB postgresql-18-pg-strict_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-18-pg-strict 1.0.5 u24.aarch64 pigsty 196.8 KiB postgresql-18-pg-strict_1.0.5-1PIGSTY~noble_arm64.deb

Source

pig build pkg pg_strict;		# 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_strict;		# install via package name, for the active PG version

pig install pg_strict -v 18;   # install for PG 18
pig install pg_strict -v 17;   # install for PG 17
pig install pg_strict -v 16;   # install for PG 16
pig install pg_strict -v 15;   # install for PG 15
pig install pg_strict -v 14;   # install for PG 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_strict';

Create this extension with:

CREATE EXTENSION pg_strict;

Usage

Source: README, Release v1.0.5, API source

pg_strict blocks or warns on UPDATE and DELETE statements that omit a WHERE clause. It installs a post_parse_analyze_hook, so it must be loaded from shared_preload_libraries.

Required setup

-- postgresql.conf
shared_preload_libraries = 'pg_strict'

CREATE EXTENSION pg_strict;

GUCs

  • pg_strict.require_where_on_update
  • pg_strict.require_where_on_delete

Each setting supports off, warn, and on.

SET pg_strict.require_where_on_update = 'on';
SET pg_strict.require_where_on_delete = 'warn';

Helper functions

SELECT pg_strict_version();
SELECT * FROM pg_strict_config();

SELECT pg_strict_check_where_clause('DELETE FROM t', 'DELETE');
SELECT pg_strict_validate_update('UPDATE t SET x = 1 WHERE id = 42');
SELECT pg_strict_validate_delete('DELETE FROM t WHERE id = 42');

SELECT pg_strict_enable_update();
SELECT pg_strict_warn_delete();
SELECT pg_strict_disable_delete();
  • pg_strict_set_update_mode(mode) and pg_strict_set_delete_mode(mode) provide generic mode setters.
  • SET LOCAL works for one-off bulk operations inside a transaction.

Caveats

  • Enforcement is presence-based, not intent-based: any non-null WHERE clause satisfies the rule.
  • Only UPDATE and DELETE are checked.
  • Current upstream release is 1.0.5; the Pigsty note about pgrx 0.17.0 is packaging/build metadata, not a documented user-facing feature change.
Last updated on