mirror of
https://github.com/isar/libmdbx.git
synced 2025-02-01 08:58:20 +08:00
mdbx: backport - Add error MDB_PROBLEM, replace some MDB_CORRUPTED.
When problem is most likely in txn, not on disk. Change-Id: Ie01d9eb32e8f250f6dd98f3fe84c38ed15593a2e
This commit is contained in:
parent
3befcdab01
commit
dd98ab22da
4
lmdb.h
4
lmdb.h
@ -475,8 +475,10 @@ typedef enum MDB_cursor_op {
|
||||
#define MDB_BAD_VALSIZE (-30781)
|
||||
/** The specified DBI was changed unexpectedly */
|
||||
#define MDB_BAD_DBI (-30780)
|
||||
/** Unexpected problem - txn should abort */
|
||||
#define MDB_PROBLEM (-30779)
|
||||
/** The last defined error code */
|
||||
#define MDB_LAST_ERRCODE MDB_BAD_DBI
|
||||
#define MDB_LAST_ERRCODE MDB_PROBLEM
|
||||
/** @} */
|
||||
|
||||
/** @brief Statistics for a database in the environment */
|
||||
|
9
mdb.c
9
mdb.c
@ -1181,6 +1181,7 @@ static char *const mdb_errstr[] = {
|
||||
"MDB_BAD_TXN: Transaction must abort, has a child, or is invalid",
|
||||
"MDB_BAD_VALSIZE: Unsupported size of key/DB name/data, or wrong DUPFIXED size",
|
||||
"MDB_BAD_DBI: The specified DBI handle was closed/changed unexpectedly",
|
||||
"MDB_PROBLEM: Unexpected problem - txn should abort",
|
||||
};
|
||||
|
||||
char * __cold
|
||||
@ -1640,7 +1641,7 @@ mdb_page_loose(MDB_cursor *mc, MDB_page *mp)
|
||||
if (unlikely(mp != dl[x].mptr)) { /* bad cursor? */
|
||||
mc->mc_flags &= ~(C_INITIALIZED|C_EOF);
|
||||
txn->mt_flags |= MDB_TXN_ERROR;
|
||||
return MDB_CORRUPTED;
|
||||
return MDB_PROBLEM;
|
||||
}
|
||||
/* ok, it's ours */
|
||||
loose = 1;
|
||||
@ -2490,7 +2491,7 @@ mdb_page_touch(MDB_cursor *mc)
|
||||
if (unlikely(mp != dl[x].mptr)) { /* bad cursor? */
|
||||
mc->mc_flags &= ~(C_INITIALIZED|C_EOF);
|
||||
txn->mt_flags |= MDB_TXN_ERROR;
|
||||
return MDB_CORRUPTED;
|
||||
return MDB_PROBLEM;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -5664,7 +5665,7 @@ mdb_ovpage_free(MDB_cursor *mc, MDB_page *mp)
|
||||
j = ++(dl[0].mid);
|
||||
dl[j] = ix; /* Unsorted. OK when MDB_TXN_ERROR. */
|
||||
txn->mt_flags |= MDB_TXN_ERROR;
|
||||
return MDB_CORRUPTED;
|
||||
return MDB_PROBLEM;
|
||||
}
|
||||
}
|
||||
txn->mt_dirty_room++;
|
||||
@ -7030,7 +7031,7 @@ put_sub:
|
||||
return rc;
|
||||
bad_sub:
|
||||
if (unlikely(rc == MDB_KEYEXIST)) /* should not happen, we deleted that item */
|
||||
rc = MDB_CORRUPTED;
|
||||
rc = MDB_PROBLEM;
|
||||
}
|
||||
mc->mc_txn->mt_flags |= MDB_TXN_ERROR;
|
||||
return rc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user