]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix construction of updated-columns bitmap in logical replication.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 20 Jul 2020 17:40:16 +0000 (13:40 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 20 Jul 2020 17:40:16 +0000 (13:40 -0400)
commite8de627a3e05e201ffb78ad7792d14fd25c857c8
treeccebd14ac201757e50d64fedc39b6ad7007b99c9
parentdcd6718017943ad5bfbba7c3474992fa5a89d242
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
src/backend/replication/logical/worker.c
src/test/subscription/t/003_constraints.pl