diff --git a/storage/tianchi/ha_tse.cc b/storage/tianchi/ha_tse.cc index 52b1cab26bd71257a1030a5fbc3bd8f8c4a67ea6..5205399367509173811aa9ac55ccd61e4849a713 100644 --- a/storage/tianchi/ha_tse.cc +++ b/storage/tianchi/ha_tse.cc @@ -2628,6 +2628,21 @@ int ha_tse::end_bulk_insert() { return ret; } +static bool check_if_update_primary_key(TABLE *table) { + if (table->s->primary_key < MAX_KEY) { + KEY *keyinfo; + keyinfo = table->s->key_info + table->s->primary_key; + for (uint i = 0; i < keyinfo->user_defined_key_parts; i++) { + uint fieldnr = keyinfo->key_part[i].fieldnr - 1; + if (bitmap_is_set(table->write_set, fieldnr)) { + return true; + } + } + } + + return false; +} + int tse_cmp_key_values(TABLE *table, const uchar *old_data, const uchar *new_data, uint key_nr) { if (key_nr == MAX_KEY) { return 0; @@ -2693,8 +2708,9 @@ EXTER_ATTACK int ha_tse::update_row(const uchar *old_data, uchar *new_data) { vector upd_fields; + bool update_primary_key = m_tch.change_data_capture && check_if_update_primary_key(table); for (uint16_t i = 0; i < table->write_set->n_bits; i++) { - if (m_tch.change_data_capture || bitmap_is_set(table->write_set, i)) { + if (update_primary_key || bitmap_is_set(table->write_set, i)) { upd_fields.push_back(i); } }