pg_iot
pg_iot · Restrict selected tables to inserts and reads using server hooks.
Overview
PostgreSQL · 14, 15, 16, 17, 18, 19
Usage
Sources:
pg_iot marks selected tables as insert-only tables. Version 0.0.1 uses server hooks to reject UPDATE, DELETE, MERGE, TRUNCATE and ALTER TABLE for registered tables while retaining INSERT and SELECT. Upstream reports validation on PostgreSQL 14–19.
Enable and Register a Table
Add the library to the existing preload list and restart PostgreSQL:
As a superuser, install the extension in the database and register an existing table by schema and name:
The non-relocatable extension creates the fixed iot schema. iot.pg_iot_set(cstring, cstring) returns boolean and is revoked from PUBLIC. iot.tables records the namespace, relation name and OID of registered tables. The preload setting must preserve other required libraries.
Maintenance Boundary
The documented interface has no operation to turn an insert-only table back into an ordinary table. Plan schema changes and data retention before registration. This extension depends on its library being preloaded and on its catalog; it is not a tamper-proof archive against database or operating-system administrators. Ordinary table privileges still determine who may read or insert data.