pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix construction of updated-columns bitmap in logical replicatio
Date: Mon, 20 Jul 2020 17:40:36 +0000
Message-ID: <E1jxZmG-0002H7-KX@gemulon.postgresql.org> (raw)

Fix construction of updated-columns bitmap in logical replication.

Commit b9c130a1f failed to apply the publisher-to-subscriber column
mapping while checking which columns were updated.  Perhaps less
significantly, it didn't exclude dropped columns either.  This could
result in an incorrect updated-columns bitmap and thus wrong decisions
about whether to fire column-specific triggers on the subscriber while
applying updates.  In HEAD (since commit 9de77b545), it could also
result in accesses off the end of the colstatus array, as detected by
buildfarm member skink.  Fix the logic, and adjust 003_constraints.pl
so that the problem is exposed in unpatched code.

In HEAD, also add some assertions to check that we don't access off
the ends of these newly variable-sized arrays.

Back-patch to v10, as b9c130a1f was.

Discussion: https://postgr.es/m/CAH2-Wz=79hKQ4++c5A060RYbjTHgiYTHz=fw6mptCtgghH2gJA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d5daae47db5e8a61ce6ed7afaa3e3a99af108c06

Modified Files
--------------
src/backend/replication/logical/proto.c    |  1 +
src/backend/replication/logical/worker.c   | 18 +++++++++++++++---
src/include/replication/logicalproto.h     |  7 ++++++-
src/test/subscription/t/003_constraints.pl | 12 +++++++-----
4 files changed, 29 insertions(+), 9 deletions(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1jxZmG-0002H7-KX@gemulon.postgresql.org>
Permalink:  ../E1jxZmG-0002H7-KX@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jxZmG-0002H7-KX@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix construction of updated-columns bitmap in logical replicatio
  In-Reply-To: <E1jxZmG-0002H7-KX@gemulon.postgresql.org>
  References: <E1jxZmG-0002H7-KX@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox