Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
HAMANO Tsukasa
OpenLDAP
Commits
acbff5b1
Commit
acbff5b1
authored
Sep 17, 2012
by
Howard Chu
Browse files
Add mdb_cursor_renew()
Allow cursors on read-only txns to be reused with later txns.
parent
076b2b36
Changes
2
Hide whitespace changes
Inline
Side-by-side
libraries/libmdb/mdb.c
View file @
acbff5b1
...
...
@@ -5285,6 +5285,19 @@ mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **ret)
return
MDB_SUCCESS
;
}
int
mdb_cursor_renew
(
MDB_txn
*
txn
,
MDB_cursor
*
mc
)
{
if
(
txn
==
NULL
||
mc
==
NULL
||
mc
->
mc_dbi
>=
txn
->
mt_numdbs
)
return
EINVAL
;
if
(
txn
->
mt_cursors
)
return
EINVAL
;
mdb_cursor_init
(
mc
,
txn
,
mc
->
mc_dbi
,
mc
->
mc_xcursor
);
return
MDB_SUCCESS
;
}
/* Return the count of duplicate data items for the current key */
int
mdb_cursor_count
(
MDB_cursor
*
mc
,
size_t
*
countp
)
...
...
libraries/libmdb/mdb.h
View file @
acbff5b1
...
...
@@ -904,6 +904,23 @@ int mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor);
*/
void
mdb_cursor_close
(
MDB_cursor
*
cursor
);
/** @brief Renew a cursor handle.
*
* Cursors are associated with a specific transaction and database and
* may not span threads. Cursors that are only used in read-only
* transactions may be re-used, to avoid unnecessary malloc/free overhead.
* The cursor may be associated with a new read-only transaction, and
* referencing the same database handle as it was created with.
* @param[in] txn A transaction handle returned by #mdb_txn_begin()
* @param[in] cursor A cursor handle returned by #mdb_cursor_open()
* @return A non-zero error value on failure and 0 on success. Some possible
* errors are:
* <ul>
* <li>EINVAL - an invalid parameter was specified.
* </ul>
*/
int
mdb_cursor_renew
(
MDB_txn
*
txn
,
MDB_cursor
*
cursor
);
/** @brief Return the cursor's transaction handle.
*
* @param[in] cursor A cursor handle returned by #mdb_cursor_open()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment