From adc8ac29e5709e1b8c1a8c4c3230d52830287204 Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Fri, 24 Jul 2026 20:26:02 +0900
Subject: [PATCH v3 3/3] Invoke post-alter hook for ALTER PUBLICATION SET ALL

Previously, ALTER PUBLICATION ... SET ALL TABLES and
SET ALL SEQUENCES updated the pg_publication catalog without
invoking the post-alter hook. As a result, object access hook users
could miss changes made by these commands.

Fix this by invoking the post-alter hook whenever a SET ALL command
changes the publication state, using the updated catalog tuple.

Backpatch to v19, where ALTER PUBLICATION SET ALL TABLES and
SET ALL SEQUENCES were introduced.
---
 src/backend/commands/publicationcmds.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 601ae091e32..adbbc65cd8e 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -1647,9 +1647,14 @@ AlterPublicationAllFlags(AlterPublicationStmt *stmt, Relation rel,
 		CatalogTupleUpdate(rel, &tup->t_self, tup);
 		CommandCounterIncrement();
 
+		pubform = (Form_pg_publication) GETSTRUCT(tup);
+
 		/* For ALL TABLES, we must invalidate all relcache entries */
 		if (replaces[Anum_pg_publication_puballtables - 1])
 			CacheInvalidateRelcacheAll();
+
+		InvokeObjectPostAlterHook(PublicationRelationId,
+								  pubform->oid, 0);
 	}
 
 	return dirty;
-- 
2.37.1 (Apple Git-137.1)

