Improve comment in function GetPublicationRelations

Started by Shlok Kyalabout 1 month ago3 messages
#1Shlok Kyal
shlok.kyal.oss@gmail.com
1 attachment(s)

Hi,

While working on the thread [1]/messages/by-id/CANhcyEV_EVi5cgJ6WPvmeVAqjCS7Of+VAWuRHZtsVf8PQb_z7g@mail.gmail.com, we found that the comment in the
function GetPublicationRelations is not correct. This function gets
the list of relations associated with the publication, but the comment
says the opposite :
/* Find all publications associated with the relation. */

Attached a patch to fix it.

[1]: /messages/by-id/CANhcyEV_EVi5cgJ6WPvmeVAqjCS7Of+VAWuRHZtsVf8PQb_z7g@mail.gmail.com

Thanks,
Shlok Kyal

Attachments:

v1-0001-Improve-comment-in-function-GetPublicationRelatio.patchapplication/octet-stream; name=v1-0001-Improve-comment-in-function-GetPublicationRelatio.patchDownload
From 941fc5a716cb497eaa79048c1696442fc2180cd5 Mon Sep 17 00:00:00 2001
From: Shlok Kyal <shlok.kyal.oss@gmail.com>
Date: Wed, 10 Dec 2025 16:28:42 +0530
Subject: [PATCH v1] Improve comment in function GetPublicationRelations

This function gets the list of relations associated with the publication
but the comment says the opposite. This patch fixes it.
---
 src/backend/catalog/pg_publication.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index be5ef5e4c0e..7aa3f179924 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -788,7 +788,7 @@ GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt)
 	SysScanDesc scan;
 	HeapTuple	tup;
 
-	/* Find all publications associated with the relation. */
+	/* Find all relations associated with the publication. */
 	pubrelsrel = table_open(PublicationRelRelationId, AccessShareLock);
 
 	ScanKeyInit(&scankey,
-- 
2.34.1

#2Chao Li
li.evan.chao@gmail.com
In reply to: Shlok Kyal (#1)
Re: Improve comment in function GetPublicationRelations

On Dec 10, 2025, at 19:15, Shlok Kyal <shlok.kyal.oss@gmail.com> wrote:

Hi,

While working on the thread [1], we found that the comment in the
function GetPublicationRelations is not correct. This function gets
the list of relations associated with the publication, but the comment
says the opposite :
/* Find all publications associated with the relation. */

Attached a patch to fix it.

[1]: /messages/by-id/CANhcyEV_EVi5cgJ6WPvmeVAqjCS7Of+VAWuRHZtsVf8PQb_z7g@mail.gmail.com

Thanks,
Shlok Kyal
<v1-0001-Improve-comment-in-function-GetPublicationRelatio.patch>

Looking at the code:

```
/* Find all publications associated with the relation. */
pubrelsrel = table_open(PublicationRelRelationId, AccessShareLock);

ScanKeyInit(&scankey,
Anum_pg_publication_rel_prpubid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(pubid));
```

It queries the pg_publication table by a pubid, so, indeed, the fix is correct.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#3Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Shlok Kyal (#1)
Re: Improve comment in function GetPublicationRelations

On 10/12/2025 13:15, Shlok Kyal wrote:

Hi,

While working on the thread [1], we found that the comment in the
function GetPublicationRelations is not correct. This function gets
the list of relations associated with the publication, but the comment
says the opposite :
/* Find all publications associated with the relation. */

Attached a patch to fix it.

[1]: /messages/by-id/CANhcyEV_EVi5cgJ6WPvmeVAqjCS7Of+VAWuRHZtsVf8PQb_z7g@mail.gmail.com

Fixed, thanks

- Heikki