aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/transam.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/transam/transam.c')
-rw-r--r--src/backend/access/transam/transam.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index 3466b50ef24..e53b05e04d5 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.70 2007/08/01 22:45:07 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.71 2007/09/08 20:31:14 tgl Exp $
*
* NOTES
* This file contains the high level access-method interface to the
@@ -432,6 +432,33 @@ TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2)
return (diff >= 0);
}
+
+/*
+ * TransactionIdLatest --- get latest XID among a main xact and its children
+ */
+TransactionId
+TransactionIdLatest(TransactionId mainxid,
+ int nxids, const TransactionId *xids)
+{
+ TransactionId result;
+
+ /*
+ * In practice it is highly likely that the xids[] array is sorted, and
+ * so we could save some cycles by just taking the last child XID, but
+ * this probably isn't so performance-critical that it's worth depending
+ * on that assumption. But just to show we're not totally stupid, scan
+ * the array back-to-front to avoid useless assignments.
+ */
+ result = mainxid;
+ while (--nxids >= 0)
+ {
+ if (TransactionIdPrecedes(result, xids[nxids]))
+ result = xids[nxids];
+ }
+ return result;
+}
+
+
/*
* TransactionIdGetCommitLSN
*