v49_0001_amit.diff.txt

text/plain

Filename: v49_0001_amit.diff.txt
Type: text/plain
Part: 0
Message: Re: Pgoutput not capturing the generated columns
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 92a5fa65e0..6dcb399ee3 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -261,15 +261,14 @@ is_schema_publication(Oid pubid)
  * publication, false otherwise.
  *
  * If a column list is found, the corresponding bitmap is returned through the
- * cols parameter (if provided) and is constructed within the specified memory
- * context (mcxt).
+ * cols parameter, if provided. The bitmap is constructed within the given
+ * memory context (mcxt).
  */
 bool
-check_fetch_column_list(Publication *pub, Oid relid, MemoryContext mcxt,
+check_and_fetch_column_list(Publication *pub, Oid relid, MemoryContext mcxt,
 						Bitmapset **cols)
 {
-	HeapTuple	cftuple = NULL;
-	Datum		cfdatum = 0;
+	HeapTuple	cftuple;
 	bool		found = false;
 
 	if (pub->alltables)
@@ -280,6 +279,7 @@ check_fetch_column_list(Publication *pub, Oid relid, MemoryContext mcxt,
 							  ObjectIdGetDatum(pub->oid));
 	if (HeapTupleIsValid(cftuple))
 	{
+		Datum		cfdatum;
 		bool		isnull;
 
 		/* Lookup the column list attribute. */
@@ -289,7 +289,7 @@ check_fetch_column_list(Publication *pub, Oid relid, MemoryContext mcxt,
 		/* Was a column list found? */
 		if (!isnull)
 		{
-			/* Build the column list bitmap in the mcxt context. */
+			/* Build the column list bitmap in the given memory context. */
 			if (cols)
 				*cols = pub_collist_to_bitmapset(*cols, cfdatum, mcxt);
 
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index 1a7b9dee10..32e1134b54 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -1051,11 +1051,11 @@ check_and_init_gencol(PGOutputData *data, List *publications,
 	foreach_ptr(Publication, pub, publications)
 	{
 		/*
-		 * The column list takes precedence over 'publish_generated_columns'
-		 * parameter. Those will be checked later, see
-		 * pgoutput_column_list_init.
+		 * The column list takes precedence over the
+		 * 'publish_generated_columns' parameter. Those will be checked later,
+		 * seepgoutput_column_list_init.
 		 */
-		if (check_fetch_column_list(pub, entry->publish_as_relid, NULL, NULL))
+		if (check_and_fetch_column_list(pub, entry->publish_as_relid, NULL, NULL))
 			continue;
 
 		if (first)
@@ -1106,9 +1106,9 @@ pgoutput_column_list_init(PGOutputData *data, List *publications,
 		Bitmapset  *cols = NULL;
 
 		/* Retrieve the bitmap of columns for a column list publication. */
-		found_pub_collist |= check_fetch_column_list(pub,
-													 entry->publish_as_relid,
-													 entry->entry_cxt, &cols);
+		found_pub_collist |= check_and_fetch_column_list(pub,
+														 entry->publish_as_relid,
+														 entry->entry_cxt, &cols);
 
 		/*
 		 * For non-column list publications — e.g. TABLE (without a column
diff --git a/src/include/catalog/pg_publication.h b/src/include/catalog/pg_publication.h
index c3302efd1a..71e5a5daf7 100644
--- a/src/include/catalog/pg_publication.h
+++ b/src/include/catalog/pg_publication.h
@@ -154,8 +154,8 @@ extern Oid	GetTopMostAncestorInPublication(Oid puboid, List *ancestors,
 
 extern bool is_publishable_relation(Relation rel);
 extern bool is_schema_publication(Oid pubid);
-extern bool check_fetch_column_list(Publication *pub, Oid relid,
-									MemoryContext mcxt, Bitmapset **cols);
+extern bool check_and_fetch_column_list(Publication *pub, Oid relid,
+										MemoryContext mcxt, Bitmapset **cols);
 extern ObjectAddress publication_add_relation(Oid pubid, PublicationRelInfo *pri,
 											  bool if_not_exists);
 extern Bitmapset *pub_collist_validate(Relation targetrel, List *columns);