Commit 637ac1a3 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #307

Addresses #293
Bugfixes in locktree, selfread must NOT allow overlaps.


git-svn-id: file:///svn/tokudb@1880 c7de825b-a66e-492c-adef-691d508d4ae1
parent 19c20152
......@@ -199,8 +199,8 @@ static int __toku_lt_rt_dominates(toku_lock_tree* tree, toku_range* query,
assert(tree && query && rt && dominated);
BOOL allow_overlaps;
toku_range buffer[1];
unsigned buflen = sizeof(buffer) / sizeof(buffer[0]);
toku_range* buf = &buffer[0];
unsigned buflen = sizeof(buf) / sizeof(buf[0]);
unsigned numfound;
int r;
......@@ -255,8 +255,8 @@ static int __toku_lt_borderwrite_conflict(toku_lock_tree* tree, DB_TXN* self,
assert(rt);
toku_range buffer[2];
unsigned buflen = sizeof(buffer) / sizeof(buffer[0]);
toku_range* buf = &buffer[0];
unsigned buflen = sizeof(buf) / sizeof(buf[0]);
unsigned numfound;
int r;
......@@ -287,8 +287,8 @@ static int __toku_lt_meets(toku_lock_tree* tree, DB_TXN* self,
toku_range* query, toku_range_tree* rt, BOOL* met) {
assert(tree && self && query && rt && met);
toku_range buffer[1];
unsigned buflen = sizeof(buffer) / sizeof(buffer[0]);
toku_range* buf = &buffer[0];
unsigned buflen = sizeof(buf) / sizeof(buf[0]);
unsigned numfound;
int r;
BOOL allow_overlaps;
......@@ -670,7 +670,7 @@ r = toku_rt_create(&temp_tree->selfwrite,
assert(temp_tree->selfwrite);
//TODO: Remove this, and use multiples per transaction
r = toku_rt_create(&temp_tree->selfread,
__toku_lt_point_cmp, __toku_lt_txn_cmp, TRUE,
__toku_lt_point_cmp, __toku_lt_txn_cmp, FALSE,
user_malloc, user_free, user_realloc);
assert(temp_tree->selfread);
temp_tree->buflen = __toku_default_buflen;
......
......@@ -81,3 +81,10 @@ void toku_free(void* p) {
void* toku_realloc(void *ptr, size_t size) {
return realloc(ptr, size);
}
DBT *dbt_init(DBT *dbt, void *data, u_int32_t size) {
memset(dbt, 0, sizeof *dbt);
dbt->data = data;
dbt->size = size;
return dbt;
}
/* We are going to test whether create and close properly check their input. */
#include "test.h"
int r;
toku_lock_tree* lt = NULL;
DB* db = (DB*)1;
DB_TXN* txn = (DB_TXN*)1;
BOOL duplicates = FALSE;
int nums[100];
void setup_tree(BOOL dups) {
r = toku_lt_create(&lt, db, dups, dbcmp, dbcmp,
toku_malloc, toku_free, toku_realloc);
CKERR(r);
assert(lt);
}
void close_tree(void) {
assert(lt);
r = toku_lt_close(lt);
CKERR(r);
lt = NULL;
}
void runtest(BOOL dups) {
DBT _key_left;
DBT _key_right;
DBT _data_left;
DBT _data_right;
DBT* key_left = &_key_left;
DBT* key_right = &_key_right;
DBT* data_left = dups ? &_data_left : NULL;
DBT* data_right = dups ? &_data_right: NULL;
dbt_init (key_left, &nums[3], sizeof(nums[3]));
dbt_init (key_right, &nums[6], sizeof(nums[6]));
if (dups) {
dbt_init(data_left, &nums[3], sizeof(nums[3]));
dbt_init(data_left, &nums[6], sizeof(nums[6]));
}
setup_tree(dups);
r = toku_lt_acquire_range_read_lock(lt, txn, key_left, data_left,
key_right, data_right);
CKERR(r);
close_tree();
setup_tree(dups);
r = toku_lt_acquire_read_lock(lt, txn, key_left, data_left);
CKERR(r);
close_tree();
}
int main(int argc, const char *argv[]) {
int i;
for (i = 0; i < sizeof(nums)/sizeof(nums[0]); i++) nums[i] = i;
runtest(FALSE);
runtest(TRUE);
return 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