Commit b543b4ac authored by Quanah Gibson-Mount's avatar Quanah Gibson-Mount
Browse files

Merge remote branch 'origin/mdb.master' into OPENLDAP_REL_ENG_2_4

parents f4d6b857 48ef27b6
......@@ -1067,10 +1067,10 @@ mdb_dkey(MDB_val *key, char *buf)
/** Display all the keys in the page. */
static void
mdb_page_keys(MDB_page *mp)
mdb_page_list(MDB_page *mp)
{
MDB_node *node;
unsigned int i, nkeys;
unsigned int i, nkeys, nsize;
MDB_val key;
DKBUF;
......@@ -1080,7 +1080,12 @@ mdb_page_keys(MDB_page *mp)
node = NODEPTR(mp, i);
key.mv_size = node->mn_ksize;
key.mv_data = node->mn_data;
fprintf(stderr, "key %d: %s\n", i, DKEY(&key));
nsize = NODESIZE + NODEKSZ(node) + sizeof(indx_t);
if (F_ISSET(node->mn_flags, F_BIGDATA))
nsize += sizeof(pgno_t);
else
nsize += NODEDSZ(node);
fprintf(stderr, "key %d: nsize %d, %s\n", i, nsize, DKEY(&key));
}
}
......@@ -1478,7 +1483,7 @@ mdb_env_sync(MDB_env *env, int force)
int rc = 0;
if (force || !F_ISSET(env->me_flags, MDB_NOSYNC)) {
if (env->me_flags & MDB_WRITEMAP) {
int flags = (env->me_flags & MDB_MAPSYNC) ? MS_SYNC : MS_ASYNC;
int flags = (env->me_flags & MDB_MAPASYNC) ? MS_ASYNC : MS_SYNC;
if (MDB_MSYNC(env->me_map, env->me_mapsize, flags))
rc = ErrCode();
#ifdef _WIN32
......@@ -2383,7 +2388,7 @@ mdb_env_write_meta(MDB_txn *txn)
mp->mm_last_pg = txn->mt_next_pgno - 1;
mp->mm_txnid = txn->mt_txnid;
if (!(env->me_flags & (MDB_NOMETASYNC|MDB_NOSYNC))) {
rc = (env->me_flags & MDB_MAPSYNC) ? MS_SYNC : MS_ASYNC;
rc = (env->me_flags & MDB_MAPASYNC) ? MS_ASYNC : MS_SYNC;
ptr = env->me_map;
if (toggle)
ptr += env->me_psize;
......@@ -5988,7 +5993,7 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
}
nkeys = NUMKEYS(mp);
split_indx = (nkeys + 1) / 2;
split_indx = nkeys / 2;
if (newindx < split_indx)
newpos = 0;
......@@ -6062,8 +6067,11 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
psize += NODEDSZ(node);
psize += psize & 1;
if (psize > pmax) {
if (i == split_indx - 1 && newindx == split_indx)
newpos = 1;
if (i <= newindx) {
split_indx = newindx;
if (i < newindx)
newpos = 1;
}
else
split_indx = i;
break;
......@@ -6080,7 +6088,10 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
psize += NODEDSZ(node);
psize += psize & 1;
if (psize > pmax) {
split_indx = i+1;
if (i >= newindx)
split_indx = newindx;
else
split_indx = i+1;
break;
}
}
......
......@@ -4,12 +4,12 @@
* @mainpage MDB Memory-Mapped Database Manager
* MDB is a Btree-based database management library modeled loosely on the
* BerkeleyDB API, but much simplified. The entire database is exposed
* in a read-only memory map, and all data fetches return data directly
* in a memory map, and all data fetches return data directly
* from the mapped memory, so no malloc's or memcpy's occur during
* data fetches. As such, the library is extremely simple because it
* requires no page caching layer of its own, and it is extremely high
* performance and memory-efficient. It is also fully transactional with
* full ACID semantics, and because the memory map is read-only, the
* full ACID semantics, and when the memory map is read-only, the
* database integrity cannot be corrupted by stray pointer writes from
* application code.
*
......@@ -31,6 +31,13 @@
* the database and re-uses them for new write operations, so the database
* size does not grow without bound in normal use.
*
* The memory map can be used as a read-only or read-write map. It is
* read-only by default as this provides total immunity to corruption.
* Using read-write mode offers much higher write performance, but adds
* the possibility for stray application writes thru pointers to silently
* corrupt the database. Of course if your application code is known to
* be bug-free (...) then this is not an issue.
*
* @author Howard Chu, Symas Corporation.
*
* @copyright Copyright 2011-2012 Howard Chu, Symas Corp. All rights reserved.
......@@ -80,7 +87,7 @@ extern "C" {
/** Library minor version */
#define MDB_VERSION_MINOR 9
/** Library patch version */
#define MDB_VERSION_PATCH 2
#define MDB_VERSION_PATCH 3
/** Combine args a,b,c into a single integer for easy version comparisons */
#define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c))
......@@ -90,7 +97,7 @@ extern "C" {
MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)
/** The release date of this library version */
#define MDB_VERSION_DATE "August 2, 2012"
#define MDB_VERSION_DATE "September 7, 2012"
/** A stringifier for the version info */
#define MDB_VERSTR(a,b,c,d) "MDB " #a "." #b "." #c ": (" d ")"
......@@ -163,8 +170,8 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel
#define MDB_NOMETASYNC 0x40000
/** use writable mmap */
#define MDB_WRITEMAP 0x80000
/** use synchronous msync */
#define MDB_MAPSYNC 0x100000
/** use asynchronous msync */
#define MDB_MAPASYNC 0x100000
/** @} */
/** @defgroup mdb_open Database Flags
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment