Fix mdb_txn_begin(&read-only txn) calls. Test mdb_env_set_maxreaders().
Rename DBI open/close functions. Move mdb_dbi_close() out of txn.
}
E(mdb_env_create(&env));
+ E(mdb_env_set_maxreaders(env, 1));
E(mdb_env_set_mapsize(env, 10485760));
E(mdb_env_open(env, "./testdb", MDB_FIXEDMAP /*|MDB_NOSYNC*/, 0664));
+
E(mdb_txn_begin(env, NULL, 0, &txn));
- E(mdb_open(txn, NULL, 0, &dbi));
+ E(mdb_dbi_open(txn, NULL, 0, &dbi));
key.mv_size = sizeof(int);
key.mv_data = sval;
E(mdb_txn_commit(txn));
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));
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
printf("key: %p %.*s, data: %p %.*s\n",
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) {
data.mv_data, (int) data.mv_size, (char *) data.mv_data);
}
mdb_cursor_close(cursor);
- mdb_close(env, dbi);
-
mdb_txn_abort(txn);
+
+ mdb_dbi_close(env, dbi);
mdb_env_close(env);
return 0;
}
E(mdb_env_create(&env));
+ E(mdb_env_set_maxreaders(env, 1));
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, "id1", MDB_CREATE, &dbi));
+ E(mdb_dbi_open(txn, "id1", MDB_CREATE, &dbi));
key.mv_size = sizeof(int);
key.mv_data = sval;
E(mdb_txn_commit(txn));
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));
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
printf("key: %p %.*s, data: %p %.*s\n",
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) {
}
CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get");
mdb_cursor_close(cursor);
- mdb_close(env, dbi);
-
mdb_txn_abort(txn);
- mdb_env_close(env);
+ mdb_dbi_close(env, dbi);
+ mdb_env_close(env);
return 0;
}
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, "id2", MDB_CREATE|MDB_DUPSORT, &dbi));
+ E(mdb_dbi_open(txn, "id2", MDB_CREATE|MDB_DUPSORT, &dbi));
key.mv_size = sizeof(int);
key.mv_data = kval;
E(mdb_txn_commit(txn));
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));
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
printf("key: %p %.*s, data: %p %.*s\n",
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) {
}
CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get");
mdb_cursor_close(cursor);
- mdb_close(env, dbi);
-
mdb_txn_abort(txn);
- mdb_env_close(env);
+ mdb_dbi_close(env, dbi);
+ mdb_env_close(env);
return 0;
}
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, "id4", MDB_CREATE|MDB_DUPSORT|MDB_DUPFIXED, &dbi));
+ E(mdb_dbi_open(txn, "id4", MDB_CREATE|MDB_DUPSORT|MDB_DUPFIXED, &dbi));
key.mv_size = sizeof(int);
key.mv_data = kval;
/* there should be one full page of dups now.
*/
- E(mdb_txn_begin(env, NULL, 1, &txn));
+ E(mdb_txn_begin(env, NULL, MDB_RDONLY, &txn));
E(mdb_cursor_open(txn, dbi, &cursor));
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
printf("key: %p %.*s, data: %p %.*s\n",
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) {
}
CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get");
mdb_cursor_close(cursor);
- mdb_close(env, dbi);
-
mdb_txn_abort(txn);
- mdb_env_close(env);
+ mdb_dbi_close(env, dbi);
+ mdb_env_close(env);
return 0;
}
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, "id2", MDB_CREATE|MDB_DUPSORT, &dbi));
+ E(mdb_dbi_open(txn, "id2", MDB_CREATE|MDB_DUPSORT, &dbi));
E(mdb_cursor_open(txn, dbi, &cursor));
key.mv_size = sizeof(int);
E(mdb_txn_commit(txn));
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));
while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
printf("key: %p %.*s, data: %p %.*s\n",
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) {
}
CHECK(rc == MDB_NOTFOUND, "mdb_cursor_get");
mdb_cursor_close(cursor);
- mdb_close(env, dbi);
-
mdb_txn_abort(txn);
- mdb_env_close(env);
+ mdb_dbi_close(env, dbi);
+ mdb_env_close(env);
return 0;
}
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));
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) {
}
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);
rc = mdb_env_create(&env);
rc = mdb_env_open(env, "./testdb", 0, 0664);
rc = mdb_txn_begin(env, NULL, 0, &txn);
- rc = mdb_open(txn, NULL, 0, &dbi);
+ rc = mdb_dbi_open(txn, NULL, 0, &dbi);
key.mv_size = sizeof(int);
key.mv_data = sval;
mdb_cursor_close(cursor);
mdb_txn_abort(txn);
leave:
- mdb_close(env, dbi);
+ mdb_dbi_close(env, dbi);
mdb_env_close(env);
return 0;
}