Commit 90eee715 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

make {{{test_cursor_2}}} use an environment with {{{DB_THREAD}}} set, since...

make {{{test_cursor_2}}} use an environment with {{{DB_THREAD}}} set, since that the MySQL usage.  Addresses #538.

git-svn-id: file:///svn/tokudb@2828 c7de825b-a66e-492c-adef-691d508d4ae1
parent 953d0edf
...@@ -16,17 +16,19 @@ ...@@ -16,17 +16,19 @@
void test_cursor() { void test_cursor() {
if (verbose) printf("test_cursor\n"); if (verbose) printf("test_cursor\n");
DB_ENV * const null_env = 0; DB_ENV * env;
DB *db; DB *db;
DB_TXN * const null_txn = 0; DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test.cursor.brt"; const char * const fname = "test.cursor.brt";
int r; int r;
unlink(fname); unlink(fname);
/* create the dup database file */ /* create the dup database file */
r = db_create(&db, null_env, 0); assert(r == 0); r = db_env_create(&env, 0); assert(r == 0);
db->set_errfile(db,0); // Turn off those annoying errors r = env->open(env, ENVDIR, DB_CREATE|DB_INIT_MPOOL|DB_THREAD, 0777); CKERR(r);
r = db_create(&db, env, 0); assert(r == 0);
db->set_errfile(db,stderr); // 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);
int i; int i;
...@@ -47,23 +49,30 @@ void test_cursor() { ...@@ -47,23 +49,30 @@ void test_cursor() {
DBT k0; memset(&k0, 0, sizeof k0); DBT k0; memset(&k0, 0, sizeof k0);
DBT v0; memset(&v0, 0, sizeof v0); DBT v0; memset(&v0, 0, sizeof v0);
r = cursor[0]->c_get(cursor[0], &k0, &v0, DB_FIRST); assert(r == 0); r = cursor[0]->c_get(cursor[0], &k0, &v0, DB_FIRST); assert(r == 0);
if (verbose) {
printf("k0:%p:%d\n", k0.data, k0.size); printf("k0:%p:%d\n", k0.data, k0.size);
printf("v0:%p:%d\n", v0.data, v0.size); printf("v0:%p:%d\n", v0.data, v0.size);
}
DBT k1; memset(&k1, 0, sizeof k1); DBT k1; memset(&k1, 0, sizeof k1);
DBT v1; memset(&v1, 0, sizeof v1); DBT v1; memset(&v1, 0, sizeof v1);
r = cursor[1]->c_get(cursor[1], &k1, &v1, DB_FIRST); assert(r == 0); r = cursor[1]->c_get(cursor[1], &k1, &v1, DB_FIRST); assert(r == 0);
if (verbose) {
printf("k1:%p:%d\n", k1.data, k1.size); printf("k1:%p:%d\n", k1.data, k1.size);
printf("v1:%p:%d\n", v1.data, v1.size); printf("v1:%p:%d\n", v1.data, v1.size);
}
r = cursor[0]->c_get(cursor[0], &k0, &v0, DB_NEXT); assert(r == 0); r = cursor[0]->c_get(cursor[0], &k0, &v0, DB_NEXT); assert(r == 0);
if (verbose) {
printf("k0:%p:%d\n", k0.data, k0.size); printf("k0:%p:%d\n", k0.data, k0.size);
printf("v0:%p:%d\n", v0.data, v0.size); printf("v0:%p:%d\n", v0.data, v0.size);
}
r = cursor[0]->c_close(cursor[0]); assert(r == 0); r = cursor[0]->c_close(cursor[0]); assert(r == 0);
r = cursor[1]->c_close(cursor[1]); assert(r == 0); r = cursor[1]->c_close(cursor[1]); 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 main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
......
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