Full_Name: Christopher Zimmermann
Version: lmdb 0.9.23
OS: OpenBSD
URL:
Submission from: (NULL) (85.212.134.155)
Hello,
I'm working on a language binding of lmdb for OCaml. While doing so I missed a
functin with with to check whether a transaction is read-only. To implement the
functionality I propose the following change.
The attached patch file is derived from OpenLDAP Software. All of the
modifications to OpenLDAP Software represented in the following patch(es) were
developed by Christopher Zimmermann <christopher(a)gmerlin.de>. I have not
assigned rights and/or interest in this work to any party.
I, Christopher Zimmermann, hereby place the following modifications to OpenLDAP
Software (and only these modifications) into the public domain. Hence, these
modifications may be freely used and/or redistributed for any purpose with or
without attribution and/or other notice.
>From 2e573257a15edb0aebef3d522c262fa75c676f84 Mon Sep 17 00:00:00 2001
From: Christopher Zimmermann <madroach(a)gmerlin.de>
Date: Sat, 20 Apr 2019 23:06:51 +0200
Subject: [PATCH] Add mdb_txn_flags()
---
libraries/liblmdb/lmdb.h | 8 ++++++++
libraries/liblmdb/mdb.c | 7 +++++++
2 files changed, 15 insertions(+)
diff --git libraries/liblmdb/lmdb.h libraries/liblmdb/lmdb.h
index 50ee37f..46ae389 100644
--- libraries/liblmdb/lmdb.h
+++ libraries/liblmdb/lmdb.h
@@ -989,6 +989,14 @@ MDB_env *mdb_txn_env(MDB_txn *txn);
*/
size_t mdb_txn_id(MDB_txn *txn);
+ /** @brief Retrieve the transaction's flags
+ *
+ * @param[in] txn A transaction handle returned by #mdb_txn_begin()
+ * @param[out] flags Address where the flags will be returned.
+ * @return A non-zero error value on failure and 0 on success.
+ */
+int mdb_txn_flags(MDB_txn *txn, unsigned int *flags);
+
/** @brief Commit all the operations of a transaction into the database.
*
* The transaction handle is freed. It and its cursors must not be used
diff --git libraries/liblmdb/mdb.c libraries/liblmdb/mdb.c
index 692feaa..fdf7618 100644
--- libraries/liblmdb/mdb.c
+++ libraries/liblmdb/mdb.c
@@ -2934,6 +2934,13 @@ mdb_txn_id(MDB_txn *txn)
return txn->mt_txnid;
}
+int mdb_txn_flags(MDB_txn *txn, unsigned int *flags)
+{
+ if(!txn) return EINVAL;
+ *flags = txn->mt_flags & MDB_RDONLY;
+ return MDB_SUCCESS;
+}
+
/** Export or close DBI handles opened in this txn. */
static void
mdb_dbis_update(MDB_txn *txn, int keep)
--
2.20.1