pg_readonly
pg_readonly : cluster database read only
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 5120 | pg_readonly | pg_readonly | 1.0.6 |
ADMIN | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| See Also | plan_filter pg_kpart prioritize qos pg_permissions set_user pg_roast pg_command_fw pg_hint_plan |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED | 1.0.6 |
18 17 16 15 14 | pg_readonly |
- |
| RPM | PGDG | 1.0.6 |
18 17 16 15 14 | pg_readonly_$v |
- |
| DEB | PIGSTY | 1.0.5 |
18 17 16 15 14 | postgresql-$v-pg-readonly |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 |
| el8.aarch64 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 |
| el9.x86_64 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 |
| el9.aarch64 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 |
| el10.x86_64 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 |
| el10.aarch64 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 | PGDG 1.0.6 |
| 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 |
Source
github.com/pierreforstmann/pg_readonly
pg_readonly-1.0.5.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
pg_readonly sets all databases in a PostgreSQL cluster to read-only mode at the SQL level. It must be loaded via shared_preload_libraries. The read-only status is managed in shared memory with a global flag (not persisted across restarts).
Check Read-Only Status
Set Cluster Read-Only
In read-only mode, SELECT statements are allowed (unless they call writing functions), but DML (INSERT, UPDATE, DELETE), DDL (including TRUNCATE), and DCL (GRANT, REVOKE) are blocked:
Note: set_cluster_readonly() terminates all open transactions.
Set Cluster Read-Write
Note: background processes (checkpointer, bgwriter, walwriter, autovacuum) continue running in read-only mode – the restriction is at the SQL statement level only.