diff options
Diffstat (limited to 'external/db_drivers/liblmdb32/mtest6.c')
-rw-r--r-- | external/db_drivers/liblmdb32/mtest6.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/external/db_drivers/liblmdb32/mtest6.c b/external/db_drivers/liblmdb32/mtest6.c index 07d575893..ae3c7f264 100644 --- a/external/db_drivers/liblmdb32/mtest6.c +++ b/external/db_drivers/liblmdb32/mtest6.c @@ -1,6 +1,6 @@ /* mtest6.c - memory-mapped database tester/toy */ /* - * Copyright 2011-2014 Howard Chu, Symas Corp. + * Copyright 2011-2015 Howard Chu, Symas Corp. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ int main(int argc,char * argv[]) int i = 0, j = 0, rc; MDB_env *env; MDB_dbi dbi; - MDB_val key, data; + MDB_val key, data, sdata; MDB_txn *txn; MDB_stat mst; MDB_cursor *cursor; @@ -46,33 +46,37 @@ int main(int argc,char * argv[]) E(mdb_env_set_mapsize(env, 10485760)); E(mdb_env_set_maxdbs(env, 4)); E(mdb_env_open(env, "./testdb", MDB_FIXEDMAP|MDB_NOSYNC, 0664)); + E(mdb_txn_begin(env, NULL, 0, &txn)); - E(mdb_open(txn, "id6", MDB_CREATE|MDB_INTEGERKEY, &dbi)); + E(mdb_dbi_open(txn, "id6", MDB_CREATE|MDB_INTEGERKEY, &dbi)); E(mdb_cursor_open(txn, dbi, &cursor)); E(mdb_stat(txn, dbi, &mst)); sval = calloc(1, mst.ms_psize / 4); key.mv_size = sizeof(long); key.mv_data = &kval; - data.mv_size = mst.ms_psize / 4 - 30; - data.mv_data = sval; + sdata.mv_size = mst.ms_psize / 4 - 30; + sdata.mv_data = sval; printf("Adding 12 values, should yield 3 splits\n"); for (i=0;i<12;i++) { kval = i*5; sprintf(sval, "%08x", kval); + data = sdata; (void)RES(MDB_KEYEXIST, mdb_cursor_put(cursor, &key, &data, MDB_NOOVERWRITE)); } printf("Adding 12 more values, should yield 3 splits\n"); for (i=0;i<12;i++) { kval = i*5+4; sprintf(sval, "%08x", kval); + data = sdata; (void)RES(MDB_KEYEXIST, mdb_cursor_put(cursor, &key, &data, MDB_NOOVERWRITE)); } printf("Adding 12 more values, should yield 3 splits\n"); for (i=0;i<12;i++) { kval = i*5+1; sprintf(sval, "%08x", kval); + data = sdata; (void)RES(MDB_KEYEXIST, mdb_cursor_put(cursor, &key, &data, MDB_NOOVERWRITE)); } E(mdb_cursor_get(cursor, &key, &data, MDB_FIRST)); @@ -110,7 +114,7 @@ int main(int argc,char * argv[]) printf("Deleted %d values\n", j); E(mdb_env_stat(env, &mst)); - E(mdb_txn_begin(env, NULL, 1, &txn)); + E(mdb_txn_begin(env, NULL, MDB_RDONLY, &txn)); E(mdb_cursor_open(txn, dbi, &cursor)); printf("Cursor next\n"); while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { @@ -127,9 +131,9 @@ int main(int argc,char * argv[]) } CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get"); mdb_cursor_close(cursor); - mdb_close(env, dbi); - mdb_txn_abort(txn); + + mdb_dbi_close(env, dbi); #endif mdb_env_close(env); |