mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Pass MDB_RDONLY to the LMDB environment for readonly DBs
This commit is contained in:
parent
0887a1d7ab
commit
79d831ff9f
1 changed files with 6 additions and 1 deletions
|
@ -46,6 +46,11 @@ DBA_OPEN_FUNC(lmdb)
|
||||||
|
|
||||||
ZEND_ASSERT(map_size >= 0);
|
ZEND_ASSERT(map_size >= 0);
|
||||||
|
|
||||||
|
/* Add readonly flag if DB is opened in read only mode */
|
||||||
|
if (info->mode == DBA_READER) {
|
||||||
|
flags |= MDB_RDONLY;
|
||||||
|
}
|
||||||
|
|
||||||
rc = mdb_env_create(&env);
|
rc = mdb_env_create(&env);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
*error = mdb_strerror(rc);
|
*error = mdb_strerror(rc);
|
||||||
|
@ -69,7 +74,7 @@ DBA_OPEN_FUNC(lmdb)
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = mdb_txn_begin(env, NULL, 0, &txn);
|
rc = mdb_txn_begin(env, NULL, /* flags */ MDB_RDONLY, &txn);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
mdb_env_close(env);
|
mdb_env_close(env);
|
||||||
*error = mdb_strerror(rc);
|
*error = mdb_strerror(rc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue