summaryrefslogtreecommitdiff
path: root/src/include/replication/logicalproto.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-07-20 13:40:16 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-07-20 13:40:16 -0400
commitd5daae47db5e8a61ce6ed7afaa3e3a99af108c06 (patch)
tree1ee8f847904af5d3838dbabf8d23b1cdaa33e420 /src/include/replication/logicalproto.h
parentd98c08cdc638a290d80fb69b20b8288c3924d875 (diff)
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
Diffstat (limited to 'src/include/replication/logicalproto.h')
-rw-r--r--src/include/replication/logicalproto.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/include/replication/logicalproto.h b/src/include/replication/logicalproto.h
index 287288ab415..60a76bc85cf 100644
--- a/src/include/replication/logicalproto.h
+++ b/src/include/replication/logicalproto.h
@@ -27,13 +27,18 @@
#define LOGICALREP_PROTO_MIN_VERSION_NUM 1
#define LOGICALREP_PROTO_VERSION_NUM 1
-/* Tuple coming via logical replication. */
+/*
+ * This struct stores a tuple received via logical replication.
+ * Keep in mind that the columns correspond to the *remote* table.
+ */
typedef struct LogicalRepTupleData
{
/* Array of StringInfos, one per column; some may be unused */
StringInfoData *colvalues;
/* Array of markers for null/unchanged/text/binary, one per column */
char *colstatus;
+ /* Length of above arrays */
+ int ncols;
} LogicalRepTupleData;
/* Possible values for LogicalRepTupleData.colstatus[colnum] */