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:
@@ -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
|
||||
|
Reference in New Issue
Block a user