POC-v4-0005-Tablesync-for-large-objects-for-superuser.patch

application/x-patch

Filename: POC-v4-0005-Tablesync-for-large-objects-for-superuser.patch
Type: application/x-patch
Part: 0
Message: Re: Proposal: Support Logical replication of large objects

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v4-0005
Subject: Tablesync for large objects for superuser
File+
src/backend/catalog/pg_publication.c 8 0
src/backend/commands/subscriptioncmds.c 9 0
From b5437da3be39d9be26e79fb0ac2c14d399307f0a Mon Sep 17 00:00:00 2001
From: Nitin Motiani <nitinmotiani@google.com>
Date: Mon, 2 Feb 2026 09:00:36 +0000
Subject: [PATCH v4 5/6] 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 a43d385c605..a87208f4e1c 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -1491,6 +1491,14 @@ pg_get_publication_tables(FunctionCallInfo fcinfo, ArrayType *pubnames,
 				}
 			}
 
+			/*
+			 * 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 1e10d9d9a58..0b709def9c5 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -3205,6 +3205,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.54.0.545.g6539524ca2-goog