29 printf(
" Page size: %u\n", ms->
ms_psize);
31 printf(
" Tree depth: %u\n", ms->
ms_depth);
40 fprintf(stderr,
"usage: %s [-V] [-n] [-e] [-r[r]] [-f[f[f]]] [-a|-s subdb] dbpath\n",
prog);
44 int main(
int argc,
char *argv[])
55 int alldbs = 0, envinfo = 0, envflags = 0, freinfo = 0, rdrinfo = 0;
70 while ((
i =
getopt(argc, argv,
"Vaefnrs:")) != EOF) {
109 fprintf(stderr,
"mdb_env_create failed, error %d %s\n", rc,
mdb_strerror(rc));
119 fprintf(stderr,
"mdb_env_open failed, error %d %s\n", rc,
mdb_strerror(rc));
126 printf(
"Environment Info\n");
129 printf(
" Page size: %u\n", mst.
ms_psize);
131 printf(
" Number of pages used: %"Z"u\n", mei.
me_last_pgno+1);
138 printf(
"Reader Table Status\n");
143 printf(
" %d stale readers cleared.\n", dead);
146 if (!(
subname || alldbs || freinfo))
152 fprintf(stderr,
"mdb_txn_begin failed, error %d %s\n", rc,
mdb_strerror(rc));
159 size_t pages = 0, *iptr;
161 printf(
"Freelist Status\n");
165 fprintf(stderr,
"mdb_cursor_open failed, error %d %s\n", rc,
mdb_strerror(rc));
170 fprintf(stderr,
"mdb_stat failed, error %d %s\n", rc,
mdb_strerror(rc));
182 for (
i = j,
prev = 1; --
i >= 0; ) {
185 bad =
" [bad sequence]";
188 for (;
i >= span && iptr[
i-span] == pg; span++, pg++) ;
190 printf(
" Transaction %"Z"u, %"Z"d pages, maxspan %"Z"d%s\n",
191 *(
size_t *)
key.mv_data, j, span, bad);
193 for (--j; j >= 0; ) {
195 for (span=1; --j >= 0 && iptr[j] == pg+span; span++) ;
196 printf(span>1 ?
" %9"Z"u[%"Z"d]\n" :
" %9"Z"u\n",
203 printf(
" Free pages: %"Z"u\n", pages);
208 fprintf(stderr,
"mdb_open failed, error %d %s\n", rc,
mdb_strerror(rc));
214 fprintf(stderr,
"mdb_stat failed, error %d %s\n", rc,
mdb_strerror(rc));
226 fprintf(stderr,
"mdb_cursor_open failed, error %d %s\n", rc,
mdb_strerror(rc));
232 if (memchr(
key.mv_data,
'\0',
key.mv_size))
239 printf(
"Status of %s\n",
str);
244 fprintf(stderr,
"mdb_stat failed, error %d %s\n", rc,
mdb_strerror(rc));
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#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_msg_func(const char *msg, void *ctx)
A callback function used to print a message from the library.
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.
int mdb_reader_check(MDB_env *env, int *dead)
Check for stale entries in the reader lock table.
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_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx)
Dump the entries in the reader lock table.
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.
int mdb_env_stat(MDB_env *env, MDB_stat *stat)
Return statistics about the LMDB environment.
@ MDB_NEXT_NODUP
Position at first data item of next key.
@ MDB_NEXT
Position at next data item.
#define MDB_NOSUBDIR
no environment directory
#define MDB_RDONLY
read only
unsigned int me_maxreaders
max reader slots in the environment
size_t ms_entries
Number of data items.
size_t me_mapsize
Size of the data memory map.
size_t me_last_txnid
ID of the last committed transaction.
unsigned int ms_psize
Size of a database page.
void * me_mapaddr
Address of map, if fixed.
void * mv_data
address of the data item
unsigned int ms_depth
Depth (height) of the B-tree.
size_t ms_overflow_pages
Number of overflow pages.
size_t ms_leaf_pages
Number of leaf pages.
size_t ms_branch_pages
Number of internal (non-leaf) pages.
unsigned int me_numreaders
max reader slots used in the environment
size_t me_last_pgno
ID of the last used page.
unsigned int MDB_dbi
A handle for an individual database in the DB environment.
int main(int argc, char *argv[])
static void prstat(MDB_stat *ms)
static void usage(char *prog)
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 const char * str(char *buf, int n)
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.