From 1a4bc2db6cb80a6e52aed8f5a68b895231653d6c Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Fri, 11 May 2012 14:38:11 +0100 Subject: Ensure age() returns a stable value rather than the latest value --- src/backend/utils/adt/xid.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/backend/utils/adt/xid.c') diff --git a/src/backend/utils/adt/xid.c b/src/backend/utils/adt/xid.c index 229e8e43e69..eecfee4e2ad 100644 --- a/src/backend/utils/adt/xid.c +++ b/src/backend/utils/adt/xid.c @@ -19,6 +19,7 @@ #include "access/transam.h" #include "access/xact.h" #include "libpq/pqformat.h" +#include "storage/proc.h" #include "utils/builtins.h" #define PG_GETARG_TRANSACTIONID(n) DatumGetTransactionId(PG_GETARG_DATUM(n)) @@ -87,16 +88,13 @@ xideq(PG_FUNCTION_ARGS) } /* - * xid_age - compute age of an XID (relative to current xact) + * xid_age - compute age of an XID (relative to latest stable xid) */ Datum xid_age(PG_FUNCTION_ARGS) { TransactionId xid = PG_GETARG_TRANSACTIONID(0); - TransactionId now = GetTopTransactionIdIfAny(); - - if (!TransactionIdIsValid(now)) - now = ReadNewTransactionId(); + TransactionId now = GetStableLatestTransactionId(); /* Permanent XIDs are always infinitely old */ if (!TransactionIdIsNormal(xid)) -- cgit v1.2.3