diff --git a/src/backend/replication/logical/conflict.c b/src/backend/replication/logical/conflict.c index d140f6b160a..fffbcb10198 100644 --- a/src/backend/replication/logical/conflict.c +++ b/src/backend/replication/logical/conflict.c @@ -1032,7 +1032,14 @@ tuple_table_slot_to_indextup_json(EState *estate, Relation localrel, build_index_datums_from_slot(estate, localrel, slot, indexDesc, values, isnull); - tupdesc = CreateTupleDescCopy(RelationGetDescr(indexDesc)); + + /* + * Copy only the index's key attributes. FormIndexDatum() above also fills + * in any non-key (INCLUDE) columns, but those are not part of the replica + * identity and must not be recorded here. + */ + tupdesc = CreateTupleDescTruncatedCopy(RelationGetDescr(indexDesc), + IndexRelationGetNumberOfKeyAttributes(indexDesc)); /* Bless the tupdesc so it can be looked up by row_to_json. */ BlessTupleDesc(tupdesc);