Skip to content

Commit 076b773

Browse files
dmbarbourhfuru
authored andcommitted
ITS#7994 Access to current transaction ID.
commit b660491d3fa359325cb3615a276bba78f32e2075 (mdb_txn_id()) plus c36c167cc49a59d4f40ae5fc259c013de601164e (fix prev commit) from mdb.master.
1 parent f3d3f60 commit 076b773

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

libraries/liblmdb/lmdb.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,17 @@ int mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **
953953
*/
954954
MDB_env *mdb_txn_env(MDB_txn *txn);
955955

956+
/** @brief Return the transaction's ID.
957+
*
958+
* This returns the identifier associated with this transaction. For a
959+
* read-only transaction, this corresponds to the snapshot being read;
960+
* concurrent readers will frequently have the same transaction ID.
961+
*
962+
* @param[in] txn A transaction handle returned by #mdb_txn_begin()
963+
* @return A transaction ID, valid if input is an active transaction.
964+
*/
965+
size_t mdb_txn_id(MDB_txn *txn);
966+
956967
/** @brief Commit all the operations of a transaction into the database.
957968
*
958969
* The transaction handle is freed. It and its cursors must not be used

libraries/liblmdb/mdb.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,6 +2766,13 @@ mdb_txn_env(MDB_txn *txn)
27662766
return txn->mt_env;
27672767
}
27682768

2769+
size_t
2770+
mdb_txn_id(MDB_txn *txn)
2771+
{
2772+
if(!txn) return 0;
2773+
return txn->mt_txnid;
2774+
}
2775+
27692776
/** Export or close DBI handles opened in this txn. */
27702777
static void
27712778
mdb_dbis_update(MDB_txn *txn, int keep)

0 commit comments

Comments
 (0)