pg_storage
alohadb · AlohaDB storage metadata, policies and helpers for pg_restapi object APIs
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102471 | pg_storage | alohadb | 1.1 | FEAT | MIT | SQL |
PostgreSQL · 18
| Relationships | |
|---|---|
| Requires | pg_restapi plpgsql |
Usage
Sources:
pg_storage 1.1 supplies AlohaDB’s fixed storage schema, object metadata and policy helpers for pg_restapi’s /storage/v1 API. The reviewed AlohaDB 21.7.0 distribution is based on PostgreSQL 18. The extension installs no separate library, but storage.gc() calls the pg_restapi C library: the matching REST binary is a runtime dependency despite the control file having no requires list.
Install and Define Access
A superuser installs the matching pg_restapi extension and listener first, then creates pg_storage. Preloading and restarting are needed for the REST worker, not for a separate storage worker. Create API roles before installation if they should receive the automatic table grants. Optional pg_auth supplies the usual roles and claim helpers.
The example creates a private bucket but grants no object policy. storage.buckets and storage.objects have row-level security enabled; write policies and table grants for the intended roles before using the API. Upload needs INSERT, overwrite also SELECT/UPDATE, download and listing SELECT, and deletion SELECT/DELETE. service_role with BYPASSRLS bypasses policies. The extension itself does not provide auth.uid(); policies may use verified request.jwt.claim.sub instead.
Data and Maintenance
storage.list_objects and storage.list_objects_v2 list names under the caller’s policies. Metadata belongs to storage.objects; bytes are stored by the configured REST backend in files, storage.object_blobs, or S3. Resumable uploads use server-only bookkeeping tables. Keep metadata and payload storage recoverable together; an ordinary database dump does not include filesystem or S3 payloads.
storage.gc(min_age) removes eligible unreferenced payloads and abandoned uploads and is not publicly executable; the REST worker also runs maintenance periodically. Do not delete metadata directly as a substitute for the API’s coordinated lifecycle. Preserve data before dropping the extension.
API Limits
Object names, MIME types and file sizes are validated. Configure pg_restapi.storage_max_file_size with worker memory in mind: whole HTTP requests/responses are buffered, so use bounded resumable chunks and Range downloads for large objects. Signed URLs depend on the JWT secret; rotating it revokes them. Full S3 protocol service, object versioning, lifecycle rules and multi-range downloads are not implemented. This remains an AlohaDB preview, not a verified stock-PostgreSQL storage service.
1.1 Upgrade
Install the matching AlohaDB files, then run ALTER EXTENSION pg_storage UPDATE TO '1.1' using the supplied 1.0-to-1.1 script. This SQL update only changes table descriptions; it does not add a storage capability or change grants, policies or payload backup requirements. Native REST changes require matching binaries and the REST worker’s normal restart procedure.