[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
[lmdb] mdb_stat with named databases
- To: openldap-technical@openldap.org
- Subject: [lmdb] mdb_stat with named databases
- From: JK <jkal@posteo.eu>
- Date: Sat, 08 Jun 2013 20:39:07 +0200
- User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6
Hi,
should using 'mdb_stat' in c work with named databases?
In my test, when using 'mdb_dbi_open' with a string name and inserting
some data, 'mdb_stat' sets all 'MDB_stat' values to zero.
Using an unnamed database or the 'mdb_stat' command-line utility returns
expected values.
I'm using the gitorius mdb version, commit e7f6767, on linux 3.9.4.
Thanks for any insights.
relevant code (generated)
----
#include <stdio.h>
#include <lmdb.h>
#define s(arg)
status=arg;if(!(MDB_SUCCESS==status)){puts(mdb_strerror(status));return(status);}
int status;
MDB_env* env;
int main() {
MDB_stat stat;
int data;
MDB_val val;
MDB_txn* txn;
MDB_dbi dbi;
s(mdb_env_create(&env));
s(mdb_env_set_maxdbs(env,10u));
s(mdb_env_set_maxreaders(env,3u));
s(mdb_env_open(env,"/tmp/mdb",0u,384u));
s(mdb_txn_begin(env,0u,0u,&txn));
s(mdb_dbi_open(txn,"testdb",MDB_CREATE,&dbi));
val.mv_size=sizeof(int);
val.mv_data=&data;
data=123u;
s(mdb_put(txn,dbi,&val,&val,0u));
data=124u;
s(mdb_put(txn,dbi,&val,&val,0u));
data=125u;
s(mdb_put(txn,dbi,&val,&val,0u));
s(mdb_txn_commit(txn));
s(mdb_txn_begin(env,0u,MDB_RDONLY,&txn));
s(mdb_stat(txn,dbi,&stat));
mdb_txn_abort(txn);
printf("ms-entries: %lu\nms-depth:
%lu\n",stat.ms_entries,stat.ms_depth);
mdb_env_close(env);
return(0);
}
----