aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthe lemons <citrons@mondecitronne.com>2022-12-05 20:00:26 -0600
committerthe lemons <citrons@mondecitronne.com>2022-12-05 20:00:26 -0600
commit4384b3d0bdeca1fa3df5bb8a7cc13cf043b8c3a6 (patch)
tree7c4dbf2fa07708cb400453ec20804fd6ddff6249
parent187933ca79bfbad8ca06505fcd18dacc8ee66925 (diff)
env:txn_begin(): make read-only by default
this is more sensible behavior. read-write transactions are less performant, so the programmer should have to engage them explicitly.
-rw-r--r--README.md6
-rw-r--r--lmdb.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/README.md b/README.md
index bd19045..dd0fdef 100644
--- a/README.md
+++ b/README.md
@@ -19,8 +19,8 @@ create a new environment handle and open the database at the `path`. returns the
### `lmdb.version()`
returns the LMDB version as `major, minor, patch`.
-### `env:txn_begin(rdonly)`
-create a new transaction in the environment. if `rdonly` is true, then the transaction is not to be used to perform write operations. returns the transaction handle (`txn`) on success.
+### `env:txn_begin(write_enabled)`
+create a new transaction in the environment. if `write_enabled` is true, then the transaction may make modifications to the database. returns the transaction handle (`txn`) on success.
### `env:copy(path)`
copy the environment to the specified `path`. return `true` on success.
@@ -45,5 +45,5 @@ abandon all operations performed in the transaction.
### `txn:commit()`
commit all operations of the transaction into the database.
-### `txn:txn_begin(rdonly)`
+### `txn:txn_begin()`
create a nested transaction in the parent transaction.
diff --git a/lmdb.c b/lmdb.c
index 1a2c27a..5bcf162 100644
--- a/lmdb.c
+++ b/lmdb.c
@@ -146,7 +146,7 @@ static int txn_begin(lua_State *L, bool nested) {
MDB_txn *txn;
reterr(mdb_txn_begin(
- env, parent, lua_toboolean(L, 2) ? MDB_RDONLY : 0, &txn));
+ env, parent, lua_toboolean(L, 2) || nested ? 0 : MDB_RDONLY, &txn));
struct handle *tud = lua_newuserdata(L, sizeof(struct handle));
tud->closed = false;