8000 Avoid xid error from age() function when run on Hot Standby · jcsston/postgres@d02918f · GitHub
[go: up one dir, main page]

Skip to content

Commit d02918f

Browse files
Avoid xid error from age() function when run on Hot Standby
1 parent 14c412d commit d02918f

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)
0