track_renames
Event-trigger function that forwards PostgreSQL object rename details to a configurable callback.
postgresql_track_renames · Event-trigger function that forwards PostgreSQL object rename details to a configurable callback.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100450 | track_renames | postgresql_track_renames | 0.1 | ADMIN | PostgreSQL | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
Usage
Sources:
- Official README at the catalog revision
- Extension SQL at the catalog revision
- Event-trigger implementation at the catalog revision
track_renames 0.1 supplies an event-trigger function that calls an application callback after PostgreSQL rename commands. The implementation requires a five-text-argument callback; the four-argument callback shown in the old README does not match the pinned C source.
Core Workflow
Create a callback visible by its unqualified name, set the callback name, and register an event trigger. Creating event triggers requires superuser privileges.
Persist the setting at database or role level only after confirming the callback exists in every affected session’s search path.
Callback Contract
- The intended callback returns void and must accept five text arguments: object type, schema name, object name, subobject name, and new name.
- Some arguments are NULL for rename forms whose parse tree does not expose a relation or subobject.
- The event trigger ignores intercepted commands whose parse tree is not a rename statement.
Operational Caveats
- Callback lookup uses an unqualified function name and the session search path. Use a locked-down search path and prevent untrusted users from creating shadow functions in visible schemas.
- Callback errors run in the DDL transaction and can make the rename fail. Keep logging code short, deterministic, and locally transactional.
- The code targets old PostgreSQL parse-tree APIs and enumerations. Compile and regression-test against each target server major and every rename class you depend on.