From 678ce86f4294e0c6bce9f67cc00437c045b9dc43 Mon Sep 17 00:00:00 2001
From: Nitin Motiani <nitinmotiani@google.com>
Date: Mon, 2 Feb 2026 09:00:36 +0000
Subject: [PATCH v3 3/4] Tablesync for large objects for superuser

* Add the large object table to the output of pg_get_publication_tables.

* This approach ensures that it is handled without any special logic on the subscriber side.

* For POC, we have only added pg_largeobject. We can do the same for pg_largeobject_metadata.

* Due to the permissions around pg_largeobject, this will only work for superusers.

* In the final implementation this behaviour will be controlled by a flag or some other method
  which enables the large objects replication. For POC, we have done it for all publications.
---
 src/backend/catalog/pg_publication.c    | 8 ++++++++
 src/backend/commands/subscriptioncmds.c | 9 +++++++++
 2 files changed, 17 insertions(+)

diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 9a4791c573e..f68fef6c4f3 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -1186,6 +1186,14 @@ pg_get_publication_tables(PG_FUNCTION_ARGS)
 				pub_elem_tables = list_concat_unique_oid(relids, schemarelids);
 			}
 
+			/*
+			 * TODO : For poc, just add pg_largeobject relid to the
+			 * publication. We need to figure out the long term approach to do
+			 * this and also decide which publication would publish the large
+			 * objects.
+			 */
+			pub_elem_tables = lappend_oid(pub_elem_tables, LargeObjectRelationId);
+
 			/*
 			 * Record the published table and the corresponding publication so
 			 * that we can get row filters and column lists later.
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 0b3c8499b49..3014b66ec91 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -2987,6 +2987,15 @@ fetch_relation_list(WalReceiverConn *wrconn, List *publications)
 
 	walrcv_clear_result(res);
 
+	/*
+	 * TODO : Might need a check or special code here to include the
+	 * largeobject tables. In the POC, we are chaning
+	 * pg_get_publication_tables. But that might change. We also might want to
+	 * have a combination of both - the publication provides the large object
+	 * tables and the subscription has a flag to decide if it wants to
+	 * replicate large objects or not.
+	 */
+
 	return relationlist;
 }
 
-- 
2.53.0.rc1.225.gd81095ad13-goog

