Commit fbcf218f authored by Yoni Fogel's avatar Yoni Fogel

Addresses #293

Added checks for left > right,
and added additional needed EINVAL checks.

git-svn-id: file:///svn/tokudb@1864 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2154fc6b
......@@ -626,7 +626,8 @@ int toku_lt_create(toku_lock_tree** ptree, DB* db, BOOL duplicates,
void* (*user_malloc) (size_t),
void (*user_free) (void*),
void* (*user_realloc)(void*, size_t)) {
if (!ptree || !db || !compare_fun || !dup_compare) return EINVAL;
if (!ptree || !db || !compare_fun || !dup_compare ||
!user_malloc || !user_free || !user_realloc) return EINVAL;
int r;
toku_lock_tree* temp_tree =(toku_lock_tree*)user_malloc(sizeof(*temp_tree));
......@@ -719,6 +720,7 @@ int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB_TXN* txn,
if (tree->duplicates && key_right != data_right &&
__toku_lt_is_infinite(key_right)) return EINVAL;
int r;
toku_point left;
toku_point right;
......@@ -727,6 +729,11 @@ int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB_TXN* txn,
__toku_init_point(&left, tree, key_left, data_left);
__toku_init_point(&right, tree, key_right, data_right);
/* Verify left <= right. */
if ((key_left != key_right || data_left != data_right) &&
__toku_lt_point_cmp(&left, &right) > 0) return EDOM;
__toku_init_query(&query, &left, &right);
/*
......
......@@ -67,7 +67,7 @@ int __toku_lt_point_cmp(void* a, void* b);
\param user_realloc A user provided realloc(3) function.
* Returns:
* 0: Success
* EINVAL: If (ptree == NULL || db == NULL).
* EINVAL: If any pointer parameter is NULL.
* FutureChecks: Try to return EINVAL for already opened db,
* or already closed db.
* May return other errors due to system calls.
......@@ -163,7 +163,7 @@ int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB_TXN* txn,
* (tree->db is dupsort && key_right != data_right &&
* (key_right == toku_lt_infinity ||
* key_right == toku_lt_neg_infinity))
* ERANGE: In a DB_DUPSORT db:
* EDOM: In a DB_DUPSORT db:
* If (key_left, data_left) > (key_right, data_right) or
* In a nodup db: if (key_left) > (key_right)
* (According to the db's comparison functions.
......
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