]> 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 12:56:24 +0000 (13:56 +0100)
committerSimon Riggs <simon@2ndQuadrant.com>
Wed, 9 May 2012 12:56:24 +0000 (13:56 +0100)
src/backend/utils/adt/xid.c

index 1829b8242d29ce884868347958378803a0da259d..eeda081ad18adb1f523f69f6cc1086e8fba7da3a 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))