跳转到主要内容

safeupdate

Require criteria for UPDATE and DELETE

safeupdate : Require criteria for UPDATE and DELETE

Overview

ID Extension Package Version Category License Language
5820 safeupdate safeupdate 1.7 ADMIN ISC C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sL--- No Yes Yes No no no

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PGDG 1.7 19 18 17 16 15 safeupdate -
RPM PGDG 1.7 19 18 17 16 15 safeupdate_$v -
DEB PIGSTY 1.7 19 18 17 16 15 postgresql-$v-pg-safeupdate -
Linux / PG PG19 PG18 PG17 PG16 PG15
el8.x86_64 N/A PGDG 1.7 PGDG 1.7 PGDG 1.7 PGDG 1.7
el8.aarch64 N/A PGDG 1.7 PGDG 1.7 PGDG 1.7 PGDG 1.7
el9.x86_64 PGDG 1.7 PGDG 1.7 PGDG 1.7 PGDG 1.7 PGDG 1.7
el9.aarch64 PGDG 1.7 PGDG 1.7 PGDG 1.7 PGDG 1.7 PGDG 1.7
el10.x86_64 PGDG 1.7 PGDG 1.7 PGDG 1.7 PGDG 1.7 PGDG 1.7
el10.aarch64 PGDG 1.7 PGDG 1.7 PGDG 1.7 PGDG 1.7 PGDG 1.7
d12.x86_64 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7
d12.aarch64 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7
d13.x86_64 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7
d13.aarch64 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7
u22.x86_64 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7
u22.aarch64 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7
u24.x86_64 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7
u24.aarch64 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7
u26.x86_64 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7
u26.aarch64 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7 PIGSTY 1.7
Package Version OS ORG SIZE File URL
safeupdate_19 1.7 el9.x86_64 pgdg 13.6 KiB safeupdate_19-1.7-4PGDG.rhel9.9.x86_64.rpm
safeupdate_19 1.7 el9.aarch64 pgdg 13.5 KiB safeupdate_19-1.7-4PGDG.rhel9.9.aarch64.rpm
safeupdate_19 1.7 el10.x86_64 pgdg 13.7 KiB safeupdate_19-1.7-4PGDG.rhel10.3.x86_64.rpm
safeupdate_19 1.7 el10.aarch64 pgdg 13.7 KiB safeupdate_19-1.7-4PGDG.rhel10.3.aarch64.rpm
postgresql-19-pg-safeupdate 1.7 d12.x86_64 pigsty 8.8 KiB postgresql-19-pg-safeupdate_1.7-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-safeupdate 1.7 d12.aarch64 pigsty 8.9 KiB postgresql-19-pg-safeupdate_1.7-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-safeupdate 1.7 d13.x86_64 pigsty 8.8 KiB postgresql-19-pg-safeupdate_1.7-1PGSTY~trixie_amd64.deb
postgresql-19-pg-safeupdate 1.7 d13.aarch64 pigsty 8.9 KiB postgresql-19-pg-safeupdate_1.7-1PGSTY~trixie_arm64.deb
postgresql-19-pg-safeupdate 1.7 u22.x86_64 pigsty 8.9 KiB postgresql-19-pg-safeupdate_1.7-1PGSTY~jammy_amd64.deb
postgresql-19-pg-safeupdate 1.7 u22.aarch64 pigsty 9.0 KiB postgresql-19-pg-safeupdate_1.7-1PGSTY~jammy_arm64.deb
postgresql-19-pg-safeupdate 1.7 u24.x86_64 pigsty 9.1 KiB postgresql-19-pg-safeupdate_1.7-1PGSTY~noble_amd64.deb
postgresql-19-pg-safeupdate 1.7 u24.aarch64 pigsty 9.1 KiB postgresql-19-pg-safeupdate_1.7-1PGSTY~noble_arm64.deb
postgresql-19-pg-safeupdate 1.7 u26.x86_64 pigsty 9.2 KiB postgresql-19-pg-safeupdate_1.7-1PGSTY~resolute_amd64.deb
postgresql-19-pg-safeupdate 1.7 u26.aarch64 pigsty 9.3 KiB postgresql-19-pg-safeupdate_1.7-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
safeupdate_18 1.7 el8.x86_64 pgdg 14.5 KiB safeupdate_18-1.7-4PGDG.rhel8.10.x86_64.rpm
safeupdate_18 1.5 el8.x86_64 pgdg 13.4 KiB safeupdate_18-1.5-2PGDG.rhel8.x86_64.rpm
safeupdate_18 1.7 el8.aarch64 pgdg 14.5 KiB safeupdate_18-1.7-4PGDG.rhel8.10.aarch64.rpm
safeupdate_18 1.5 el8.aarch64 pgdg 13.4 KiB safeupdate_18-1.5-2PGDG.rhel8.aarch64.rpm
safeupdate_18 1.7 el9.x86_64 pgdg 13.6 KiB safeupdate_18-1.7-4PGDG.rhel9.9.x86_64.rpm
safeupdate_18 1.7 el9.aarch64 pgdg 13.5 KiB safeupdate_18-1.7-4PGDG.rhel9.9.aarch64.rpm
safeupdate_18 1.7 el10.x86_64 pgdg 13.7 KiB safeupdate_18-1.7-4PGDG.rhel10.3.x86_64.rpm
safeupdate_18 1.7 el10.aarch64 pgdg 13.7 KiB safeupdate_18-1.7-4PGDG.rhel10.3.aarch64.rpm
safeupdate_18 1.7 el10.aarch64 pgdg 13.7 KiB safeupdate_18-1.7-4PGDG.rhel10.2.aarch64.rpm
safeupdate_18 1.5 el10.aarch64 pgdg 13.0 KiB safeupdate_18-1.5-4PGDG.rhel10.2.aarch64.rpm
safeupdate_18 1.5 el10.aarch64 pgdg 13.2 KiB safeupdate_18-1.5-2PGDG.rhel10.aarch64.rpm
postgresql-18-pg-safeupdate 1.7 d12.x86_64 pigsty 8.8 KiB postgresql-18-pg-safeupdate_1.7-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-safeupdate 1.7 d12.aarch64 pigsty 8.9 KiB postgresql-18-pg-safeupdate_1.7-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-safeupdate 1.7 d13.x86_64 pigsty 8.8 KiB postgresql-18-pg-safeupdate_1.7-1PGSTY~trixie_amd64.deb
postgresql-18-pg-safeupdate 1.7 d13.aarch64 pigsty 8.9 KiB postgresql-18-pg-safeupdate_1.7-1PGSTY~trixie_arm64.deb
postgresql-18-pg-safeupdate 1.7 u22.x86_64 pigsty 8.9 KiB postgresql-18-pg-safeupdate_1.7-1PGSTY~jammy_amd64.deb
postgresql-18-pg-safeupdate 1.7 u22.aarch64 pigsty 9.0 KiB postgresql-18-pg-safeupdate_1.7-1PGSTY~jammy_arm64.deb
postgresql-18-pg-safeupdate 1.7 u24.x86_64 pigsty 9.1 KiB postgresql-18-pg-safeupdate_1.7-1PGSTY~noble_amd64.deb
postgresql-18-pg-safeupdate 1.7 u24.aarch64 pigsty 9.1 KiB postgresql-18-pg-safeupdate_1.7-1PGSTY~noble_arm64.deb
postgresql-18-pg-safeupdate 1.7 u26.x86_64 pigsty 9.2 KiB postgresql-18-pg-safeupdate_1.7-1PGSTY~resolute_amd64.deb
postgresql-18-pg-safeupdate 1.7 u26.aarch64 pigsty 9.3 KiB postgresql-18-pg-safeupdate_1.7-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
safeupdate_17 1.7 el8.x86_64 pgdg 14.5 KiB safeupdate_17-1.7-4PGDG.rhel8.10.x86_64.rpm
safeupdate_17 1.5 el8.x86_64 pgdg 13.3 KiB safeupdate_17-1.5-1PGDG.rhel8.x86_64.rpm
safeupdate_17 1.7 el8.aarch64 pgdg 14.5 KiB safeupdate_17-1.7-4PGDG.rhel8.10.aarch64.rpm
safeupdate_17 1.5 el8.aarch64 pgdg 13.3 KiB safeupdate_17-1.5-1PGDG.rhel8.aarch64.rpm
safeupdate_17 1.7 el9.x86_64 pgdg 13.6 KiB safeupdate_17-1.7-4PGDG.rhel9.9.x86_64.rpm
safeupdate_17 1.7 el9.aarch64 pgdg 13.5 KiB safeupdate_17-1.7-4PGDG.rhel9.9.aarch64.rpm
safeupdate_17 1.7 el10.x86_64 pgdg 13.7 KiB safeupdate_17-1.7-4PGDG.rhel10.3.x86_64.rpm
safeupdate_17 1.7 el10.aarch64 pgdg 13.8 KiB safeupdate_17-1.7-4PGDG.rhel10.3.aarch64.rpm
safeupdate_17 1.7 el10.aarch64 pgdg 13.7 KiB safeupdate_17-1.7-4PGDG.rhel10.2.aarch64.rpm
safeupdate_17 1.5 el10.aarch64 pgdg 13.0 KiB safeupdate_17-1.5-4PGDG.rhel10.2.aarch64.rpm
safeupdate_17 1.5 el10.aarch64 pgdg 13.2 KiB safeupdate_17-1.5-2PGDG.rhel10.aarch64.rpm
postgresql-17-pg-safeupdate 1.7 d12.x86_64 pigsty 8.8 KiB postgresql-17-pg-safeupdate_1.7-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-safeupdate 1.7 d12.aarch64 pigsty 8.8 KiB postgresql-17-pg-safeupdate_1.7-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-safeupdate 1.7 d13.x86_64 pigsty 8.8 KiB postgresql-17-pg-safeupdate_1.7-1PGSTY~trixie_amd64.deb
postgresql-17-pg-safeupdate 1.7 d13.aarch64 pigsty 8.9 KiB postgresql-17-pg-safeupdate_1.7-1PGSTY~trixie_arm64.deb
postgresql-17-pg-safeupdate 1.7 u22.x86_64 pigsty 9.5 KiB postgresql-17-pg-safeupdate_1.7-1PGSTY~jammy_amd64.deb
postgresql-17-pg-safeupdate 1.7 u22.aarch64 pigsty 9.6 KiB postgresql-17-pg-safeupdate_1.7-1PGSTY~jammy_arm64.deb
postgresql-17-pg-safeupdate 1.7 u24.x86_64 pigsty 9.1 KiB postgresql-17-pg-safeupdate_1.7-1PGSTY~noble_amd64.deb
postgresql-17-pg-safeupdate 1.7 u24.aarch64 pigsty 9.1 KiB postgresql-17-pg-safeupdate_1.7-1PGSTY~noble_arm64.deb
postgresql-17-pg-safeupdate 1.7 u26.x86_64 pigsty 9.2 KiB postgresql-17-pg-safeupdate_1.7-1PGSTY~resolute_amd64.deb
postgresql-17-pg-safeupdate 1.7 u26.aarch64 pigsty 9.3 KiB postgresql-17-pg-safeupdate_1.7-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
safeupdate_16 1.7 el8.x86_64 pgdg 14.5 KiB safeupdate_16-1.7-4PGDG.rhel8.10.x86_64.rpm
safeupdate_16 1.5 el8.x86_64 pgdg 13.3 KiB safeupdate_16-1.5-1PGDG.rhel8.x86_64.rpm
safeupdate_16 1.4.2 el8.x86_64 pgdg 13.4 KiB safeupdate_16-1.4.2-2PGDG.rhel8.x86_64.rpm
safeupdate_16 1.7 el8.aarch64 pgdg 14.5 KiB safeupdate_16-1.7-4PGDG.rhel8.10.aarch64.rpm
safeupdate_16 1.5 el8.aarch64 pgdg 13.3 KiB safeupdate_16-1.5-1PGDG.rhel8.aarch64.rpm
safeupdate_16 1.4.2 el8.aarch64 pgdg 13.4 KiB safeupdate_16-1.4.2-2PGDG.rhel8.aarch64.rpm
safeupdate_16 1.7 el9.x86_64 pgdg 13.6 KiB safeupdate_16-1.7-4PGDG.rhel9.9.x86_64.rpm
safeupdate_16 1.7 el9.aarch64 pgdg 13.5 KiB safeupdate_16-1.7-4PGDG.rhel9.9.aarch64.rpm
safeupdate_16 1.7 el10.x86_64 pgdg 13.7 KiB safeupdate_16-1.7-4PGDG.rhel10.3.x86_64.rpm
safeupdate_16 1.7 el10.aarch64 pgdg 13.8 KiB safeupdate_16-1.7-4PGDG.rhel10.3.aarch64.rpm
safeupdate_16 1.7 el10.aarch64 pgdg 13.8 KiB safeupdate_16-1.7-4PGDG.rhel10.2.aarch64.rpm
safeupdate_16 1.5 el10.aarch64 pgdg 13.0 KiB safeupdate_16-1.5-4PGDG.rhel10.2.aarch64.rpm
safeupdate_16 1.5 el10.aarch64 pgdg 13.2 KiB safeupdate_16-1.5-2PGDG.rhel10.aarch64.rpm
postgresql-16-pg-safeupdate 1.7 d12.x86_64 pigsty 8.8 KiB postgresql-16-pg-safeupdate_1.7-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-safeupdate 1.7 d12.aarch64 pigsty 8.8 KiB postgresql-16-pg-safeupdate_1.7-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-safeupdate 1.7 d13.x86_64 pigsty 8.8 KiB postgresql-16-pg-safeupdate_1.7-1PGSTY~trixie_amd64.deb
postgresql-16-pg-safeupdate 1.7 d13.aarch64 pigsty 8.9 KiB postgresql-16-pg-safeupdate_1.7-1PGSTY~trixie_arm64.deb
postgresql-16-pg-safeupdate 1.7 u22.x86_64 pigsty 9.6 KiB postgresql-16-pg-safeupdate_1.7-1PGSTY~jammy_amd64.deb
postgresql-16-pg-safeupdate 1.7 u22.aarch64 pigsty 9.6 KiB postgresql-16-pg-safeupdate_1.7-1PGSTY~jammy_arm64.deb
postgresql-16-pg-safeupdate 1.7 u24.x86_64 pigsty 9.1 KiB postgresql-16-pg-safeupdate_1.7-1PGSTY~noble_amd64.deb
postgresql-16-pg-safeupdate 1.7 u24.aarch64 pigsty 9.3 KiB postgresql-16-pg-safeupdate_1.7-1PGSTY~noble_arm64.deb
postgresql-16-pg-safeupdate 1.7 u26.x86_64 pigsty 9.2 KiB postgresql-16-pg-safeupdate_1.7-1PGSTY~resolute_amd64.deb
postgresql-16-pg-safeupdate 1.7 u26.aarch64 pigsty 9.3 KiB postgresql-16-pg-safeupdate_1.7-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
safeupdate_15 1.7 el8.x86_64 pgdg 14.5 KiB safeupdate_15-1.7-4PGDG.rhel8.10.x86_64.rpm
safeupdate_15 1.5 el8.x86_64 pgdg 13.3 KiB safeupdate_15-1.5-1PGDG.rhel8.x86_64.rpm
safeupdate_15 1.4 el8.x86_64 pgdg 17.8 KiB safeupdate_15-1.4-1.rhel8.x86_64.rpm
safeupdate_15 1.7 el8.aarch64 pgdg 14.5 KiB safeupdate_15-1.7-4PGDG.rhel8.10.aarch64.rpm
safeupdate_15 1.5 el8.aarch64 pgdg 13.3 KiB safeupdate_15-1.5-1PGDG.rhel8.aarch64.rpm
safeupdate_15 1.4.2 el8.aarch64 pgdg 13.3 KiB safeupdate_15-1.4.2-1.rhel8.aarch64.rpm
safeupdate_15 1.4 el8.aarch64 pgdg 17.8 KiB safeupdate_15-1.4-1.rhel8.aarch64.rpm
safeupdate_15 1.7 el9.x86_64 pgdg 13.6 KiB safeupdate_15-1.7-4PGDG.rhel9.9.x86_64.rpm
safeupdate_15 1.7 el9.aarch64 pgdg 13.5 KiB safeupdate_15-1.7-4PGDG.rhel9.9.aarch64.rpm
safeupdate_15 1.7 el10.x86_64 pgdg 13.7 KiB safeupdate_15-1.7-4PGDG.rhel10.3.x86_64.rpm
safeupdate_15 1.7 el10.aarch64 pgdg 13.7 KiB safeupdate_15-1.7-4PGDG.rhel10.3.aarch64.rpm
safeupdate_15 1.7 el10.aarch64 pgdg 13.8 KiB safeupdate_15-1.7-4PGDG.rhel10.2.aarch64.rpm
safeupdate_15 1.5 el10.aarch64 pgdg 13.0 KiB safeupdate_15-1.5-4PGDG.rhel10.2.aarch64.rpm
safeupdate_15 1.5 el10.aarch64 pgdg 13.3 KiB safeupdate_15-1.5-2PGDG.rhel10.aarch64.rpm
postgresql-15-pg-safeupdate 1.7 d12.x86_64 pigsty 8.8 KiB postgresql-15-pg-safeupdate_1.7-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-safeupdate 1.7 d12.aarch64 pigsty 9.4 KiB postgresql-15-pg-safeupdate_1.7-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-safeupdate 1.7 d13.x86_64 pigsty 8.8 KiB postgresql-15-pg-safeupdate_1.7-1PGSTY~trixie_amd64.deb
postgresql-15-pg-safeupdate 1.7 d13.aarch64 pigsty 8.9 KiB postgresql-15-pg-safeupdate_1.7-1PGSTY~trixie_arm64.deb
postgresql-15-pg-safeupdate 1.7 u22.x86_64 pigsty 9.5 KiB postgresql-15-pg-safeupdate_1.7-1PGSTY~jammy_amd64.deb
postgresql-15-pg-safeupdate 1.7 u22.aarch64 pigsty 9.6 KiB postgresql-15-pg-safeupdate_1.7-1PGSTY~jammy_arm64.deb
postgresql-15-pg-safeupdate 1.7 u24.x86_64 pigsty 9.1 KiB postgresql-15-pg-safeupdate_1.7-1PGSTY~noble_amd64.deb
postgresql-15-pg-safeupdate 1.7 u24.aarch64 pigsty 9.1 KiB postgresql-15-pg-safeupdate_1.7-1PGSTY~noble_arm64.deb
postgresql-15-pg-safeupdate 1.7 u26.x86_64 pigsty 9.2 KiB postgresql-15-pg-safeupdate_1.7-1PGSTY~resolute_amd64.deb
postgresql-15-pg-safeupdate 1.7 u26.aarch64 pigsty 9.3 KiB postgresql-15-pg-safeupdate_1.7-1PGSTY~resolute_arm64.deb

