Add mdb_cursor_txn() and mdb_cursor_dbi() for querying the cursor
authorHoward Chu <hyc@symas.com>
Mon, 3 Oct 2011 02:27:31 +0000 (19:27 -0700)
committerHoward Chu <highlandsun@gmail.com>
Mon, 3 Oct 2011 02:28:33 +0000 (19:28 -0700)
libraries/libmdb/mdb.c
libraries/libmdb/mdb.h

index c6bc4f9..b3f4f0d 100644 (file)
@@ -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.
index 3bb7e4c..738f9de 100644 (file)
@@ -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