Fix negative bitmapset member not allowed error in logical replication

This happens when we add a replica identity column on a subscriber
that does not yet exist on the publisher, according to the mapping
maintained by the subscriber.  Code that checks whether the target
relation on the subscriber is updatable would check the replica
identity attribute bitmap with a column number -1, which would result
in an error.  To fix, skip such columns in the bitmap lookup and
consider the relation not updatable.  The result is consistent with
the rule that the replica identity columns on the subscriber must be a
subset of those on the publisher, since if the column doesn't exist on
the publisher, the column set on the subscriber can't be a subset.

Reported-by: Tim Clarke <>
Analyzed-by: Jehan-Guillaume de Rorthais <>



Modified Files
src/backend/replication/logical/relation.c |  3 ++-
src/test/subscription/t/ | 37 ++++++++++++++++++++++++++++--
2 files changed, 37 insertions(+), 3 deletions(-)

Reply via email to