mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 00:07:38 +00:00
Resync to upstream mdb.master
This commit is contained in:
parent
6bc0c7e685
commit
efec3ed235
27 changed files with 1081 additions and 843 deletions
1
external/db_drivers/liblmdb/.gitignore
vendored
1
external/db_drivers/liblmdb/.gitignore
vendored
|
@ -5,6 +5,7 @@ mdb_copy
|
|||
mdb_stat
|
||||
mdb_dump
|
||||
mdb_load
|
||||
mdb_drop
|
||||
*.lo
|
||||
*.[ao]
|
||||
*.so
|
||||
|
|
2
external/db_drivers/liblmdb/COPYRIGHT
vendored
2
external/db_drivers/liblmdb/COPYRIGHT
vendored
|
@ -1,4 +1,4 @@
|
|||
Copyright 2011-2015 Howard Chu, Symas Corp.
|
||||
Copyright 2011-2019 Howard Chu, Symas Corp.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
2
external/db_drivers/liblmdb/Doxyfile
vendored
2
external/db_drivers/liblmdb/Doxyfile
vendored
|
@ -253,7 +253,7 @@ IDL_PROPERTY_SUPPORT = YES
|
|||
# member in the group (if any) for the other members of the group. By default
|
||||
# all members of a group must be documented explicitly.
|
||||
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
DISTRIBUTE_GROUP_DOC = YES
|
||||
|
||||
# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
|
||||
# the same type (for instance a group of public functions) to be put as a
|
||||
|
|
5
external/db_drivers/liblmdb/Makefile
vendored
5
external/db_drivers/liblmdb/Makefile
vendored
|
@ -26,6 +26,7 @@ OPT = -O2 -g
|
|||
CFLAGS = $(THREADS) $(OPT) $(W) $(XCFLAGS)
|
||||
LDLIBS =
|
||||
SOLIBS =
|
||||
SOEXT = .so
|
||||
prefix = /usr/local
|
||||
exec_prefix = $(prefix)
|
||||
bindir = $(exec_prefix)/bin
|
||||
|
@ -37,7 +38,7 @@ mandir = $(datarootdir)/man
|
|||
########################################################################
|
||||
|
||||
IHDRS = lmdb.h
|
||||
ILIBS = liblmdb.a liblmdb.so
|
||||
ILIBS = liblmdb.a liblmdb$(SOEXT)
|
||||
IPROGS = mdb_stat mdb_copy mdb_dump mdb_load mdb_drop
|
||||
IDOCS = mdb_stat.1 mdb_copy.1 mdb_dump.1 mdb_load.1 mdb_drop.1
|
||||
PROGS = $(IPROGS) mtest mtest2 mtest3 mtest4 mtest5
|
||||
|
@ -63,7 +64,7 @@ test: all
|
|||
liblmdb.a: mdb.o midl.o
|
||||
$(AR) rs $@ mdb.o midl.o
|
||||
|
||||
liblmdb.so: mdb.lo midl.lo
|
||||
liblmdb$(SOEXT): mdb.lo midl.lo
|
||||
# $(CC) $(LDFLAGS) -pthread -shared -Wl,-Bsymbolic -o $@ mdb.o midl.o $(SOLIBS)
|
||||
$(CC) $(LDFLAGS) -pthread -shared -o $@ mdb.lo midl.lo $(SOLIBS)
|
||||
|
||||
|
|
2
external/db_drivers/liblmdb/intro.doc
vendored
2
external/db_drivers/liblmdb/intro.doc
vendored
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2015 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
|
||||
|
|
63
external/db_drivers/liblmdb/lmdb.h
vendored
63
external/db_drivers/liblmdb/lmdb.h
vendored
|
@ -97,11 +97,12 @@
|
|||
* transactions. Each transaction belongs to one thread. See below.
|
||||
* The #MDB_NOTLS flag changes this for read-only transactions.
|
||||
*
|
||||
* - Use an MDB_env* in the process which opened it, without fork()ing.
|
||||
* - Use an MDB_env* in the process which opened it, not after fork().
|
||||
*
|
||||
* - Do not have open an LMDB database twice in the same process at
|
||||
* the same time. Not even from a plain open() call - close()ing it
|
||||
* breaks flock() advisory locking.
|
||||
* breaks fcntl() advisory locking. (It is OK to reopen it after
|
||||
* fork() - exec*(), since the lockfile has FD_CLOEXEC set.)
|
||||
*
|
||||
* - Avoid long-lived transactions. Read transactions prevent
|
||||
* reuse of pages freed by newer write transactions, thus the
|
||||
|
@ -135,7 +136,7 @@
|
|||
*
|
||||
* @author Howard Chu, Symas Corporation.
|
||||
*
|
||||
* @copyright Copyright 2011-2016 Howard Chu, Symas Corp. All rights reserved.
|
||||
* @copyright Copyright 2011-2019 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
|
||||
|
@ -167,6 +168,7 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -179,11 +181,30 @@ typedef int mdb_mode_t;
|
|||
typedef mode_t mdb_mode_t;
|
||||
#endif
|
||||
|
||||
#ifdef MDB_VL32
|
||||
typedef uint64_t mdb_size_t;
|
||||
#define mdb_env_create mdb_env_create_vl32 /**< Prevent mixing with non-VL32 builds */
|
||||
#ifdef _WIN32
|
||||
# define MDB_FMT_Z "I"
|
||||
#else
|
||||
# define MDB_FMT_Z "z" /**< printf/scanf format modifier for size_t */
|
||||
#endif
|
||||
|
||||
#ifndef MDB_VL32
|
||||
/** Unsigned type used for mapsize, entry counts and page/transaction IDs.
|
||||
*
|
||||
* It is normally size_t, hence the name. Defining MDB_VL32 makes it
|
||||
* uint64_t, but do not try this unless you know what you are doing.
|
||||
*/
|
||||
typedef size_t mdb_size_t;
|
||||
# define MDB_SIZE_MAX SIZE_MAX /**< max #mdb_size_t */
|
||||
/** #mdb_size_t printf formats, \b t = one of [diouxX] without quotes */
|
||||
# define MDB_PRIy(t) MDB_FMT_Z #t
|
||||
/** #mdb_size_t scanf formats, \b t = one of [dioux] without quotes */
|
||||
# define MDB_SCNy(t) MDB_FMT_Z #t
|
||||
#else
|
||||
typedef uint64_t mdb_size_t;
|
||||
# define MDB_SIZE_MAX UINT64_MAX
|
||||
# define MDB_PRIy(t) PRI##t##64
|
||||
# define MDB_SCNy(t) SCN##t##64
|
||||
# define mdb_env_create mdb_env_create_vl32 /**< Prevent mixing with non-VL32 builds */
|
||||
#endif
|
||||
|
||||
/** An abstraction for a file handle.
|
||||
|
@ -322,7 +343,8 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel
|
|||
#define MDB_REVERSEKEY 0x02
|
||||
/** use sorted duplicates */
|
||||
#define MDB_DUPSORT 0x04
|
||||
/** numeric keys in native byte order: either unsigned int or size_t.
|
||||
/** numeric keys in native byte order, either unsigned int or #mdb_size_t.
|
||||
* (lmdb expects 32-bit int <= size_t <= 32/64-bit mdb_size_t.)
|
||||
* The keys must all be of the same size. */
|
||||
#define MDB_INTEGERKEY 0x08
|
||||
/** with #MDB_DUPSORT, sorted dup items have fixed size */
|
||||
|
@ -380,7 +402,7 @@ typedef enum MDB_cursor_op {
|
|||
MDB_GET_BOTH, /**< Position at key/data pair. Only for #MDB_DUPSORT */
|
||||
MDB_GET_BOTH_RANGE, /**< position at key, nearest data. Only for #MDB_DUPSORT */
|
||||
MDB_GET_CURRENT, /**< Return key/data at current cursor position */
|
||||
MDB_GET_MULTIPLE, /**< Return key and up to a page of duplicate data items
|
||||
MDB_GET_MULTIPLE, /**< Return up to a page of duplicate data items
|
||||
from current cursor position. Move cursor to prepare
|
||||
for #MDB_NEXT_MULTIPLE. Only for #MDB_DUPFIXED */
|
||||
MDB_LAST, /**< Position at last key/data item */
|
||||
|
@ -389,7 +411,7 @@ typedef enum MDB_cursor_op {
|
|||
MDB_NEXT, /**< Position at next data item */
|
||||
MDB_NEXT_DUP, /**< Position at next data item of current key.
|
||||
Only for #MDB_DUPSORT */
|
||||
MDB_NEXT_MULTIPLE, /**< Return key and up to a page of duplicate data items
|
||||
MDB_NEXT_MULTIPLE, /**< Return up to a page of duplicate data items
|
||||
from next cursor position. Move cursor to prepare
|
||||
for #MDB_NEXT_MULTIPLE. Only for #MDB_DUPFIXED */
|
||||
MDB_NEXT_NODUP, /**< Position at first data item of next key */
|
||||
|
@ -400,7 +422,7 @@ typedef enum MDB_cursor_op {
|
|||
MDB_SET, /**< Position at specified key */
|
||||
MDB_SET_KEY, /**< Position at specified key, return key + data */
|
||||
MDB_SET_RANGE, /**< Position at first key greater than or equal to specified key. */
|
||||
MDB_PREV_MULTIPLE /**< Position at previous page and return key and up to
|
||||
MDB_PREV_MULTIPLE /**< Position at previous page and return up to
|
||||
a page of duplicate data items. Only for #MDB_DUPFIXED */
|
||||
} MDB_cursor_op;
|
||||
|
||||
|
@ -458,8 +480,10 @@ typedef enum MDB_cursor_op {
|
|||
#define MDB_BAD_VALSIZE (-30781)
|
||||
/** The specified DBI was changed unexpectedly */
|
||||
#define MDB_BAD_DBI (-30780)
|
||||
/** Unexpected problem - txn should abort */
|
||||
#define MDB_PROBLEM (-30779)
|
||||
/** The last defined error code */
|
||||
#define MDB_LAST_ERRCODE MDB_BAD_DBI
|
||||
#define MDB_LAST_ERRCODE MDB_PROBLEM
|
||||
/** @} */
|
||||
|
||||
/** @brief Statistics for a database in the environment */
|
||||
|
@ -696,6 +720,7 @@ int mdb_env_copyfd(MDB_env *env, mdb_filehandle_t fd);
|
|||
* <li>#MDB_CP_COMPACT - Perform compaction while copying: omit free
|
||||
* pages and sequentially renumber all pages in output. This option
|
||||
* consumes more CPU and runs more slowly than the default.
|
||||
* Currently it fails if the environment has suffered a page leak.
|
||||
* </ul>
|
||||
* @return A non-zero error value on failure and 0 on success.
|
||||
*/
|
||||
|
@ -810,6 +835,10 @@ int mdb_env_get_flags(MDB_env *env, unsigned int *flags);
|
|||
int mdb_env_get_path(MDB_env *env, const char **path);
|
||||
|
||||
/** @brief Return the filedescriptor for the given environment.
|
||||
*
|
||||
* This function may be called after fork(), so the descriptor can be
|
||||
* closed before exec*(). Other LMDB file descriptors have FD_CLOEXEC.
|
||||
* (Until LMDB 0.9.18, only the lockfile had that.)
|
||||
*
|
||||
* @param[in] env An environment handle returned by #mdb_env_create()
|
||||
* @param[out] fd Address of a mdb_filehandle_t to contain the descriptor.
|
||||
|
@ -1112,14 +1141,16 @@ int mdb_txn_renew(MDB_txn *txn);
|
|||
* keys must be unique and may have only a single data item.
|
||||
* <li>#MDB_INTEGERKEY
|
||||
* Keys are binary integers in native byte order, either unsigned int
|
||||
* or size_t, and will be sorted as such.
|
||||
* or #mdb_size_t, and will be sorted as such.
|
||||
* (lmdb expects 32-bit int <= size_t <= 32/64-bit mdb_size_t.)
|
||||
* The keys must all be of the same size.
|
||||
* <li>#MDB_DUPFIXED
|
||||
* This flag may only be used in combination with #MDB_DUPSORT. This option
|
||||
* tells the library that the data items for this database are all the same
|
||||
* size, which allows further optimizations in storage and retrieval. When
|
||||
* all data items are the same size, the #MDB_GET_MULTIPLE and #MDB_NEXT_MULTIPLE
|
||||
* cursor operations may be used to retrieve multiple items at once.
|
||||
* all data items are the same size, the #MDB_GET_MULTIPLE, #MDB_NEXT_MULTIPLE
|
||||
* and #MDB_PREV_MULTIPLE cursor operations may be used to retrieve multiple
|
||||
* items at once.
|
||||
* <li>#MDB_INTEGERDUP
|
||||
* This option specifies that duplicate data items are binary integers,
|
||||
* similar to #MDB_INTEGERKEY keys.
|
||||
|
@ -1524,6 +1555,10 @@ int mdb_cursor_put(MDB_cursor *cursor, MDB_val *key, MDB_val *data,
|
|||
/** @brief Delete current key/data pair
|
||||
*
|
||||
* This function deletes the key/data pair to which the cursor refers.
|
||||
* This does not invalidate the cursor, so operations such as MDB_NEXT
|
||||
* can still be used on it.
|
||||
* Both MDB_NEXT and MDB_GET_CURRENT will return the same record after
|
||||
* this operation.
|
||||
* @param[in] cursor A cursor handle returned by #mdb_cursor_open()
|
||||
* @param[in] flags Options for this operation. This parameter
|
||||
* must be set to 0 or one of the values described here.
|
||||
|
|
1679
external/db_drivers/liblmdb/mdb.c
vendored
1679
external/db_drivers/liblmdb/mdb.c
vendored
File diff suppressed because it is too large
Load diff
5
external/db_drivers/liblmdb/mdb_copy.1
vendored
5
external/db_drivers/liblmdb/mdb_copy.1
vendored
|
@ -1,5 +1,5 @@
|
|||
.TH MDB_COPY 1 "2014/06/20" "LMDB 0.9.14"
|
||||
.\" Copyright 2012-2015 Howard Chu, Symas Corp. All Rights Reserved.
|
||||
.TH MDB_COPY 1 "2017/07/31" "LMDB 0.9.70"
|
||||
.\" Copyright 2012-2019 Howard Chu, Symas Corp. All Rights Reserved.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.SH NAME
|
||||
mdb_copy \- LMDB environment copy tool
|
||||
|
@ -38,6 +38,7 @@ Write the library version number to the standard output, and exit.
|
|||
Compact while copying. Only current data pages will be copied; freed
|
||||
or unused pages will be omitted from the copy. This option will
|
||||
slow down the backup process as it is more CPU-intensive.
|
||||
Currently it fails if the environment has suffered a page leak.
|
||||
.TP
|
||||
.BR \-n
|
||||
Open LDMB environment(s) which do not use subdirectories.
|
||||
|
|
2
external/db_drivers/liblmdb/mdb_copy.c
vendored
2
external/db_drivers/liblmdb/mdb_copy.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mdb_copy.c - memory-mapped database backup tool */
|
||||
/*
|
||||
* Copyright 2012-2015 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
|
||||
|
|
2
external/db_drivers/liblmdb/mdb_drop.1
vendored
2
external/db_drivers/liblmdb/mdb_drop.1
vendored
|
@ -1,5 +1,5 @@
|
|||
.TH MDB_DROP 1 "2017/11/19" "LMDB 0.9.70"
|
||||
.\" 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_drop \- LMDB database delete tool
|
||||
|
|
2
external/db_drivers/liblmdb/mdb_drop.c
vendored
2
external/db_drivers/liblmdb/mdb_drop.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mdb_drop.c - memory-mapped database delete tool */
|
||||
/*
|
||||
* Copyright 2016-2017 Howard Chu, Symas Corp.
|
||||
* Copyright 2016-2018 Howard Chu, Symas Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
4
external/db_drivers/liblmdb/mdb_dump.1
vendored
4
external/db_drivers/liblmdb/mdb_dump.1
vendored
|
@ -1,5 +1,5 @@
|
|||
.TH MDB_DUMP 1 "2014/06/20" "LMDB 0.9.14"
|
||||
.\" Copyright 2014-2015 Howard Chu, Symas Corp. All Rights Reserved.
|
||||
.TH MDB_DUMP 1 "2017/07/31" "LMDB 0.9.70"
|
||||
.\" Copyright 2014-2017 Howard Chu, Symas Corp. All Rights Reserved.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.SH NAME
|
||||
mdb_dump \- LMDB environment export tool
|
||||
|
|
19
external/db_drivers/liblmdb/mdb_dump.c
vendored
19
external/db_drivers/liblmdb/mdb_dump.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mdb_dump.c - memory-mapped database dump tool */
|
||||
/*
|
||||
* Copyright 2011-2015 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
|
||||
|
@ -20,20 +20,7 @@
|
|||
#include <signal.h>
|
||||
#include "lmdb.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define Z "I"
|
||||
#else
|
||||
#define Z "z"
|
||||
#endif
|
||||
#ifdef MDB_VL32
|
||||
#ifdef _WIN32
|
||||
#define Y "I64"
|
||||
#else
|
||||
#define Y "ll"
|
||||
#endif
|
||||
#else
|
||||
#define Y Z
|
||||
#endif
|
||||
#define Yu MDB_PRIy(u)
|
||||
|
||||
#define PRINT 1
|
||||
static int mode;
|
||||
|
@ -124,7 +111,7 @@ static int dumpit(MDB_txn *txn, MDB_dbi dbi, char *name)
|
|||
if (name)
|
||||
printf("database=%s\n", name);
|
||||
printf("type=btree\n");
|
||||
printf("mapsize=%" Y "u\n", info.me_mapsize);
|
||||
printf("mapsize=%"Yu"\n", info.me_mapsize);
|
||||
if (info.me_mapaddr)
|
||||
printf("mapaddr=%p\n", info.me_mapaddr);
|
||||
printf("maxreaders=%u\n", info.me_maxreaders);
|
||||
|
|
4
external/db_drivers/liblmdb/mdb_load.1
vendored
4
external/db_drivers/liblmdb/mdb_load.1
vendored
|
@ -1,5 +1,5 @@
|
|||
.TH MDB_LOAD 1 "2014/06/20" "LMDB 0.9.14"
|
||||
.\" Copyright 2014-2015 Howard Chu, Symas Corp. All Rights Reserved.
|
||||
.TH MDB_LOAD 1 "2015/09/30" "LMDB 0.9.17"
|
||||
.\" Copyright 2014-2018 Howard Chu, Symas Corp. All Rights Reserved.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.SH NAME
|
||||
mdb_load \- LMDB environment import tool
|
||||
|
|
51
external/db_drivers/liblmdb/mdb_load.c
vendored
51
external/db_drivers/liblmdb/mdb_load.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mdb_load.c - memory-mapped database load tool */
|
||||
/*
|
||||
* Copyright 2011-2015 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
|
||||
|
@ -25,7 +25,7 @@ static int mode;
|
|||
|
||||
static char *subname = NULL;
|
||||
|
||||
static size_t lineno;
|
||||
static mdb_size_t lineno;
|
||||
static int version;
|
||||
|
||||
static int flags;
|
||||
|
@ -39,20 +39,7 @@ static MDB_envinfo info;
|
|||
static MDB_val kbuf, dbuf;
|
||||
static MDB_val k0buf;
|
||||
|
||||
#ifdef _WIN32
|
||||
#define Z "I"
|
||||
#else
|
||||
#define Z "z"
|
||||
#endif
|
||||
#ifdef MDB_VL32
|
||||
#ifdef _WIN32
|
||||
#define Y "I64"
|
||||
#else
|
||||
#define Y "ll"
|
||||
#endif
|
||||
#else
|
||||
#define Y Z
|
||||
#endif
|
||||
#define Yu MDB_PRIy(u)
|
||||
|
||||
#define STRLENOF(s) (sizeof(s)-1)
|
||||
|
||||
|
@ -84,7 +71,7 @@ static void readhdr(void)
|
|||
if (!strncmp(dbuf.mv_data, "VERSION=", STRLENOF("VERSION="))) {
|
||||
version=atoi((char *)dbuf.mv_data+STRLENOF("VERSION="));
|
||||
if (version > 3) {
|
||||
fprintf(stderr, "%s: line %" Z "d: unsupported VERSION %d\n",
|
||||
fprintf(stderr, "%s: line %"Yu": unsupported VERSION %d\n",
|
||||
prog, lineno, version);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -94,7 +81,7 @@ static void readhdr(void)
|
|||
if (!strncmp((char *)dbuf.mv_data+STRLENOF("FORMAT="), "print", STRLENOF("print")))
|
||||
mode |= PRINT;
|
||||
else if (strncmp((char *)dbuf.mv_data+STRLENOF("FORMAT="), "bytevalue", STRLENOF("bytevalue"))) {
|
||||
fprintf(stderr, "%s: line %" Z "d: unsupported FORMAT %s\n",
|
||||
fprintf(stderr, "%s: line %"Yu": unsupported FORMAT %s\n",
|
||||
prog, lineno, (char *)dbuf.mv_data+STRLENOF("FORMAT="));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -105,7 +92,7 @@ static void readhdr(void)
|
|||
subname = strdup((char *)dbuf.mv_data+STRLENOF("database="));
|
||||
} else if (!strncmp(dbuf.mv_data, "type=", STRLENOF("type="))) {
|
||||
if (strncmp((char *)dbuf.mv_data+STRLENOF("type="), "btree", STRLENOF("btree"))) {
|
||||
fprintf(stderr, "%s: line %" Z "d: unsupported type %s\n",
|
||||
fprintf(stderr, "%s: line %"Yu": unsupported type %s\n",
|
||||
prog, lineno, (char *)dbuf.mv_data+STRLENOF("type="));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -115,7 +102,7 @@ static void readhdr(void)
|
|||
if (ptr) *ptr = '\0';
|
||||
i = sscanf((char *)dbuf.mv_data+STRLENOF("mapaddr="), "%p", &info.me_mapaddr);
|
||||
if (i != 1) {
|
||||
fprintf(stderr, "%s: line %" Z "d: invalid mapaddr %s\n",
|
||||
fprintf(stderr, "%s: line %"Yu": invalid mapaddr %s\n",
|
||||
prog, lineno, (char *)dbuf.mv_data+STRLENOF("mapaddr="));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -123,9 +110,10 @@ static void readhdr(void)
|
|||
int i;
|
||||
ptr = memchr(dbuf.mv_data, '\n', dbuf.mv_size);
|
||||
if (ptr) *ptr = '\0';
|
||||
i = sscanf((char *)dbuf.mv_data+STRLENOF("mapsize="), "%" Y "u", &info.me_mapsize);
|
||||
i = sscanf((char *)dbuf.mv_data+STRLENOF("mapsize="),
|
||||
"%" MDB_SCNy(u), &info.me_mapsize);
|
||||
if (i != 1) {
|
||||
fprintf(stderr, "%s: line %" Z "d: invalid mapsize %s\n",
|
||||
fprintf(stderr, "%s: line %"Yu": invalid mapsize %s\n",
|
||||
prog, lineno, (char *)dbuf.mv_data+STRLENOF("mapsize="));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -135,7 +123,7 @@ static void readhdr(void)
|
|||
if (ptr) *ptr = '\0';
|
||||
i = sscanf((char *)dbuf.mv_data+STRLENOF("maxreaders="), "%u", &info.me_maxreaders);
|
||||
if (i != 1) {
|
||||
fprintf(stderr, "%s: line %" Z "d: invalid maxreaders %s\n",
|
||||
fprintf(stderr, "%s: line %"Yu": invalid maxreaders %s\n",
|
||||
prog, lineno, (char *)dbuf.mv_data+STRLENOF("maxreaders="));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -151,12 +139,12 @@ static void readhdr(void)
|
|||
if (!dbflags[i].bit) {
|
||||
ptr = memchr(dbuf.mv_data, '=', dbuf.mv_size);
|
||||
if (!ptr) {
|
||||
fprintf(stderr, "%s: line %" Z "d: unexpected format\n",
|
||||
fprintf(stderr, "%s: line %"Yu": unexpected format\n",
|
||||
prog, lineno);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
*ptr = '\0';
|
||||
fprintf(stderr, "%s: line %" Z "d: unrecognized keyword ignored: %s\n",
|
||||
fprintf(stderr, "%s: line %"Yu": unrecognized keyword ignored: %s\n",
|
||||
prog, lineno, (char *)dbuf.mv_data);
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +154,7 @@ static void readhdr(void)
|
|||
|
||||
static void badend(void)
|
||||
{
|
||||
fprintf(stderr, "%s: line %" Z "d: unexpected end of input\n",
|
||||
fprintf(stderr, "%s: line %"Yu": unexpected end of input\n",
|
||||
prog, lineno);
|
||||
}
|
||||
|
||||
|
@ -224,7 +212,7 @@ badend:
|
|||
buf->mv_data = realloc(buf->mv_data, buf->mv_size*2);
|
||||
if (!buf->mv_data) {
|
||||
Eof = 1;
|
||||
fprintf(stderr, "%s: line %" Z "d: out of memory, line too long\n",
|
||||
fprintf(stderr, "%s: line %"Yu": out of memory, line too long\n",
|
||||
prog, lineno);
|
||||
return EOF;
|
||||
}
|
||||
|
@ -259,7 +247,8 @@ badend:
|
|||
c2 += 2;
|
||||
}
|
||||
} else {
|
||||
c1++; c2++;
|
||||
/* copies are redundant when no escapes were used */
|
||||
*c1++ = *c2++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -435,7 +424,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
rc = readline(&data, &dbuf);
|
||||
if (rc) {
|
||||
fprintf(stderr, "%s: line %" Z "d: failed to read key value\n", prog, lineno);
|
||||
fprintf(stderr, "%s: line %"Yu": failed to read key value\n", prog, lineno);
|
||||
goto txn_abort;
|
||||
}
|
||||
|
||||
|
@ -463,7 +452,7 @@ int main(int argc, char *argv[])
|
|||
if (batch == 100) {
|
||||
rc = mdb_txn_commit(txn);
|
||||
if (rc) {
|
||||
fprintf(stderr, "%s: line %" Z "d: txn_commit: %s\n",
|
||||
fprintf(stderr, "%s: line %"Yu": txn_commit: %s\n",
|
||||
prog, lineno, mdb_strerror(rc));
|
||||
goto env_close;
|
||||
}
|
||||
|
@ -487,7 +476,7 @@ int main(int argc, char *argv[])
|
|||
rc = mdb_txn_commit(txn);
|
||||
txn = NULL;
|
||||
if (rc) {
|
||||
fprintf(stderr, "%s: line %" Z "d: txn_commit: %s\n",
|
||||
fprintf(stderr, "%s: line %"Yu": txn_commit: %s\n",
|
||||
prog, lineno, mdb_strerror(rc));
|
||||
goto env_close;
|
||||
}
|
||||
|
|
4
external/db_drivers/liblmdb/mdb_stat.1
vendored
4
external/db_drivers/liblmdb/mdb_stat.1
vendored
|
@ -1,5 +1,5 @@
|
|||
.TH MDB_STAT 1 "2014/06/20" "LMDB 0.9.14"
|
||||
.\" Copyright 2012-2015 Howard Chu, Symas Corp. All Rights Reserved.
|
||||
.TH MDB_STAT 1 "2017/07/31" "LMDB 0.9.70"
|
||||
.\" Copyright 2012-2019 Howard Chu, Symas Corp. All Rights Reserved.
|
||||
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
|
||||
.SH NAME
|
||||
mdb_stat \- LMDB environment status tool
|
||||
|
|
46
external/db_drivers/liblmdb/mdb_stat.c
vendored
46
external/db_drivers/liblmdb/mdb_stat.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mdb_stat.c - memory-mapped database status tool */
|
||||
/*
|
||||
* Copyright 2011-2015 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
|
||||
|
@ -17,20 +17,8 @@
|
|||
#include <unistd.h>
|
||||
#include "lmdb.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define Z "I"
|
||||
#else
|
||||
#define Z "z"
|
||||
#endif
|
||||
#ifdef MDB_VL32
|
||||
#ifdef _WIN32
|
||||
#define Y "I64"
|
||||
#else
|
||||
#define Y "ll"
|
||||
#endif
|
||||
#else
|
||||
#define Y Z
|
||||
#endif
|
||||
#define Z MDB_FMT_Z
|
||||
#define Yu MDB_PRIy(u)
|
||||
|
||||
static void prstat(MDB_stat *ms)
|
||||
{
|
||||
|
@ -38,10 +26,10 @@ static void prstat(MDB_stat *ms)
|
|||
printf(" Page size: %u\n", ms->ms_psize);
|
||||
#endif
|
||||
printf(" Tree depth: %u\n", ms->ms_depth);
|
||||
printf(" Branch pages: %"Y"u\n", ms->ms_branch_pages);
|
||||
printf(" Leaf pages: %"Y"u\n", ms->ms_leaf_pages);
|
||||
printf(" Overflow pages: %"Y"u\n", ms->ms_overflow_pages);
|
||||
printf(" Entries: %"Y"u\n", ms->ms_entries);
|
||||
printf(" Branch pages: %"Yu"\n", ms->ms_branch_pages);
|
||||
printf(" Leaf pages: %"Yu"\n", ms->ms_leaf_pages);
|
||||
printf(" Overflow pages: %"Yu"\n", ms->ms_overflow_pages);
|
||||
printf(" Entries: %"Yu"\n", ms->ms_entries);
|
||||
}
|
||||
|
||||
static void usage(char *prog)
|
||||
|
@ -138,11 +126,11 @@ int main(int argc, char *argv[])
|
|||
(void)mdb_env_info(env, &mei);
|
||||
printf("Environment Info\n");
|
||||
printf(" Map address: %p\n", mei.me_mapaddr);
|
||||
printf(" Map size: %"Y"u\n", mei.me_mapsize);
|
||||
printf(" Map size: %"Yu"\n", mei.me_mapsize);
|
||||
printf(" Page size: %u\n", mst.ms_psize);
|
||||
printf(" Max pages: %"Y"u\n", mei.me_mapsize / mst.ms_psize);
|
||||
printf(" Number of pages used: %"Y"u\n", mei.me_last_pgno+1);
|
||||
printf(" Last transaction ID: %"Y"u\n", mei.me_last_txnid);
|
||||
printf(" Max pages: %"Yu"\n", mei.me_mapsize / mst.ms_psize);
|
||||
printf(" Number of pages used: %"Yu"\n", mei.me_last_pgno+1);
|
||||
printf(" Last transaction ID: %"Yu"\n", mei.me_last_txnid);
|
||||
printf(" Max readers: %u\n", mei.me_maxreaders);
|
||||
printf(" Number of readers used: %u\n", mei.me_numreaders);
|
||||
}
|
||||
|
@ -169,7 +157,7 @@ int main(int argc, char *argv[])
|
|||
if (freinfo) {
|
||||
MDB_cursor *cursor;
|
||||
MDB_val key, data;
|
||||
size_t pages = 0, *iptr;
|
||||
mdb_size_t pages = 0, *iptr;
|
||||
|
||||
printf("Freelist Status\n");
|
||||
dbi = 0;
|
||||
|
@ -189,7 +177,7 @@ int main(int argc, char *argv[])
|
|||
pages += *iptr;
|
||||
if (freinfo > 1) {
|
||||
char *bad = "";
|
||||
size_t pg, prev;
|
||||
mdb_size_t pg, prev;
|
||||
ssize_t i, j, span = 0;
|
||||
j = *iptr++;
|
||||
for (i = j, prev = 1; --i >= 0; ) {
|
||||
|
@ -200,20 +188,20 @@ int main(int argc, char *argv[])
|
|||
pg += span;
|
||||
for (; i >= span && iptr[i-span] == pg; span++, pg++) ;
|
||||
}
|
||||
printf(" Transaction %"Z"u, %"Z"d pages, maxspan %"Z"d%s\n",
|
||||
*(size_t *)key.mv_data, j, span, bad);
|
||||
printf(" Transaction %"Yu", %"Z"d pages, maxspan %"Z"d%s\n",
|
||||
*(mdb_size_t *)key.mv_data, j, span, bad);
|
||||
if (freinfo > 2) {
|
||||
for (--j; j >= 0; ) {
|
||||
pg = iptr[j];
|
||||
for (span=1; --j >= 0 && iptr[j] == pg+span; span++) ;
|
||||
printf(span>1 ? " %9"Z"u[%"Z"d]\n" : " %9"Z"u\n",
|
||||
printf(span>1 ? " %9"Yu"[%"Z"d]\n" : " %9"Yu"\n",
|
||||
pg, span);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mdb_cursor_close(cursor);
|
||||
printf(" Free pages: %"Z"u\n", pages);
|
||||
printf(" Free pages: %"Yu"\n", pages);
|
||||
}
|
||||
|
||||
rc = mdb_open(txn, subname, 0, &dbi);
|
||||
|
|
3
external/db_drivers/liblmdb/midl.c
vendored
3
external/db_drivers/liblmdb/midl.c
vendored
|
@ -3,7 +3,8 @@
|
|||
/* $OpenLDAP$ */
|
||||
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
||||
*
|
||||
* Copyright 2000-2015 The OpenLDAP Foundation.
|
||||
* Copyright 2000-2019 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
|
||||
|
|
12
external/db_drivers/liblmdb/midl.h
vendored
12
external/db_drivers/liblmdb/midl.h
vendored
|
@ -11,7 +11,8 @@
|
|||
/* $OpenLDAP$ */
|
||||
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
||||
*
|
||||
* Copyright 2000-2015 The OpenLDAP Foundation.
|
||||
* Copyright 2000-2019 The OpenLDAP Foundation.
|
||||
* Portions Copyright 2001-2019 Howard Chu, Symas Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -26,8 +27,7 @@
|
|||
#ifndef _MDB_MIDL_H_
|
||||
#define _MDB_MIDL_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
#include "lmdb.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -43,11 +43,7 @@ extern "C" {
|
|||
/** A generic unsigned ID number. These were entryIDs in back-bdb.
|
||||
* Preferably it should have the same size as a pointer.
|
||||
*/
|
||||
#ifdef MDB_VL32
|
||||
typedef uint64_t MDB_ID;
|
||||
#else
|
||||
typedef size_t MDB_ID;
|
||||
#endif
|
||||
typedef mdb_size_t MDB_ID;
|
||||
|
||||
/** An IDL is an ID List, a sorted array of IDs. The first
|
||||
* element of the array is a counter for how many actual
|
||||
|
|
2
external/db_drivers/liblmdb/mtest.c
vendored
2
external/db_drivers/liblmdb/mtest.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mtest.c - memory-mapped database tester/toy */
|
||||
/*
|
||||
* Copyright 2011-2015 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
|
||||
|
|
2
external/db_drivers/liblmdb/mtest2.c
vendored
2
external/db_drivers/liblmdb/mtest2.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mtest2.c - memory-mapped database tester/toy */
|
||||
/*
|
||||
* Copyright 2011-2015 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
|
||||
|
|
2
external/db_drivers/liblmdb/mtest3.c
vendored
2
external/db_drivers/liblmdb/mtest3.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mtest3.c - memory-mapped database tester/toy */
|
||||
/*
|
||||
* Copyright 2011-2015 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
|
||||
|
|
2
external/db_drivers/liblmdb/mtest4.c
vendored
2
external/db_drivers/liblmdb/mtest4.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mtest4.c - memory-mapped database tester/toy */
|
||||
/*
|
||||
* Copyright 2011-2015 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
|
||||
|
|
2
external/db_drivers/liblmdb/mtest5.c
vendored
2
external/db_drivers/liblmdb/mtest5.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mtest5.c - memory-mapped database tester/toy */
|
||||
/*
|
||||
* Copyright 2011-2015 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
|
||||
|
|
2
external/db_drivers/liblmdb/mtest6.c
vendored
2
external/db_drivers/liblmdb/mtest6.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* mtest6.c - memory-mapped database tester/toy */
|
||||
/*
|
||||
* Copyright 2011-2015 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
|
||||
|
|
2
external/db_drivers/liblmdb/sample-bdb.txt
vendored
2
external/db_drivers/liblmdb/sample-bdb.txt
vendored
|
@ -3,7 +3,7 @@
|
|||
* Do a line-by-line comparison of this and sample-mdb.txt
|
||||
*/
|
||||
/*
|
||||
* Copyright 2012-2015 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
|
||||
|
|
2
external/db_drivers/liblmdb/sample-mdb.txt
vendored
2
external/db_drivers/liblmdb/sample-mdb.txt
vendored
|
@ -3,7 +3,7 @@
|
|||
* Do a line-by-line comparison of this and sample-bdb.txt
|
||||
*/
|
||||
/*
|
||||
* Copyright 2012-2015 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
|
||||
|
|
Loading…
Reference in a new issue