1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-09 13:09:39 +03:00

Ignore dropped and generated columns from the column list.

We don't allow different column lists for the same table in the different
publications of the single subscription. A publication with a column list
except for dropped and generated columns should be considered the same as
a publication with no column list (which implicitly includes all columns
as part of the columns list). However, as we were not excluding the
dropped and generated columns from the column list combining such
publications leads to an error "cannot use different column lists for
table ...".

We decided not to backpatch this fix as there is a risk of users seeing
this as a behavior change and also we didn't see any field report of this
case.

Author: Shi yu
Reviewed-by: Amit Kapila
Discussion: https://postgr.es/m/OSZPR01MB631091CCBC56F195B1B9ACB0FDFE9@OSZPR01MB6310.jpnprd01.prod.outlook.com
This commit is contained in:
Amit Kapila
2023-01-13 14:49:23 +05:30
parent dca8b01f5f
commit b7ae039536
6 changed files with 97 additions and 6 deletions

View File

@@ -1058,16 +1058,31 @@ pgoutput_column_list_init(PGOutputData *data, List *publications,
/* Build the column list bitmap in the per-entry context. */
if (!pub_no_list) /* when not null */
{
int i;
int nliveatts = 0;
TupleDesc desc = RelationGetDescr(relation);
pgoutput_ensure_entry_cxt(data, entry);
cols = pub_collist_to_bitmapset(cols, cfdatum,
entry->entry_cxt);
/* Get the number of live attributes. */
for (i = 0; i < desc->natts; i++)
{
Form_pg_attribute att = TupleDescAttr(desc, i);
if (att->attisdropped || att->attgenerated)
continue;
nliveatts++;
}
/*
* If column list includes all the columns of the table,
* set it to NULL.
*/
if (bms_num_members(cols) == RelationGetNumberOfAttributes(relation))
if (bms_num_members(cols) == nliveatts)
{
bms_free(cols);
cols = NULL;