跳转到主要内容

pg_strict

Prevent dangerous UPDATE and DELETE without WHERE clause

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

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 PIGSTY 1.0.5 PIGSTY 1.0.5 PIGSTY 1.0.5 PIGSTY 1.0.5 PIGSTY 1.0.5
u26.aarch64 PIGSTY 1.0.5 PIGSTY 1.0.5 PIGSTY 1.0.5 PIGSTY 1.0.5 PIGSTY 1.0.5
Package Version OS ORG SIZE File URL
pg_strict_18 1.0.5 el8.x86_64 pigsty 863.8 KiB pg_strict_18-1.0.5-3PIGSTY.el8.x86_64.rpm
pg_strict_18 1.0.5 el8.aarch64 pigsty 776.2 KiB pg_strict_18-1.0.5-3PIGSTY.el8.aarch64.rpm
pg_strict_18 1.0.5 el9.x86_64 pigsty 872.1 KiB pg_strict_18-1.0.5-3PIGSTY.el9.x86_64.rpm
pg_strict_18 1.0.5 el9.aarch64 pigsty 822.9 KiB pg_strict_18-1.0.5-3PIGSTY.el9.aarch64.rpm
pg_strict_18 1.0.5 el10.x86_64 pigsty 872.0 KiB pg_strict_18-1.0.5-3PIGSTY.el10.x86_64.rpm
pg_strict_18 1.0.5 el10.aarch64 pigsty 801.3 KiB pg_strict_18-1.0.5-3PIGSTY.el10.aarch64.rpm
postgresql-18-pg-strict 1.0.5 d12.x86_64 pigsty 689.2 KiB postgresql-18-pg-strict_1.0.5-3PIGSTY~bookworm_amd64.deb
postgresql-18-pg-strict 1.0.5 d12.aarch64 pigsty 575.6 KiB postgresql-18-pg-strict_1.0.5-3PIGSTY~bookworm_arm64.deb
postgresql-18-pg-strict 1.0.5 d13.x86_64 pigsty 689.7 KiB postgresql-18-pg-strict_1.0.5-3PIGSTY~trixie_amd64.deb
postgresql-18-pg-strict 1.0.5 d13.aarch64 pigsty 576.3 KiB postgresql-18-pg-strict_1.0.5-3PIGSTY~trixie_arm64.deb
postgresql-18-pg-strict 1.0.5 u22.x86_64 pigsty 769.8 KiB postgresql-18-pg-strict_1.0.5-3PIGSTY~jammy_amd64.deb
postgresql-18-pg-strict 1.0.5 u22.aarch64 pigsty 678.9 KiB postgresql-18-pg-strict_1.0.5-3PIGSTY~jammy_arm64.deb
postgresql-18-pg-strict 1.0.5 u24.x86_64 pigsty 760.3 KiB postgresql-18-pg-strict_1.0.5-3PIGSTY~noble_amd64.deb
postgresql-18-pg-strict 1.0.5 u24.aarch64 pigsty 671.7 KiB postgresql-18-pg-strict_1.0.5-3PIGSTY~noble_arm64.deb
postgresql-18-pg-strict 1.0.5 u26.x86_64 pigsty 754.8 KiB postgresql-18-pg-strict_1.0.5-3PIGSTY~resolute_amd64.deb
postgresql-18-pg-strict 1.0.5 u26.aarch64 pigsty 670.7 KiB postgresql-18-pg-strict_1.0.5-3PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_strict_17 1.0.5 el8.x86_64 pigsty 860.9 KiB pg_strict_17-1.0.5-3PIGSTY.el8.x86_64.rpm
pg_strict_17 1.0.5 el8.aarch64 pigsty 773.1 KiB pg_strict_17-1.0.5-3PIGSTY.el8.aarch64.rpm
pg_strict_17 1.0.5 el9.x86_64 pigsty 869.9 KiB pg_strict_17-1.0.5-3PIGSTY.el9.x86_64.rpm
pg_strict_17 1.0.5 el9.aarch64 pigsty 819.5 KiB pg_strict_17-1.0.5-3PIGSTY.el9.aarch64.rpm
pg_strict_17 1.0.5 el10.x86_64 pigsty 871.6 KiB pg_strict_17-1.0.5-3PIGSTY.el10.x86_64.rpm
pg_strict_17 1.0.5 el10.aarch64 pigsty 800.5 KiB pg_strict_17-1.0.5-3PIGSTY.el10.aarch64.rpm
postgresql-17-pg-strict 1.0.5 d12.x86_64 pigsty 687.8 KiB postgresql-17-pg-strict_1.0.5-3PIGSTY~bookworm_amd64.deb
postgresql-17-pg-strict 1.0.5 d12.aarch64 pigsty 574.3 KiB postgresql-17-pg-strict_1.0.5-3PIGSTY~bookworm_arm64.deb
postgresql-17-pg-strict 1.0.5 d13.x86_64 pigsty 687.2 KiB postgresql-17-pg-strict_1.0.5-3PIGSTY~trixie_amd64.deb
postgresql-17-pg-strict 1.0.5 d13.aarch64 pigsty 574.8 KiB postgresql-17-pg-strict_1.0.5-3PIGSTY~trixie_arm64.deb
postgresql-17-pg-strict 1.0.5 u22.x86_64 pigsty 768.1 KiB postgresql-17-pg-strict_1.0.5-3PIGSTY~jammy_amd64.deb
postgresql-17-pg-strict 1.0.5 u22.aarch64 pigsty 678.1 KiB postgresql-17-pg-strict_1.0.5-3PIGSTY~jammy_arm64.deb
postgresql-17-pg-strict 1.0.5 u24.x86_64 pigsty 758.0 KiB postgresql-17-pg-strict_1.0.5-3PIGSTY~noble_amd64.deb
postgresql-17-pg-strict 1.0.5 u24.aarch64 pigsty 670.0 KiB postgresql-17-pg-strict_1.0.5-3PIGSTY~noble_arm64.deb
postgresql-17-pg-strict 1.0.5 u26.x86_64 pigsty 753.0 KiB postgresql-17-pg-strict_1.0.5-3PIGSTY~resolute_amd64.deb
postgresql-17-pg-strict 1.0.5 u26.aarch64 pigsty 668.2 KiB postgresql-17-pg-strict_1.0.5-3PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_strict_16 1.0.5 el8.x86_64 pigsty 859.5 KiB pg_strict_16-1.0.5-3PIGSTY.el8.x86_64.rpm
pg_strict_16 1.0.5 el8.aarch64 pigsty 771.1 KiB pg_strict_16-1.0.5-3PIGSTY.el8.aarch64.rpm
pg_strict_16 1.0.5 el9.x86_64 pigsty 864.4 KiB pg_strict_16-1.0.5-3PIGSTY.el9.x86_64.rpm
pg_strict_16 1.0.5 el9.aarch64 pigsty 817.4 KiB pg_strict_16-1.0.5-3PIGSTY.el9.aarch64.rpm
pg_strict_16 1.0.5 el10.x86_64 pigsty 869.2 KiB pg_strict_16-1.0.5-3PIGSTY.el10.x86_64.rpm
pg_strict_16 1.0.5 el10.aarch64 pigsty 800.1 KiB pg_strict_16-1.0.5-3PIGSTY.el10.aarch64.rpm
postgresql-16-pg-strict 1.0.5 d12.x86_64 pigsty 686.5 KiB postgresql-16-pg-strict_1.0.5-3PIGSTY~bookworm_amd64.deb
postgresql-16-pg-strict 1.0.5 d12.aarch64 pigsty 573.6 KiB postgresql-16-pg-strict_1.0.5-3PIGSTY~bookworm_arm64.deb
postgresql-16-pg-strict 1.0.5 d13.x86_64 pigsty 687.0 KiB postgresql-16-pg-strict_1.0.5-3PIGSTY~trixie_amd64.deb
postgresql-16-pg-strict 1.0.5 d13.aarch64 pigsty 573.7 KiB postgresql-16-pg-strict_1.0.5-3PIGSTY~trixie_arm64.deb
postgresql-16-pg-strict 1.0.5 u22.x86_64 pigsty 765.3 KiB postgresql-16-pg-strict_1.0.5-3PIGSTY~jammy_amd64.deb
postgresql-16-pg-strict 1.0.5 u22.aarch64 pigsty 676.4 KiB postgresql-16-pg-strict_1.0.5-3PIGSTY~jammy_arm64.deb
postgresql-16-pg-strict 1.0.5 u24.x86_64 pigsty 757.4 KiB postgresql-16-pg-strict_1.0.5-3PIGSTY~noble_amd64.deb
postgresql-16-pg-strict 1.0.5 u24.aarch64 pigsty 668.7 KiB postgresql-16-pg-strict_1.0.5-3PIGSTY~noble_arm64.deb
postgresql-16-pg-strict 1.0.5 u26.x86_64 pigsty 752.1 KiB postgresql-16-pg-strict_1.0.5-3PIGSTY~resolute_amd64.deb
postgresql-16-pg-strict 1.0.5 u26.aarch64 pigsty 667.0 KiB postgresql-16-pg-strict_1.0.5-3PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_strict_15 1.0.5 el8.x86_64 pigsty 850.0 KiB pg_strict_15-1.0.5-3PIGSTY.el8.x86_64.rpm
pg_strict_15 1.0.5 el8.aarch64 pigsty 762.0 KiB pg_strict_15-1.0.5-3PIGSTY.el8.aarch64.rpm
pg_strict_15 1.0.5 el9.x86_64 pigsty 858.7 KiB pg_strict_15-1.0.5-3PIGSTY.el9.x86_64.rpm
pg_strict_15 1.0.5 el9.aarch64 pigsty 807.5 KiB pg_strict_15-1.0.5-3PIGSTY.el9.aarch64.rpm
pg_strict_15 1.0.5 el10.x86_64 pigsty 858.7 KiB pg_strict_15-1.0.5-3PIGSTY.el10.x86_64.rpm
pg_strict_15 1.0.5 el10.aarch64 pigsty 796.8 KiB pg_strict_15-1.0.5-3PIGSTY.el10.aarch64.rpm
postgresql-15-pg-strict 1.0.5 d12.x86_64 pigsty 680.2 KiB postgresql-15-pg-strict_1.0.5-3PIGSTY~bookworm_amd64.deb
postgresql-15-pg-strict 1.0.5 d12.aarch64 pigsty 569.4 KiB postgresql-15-pg-strict_1.0.5-3PIGSTY~bookworm_arm64.deb
postgresql-15-pg-strict 1.0.5 d13.x86_64 pigsty 680.4 KiB postgresql-15-pg-strict_1.0.5-3PIGSTY~trixie_amd64.deb
postgresql-15-pg-strict 1.0.5 d13.aarch64 pigsty 569.4 KiB postgresql-15-pg-strict_1.0.5-3PIGSTY~trixie_arm64.deb
postgresql-15-pg-strict 1.0.5 u22.x86_64 pigsty 757.3 KiB postgresql-15-pg-strict_1.0.5-3PIGSTY~jammy_amd64.deb
postgresql-15-pg-strict 1.0.5 u22.aarch64 pigsty 669.7 KiB postgresql-15-pg-strict_1.0.5-3PIGSTY~jammy_arm64.deb
postgresql-15-pg-strict 1.0.5 u24.x86_64 pigsty 749.5 KiB postgresql-15-pg-strict_1.0.5-3PIGSTY~noble_amd64.deb
postgresql-15-pg-strict 1.0.5 u24.aarch64 pigsty 663.1 KiB postgresql-15-pg-strict_1.0.5-3PIGSTY~noble_arm64.deb
postgresql-15-pg-strict 1.0.5 u26.x86_64 pigsty 745.4 KiB postgresql-15-pg-strict_1.0.5-3PIGSTY~resolute_amd64.deb
postgresql-15-pg-strict 1.0.5 u26.aarch64 pigsty 661.4 KiB postgresql-15-pg-strict_1.0.5-3PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_strict_14 1.0.5 el8.x86_64 pigsty 847.9 KiB pg_strict_14-1.0.5-3PIGSTY.el8.x86_64.rpm
pg_strict_14 1.0.5 el8.aarch64 pigsty 759.4 KiB pg_strict_14-1.0.5-3PIGSTY.el8.aarch64.rpm
pg_strict_14 1.0.5 el9.x86_64 pigsty 856.5 KiB pg_strict_14-1.0.5-3PIGSTY.el9.x86_64.rpm
pg_strict_14 1.0.5 el9.aarch64 pigsty 805.9 KiB pg_strict_14-1.0.5-3PIGSTY.el9.aarch64.rpm
pg_strict_14 1.0.5 el10.x86_64 pigsty 856.2 KiB pg_strict_14-1.0.5-3PIGSTY.el10.x86_64.rpm
pg_strict_14 1.0.5 el10.aarch64 pigsty 794.4 KiB pg_strict_14-1.0.5-3PIGSTY.el10.aarch64.rpm
postgresql-14-pg-strict 1.0.5 d12.x86_64 pigsty 678.6 KiB postgresql-14-pg-strict_1.0.5-3PIGSTY~bookworm_amd64.deb
postgresql-14-pg-strict 1.0.5 d12.aarch64 pigsty 567.1 KiB postgresql-14-pg-strict_1.0.5-3PIGSTY~bookworm_arm64.deb
postgresql-14-pg-strict 1.0.5 d13.x86_64 pigsty 678.9 KiB postgresql-14-pg-strict_1.0.5-3PIGSTY~trixie_amd64.deb
postgresql-14-pg-strict 1.0.5 d13.aarch64 pigsty 567.6 KiB postgresql-14-pg-strict_1.0.5-3PIGSTY~trixie_arm64.deb
postgresql-14-pg-strict 1.0.5 u22.x86_64 pigsty 755.7 KiB postgresql-14-pg-strict_1.0.5-3PIGSTY~jammy_amd64.deb
postgresql-14-pg-strict 1.0.5 u22.aarch64 pigsty 667.6 KiB postgresql-14-pg-strict_1.0.5-3PIGSTY~jammy_arm64.deb
postgresql-14-pg-strict 1.0.5 u24.x86_64 pigsty 748.1 KiB postgresql-14-pg-strict_1.0.5-3PIGSTY~noble_amd64.deb
postgresql-14-pg-strict 1.0.5 u24.aarch64 pigsty 661.1 KiB postgresql-14-pg-strict_1.0.5-3PIGSTY~noble_arm64.deb
postgresql-14-pg-strict 1.0.5 u26.x86_64 pigsty 743.9 KiB postgresql-14-pg-strict_1.0.5-3PIGSTY~resolute_amd64.deb
postgresql-14-pg-strict 1.0.5 u26.aarch64 pigsty 658.4 KiB postgresql-14-pg-strict_1.0.5-3PIGSTY~resolute_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; upstream documents PostgreSQL 13 through 18, while the Pigsty package row in db/extension.csv covers PostgreSQL 14 through 18.
  • The Pigsty note about pgrx 0.17.0 is packaging/build metadata, not a documented user-facing feature change.