diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2012-05-11 14:36:24 +0100 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2012-05-11 14:36:24 +0100 |
commit | b06679e01244d33304b71a6a44c7cc86173617b3 (patch) | |
tree | e53c3c2f8f2649a408e25262f2674717ea3e4b86 /src/backend/utils/adt/xid.c | |
parent | 3652d72dd45b3ef2ca5e83e8cbd09f78696ad4c4 (diff) | |
download | postgresql-b06679e01244d33304b71a6a44c7cc86173617b3.tar.gz postgresql-b06679e01244d33304b71a6a44c7cc86173617b3.zip |
Ensure age() returns a stable value rather than the latest value
Diffstat (limited to 'src/backend/utils/adt/xid.c')
-rw-r--r-- | src/backend/utils/adt/xid.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/backend/utils/adt/xid.c b/src/backend/utils/adt/xid.c index eeda081ad18..da9da8a29b9 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)) |