]> granicus.if.org Git - postgresql/commitdiff
Avoid xid error from age() function when run on Hot Standby
authorSimon Riggs <simon@2ndQuadrant.com>
Wed, 9 May 2012 13:00:09 +0000 (14:00 +0100)
committerSimon Riggs <simon@2ndQuadrant.com>
Wed, 9 May 2012 13:00:09 +0000 (14:00 +0100)
src/backend/utils/adt/xid.c

index fcde92cb8a8f83958e175f10d223e291b3365a43..7db6bb1a66083e4d4f25e0f6d20f2ed46d1d1721 100644 (file)
@@ -93,7 +93,10 @@ Datum
 xid_age(PG_FUNCTION_ARGS)
 {
        TransactionId xid = PG_GETARG_TRANSACTIONID(0);
-       TransactionId now = GetTopTransactionId();
+       TransactionId now = GetTopTransactionIdIfAny();
+
+       if (!TransactionIdIsValid(now))
+               now = ReadNewTransactionId();
 
        /* Permanent XIDs are always infinitely old */
        if (!TransactionIdIsNormal(xid))