pg_dbms_errlog
Emulate DBMS_ERRLOG Oracle module to log DML errors in a dedicated table.
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_dbms_errlog | 2.2 | SIM | ISC | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 9270 | pg_dbms_errlog | No | Yes | No | Yes | No | No | dbms_errlog |
| Related | pg_dbms_metadata pg_dbms_lock pg_dbms_job |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 2.2 | 1817161514 | pg_dbms_errlog | - |
| RPM | PGDG | 2.2 | 1817161514 | pg_dbms_errlog_$v | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 2.2 el8.x86_64.pg18 : pg_dbms_errlog_18 pg_dbms_errlog_18-2.2-1PGDG.rhel8.x86_64.rpm
| PGDG 2.2 el8.x86_64.pg17 : pg_dbms_errlog_17 pg_dbms_errlog_17-2.2-1PGDG.rhel8.x86_64.rpm
| PGDG 2.2 el8.x86_64.pg16 : pg_dbms_errlog_16 pg_dbms_errlog_16-2.2-1PGDG.rhel8.x86_64.rpm
| PGDG 2.2 el8.x86_64.pg15 : pg_dbms_errlog_15 pg_dbms_errlog_15-2.2-1PGDG.rhel8.x86_64.rpm
| PGDG 2.2 el8.x86_64.pg14 : pg_dbms_errlog_14 pg_dbms_errlog_14-2.2-1PGDG.rhel8.x86_64.rpm
|
| el8.aarch64 | PGDG 2.2 el8.aarch64.pg18 : pg_dbms_errlog_18 pg_dbms_errlog_18-2.2-1PGDG.rhel8.aarch64.rpm
| PGDG 2.2 el8.aarch64.pg17 : pg_dbms_errlog_17 pg_dbms_errlog_17-2.2-1PGDG.rhel8.aarch64.rpm
| PGDG 2.2 el8.aarch64.pg16 : pg_dbms_errlog_16 pg_dbms_errlog_16-2.2-1PGDG.rhel8.aarch64.rpm
| PGDG 2.2 el8.aarch64.pg15 : pg_dbms_errlog_15 pg_dbms_errlog_15-2.2-1PGDG.rhel8.aarch64.rpm
| PGDG 2.2 el8.aarch64.pg14 : pg_dbms_errlog_14 pg_dbms_errlog_14-2.2-1PGDG.rhel8.aarch64.rpm
|
| el9.x86_64 | PGDG 2.2 el9.x86_64.pg18 : pg_dbms_errlog_18 pg_dbms_errlog_18-2.2-1PGDG.rhel9.x86_64.rpm
| PGDG 2.2 el9.x86_64.pg17 : pg_dbms_errlog_17 pg_dbms_errlog_17-2.2-1PGDG.rhel9.x86_64.rpm
| PGDG 2.2 el9.x86_64.pg16 : pg_dbms_errlog_16 pg_dbms_errlog_16-2.2-1PGDG.rhel9.x86_64.rpm
| PGDG 2.2 el9.x86_64.pg15 : pg_dbms_errlog_15 pg_dbms_errlog_15-2.2-1PGDG.rhel9.x86_64.rpm
| PGDG 2.2 el9.x86_64.pg14 : pg_dbms_errlog_14 pg_dbms_errlog_14-2.2-1PGDG.rhel9.x86_64.rpm
|
| el9.aarch64 | PGDG 2.2 el9.aarch64.pg18 : pg_dbms_errlog_18 pg_dbms_errlog_18-2.2-1PGDG.rhel9.aarch64.rpm
| PGDG 2.2 el9.aarch64.pg17 : pg_dbms_errlog_17 pg_dbms_errlog_17-2.2-1PGDG.rhel9.aarch64.rpm
| PGDG 2.2 el9.aarch64.pg16 : pg_dbms_errlog_16 pg_dbms_errlog_16-2.2-1PGDG.rhel9.aarch64.rpm
| PGDG 2.2 el9.aarch64.pg15 : pg_dbms_errlog_15 pg_dbms_errlog_15-2.2-1PGDG.rhel9.aarch64.rpm
| PGDG 2.2 el9.aarch64.pg14 : pg_dbms_errlog_14 pg_dbms_errlog_14-2.2-1PGDG.rhel9.aarch64.rpm
|
| el10.x86_64 | PGDG 2.2 el10.x86_64.pg18 : pg_dbms_errlog_18 pg_dbms_errlog_18-2.2-1PGDG.rhel10.x86_64.rpm
| PGDG 2.2 el10.x86_64.pg17 : pg_dbms_errlog_17 pg_dbms_errlog_17-2.2-1PGDG.rhel10.x86_64.rpm
| PGDG 2.2 el10.x86_64.pg16 : pg_dbms_errlog_16 pg_dbms_errlog_16-2.2-1PGDG.rhel10.x86_64.rpm
| PGDG 2.2 el10.x86_64.pg15 : pg_dbms_errlog_15 pg_dbms_errlog_15-2.2-1PGDG.rhel10.x86_64.rpm
| PGDG 2.2 el10.x86_64.pg14 : pg_dbms_errlog_14 pg_dbms_errlog_14-2.2-1PGDG.rhel10.x86_64.rpm
|
| el10.aarch64 | PGDG 2.2 el10.aarch64.pg18 : pg_dbms_errlog_18 pg_dbms_errlog_18-2.2-1PGDG.rhel10.aarch64.rpm
| PGDG 2.2 el10.aarch64.pg17 : pg_dbms_errlog_17 pg_dbms_errlog_17-2.2-1PGDG.rhel10.aarch64.rpm
| PGDG 2.2 el10.aarch64.pg16 : pg_dbms_errlog_16 pg_dbms_errlog_16-2.2-1PGDG.rhel10.aarch64.rpm
| PGDG 2.2 el10.aarch64.pg15 : pg_dbms_errlog_15 pg_dbms_errlog_15-2.2-1PGDG.rhel10.aarch64.rpm
| PGDG 2.2 el10.aarch64.pg14 : pg_dbms_errlog_14 pg_dbms_errlog_14-2.2-1PGDG.rhel10.aarch64.rpm
|
| d12.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d12.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d13.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d13.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u22.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u22.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u24.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u24.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
Install
You can install pg_dbms_errlog directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_dbms_errlog; # Install for current active PG version
pig ext install -y pg_dbms_errlog -v 18 # PG 18
pig ext install -y pg_dbms_errlog -v 17 # PG 17
pig ext install -y pg_dbms_errlog -v 16 # PG 16
pig ext install -y pg_dbms_errlog -v 15 # PG 15
pig ext install -y pg_dbms_errlog -v 14 # PG 14
dnf install -y pg_dbms_errlog_18 # PG 18
dnf install -y pg_dbms_errlog_17 # PG 17
dnf install -y pg_dbms_errlog_16 # PG 16
dnf install -y pg_dbms_errlog_15 # PG 15
dnf install -y pg_dbms_errlog_14 # PG 14
Create Extension:
CREATE EXTENSION pg_dbms_errlog;
Usage
pg_dbms_errlog: Emulate DBMS_ERRLOG Oracle module to log DML errors in a dedicated table
Enables DML operations to continue after encountering errors by logging failures to an error table, rather than aborting the transaction.
Enabling
Add to shared_preload_libraries in postgresql.conf:
shared_preload_libraries = 'pg_dbms_errlog'
CREATE EXTENSION pg_dbms_errlog;
LOAD 'pg_dbms_errlog';
Create Error Log Table
BEGIN;
CALL dbms_errlog.create_error_log('employees');
END;
-- Creates table "ERR$_employees" with error logging columns
-- With custom name and schema:
BEGIN;
CALL dbms_errlog.create_error_log('hr.employees', '"ERRORS"."ERR$_EMPTABLE"');
END;
Configuration
SET pg_dbms_errlog.enabled TO true; -- enable error logging
SET pg_dbms_errlog.query_tag TO 'daily_load'; -- tag for identifying statements
SET pg_dbms_errlog.reject_limit TO 10; -- max errors before rollback (-1=unlimited)
SET pg_dbms_errlog.synchronous TO 'transaction'; -- 'transaction', 'query', or 'off'
SET pg_dbms_errlog.no_client_error TO true; -- suppress client error messages
Usage with pg_statement_rollback
LOAD 'pg_dbms_errlog';
LOAD 'pg_statement_rollback';
CREATE TABLE hr.raises (emp_id integer, sal integer CHECK(sal > 8000));
BEGIN;
CALL dbms_errlog.create_error_log('hr.raises');
END;
SET pg_dbms_errlog.query_tag TO 'daily_load';
SET pg_dbms_errlog.reject_limit TO 10;
SET pg_dbms_errlog.enabled TO true;
BEGIN;
SET pg_statement_rollback.enabled TO on;
INSERT INTO hr.raises VALUES (145, 15400); -- Success
INSERT INTO hr.raises VALUES (161, 7700); -- Failure (logged)
ROLLBACK TO SAVEPOINT "PgSLRAutoSvpt";
INSERT INTO hr.raises VALUES (175, 9680); -- Success
COMMIT;
Viewing Error Logs
SELECT * FROM "ERR$_raises";
-- pg_err_number$ | 23514
-- pg_err_mesg$ | new row for relation "raises" violates check constraint
-- pg_err_optyp$ | I
-- pg_err_tag$ | daily_load
-- pg_err_query$ | INSERT INTO hr.raises VALUES (161, 7700);
Flush Queued Errors
SELECT dbms_errlog.publish_queue();
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.