mdbx: Merge branch 'devel'.

This commit is contained in:
Leo Yuriev 2016-08-23 15:14:58 +03:00
commit 7e61c52592
24 changed files with 49 additions and 41 deletions

View File

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
--- ---
Copyright 2011-2014 Howard Chu, Symas Corp. Copyright 2011-2016 Howard Chu, Symas Corp.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

View File

@ -1,3 +1,9 @@
Note: This project pending for dual licensing. We assume to resolve
issues related to OpenLDAP Public License and then provide dual
licensing under OpenLDAP and AGPL. Sign the CLA before contributing.
***********************************************************************
GNU AFFERO GENERAL PUBLIC LICENSE GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007 Version 3, 19 November 2007

View File

@ -44,7 +44,7 @@ TESTS := mtest0 mtest1 mtest2 mtest3 mtest4 mtest5 mtest6 wbench \
yota_test1 yota_test2 yota_test1 yota_test2
SRC_LMDB := mdb.c midl.c lmdb.h midl.h reopen.h barriers.h SRC_LMDB := mdb.c midl.c lmdb.h midl.h reopen.h barriers.h
SRC_MDBX := $(SRC_LMDB) mdbx.h SRC_MDBX := $(SRC_LMDB) mdbx.c mdbx.h
.PHONY: mdbx lmdb all install clean check tests coverage .PHONY: mdbx lmdb all install clean check tests coverage

View File

@ -19,7 +19,7 @@
* *
* --- * ---
* *
* Copyright 2015-2014 Howard Chu, Symas Corp. * Copyright 2015 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

4
lmdb.h
View File

@ -120,7 +120,7 @@
* Howard Chu, Symas Corp. All rights reserved. * Howard Chu, Symas Corp. All rights reserved.
* *
* @copyright 2015,2016 Leonid Yuriev <leo@yuriev.ru>. * @copyright 2015,2016 Leonid Yuriev <leo@yuriev.ru>.
* 2011-2014 Howard Chu, Symas Corp. All rights reserved. * 2011-2016 Howard Chu, Symas Corp. All rights reserved.
* *
* --- * ---
* *
@ -146,7 +146,7 @@
* @par Derived From: * @par Derived From:
* This code is derived from LMDB engine written by Howard Chu, Symas Corporation. * This code is derived from LMDB engine written by Howard Chu, Symas Corporation.
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. All rights reserved. * Copyright 2011-2016 Howard Chu, Symas Corp. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP * modification, are permitted only as authorized by the OpenLDAP

33
mdb.c
View File

