emaj
emaj : Enables fine-grained write logging and time travel on subsets of the database.
Overview
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | emaj |
| Requires | btree_gist dblink |
| See Also | table_version pgmemento data_historization table_log ddl_historization periods temporal_tables |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 5.0.0 |
18 17 16 15 14 | emaj |
btree_gist, dblink |
| RPM | PIGSTY | 5.0.0 |
18 17 16 15 14 | e-maj_$v |
- |
| DEB | PIGSTY | 5.0.0 |
18 17 16 15 14 | postgresql-$v-emaj |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| el8.aarch64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| el9.x86_64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| el9.aarch64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| el10.x86_64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| el10.aarch64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| d12.x86_64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| d12.aarch64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| d13.x86_64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| d13.aarch64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| u22.x86_64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| u22.aarch64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| u24.x86_64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| u24.aarch64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| u26.x86_64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
| u26.aarch64 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 | PIGSTY 5.0.0 |
Source
github.com/dalibo/emaj
emaj-5.0.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
The canonical extension name is emaj; E-Maj records table and sequence changes for a coordinated table group and can roll that group back to a named mark. It is useful for repeatable test runs, batch savepoints, change inspection, and targeted recovery, but an E-Maj rollback is not a replacement for PostgreSQL transaction rollback or backup.
Core Workflow
A rollbackable table group can contain tables and sequences from several schemas, but each table must have a primary key. Audit-only groups can record changes for objects that are not rollbackable. Starting and stopping a group takes locks on its application tables, so plan these operations around concurrent traffic.
Important Objects
emaj_create_groupand assignment functions define table groups.emaj_start_group,emaj_set_mark_group, andemaj_stop_groupmanage logging sessions and marks.emaj_rollback_groupperforms an unlogged rollback;emaj_logged_rollback_grouprecords the compensating changes.- Multi-group variants operate on arrays of group names at one common point in time.
- Statistics and change-dump functions inspect changes between marks or generate SQL for replay.
emaj_set_paramchanges or resets an E-Maj parameter without direct writes to the internal parameter table.emaj_drop_extension()is the supported full-removal helper.
Version 5.0 Upgrade
For an E-Maj extension installed at version 2.3.1 or later, install the new package files and run:
The documented extension upgrade preserves logs and can run while groups remain in the LOGGING state. Review these 5.0 compatibility changes before cutover:
- PostgreSQL 14 through 19 are supported; PostgreSQL 12 and 13 are no longer supported.
- Direct
INSERT,UPDATE, orDELETEagainstemaj_parammust be replaced byemaj_set_param. - Idempotent start and stop calls have new allow-already-active or allow-already-idle parameters; named-argument callers must review renamed parameters.
- The PHP command-line clients and
emaj_uninstall.sqlwere removed.
Installations made with the standalone SQL script do not have the same in-place extension upgrade path; follow the official delete-and-reinstall procedure.
Requirements and Caveats
The standard CREATE EXTENSION path requires superuser privileges and installs dblink plus btree_gist through CASCADE. E-Maj also supports a limited non-superuser script installation, with capability restrictions tied to the installer role.
max_prepared_transactions is required only for the parallel rollback client and must be at least the intended session count; changing it requires a restart. Large groups can also require a higher max_locks_per_transaction. Treat E-Maj log tables as operational data: size retention deliberately, monitor their growth, and keep ordinary backups for disaster recovery.