Set statement timestamp in apply worker
authorPeter Eisentraut <peter_e@gmx.net>
Sat, 17 Jun 2017 12:54:21 +0000 (08:54 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Sat, 17 Jun 2017 12:54:21 +0000 (08:54 -0400)
This ensures that triggers can see an up-to-date timestamp.

Reported-by: Konstantin Evteev <konst583@gmail.com>
src/backend/replication/logical/worker.c

index 97d2dff0dd34b5c2ce44003e4eaeb6cb2b92a99c..21a4fea821dcd07bea913614b7f4b0f0791a3dc2 100644 (file)
@@ -157,12 +157,15 @@ ensure_transaction(void)
 {
        if (IsTransactionState())
        {
+               SetCurrentStatementStartTimestamp();
+
                if (CurrentMemoryContext != ApplyMessageContext)
                        MemoryContextSwitchTo(ApplyMessageContext);
 
                return false;
        }
 
+       SetCurrentStatementStartTimestamp();
        StartTransactionCommand();
 
        maybe_reread_subscription();