From 9a5fad6e73b05ba7339a628f2058c2577fc6cab7 Mon Sep 17 00:00:00 2001
From: Andrey Borodin <amborodin@acm.org>
Date: Thu, 7 Nov 2024 23:11:22 +0500
Subject: [PATCH vPoC] Simplify recovery after dropping a table by giving
 restore LSN in logs

Hacked online on postgres.tv by Nik, Kirk and Andrey.
---
 src/backend/catalog/dependency.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 0489cbabcb..81e1b7d519 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -1507,6 +1507,14 @@ AcquireDeletionLock(const ObjectAddress *object, int flags)
 			LockRelationOid(object->objectId, ShareUpdateExclusiveLock);
 		else
 			LockRelationOid(object->objectId, AccessExclusiveLock);
+
+		if (get_rel_relkind(object->objectId) == RELKIND_RELATION ||
+			get_rel_relkind(object->objectId) == RELKIND_PARTITIONED_TABLE)
+		{
+			XLogRecPtr ptr = GetInsertRecPtr();
+			char *relname = get_rel_name(object->objectId);
+			elog(LOG, "Aquired drop table lock on table %s. Restore at %X/%X", relname, (uint32)(ptr >> 32), (uint32) ptr);
+		}
 	}
 	else if (object->classId == AuthMemRelationId)
 		LockSharedObject(object->classId, object->objectId, 0,
-- 
2.39.5 (Apple Git-154)

