diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-11-13 13:40:11 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-11-13 13:40:11 +0100 |
commit | 6a2c1701412d3951b7bae2f683e646b75b916cd2 (patch) | |
tree | 9f18977d2aa844f5f7baeccf747d506222af650f /sql/sql_insert.cc | |
parent | 815667086cfa4ee28eb1bdc88d5ae86755c71b72 (diff) | |
download | mariadb-git-6a2c1701412d3951b7bae2f683e646b75b916cd2.tar.gz |
MDEV-6849 ON UPDATE CURRENT_TIMESTAMP doesn't always work
reset default fields not for every modified row, but only once,
at the beginning, as the set of modified fields doesn't change.
exception: INSERT ... ON DUPLICATE KEY UPDATE - the set of fields
does change per row and in that case we reset default fields per row.
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 041074a815e..0ecc6418cb2 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -868,6 +868,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, table_list->prepare_check_option(thd)) error= 1; + table->reset_default_fields(); + while ((values= its++)) { if (fields.elements || !value_count) @@ -1661,6 +1663,13 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) DBUG_ASSERT(table->insert_values != NULL); store_record(table,insert_values); restore_record(table,record[1]); + + /* + in INSERT ... ON DUPLICATE KEY UPDATE the set of modified fields can + change per row. Thus, we have to do reset_default_fields() per row. + Twice (before insert and before update). + */ + table->reset_default_fields(); DBUG_ASSERT(info->update_fields->elements == info->update_values->elements); if (fill_record_n_invoke_before_triggers(thd, table, *info->update_fields, @@ -1688,6 +1697,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) if (res) goto err; } + table->reset_default_fields(); /* CHECK OPTION for VIEW ... ON DUPLICATE KEY UPDATE ... */ if (info->view && @@ -3473,6 +3483,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) table->file->ha_start_bulk_insert((ha_rows) 0); } restore_record(table,s->default_values); // Get empty record + table->reset_default_fields(); table->next_number_field=table->found_next_number_field; #ifdef HAVE_REPLICATION |