pg_dbms_errlog
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_dbms_errlog | 2.4 | SIM | ISC | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 9270 | pg_dbms_errlog | No | Yes | Yes | Yes | No | No | dbms_errlog |
| Related | pg_statement_rollback pg_dbms_job pg_dbms_metadata pg_utl_smtp pg_dbms_lock orafce pg_cron pgagent pg_task |
|---|
Requires pg_statement_rollback and shared_preload_libraries=pg_dbms_errlog; restart required.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | MIXED | 2.4 | 1817161514 | pg_dbms_errlog | pg_statement_rollback |
| RPM | PGDG | 2.2 | 1817161514 | pg_dbms_errlog_$v | pg_statement_rollback_$v |
| DEB | PIGSTY | 2.4 | 1817161514 | postgresql-$v-pg-dbms-errlog | postgresql-$v-pg-statement-rollback |
Build
You can build the DEB packages for pg_dbms_errlog using pig build:
Install
You can install pg_dbms_errlog directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Preload:
Create Extension:
Usage
Sources:
pg_dbms_errlog provides Oracle-style DML error logging for PostgreSQL. It queues an error from a failed INSERT, UPDATE, or DELETE, writes it to a registered ERR$_... table through background workers, and lets the surrounding script continue after rolling back to a savepoint. It requires either pg_statement_rollback or explicit savepoint management by the caller.
Enable the Extension
Add the library to shared_preload_libraries, ensure max_worker_processes can accommodate pg_dbms_errlog.max_workers plus the fixed worker, and restart PostgreSQL:
Create and register an error table for each DML target:
Log and Continue after an Error
The error table contains pg_err_number$, pg_err_mesg$, pg_err_optyp$, pg_err_tag$, pg_err_query$, and pg_err_detail$.
API and Configuration Index
dbms_errlog.create_error_log(dml_table_name, err_log_table_name, err_log_table_owner, err_log_table_space): creates and registers an error table.dbms_errlog.publish_queue(wait_for_completion): asks workers to process queued errors; execution is not granted toPUBLICby default.dbms_errlog.queue_size(): reports queued errors.pg_dbms_errlog.synchronous:transactionby default,query, oroff. Transaction mode guarantees that only errors from committed transactions are logged.pg_dbms_errlog.reject_limit: transaction-wide error limit;-1is unlimited and0logs nothing and rolls back.pg_dbms_errlog.no_client_error: suppresses client error messages while retaining server logging; enabled by default.pg_dbms_errlog.frequencyandpg_dbms_errlog.max_workers: asynchronous worker timing and concurrency.
Caveats
- A caller needs DML privileges on the target and error tables; creating an error table also requires execution and registration-table privileges described upstream.
INSERT INTO ... SELECT ...is one PostgreSQL statement and cannot preserve only successful rows in the Oracle manner.- Syntax and other parse-time errors are not logged. Stored query text must remain below PostgreSQL’s 1 GB value limit.
- Version
2.4changes no SQL API; it fixes worker shutdown loops and a dynamic-background-worker crash.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)