From: David Barbour Date: Mon, 12 Jan 2015 22:00:30 +0000 (+0100) Subject: ITS#7994 Access to current transaction ID. X-Git-Tag: LMDB_0.9.17~88 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=076b773d6bab49e1b467051cc09f2522444a22f3;p=openldap ITS#7994 Access to current transaction ID. commit b660491d3fa359325cb3615a276bba78f32e2075 (mdb_txn_id()) plus c36c167cc49a59d4f40ae5fc259c013de601164e (fix prev commit) from mdb.master. --- diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index c5e5c9bf12..ee302a2365 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -953,6 +953,17 @@ int mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn ** */ MDB_env *mdb_txn_env(MDB_txn *txn); + /** @brief Return the transaction's ID. + * + * This returns the identifier associated with this transaction. For a + * read-only transaction, this corresponds to the snapshot being read; + * concurrent readers will frequently have the same transaction ID. + * + * @param[in] txn A transaction handle returned by #mdb_txn_begin() + * @return A transaction ID, valid if input is an active transaction. + */ +size_t mdb_txn_id(MDB_txn *txn); + /** @brief Commit all the operations of a transaction into the database. * * The transaction handle is freed. It and its cursors must not be used diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index da09f8dbfe..2ae60436b5 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -2766,6 +2766,13 @@ mdb_txn_env(MDB_txn *txn) return txn->mt_env; } +size_t +mdb_txn_id(MDB_txn *txn) +{ + if(!txn) return 0; + return txn->mt_txnid; +} + /** Export or close DBI handles opened in this txn. */ static void mdb_dbis_update(MDB_txn *txn, int keep)