Commit e382a6bc authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

add some txnid comparison functions [t:1972]

git-svn-id: file:///svn/toku/tokudb@14308 c7de825b-a66e-492c-adef-691d508d4ae1
parent 001bc6f4
......@@ -443,8 +443,7 @@ static int toku_recover_backward_xstillopen (struct logtype_xstillopen *l, RECOV
case BS_SAW_CKPT_END:
if (bs->n_live_txns == 0)
bs->min_live_txn = l->txnid;
// TODO need a new txnid comparison
else if (bs->min_live_txn > l->txnid)
else if (toku_txnid_older(l->txnid, bs->min_live_txn))
bs->min_live_txn = l->txnid;
bs->n_live_txns++;
return 0;
......@@ -595,11 +594,12 @@ static int compare_txn(const void *a, const void *b) {
TOKUTXN atxn = (TOKUTXN) * (void **) a;
TOKUTXN btxn = (TOKUTXN) * (void **) b;
// TODO this is wrong. we want if (older(atxn, btxn)) return -1
if (atxn->txnid64 > btxn->txnid64)
return -1;
if (atxn->txnid64 < btxn->txnid64)
if (toku_txnid_eq(atxn->txnid64, btxn->txnid64))
return 0;
if (toku_txnid_older(atxn->txnid64, btxn->txnid64))
return +1;
return 0;
else
return -1;
}
// Append a transaction to the set of live transactions
......
......@@ -151,3 +151,10 @@ XIDS toku_txn_get_xids (TOKUTXN txn) {
else return txn->xids;
}
BOOL toku_txnid_older(TXNID a, TXNID b) {
return a < b; // TODO need modulo 64 arithmetic
}
BOOL toku_txnid_eq(TXNID a, TXNID b) {
return (BOOL)(a == b);
}
......@@ -12,4 +12,13 @@ int toku_txn_abort_txn(TOKUTXN txn, YIELDF yield, void*yieldv);
void toku_txn_close_txn(TOKUTXN txn);
XIDS toku_txn_get_xids (TOKUTXN);
// Returns TRUE if a is older than b
BOOL toku_txnid_older(TXNID a, TXNID b);
// Returns TRUE if a == b
BOOL toku_txnid_eq(TXNID a, TXNID b);
// Returns TRUE if a is newer than b
BOOL toku_txnid_newer(TXNID a, TXNID b);
#endif //TOKUTXN_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment