54 static const char hexc[] =
"0123456789abcdef";
56 static void hex(
unsigned char c)
58 putchar(
hexc[c >> 4]);
59 putchar(
hexc[c & 0xf]);
64 unsigned char *c, *end;
83 unsigned char *c, *end;
113 printf(
"VERSION=3\n");
114 printf(
"format=%s\n",
mode &
PRINT ?
"print" :
"bytevalue");
116 printf(
"database=%s\n", name);
117 printf(
"type=btree\n");
124 printf(
"duplicates=1\n");
130 printf(
"db_pagesize=%d\n",
ms.ms_psize);
131 printf(
"HEADER=END\n");
149 printf(
"DATA=END\n");
158 fprintf(stderr,
"usage: %s [-V] [-f output] [-l] [-n] [-p] [-a|-s subdb] dbpath\n",
prog);
162 int main(
int argc,
char *argv[])
168 char *
prog = argv[0];
171 int alldbs = 0, envflags = 0, list = 0;
185 while ((
i =
getopt(argc, argv,
"af:lnps:V")) != EOF) {
201 fprintf(stderr,
"%s: %s: reopen: %s\n",
237 fprintf(stderr,
"mdb_env_create failed, error %d %s\n", rc,
mdb_strerror(rc));
247 fprintf(stderr,
"mdb_env_open failed, error %d %s\n", rc,
mdb_strerror(rc));
253 fprintf(stderr,
"mdb_txn_begin failed, error %d %s\n", rc,
mdb_strerror(rc));
259 fprintf(stderr,
"mdb_open failed, error %d %s\n", rc,
mdb_strerror(rc));
270 fprintf(stderr,
"mdb_cursor_open failed, error %d %s\n", rc,
mdb_strerror(rc));
276 if (memchr(
key.mv_data,
'\0',
key.mv_size))
299 fprintf(stderr,
"%s: %s does not contain multiple databases\n",
prog, envname);
static const char * str(char *buf, int n)
#define MDB_VERSION_STRING
The full library version as a C string.
#define MDB_NOTFOUND
key/data pair not found (EOF)
#define MDB_SUCCESS
Successful result.
int mdb_env_info(MDB_env *env, MDB_envinfo *stat)
Return information about the LMDB environment.
int mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode)
Open an environment handle.
void mdb_env_close(MDB_env *env)
Close the environment and release the memory map.
int mdb_cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data, MDB_cursor_op op)
Retrieve by cursor.
void mdb_txn_abort(MDB_txn *txn)
Abandon all the operations of the transaction instead of saving them.
int mdb_dbi_flags(MDB_txn *txn, MDB_dbi dbi, unsigned int *flags)
Retrieve the DB flags for a database handle.
char * mdb_strerror(int err)
Return a string describing a given error code.
int mdb_cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor)
Create a cursor handle.
int mdb_env_set_maxdbs(MDB_env *env, MDB_dbi dbs)
Set the maximum number of named databases for the environment.
int mdb_env_create(MDB_env **env)
Create an LMDB environment handle.
#define mdb_open(txn, name, flags, dbi)
Compat with version <= 0.9.4, avoid clash with libmdb from MDB Tools project.
#define mdb_close(env, dbi)
Compat with version <= 0.9.4, avoid clash with libmdb from MDB Tools project.
void mdb_cursor_close(MDB_cursor *cursor)
Close a cursor handle.
int mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **txn)
Create a transaction for use with the environment.
int mdb_stat(MDB_txn *txn, MDB_dbi dbi, MDB_stat *stat)
Retrieve statistics for a database.
MDB_env * mdb_txn_env(MDB_txn *txn)
Returns the transaction's MDB_env.
@ MDB_NEXT_NODUP
Position at first data item of next key.
@ MDB_NEXT
Position at next data item.
#define MDB_INTEGERKEY
numeric keys in native byte order: either unsigned int or size_t.
#define MDB_DUPFIXED
with MDB_DUPSORT, sorted dup items have fixed size
#define MDB_INTEGERDUP
with MDB_DUPSORT, dups are MDB_INTEGERKEY-style integers
#define MDB_DUPSORT
use sorted duplicates
#define MDB_REVERSEKEY
use reverse string keys
#define MDB_REVERSEDUP
with MDB_DUPSORT, use reverse string dups
#define MDB_NOSUBDIR
no environment directory
#define MDB_RDONLY
read only
unsigned int me_maxreaders
max reader slots in the environment
size_t me_mapsize
Size of the data memory map.
void * me_mapaddr
Address of map, if fixed.
size_t mv_size
size of the data item
void * mv_data
address of the data item
unsigned int MDB_dbi
A handle for an individual database in the DB environment.
int main(int argc, char *argv[])
static void hex(unsigned char c)
static volatile sig_atomic_t gotsig
static void byte(MDB_val *v)
static void usage(char *prog)
static void dumpsig(int sig)
static int dumpit(MDB_txn *txn, MDB_dbi dbi, char *name)
static void text(MDB_val *v)
static void env_close(MDB_env *env) noexcept
static void txn_abort(MDB_txn *txn) noexcept
const struct ncbi::grid::netcache::search::fields::KEY key
static SLJIT_INLINE sljit_ins ms(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
Cursors are used for all DB operations.
The database environment.
Information about the environment.
Statistics for a database in the environment.
Generic structure used for passing keys and data in and out of the database.