1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Avoid xid error from age() function when run on Hot Standby

This commit is contained in:
Simon Riggs
2012-05-09 13:59:30 +01:00
parent 1c0e678678
commit e7c43ddc26

View File

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