summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpukkamustard <pukkamustard@posteo.net>2021-01-12 09:07:30 +0100
committerpukkamustard <pukkamustard@posteo.net>2021-01-12 09:07:30 +0100
commit82b569ec39389e799ffc7c9cf3da2ef92dfe39e3 (patch)
treea442879bc2f658e3255d02d01707e712902e434e
parent35f9fc59327945b2c48b2687f12f76837784e970 (diff)
(lmdb low-level): Allow flags and parent transaction in mdb-txn-begin
-rw-r--r--lmdb/low-level.scm14
1 files changed, 10 insertions, 4 deletions
diff --git a/lmdb/low-level.scm b/lmdb/low-level.scm
index ee6c684..99c5c43 100644
--- a/lmdb/low-level.scm
+++ b/lmdb/low-level.scm
@@ -194,7 +194,7 @@
(format port "#<mdb-txn ~x>"
(pointer-address (unwrap-mdb-txn mdb-txn)))))
-(define (mdb-txn-begin env)
+(define* (mdb-txn-begin env #:key (flags 0) (parent #f))
"Create a transaction for use with the environment"
(let* ((proc (liblmdb-func "mdb_txn_begin"
(list
@@ -207,14 +207,20 @@
;; MDB_txn** txn
'*)))
+ ;; pointer to parent transaction
+ (parent-ptr (if (mdb-txn? parent)
+ (unwrap-mdb-txn parent)
+ ;; else use a NULL pointer
+ (make-pointer 0)))
+
;; allocate a new pointer for returned txn
(txn-ptr (bytevector->pointer
(make-bytevector (sizeof '*))))
+
;; call mdb_txn_begin
(return-value (proc (unwrap-mdb-env env)
- ;; TODO allow specifying parent txn
- (make-pointer 0)
- 0
+ parent-ptr
+ flags
txn-ptr)))
(if (eqv? return-value MDB_SUCCESS)