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
|
Source
pig build pkg pg_strict; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall 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 14Config 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_updatepg_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)andpg_strict_set_delete_mode(mode)provide generic mode setters.SET LOCALworks for one-off bulk operations inside a transaction.
Caveats
- Enforcement is presence-based, not intent-based: any non-null
WHEREclause satisfies the rule. - Only
UPDATEandDELETEare checked. - Current upstream release is
1.0.5; the Pigsty note aboutpgrx0.17.0 is packaging/build metadata, not a documented user-facing feature change.
Last updated on