logirep-partition-update-tuple-not-found-fix.patch
application/octet-stream
Filename: logirep-partition-update-tuple-not-found-fix.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/replication/logical/worker.c | 9 | 11 |
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 98c26002e8..41a73cd4f2 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1728,17 +1728,7 @@ apply_handle_tuple_routing(ApplyExecutionData *edata,
found = FindReplTupleInLocalRel(estate, partrel,
&part_entry->remoterel,
remoteslot_part, &localslot);
-
- oldctx = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
- if (found)
- {
- /* Apply the update. */
- slot_modify_data(remoteslot_part, localslot,
- part_entry,
- newtup);
- MemoryContextSwitchTo(oldctx);
- }
- else
+ if (!found)
{
/*
* The tuple to be updated could not be found.
@@ -1750,8 +1740,16 @@ apply_handle_tuple_routing(ApplyExecutionData *edata,
"logical replication did not find row for update "
"in replication target relation \"%s\"",
RelationGetRelationName(partrel));
+ /* Nothing further to do here. */
+ return;
}
+ /* Apply the update. */
+ oldctx = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));
+ slot_modify_data(remoteslot_part, localslot, part_entry,
+ newtup);
+ MemoryContextSwitchTo(oldctx);
+
/*
* Does the updated tuple still satisfy the current
* partition's constraint?