lmdb: fix mdb_chk for case MainDB's records isn't a sub-db.

Change-Id: I3a4ae1f50972fde6edab828b58199dde9b84550c
This commit is contained in:
Leo Yuriev 2015-05-08 23:57:01 +03:00
parent f2703156f0
commit bd05dd24ab
3 changed files with 4 additions and 4 deletions

2
mdb.c
View File

@ -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);

View File

@ -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));
}

View File

@ -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 {