diff --git a/heed/src/mdb/lmdb_ffi.rs b/heed/src/mdb/lmdb_ffi.rs index 1f68da0e..4c44cdc1 100644 --- a/heed/src/mdb/lmdb_ffi.rs +++ b/heed/src/mdb/lmdb_ffi.rs @@ -6,9 +6,9 @@ pub use ffi::{ mdb_env_get_fd, mdb_env_get_flags, mdb_env_get_maxkeysize, mdb_env_info, mdb_env_open, mdb_env_set_flags, mdb_env_set_mapsize, mdb_env_set_maxdbs, mdb_env_set_maxreaders, mdb_env_stat, mdb_env_sync, mdb_filehandle_t, mdb_get, mdb_put, mdb_reader_check, - mdb_set_compare, mdb_stat, mdb_txn_abort, mdb_txn_begin, mdb_txn_commit, mdb_version, - MDB_cursor, MDB_dbi, MDB_env, MDB_stat, MDB_txn, MDB_val, MDB_CP_COMPACT, MDB_CURRENT, - MDB_RDONLY, MDB_RESERVE, + mdb_set_compare, mdb_stat, mdb_txn_abort, mdb_txn_begin, mdb_txn_commit, mdb_txn_id, + mdb_version, MDB_cursor, MDB_dbi, MDB_env, MDB_stat, MDB_txn, MDB_val, MDB_CP_COMPACT, + MDB_CURRENT, MDB_RDONLY, MDB_RESERVE, }; #[cfg(master3)] pub use ffi::{mdb_env_set_encrypt, MDB_enc_func}; diff --git a/heed/src/txn.rs b/heed/src/txn.rs index 657f1262..2cea3df7 100644 --- a/heed/src/txn.rs +++ b/heed/src/txn.rs @@ -86,6 +86,15 @@ impl<'e> RoTxn<'e> { self.env.env_mut_ptr() } + /// Return the transaction's ID. + /// + /// This returns the identifier associated with this transaction. For a + /// [`RoTxn`], this corresponds to the snapshot being read; + /// concurrent readers will frequently have the same transaction ID. + pub fn id(&self) -> usize { + unsafe { ffi::mdb_txn_id(self.txn.unwrap().as_ptr()) } + } + /// Commit a read transaction. /// /// Synchronizing some [`Env`] metadata with the global handle.