From 3789692d17625780b546bf2ec4a33acf5badae2c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 2 Sep 2019 14:14:57 +0200 Subject: [PATCH] don't compare unassigned columns on UPDATE, compare_record() was comparing all columns that are marked for writing. But generated columns that are written to the table are always deterministic and cannot change unless normal non-generated columns were changed. So it's enough to compare only non-generated columns that were explicitly assigned values in the SET clause. --- sql/sql_update.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 4f129eb995a..0d55fa58bde 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -76,7 +76,7 @@ bool compare_record(const TABLE *table) for (Field **ptr= table->field ; *ptr != NULL; ptr++) { Field *field= *ptr; - if (bitmap_is_set(table->write_set, field->field_index)) + if (field->has_explicit_value() && !field->vcol_info) { if (field->real_maybe_null()) { @@ -108,8 +108,9 @@ bool compare_record(const TABLE *table) /* Compare updated fields */ for (Field **ptr= table->field ; *ptr ; ptr++) { - if (bitmap_is_set(table->write_set, (*ptr)->field_index) && - (*ptr)->cmp_binary_offset(table->s->rec_buff_length)) + Field *field= *ptr; + if (field->has_explicit_value() && !field->vcol_info && + field->cmp_binary_offset(table->s->rec_buff_length)) return TRUE; } return FALSE;