pg_drop_events

pg_drop_events

pg_drop_events : logs transaction ids of drop table, drop column, drop materialized view statements

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
5850
pg_drop_events
pg_drop_events
0.1.0
ADMIN
PostgreSQL
SQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----d--
No
No
No
Yes
no
no
Relationships
Schemaspublic
Requires
plpgsql
See Also
pg_savior
table_log
pgaudit
pg_auditor
temporal_tables
emaj
pg_upless
pgauditlogtofile

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
MIXED
0.1.0
18
17
16
15
14
pg_drop_eventsplpgsql
RPM
PGDG
0.1.0
18
17
16
15
14
pg_drop_events_$v-
DEB
PIGSTY
0.1.0
18
17
16
15
14
postgresql-$v-pg-drop-events-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
el8.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
el9.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
el9.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
el10.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
el10.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
d12.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
d12.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
d13.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
d13.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
u22.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
u22.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
u24.x86_64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
u24.aarch64
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PIGSTY 0.1.0
PackageVersionOSORGSIZEFile URL
pg_drop_events_180.1.0el8.x86_64pigsty10.9 KiBpg_drop_events_18-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_drop_events_180.1.0el8.aarch64pigsty10.9 KiBpg_drop_events_18-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_drop_events_180.1.0el9.x86_64pigsty10.9 KiBpg_drop_events_18-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_drop_events_180.1.0el9.aarch64pigsty10.9 KiBpg_drop_events_18-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_drop_events_180.1.0el10.x86_64pigsty11.0 KiBpg_drop_events_18-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_drop_events_180.1.0el10.aarch64pigsty11.0 KiBpg_drop_events_18-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-drop-events0.1.0d12.x86_64pigsty7.8 KiBpostgresql-18-pg-drop-events_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-drop-events0.1.0d12.aarch64pigsty7.8 KiBpostgresql-18-pg-drop-events_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-drop-events0.1.0d13.x86_64pigsty7.8 KiBpostgresql-18-pg-drop-events_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-drop-events0.1.0d13.aarch64pigsty7.8 KiBpostgresql-18-pg-drop-events_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-drop-events0.1.0u22.x86_64pigsty7.8 KiBpostgresql-18-pg-drop-events_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-drop-events0.1.0u22.aarch64pigsty7.8 KiBpostgresql-18-pg-drop-events_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-drop-events0.1.0u24.x86_64pigsty7.8 KiBpostgresql-18-pg-drop-events_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-18-pg-drop-events0.1.0u24.aarch64pigsty7.8 KiBpostgresql-18-pg-drop-events_0.1.0-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_drop_events_170.1.0el8.x86_64pigsty10.9 KiBpg_drop_events_17-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_drop_events_170.1.0el8.aarch64pigsty10.9 KiBpg_drop_events_17-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_drop_events_170.1.0el9.x86_64pigsty10.9 KiBpg_drop_events_17-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_drop_events_170.1.0el9.aarch64pigsty10.9 KiBpg_drop_events_17-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_drop_events_170.1.0el10.x86_64pigsty11.0 KiBpg_drop_events_17-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_drop_events_170.1.0el10.aarch64pigsty11.0 KiBpg_drop_events_17-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-drop-events0.1.0d12.x86_64pigsty7.8 KiBpostgresql-17-pg-drop-events_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-17-pg-drop-events0.1.0d12.aarch64pigsty7.8 KiBpostgresql-17-pg-drop-events_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-17-pg-drop-events0.1.0d13.x86_64pigsty7.8 KiBpostgresql-17-pg-drop-events_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-17-pg-drop-events0.1.0d13.aarch64pigsty7.8 KiBpostgresql-17-pg-drop-events_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-17-pg-drop-events0.1.0u22.x86_64pigsty7.8 KiBpostgresql-17-pg-drop-events_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-17-pg-drop-events0.1.0u22.aarch64pigsty7.8 KiBpostgresql-17-pg-drop-events_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-17-pg-drop-events0.1.0u24.x86_64pigsty7.8 KiBpostgresql-17-pg-drop-events_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-17-pg-drop-events0.1.0u24.aarch64pigsty7.8 KiBpostgresql-17-pg-drop-events_0.1.0-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_drop_events_160.1.0el8.x86_64pigsty10.9 KiBpg_drop_events_16-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_drop_events_160.1.0el8.aarch64pigsty10.9 KiBpg_drop_events_16-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_drop_events_160.1.0el9.x86_64pigsty10.9 KiBpg_drop_events_16-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_drop_events_160.1.0el9.aarch64pigsty10.9 KiBpg_drop_events_16-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_drop_events_160.1.0el10.x86_64pigsty11.0 KiBpg_drop_events_16-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_drop_events_160.1.0el10.aarch64pigsty11.0 KiBpg_drop_events_16-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-drop-events0.1.0d12.x86_64pigsty7.8 KiBpostgresql-16-pg-drop-events_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-pg-drop-events0.1.0d12.aarch64pigsty7.8 KiBpostgresql-16-pg-drop-events_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-pg-drop-events0.1.0d13.x86_64pigsty7.8 KiBpostgresql-16-pg-drop-events_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-16-pg-drop-events0.1.0d13.aarch64pigsty7.8 KiBpostgresql-16-pg-drop-events_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-16-pg-drop-events0.1.0u22.x86_64pigsty7.8 KiBpostgresql-16-pg-drop-events_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-16-pg-drop-events0.1.0u22.aarch64pigsty7.8 KiBpostgresql-16-pg-drop-events_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-16-pg-drop-events0.1.0u24.x86_64pigsty7.8 KiBpostgresql-16-pg-drop-events_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-16-pg-drop-events0.1.0u24.aarch64pigsty7.8 KiBpostgresql-16-pg-drop-events_0.1.0-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_drop_events_150.1.0el8.x86_64pigsty10.9 KiBpg_drop_events_15-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_drop_events_150.1.0el8.aarch64pigsty10.9 KiBpg_drop_events_15-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_drop_events_150.1.0el9.x86_64pigsty10.9 KiBpg_drop_events_15-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_drop_events_150.1.0el9.aarch64pigsty10.9 KiBpg_drop_events_15-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_drop_events_150.1.0el10.x86_64pigsty11.0 KiBpg_drop_events_15-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_drop_events_150.1.0el10.aarch64pigsty11.0 KiBpg_drop_events_15-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-drop-events0.1.0d12.x86_64pigsty7.8 KiBpostgresql-15-pg-drop-events_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-pg-drop-events0.1.0d12.aarch64pigsty7.8 KiBpostgresql-15-pg-drop-events_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-pg-drop-events0.1.0d13.x86_64pigsty7.8 KiBpostgresql-15-pg-drop-events_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-15-pg-drop-events0.1.0d13.aarch64pigsty7.8 KiBpostgresql-15-pg-drop-events_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-15-pg-drop-events0.1.0u22.x86_64pigsty7.8 KiBpostgresql-15-pg-drop-events_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-15-pg-drop-events0.1.0u22.aarch64pigsty7.8 KiBpostgresql-15-pg-drop-events_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-15-pg-drop-events0.1.0u24.x86_64pigsty7.8 KiBpostgresql-15-pg-drop-events_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-15-pg-drop-events0.1.0u24.aarch64pigsty7.8 KiBpostgresql-15-pg-drop-events_0.1.0-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_drop_events_140.1.0el8.x86_64pigsty10.9 KiBpg_drop_events_14-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_drop_events_140.1.0el8.aarch64pigsty10.9 KiBpg_drop_events_14-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_drop_events_140.1.0el9.x86_64pigsty10.9 KiBpg_drop_events_14-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_drop_events_140.1.0el9.aarch64pigsty10.9 KiBpg_drop_events_14-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_drop_events_140.1.0el10.x86_64pigsty11.0 KiBpg_drop_events_14-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_drop_events_140.1.0el10.aarch64pigsty11.0 KiBpg_drop_events_14-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-drop-events0.1.0d12.x86_64pigsty7.8 KiBpostgresql-14-pg-drop-events_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-pg-drop-events0.1.0d12.aarch64pigsty7.8 KiBpostgresql-14-pg-drop-events_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-pg-drop-events0.1.0d13.x86_64pigsty7.8 KiBpostgresql-14-pg-drop-events_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-14-pg-drop-events0.1.0d13.aarch64pigsty7.8 KiBpostgresql-14-pg-drop-events_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-14-pg-drop-events0.1.0u22.x86_64pigsty7.8 KiBpostgresql-14-pg-drop-events_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-14-pg-drop-events0.1.0u22.aarch64pigsty7.8 KiBpostgresql-14-pg-drop-events_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-14-pg-drop-events0.1.0u24.x86_64pigsty7.8 KiBpostgresql-14-pg-drop-events_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-14-pg-drop-events0.1.0u24.aarch64pigsty7.8 KiBpostgresql-14-pg-drop-events_0.1.0-1PIGSTY~noble_arm64.deb

