PS_NITPICKS_GENCOLS_V310002.txt

text/plain

Filename: PS_NITPICKS_GENCOLS_V310002.txt
Type: text/plain
Part: 0
Message: Re: Pgoutput not capturing the generated columns
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 723c44c..6d17984 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -850,7 +850,7 @@ fetch_remote_table_info(char *nspname, char *relname, bool **remotegenlist_res,
 	Oid			qualRow[] = {TEXTOID};
 	bool		isnull;
 	bool	   *remotegenlist;
-	bool		hasgencolpub;
+	bool		has_pub_with_pubgencols = false;
 	int			natt;
 	ListCell   *lc;
 	Bitmapset  *included_cols = NULL;
@@ -897,8 +897,8 @@ fetch_remote_table_info(char *nspname, char *relname, bool **remotegenlist_res,
 
 
 	/*
-	 * Get column lists for each relation and check if any of the publication
-	 * has generated column option.
+	 * Get column lists for each relation, and check if any of the publications
+	 * have the 'publish_generated_columns' parameter enabled.
 	 *
 	 * We need to do this before fetching info about column names and types,
 	 * so that we can skip columns that should not be replicated.
@@ -989,7 +989,10 @@ fetch_remote_table_info(char *nspname, char *relname, bool **remotegenlist_res,
 
 		walrcv_clear_result(pubres);
 
-		/* Check if any of the publication has generated column option */
+		/*
+		 * Check if any of the publications have the 'publish_generated_columns'
+		 * parameter enabled.
+		 */
 		if (server_version >= 180000)
 		{
 			WalRcvExecResult *gencolres;
@@ -1006,17 +1009,17 @@ fetch_remote_table_info(char *nspname, char *relname, bool **remotegenlist_res,
 			if (gencolres->status != WALRCV_OK_TUPLES)
 				ereport(ERROR,
 						errcode(ERRCODE_CONNECTION_FAILURE),
-						errmsg("could not fetch gencolumns information from publication list: %s",
+						errmsg("could not fetch generated column publication information from publication list: %s",
 							   pub_names.data));
 
 			tslot = MakeSingleTupleTableSlot(gencolres->tupledesc, &TTSOpsMinimalTuple);
 			if (!tuplestore_gettupleslot(gencolres->tuplestore, true, false, tslot))
 				ereport(ERROR,
 						errcode(ERRCODE_UNDEFINED_OBJECT),
-						errmsg("failed to fetch tuple for gencols from publication list: %s",
+						errmsg("failed to fetch tuple for generated column publication information from publication list: %s",
 							   pub_names.data));
 
-			hasgencolpub = DatumGetBool(slot_getattr(tslot, 1, &isnull));
+			has_pub_with_pubgencols = DatumGetBool(slot_getattr(tslot, 1, &isnull));
 			Assert(!isnull);
 
 			ExecClearTuple(tslot);
@@ -1048,7 +1051,7 @@ fetch_remote_table_info(char *nspname, char *relname, bool **remotegenlist_res,
 
 	if (server_version >= 120000)
 	{
-		bool		gencols_allowed = server_version >= 180000 && hasgencolpub;
+		bool		gencols_allowed = server_version >= 180000 && has_pub_with_pubgencols;
 
 		if (!gencols_allowed)
 			appendStringInfo(&cmd, " AND a.attgenerated = ''");