mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 17:04:13 +08:00
mdbx: fix mdbx_dbi_open_ex(MDBX_CREATE) for rdonly txn.
Fix https://github.com/leo-yuriev/libmdbx/issues/19 Change-Id: I3ae1ab3188482fd8c31de51d62e34591082cd60a
This commit is contained in:
parent
26dab6dee0
commit
5b23d7e452
@ -8118,6 +8118,8 @@ static void mdbx_cursor_copy(const MDBX_cursor *csrc, MDBX_cursor *cdst);
|
|||||||
/* Perform act while tracking temporary cursor mn */
|
/* Perform act while tracking temporary cursor mn */
|
||||||
#define WITH_CURSOR_TRACKING(mn, act) \
|
#define WITH_CURSOR_TRACKING(mn, act) \
|
||||||
do { \
|
do { \
|
||||||
|
mdbx_cassert(&(mn), \
|
||||||
|
mn.mc_txn->mt_cursors != NULL /* must be not rdonly txt */); \
|
||||||
MDBX_cursor mc_dummy, *tracked, \
|
MDBX_cursor mc_dummy, *tracked, \
|
||||||
**tp = &(mn).mc_txn->mt_cursors[mn.mc_dbi]; \
|
**tp = &(mn).mc_txn->mt_cursors[mn.mc_dbi]; \
|
||||||
if ((mn).mc_flags & C_SUB) { \
|
if ((mn).mc_flags & C_SUB) { \
|
||||||
@ -10080,6 +10082,10 @@ int mdbx_dbi_open_ex(MDBX_txn *txn, const char *table_name, unsigned user_flags,
|
|||||||
return MDBX_INCOMPATIBLE;
|
return MDBX_INCOMPATIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rc != MDBX_SUCCESS &&
|
||||||
|
unlikely(txn->mt_flags & (MDBX_TXN_RDONLY | MDBX_TXN_BLOCKED)))
|
||||||
|
return (txn->mt_flags & MDBX_TXN_RDONLY) ? MDBX_EACCESS : MDBX_BAD_TXN;
|
||||||
|
|
||||||
/* Done here so we cannot fail after creating a new DB */
|
/* Done here so we cannot fail after creating a new DB */
|
||||||
char *namedup = mdbx_strdup(table_name);
|
char *namedup = mdbx_strdup(table_name);
|
||||||
if (unlikely(!namedup))
|
if (unlikely(!namedup))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user