aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/utils/adt/xid.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/backend/utils/adt/xid.c b/src/backend/utils/adt/xid.c
index 602a9e5d6f4..ecb3cf55dd1 100644
--- a/src/backend/utils/adt/xid.c
+++ b/src/backend/utils/adt/xid.c
@@ -16,6 +16,7 @@
#include <limits.h>
+#include "access/multixact.h"
#include "access/transam.h"
#include "access/xact.h"
#include "libpq/pqformat.h"
@@ -103,6 +104,21 @@ xid_age(PG_FUNCTION_ARGS)
}
/*
+ * 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
*