@ -26,7 +26,7 @@
* *
* --- * ---
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. * Copyright 2011-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -1222,11 +1222,12 @@ mdb_strerror(int err)
static txnid_t mdbx_oomkick(MDB_env *env, txnid_t oldest); static txnid_t mdbx_oomkick(MDB_env *env, txnid_t oldest);
#endif /* MDBX_MODE_ENABLED */ #endif /* MDBX_MODE_ENABLED */
static void mdb_debug_log(int type, const char *function, int line, const char *fmt, ...)
__attribute__((format(gnu_printf, 4, 5)));
#if MDB_DEBUG #if MDB_DEBUG
static txnid_t mdb_debug_edge; static txnid_t mdb_debug_edge;
static void mdb_debug_log(int type, const char *function, int line,
const char *fmt, ...);
static void __cold static void __cold
mdb_assert_fail(MDB_env *env, const char *msg, mdb_assert_fail(MDB_env *env, const char *msg,
const char *func, int line) const char *func, int line)
@ -1263,8 +1264,7 @@ static txnid_t mdbx_oomkick(MDB_env *env, txnid_t oldest);
#endif /* MDB_DEBUG */ #endif /* MDB_DEBUG */
static void __cold static void __cold
mdb_debug_log(int type, const char *function, int line, mdb_debug_log(int type, const char *function, int line, const char *fmt, ...)
const char *fmt, ...)
{ {
va_list args; va_list args;
@ -1272,8 +1272,12 @@ mdb_debug_log(int type, const char *function, int line,
if (mdb_debug_logger) if (mdb_debug_logger)
mdb_debug_logger(type, function, line, fmt, args); mdb_debug_logger(type, function, line, fmt, args);
else { else {
if (function && line) if (function && line > 0)
fprintf(stderr, "%s:%u ", function, line); fprintf(stderr, "%s:%d ", function, line);
else if (function)
fprintf(stderr, "%s: ", function);
else if (line > 0)
fprintf(stderr, "%d: ", line);
vfprintf(stderr, fmt, args); vfprintf(stderr, fmt, args);
} }
va_end(args); va_end(args);
@ -1344,7 +1348,6 @@ char *
mdb_dkey(MDB_val *key, char *buf) mdb_dkey(MDB_val *key, char *buf)
{ {
char *ptr = buf; char *ptr = buf;
unsigned char *c = key->mv_data;
unsigned i; unsigned i;
if (!key) if (!key)
@ -1358,7 +1361,7 @@ mdb_dkey(MDB_val *key, char *buf)
#if 1 #if 1
buf[0] = '\0'; buf[0] = '\0';
for (i=0; i<key->mv_size; i++) for (i=0; i<key->mv_size; i++)
ptr += sprintf(ptr, "%02x", *c++); ptr += sprintf(ptr, "%02x", ((unsigned char*) key->mv_data)[i]);
#else #else
sprintf(buf, "%.*s", key->mv_size, key->mv_data); sprintf(buf, "%.*s", key->mv_size, key->mv_data);
#endif #endif
@ -1405,14 +1408,14 @@ mdb_page_list(MDB_page *mp)
} }
nkeys = NUMKEYS(mp); nkeys = NUMKEYS(mp);
mdb_print("%s %zu numkeys %d%s\n", type, pgno, nkeys, state); mdb_print("%s %zu numkeys %u%s\n", type, pgno, nkeys, state);
for (i=0; i<nkeys; i++) { for (i=0; i<nkeys; i++) {
if (IS_LEAF2(mp)) { /* LEAF2 pages have no mp_ptrs[] or node headers */ if (IS_LEAF2(mp)) { /* LEAF2 pages have no mp_ptrs[] or node headers */
key.mv_size = nsize = mp->mp_leaf2_ksize; key.mv_size = nsize = mp->mp_leaf2_ksize;
key.mv_data = LEAF2KEY(mp, i, nsize); key.mv_data = LEAF2KEY(mp, i, nsize);
total += nsize; total += nsize;
mdb_print("key %d: nsize %d, %s\n", i, nsize, DKEY(&key)); mdb_print("key %u: nsize %u, %s\n", i, nsize, DKEY(&key));
continue; continue;
} }
node = NODEPTR(mp, i); node = NODEPTR(mp, i);
@ -1420,7 +1423,7 @@ mdb_page_list(MDB_page *mp)
key.mv_data = node->mn_data; key.mv_data = node->mn_data;
nsize = NODESIZE + key.mv_size; nsize = NODESIZE + key.mv_size;
if (IS_BRANCH(mp)) { if (IS_BRANCH(mp)) {
mdb_print("key %d: page %zu, %s\n", i, NODEPGNO(node), DKEY(&key)); mdb_print("key %u: page %zu, %s\n", i, NODEPGNO(node), DKEY(&key));
total += nsize; total += nsize;
} else { } else {
if (F_ISSET(node->mn_flags, F_BIGDATA)) if (F_ISSET(node->mn_flags, F_BIGDATA))
@ -1429,12 +1432,12 @@ mdb_page_list(MDB_page *mp)
nsize += NODEDSZ(node); nsize += NODEDSZ(node);
total += nsize; total += nsize;
nsize += sizeof(indx_t); nsize += sizeof(indx_t);
mdb_print("key %d: nsize %d, %s%s\n", mdb_print("key %u: nsize %u, %s%s\n",
i, nsize, DKEY(&key), mdb_leafnode_type(node)); i, nsize, DKEY(&key), mdb_leafnode_type(node));
} }
total = EVEN(total); total = EVEN(total);
} }
mdb_print("Total: header %d + contents %d + unused %d\n", mdb_print("Total: header %u + contents %u + unused %u\n",
IS_LEAF2(mp) ? PAGEHDRSZ : PAGEBASE + mp->mp_lower, total, SIZELEFT(mp)); IS_LEAF2(mp) ? PAGEHDRSZ : PAGEBASE + mp->mp_lower, total, SIZELEFT(mp));
} }
@ -5651,7 +5654,7 @@ mdb_ovpage_free(MDB_cursor *mc, MDB_page *mp)
MDB_ID pn = pg << 1; MDB_ID pn = pg << 1;
int rc; int rc;
mdb_debug("free ov page %zu (%d)", pg, ovpages); mdb_debug("free ov page %zu (%u)", pg, ovpages);
/* If the page is dirty or on the spill list we just acquired it, /* If the page is dirty or on the spill list we just acquired it,
* so we should give it back to our current free list, if any. * so we should give it back to our current free list, if any.
* Otherwise put it onto the list of pages we freed in this txn. * Otherwise put it onto the list of pages we freed in this txn.

View File

@ -18,7 +18,7 @@
.\" .\"
.\" --- .\" ---
.\" .\"
.\" Copyright 2012-2014 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2012-2016 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDB_COPY 1 "2014/06/20" "LMDB 0.9.14" .TH MDB_COPY 1 "2014/06/20" "LMDB 0.9.14"
.SH NAME .SH NAME

View File

@ -21,7 +21,7 @@
* *
* --- * ---
* *
* Copyright 2012-2014 Howard Chu, Symas Corp. * Copyright 2012-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -18,7 +18,7 @@
.\" .\"
.\" --- .\" ---
.\" .\"
.\" Copyright 2014 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2014-2016 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDB_DUMP 1 "2014/06/20" "LMDB 0.9.14" .TH MDB_DUMP 1 "2014/06/20" "LMDB 0.9.14"
.SH NAME .SH NAME

View File

@ -21,7 +21,7 @@
* *
* --- * ---
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. * Copyright 2011-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -147,7 +147,7 @@ static int dumpit(MDB_txn *txn, MDB_dbi dbi, char *name)
rc = mdb_cursor_open(txn, dbi, &mc); rc = mdb_cursor_open(txn, dbi, &mc);
if (rc) return rc; if (rc) return rc;
while ((rc = mdb_cursor_get(mc, &key, &data, MDB_NEXT) == MDB_SUCCESS)) { while ((rc = mdb_cursor_get(mc, &key, &data, MDB_NEXT)) == MDB_SUCCESS) {
if (gotsig) { if (gotsig) {
rc = EINTR; rc = EINTR;
break; break;

View File

@ -21,7 +21,7 @@
* *
* --- * ---
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. * Copyright 2011-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -18,7 +18,7 @@
.\" .\"
.\" --- .\" ---
.\" .\"
.\" Copyright 2012-2014 Howard Chu, Symas Corp. All Rights Reserved. .\" Copyright 2012-2016 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE. .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.TH MDB_STAT 1 "2014/06/20" "LMDB 0.9.14" .TH MDB_STAT 1 "2014/06/20" "LMDB 0.9.14"
.SH NAME .SH NAME

View File

@ -21,7 +21,7 @@
* *
* --- * ---
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. * Copyright 2011-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

5
mdbx.c
View File

@ -49,12 +49,11 @@ mdbx_setup_debug(int flags, MDBX_debug_func* logger, long edge_txn) {
mdb_runtime_flags = flags; mdb_runtime_flags = flags;
if (logger != (MDBX_debug_func*) MDBX_DBG_DNT) if (logger != (MDBX_debug_func*) MDBX_DBG_DNT)
mdb_debug_logger = logger; mdb_debug_logger = logger;
if (edge_txn != (long) MDBX_DBG_DNT) {
#if MDB_DEBUG #if MDB_DEBUG
if (edge_txn != (long) MDBX_DBG_DNT)
mdb_debug_edge = edge_txn; mdb_debug_edge = edge_txn;
#else
(void) edge_txn;
#endif #endif
}
return ret; return ret;
} }

2
midl.c
View File

@ -22,7 +22,7 @@
* *
* --- * ---
* *
* Copyright 2000-2014 The OpenLDAP Foundation. * Copyright 2000-2016 The OpenLDAP Foundation.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

2
midl.h
View File

@ -30,7 +30,7 @@
* *
* --- * ---
* *
* Copyright 2000-2014 The OpenLDAP Foundation. * Copyright 2000-2016 The OpenLDAP Foundation.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. * Copyright 2011-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -21,7 +21,7 @@
* *
* --- * ---
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. * Copyright 2011-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -21,7 +21,7 @@
* *
* --- * ---
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. * Copyright 2011-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -21,7 +21,7 @@
* *
* --- * ---
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. * Copyright 2011-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -21,7 +21,7 @@
* *
* --- * ---
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. * Copyright 2011-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -21,7 +21,7 @@
* *
* --- * ---
* *
* Copyright 2011-2014 Howard Chu, Symas Corp. * Copyright 2011-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -24,7 +24,7 @@
* *
* --- * ---
* *
* Copyright 2012-2014 Howard Chu, Symas Corp. * Copyright 2012-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -24,7 +24,7 @@
* *
* --- * ---
* *
* Copyright 2012-2014 Howard Chu, Symas Corp. * Copyright 2012-2016 Howard Chu, Symas Corp.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without