Skip to content

Commit aa9fb08

Browse files
committed
Pass MDB_RDONLY to the LMDB environment for readonly DBs
1 parent c580a38 commit aa9fb08

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ PHP 8.2 UPGRADE NOTES
172172
The overloaded signature
173173
dba_fetch(string|array $key, $skip, $dba): string|false
174174
is still accepted, but it is recommended to use the new standard variant.
175+
- LMDB
176+
. When opened with the readonly mode, the MDB_RDONLY flag is now passed to the underlying database environment
175177

176178
========================================
177179
6. New Functions

ext/dba/dba_lmdb.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ DBA_OPEN_FUNC(lmdb)
4646

4747
ZEND_ASSERT(map_size >= 0);
4848

49+
/* Add readonly flag if DB is opened in read only mode */
50+
if (info->mode == DBA_READER) {
51+
flags |= MDB_RDONLY;
52+
}
53+
4954
rc = mdb_env_create(&env);
5055
if (rc) {
5156
*error = mdb_strerror(rc);
@@ -66,7 +71,7 @@ DBA_OPEN_FUNC(lmdb)
6671
return FAILURE;
6772
}
6873

69-
rc = mdb_txn_begin(env, NULL, 0, &txn);
74+
rc = mdb_txn_begin(env, NULL, /* flags */ MDB_RDONLY, &txn);
7075
if (rc) {
7176
mdb_env_close(env);
7277
*error = mdb_strerror(rc);

0 commit comments

Comments
 (0)