From 28b8aaeb9670cad3d02d1be226ff5980590625f4 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sun, 2 Oct 2011 19:27:31 -0700 Subject: [PATCH] Add mdb_cursor_txn() and mdb_cursor_dbi() for querying the cursor --- libraries/libmdb/mdb.c | 14 ++++++++++++++ libraries/libmdb/mdb.h | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/libraries/libmdb/mdb.c b/libraries/libmdb/mdb.c index c6bc4f93ee..b3f4f0de9f 100644 --- a/libraries/libmdb/mdb.c +++ b/libraries/libmdb/mdb.c @@ -4700,6 +4700,20 @@ mdb_cursor_close(MDB_cursor *mc) } } +MDB_txn * +mdb_cursor_txn(MDB_cursor *mc) +{ + if (!mc) return NULL; + return mc->mc_txn; +} + +MDB_dbi +mdb_cursor_dbi(MDB_cursor *mc) +{ + if (!mc) return 0; + return mc->mc_dbi; +} + /** Replace the key for a node with a new key. * @param[in] mp The page containing the node to operate on. * @param[in] indx The index of the node to operate on. diff --git a/libraries/libmdb/mdb.h b/libraries/libmdb/mdb.h index 3bb7e4cdd8..738f9deca0 100644 --- a/libraries/libmdb/mdb.h +++ b/libraries/libmdb/mdb.h @@ -846,6 +846,18 @@ int mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor); */ void mdb_cursor_close(MDB_cursor *cursor); + /** @brief Return the cursor's transaction handle. + * + * @param[in] cursor A cursor handle returned by #mdb_cursor_open() + */ +MDB_txn *mdb_cursor_txn(MDB_cursor *cursor); + + /** @brief Return the cursor's database handle. + * + * @param[in] cursor A cursor handle returned by #mdb_cursor_open() + */ +MDB_dbi mdb_cursor_dbi(MDB_cursor *cursor); + /** @brief Retrieve by cursor. * * This function retrieves key/data pairs from the database. The address and length -- 2.39.5