PS_NITPICKS_20241126_errmsg_v50001.txt
text/plain
Filename: PS_NITPICKS_20241126_errmsg_v50001.txt
Type: text/plain
Part: 0
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index cdce752..7fb1604 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -220,13 +220,11 @@ logicalrep_rel_att_by_name(LogicalRepRelation *remoterel, const char *attname)
}
/*
- * Generates a comma-separated string of attribute names based on the provided
- * relation information and a bitmap indicating which attributes are included.
- *
- * The result is a palloc'd string.
+ * Returns a comma-separated string of attribute names based on the provided
+ * relation and bitmap indicating which attributes to include.
*/
static char *
-get_attrs_str(LogicalRepRelation *remoterel, Bitmapset *atts)
+logicalrep_get_attrs_str(LogicalRepRelation *remoterel, Bitmapset *atts)
{
StringInfoData attsbuf;
int attcnt = 0;
@@ -249,12 +247,13 @@ get_attrs_str(LogicalRepRelation *remoterel, Bitmapset *atts)
}
/*
- * If !bms_is_empty(missingatts), report the error message as 'Missing
- * replicated columns.' Otherwise, report the error message as 'Cannot replicate
- * to generated columns.'
+ * If attempting to replicate to subscriber side missing columns or generated
+ * columns then report an error.
+ *
+ * (If both problems exist then the 'missing' error takes precedence).
*/
static void
-logicalrep_report_missing_and_gen_attrs(LogicalRepRelation *remoterel,
+logicalrep_report_missing_or_gen_attrs(LogicalRepRelation *remoterel,
Bitmapset *missingatts,
Bitmapset *genatts)
{
@@ -266,7 +265,7 @@ logicalrep_report_missing_and_gen_attrs(LogicalRepRelation *remoterel,
bms_num_members(missingatts),
remoterel->nspname,
remoterel->relname,
- get_attrs_str(remoterel, missingatts)));
+ logicalrep_get_attrs_str(remoterel, missingatts)));
if (!bms_is_empty(genatts))
ereport(ERROR,
@@ -276,7 +275,7 @@ logicalrep_report_missing_and_gen_attrs(LogicalRepRelation *remoterel,
bms_num_members(genatts),
remoterel->nspname,
remoterel->relname,
- get_attrs_str(remoterel, genatts)));
+ logicalrep_get_attrs_str(remoterel, genatts)));
}
/*
@@ -401,9 +400,8 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
TupleDesc desc;
MemoryContext oldctx;
int i;
- Bitmapset *missingatts; /* Bitmapset for missing attributes. */
- Bitmapset *generatedattrs = NULL; /* Bitmapset for generated
- * attributes. */
+ Bitmapset *missingatts;
+ Bitmapset *generatedattrs = NULL;
/* Release the no-longer-useful attrmap, if any. */
if (entry->attrmap)
@@ -465,11 +463,7 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
}
}
- /*
- * Report any missing and generated columns. Note, if there are both
- * kinds then the 'missing' error takes precedence.
- */
- logicalrep_report_missing_and_gen_attrs(remoterel, missingatts,
+ logicalrep_report_missing_or_gen_attrs(remoterel, missingatts,
generatedattrs);
/* be tidy */