AlterPublicationTables_fix.patch.txt

text/plain

Filename: AlterPublicationTables_fix.patch.txt
Type: text/plain
Part: 0
Message: Re: BUG #18558: ALTER PUBLICATION fails with unhelpful error on attempt to use system column
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 6ea709988e..97f614dde1 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -1188,7 +1188,13 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
 						char	   *colname = strVal(lfirst(lc));
 						AttrNumber	attnum = get_attnum(newrelid, colname);
 
-						newcolumns = bms_add_member(newcolumns, attnum);
+						/*
+						 * Ignore any unknown columns or system columns, we'll
+						 * validate the columns list later during the call to
+						 * PublicationAddTables.
+						 */
+						if (attnum >= 0)
+							newcolumns = bms_add_member(newcolumns, attnum);
 					}
 				}