Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5829387

Browse files
Avoid xid error from age() function when run on Hot Standby
1 parent 773b5e0 commit 5829387

File tree

1 file changed

+4
-1
lines changed
  • src/backend/utils/adt

1 file changed

+4
-1
lines changed

src/backend/utils/adt/xid.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ Datum
9393
xid_age(PG_FUNCTION_ARGS)
9494
{
9595
TransactionId xid = PG_GETARG_TRANSACTIONID(0);
96-
TransactionId now = GetTopTransactionId();
96+
TransactionId now = GetTopTransactionIdIfAny();
97+
98+
if (!TransactionIdIsValid(now))
99+
now = ReadNewTransactionId();
97100

98101
/* Permanent XIDs are always infinitely old */
99102
if (!TransactionIdIsNormal(xid))

0 commit comments

Comments
 (0)