Commit 4d63caa9 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4648], fix bug

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@41271 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0d2da79a
...@@ -3959,25 +3959,16 @@ int ha_tokudb::write_row(uchar * record) { ...@@ -3959,25 +3959,16 @@ int ha_tokudb::write_row(uchar * record) {
} }
/* Compare if a key in a row has changed */ /* Compare if a key in a row has changed */
int ha_tokudb::key_cmp(uint keynr, const uchar * old_row, const uchar * new_row) { bool ha_tokudb::key_changed(uint keynr, const uchar * old_row, const uchar * new_row) {
KEY_PART_INFO *key_part = table->key_info[keynr].key_part; DBT old_key;
KEY_PART_INFO *end = key_part + table->key_info[keynr].key_parts; DBT new_key;
bzero((void *) &old_key, sizeof(old_key));
bzero((void *) &new_key, sizeof(new_key));
for (; key_part != end; key_part++) { bool has_null;
if (key_part->null_bit) { create_dbt_key_from_table(&new_key, keynr, key_buff2, new_row, &has_null);
if ((old_row[key_part->null_offset] & key_part->null_bit) != (new_row[key_part->null_offset] & key_part->null_bit)) create_dbt_key_for_lookup(&old_key,&table->key_info[keynr], key_buff3, old_row, &has_null);
return 1; return tokudb_prefix_cmp_dbt_key(share->key_file[keynr], &old_key, &new_key);
}
if (key_part->key_part_flag & (HA_BLOB_PART | HA_VAR_LENGTH_PART)) {
if (key_part->field->cmp_binary((uchar *) (old_row + key_part->offset), (uchar *) (new_row + key_part->offset), (ulong) key_part->length))
return 1;
} else {
if (memcmp(old_row + key_part->offset, new_row + key_part->offset, key_part->length))
return 1;
}
}
return 0;
} }
// //
...@@ -3993,7 +3984,6 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { ...@@ -3993,7 +3984,6 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) {
TOKUDB_DBUG_ENTER("update_row"); TOKUDB_DBUG_ENTER("update_row");
DBT prim_key, old_prim_key, prim_row, old_prim_row; DBT prim_key, old_prim_key, prim_row, old_prim_row;
int error; int error;
bool primary_key_changed;
bool has_null; bool has_null;
THD* thd = ha_thd(); THD* thd = ha_thd();
DB_TXN* sub_trans = NULL; DB_TXN* sub_trans = NULL;
...@@ -4051,7 +4041,6 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { ...@@ -4051,7 +4041,6 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) {
if (hidden_primary_key) { if (hidden_primary_key) {
primary_key_changed = 0;
bzero((void *) &prim_key, sizeof(prim_key)); bzero((void *) &prim_key, sizeof(prim_key));
prim_key.data = (void *) current_ident; prim_key.data = (void *) current_ident;
prim_key.size = TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH; prim_key.size = TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH;
...@@ -4059,7 +4048,7 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { ...@@ -4059,7 +4048,7 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) {
} }
else { else {
create_dbt_key_from_table(&prim_key, primary_key, key_buff, new_row, &has_null); create_dbt_key_from_table(&prim_key, primary_key, key_buff, new_row, &has_null);
if ((primary_key_changed = key_cmp(primary_key, old_row, new_row))) { if (key_changed(primary_key, old_row, new_row)) {
create_dbt_key_from_table(&old_prim_key, primary_key, primary_key_buff, old_row, &has_null); create_dbt_key_from_table(&old_prim_key, primary_key, primary_key_buff, old_row, &has_null);
} }
else { else {
...@@ -4077,8 +4066,8 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) { ...@@ -4077,8 +4066,8 @@ int ha_tokudb::update_row(const uchar * old_row, uchar * new_row) {
continue; continue;
} }
if (is_unique_key) { if (is_unique_key) {
bool key_changed = key_cmp(keynr, old_row, new_row); bool key_ch = key_changed(keynr, old_row, new_row);
if (key_changed) { if (key_ch) {
bool is_unique; bool is_unique;
error = is_val_unique(&is_unique, new_row, &table->key_info[keynr], keynr, txn); error = is_val_unique(&is_unique, new_row, &table->key_info[keynr], keynr, txn);
if (error) goto cleanup; if (error) goto cleanup;
......
...@@ -354,7 +354,7 @@ class ha_tokudb : public handler { ...@@ -354,7 +354,7 @@ class ha_tokudb : public handler {
DBT *create_dbt_key_from_table(DBT * key, uint keynr, uchar * buff, const uchar * record, bool* has_null, int key_length = MAX_KEY_LENGTH); DBT *create_dbt_key_from_table(DBT * key, uint keynr, uchar * buff, const uchar * record, bool* has_null, int key_length = MAX_KEY_LENGTH);
DBT* create_dbt_key_for_lookup(DBT * key, KEY* key_info, uchar * buff, const uchar * record, bool* has_null, int key_length = MAX_KEY_LENGTH); DBT* create_dbt_key_for_lookup(DBT * key, KEY* key_info, uchar * buff, const uchar * record, bool* has_null, int key_length = MAX_KEY_LENGTH);
DBT *pack_key(DBT * key, uint keynr, uchar * buff, const uchar * key_ptr, uint key_length, int8_t inf_byte); DBT *pack_key(DBT * key, uint keynr, uchar * buff, const uchar * key_ptr, uint key_length, int8_t inf_byte);
int key_cmp(uint keynr, const uchar * old_row, const uchar * new_row); bool key_changed(uint keynr, const uchar * old_row, const uchar * new_row);
int handle_cursor_error(int error, int err_to_return, uint keynr); int handle_cursor_error(int error, int err_to_return, uint keynr);
DBT *get_pos(DBT * to, uchar * pos); DBT *get_pos(DBT * to, uchar * pos);
......
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