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) {
// Map filenum to brt
// 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 cf_tuple {
FILENUM filenum;
......
......@@ -147,6 +147,7 @@ TDB_TESTS_THAT_SHOULD_FAIL= \
test_groupcommit_count \
test944 \
test_truncate_txn_abort \
test_db_no_env \
#\ ends prev line
ifneq ($(OS_CHOICE),windows)
TDB_TESTS_THAT_SHOULD_FAIL+= \
......
......@@ -14,8 +14,6 @@
static void
test_upgrade_from_10 (void) {
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
int r;
......@@ -25,7 +23,12 @@ test_upgrade_from_10 (void) {
const int PAGESIZE=1024;
/* 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);
r = db->set_pagesize(db, PAGESIZE);
assert(r == 0);
......@@ -104,8 +107,8 @@ test_upgrade_from_10 (void) {
c->c_close(c);
assert(num_found == num_leafentries + num_insert_messages - 2); //le_provdels should not show up
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
......
......@@ -23,13 +23,16 @@ static void
test_cursor_current (void) {
if (verbose) printf("test_cursor_current\n");
DB_ENV * const null_env = 0;
DB *db;
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;
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
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); CKERR(r);
......@@ -84,6 +87,7 @@ test_cursor_current (void) {
r = cursor->c_close(cursor); CKERR(r);
r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); CKERR(r);
}
static void
......@@ -97,19 +101,23 @@ static void
test_reopen (void) {
if (verbose) printf("test_reopen\n");
DB_ENV * const null_env = 0;
DB *db;
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;
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
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); CKERR(r);
db_get(db, 1, 1, DB_NOTFOUND);
r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); CKERR(r);
}
int
......
......@@ -50,18 +50,20 @@ test_cursor_delete (int dup_mode) {
int npp = pagesize/elementsize;
int n = 16*npp; /* build a 2 level tree */
DB_ENV * const null_env = 0;
DB *db;
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;
r = system("rm -rf " ENVDIR); assert(r == 0);
r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
/* 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
r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, pagesize); assert(r == 0);
......@@ -88,6 +90,7 @@ test_cursor_delete (int dup_mode) {
r = cursor->c_close(cursor); 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 */
......@@ -102,17 +105,20 @@ test_cursor_delete_dupsort (void) {
int npp = pagesize/elementsize;
int n = 16*npp; /* build a 2 level tree */
DB_ENV * const null_env = 0;
DB *db;
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;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
/* 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
r = db->set_flags(db, DB_DUP + DB_DUPSORT); assert(r == 0);
r = db->set_pagesize(db, pagesize); assert(r == 0);
......@@ -151,6 +157,7 @@ test_cursor_delete_dupsort (void) {
r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -16,16 +16,19 @@ static void
test_cursor_flags (int cursor_flags, int 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;
const char * const fname = ENVDIR "/" "test.cursor.delete.brt";
const char * const fname = "test.cursor.delete.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
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
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) {
}
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -49,17 +49,20 @@ static void
test_cursor_nonleaf_expand (int n, int 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;
const char * const fname = ENVDIR "/" "test.insert.brt";
const char * const fname = "test.insert.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* 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->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) {
r = cursor0->c_close(cursor0); assert(r == 0);
r = cursorn->c_close(cursorn); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -37,17 +37,20 @@ static void
test_cursor_sticky (int n, int 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;
const char * const fname = ENVDIR "/" "test_cursor_sticky.brt";
const char * const fname = "test_cursor_sticky.brt";
int r;
r = system("rm -rf " ENVDIR); assert(r == 0);
r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
/* 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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
......
......@@ -16,42 +16,46 @@
int
test_main(int argc, char *argv[]) {
parse_args(argc, argv);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
const char * const fname = "test.already.exists.brt";
int r;
system("rm -rf " ENVDIR);
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
// 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->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
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); 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
r = db->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); 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
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_EXCL, 0666);
assert(r == EINVAL);
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
r = db->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE | DB_EXCL, 0666);
assert(r == EEXIST);
r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); CKERR(r);
return 0;
}
......@@ -28,7 +28,8 @@ setup(void) {
system("rm -rf " ENVDIR);
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 */
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);
......@@ -54,6 +55,7 @@ close_dbs (void) {
int r;
r = db->close(db, 0); CKERR(r);
r = dbenv->close(dbenv, 0); CKERR(r);
}
int
......
......@@ -45,17 +45,20 @@ static void
test_db_delboth (int n, int 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;
const char * const fname = ENVDIR "/" "test.db.delete.brt";
const char * const fname = "test.db.delete.brt";
int r;
system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* 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);
r = db->set_flags(db, dup_mode);
CKERR(r);
......@@ -72,7 +75,7 @@ test_db_delboth (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */
r = db->close(db, 0);
CKERR(r);
r = db_create(&db, null_env, 0);
r = db_create(&db, env, 0);
CKERR(r);
r = db->set_flags(db, dup_mode);
CKERR(r);
......@@ -156,8 +159,8 @@ test_db_delboth (int n, int dup_mode) {
expect_db_getboth(db, htonl(i), htonl(i+1), DB_NOTFOUND);
}
r = db->close(db, 0);
CKERR(r);
r = db->close(db, 0); CKERR(r);
r = env->close(env, 0); CKERR(r);
}
#endif //USE_TDB
......
......@@ -39,17 +39,20 @@ static void
test_db_delete (int n, int 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;
const char * const fname = ENVDIR "/" "test.db.delete.brt";
const char * const fname = "test.db.delete.brt";
int r;
system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -66,7 +69,7 @@ test_db_delete (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */
r = db->close(db, 0);
assert(r == 0);
r = db_create(&db, null_env, 0);
r = db_create(&db, env, 0);
assert(r == 0);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -97,25 +100,28 @@ test_db_delete (int n, int dup_mode) {
#endif
#endif
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
test_db_get_datasize0 (void) {
if (verbose) printf("test_db_get_datasize0\n");
DB_ENV * const null_env = 0;
DB *db;
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;
system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* 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);
r = db->set_pagesize(db, 4096);
assert(r == 0);
......@@ -130,8 +136,8 @@ test_db_get_datasize0 (void) {
assert(r == 0);
toku_free(val.data);
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
......
......@@ -48,6 +48,8 @@ setup (u_int32_t flags) {
system("rm -rf " ENVDIR);
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
/* 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);
dbp->set_errfile(dbp,0); // Turn off those annoying errors
if (flags) {
......@@ -60,6 +62,7 @@ static void
close_dbs (void) {
int r;
r = dbp->close(dbp, 0); CKERR(r);
r = dbenv->close(dbenv, 0); CKERR(r);
}
static void
......
......@@ -3,11 +3,9 @@
#include "test.h"
#include <fcntl.h>
DB_ENV * const null_env = 0;
DB *db1, *db2;
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) {
int r;
......@@ -15,15 +13,21 @@ static void test_db_remove (void) {
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
// 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->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);
// 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);
#ifdef USE_TDB
assert(r!=0);
......@@ -32,6 +36,7 @@ static void test_db_remove (void) {
#endif
r = db1->close(db1, 0); assert(r==0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -16,21 +16,25 @@ static void
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);
DB_ENV * const null_env = 0;
DB *db;
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;
r = system("rm -rf " ENVDIR); CKERR(r);
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
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->set_flags(db, flags2); assert(r == expectr2);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -19,7 +19,7 @@ create_db(char *name) {
char fullname[strlen(name) + sizeof(ENVDIR) + sizeof("/")];
sprintf(fullname, "%s/%s", ENVDIR, name);
int r;
r=db_create(&db, NULL, 0);
r=db_create(&db, env, 0);
CKERR(r);
r=db->open(db, NULL, fullname, NULL, DB_BTREE, DB_CREATE, 0666);
CKERR(r);
......@@ -36,7 +36,7 @@ delete_db(char *name) {
r = toku_stat(fullname, &buf);
CKERR(r);
r=db_create(&db, NULL, 0);
r=db_create(&db, env, 0);
CKERR(r);
r=db->remove(db, fullname, NULL, 0);
CKERR(r);
......@@ -55,6 +55,10 @@ test_main (int UU(argc), char UU(*argv[])) {
CKERR(r);
system("cp test_dbremove_old.dir/* "ENVDIR);
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.
char *unnamed_db = "version_now_unnamed.tokudb";
......
This diff is collapsed.
......@@ -59,17 +59,20 @@ static void
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);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_insert.brt";
const char * const fname = "test_insert.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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);
r = db->set_flags(db, 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)
r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
static void
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);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_insert.brt";
const char * const fname = "test_insert.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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);
r = db->set_flags(db, 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)
r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
static void
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);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_insert.brt";
const char * const fname = "test_insert.brt";
int r, expectr;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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);
r = db->set_flags(db, 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) {
r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -16,17 +16,20 @@ static void
test_dup_flags (u_int32_t 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;
const char * const fname = ENVDIR "/" "test_dup_flags.brt";
const char * const fname = "test_dup_flags.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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);
if (IS_TDB) {
if (r != 0 && dup_flags == DB_DUP) {
......@@ -49,23 +52,24 @@ test_dup_flags (u_int32_t dup_flags) {
r = db->close(db, 0); assert(r == 0);
/* 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);
if (r == 0 && verbose)
printf("%s:%d: WARNING:open ok:dup_mode:%u\n", __FILE__, __LINE__, dup_flags);
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->open(db, null_txn, fname, "main", DB_BTREE, 0, 0666); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
/* 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_pagesize(db, 4096); 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 = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -47,10 +47,8 @@ static void
test_insert (int n, int 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;
const char * const fname = ENVDIR "/" "test_insert.brt";
const char * const fname = "test_insert.brt";
int r;
int i;
......@@ -58,7 +56,12 @@ test_insert (int n, int dup_mode) {
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -136,8 +139,8 @@ test_insert (int n, int dup_mode) {
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);
}
/* verify dup keys are buffered in order in non-leaf nodes */
......@@ -145,10 +148,8 @@ static void
test_nonleaf_insert (int n, int 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;
const char * const fname = ENVDIR "/" "test_nonleaf_insert.brt";
const char * const fname = "test_nonleaf_insert.brt";
int r;
int i;
......@@ -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);
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -185,7 +191,7 @@ test_nonleaf_insert (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */
r = db->close(db, 0);
assert(r == 0);
r = db_create(&db, null_env, 0);
r = db_create(&db, env, 0);
assert(r == 0);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -248,6 +254,7 @@ test_nonleaf_insert (int n, int dup_mode) {
r = db->close(db, 0);
assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -63,17 +63,20 @@ static void
test_dup_next (int n, int 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;
const char * const fname = ENVDIR "/" "test_dup_next.brt";
const char * const fname = "test_dup_next.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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
r = db->set_flags(db, dup_mode); assert(r == 0);
r = db->set_pagesize(db, 4096); assert(r == 0);
......@@ -116,6 +119,7 @@ test_dup_next (int n, int dup_mode) {
r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -66,17 +66,20 @@ static void
test_icdi_search (int n, int 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;
const char * const fname = ENVDIR "/" "test_icdi_search.brt";
const char * const fname = "test_icdi_search.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -98,7 +101,7 @@ test_icdi_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */
r = db->close(db, 0);
assert(r == 0);
r = db_create(&db, null_env, 0);
r = db_create(&db, env, 0);
assert(r == 0);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -129,8 +132,8 @@ test_icdi_search (int n, int dup_mode) {
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, close, insert, search */
......@@ -138,17 +141,20 @@ static void
test_ici_search (int n, int 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;
const char * const fname = ENVDIR "/" "test_ici_search.brt";
const char * const fname = "test_ici_search.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -170,7 +176,7 @@ test_ici_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */
r = db->close(db, 0);
assert(r == 0);
r = db_create(&db, null_env, 0);
r = db_create(&db, env, 0);
assert(r == 0);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -199,8 +205,8 @@ test_ici_search (int n, int dup_mode) {
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 0, insert 1, close, insert 0, search 0 */
......@@ -208,14 +214,17 @@ static void
test_i0i1ci0_search (int n, int 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;
const char * const fname = ENVDIR "/" "test_i0i1ci0.brt";
const char * const fname = "test_i0i1ci0.brt";
int r;
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -239,7 +248,7 @@ test_i0i1ci0_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */
r = db->close(db, 0);
assert(r == 0);
r = db_create(&db, null_env, 0);
r = db_create(&db, env, 0);
assert(r == 0);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -254,8 +263,8 @@ test_i0i1ci0_search (int n, int dup_mode) {
/* verify dup search digs deep into the tree */
expect_db_get(db, 0, 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 dup keys with data descending from n to 1 */
......@@ -263,17 +272,20 @@ static void
test_reverse_search (int n, int 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;
const char * const fname = ENVDIR "/" "test_reverse_search.brt";
const char * const fname = "test_reverse_search.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -293,7 +305,7 @@ test_reverse_search (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */
r = db->close(db, 0);
assert(r == 0);
r = db_create(&db, null_env, 0);
r = db_create(&db, env, 0);
assert(r == 0);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -316,8 +328,8 @@ test_reverse_search (int n, int dup_mode) {
else
expect_db_get(db, htonl(n), htonl(1));
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
......
......@@ -42,10 +42,8 @@ static void
test_dupsort_delete (int n) {
if (verbose) printf("test_dupsort_delete:%d\n", n);
DB_ENV * const null_env = 0;
DB *db;
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 i;
......@@ -53,7 +51,12 @@ test_dupsort_delete (int n) {
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
/* reopen the database to force nonleaf buffering */
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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -66,17 +66,20 @@ static void
test_dupsort_get (int n, int 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;
const char * const fname = ENVDIR "/" "test.dupsort.get.brt";
const char * const fname = "test.dupsort.get.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
/* reopen the database to force nonleaf buffering */
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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); 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
test_icdi_search (int n, int 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;
const char * const fname = ENVDIR "/" "test_icdi_search.brt";
const char * const fname = "test_icdi_search.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
/* reopen the database to force nonleaf buffering */
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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); 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
test_icdi_search (int n, int 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;
const char * const fname = ENVDIR "/" "test_icdi_search.brt";
const char * const fname = "test_icdi_search.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
/* reopen the database to force nonleaf buffering */
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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); 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
test_icdi_search (int n, int 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;
const char * const fname = ENVDIR "/" "test_icdi_search.brt";
const char * const fname = "test_icdi_search.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
/* reopen the database to force nonleaf buffering */
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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); 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
test_icdi_search (int n, int 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;
const char * const fname = ENVDIR "/" "test_icdi_search.brt";
const char * const fname = "test_icdi_search.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
/* reopen the database to force nonleaf buffering */
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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); 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
test_icdi_search (int n, int 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;
const char * const fname = ENVDIR "/" "test_icdi_search.brt";
const char * const fname = "test_icdi_search.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
/* reopen the database to force nonleaf buffering */
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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); 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) {
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;
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 = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
/* reopen the database to force nonleaf buffering */
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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); 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) {
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;
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 = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
/* reopen the database to force nonleaf buffering */
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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); 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 " ";
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);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
char fname[sizeof(ENVDIR)+100];
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) {
unlink(fname);
/* 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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
......
......@@ -13,15 +13,18 @@
static void
test_get (int dup_mode) {
DB_ENV * const null_env = 0;
DB_TXN * const null_txn = 0;
DB *db;
DBT key,data;
int fnamelen = sizeof(ENVDIR) + 30;
char fname[fnamelen];
int r;
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->open(db, null_txn, fname, "main", DB_BTREE, DB_CREATE, 0666); assert(r == 0);
dbt_init(&key, "a", 2);
......@@ -29,7 +32,8 @@ test_get (int dup_mode) {
memset(&data, 0, sizeof(data));
r = db->get(db, null_txn, &key, &data, 0); assert(r == 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
......
......@@ -41,17 +41,20 @@ test_hsoc (int pagesize, int dup_mode) {
int npp = pagesize / 16;
int n = npp + 13*npp/2;
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.hsoc.brt";
const char * const fname = "test.hsoc.brt";
int r;
system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* 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_pagesize(db, pagesize); 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) {
/* reopen the database to force nonleaf buffering */
if (verbose) printf("reopen\n");
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_pagesize(db, pagesize); 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) {
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;
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 */
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->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) {
r = cursor->c_close(cursor); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -15,14 +15,17 @@ static void
test_insert (int n, int 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;
const char * const fname = ENVDIR "/" "test.insert.brt";
const char * const fname = "test.insert.brt";
int r;
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -39,8 +42,8 @@ test_insert (int n, int dup_mode) {
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
......
......@@ -18,17 +18,20 @@ static void
test_key_size_limit (int 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;
const char * const fname = ENVDIR "/" "test.rand.insert.brt";
const char * const fname = "test.rand.insert.brt";
int r;
system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -66,25 +69,28 @@ test_key_size_limit (int dup_mode) {
assert(bigest > 0);
if (verbose) printf("%s bigest %u\n", __FUNCTION__, bigest);
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
test_data_size_limit (int 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;
const char * const fname = ENVDIR "/" "test.rand.insert.brt";
const char * const fname = "test.rand.insert.brt";
int r;
system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -121,8 +127,8 @@ test_data_size_limit (int dup_mode) {
toku_free(v);
if (verbose && bigest > 0) printf("%s bigest %u\n", __FUNCTION__, bigest);
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
......
......@@ -86,17 +86,20 @@ static void
test_icdi_search (int n, int 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;
const char * const fname = ENVDIR "/" "test_icdi_search.brt";
const char * const fname = "test_icdi_search.brt";
int r;
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
/* reopen the database to force nonleaf buffering */
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_pagesize(db, 4096); 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) {
r = cursor->c_close(cursor); 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
test_rand_insert (int n, int 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;
const char * const fname = ENVDIR "/" "test.rand.insert.brt";
const char * const fname = "test.rand.insert.brt";
int r;
system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
/* 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);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -49,7 +52,7 @@ test_rand_insert (int n, int dup_mode) {
/* reopen the database to force nonleaf buffering */
r = db->close(db, 0);
assert(r == 0);
r = db_create(&db, null_env, 0);
r = db_create(&db, env, 0);
assert(r == 0);
r = db->set_flags(db, dup_mode);
assert(r == 0);
......@@ -77,8 +80,8 @@ test_rand_insert (int n, int dup_mode) {
toku_free(val.data);
}
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
......
......@@ -56,10 +56,8 @@ static void
test_reverse_compare (int n, int 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;
const char * const fname = ENVDIR "/reverse.compare.db";
const char * const fname = "reverse.compare.db";
int r;
int i;
......@@ -68,7 +66,12 @@ test_reverse_compare (int n, int dup_flags) {
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
/* 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);
r = db->set_flags(db, dup_flags);
CKERR(r);
......@@ -96,7 +99,7 @@ test_reverse_compare (int n, int dup_flags) {
/* reopen the database to force nonleaf buffering */
r = db->close(db, 0);
CKERR(r);
r = db_create(&db, null_env, 0);
r = db_create(&db, env, 0);
CKERR(r);
r = db->set_flags(db, dup_flags);
CKERR(r);
......@@ -133,8 +136,8 @@ test_reverse_compare (int n, int dup_flags) {
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);
}
int
......
......@@ -44,25 +44,36 @@ db_get (DB *db, int k, int expectv, int val_flags) {
static void
test_db_create (void) {
int r;
DB *db;
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
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_get(db, htonl(1), 1, 0); 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 = env->close(env, 0); assert(r == 0);
}
static void
test_db_thread (void) {
int r;
DB *db;
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
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);
......@@ -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_USERMEM); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -41,17 +41,20 @@ static void
test_cursor_nonleaf_expand (int n, int 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;
const char * const fname = ENVDIR "/" "test.insert.brt";
const char * const fname = "test.insert.brt";
int r;
// r = system("rm -rf " ENVDIR); CKERR(r);
// r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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->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) {
r = cursor0->c_close(cursor0); assert(r == 0);
r = cursorn->c_close(cursorn); assert(r == 0);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -40,22 +40,22 @@ walk (DB *db) {
}
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);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
int r;
char fname[strlen(ENVDIR) + strlen("/") + strlen(dbname) + 1];
sprintf(fname, "%s/%s", ENVDIR, dbname);
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
walk(db);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
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);
DB_ENV * const null_env = 0;
DB *db;
DB_TXN * const null_txn = 0;
int r;
char fname[strlen(ENVDIR) + strlen("/") + strlen(dbname) + 1];
sprintf(fname, "%s/%s", ENVDIR, dbname);
r = system("rm -rf " ENVDIR); CKERR(r);
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
/* 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_pagesize(db, 4096); 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) {
walk(db);
r = db->close(db, 0); assert(r == 0);
r = env->close(env, 0); assert(r == 0);
}
int
......
......@@ -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) {
int r;
if (flags) return EINVAL;
/* if the env already exists then add a ref to it
otherwise create one */
if (env) {
if (!env_opened(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));
}
if (flags || env == NULL)
return EINVAL;
if (!env_opened(env))
return EINVAL;
env_add_ref(env);
DB *MALLOC(result);
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