openldap/libraries/libmdb/mdb_stat.c

49 lines
1.0 KiB
C
Raw Normal View History

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "mdb.h"
int main(int argc,char * argv[])
{
2011-06-30 03:12:08 +08:00
int rc;
MDB_env *env;
2011-08-03 16:41:54 +08:00
MDB_txn *txn;
MDB_dbi dbi;
2011-07-03 19:22:10 +08:00
MDB_stat mst;
char *envname = argv[1];
char *subname = NULL;
if (argc > 2)
subname = argv[2];
rc = mdbenv_create(&env);
rc = mdbenv_open(env, envname, MDB_RDONLY, 0);
if (rc) {
printf("mdbenv_open failed, error %d\n", rc);
exit(1);
}
2011-08-03 16:41:54 +08:00
rc = mdb_txn_begin(env, 1, &txn);
if (rc) {
printf("mdb_txn_begin failed, error %d\n", rc);
exit(1);
}
rc = mdb_open(txn, subname, 0, &dbi);
if (rc) {
printf("mdb_open failed, error %d\n", rc);
exit(1);
}
2011-08-03 16:41:54 +08:00
rc = mdb_stat(txn, dbi, &mst);
2011-07-03 19:22:10 +08:00
printf("Page size: %u\n", mst.ms_psize);
printf("Tree depth: %u\n", mst.ms_depth);
printf("Branch pages: %lu\n", mst.ms_branch_pages);
printf("Leaf pages: %lu\n", mst.ms_leaf_pages);
printf("Overflow pages: %lu\n", mst.ms_overflow_pages);
printf("Entries: %lu\n", mst.ms_entries);
2011-08-03 17:23:16 +08:00
mdb_close(txn, dbi);
2011-08-03 16:41:54 +08:00
mdb_txn_abort(txn);
mdbenv_close(env);
return 0;
}