1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Implement mxid_age() to compute multi-xid age

Report by Josh Berkus
This commit is contained in:
Bruce Momjian
2014-09-10 17:13:04 -04:00
parent 84aa8ba128
commit 36ad1a87a3
5 changed files with 26 additions and 2 deletions

View File

@@ -16,6 +16,7 @@
#include <limits.h>
#include "access/multixact.h"
#include "access/transam.h"
#include "access/xact.h"
#include "libpq/pqformat.h"
@@ -102,6 +103,21 @@ xid_age(PG_FUNCTION_ARGS)
PG_RETURN_INT32((int32) (now - xid));
}
/*
* mxid_age - compute age of a multi XID (relative to latest stable mxid)
*/
Datum
mxid_age(PG_FUNCTION_ARGS)
{
TransactionId xid = PG_GETARG_TRANSACTIONID(0);
MultiXactId now = ReadNextMultiXactId();
if (!MultiXactIdIsValid(xid))
PG_RETURN_INT32(INT_MAX);
PG_RETURN_INT32((int32) (now - xid));
}
/*
* xidComparator
* qsort comparison function for XIDs