From 7aba5f5ab92a3fa92de001edb2c5ff4b04fd7d0d Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Sat, 16 Feb 2013 19:06:28 +0100 Subject: [PATCH] Add error code MDB_MAP_RESIZED. --- libraries/liblmdb/lmdb.h | 8 ++++++-- libraries/liblmdb/mdb.c | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index 7719e32..aaaa292 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -353,7 +353,9 @@ typedef enum MDB_cursor_op { #define MDB_CURSOR_FULL (-30787) /** Page has not enough space - internal error */ #define MDB_PAGE_FULL (-30786) -#define MDB_LAST_ERRCODE MDB_PAGE_FULL + /** Database contents grew beyond environment mapsize */ +#define MDB_MAP_RESIZED (-30785) +#define MDB_LAST_ERRCODE MDB_MAP_RESIZED /** @} */ /** @brief Statistics for a database in the environment */ @@ -675,7 +677,9 @@ int mdb_env_set_maxdbs(MDB_env *env, MDB_dbi dbs); * errors are: * diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 7bfdfc2..40b9bda 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -1054,7 +1054,8 @@ static char *const mdb_errstr[] = { "MDB_TLS_FULL: Thread-local storage keys full - too many environments open", "MDB_TXN_FULL: Transaction has too many dirty pages - transaction too big", "MDB_CURSOR_FULL: Internal error - cursor stack limit reached", - "MDB_PAGE_FULL: Internal error - page has no more space" + "MDB_PAGE_FULL: Internal error - page has no more space", + "MDB_MAP_RESIZED: Database contents grew beyond environment mapsize", }; char * @@ -1818,6 +1819,11 @@ mdb_txn_renew0(MDB_txn *txn) if (txn->mt_numdbs > 2) memset(txn->mt_dbflags+2, DB_STALE, txn->mt_numdbs-2); + if (env->me_maxpg < txn->mt_next_pgno) { + mdb_txn_reset0(txn); + return MDB_MAP_RESIZED; + } + return MDB_SUCCESS; }