if (parent) {
/* Nested transactions: Max 1 child, write txns only, no writemap */
if (parent->mt_child ||
- (flags & MDB_RDONLY) || (parent->mt_flags & MDB_TXN_RDONLY) ||
+ (flags & MDB_RDONLY) ||
+ (parent->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_ERROR)) ||
(env->me_flags & MDB_WRITEMAP))
{
- return EINVAL;
+ return (parent->mt_flags & MDB_TXN_RDONLY) ? EINVAL : MDB_BAD_TXN;
}
tsize = sizeof(MDB_ntxn);
}
if (txn == NULL || !dbi || dbi >= txn->mt_numdbs || !(txn->mt_dbflags[dbi] & DB_VALID))
return EINVAL;
+ if (txn->mt_flags & MDB_TXN_ERROR)
+ return MDB_BAD_TXN;
+
if (key->mv_size == 0 || key->mv_size > MDB_MAXKEYSIZE) {
return MDB_BAD_VALSIZE;
}
assert(mc);
+ if (mc->mc_txn->mt_flags & MDB_TXN_ERROR)
+ return MDB_BAD_TXN;
+
switch (op) {
case MDB_GET_CURRENT:
if (!(mc->mc_flags & C_INITIALIZED)) {
nospill = flags & MDB_NOSPILL;
flags &= ~MDB_NOSPILL;
- if (F_ISSET(mc->mc_txn->mt_flags, MDB_TXN_RDONLY))
- return EACCES;
+ if (mc->mc_txn->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_ERROR))
+ return (mc->mc_txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN;
if (flags != MDB_CURRENT && (key->mv_size == 0 || key->mv_size > MDB_MAXKEYSIZE))
return MDB_BAD_VALSIZE;
MDB_node *leaf;
int rc;
- if (F_ISSET(mc->mc_txn->mt_flags, MDB_TXN_RDONLY))
- return EACCES;
+ if (mc->mc_txn->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_ERROR))
+ return (mc->mc_txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN;
if (!(mc->mc_flags & C_INITIALIZED))
return EINVAL;
if (txn == NULL || ret == NULL || dbi >= txn->mt_numdbs || !(txn->mt_dbflags[dbi] & DB_VALID))
return EINVAL;
+ if (txn->mt_flags & MDB_TXN_ERROR)
+ return MDB_BAD_TXN;
+
/* Allow read access to the freelist */
if (!dbi && !F_ISSET(txn->mt_flags, MDB_TXN_RDONLY))
return EINVAL;
if (txn == NULL || !dbi || dbi >= txn->mt_numdbs || !(txn->mt_dbflags[dbi] & DB_VALID))
return EINVAL;
- if (F_ISSET(txn->mt_flags, MDB_TXN_RDONLY)) {
- return EACCES;
- }
+ if (txn->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_ERROR))
+ return (txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN;
if (key->mv_size == 0 || key->mv_size > MDB_MAXKEYSIZE) {
return MDB_BAD_VALSIZE;
if (txn == NULL || !dbi || dbi >= txn->mt_numdbs || !(txn->mt_dbflags[dbi] & DB_VALID))
return EINVAL;
- if (F_ISSET(txn->mt_flags, MDB_TXN_RDONLY)) {
- return EACCES;
- }
+ if (txn->mt_flags & (MDB_TXN_RDONLY|MDB_TXN_ERROR))
+ return (txn->mt_flags & MDB_TXN_RDONLY) ? EACCES : MDB_BAD_TXN;
if (key->mv_size == 0 || key->mv_size > MDB_MAXKEYSIZE) {
return MDB_BAD_VALSIZE;
if ((flags & VALID_FLAGS) != flags)
return EINVAL;
+ if (txn->mt_flags & MDB_TXN_ERROR)
+ return MDB_BAD_TXN;
/* main DB? */
if (!name) {