Skip to content

pgelog

Extended logging via pseudo-autonomous transactions

pgelog · Extended logging via pseudo-autonomous transactions

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
5870pgelogpgelog1.0.2ADMINPostgreSQLSQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----d--NoNoNoYesnono
SQL 1.0/1.0.2.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.0.219 18 17 16 15pgelogdblink, pg_variables
RPMPIGSTY1.0.219 18 17 16 15pgelog_$vpostgresql$v-contrib, pg_variables_$v
DEBPIGSTY1.0.219 18 17 16 15postgresql-$v-pgelogpostgresql-$v-pg-variables
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
el8.aarch64N/APIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
el9.x86_64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
el9.aarch64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
el10.x86_64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
el10.aarch64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
d12.x86_64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
d12.aarch64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
d13.x86_64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
d13.aarch64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
u22.x86_64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
u22.aarch64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
u24.x86_64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
u24.aarch64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
u26.x86_64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
u26.aarch64PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2PIGSTY 1.0.2
PackageVersionOSORGSIZEFile URL
pgelog_191.0.2el9.x86_64pigsty15.6 KiBpgelog_19-1.0.2-2PGSTY.el9.noarch.rpm
pgelog_191.0.2el9.aarch64pigsty15.6 KiBpgelog_19-1.0.2-2PGSTY.el9.noarch.rpm
pgelog_191.0.2el10.x86_64pigsty15.7 KiBpgelog_19-1.0.2-2PGSTY.el10.noarch.rpm
pgelog_191.0.2el10.aarch64pigsty15.7 KiBpgelog_19-1.0.2-2PGSTY.el10.noarch.rpm
postgresql-19-pgelog1.0.2d12.x86_64pigsty9.6 KiBpostgresql-19-pgelog_1.0.2-1PGSTY~bookworm_all.deb
postgresql-19-pgelog1.0.2d12.aarch64pigsty9.6 KiBpostgresql-19-pgelog_1.0.2-1PGSTY~bookworm_all.deb
postgresql-19-pgelog1.0.2d13.x86_64pigsty9.6 KiBpostgresql-19-pgelog_1.0.2-1PGSTY~trixie_all.deb
postgresql-19-pgelog1.0.2d13.aarch64pigsty9.6 KiBpostgresql-19-pgelog_1.0.2-1PGSTY~trixie_all.deb
postgresql-19-pgelog1.0.2u22.x86_64pigsty9.8 KiBpostgresql-19-pgelog_1.0.2-1PGSTY~jammy_all.deb
postgresql-19-pgelog1.0.2u22.aarch64pigsty9.8 KiBpostgresql-19-pgelog_1.0.2-1PGSTY~jammy_all.deb
postgresql-19-pgelog1.0.2u24.x86_64pigsty9.8 KiBpostgresql-19-pgelog_1.0.2-1PGSTY~noble_all.deb
postgresql-19-pgelog1.0.2u24.aarch64pigsty9.8 KiBpostgresql-19-pgelog_1.0.2-1PGSTY~noble_all.deb
postgresql-19-pgelog1.0.2u26.x86_64pigsty9.8 KiBpostgresql-19-pgelog_1.0.2-1PGSTY~resolute_all.deb
postgresql-19-pgelog1.0.2u26.aarch64pigsty9.8 KiBpostgresql-19-pgelog_1.0.2-1PGSTY~resolute_all.deb

Source

pig build pkg pgelog;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pgelog;		# install by package name

pig install pgelog -v 19;   # install for PG 19
pig install pgelog -v 18;   # install for PG 18
pig install pgelog -v 17;   # install for PG 17
pig install pgelog -v 16;   # install for PG 16
pig install pgelog -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pgelog CASCADE; -- requires dblink, pg_variables

Usage

Source: README, control file, extension SQL 1.0.2, Tag v1.0.2

pgelog writes rollback-resistant log rows through pseudo-autonomous transactions implemented with dblink. It caches the extra connection in pg_variables so repeated logging in the same session is cheaper.

Requirements and install

  • PostgreSQL 11+
  • dblink
  • pg_variables
  • passwordless local dblink access, typically via peer
CREATE EXTENSION IF NOT EXISTS dblink;
CREATE EXTENSION IF NOT EXISTS pg_variables;
CREATE EXTENSION pgelog;

Main objects and functions

SELECT pgelog_to_log('SQL', 'standalone', 'Test of logging by pgelog', '1');

SELECT pgelog_get_param('pgelog_ttl_minutes');
SELECT pgelog_set_param('pgelog_ttl_minutes', '2880');
  • pgelog_logs: base log table.
  • pgelog_vw_logs: log view with timing deltas.
  • pgelog_params: configuration table.
  • pgelog_to_log(...): write a log row that survives rollback.
  • pgelog_get_param(...), pgelog_set_param(...), pgelog_delete_param(...): manage extension settings.

Typical use

The official README shows pgelog_to_log(...) in PL/pgSQL exception handlers: collect diagnostics with GET STACKED DIAGNOSTICS, write a FAIL log row, then re-raise the error.

Caveats

  • Each session can open one additional dblink connection, so max_connections should account for that.
  • Upstream v1.0.2 still ships extension SQL under the same user-visible object family; Pigsty’s note about runtime dblink plus pg_variables requirements is confirmed by the control file and README.

Table reader