Commit c1a5341f authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4618], [t:4631], make fix

git-svn-id: file:///svn/toku/tokudb@41259 c7de825b-a66e-492c-adef-691d508d4ae1
parent 78c9db83
...@@ -426,6 +426,11 @@ msg_init_empty_ule(ULE ule, BRT_MSG msg) { ...@@ -426,6 +426,11 @@ msg_init_empty_ule(ULE ule, BRT_MSG msg) {
ule_init_empty_ule(ule, keylen, keyp); ule_init_empty_ule(ule, keylen, keyp);
} }
static void
update_ule_key(ULE ule, BRT_MSG msg) {
ule->keylen = brt_msg_get_keylen(msg);
ule->keyp = brt_msg_get_key(msg);
}
// Purpose is to modify the unpacked leafentry in our private workspace. // Purpose is to modify the unpacked leafentry in our private workspace.
// //
...@@ -446,6 +451,11 @@ msg_modify_ule(ULE ule, BRT_MSG msg) { ...@@ -446,6 +451,11 @@ msg_modify_ule(ULE ule, BRT_MSG msg) {
//fall through to BRT_INSERT on purpose. //fall through to BRT_INSERT on purpose.
} }
case BRT_INSERT: { case BRT_INSERT: {
// even though the keys of the ule and the msg should techinically
// be the same as far as comparison goes, tickets #4618 and #4631
// show why this is necessary. We need to update the key with the exact
// bytes of the message
update_ule_key(ule, msg);
u_int32_t vallen = brt_msg_get_vallen(msg); u_int32_t vallen = brt_msg_get_vallen(msg);
invariant(IS_VALID_LEN(vallen)); invariant(IS_VALID_LEN(vallen));
void * valp = brt_msg_get_val(msg); void * valp = brt_msg_get_val(msg);
......
...@@ -682,6 +682,9 @@ env_update_multiple(DB_ENV *env, DB *src_db, DB_TXN *txn, ...@@ -682,6 +682,9 @@ env_update_multiple(DB_ENV *env, DB *src_db, DB_TXN *txn,
} }
toku_dbt_cmp cmpfun = toku_db_get_compare_fun(db); toku_dbt_cmp cmpfun = toku_db_get_compare_fun(db);
BOOL key_eq = cmpfun(db, &curr_old_key, &curr_new_key) == 0; BOOL key_eq = cmpfun(db, &curr_old_key, &curr_new_key) == 0;
BOOL key_bytes_eq = (curr_old_key.size == curr_new_key.size &&
(memcmp(curr_old_key.data, curr_new_key.data, curr_old_key.size) == 0)
);
if (!key_eq) { if (!key_eq) {
//Check overwrite constraints only in the case where //Check overwrite constraints only in the case where
// the keys are not equal. // the keys are not equal.
...@@ -711,7 +714,7 @@ env_update_multiple(DB_ENV *env, DB *src_db, DB_TXN *txn, ...@@ -711,7 +714,7 @@ env_update_multiple(DB_ENV *env, DB *src_db, DB_TXN *txn,
// we take a shortcut and avoid generating the old val // we take a shortcut and avoid generating the old val
// we assume that any new vals with size > 0 are different than the old val // we assume that any new vals with size > 0 are different than the old val
// if (!key_eq || !(dbt_cmp(&vals[which_db], &vals[which_db + num_dbs]) == 0)) { // if (!key_eq || !(dbt_cmp(&vals[which_db], &vals[which_db + num_dbs]) == 0)) {
if (!key_eq || curr_new_val.size > 0) { if (!key_bytes_eq || curr_new_val.size > 0) {
r = db_put_check_size_constraints(db, &curr_new_key, &curr_new_val); r = db_put_check_size_constraints(db, &curr_new_key, &curr_new_val);
if (r != 0) goto cleanup; if (r != 0) goto cleanup;
......
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