pgx_trace_hooks
pgextmgrext · Trace PostgreSQL executor and utility-hook invocations through a preloaded pgrx library
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100838 | pgx_trace_hooks | pgextmgrext | 0.0.0 | STAT | MIT | Rust |
PostgreSQL · 15
Usage
Sources:
pgx_trace_hooks is a diagnostic preload extension that logs entry into PostgreSQL’s executor and utility hooks. Use it in a controlled test server to observe whether statements reach ExecutorStart, ExecutorRun, ExecutorFinish, ExecutorEnd, and ProcessUtility; it records hook-stage names, not query plans, timings, or statement attribution.
Core Workflow
The library rejects ordinary runtime loading, so configure it in shared_preload_libraries and restart PostgreSQL before creating the SQL extension:
Inspect the PostgreSQL server log after executing representative statements. A query can emit executor-stage entries, while utility commands can emit ProcessUtility. The implementation preserves and calls the previously installed callback for every hook, or falls back to PostgreSQL’s standard handler when none was installed.
Traced Hooks
ExecutorStartmarks executor initialization.ExecutorRunmarks tuple-producing execution.ExecutorFinishmarks executor completion work.ExecutorEndmarks executor teardown.ProcessUtilitymarks utility-statement processing.
Operational Notes
pgx_trace_hooks is non-relocatable and requires superuser privileges to create. _PG_init raises an error unless the library is being processed through shared_preload_libraries; changing that setting requires a server restart. Hook messages use PostgreSQL’s INFO level and can multiply log volume for ordinary workloads, so keep this extension out of busy production systems unless log cost and data exposure have been explicitly evaluated.
The hooks chain to the callbacks that were present when this library initialized. Preload order can therefore affect the resulting chain; test it with every other hook-using extension in the final order. The reviewed source belongs to a PostgreSQL 15-era research repository and exposes no SQL API beyond loading the library.