Commit 6a3b4d64 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Recompute the fingerprint for DBC->c_del(). Fixes #154.

git-svn-id: file:///svn/tokudb@1017 c7de825b-a66e-492c-adef-691d508d4ae1
parent e9a50167
......@@ -2948,7 +2948,7 @@ int toku_brt_cursor_delete(BRT_CURSOR cursor, int flags __attribute__((__unused_
BRTNODE node = cursor->path[cursor->path_len-1];
assert(node->height == 0);
int kvsize;
r = toku_pma_cursor_delete_under(cursor->pmacurs, &kvsize);
r = toku_pma_cursor_delete_under(cursor->pmacurs, &kvsize, node->rand4fingerprint, &node->local_fingerprint);
if (r == 0) {
node->u.l.n_bytes_in_buffer -= PMA_ITEM_OVERHEAD + KEY_VALUE_OVERHEAD + kvsize;
node->dirty = 1;
......
......@@ -1904,7 +1904,7 @@ static void test_pma_cursor_delete_under() {
int kvsize;
/* delete under an uninitialized cursor should fail */
error = toku_pma_cursor_delete_under(cursor, &kvsize);
error = toku_pma_cursor_delete_under(cursor, &kvsize, rand4fingerprint, &expect_fingerprint);
assert(error == DB_NOTFOUND);
DBT key, val;
......@@ -1937,11 +1937,11 @@ static void test_pma_cursor_delete_under() {
toku_free(val.data);
/* delete under should succeed */
error = toku_pma_cursor_delete_under(cursor, &kvsize);
error = toku_pma_cursor_delete_under(cursor, &kvsize, rand4fingerprint, &expect_fingerprint);
assert(error == 0);
/* 2nd delete under should fail */
error = toku_pma_cursor_delete_under(cursor, &kvsize);
error = toku_pma_cursor_delete_under(cursor, &kvsize, rand4fingerprint, &expect_fingerprint);
assert(error == DB_NOTFOUND);
}
assert(i == n);
......
......@@ -865,7 +865,7 @@ int toku_pma_cursor_set_range(PMA_CURSOR c, DBT *key) {
return r;
}
int toku_pma_cursor_delete_under(PMA_CURSOR c, int *kvsize) {
int toku_pma_cursor_delete_under(PMA_CURSOR c, int *kvsize, u_int32_t rand4sem, u_int32_t *fingerprint) {
int r = DB_NOTFOUND;
if (c->position >= 0) {
PMA pma = c->pma;
......@@ -874,6 +874,7 @@ int toku_pma_cursor_delete_under(PMA_CURSOR c, int *kvsize) {
if (kv_pair_valid(kv)) {
if (kvsize)
*kvsize = kv_pair_keylen(kv) + kv_pair_vallen(kv);
*fingerprint -= rand4sem*toku_calccrc32_kvpair (kv_pair_key_const(kv), kv_pair_keylen(kv), kv_pair_val_const(kv), kv_pair_vallen(kv));
pma->pairs[c->position] = kv_pair_set_deleted(kv);
r = 0;
}
......
......@@ -117,7 +117,7 @@ int toku_pma_cursor_set_key(PMA_CURSOR c, DBT *key);
int toku_pma_cursor_set_range(PMA_CURSOR c, DBT *key);
/* delete the key value pair under the cursor, return the size of the pair */
int toku_pma_cursor_delete_under(PMA_CURSOR c, int *kvsize);
int toku_pma_cursor_delete_under(PMA_CURSOR /*c*/, int */*kvsize*/, u_int32_t /*rand4sem*/, u_int32_t */*fingerprint*/);
int toku_pma_random_pick(PMA, bytevec *key, ITEMLEN *keylen, bytevec *data, ITEMLEN *datalen);
......
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