Commit bb78f478 authored by Rich Prohaska's avatar Rich Prohaska

txn parameter added to some brt functions. closes #316

git-svn-id: file:///svn/tokudb@1941 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0727c563
...@@ -1711,11 +1711,11 @@ static void test_brt_cursor_delete(int n, DB *db) { ...@@ -1711,11 +1711,11 @@ static void test_brt_cursor_delete(int n, DB *db) {
toku_free(key.data); toku_free(key.data);
toku_free(val.data); toku_free(val.data);
error = toku_brt_cursor_delete(cursor, 0); error = toku_brt_cursor_delete(cursor, 0, null_txn);
assert(error == 0); assert(error == 0);
} }
error = toku_brt_cursor_delete(cursor, 0); error = toku_brt_cursor_delete(cursor, 0, null_txn);
assert(error != 0); assert(error != 0);
error = toku_brt_cursor_close(cursor); error = toku_brt_cursor_close(cursor);
...@@ -1808,7 +1808,7 @@ static void test_brt_cursor_get_both(int n, DB *db) { ...@@ -1808,7 +1808,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
toku_free(key.data); toku_free(key.data);
toku_free(val.data); toku_free(val.data);
#endif #endif
error = toku_brt_cursor_delete(cursor, 0); error = toku_brt_cursor_delete(cursor, 0, null_txn);
assert(error == 0); assert(error == 0);
k = htonl(i); k = htonl(i);
...@@ -1819,7 +1819,7 @@ static void test_brt_cursor_get_both(int n, DB *db) { ...@@ -1819,7 +1819,7 @@ static void test_brt_cursor_get_both(int n, DB *db) {
assert(error == DB_NOTFOUND); assert(error == DB_NOTFOUND);
} }
error = toku_brt_cursor_delete(cursor, 0); error = toku_brt_cursor_delete(cursor, 0, null_txn);
assert(error != 0); assert(error != 0);
error = toku_brt_cursor_close(cursor); error = toku_brt_cursor_close(cursor);
...@@ -1945,7 +1945,7 @@ static void test_brt_delete_empty() { ...@@ -1945,7 +1945,7 @@ static void test_brt_delete_empty() {
DBT key; DBT key;
int k = htonl(1); int k = htonl(1);
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key); r = toku_brt_delete(t, &key, null_txn);
assert(r == 0); assert(r == 0);
r = toku_close_brt(t); assert(r==0); r = toku_close_brt(t); assert(r==0);
...@@ -1987,7 +1987,7 @@ static void test_brt_delete_present(int n) { ...@@ -1987,7 +1987,7 @@ static void test_brt_delete_present(int n) {
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
k = htonl(i); k = htonl(i);
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key); r = toku_brt_delete(t, &key, null_txn);
assert(r == 0); assert(r == 0);
} }
...@@ -2049,14 +2049,14 @@ static void test_brt_delete_not_present(int n) { ...@@ -2049,14 +2049,14 @@ static void test_brt_delete_not_present(int n) {
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
k = htonl(i); k = htonl(i);
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key); r = toku_brt_delete(t, &key, null_txn);
assert(r == 0); assert(r == 0);
} }
/* try to delete key n+1 not in the tree */ /* try to delete key n+1 not in the tree */
k = htonl(n+1); k = htonl(n+1);
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key); r = toku_brt_delete(t, &key, null_txn);
/* the delete may be buffered or may be executed on a leaf node, so the /* the delete may be buffered or may be executed on a leaf node, so the
return value depends */ return value depends */
if (verbose) printf("toku_brt_delete k=%d %d\n", k, r); if (verbose) printf("toku_brt_delete k=%d %d\n", k, r);
...@@ -2110,7 +2110,7 @@ static void test_brt_delete_cursor_first(int n) { ...@@ -2110,7 +2110,7 @@ static void test_brt_delete_cursor_first(int n) {
for (i=0; i<n-1; i++) { for (i=0; i<n-1; i++) {
k = htonl(i); k = htonl(i);
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key); r = toku_brt_delete(t, &key, null_txn);
assert(r == 0); assert(r == 0);
toku_init_dbt(&val); val.flags = DB_DBT_MALLOC; toku_init_dbt(&val); val.flags = DB_DBT_MALLOC;
...@@ -2187,7 +2187,7 @@ static void test_insert_delete_lookup(int n) { ...@@ -2187,7 +2187,7 @@ static void test_insert_delete_lookup(int n) {
if (n > 0) { if (n > 0) {
k = htonl(n-1); k = htonl(n-1);
toku_fill_dbt(&key, &k, sizeof k); toku_fill_dbt(&key, &k, sizeof k);
r = toku_brt_delete(t, &key); r = toku_brt_delete(t, &key, null_txn);
assert(r == 0); assert(r == 0);
k = htonl(n-1); k = htonl(n-1);
...@@ -2233,7 +2233,7 @@ void test_brt_delete_both(int n) { ...@@ -2233,7 +2233,7 @@ void test_brt_delete_both(int n) {
for (i=0; i<n; i += 2) { for (i=0; i<n; i += 2) {
k = htonl(0); v = htonl(i); k = htonl(0); v = htonl(i);
r = toku_brt_delete_both(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v)); assert(r == 0); r = toku_brt_delete_both(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &v, sizeof v), null_txn); assert(r == 0);
} }
#if 0 #if 0
...@@ -2247,7 +2247,7 @@ void test_brt_delete_both(int n) { ...@@ -2247,7 +2247,7 @@ void test_brt_delete_both(int n) {
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i)); assert(vv == (int) htonl(i));
if (val.data) free(val.data); if (val.data) free(val.data);
r = toku_brt_delete_both(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &vv, sizeof vv)); assert(r == 0); r = toku_brt_delete_both(t, toku_fill_dbt(&key, &k, sizeof k), toku_fill_dbt(&val, &vv, sizeof vv), null_txn); assert(r == 0);
} }
#endif #endif
...@@ -2353,7 +2353,7 @@ static void test_new_brt_cursor_first(int n, int dup_mode) { ...@@ -2353,7 +2353,7 @@ static void test_new_brt_cursor_first(int n, int dup_mode) {
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i)); assert(vv == (int) htonl(i));
r = toku_brt_cursor_delete(cursor, 0); assert(r == 0); r = toku_brt_cursor_delete(cursor, 0, null_txn); assert(r == 0);
} }
assert(i == n); assert(i == n);
...@@ -2408,7 +2408,7 @@ static void test_new_brt_cursor_last(int n, int dup_mode) { ...@@ -2408,7 +2408,7 @@ static void test_new_brt_cursor_last(int n, int dup_mode) {
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i)); assert(vv == (int) htonl(i));
r = toku_brt_cursor_delete(cursor, 0); assert(r == 0); r = toku_brt_cursor_delete(cursor, 0, null_txn); assert(r == 0);
} }
assert(i == -1); assert(i == -1);
...@@ -2585,7 +2585,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) { ...@@ -2585,7 +2585,7 @@ static void test_new_brt_cursor_current(int n, int dup_mode) {
memcpy(&vv, val.data, val.size); memcpy(&vv, val.data, val.size);
assert(vv == (int) htonl(i)); assert(vv == (int) htonl(i));
r = toku_brt_cursor_delete(cursor, 0); assert(r == 0); r = toku_brt_cursor_delete(cursor, 0, null_txn); assert(r == 0);
r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT, null_txn); assert(r == DB_KEYEMPTY); r = toku_brt_cursor_get(cursor, &key, &val, DB_CURRENT, null_txn); assert(r == DB_KEYEMPTY);
......
...@@ -1687,7 +1687,7 @@ int toku_brt_lookup (BRT brt, DBT *k, DBT *v) { ...@@ -1687,7 +1687,7 @@ int toku_brt_lookup (BRT brt, DBT *k, DBT *v) {
return r; return r;
} }
int toku_brt_delete(BRT brt, DBT *key) { int toku_brt_delete(BRT brt, DBT *key, TOKUTXN txn) {
int r; int r;
BRT_CMD brtcmd; BRT_CMD brtcmd;
DBT val; DBT val;
...@@ -1697,18 +1697,18 @@ int toku_brt_delete(BRT brt, DBT *key) { ...@@ -1697,18 +1697,18 @@ int toku_brt_delete(BRT brt, DBT *key) {
brtcmd.type = BRT_DELETE; brtcmd.type = BRT_DELETE;
brtcmd.u.id.key = key; brtcmd.u.id.key = key;
brtcmd.u.id.val = &val; brtcmd.u.id.val = &val;
r = brt_root_put_cmd(brt, &brtcmd, 0); r = brt_root_put_cmd(brt, &brtcmd, txn);
return r; return r;
} }
int toku_brt_delete_both(BRT brt, DBT *key, DBT *val) { int toku_brt_delete_both(BRT brt, DBT *key, DBT *val, TOKUTXN txn) {
int r; int r;
BRT_CMD brtcmd; BRT_CMD brtcmd;
brtcmd.type = BRT_DELETE_BOTH; brtcmd.type = BRT_DELETE_BOTH;
brtcmd.u.id.key = key; brtcmd.u.id.key = key;
brtcmd.u.id.val = val; brtcmd.u.id.val = val;
r = brt_root_put_cmd(brt, &brtcmd, 0); r = brt_root_put_cmd(brt, &brtcmd, txn);
return r; return r;
} }
...@@ -2292,16 +2292,16 @@ int toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, int get_flags, T ...@@ -2292,16 +2292,16 @@ int toku_brt_cursor_get (BRT_CURSOR cursor, DBT *key, DBT *val, int get_flags, T
return r; return r;
} }
int toku_brt_cursor_delete(BRT_CURSOR cursor, int flags) { int toku_brt_cursor_delete(BRT_CURSOR cursor, int flags, TOKUTXN txn) {
if ((flags & ~DB_DELETE_ANY) != 0) if ((flags & ~DB_DELETE_ANY) != 0)
return EINVAL; return EINVAL;
if (brt_cursor_not_set(cursor)) if (brt_cursor_not_set(cursor))
return EINVAL; return EINVAL;
int r = 0; int r = 0;
if (!(flags & DB_DELETE_ANY)) if (!(flags & DB_DELETE_ANY))
r = brt_cursor_current(cursor, DB_CURRENT, 0, 0, 0); r = brt_cursor_current(cursor, DB_CURRENT, 0, 0, txn);
if (r == 0) if (r == 0)
r = toku_brt_delete_both(cursor->brt, &cursor->key, &cursor->val); r = toku_brt_delete_both(cursor->brt, &cursor->key, &cursor->val, txn);
return r; return r;
} }
...@@ -27,8 +27,8 @@ int toku_brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags); ...@@ -27,8 +27,8 @@ int toku_brt_remove_subdb(BRT brt, const char *dbname, u_int32_t flags);
int toku_brt_insert (BRT, DBT *, DBT *, TOKUTXN); int toku_brt_insert (BRT, DBT *, DBT *, TOKUTXN);
int toku_brt_lookup (BRT brt, DBT *k, DBT *v); int toku_brt_lookup (BRT brt, DBT *k, DBT *v);
int toku_brt_delete (BRT brt, DBT *k); int toku_brt_delete (BRT brt, DBT *k, TOKUTXN);
int toku_brt_delete_both (BRT brt, DBT *k, DBT *v); int toku_brt_delete_both (BRT brt, DBT *k, DBT *v, TOKUTXN);
int toku_close_brt (BRT); int toku_close_brt (BRT);
int toku_dump_brt (BRT brt); int toku_dump_brt (BRT brt);
void brt_fsync (BRT); /* fsync, but don't clear the caches. */ void brt_fsync (BRT); /* fsync, but don't clear the caches. */
...@@ -49,7 +49,7 @@ int toku_verify_brt (BRT brt); ...@@ -49,7 +49,7 @@ int toku_verify_brt (BRT brt);
typedef struct brt_cursor *BRT_CURSOR; typedef struct brt_cursor *BRT_CURSOR;
int toku_brt_cursor (BRT, BRT_CURSOR*); int toku_brt_cursor (BRT, BRT_CURSOR*);
int toku_brt_cursor_get (BRT_CURSOR cursor, DBT *kbt, DBT *vbt, int brtc_flags, TOKUTXN); int toku_brt_cursor_get (BRT_CURSOR cursor, DBT *kbt, DBT *vbt, int brtc_flags, TOKUTXN);
int toku_brt_cursor_delete(BRT_CURSOR cursor, int flags); int toku_brt_cursor_delete(BRT_CURSOR cursor, int flags, TOKUTXN);
int toku_brt_cursor_close (BRT_CURSOR curs); int toku_brt_cursor_close (BRT_CURSOR curs);
typedef struct brtenv *BRTENV; typedef struct brtenv *BRTENV;
......
...@@ -960,7 +960,7 @@ static int toku_c_get_noassociate(DBC * c, DBT * key, DBT * data, u_int32_t flag ...@@ -960,7 +960,7 @@ static int toku_c_get_noassociate(DBC * c, DBT * key, DBT * data, u_int32_t flag
static int toku_c_del_noassociate(DBC * c, u_int32_t flags) { static int toku_c_del_noassociate(DBC * c, u_int32_t flags) {
HANDLE_PANICKED_DB(c->dbp); HANDLE_PANICKED_DB(c->dbp);
int r = toku_brt_cursor_delete(c->i->c, flags); int r = toku_brt_cursor_delete(c->i->c, flags, c->i->txn ? c->i->txn->i->tokutxn : 0);
return r; return r;
} }
...@@ -1202,7 +1202,7 @@ static int toku_db_del_noassociate(DB * db, DB_TXN * txn, DBT * key, u_int32_t f ...@@ -1202,7 +1202,7 @@ static int toku_db_del_noassociate(DB * db, DB_TXN * txn, DBT * key, u_int32_t f
toku_free(search_val.data); toku_free(search_val.data);
} }
//Do the actual deleting. //Do the actual deleting.
r = toku_brt_delete(db->i->brt, key); r = toku_brt_delete(db->i->brt, key, txn ? txn->i->tokutxn : 0);
return r; return r;
} }
......
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