Set statement timestamp in apply worker
authorPeter Eisentraut <[email protected]>
Sat, 17 Jun 2017 12:54:21 +0000 (08:54 -0400)
committerPeter Eisentraut <[email protected]>
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 <[email protected]>
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();