mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 02:04:12 +08:00
lmdb: fix mdb_chk for case MainDB's records isn't a sub-db.
Change-Id: I3a4ae1f50972fde6edab828b58199dde9b84550c
This commit is contained in:
parent
f2703156f0
commit
bd05dd24ab
2
mdb.c
2
mdb.c
@ -9410,7 +9410,7 @@ int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *db
|
||||
/* make sure this is actually a DB */
|
||||
MDB_node *node = NODEPTR(mc.mc_pg[mc.mc_top], mc.mc_ki[mc.mc_top]);
|
||||
if (!(node->mn_flags & F_SUBDATA))
|
||||
return MDB_INCOMPATIBLE;
|
||||
return MDB_BAD_DBI;
|
||||
} else if (rc == MDB_NOTFOUND && (flags & MDB_CREATE)) {
|
||||
/* Create if requested */
|
||||
data.mv_size = sizeof(MDB_db);
|
||||
|
@ -279,7 +279,7 @@ static long handle_maindb(size_t record_number, MDB_val *key, MDB_val* data) {
|
||||
|
||||
rc = process_db(-1, name, handle_userdb, 0);
|
||||
free(name);
|
||||
if (rc != MDB_NOTFOUND)
|
||||
if (rc != MDB_BAD_DBI)
|
||||
return rc;
|
||||
|
||||
return handle_userdb(record_number, key, data);
|
||||
@ -302,7 +302,7 @@ static long process_db(MDB_dbi dbi, char *name, visitor *handler, int silent)
|
||||
if (0 > (int) dbi) {
|
||||
rc = mdb_dbi_open(txn, name, 0, &dbi);
|
||||
if (rc) {
|
||||
if (rc != MDB_NOTFOUND) /* LY: mainDB's record is not a user's DB. */ {
|
||||
if (!name || rc != MDB_BAD_DBI) /* LY: mainDB's record is not a user's DB. */ {
|
||||
error(" - mdb_open '%s' failed, error %d %s\n",
|
||||
name ? name : "main", rc, mdb_strerror(rc));
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ int main(int argc, char *argv[])
|
||||
if (!count) {
|
||||
fprintf(stderr, "%s: %s does not contain multiple databases\n", prog, envname);
|
||||
rc = MDB_NOTFOUND;
|
||||
} else if (rc == MDB_NOTFOUND) {
|
||||
} else if (rc == MDB_BAD_DBI) {
|
||||
rc = MDB_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user