Source

pig build pkg pg_drop_events;		# 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 pg_drop_events;		# install via package name, for the active PG version

pig install pg_drop_events -v 18;   # install for PG 18
pig install pg_drop_events -v 17;   # install for PG 17
pig install pg_drop_events -v 16;   # install for PG 16
pig install pg_drop_events -v 15;   # install for PG 15
pig install pg_drop_events -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pg_drop_events CASCADE; -- requires plpgsql

Usage

pg_drop_events: logs transaction ids of drop table, drop column, drop materialized view statements

The pg_drop_events extension uses event triggers to automatically log details about DROP operations on tables, columns, and materialized views. The logged information can be used for point-in-time recovery (PITR) after accidental drops.

Tracked Operations

  • DROP TABLE
  • DROP COLUMN (via ALTER TABLE)
  • DROP MATERIALIZED VIEW

Logged Information

ColumnDescription
pidProcess identifier
usenameDatabase user who executed the command
queryThe SQL statement
xact_idTransaction identifier
wal_positionWrite-ahead log position
objidObject identifier
object_nameFully qualified name of dropped object
object_typeObject classification (table, table column, etc.)
xact_timeTimestamp of the transaction

Example

CREATE EXTENSION pg_drop_events;

-- Drop a table
DROP TABLE t.t3;
-- NOTICE: table t.t3 dropped by transaction 1085.

-- Query the event log
SELECT * FROM pg_drop_events;

Point-in-Time Recovery

The logged data maps directly to PostgreSQL recovery parameters:

pg_drop_events columnRecovery parameter
xact_idrecovery_target_xid
xact_timerecovery_target_time
wal_positionrecovery_target_lsn

Use these values in postgresql.conf or recovery.conf to restore the database to a point just before the accidental drop.

Last updated on