plpgsql_wrap
plpgsql_wrap : Oracle WRAP-equivalent PL/pgSQL language handler storing AES-256-GCM encrypted procedure source.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 9210 | plpgsql_wrap | plpgsql_wrap | 1.0 |
SIM | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 1.0 |
18 17 16 15 14 | plpgsql_wrap |
plpgsql |
| RPM | PGDG | 1.0 |
18 17 16 15 14 | plpgsql_wrap_$v |
openssl-libs |
| DEB | PIGSTY | 1.0 |
18 17 16 15 14 | postgresql-$v-plpgsql-wrap |
libssl3 |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 |
| el8.aarch64 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 |
| el9.x86_64 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 |
| el9.aarch64 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 |
| el10.x86_64 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 |
| el10.aarch64 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 | PGDG 1.0 |
| d12.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| d12.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| d13.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| d13.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u22.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u22.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u24.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u24.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u26.x86_64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
| u26.aarch64 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 | PIGSTY 1.0 |
Source
github.com/hexacluster/plpgsql_wrap/
plpgsql_wrap-1.0.tar.gz
Install
Make sure PGDG repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources: README, v1.0 release, control file
plpgsql_wrap provides an Oracle WRAP-style procedural language for PostgreSQL. Functions written with LANGUAGE plpgsql_wrap are validated as PL/pgSQL and then stored encrypted in pg_proc.prosrc as PLPGSQLWRAP:1:<hex>.
Install With A Key
Build the extension with a 32-byte AES-256-GCM key:
Back up the key. Wrapped functions can only be unwrapped or restored safely when the correct compiled key is available.
Install the extension in each database that needs the language:
Create Wrapped Functions
Use normal PL/pgSQL syntax with a different language name:
The stored body is opaque:
Dump, Restore, And Unwrap
pg_dump emits the encrypted PLPGSQLWRAP:1: blob. A restore on a server with the same compiled key works normally. A different key leaves the blob stored, but calls fail when the validator/authentication path cannot authenticate it.
Superusers can permanently unwrap a function when they know the key:
Caveats
- Version 1.0 supports PostgreSQL 14-18.
- The control file requires
plpgsqland superuser installation. - This protects casual source inspection and dumps, but the compiled key is a critical secret. Treat package artifacts and build logs accordingly.
- Syntax is validated before encryption, so ordinary PL/pgSQL syntax errors abort
CREATE FUNCTIONbefore encrypted storage is written.