Commit 20e019e6 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Get it to work on BDB and TDB. Refs #1802.

git-svn-id: file:///svn/toku/tokudb@12759 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2a861906
......@@ -14,18 +14,17 @@
DB_ENV *env;
DB *db;
const char dbname[] = "foo.db";
const int envflags = DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN;
const int envflags = DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG;
static void
open_em (void)
{
int r;
r = db_env_create(&env, 0); CKERR(r);
r = env->open(env, ENVDIR, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
r = db->open(db, NULL, dbname, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
r = db_env_create(&env, 0); CKERR(r);
r = env->open(env, ENVDIR, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
r = db->open(db, NULL, dbname, NULL, DB_BTREE, DB_CREATE, 0666); CKERR(r);
}
static void
......@@ -50,11 +49,11 @@ setup(void)
system("rm -rf " ENVDIR);
toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO);
int r;
r = db_env_create(&env, 0); CKERR(r);
r = env->open(env, ENVDIR, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
r = db->set_pagesize(db, 8192);
r = db->open(db, NULL, dbname, NULL, DB_BTREE, DB_AUTO_COMMIT|DB_CREATE, 0666); CKERR(r);
r = db_env_create(&env, 0); CKERR(r);
r = env->open(env, ENVDIR, envflags, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r = db_create(&db, env, 0); CKERR(r);
r = db->set_pagesize(db, 8192); CKERR(r);
r = db->open(db, NULL, dbname, NULL, DB_BTREE, DB_CREATE, 0666); CKERR(r);
}
char vdata[150];
......@@ -74,7 +73,11 @@ delete_n (u_int32_t ah)
u_int32_t an = htonl(ah);
DBT key = {.size = 4, .data=&an };
int r = db->del(db, NULL, &key, DB_DELETE_ANY);
#ifdef USE_BDB
assert(r==0 || r==DB_NOTFOUND);
#else
CKERR(r);
#endif
}
static void
......@@ -82,9 +85,10 @@ get_n (u_int32_t ah, int expect_r)
{
u_int32_t an = htonl(ah);
DBT key = {.size = 4, .data=&an };
DBT val = {.data=0};
DBT val = {.data=0, .flags = DB_DBT_MALLOC};
int r = db->get(db, NULL, &key, &val, 0);
assert(r==expect_r);
if (r==0) toku_free(val.data);
}
static void
......@@ -120,7 +124,6 @@ doit (void)
get_n((73-i) << 16, DB_NOTFOUND);
}
reopen_em(); // now a node is 9143 bytes
}
int test_main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
......
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