Source

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

pig install safeupdate -v 19;   # install for PG 19
pig install safeupdate -v 18;   # install for PG 18
pig install safeupdate -v 17;   # install for PG 17
pig install safeupdate -v 16;   # install for PG 16
pig install safeupdate -v 15;   # install for PG 15

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'safeupdate';

This extension does not need CREATE EXTENSION DDL command

Usage

safeupdate: Require criteria for UPDATE and DELETE

The safeupdate extension prevents accidental mass data changes by raising an error whenever UPDATE or DELETE statements are executed without a WHERE clause.

Activation

-- Per-session
LOAD 'safeupdate';

-- Per-database (persistent)
ALTER DATABASE mydb SET session_preload_libraries = 'safeupdate';

-- Global (all databases, requires restart)
-- shared_preload_libraries = 'safeupdate'   -- in postgresql.conf

Behavior

-- Blocked: UPDATE without WHERE
UPDATE rack SET fan_speed = 70;
-- ERROR: UPDATE requires a WHERE clause

-- Blocked: DELETE without WHERE
DELETE FROM rack;
-- ERROR: DELETE requires a WHERE clause

-- Allowed: with WHERE clause
UPDATE rack SET fan_speed = 90 WHERE fan_speed = 70;

-- Workaround: explicit always-true condition
UPDATE rack SET fan_speed = 90 WHERE 1 = 1;

Administrative Override

-- Temporarily disable protection in current session
SET safeupdate.enabled = 0;

CTE-based modifications without WHERE conditions are also blocked. The extension is particularly useful with PostgREST or other systems that provide direct write access to the database.

表格阅读器