Skip to content

Commit

Permalink
Add support for getting txn id
Browse files Browse the repository at this point in the history
  • Loading branch information
dureuill committed Dec 19, 2024
1 parent c219133 commit 874e9e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions heed/src/mdb/lmdb_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
9 changes: 9 additions & 0 deletions heed/src/txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 874e9e3

Please sign in to comment.