PS_NITPICKS_20241022_GENCOLS_V400001.txt

text/plain

Filename: PS_NITPICKS_20241022_GENCOLS_V400001.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 e6e5506..eff876a 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -500,8 +500,7 @@ publication_add_relation(Oid pubid, PublicationRelInfo *pri,
  * pub_collist_validate
  *		Process and validate the 'columns' list and ensure the columns are all
  *		valid to use for a publication.  Checks for and raises an ERROR for
- * 		any; unknown columns, system columns, duplicate columns or generated
- *		columns.
+ * 		any unknown columns, system columns, or duplicate columns.
  *
  * Looks up each column's attnum and returns a 0-based Bitmapset of the
  * corresponding attnums.
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 2f55fc5..b1ebefe 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -891,7 +891,7 @@ fetch_remote_table_info(char *nspname, char *relname, LogicalRepRelation *lrel,
 	 * We need to do this before fetching info about column names and types,
 	 * so that we can skip columns that should not be replicated.
 	 */
-	if (walrcv_server_version(LogRepWorkerWalRcvConn) >= 150000)
+	if (server_version >= 150000)
 	{
 		WalRcvExecResult *pubres;
 		TupleTableSlot *tslot;
@@ -1110,6 +1110,7 @@ fetch_remote_table_info(char *nspname, char *relname, LogicalRepRelation *lrel,
 	ExecDropSingleTupleTableSlot(slot);
 
 	lrel->natts = natt;
+
 	walrcv_clear_result(res);
 
 	/*
@@ -1288,9 +1289,8 @@ copy_table(Relation rel)
 		 * SELECT query with OR'ed row filters for COPY.
 		 *
 		 * We also need to use this same COPY (SELECT ...) syntax when
-		 * 'publish_generated_columns' is specified as true and the remote
-		 * table has generated columns, because copy of generated columns is
-		 * not supported by the normal COPY.
+		 * generated columns are published, because copy of generated columns
+		 * is not supported by the normal COPY.
 		 */
 		int			i = 0;
 
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 80e11a3..0216b57 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -5826,9 +5826,9 @@ RelationBuildPublicationDesc(Relation relation, PublicationDesc *pubdesc)
 		/*
 		 * Check if all columns are part of the REPLICA IDENTITY index or not.
 		 *
-		 * If the publication is FOR ALL TABLES and publication includes
-		 * generated columns then it means that all the table will replicate
-		 * all columns and we can skip the validation.
+		 * If the publication is FOR ALL TABLES then column lists are not possible.
+		 * In this case, if 'publish_generated_columns' is true then all table
+		 * columns will be replicated, so the validation can be skipped.
 		 */
 		if (!(pubform->puballtables && pubform->pubgencols) &&
 			(pubform->pubupdate || pubform->pubdelete) &&
diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out
index fc856d9..72943ef 100644
--- a/src/test/regress/expected/publication.out
+++ b/src/test/regress/expected/publication.out
@@ -1809,7 +1809,7 @@ ALTER PUBLICATION pub2 SET (publish_generated_columns = false);
 Tables:
     "public.gencols" (a, gen1)
 
--- Remove generate columns from column list, when 'publish_generated_columns'=false
+-- Remove generated columns from column list, when 'publish_generated_columns'=false
 ALTER PUBLICATION pub2 SET TABLE gencols(a);
 \dRp+ pub2
                                                 Publication pub2
diff --git a/src/test/regress/sql/publication.sql b/src/test/regress/sql/publication.sql
index 454a03b..1ee322f 100644
--- a/src/test/regress/sql/publication.sql
+++ b/src/test/regress/sql/publication.sql
@@ -1140,7 +1140,7 @@ CREATE PUBLICATION pub2 FOR table gencols(a, gen1) WITH (publish_generated_colum
 ALTER PUBLICATION pub2 SET (publish_generated_columns = false);
 \dRp+ pub2
 
--- Remove generate columns from column list, when 'publish_generated_columns'=false
+-- Remove generated columns from column list, when 'publish_generated_columns'=false
 ALTER PUBLICATION pub2 SET TABLE gencols(a);
 \dRp+ pub2