Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LMDB 0.9.22 #1

Open
wants to merge 19 commits into
base: lmdb_0_9_21
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions libraries/liblmdb/CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
LMDB 0.9 Change Log

LMDB 0.9.23 Engineering

LMDB 0.9.22 Release (2018/03/22)
Fix MDB_DUPSORT alignment bug (ITS#8819)
Fix regression with new db from 0.9.19 (ITS#8760)
Fix liblmdb to build on Solaris (ITS#8612)
Fix delete behavior with DUPSORT DB (ITS#8622)
Fix mdb_cursor_get/mdb_cursor_del behavior (ITS#8722)

LMDB 0.9.21 Release (2017/06/01)
Fix xcursor after cursor_del (ITS#8622)

Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2011-2017 Howard Chu, Symas Corp.
Copyright 2011-2018 Howard Chu, Symas Corp.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/intro.doc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 Howard Chu, Symas Corp.
* Copyright 2015-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
6 changes: 3 additions & 3 deletions libraries/liblmdb/lmdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
*
* @author Howard Chu, Symas Corporation.
*
* @copyright Copyright 2011-2017 Howard Chu, Symas Corp. All rights reserved.
* @copyright Copyright 2011-2018 Howard Chu, Symas Corp. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
Expand Down Expand Up @@ -200,7 +200,7 @@ typedef int mdb_filehandle_t;
/** Library minor version */
#define MDB_VERSION_MINOR 9
/** Library patch version */
#define MDB_VERSION_PATCH 21
#define MDB_VERSION_PATCH 22

/** Combine args a,b,c into a single integer for easy version comparisons */
#define MDB_VERINT(a,b,c) (((a) << 24) | ((b) << 16) | (c))
Expand All @@ -210,7 +210,7 @@ typedef int mdb_filehandle_t;
MDB_VERINT(MDB_VERSION_MAJOR,MDB_VERSION_MINOR,MDB_VERSION_PATCH)

/** The release date of this library version */
#define MDB_VERSION_DATE "June 1, 2017"
#define MDB_VERSION_DATE "March 21, 2018"

/** A stringifier for the version info */
#define MDB_VERSTR(a,b,c,d) "LMDB " #a "." #b "." #c ": (" d ")"
Expand Down
77 changes: 43 additions & 34 deletions libraries/liblmdb/mdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* BerkeleyDB API, but much simplified.
*/
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* Copyright 2011-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -142,6 +142,10 @@ typedef SSIZE_T ssize_t;
/* Most platforms have posix_memalign, older may only have memalign */
#define HAVE_MEMALIGN 1
#include <malloc.h>
/* On Solaris, we need the POSIX sigwait function */
#if defined (__sun)
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
#endif

#if !(defined(BYTE_ORDER) || defined(__BYTE_ORDER))
Expand Down Expand Up @@ -1251,17 +1255,19 @@ typedef struct MDB_xcursor {
unsigned char mx_dbflag;
} MDB_xcursor;

/** Check if there is an inited xcursor, so #XCURSOR_REFRESH() is proper */
/** Check if there is an inited xcursor */
#define XCURSOR_INITED(mc) \
((mc)->mc_xcursor && ((mc)->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED))

/** Update sub-page pointer, if any, in \b mc->mc_xcursor. Needed
/** Update the xcursor's sub-page pointer, if any, in \b mc. Needed
* when the node which contains the sub-page may have moved. Called
* with \b mp = mc->mc_pg[mc->mc_top], \b ki = mc->mc_ki[mc->mc_top].
* with leaf page \b mp = mc->mc_pg[\b top].
*/
#define XCURSOR_REFRESH(mc, mp, ki) do { \
#define XCURSOR_REFRESH(mc, top, mp) do { \
MDB_page *xr_pg = (mp); \
MDB_node *xr_node = NODEPTR(xr_pg, ki); \
MDB_node *xr_node; \
if (!XCURSOR_INITED(mc) || (mc)->mc_ki[top] >= NUMKEYS(xr_pg)) break; \
xr_node = NODEPTR(xr_pg, (mc)->mc_ki[top]); \
if ((xr_node->mn_flags & (F_DUPDATA|F_SUBDATA)) == F_DUPDATA) \
(mc)->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(xr_node); \
} while (0)
Expand Down Expand Up @@ -2528,8 +2534,8 @@ mdb_page_touch(MDB_cursor *mc)
if (m2 == mc) continue;
if (m2->mc_pg[mc->mc_top] == mp) {
m2->mc_pg[mc->mc_top] = np;
if (XCURSOR_INITED(m2) && IS_LEAF(np))
XCURSOR_REFRESH(m2, np, m2->mc_ki[mc->mc_top]);
if (IS_LEAF(np))
XCURSOR_REFRESH(m2, mc->mc_top, np);
}
}
}
Expand Down Expand Up @@ -5095,7 +5101,7 @@ mdb_env_close0(MDB_env *env, int excl)
if (env->me_fd != INVALID_HANDLE_VALUE)
(void) close(env->me_fd);
if (env->me_txns) {
MDB_PID_T pid = env->me_pid;
MDB_PID_T pid = getpid();
/* Clearing readers is done in this function because
* me_txkey with its destructor must be disabled first.
*
Expand Down Expand Up @@ -6460,6 +6466,11 @@ mdb_cursor_get(MDB_cursor *mc, MDB_val *key, MDB_val *data,
rc = MDB_INCOMPATIBLE;
break;
}
if (mc->mc_ki[mc->mc_top] >= NUMKEYS(mc->mc_pg[mc->mc_top])) {
mc->mc_ki[mc->mc_top] = NUMKEYS(mc->mc_pg[mc->mc_top]);
rc = MDB_NOTFOUND;
break;
}
{
MDB_node *leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
if (!F_ISSET(leaf->mn_flags, F_DUPDATA)) {
Expand Down Expand Up @@ -6826,8 +6837,9 @@ mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data,
} else {
memcpy((char *)mp + mp->mp_upper + PAGEBASE, (char *)fp + fp->mp_upper + PAGEBASE,
olddata.mv_size - fp->mp_upper - PAGEBASE);
memcpy((char *)(&mp->mp_ptrs), (char *)(&fp->mp_ptrs), NUMKEYS(fp) * sizeof(mp->mp_ptrs[0]));
for (i=0; i<NUMKEYS(fp); i++)
mp->mp_ptrs[i] = fp->mp_ptrs[i] + offset;
mp->mp_ptrs[i] += offset;
}
}

Expand Down Expand Up @@ -6956,8 +6968,7 @@ mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data,
if (m3->mc_ki[i] >= mc->mc_ki[i] && insert_key) {
m3->mc_ki[i]++;
}
if (XCURSOR_INITED(m3))
XCURSOR_REFRESH(m3, mp, m3->mc_ki[i]);
XCURSOR_REFRESH(m3, i, mp);
}
}
}
Expand Down Expand Up @@ -6999,16 +7010,15 @@ mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val *data,
MDB_xcursor *mx = mc->mc_xcursor;
unsigned i = mc->mc_top;
MDB_page *mp = mc->mc_pg[i];
int nkeys = NUMKEYS(mp);

for (m2 = mc->mc_txn->mt_cursors[mc->mc_dbi]; m2; m2=m2->mc_next) {
if (m2 == mc || m2->mc_snum < mc->mc_snum) continue;
if (!(m2->mc_flags & C_INITIALIZED)) continue;
if (m2->mc_pg[i] == mp) {
if (m2->mc_ki[i] == mc->mc_ki[i]) {
mdb_xcursor_init2(m2, mx, new_dupdata);
} else if (!insert_key && m2->mc_ki[i] < nkeys) {
XCURSOR_REFRESH(m2, mp, m2->mc_ki[i]);
} else if (!insert_key) {
XCURSOR_REFRESH(m2, i, mp);
}
}
}
Expand Down Expand Up @@ -7113,12 +7123,7 @@ mdb_cursor_del(MDB_cursor *mc, unsigned int flags)
if (m2 == mc || m2->mc_snum < mc->mc_snum) continue;
if (!(m2->mc_flags & C_INITIALIZED)) continue;
if (m2->mc_pg[mc->mc_top] == mp) {
MDB_node *n2 = leaf;
if (m2->mc_ki[mc->mc_top] != mc->mc_ki[mc->mc_top]) {
n2 = NODEPTR(mp, m2->mc_ki[mc->mc_top]);
if (n2->mn_flags & F_SUBDATA) continue;
}
m2->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(n2);
XCURSOR_REFRESH(m2, mc->mc_top, mp);
}
}
}
Expand Down Expand Up @@ -7964,8 +7969,8 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst, int fromleft)
m3->mc_ki[csrc->mc_top] = cdst->mc_ki[cdst->mc_top];
m3->mc_ki[csrc->mc_top-1]++;
}
if (XCURSOR_INITED(m3) && IS_LEAF(mps))
XCURSOR_REFRESH(m3, m3->mc_pg[csrc->mc_top], m3->mc_ki[csrc->mc_top]);
if (IS_LEAF(mps))
XCURSOR_REFRESH(m3, csrc->mc_top, m3->mc_pg[csrc->mc_top]);
}
} else
/* Adding on the right, bump others down */
Expand All @@ -7986,8 +7991,8 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst, int fromleft)
} else {
m3->mc_ki[csrc->mc_top]--;
}
if (XCURSOR_INITED(m3) && IS_LEAF(mps))
XCURSOR_REFRESH(m3, m3->mc_pg[csrc->mc_top], m3->mc_ki[csrc->mc_top]);
if (IS_LEAF(mps))
XCURSOR_REFRESH(m3, csrc->mc_top, m3->mc_pg[csrc->mc_top]);
}
}
}
Expand Down Expand Up @@ -8188,8 +8193,8 @@ mdb_page_merge(MDB_cursor *csrc, MDB_cursor *cdst)
m3->mc_ki[top-1] > csrc->mc_ki[top-1]) {
m3->mc_ki[top-1]--;
}
if (XCURSOR_INITED(m3) && IS_LEAF(psrc))
XCURSOR_REFRESH(m3, m3->mc_pg[top], m3->mc_ki[top]);
if (IS_LEAF(psrc))
XCURSOR_REFRESH(m3, top, m3->mc_pg[top]);
}
}
{
Expand Down Expand Up @@ -8451,8 +8456,7 @@ mdb_cursor_del0(MDB_cursor *mc)
} else if (m3->mc_ki[mc->mc_top] > ki) {
m3->mc_ki[mc->mc_top]--;
}
if (XCURSOR_INITED(m3))
XCURSOR_REFRESH(m3, m3->mc_pg[mc->mc_top], m3->mc_ki[mc->mc_top]);
XCURSOR_REFRESH(m3, mc->mc_top, mp);
}
}
}
Expand Down Expand Up @@ -8499,8 +8503,10 @@ mdb_cursor_del0(MDB_cursor *mc)
if (m3->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED) {
if (!(node->mn_flags & F_SUBDATA))
m3->mc_xcursor->mx_cursor.mc_pg[0] = NODEDATA(node);
} else
} else {
mdb_xcursor_init1(m3, node);
m3->mc_xcursor->mx_cursor.mc_flags |= C_DEL;
}
}
}
}
Expand Down Expand Up @@ -8986,8 +8992,8 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
m3->mc_ki[ptop] >= mc->mc_ki[ptop]) {
m3->mc_ki[ptop]++;
}
if (XCURSOR_INITED(m3) && IS_LEAF(mp))
XCURSOR_REFRESH(m3, m3->mc_pg[mc->mc_top], m3->mc_ki[mc->mc_top]);
if (IS_LEAF(mp))
XCURSOR_REFRESH(m3, mc->mc_top, m3->mc_pg[mc->mc_top]);
}
}
DPRINTF(("mp left: %d, rp left: %d", SIZELEFT(mp), SIZELEFT(rp)));
Expand Down Expand Up @@ -9792,8 +9798,11 @@ int mdb_dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *db
MDB_node *node = NODEPTR(mc.mc_pg[mc.mc_top], mc.mc_ki[mc.mc_top]);
if ((node->mn_flags & (F_DUPDATA|F_SUBDATA)) != F_SUBDATA)
return MDB_INCOMPATIBLE;
} else if (! (rc == MDB_NOTFOUND && (flags & MDB_CREATE))) {
return rc;
} else {
if (rc != MDB_NOTFOUND || !(flags & MDB_CREATE))
return rc;
if (F_ISSET(txn->mt_flags, MDB_TXN_RDONLY))
return EACCES;
}

