Index: src/backend/replication/logical/worker.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/backend/replication/logical/worker.c	(revision 986127e3db6858c461dae00f23c1fbaf9302d8cb)
+++ src/backend/replication/logical/worker.c	(date 1532114885746)
@@ -610,15 +610,15 @@
 	remoteslot = ExecInitExtraTupleSlot(estate,
 										RelationGetDescr(rel->localrel));
 
+    PushActiveSnapshot(GetTransactionSnapshot());
+    ExecOpenIndices(estate->es_result_relation_info, false);
+
 	/* 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. */
 	ExecSimpleRelationInsert(estate, remoteslot);
 
