diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2018-07-30 16:30:07 -0400 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2018-07-30 16:30:07 -0400 |
commit | 2c4d0f32e0c75179bba360ee884f535117b28b90 (patch) | |
tree | 4f7c340b5717b47eefc4b812611a2aa7e652b5d5 /src/backend/replication/logical/worker.c | |
parent | 96b1d984feab268131dfd09dd7a1048dd221094f (diff) |
Set ActiveSnapshot when logically replaying inserts
Input functions for the inserted tuples may require a snapshot, when
they are replayed by native logical replication. An example is a domain
with a constraint using a SQL-language function, which prior to this
commit failed to apply on the subscriber side.
Reported-by: Mai Peng <maily.peng@webedia-group.com>
Co-authored-by: Minh-Quan TRAN <qtran@itscaro.me>
Co-authored-by: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/4EB4BD78-BFC3-4D04-B8DA-D53DF7160354@webedia-group.com
Discussion: https://postgr.es/m/153211336163.1404.11721804383024050689@wrigleys.postgresql.org
Diffstat (limited to 'src/backend/replication/logical/worker.c')
-rw-r--r-- | src/backend/replication/logical/worker.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 39bfb6d39c9..bd600945761 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -607,13 +607,15 @@ apply_handle_insert(StringInfo s) remoteslot = ExecInitExtraTupleSlot(estate); ExecSetSlotDescriptor(remoteslot, RelationGetDescr(rel->localrel)); + /* Input functions may need an active snapshot, so get one */ + PushActiveSnapshot(GetTransactionSnapshot()); + /* Process and store remote tuple in the slot */ oldctx = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate)); slot_store_cstrings(remoteslot, rel, newtup.values); slot_fill_defaults(rel, estate, remoteslot); MemoryContextSwitchTo(oldctx); - PushActiveSnapshot(GetTransactionSnapshot()); ExecOpenIndices(estate->es_result_relation_info, false); /* Do the insert. */ |