Commit 0b920d5f authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

require an env to create a db [t:2001]

git-svn-id: file:///svn/toku/tokudb@14513 c7de825b-a66e-492c-adef-691d508d4ae1
parent d4c7ca77
...@@ -29,6 +29,7 @@ static void backward_scan_state_init(struct backward_scan_state *bs) { ...@@ -29,6 +29,7 @@ static void backward_scan_state_init(struct backward_scan_state *bs) {
// Map filenum to brt // Map filenum to brt
// TODO why can't we use the cachetable to find by filenum? // TODO why can't we use the cachetable to find by filenum?
// TODO O(n) time for linear search. should we use an OMT?
struct file_map { struct file_map {
struct cf_tuple { struct cf_tuple {
FILENUM filenum; FILENUM filenum;
......
...@@ -147,6 +147,7 @@ TDB_TESTS_THAT_SHOULD_FAIL= \ ...@@ -147,6 +147,7 @@ TDB_TESTS_THAT_SHOULD_FAIL= \
test_groupcommit_count \ test_groupcommit_count \
test944 \ test944 \
test_truncate_txn_abort \ test_truncate_txn_abort \
test_db_no_env \
#\ ends prev line #\ ends prev line
ifneq ($(OS_CHOICE),windows) ifneq ($(OS_CHOICE),windows)
TDB_TESTS_THAT_SHOULD_FAIL+= \ TDB_TESTS_THAT_SHOULD_FAIL+= \
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
static void static void
test_upgrade_from_10 (void) { test_upgrade_from_10 (void) {
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
int r; int r;
...@@ -25,7 +23,12 @@ test_upgrade_from_10 (void) { ...@@ -25,7 +23,12 @@ test_upgrade_from_10 (void) {
const int PAGESIZE=1024; const int PAGESIZE=1024;
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ".", DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_pagesize(db, PAGESIZE); r = db->set_pagesize(db, PAGESIZE);
assert(r == 0); assert(r == 0);
...@@ -104,8 +107,8 @@ test_upgrade_from_10 (void) { ...@@ -104,8 +107,8 @@ test_upgrade_from_10 (void) {
c->c_close(c); c->c_close(c);
assert(num_found == num_leafentries + num_insert_messages - 2); //le_provdels should not show up assert(num_found == num_leafentries + num_insert_messages - 2); //le_provdels should not show up
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -23,13 +23,16 @@ static void ...@@ -23,13 +23,16 @@ static void
test_cursor_current (void) { test_cursor_current (void) {
if (verbose) printf("test_cursor_current\n"); if (verbose) printf("test_cursor_current\n");
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.cursor.current.brt"; const char * const fname = "test.cursor.current.brt";
int r; int r;
r = db_create(&db, null_env, 0); CKERR(r); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); CKERR(r);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r);
...@@ -84,6 +87,7 @@ test_cursor_current (void) { ...@@ -84,6 +87,7 @@ test_cursor_current (void) {
r = cursor->c_close(cursor); CKERR(r); r = cursor->c_close(cursor); CKERR(r);
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); CKERR(r);
} }
static void static void
...@@ -97,19 +101,23 @@ static void ...@@ -97,19 +101,23 @@ static void
test_reopen (void) { test_reopen (void) {
if (verbose) printf("test_reopen\n"); if (verbose) printf("test_reopen\n");
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.cursor.current.brt"; const char * const fname = "test.cursor.current.brt";
int r; int r;
r = db_create(&db, null_env, 0); CKERR(r); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); CKERR(r);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); CKERR(r); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); CKERR(r);
db_get(db, 1, 1, DB_NOTFOUND); db_get(db, 1, 1, DB_NOTFOUND);
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); CKERR(r);
} }
int int
......
...@@ -50,18 +50,20 @@ test_cursor_delete (int dup_mode) { ...@@ -50,18 +50,20 @@ test_cursor_delete (int dup_mode) {
int npp = pagesize/elementsize; int npp = pagesize/elementsize;
int n = 16*npp; /* build a 2 level tree */ int n = 16*npp; /* build a 2 level tree */
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.cursor.delete.brt"; const char * const fname = "test.cursor.delete.brt";
int r; int r;
r = system("rm -rf " ENVDIR); assert(r == 0); r = system("rm -rf " ENVDIR); assert(r == 0);
r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, pagesize); assert(r == 0); r = db->set_pagesize(db, pagesize); assert(r == 0);
...@@ -88,6 +90,7 @@ test_cursor_delete (int dup_mode) { ...@@ -88,6 +90,7 @@ test_cursor_delete (int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
/* insert duplicate duplicates into a sorted duplicate tree */ /* insert duplicate duplicates into a sorted duplicate tree */
...@@ -102,17 +105,20 @@ test_cursor_delete_dupsort (void) { ...@@ -102,17 +105,20 @@ test_cursor_delete_dupsort (void) {
int npp = pagesize/elementsize; int npp = pagesize/elementsize;
int n = 16*npp; /* build a 2 level tree */ int n = 16*npp; /* build a 2 level tree */
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.cursor.delete.brt"; const char * const fname = "test.cursor.delete.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->set_flags(db, DB_DUP + DB_DUPSORT); assert(r == 0); r = db->set_flags(db, DB_DUP + DB_DUPSORT); assert(r == 0);
r = db->set_pagesize(db, pagesize); assert(r == 0); r = db->set_pagesize(db, pagesize); assert(r == 0);
...@@ -151,6 +157,7 @@ test_cursor_delete_dupsort (void) { ...@@ -151,6 +157,7 @@ test_cursor_delete_dupsort (void) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -16,16 +16,19 @@ static void ...@@ -16,16 +16,19 @@ static void
test_cursor_flags (int cursor_flags, int expectr) { test_cursor_flags (int cursor_flags, int expectr) {
if (verbose) printf("test_cursor_flags:%d %d\n", cursor_flags, expectr); if (verbose) printf("test_cursor_flags:%d %d\n", cursor_flags, expectr);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.cursor.delete.brt"; const char * const fname = "test.cursor.delete.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -38,6 +41,7 @@ test_cursor_flags (int cursor_flags, int expectr) { ...@@ -38,6 +41,7 @@ test_cursor_flags (int cursor_flags, int expectr) {
} }
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -49,17 +49,20 @@ static void ...@@ -49,17 +49,20 @@ static void
test_cursor_nonleaf_expand (int n, int reverse) { test_cursor_nonleaf_expand (int n, int reverse) {
if (verbose) printf("test_cursor_nonleaf_expand:%d %d\n", n, reverse); if (verbose) printf("test_cursor_nonleaf_expand:%d %d\n", n, reverse);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.insert.brt"; const char * const fname = "test.insert.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -86,6 +89,7 @@ test_cursor_nonleaf_expand (int n, int reverse) { ...@@ -86,6 +89,7 @@ test_cursor_nonleaf_expand (int n, int reverse) {
r = cursor0->c_close(cursor0); assert(r == 0); r = cursor0->c_close(cursor0); assert(r == 0);
r = cursorn->c_close(cursorn); assert(r == 0); r = cursorn->c_close(cursorn); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -37,17 +37,20 @@ static void ...@@ -37,17 +37,20 @@ static void
test_cursor_sticky (int n, int dup_mode) { test_cursor_sticky (int n, int dup_mode) {
if (verbose) printf("test_cursor_sticky:%d %d\n", n, dup_mode); if (verbose) printf("test_cursor_sticky:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_cursor_sticky.brt"; const char * const fname = "test_cursor_sticky.brt";
int r; int r;
r = system("rm -rf " ENVDIR); assert(r == 0); r = system("rm -rf " ENVDIR); assert(r == 0);
r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0); r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -73,6 +76,7 @@ test_cursor_sticky (int n, int dup_mode) { ...@@ -73,6 +76,7 @@ test_cursor_sticky (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -16,42 +16,46 @@ ...@@ -16,42 +16,46 @@
int int
test_main(int argc, char *argv[]) { test_main(int argc, char *argv[]) {
parse_args(argc, argv); parse_args(argc, argv);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = "test.already.exists.brt"; const char * const fname = "test.already.exists.brt";
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
r=chdir(ENVDIR); assert(r==0);
r = db_create(&db, null_env, 0); CKERR(r); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); CKERR(r);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
// r = db->set_flags(db, DB_DUP); CKERR(r); // r = db->set_flags(db, DB_DUP); CKERR(r);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r);
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
r = db_create(&db, null_env, 0); CKERR(r); r = db_create(&db, env, 0); CKERR(r);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r);
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
r = db_create(&db, null_env, 0); CKERR(r); r = db_create(&db, env, 0); CKERR(r);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); CKERR(r); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); CKERR(r);
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
r = db_create(&db, null_env, 0); CKERR(r); r = db_create(&db, env, 0); CKERR(r);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_EXCL, 0666); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_EXCL, 0666);
assert(r == EINVAL); assert(r == EINVAL);
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
r = db_create(&db, null_env, 0); CKERR(r); r = db_create(&db, env, 0); CKERR(r);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE | DB_EXCL, 0666); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE | DB_EXCL, 0666);
assert(r == EEXIST); assert(r == EEXIST);
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); CKERR(r);
return 0; return 0;
} }
...@@ -28,7 +28,8 @@ setup(void) { ...@@ -28,7 +28,8 @@ setup(void) {
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
dbenv = 0; r = db_env_create(&dbenv, 0); assert(r == 0);
r = dbenv->open(dbenv, ".", DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
/* Open/create primary */ /* Open/create primary */
r = db_create(&db, dbenv, 0); CKERR(r); r = db_create(&db, dbenv, 0); CKERR(r);
r = db->open(db, null_txn, ENVDIR "/primary.db", NULL, DB_BTREE, DB_CREATE, 0600); CKERR(r); r = db->open(db, null_txn, ENVDIR "/primary.db", NULL, DB_BTREE, DB_CREATE, 0600); CKERR(r);
...@@ -54,6 +55,7 @@ close_dbs (void) { ...@@ -54,6 +55,7 @@ close_dbs (void) {
int r; int r;
r = db->close(db, 0); CKERR(r); r = db->close(db, 0); CKERR(r);
r = dbenv->close(dbenv, 0); CKERR(r);
} }
int int
......
...@@ -45,17 +45,20 @@ static void ...@@ -45,17 +45,20 @@ static void
test_db_delboth (int n, int dup_mode) { test_db_delboth (int n, int dup_mode) {
if (verbose) printf("test_db_delboth:%d %d\n", n, dup_mode); if (verbose) printf("test_db_delboth:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.db.delete.brt"; const char * const fname = "test.db.delete.brt";
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
CKERR(r); CKERR(r);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
CKERR(r); CKERR(r);
...@@ -72,7 +75,7 @@ test_db_delboth (int n, int dup_mode) { ...@@ -72,7 +75,7 @@ test_db_delboth (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
CKERR(r); CKERR(r);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
CKERR(r); CKERR(r);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
CKERR(r); CKERR(r);
...@@ -156,8 +159,8 @@ test_db_delboth (int n, int dup_mode) { ...@@ -156,8 +159,8 @@ test_db_delboth (int n, int dup_mode) {
expect_db_getboth(db, htonl(i), htonl(i+1), DB_NOTFOUND); expect_db_getboth(db, htonl(i), htonl(i+1), DB_NOTFOUND);
} }
r = db->close(db, 0); r = db->close(db, 0); CKERR(r);
CKERR(r); r = env->close(env, 0); CKERR(r);
} }
#endif //USE_TDB #endif //USE_TDB
......
...@@ -39,17 +39,20 @@ static void ...@@ -39,17 +39,20 @@ static void
test_db_delete (int n, int dup_mode) { test_db_delete (int n, int dup_mode) {
if (verbose) printf("test_db_delete:%d %d\n", n, dup_mode); if (verbose) printf("test_db_delete:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.db.delete.brt"; const char * const fname = "test.db.delete.brt";
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -66,7 +69,7 @@ test_db_delete (int n, int dup_mode) { ...@@ -66,7 +69,7 @@ test_db_delete (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -97,25 +100,28 @@ test_db_delete (int n, int dup_mode) { ...@@ -97,25 +100,28 @@ test_db_delete (int n, int dup_mode) {
#endif #endif
#endif #endif
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
static void static void
test_db_get_datasize0 (void) { test_db_get_datasize0 (void) {
if (verbose) printf("test_db_get_datasize0\n"); if (verbose) printf("test_db_get_datasize0\n");
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.db_delete.brt"; const char * const fname = "test.db_delete.brt";
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_pagesize(db, 4096); r = db->set_pagesize(db, 4096);
assert(r == 0); assert(r == 0);
...@@ -130,8 +136,8 @@ test_db_get_datasize0 (void) { ...@@ -130,8 +136,8 @@ test_db_get_datasize0 (void) {
assert(r == 0); assert(r == 0);
toku_free(val.data); toku_free(val.data);
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -48,6 +48,8 @@ setup (u_int32_t flags) { ...@@ -48,6 +48,8 @@ setup (u_int32_t flags) {
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
/* Open/create primary */ /* Open/create primary */
r = db_env_create(&dbenv, 0); assert(r == 0);
r = dbenv->open(dbenv, ".", DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
r = db_create(&dbp, dbenv, 0); CKERR(r); r = db_create(&dbp, dbenv, 0); CKERR(r);
dbp->set_errfile(dbp,0); // Turn off those annoying errors dbp->set_errfile(dbp,0); // Turn off those annoying errors
if (flags) { if (flags) {
...@@ -60,6 +62,7 @@ static void ...@@ -60,6 +62,7 @@ static void
close_dbs (void) { close_dbs (void) {
int r; int r;
r = dbp->close(dbp, 0); CKERR(r); r = dbp->close(dbp, 0); CKERR(r);
r = dbenv->close(dbenv, 0); CKERR(r);
} }
static void static void
......
...@@ -3,11 +3,9 @@ ...@@ -3,11 +3,9 @@
#include "test.h" #include "test.h"
#include <fcntl.h> #include <fcntl.h>
DB_ENV * const null_env = 0;
DB *db1, *db2;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_db_remove.brt"; const char * const fname = "test_db_remove.brt";
static void test_db_remove (void) { static void test_db_remove (void) {
int r; int r;
...@@ -15,15 +13,21 @@ static void test_db_remove (void) { ...@@ -15,15 +13,21 @@ static void test_db_remove (void) {
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
// create the DB // create the DB
r = db_create(&db1, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db1;
r = db_create(&db1, env, 0); assert(r == 0);
r = db1->open(db1, null_txn, fname, 0, DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db1->open(db1, null_txn, fname, 0, DB_BTREE, DB_CREATE, 0666); assert(r == 0);
r = db1->close(db1, 0); assert(r == 0); //Header has been written to disk r = db1->close(db1, 0); assert(r == 0); //Header has been written to disk
r = db_create(&db1, null_env, 0); assert(r == 0); r = db_create(&db1, env, 0); assert(r == 0);
r = db1->open(db1, null_txn, fname, 0, DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db1->open(db1, null_txn, fname, 0, DB_BTREE, DB_CREATE, 0666); assert(r == 0);
// Now remove it, while it is open. // Now remove it, while it is open.
r = db_create(&db2, null_env, 0); assert(r==0); DB *db2;
r = db_create(&db2, env, 0); assert(r==0);
r = db2->remove(db2, fname, 0, 0); r = db2->remove(db2, fname, 0, 0);
#ifdef USE_TDB #ifdef USE_TDB
assert(r!=0); assert(r!=0);
...@@ -32,6 +36,7 @@ static void test_db_remove (void) { ...@@ -32,6 +36,7 @@ static void test_db_remove (void) {
#endif #endif
r = db1->close(db1, 0); assert(r==0); r = db1->close(db1, 0); assert(r==0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -16,21 +16,25 @@ static void ...@@ -16,21 +16,25 @@ static void
test_db_set_flags (int flags, int expectr, int flags2, int expectr2) { test_db_set_flags (int flags, int expectr, int flags2, int expectr2) {
if (verbose) printf("test_db_set_flags:%d %d %d %d\n", flags, expectr, flags2, expectr2); if (verbose) printf("test_db_set_flags:%d %d %d %d\n", flags, expectr, flags2, expectr2);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.db.set.flags.brt"; const char * const fname = "test.db.set.flags.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->set_flags(db, flags); assert(r == expectr); r = db->set_flags(db, flags); assert(r == expectr);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
r = db->set_flags(db, flags2); assert(r == expectr2); r = db->set_flags(db, flags2); assert(r == expectr2);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -19,7 +19,7 @@ create_db(char *name) { ...@@ -19,7 +19,7 @@ create_db(char *name) {
char fullname[strlen(name) + sizeof(ENVDIR) + sizeof("/")]; char fullname[strlen(name) + sizeof(ENVDIR) + sizeof("/")];
sprintf(fullname, "%s/%s", ENVDIR, name); sprintf(fullname, "%s/%s", ENVDIR, name);
int r; int r;
r=db_create(&db, NULL, 0); r=db_create(&db, env, 0);
CKERR(r); CKERR(r);
r=db->open(db, NULL, fullname, NULL, DB_BTREE, DB_CREATE, 0666); r=db->open(db, NULL, fullname, NULL, DB_BTREE, DB_CREATE, 0666);
CKERR(r); CKERR(r);
...@@ -36,7 +36,7 @@ delete_db(char *name) { ...@@ -36,7 +36,7 @@ delete_db(char *name) {
r = toku_stat(fullname, &buf); r = toku_stat(fullname, &buf);
CKERR(r); CKERR(r);
r=db_create(&db, NULL, 0); r=db_create(&db, env, 0);
CKERR(r); CKERR(r);
r=db->remove(db, fullname, NULL, 0); r=db->remove(db, fullname, NULL, 0);
CKERR(r); CKERR(r);
...@@ -55,6 +55,10 @@ test_main (int UU(argc), char UU(*argv[])) { ...@@ -55,6 +55,10 @@ test_main (int UU(argc), char UU(*argv[])) {
CKERR(r); CKERR(r);
system("cp test_dbremove_old.dir/* "ENVDIR); system("cp test_dbremove_old.dir/* "ENVDIR);
CKERR(r); CKERR(r);
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ".", DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
{ {
//Create and delete a brand new version db. //Create and delete a brand new version db.
char *unnamed_db = "version_now_unnamed.tokudb"; char *unnamed_db = "version_now_unnamed.tokudb";
......
...@@ -43,24 +43,23 @@ static void ...@@ -43,24 +43,23 @@ static void
test_dup_delete (int n, int dup_mode) { test_dup_delete (int n, int dup_mode) {
if (verbose) printf("test_dup_delete:%d %d\n", n, dup_mode); if (verbose) printf("test_dup_delete:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_dup_delete.brt"; const char * const fname = "test_dup_delete.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
assert(r == 0); r = db_env_create(&env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
assert(r == 0);
r = db->set_pagesize(db, 4096); DB *db;
assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); r = db->set_flags(db, dup_mode); assert(r == 0);
assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
/* insert n-1 unique keys {0, 1, n-1} - {n/2} */ /* insert n-1 unique keys {0, 1, n-1} - {n/2} */
int i; int i;
...@@ -75,7 +74,7 @@ test_dup_delete (int n, int dup_mode) { ...@@ -75,7 +74,7 @@ test_dup_delete (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -130,8 +129,8 @@ test_dup_delete (int n, int dup_mode) { ...@@ -130,8 +129,8 @@ test_dup_delete (int n, int dup_mode) {
r = cursor->c_close(cursor); r = cursor->c_close(cursor);
assert(r == 0); assert(r == 0);
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0), assert(r == 0);
} }
static __attribute__((__unused__)) static __attribute__((__unused__))
...@@ -139,14 +138,17 @@ void ...@@ -139,14 +138,17 @@ void
test_dup_delete_delete (int n) { test_dup_delete_delete (int n) {
if (verbose) printf("test_dup_delete_delete:%d\n", n); if (verbose) printf("test_dup_delete_delete:%d\n", n);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_dup_delete_delete.brt"; const char * const fname = "test_dup_delete_delete.brt";
int r; int r;
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, DB_DUP); r = db->set_flags(db, DB_DUP);
assert(r == 0); assert(r == 0);
...@@ -168,7 +170,7 @@ test_dup_delete_delete (int n) { ...@@ -168,7 +170,7 @@ test_dup_delete_delete (int n) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, DB_DUP); r = db->set_flags(db, DB_DUP);
assert(r == 0); assert(r == 0);
...@@ -212,20 +214,24 @@ test_dup_delete_delete (int n) { ...@@ -212,20 +214,24 @@ test_dup_delete_delete (int n) {
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = env->close(env, 0), assert(r == 0);
} }
static void static void
test_dup_delete_insert (int n, int dup_mode) { test_dup_delete_insert (int n, int dup_mode) {
if (verbose) printf("test_dup_delete_insert:%d %d\n", n, dup_mode); if (verbose) printf("test_dup_delete_insert:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_dup_delete_insert.brt"; const char * const fname = "test_dup_delete_insert.brt";
int r; int r;
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -247,7 +253,7 @@ test_dup_delete_insert (int n, int dup_mode) { ...@@ -247,7 +253,7 @@ test_dup_delete_insert (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -316,6 +322,7 @@ test_dup_delete_insert (int n, int dup_mode) { ...@@ -316,6 +322,7 @@ test_dup_delete_insert (int n, int dup_mode) {
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = env->close(env, 0), assert(r == 0);
} }
static __attribute__((__unused__)) static __attribute__((__unused__))
...@@ -323,14 +330,17 @@ void ...@@ -323,14 +330,17 @@ void
test_all_dup_delete_insert (int n) { test_all_dup_delete_insert (int n) {
if (verbose) printf("test_all_dup_delete_insert:%d\n", n); if (verbose) printf("test_all_dup_delete_insert:%d\n", n);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_all_dup_delete_insert.brt"; const char * const fname = "test_all_dup_delete_insert.brt";
int r; int r;
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, DB_DUP); r = db->set_flags(db, DB_DUP);
assert(r == 0); assert(r == 0);
...@@ -349,7 +359,7 @@ test_all_dup_delete_insert (int n) { ...@@ -349,7 +359,7 @@ test_all_dup_delete_insert (int n) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, DB_DUP); r = db->set_flags(db, DB_DUP);
assert(r == 0); assert(r == 0);
...@@ -391,20 +401,24 @@ test_all_dup_delete_insert (int n) { ...@@ -391,20 +401,24 @@ test_all_dup_delete_insert (int n) {
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = env->close(env, 0), assert(r == 0);
} }
static void static void
test_walk_empty (int n, int dup_mode) { test_walk_empty (int n, int dup_mode) {
if (verbose) printf("test_walk_empty:%d %d\n", n, dup_mode); if (verbose) printf("test_walk_empty:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_walk_empty.brt"; const char * const fname = "test_walk_empty.brt";
int r; int r;
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -424,7 +438,7 @@ test_walk_empty (int n, int dup_mode) { ...@@ -424,7 +438,7 @@ test_walk_empty (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -461,6 +475,7 @@ test_walk_empty (int n, int dup_mode) { ...@@ -461,6 +475,7 @@ test_walk_empty (int n, int dup_mode) {
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = env->close(env, 0), assert(r == 0);
} }
/* insert, close, delete, insert, search */ /* insert, close, delete, insert, search */
...@@ -469,14 +484,17 @@ void ...@@ -469,14 +484,17 @@ void
test_icdi_search (int n, int dup_mode) { test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt"; const char * const fname = "test_icdi_search.brt";
int r; int r;
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -505,7 +523,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -505,7 +523,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -550,6 +568,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -550,6 +568,7 @@ test_icdi_search (int n, int dup_mode) {
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = env->close(env, 0), assert(r == 0);
} }
/* insert, close, insert, search */ /* insert, close, insert, search */
...@@ -558,14 +577,17 @@ void ...@@ -558,14 +577,17 @@ void
test_ici_search (int n, int dup_mode) { test_ici_search (int n, int dup_mode) {
if (verbose) printf("test_ici_search:%d %d\n", n, dup_mode); if (verbose) printf("test_ici_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_ici_search.brt"; const char * const fname = "test_ici_search.brt";
int r; int r;
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -594,7 +616,7 @@ test_ici_search (int n, int dup_mode) { ...@@ -594,7 +616,7 @@ test_ici_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -632,6 +654,7 @@ test_ici_search (int n, int dup_mode) { ...@@ -632,6 +654,7 @@ test_ici_search (int n, int dup_mode) {
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = env->close(env, 0), assert(r == 0);
} }
static void static void
...@@ -653,14 +676,17 @@ void ...@@ -653,14 +676,17 @@ void
test_i0i1ci0_search (int n, int dup_mode) { test_i0i1ci0_search (int n, int dup_mode) {
if (verbose) printf("test_i0i1ci0_search:%d %d\n", n, dup_mode); if (verbose) printf("test_i0i1ci0_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_i0i1ci0.brt"; const char * const fname = "test_i0i1ci0.brt";
int r; int r;
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -684,7 +710,7 @@ test_i0i1ci0_search (int n, int dup_mode) { ...@@ -684,7 +710,7 @@ test_i0i1ci0_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -701,6 +727,7 @@ test_i0i1ci0_search (int n, int dup_mode) { ...@@ -701,6 +727,7 @@ test_i0i1ci0_search (int n, int dup_mode) {
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = env->close(env, 0), assert(r == 0);
} }
int int
......
...@@ -59,17 +59,20 @@ static void ...@@ -59,17 +59,20 @@ static void
test_dup_key (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) { test_dup_key (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) {
if (verbose) printf("test_dup_key: %d, %u, %d, %d\n", dup_mode, put_flags, rexpect, rexpectdupdup); if (verbose) printf("test_dup_key: %d, %u, %d, %d\n", dup_mode, put_flags, rexpect, rexpectdupdup);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_insert.brt"; const char * const fname = "test_insert.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db, stderr); db->set_errfile(db, stderr);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
if (maybe_do_db_dup_warning(r, dup_mode)) { if (maybe_do_db_dup_warning(r, dup_mode)) {
...@@ -106,23 +109,27 @@ test_dup_key (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) ...@@ -106,23 +109,27 @@ test_dup_key (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup)
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
static void static void
test_dup_dup (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) { test_dup_dup (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) {
if (verbose) printf("test_dup_dup: %d, %u, %d, %d\n", dup_mode, put_flags, rexpect, rexpectdupdup); if (verbose) printf("test_dup_dup: %d, %u, %d, %d\n", dup_mode, put_flags, rexpect, rexpectdupdup);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_insert.brt"; const char * const fname = "test_insert.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db, stderr); db->set_errfile(db, stderr);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
if (maybe_do_db_dup_warning(r, dup_mode)) { if (maybe_do_db_dup_warning(r, dup_mode)) {
...@@ -159,23 +166,27 @@ test_dup_dup (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup) ...@@ -159,23 +166,27 @@ test_dup_dup (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup)
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
static void static void
test_put_00_01_01 (int dup_mode, u_int32_t put_flags) { test_put_00_01_01 (int dup_mode, u_int32_t put_flags) {
if (verbose) printf("test_put_00_01_01: %d, %u\n", dup_mode, put_flags); if (verbose) printf("test_put_00_01_01: %d, %u\n", dup_mode, put_flags);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_insert.brt"; const char * const fname = "test_insert.brt";
int r, expectr; int r, expectr;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db, stderr); db->set_errfile(db, stderr);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
if (maybe_do_db_dup_warning(r, dup_mode)) { if (maybe_do_db_dup_warning(r, dup_mode)) {
...@@ -218,6 +229,7 @@ test_put_00_01_01 (int dup_mode, u_int32_t put_flags) { ...@@ -218,6 +229,7 @@ test_put_00_01_01 (int dup_mode, u_int32_t put_flags) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -16,17 +16,20 @@ static void ...@@ -16,17 +16,20 @@ static void
test_dup_flags (u_int32_t dup_flags) { test_dup_flags (u_int32_t dup_flags) {
if (verbose) printf("test_dup_flags:%u\n", dup_flags); if (verbose) printf("test_dup_flags:%u\n", dup_flags);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_dup_flags.brt"; const char * const fname = "test_dup_flags.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_flags); r = db->set_flags(db, dup_flags);
if (IS_TDB) { if (IS_TDB) {
if (r != 0 && dup_flags == DB_DUP) { if (r != 0 && dup_flags == DB_DUP) {
...@@ -49,23 +52,24 @@ test_dup_flags (u_int32_t dup_flags) { ...@@ -49,23 +52,24 @@ test_dup_flags (u_int32_t dup_flags) {
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
/* verify dup flags match */ /* verify dup flags match */
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666);
if (r == 0 && verbose) if (r == 0 && verbose)
printf("%s:%d: WARNING:open ok:dup_mode:%u\n", __FILE__, __LINE__, dup_flags); printf("%s:%d: WARNING:open ok:dup_mode:%u\n", __FILE__, __LINE__, dup_flags);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_flags); assert(r == 0); r = db->set_flags(db, dup_flags); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
/* verify nodesize match */ /* verify nodesize match */
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_flags); assert(r == 0); r = db->set_flags(db, dup_flags); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -47,10 +47,8 @@ static void ...@@ -47,10 +47,8 @@ static void
test_insert (int n, int dup_mode) { test_insert (int n, int dup_mode) {
if (verbose) printf("test_insert:%d %d\n", n, dup_mode); if (verbose) printf("test_insert:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_insert.brt"; const char * const fname = "test_insert.brt";
int r; int r;
int i; int i;
...@@ -58,7 +56,12 @@ test_insert (int n, int dup_mode) { ...@@ -58,7 +56,12 @@ test_insert (int n, int dup_mode) {
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -136,8 +139,8 @@ test_insert (int n, int dup_mode) { ...@@ -136,8 +139,8 @@ test_insert (int n, int dup_mode) {
r = cursor->c_close(cursor); r = cursor->c_close(cursor);
assert(r == 0); assert(r == 0);
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
/* verify dup keys are buffered in order in non-leaf nodes */ /* verify dup keys are buffered in order in non-leaf nodes */
...@@ -145,10 +148,8 @@ static void ...@@ -145,10 +148,8 @@ static void
test_nonleaf_insert (int n, int dup_mode) { test_nonleaf_insert (int n, int dup_mode) {
if (verbose) printf("test_nonleaf_insert:%d %d\n", n, dup_mode); if (verbose) printf("test_nonleaf_insert:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_nonleaf_insert.brt"; const char * const fname = "test_nonleaf_insert.brt";
int r; int r;
int i; int i;
...@@ -156,7 +157,12 @@ test_nonleaf_insert (int n, int dup_mode) { ...@@ -156,7 +157,12 @@ test_nonleaf_insert (int n, int dup_mode) {
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -185,7 +191,7 @@ test_nonleaf_insert (int n, int dup_mode) { ...@@ -185,7 +191,7 @@ test_nonleaf_insert (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -248,6 +254,7 @@ test_nonleaf_insert (int n, int dup_mode) { ...@@ -248,6 +254,7 @@ test_nonleaf_insert (int n, int dup_mode) {
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -63,17 +63,20 @@ static void ...@@ -63,17 +63,20 @@ static void
test_dup_next (int n, int dup_mode) { test_dup_next (int n, int dup_mode) {
if (verbose) printf("test_dup_next:%d %d\n", n, dup_mode); if (verbose) printf("test_dup_next:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_dup_next.brt"; const char * const fname = "test_dup_next.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
...@@ -116,6 +119,7 @@ test_dup_next (int n, int dup_mode) { ...@@ -116,6 +119,7 @@ test_dup_next (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -66,17 +66,20 @@ static void ...@@ -66,17 +66,20 @@ static void
test_icdi_search (int n, int dup_mode) { test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt"; const char * const fname = "test_icdi_search.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -98,7 +101,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -98,7 +101,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -129,8 +132,8 @@ test_icdi_search (int n, int dup_mode) { ...@@ -129,8 +132,8 @@ test_icdi_search (int n, int dup_mode) {
r = cursor->c_close(cursor); r = cursor->c_close(cursor);
assert(r == 0); assert(r == 0);
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
/* insert, close, insert, search */ /* insert, close, insert, search */
...@@ -138,17 +141,20 @@ static void ...@@ -138,17 +141,20 @@ static void
test_ici_search (int n, int dup_mode) { test_ici_search (int n, int dup_mode) {
if (verbose) printf("test_ici_search:%d %d\n", n, dup_mode); if (verbose) printf("test_ici_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_ici_search.brt"; const char * const fname = "test_ici_search.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -170,7 +176,7 @@ test_ici_search (int n, int dup_mode) { ...@@ -170,7 +176,7 @@ test_ici_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -199,8 +205,8 @@ test_ici_search (int n, int dup_mode) { ...@@ -199,8 +205,8 @@ test_ici_search (int n, int dup_mode) {
r = cursor->c_close(cursor); r = cursor->c_close(cursor);
assert(r == 0); assert(r == 0);
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
/* insert 0, insert 1, close, insert 0, search 0 */ /* insert 0, insert 1, close, insert 0, search 0 */
...@@ -208,14 +214,17 @@ static void ...@@ -208,14 +214,17 @@ static void
test_i0i1ci0_search (int n, int dup_mode) { test_i0i1ci0_search (int n, int dup_mode) {
if (verbose) printf("test_i0i1ci0_search:%d %d\n", n, dup_mode); if (verbose) printf("test_i0i1ci0_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_i0i1ci0.brt"; const char * const fname = "test_i0i1ci0.brt";
int r; int r;
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -239,7 +248,7 @@ test_i0i1ci0_search (int n, int dup_mode) { ...@@ -239,7 +248,7 @@ test_i0i1ci0_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -254,8 +263,8 @@ test_i0i1ci0_search (int n, int dup_mode) { ...@@ -254,8 +263,8 @@ test_i0i1ci0_search (int n, int dup_mode) {
/* verify dup search digs deep into the tree */ /* verify dup search digs deep into the tree */
expect_db_get(db, 0, 0); expect_db_get(db, 0, 0);
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
/* insert dup keys with data descending from n to 1 */ /* insert dup keys with data descending from n to 1 */
...@@ -263,17 +272,20 @@ static void ...@@ -263,17 +272,20 @@ static void
test_reverse_search (int n, int dup_mode) { test_reverse_search (int n, int dup_mode) {
if (verbose) printf("test_reverse_search:%d %d\n", n, dup_mode); if (verbose) printf("test_reverse_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_reverse_search.brt"; const char * const fname = "test_reverse_search.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -293,7 +305,7 @@ test_reverse_search (int n, int dup_mode) { ...@@ -293,7 +305,7 @@ test_reverse_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -316,8 +328,8 @@ test_reverse_search (int n, int dup_mode) { ...@@ -316,8 +328,8 @@ test_reverse_search (int n, int dup_mode) {
else else
expect_db_get(db, htonl(n), htonl(1)); expect_db_get(db, htonl(n), htonl(1));
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -42,10 +42,8 @@ static void ...@@ -42,10 +42,8 @@ static void
test_dupsort_delete (int n) { test_dupsort_delete (int n) {
if (verbose) printf("test_dupsort_delete:%d\n", n); if (verbose) printf("test_dupsort_delete:%d\n", n);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_dupsort_delete.brt"; const char * const fname = "test_dupsort_delete.brt";
int r; int r;
int i; int i;
...@@ -53,7 +51,12 @@ test_dupsort_delete (int n) { ...@@ -53,7 +51,12 @@ test_dupsort_delete (int n) {
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, DB_DUP + DB_DUPSORT); assert(r == 0); r = db->set_flags(db, DB_DUP + DB_DUPSORT); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -72,7 +75,7 @@ test_dupsort_delete (int n) { ...@@ -72,7 +75,7 @@ test_dupsort_delete (int n) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, DB_DUP + DB_DUPSORT); assert(r == 0); r = db->set_flags(db, DB_DUP + DB_DUPSORT); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
...@@ -94,6 +97,7 @@ test_dupsort_delete (int n) { ...@@ -94,6 +97,7 @@ test_dupsort_delete (int n) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -66,17 +66,20 @@ static void ...@@ -66,17 +66,20 @@ static void
test_dupsort_get (int n, int dup_mode) { test_dupsort_get (int n, int dup_mode) {
if (verbose) printf("test_dupsort_get:%d %d\n", n, dup_mode); if (verbose) printf("test_dupsort_get:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.dupsort.get.brt"; const char * const fname = "test.dupsort.get.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -93,7 +96,7 @@ test_dupsort_get (int n, int dup_mode) { ...@@ -93,7 +96,7 @@ test_dupsort_get (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
...@@ -115,6 +118,7 @@ test_dupsort_get (int n, int dup_mode) { ...@@ -115,6 +118,7 @@ test_dupsort_get (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -83,17 +83,20 @@ static void ...@@ -83,17 +83,20 @@ static void
test_icdi_search (int n, int dup_mode) { test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt"; const char * const fname = "test_icdi_search.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -110,7 +113,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -110,7 +113,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
...@@ -140,6 +143,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -140,6 +143,7 @@ test_icdi_search (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -83,17 +83,20 @@ static void ...@@ -83,17 +83,20 @@ static void
test_icdi_search (int n, int dup_mode) { test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt"; const char * const fname = "test_icdi_search.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -110,7 +113,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -110,7 +113,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
...@@ -140,6 +143,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -140,6 +143,7 @@ test_icdi_search (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -83,17 +83,20 @@ static void ...@@ -83,17 +83,20 @@ static void
test_icdi_search (int n, int dup_mode) { test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt"; const char * const fname = "test_icdi_search.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -110,7 +113,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -110,7 +113,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
...@@ -146,6 +149,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -146,6 +149,7 @@ test_icdi_search (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -83,17 +83,20 @@ static void ...@@ -83,17 +83,20 @@ static void
test_icdi_search (int n, int dup_mode) { test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt"; const char * const fname = "test_icdi_search.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -110,7 +113,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -110,7 +113,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
...@@ -147,6 +150,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -147,6 +150,7 @@ test_icdi_search (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -84,17 +84,20 @@ static void ...@@ -84,17 +84,20 @@ static void
test_icdi_search (int n, int dup_mode) { test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt"; const char * const fname = "test_icdi_search.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -111,7 +114,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -111,7 +114,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
...@@ -141,6 +144,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -141,6 +144,7 @@ test_icdi_search (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -93,16 +93,19 @@ test_icdi_search (int n, int dup_mode) { ...@@ -93,16 +93,19 @@ test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt"; const char * const fname = "test_icdi_search.brt";
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -119,7 +122,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -119,7 +122,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
...@@ -149,6 +152,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -149,6 +152,7 @@ test_icdi_search (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -93,16 +93,19 @@ test_icdi_search (int n, int dup_mode) { ...@@ -93,16 +93,19 @@ test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt"; const char * const fname = "test_icdi_search.brt";
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -119,7 +122,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -119,7 +122,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
...@@ -149,6 +152,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -149,6 +152,7 @@ test_icdi_search (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -33,8 +33,6 @@ static char annotated_envdir[]= ENVDIR " "; ...@@ -33,8 +33,6 @@ static char annotated_envdir[]= ENVDIR " ";
static void test_get_both(int n, int dup_mode, int op) { static void test_get_both(int n, int dup_mode, int op) {
if (verbose) printf("test_get_both_range:%d %d %d\n", n, dup_mode, op); if (verbose) printf("test_get_both_range:%d %d %d\n", n, dup_mode, op);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
char fname[sizeof(ENVDIR)+100]; char fname[sizeof(ENVDIR)+100];
snprintf(fname, sizeof(fname), "%s/test_icdi_search_brt", annotated_envdir); snprintf(fname, sizeof(fname), "%s/test_icdi_search_brt", annotated_envdir);
...@@ -50,7 +48,12 @@ static void test_get_both(int n, int dup_mode, int op) { ...@@ -50,7 +48,12 @@ static void test_get_both(int n, int dup_mode, int op) {
unlink(fname); unlink(fname);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ".", DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -105,6 +108,7 @@ static void test_get_both(int n, int dup_mode, int op) { ...@@ -105,6 +108,7 @@ static void test_get_both(int n, int dup_mode, int op) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -13,15 +13,18 @@ ...@@ -13,15 +13,18 @@
static void static void
test_get (int dup_mode) { test_get (int dup_mode) {
DB_ENV * const null_env = 0;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
DB *db;
DBT key,data; DBT key,data;
int fnamelen = sizeof(ENVDIR) + 30; int fnamelen = sizeof(ENVDIR) + 30;
char fname[fnamelen]; char fname[fnamelen];
int r; int r;
snprintf(fname, fnamelen, "%s/test%d.db", ENVDIR, dup_mode); snprintf(fname, fnamelen, "%s/test%d.db", ENVDIR, dup_mode);
r = db_create (&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ".", DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create (&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
dbt_init(&key, "a", 2); dbt_init(&key, "a", 2);
...@@ -29,7 +32,8 @@ test_get (int dup_mode) { ...@@ -29,7 +32,8 @@ test_get (int dup_mode) {
memset(&data, 0, sizeof(data)); memset(&data, 0, sizeof(data));
r = db->get(db, null_txn, &key, &data, 0); assert(r == 0); r = db->get(db, null_txn, &key, &data, 0); assert(r == 0);
assert(strcmp(data.data, "b")==0); assert(strcmp(data.data, "b")==0);
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -41,17 +41,20 @@ test_hsoc (int pagesize, int dup_mode) { ...@@ -41,17 +41,20 @@ test_hsoc (int pagesize, int dup_mode) {
int npp = pagesize / 16; int npp = pagesize / 16;
int n = npp + 13*npp/2; int n = npp + 13*npp/2;
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.hsoc.brt"; const char * const fname = "test.hsoc.brt";
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, pagesize); assert(r == 0); r = db->set_pagesize(db, pagesize); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -79,7 +82,7 @@ test_hsoc (int pagesize, int dup_mode) { ...@@ -79,7 +82,7 @@ test_hsoc (int pagesize, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
if (verbose) printf("reopen\n"); if (verbose) printf("reopen\n");
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, pagesize); assert(r == 0); r = db->set_pagesize(db, pagesize); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
......
...@@ -20,13 +20,16 @@ test_insert_delete_insert (int dup_mode) { ...@@ -20,13 +20,16 @@ test_insert_delete_insert (int dup_mode) {
if (verbose) printf("test_insert_delete_insert:%d\n", dup_mode); if (verbose) printf("test_insert_delete_insert:%d\n", dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.cursor.insert.delete.insert.brt"; const char * const fname = "test.cursor.insert.delete.insert.brt";
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -62,6 +65,7 @@ test_insert_delete_insert (int dup_mode) { ...@@ -62,6 +65,7 @@ test_insert_delete_insert (int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -15,14 +15,17 @@ static void ...@@ -15,14 +15,17 @@ static void
test_insert (int n, int dup_mode) { test_insert (int n, int dup_mode) {
if (verbose) printf("test_insert:%d %d\n", n, dup_mode); if (verbose) printf("test_insert:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.insert.brt"; const char * const fname = "test.insert.brt";
int r; int r;
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -39,8 +42,8 @@ test_insert (int n, int dup_mode) { ...@@ -39,8 +42,8 @@ test_insert (int n, int dup_mode) {
assert(r == 0); assert(r == 0);
} }
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -18,17 +18,20 @@ static void ...@@ -18,17 +18,20 @@ static void
test_key_size_limit (int dup_mode) { test_key_size_limit (int dup_mode) {
if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode); if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.rand.insert.brt"; const char * const fname = "test.rand.insert.brt";
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -66,25 +69,28 @@ test_key_size_limit (int dup_mode) { ...@@ -66,25 +69,28 @@ test_key_size_limit (int dup_mode) {
assert(bigest > 0); assert(bigest > 0);
if (verbose) printf("%s bigest %u\n", __FUNCTION__, bigest); if (verbose) printf("%s bigest %u\n", __FUNCTION__, bigest);
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
static void static void
test_data_size_limit (int dup_mode) { test_data_size_limit (int dup_mode) {
if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode); if (verbose > 1) printf("%s:%d\n", __FUNCTION__, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.rand.insert.brt"; const char * const fname = "test.rand.insert.brt";
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -121,8 +127,8 @@ test_data_size_limit (int dup_mode) { ...@@ -121,8 +127,8 @@ test_data_size_limit (int dup_mode) {
toku_free(v); toku_free(v);
if (verbose && bigest > 0) printf("%s bigest %u\n", __FUNCTION__, bigest); if (verbose && bigest > 0) printf("%s bigest %u\n", __FUNCTION__, bigest);
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -86,17 +86,20 @@ static void ...@@ -86,17 +86,20 @@ static void
test_icdi_search (int n, int dup_mode) { test_icdi_search (int n, int dup_mode) {
if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode); if (verbose) printf("test_icdi_search:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_icdi_search.brt"; const char * const fname = "test_icdi_search.brt";
int r; int r;
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -112,7 +115,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -112,7 +115,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = db_create(&db, null_env, 0); assert(r == 0); r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
...@@ -149,6 +152,7 @@ test_icdi_search (int n, int dup_mode) { ...@@ -149,6 +152,7 @@ test_icdi_search (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
......
...@@ -15,17 +15,20 @@ static void ...@@ -15,17 +15,20 @@ static void
test_rand_insert (int n, int dup_mode) { test_rand_insert (int n, int dup_mode) {
if (verbose) printf("test_rand_insert:%d %d\n", n, dup_mode); if (verbose) printf("test_rand_insert:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.rand.insert.brt"; const char * const fname = "test.rand.insert.brt";
int r; int r;
system("rm -rf " ENVDIR); system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0); r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -49,7 +52,7 @@ test_rand_insert (int n, int dup_mode) { ...@@ -49,7 +52,7 @@ test_rand_insert (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
assert(r == 0); assert(r == 0);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
assert(r == 0); assert(r == 0);
r = db->set_flags(db, dup_mode); r = db->set_flags(db, dup_mode);
assert(r == 0); assert(r == 0);
...@@ -77,8 +80,8 @@ test_rand_insert (int n, int dup_mode) { ...@@ -77,8 +80,8 @@ test_rand_insert (int n, int dup_mode) {
toku_free(val.data); toku_free(val.data);
} }
r = db->close(db, 0); r = db->close(db, 0); assert(r == 0);
assert(r == 0); r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -56,10 +56,8 @@ static void ...@@ -56,10 +56,8 @@ static void
test_reverse_compare (int n, int dup_flags) { test_reverse_compare (int n, int dup_flags) {
if (verbose) printf("test_reverse_compare:%d %d\n", n, dup_flags); if (verbose) printf("test_reverse_compare:%d %d\n", n, dup_flags);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/reverse.compare.db"; const char * const fname = "reverse.compare.db";
int r; int r;
int i; int i;
...@@ -68,7 +66,12 @@ test_reverse_compare (int n, int dup_flags) { ...@@ -68,7 +66,12 @@ test_reverse_compare (int n, int dup_flags) {
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0);
CKERR(r); CKERR(r);
r = db->set_flags(db, dup_flags); r = db->set_flags(db, dup_flags);
CKERR(r); CKERR(r);
...@@ -96,7 +99,7 @@ test_reverse_compare (int n, int dup_flags) { ...@@ -96,7 +99,7 @@ test_reverse_compare (int n, int dup_flags) {
/* reopen the database to force nonleaf buffering */ /* reopen the database to force nonleaf buffering */
r = db->close(db, 0); r = db->close(db, 0);
CKERR(r); CKERR(r);
r = db_create(&db, null_env, 0); r = db_create(&db, env, 0);
CKERR(r); CKERR(r);
r = db->set_flags(db, dup_flags); r = db->set_flags(db, dup_flags);
CKERR(r); CKERR(r);
...@@ -133,8 +136,8 @@ test_reverse_compare (int n, int dup_flags) { ...@@ -133,8 +136,8 @@ test_reverse_compare (int n, int dup_flags) {
r = cursor->c_close(cursor); r = cursor->c_close(cursor);
CKERR(r); CKERR(r);
r = db->close(db, 0); r = db->close(db, 0); CKERR(r);
CKERR(r); r = env->close(env, 0); CKERR(r);
} }
int int
......
...@@ -44,25 +44,36 @@ db_get (DB *db, int k, int expectv, int val_flags) { ...@@ -44,25 +44,36 @@ db_get (DB *db, int k, int expectv, int val_flags) {
static void static void
test_db_create (void) { test_db_create (void) {
int r; int r;
DB *db;
unlink(dbfile); unlink(dbfile);
r = db_create(&db, 0, 0); assert(r == 0);
DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ".", DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->open(db, 0, dbfile, dbname, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0); r = db->open(db, 0, dbfile, dbname, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0);
r = db_put(db, htonl(1), 1); assert(r == 0); r = db_put(db, htonl(1), 1); assert(r == 0);
r = db_get(db, htonl(1), 1, 0); assert(r == 0); r = db_get(db, htonl(1), 1, 0); assert(r == 0);
r = db_get(db, htonl(1), 1, DB_DBT_USERMEM); assert(r == 0); r = db_get(db, htonl(1), 1, DB_DBT_USERMEM); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
static void static void
test_db_thread (void) { test_db_thread (void) {
int r; int r;
DB *db;
unlink(dbfile); unlink(dbfile);
r = db_create(&db, 0, 0); assert(r == 0);
DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ".", DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db,0); // Turn off those annoying errors db->set_errfile(db,0); // Turn off those annoying errors
r = db->open(db, 0, dbfile, dbname, DB_BTREE, DB_CREATE + DB_THREAD, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0); r = db->open(db, 0, dbfile, dbname, DB_BTREE, DB_CREATE + DB_THREAD, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0);
r = db_put(db, htonl(1), 1); assert(r == 0); r = db_put(db, htonl(1), 1); assert(r == 0);
...@@ -71,6 +82,7 @@ test_db_thread (void) { ...@@ -71,6 +82,7 @@ test_db_thread (void) {
r = db_get(db, htonl(1), 1, DB_DBT_REALLOC); assert(r == 0); r = db_get(db, htonl(1), 1, DB_DBT_REALLOC); assert(r == 0);
r = db_get(db, htonl(1), 1, DB_DBT_USERMEM); assert(r == 0); r = db_get(db, htonl(1), 1, DB_DBT_USERMEM); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -41,17 +41,20 @@ static void ...@@ -41,17 +41,20 @@ static void
test_cursor_nonleaf_expand (int n, int reverse) { test_cursor_nonleaf_expand (int n, int reverse) {
if (verbose) printf("test_cursor_nonleaf_expand:%d %d\n", n, reverse); if (verbose) printf("test_cursor_nonleaf_expand:%d %d\n", n, reverse);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.insert.brt"; const char * const fname = "test.insert.brt";
int r; int r;
// r = system("rm -rf " ENVDIR); CKERR(r); // r = system("rm -rf " ENVDIR); CKERR(r);
// r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); // r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -77,6 +80,7 @@ test_cursor_nonleaf_expand (int n, int reverse) { ...@@ -77,6 +80,7 @@ test_cursor_nonleaf_expand (int n, int reverse) {
r = cursor0->c_close(cursor0); assert(r == 0); r = cursor0->c_close(cursor0); assert(r == 0);
r = cursorn->c_close(cursorn); assert(r == 0); r = cursorn->c_close(cursorn); assert(r == 0);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -40,22 +40,22 @@ walk (DB *db) { ...@@ -40,22 +40,22 @@ walk (DB *db) {
} }
static void static void
test_insert_zero_length (int n, int dup_mode, const char *dbname) { test_insert_zero_length (int n, int dup_mode, const char *fname) {
if (verbose) printf("test_insert_zero_length:%d %d\n", n, dup_mode); if (verbose) printf("test_insert_zero_length:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
int r; int r;
char fname[strlen(ENVDIR) + strlen("/") + strlen(dbname) + 1];
sprintf(fname, "%s/%s", ENVDIR, dbname);
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -95,25 +95,26 @@ test_insert_zero_length (int n, int dup_mode, const char *dbname) { ...@@ -95,25 +95,26 @@ test_insert_zero_length (int n, int dup_mode, const char *dbname) {
walk(db); walk(db);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
static void static void
test_insert_zero_length_keys (int n, int dup_mode, const char *dbname) { test_insert_zero_length_keys (int n, int dup_mode, const char *fname) {
if (verbose) printf("test_insert_zero_length_keys:%d %d\n", n, dup_mode); if (verbose) printf("test_insert_zero_length_keys:%d %d\n", n, dup_mode);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
int r; int r;
char fname[strlen(ENVDIR) + strlen("/") + strlen(dbname) + 1];
sprintf(fname, "%s/%s", ENVDIR, dbname);
r = system("rm -rf " ENVDIR); CKERR(r); r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); DB_ENV *env;
r = db_env_create(&env, 0); assert(r == 0);
r = env->open(env, ENVDIR, DB_CREATE+DB_PRIVATE+DB_INIT_MPOOL, 0); assert(r == 0);
DB *db;
r = db_create(&db, env, 0); assert(r == 0);
r = db->set_flags(db, dup_mode); assert(r == 0); r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0); r = db->set_pagesize(db, 4096); assert(r == 0);
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0); r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
...@@ -134,6 +135,7 @@ test_insert_zero_length_keys (int n, int dup_mode, const char *dbname) { ...@@ -134,6 +135,7 @@ test_insert_zero_length_keys (int n, int dup_mode, const char *dbname) {
walk(db); walk(db);
r = db->close(db, 0); assert(r == 0); r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
} }
int int
......
...@@ -3888,25 +3888,12 @@ static int locked_db_flatten(DB *db, DB_TXN *txn) { ...@@ -3888,25 +3888,12 @@ static int locked_db_flatten(DB *db, DB_TXN *txn) {
static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) { static int toku_db_create(DB ** db, DB_ENV * env, u_int32_t flags) {
int r; int r;
if (flags) return EINVAL; if (flags || env == NULL)
return EINVAL;
/* if the env already exists then add a ref to it
otherwise create one */ if (!env_opened(env))
if (env) { return EINVAL;
if (!env_opened(env)) env_add_ref(env);
return EINVAL;
env_add_ref(env);
} else {
r = toku_env_create(&env, 0);
if (r != 0)
return r;
r = toku_env_open(env, ".", DB_CREATE | DB_PRIVATE | DB_INIT_MPOOL, 0);
if (r != 0) {
env_unref(env);
return r;
}
assert(env_opened(env));
}
DB *MALLOC(result); DB *MALLOC(result);
if (result == 0) { if (result == 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment