Skip to content

Commit 4ab4485

Browse files
author
JkLondon
committed
Add Unbind method for Cursor and ReleaseAllCursors for Txn
1 parent f298a8b commit 4ab4485

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

mdbx/cursor.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ func (c *Cursor) Bind(txn *Txn, db DBI) error {
9898
return nil
9999
}
100100

101+
// Unbind Unbinded cursor is disassociated with any transactions but still holds
102+
// the original DBI-handle internally. Thus, it could be renewed with any running
103+
// transaction or closed.
104+
func (c *Cursor) Unbind() error {
105+
ret := C.mdbx_cursor_unbind(c._c)
106+
if ret != success {
107+
return operrno("mdbx_cursor_unbind", ret)
108+
}
109+
return nil
110+
}
111+
101112
// Close the cursor handle and clear the finalizer on c. Cursors belonging to
102113
// write transactions are closed automatically when the transaction is
103114
// terminated.

mdbx/txn.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,3 +768,11 @@ func (txn *Txn) EnvWarmup(flags uint, timeout time.Duration) error {
768768
func (txn *Txn) CHandle() unsafe.Pointer {
769769
return unsafe.Pointer(txn._txn)
770770
}
771+
772+
func (txn *Txn) ReleaseAllCursors(unbind bool) error {
773+
ret := C.mdbx_txn_release_all_cursors(txn._txn, C.bool(unbind))
774+
if ret != success {
775+
return operrno("mdbx_txn_release_all_cursors", ret)
776+
}
777+
return nil
778+
}

0 commit comments

Comments
 (0)