diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-06-11 16:12:36 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-06-11 16:12:36 -0400 |
commit | b270713fd44b1378cebc3177e092add0155b55b6 (patch) | |
tree | a36bcbf0b58d01fe7cb1b61e702dcfb471f9638f /src/backend/replication/pgoutput/pgoutput.c | |
parent | 218b101008b533156d7e5832fe143d1e04a01301 (diff) | |
download | postgresql-b270713fd44b1378cebc3177e092add0155b55b6.tar.gz postgresql-b270713fd44b1378cebc3177e092add0155b55b6.zip |
Fix multiple crasher bugs in partitioned-table replication logic.
apply_handle_tuple_routing(), having detected and reported that
the tuple it needed to update didn't exist, tried to update that
tuple anyway, leading to a null-pointer dereference.
logicalrep_partition_open() failed to ensure that the
LogicalRepPartMapEntry it built for a partition was fully
independent of that for the partition root, leading to
trouble if the root entry was later freed or rebuilt.
Meanwhile, on the publisher's side, pgoutput_change() sometimes
attempted to apply execute_attr_map_tuple() to a NULL tuple.
The first of these was reported by Sergey Bernikov in bug #17055;
I found the other two while developing some test cases for this
sadly under-tested code.
Diagnosis and patch for the first issue by Amit Langote; patches
for the others by me; new test cases by me. Back-patch to v13
where this logic came in.
Discussion: https://postgr.es/m/17055-9ba800ec8522668b@postgresql.org
Diffstat (limited to 'src/backend/replication/pgoutput/pgoutput.c')
-rw-r--r-- | src/backend/replication/pgoutput/pgoutput.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index d9e45bab4ad..5b33b31515e 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -452,8 +452,11 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, /* Convert tuples if needed. */ if (relentry->map) { - oldtuple = execute_attr_map_tuple(oldtuple, relentry->map); - newtuple = execute_attr_map_tuple(newtuple, relentry->map); + if (oldtuple) + oldtuple = execute_attr_map_tuple(oldtuple, + relentry->map); + newtuple = execute_attr_map_tuple(newtuple, + relentry->map); } } |