/* Done here so we cannot fail after creating a new DB */
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mdb_copy.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.TH MDB_COPY 1 "2014/07/01" "LMDB 0.9.14"
.\" Copyright 2012-2017 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2012-2018 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
mdb_copy \- LMDB environment copy tool
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mdb_copy.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mdb_copy.c - memory-mapped database backup tool */
/*
* Copyright 2012-2017 Howard Chu, Symas Corp.
* Copyright 2012-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mdb_dump.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.TH MDB_DUMP 1 "2015/09/30" "LMDB 0.9.17"
.\" Copyright 2014-2017 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2014-2018 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
mdb_dump \- LMDB environment export tool
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mdb_dump.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mdb_dump.c - memory-mapped database dump tool */
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* Copyright 2011-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mdb_load.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.TH MDB_LOAD 1 "2015/09/30" "LMDB 0.9.17"
.\" Copyright 2014-2017 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2014-2018 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
mdb_load \- LMDB environment import tool
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mdb_load.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mdb_load.c - memory-mapped database load tool */
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* Copyright 2011-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mdb_stat.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.TH MDB_STAT 1 "2015/09/30" "LMDB 0.9.17"
.\" Copyright 2012-2017 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copyright 2012-2018 Howard Chu, Symas Corp. All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
.SH NAME
mdb_stat \- LMDB environment status tool
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mdb_stat.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mdb_stat.c - memory-mapped database status tool */
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* Copyright 2011-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
4 changes: 2 additions & 2 deletions libraries/liblmdb/midl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 2000-2016 The OpenLDAP Foundation.
* Portions Copyright 2001-2017 Howard Chu, Symas Corp.
* Copyright 2000-2018 The OpenLDAP Foundation.
* Portions Copyright 2001-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
4 changes: 2 additions & 2 deletions libraries/liblmdb/midl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 2000-2016 The OpenLDAP Foundation.
* Portions Copyright 2001-2017 Howard Chu, Symas Corp.
* Copyright 2000-2018 The OpenLDAP Foundation.
* Portions Copyright 2001-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mtest.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mtest.c - memory-mapped database tester/toy */
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* Copyright 2011-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mtest2.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mtest2.c - memory-mapped database tester/toy */
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* Copyright 2011-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mtest3.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mtest3.c - memory-mapped database tester/toy */
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* Copyright 2011-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mtest4.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mtest4.c - memory-mapped database tester/toy */
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* Copyright 2011-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mtest5.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mtest5.c - memory-mapped database tester/toy */
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* Copyright 2011-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion libraries/liblmdb/mtest6.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* mtest6.c - memory-mapped database tester/toy */
/*
* Copyright 2011-2017 Howard Chu, Symas Corp.
* Copyright 2011-2018 Howard Chu, Symas Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
Loading