pg_drop_events

pg_drop_events

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

Overview

ID Extension Package Version Category License Language
5850
pg_drop_events
pg_drop_events
0.1.0
ADMIN
PostgreSQL
SQL
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----d--
No
No
No
Yes
no
no
Relationships
Schemas public
Requires
plpgsql
See Also
pg_savior
table_log
pgaudit
pg_auditor
temporal_tables
emaj
pg_upless
pgauditlogtofile

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
MIXED
0.1.0
18
17
16
15
14
pg_drop_events plpgsql
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 / PG PG18 PG17 PG16 PG15 PG14
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
Package Version OS ORG SIZE File URL
pg_drop_events_18 0.1.0 el8.x86_64 pigsty 10.9 KiB pg_drop_events_18-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_drop_events_18 0.1.0 el8.aarch64 pigsty 10.9 KiB pg_drop_events_18-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_drop_events_18 0.1.0 el9.x86_64 pigsty 10.9 KiB pg_drop_events_18-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_drop_events_18 0.1.0 el9.aarch64 pigsty 10.9 KiB pg_drop_events_18-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_drop_events_18 0.1.0 el10.x86_64 pigsty 11.0 KiB pg_drop_events_18-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_drop_events_18 0.1.0 el10.aarch64 pigsty 11.0 KiB pg_drop_events_18-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-drop-events 0.1.0 d12.x86_64 pigsty 7.8 KiB postgresql-18-pg-drop-events_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-drop-events 0.1.0 d12.aarch64 pigsty 7.8 KiB postgresql-18-pg-drop-events_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-drop-events 0.1.0 d13.x86_64 pigsty 7.8 KiB postgresql-18-pg-drop-events_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-drop-events 0.1.0 d13.aarch64 pigsty 7.8 KiB postgresql-18-pg-drop-events_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-drop-events 0.1.0 u22.x86_64 pigsty 7.8 KiB postgresql-18-pg-drop-events_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-drop-events 0.1.0 u22.aarch64 pigsty 7.8 KiB postgresql-18-pg-drop-events_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-drop-events 0.1.0 u24.x86_64 pigsty 7.8 KiB postgresql-18-pg-drop-events_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-18-pg-drop-events 0.1.0 u24.aarch64 pigsty 7.8 KiB postgresql-18-pg-drop-events_0.1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_drop_events_17 0.1.0 el8.x86_64 pigsty 10.9 KiB pg_drop_events_17-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_drop_events_17 0.1.0 el8.aarch64 pigsty 10.9 KiB pg_drop_events_17-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_drop_events_17 0.1.0 el9.x86_64 pigsty 10.9 KiB pg_drop_events_17-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_drop_events_17 0.1.0 el9.aarch64 pigsty 10.9 KiB pg_drop_events_17-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_drop_events_17 0.1.0 el10.x86_64 pigsty 11.0 KiB pg_drop_events_17-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_drop_events_17 0.1.0 el10.aarch64 pigsty 11.0 KiB pg_drop_events_17-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-drop-events 0.1.0 d12.x86_64 pigsty 7.8 KiB postgresql-17-pg-drop-events_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-17-pg-drop-events 0.1.0 d12.aarch64 pigsty 7.8 KiB postgresql-17-pg-drop-events_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-17-pg-drop-events 0.1.0 d13.x86_64 pigsty 7.8 KiB postgresql-17-pg-drop-events_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-17-pg-drop-events 0.1.0 d13.aarch64 pigsty 7.8 KiB postgresql-17-pg-drop-events_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-17-pg-drop-events 0.1.0 u22.x86_64 pigsty 7.8 KiB postgresql-17-pg-drop-events_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-17-pg-drop-events 0.1.0 u22.aarch64 pigsty 7.8 KiB postgresql-17-pg-drop-events_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-17-pg-drop-events 0.1.0 u24.x86_64 pigsty 7.8 KiB postgresql-17-pg-drop-events_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-17-pg-drop-events 0.1.0 u24.aarch64 pigsty 7.8 KiB postgresql-17-pg-drop-events_0.1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_drop_events_16 0.1.0 el8.x86_64 pigsty 10.9 KiB pg_drop_events_16-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_drop_events_16 0.1.0 el8.aarch64 pigsty 10.9 KiB pg_drop_events_16-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_drop_events_16 0.1.0 el9.x86_64 pigsty 10.9 KiB pg_drop_events_16-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_drop_events_16 0.1.0 el9.aarch64 pigsty 10.9 KiB pg_drop_events_16-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_drop_events_16 0.1.0 el10.x86_64 pigsty 11.0 KiB pg_drop_events_16-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_drop_events_16 0.1.0 el10.aarch64 pigsty 11.0 KiB pg_drop_events_16-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-drop-events 0.1.0 d12.x86_64 pigsty 7.8 KiB postgresql-16-pg-drop-events_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-16-pg-drop-events 0.1.0 d12.aarch64 pigsty 7.8 KiB postgresql-16-pg-drop-events_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-16-pg-drop-events 0.1.0 d13.x86_64 pigsty 7.8 KiB postgresql-16-pg-drop-events_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-16-pg-drop-events 0.1.0 d13.aarch64 pigsty 7.8 KiB postgresql-16-pg-drop-events_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-16-pg-drop-events 0.1.0 u22.x86_64 pigsty 7.8 KiB postgresql-16-pg-drop-events_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-16-pg-drop-events 0.1.0 u22.aarch64 pigsty 7.8 KiB postgresql-16-pg-drop-events_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-16-pg-drop-events 0.1.0 u24.x86_64 pigsty 7.8 KiB postgresql-16-pg-drop-events_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-16-pg-drop-events 0.1.0 u24.aarch64 pigsty 7.8 KiB postgresql-16-pg-drop-events_0.1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_drop_events_15 0.1.0 el8.x86_64 pigsty 10.9 KiB pg_drop_events_15-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_drop_events_15 0.1.0 el8.aarch64 pigsty 10.9 KiB pg_drop_events_15-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_drop_events_15 0.1.0 el9.x86_64 pigsty 10.9 KiB pg_drop_events_15-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_drop_events_15 0.1.0 el9.aarch64 pigsty 10.9 KiB pg_drop_events_15-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_drop_events_15 0.1.0 el10.x86_64 pigsty 11.0 KiB pg_drop_events_15-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_drop_events_15 0.1.0 el10.aarch64 pigsty 11.0 KiB pg_drop_events_15-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-drop-events 0.1.0 d12.x86_64 pigsty 7.8 KiB postgresql-15-pg-drop-events_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-15-pg-drop-events 0.1.0 d12.aarch64 pigsty 7.8 KiB postgresql-15-pg-drop-events_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-15-pg-drop-events 0.1.0 d13.x86_64 pigsty 7.8 KiB postgresql-15-pg-drop-events_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-15-pg-drop-events 0.1.0 d13.aarch64 pigsty 7.8 KiB postgresql-15-pg-drop-events_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-15-pg-drop-events 0.1.0 u22.x86_64 pigsty 7.8 KiB postgresql-15-pg-drop-events_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-15-pg-drop-events 0.1.0 u22.aarch64 pigsty 7.8 KiB postgresql-15-pg-drop-events_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-15-pg-drop-events 0.1.0 u24.x86_64 pigsty 7.8 KiB postgresql-15-pg-drop-events_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-15-pg-drop-events 0.1.0 u24.aarch64 pigsty 7.8 KiB postgresql-15-pg-drop-events_0.1.0-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_drop_events_14 0.1.0 el8.x86_64 pigsty 10.9 KiB pg_drop_events_14-0.1.0-1PIGSTY.el8.x86_64.rpm
pg_drop_events_14 0.1.0 el8.aarch64 pigsty 10.9 KiB pg_drop_events_14-0.1.0-1PIGSTY.el8.aarch64.rpm
pg_drop_events_14 0.1.0 el9.x86_64 pigsty 10.9 KiB pg_drop_events_14-0.1.0-1PIGSTY.el9.x86_64.rpm
pg_drop_events_14 0.1.0 el9.aarch64 pigsty 10.9 KiB pg_drop_events_14-0.1.0-1PIGSTY.el9.aarch64.rpm
pg_drop_events_14 0.1.0 el10.x86_64 pigsty 11.0 KiB pg_drop_events_14-0.1.0-1PIGSTY.el10.x86_64.rpm
pg_drop_events_14 0.1.0 el10.aarch64 pigsty 11.0 KiB pg_drop_events_14-0.1.0-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-drop-events 0.1.0 d12.x86_64 pigsty 7.8 KiB postgresql-14-pg-drop-events_0.1.0-1PIGSTY~bookworm_amd64.deb
postgresql-14-pg-drop-events 0.1.0 d12.aarch64 pigsty 7.8 KiB postgresql-14-pg-drop-events_0.1.0-1PIGSTY~bookworm_arm64.deb
postgresql-14-pg-drop-events 0.1.0 d13.x86_64 pigsty 7.8 KiB postgresql-14-pg-drop-events_0.1.0-1PIGSTY~trixie_amd64.deb
postgresql-14-pg-drop-events 0.1.0 d13.aarch64 pigsty 7.8 KiB postgresql-14-pg-drop-events_0.1.0-1PIGSTY~trixie_arm64.deb
postgresql-14-pg-drop-events 0.1.0 u22.x86_64 pigsty 7.8 KiB postgresql-14-pg-drop-events_0.1.0-1PIGSTY~jammy_amd64.deb
postgresql-14-pg-drop-events 0.1.0 u22.aarch64 pigsty 7.8 KiB postgresql-14-pg-drop-events_0.1.0-1PIGSTY~jammy_arm64.deb
postgresql-14-pg-drop-events 0.1.0 u24.x86_64 pigsty 7.8 KiB postgresql-14-pg-drop-events_0.1.0-1PIGSTY~noble_amd64.deb
postgresql-14-pg-drop-events 0.1.0 u24.aarch64 pigsty 7.8 KiB postgresql-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

Column Description
pid Process identifier
usename Database user who executed the command
query The SQL statement
xact_id Transaction identifier
wal_position Write-ahead log position
objid Object identifier
object_name Fully qualified name of dropped object
object_type Object classification (table, table column, etc.)
xact_time Timestamp 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 column Recovery parameter
xact_id recovery_target_xid
xact_time recovery_target_time
wal_position recovery_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