summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-06-17 11:19:50 +0400
committerAlexander Barkov <bar@mariadb.com>2020-06-17 11:19:50 +0400
commitb46b7144d1999d4950a812486f36f2f0d6ab645d (patch)
treeba341f76f8dfc1794efed1b155f6ba6ad3558151 /sql/sql_table.cc
parentfb0d18e4128d82ac92c6024cb9d5e4e3c9a6da98 (diff)
downloadmariadb-git-b46b7144d1999d4950a812486f36f2f0d6ab645d.tar.gz
MDEV-21695 Server crashes in TABLE::evaluate_update_default_function upon UPDATE on temporary table
copy_data_between_tables() sets to->s->default_fields to 0, as a part of the code disabling ON UPDATE actions for all old fields (so ON UPDATE is enable only for new fields during copying). After the actual copying, copy_data_between_tables() did not restore to->s->default_fields to the original value. As a result, the TABLE_SHARE to->s was left in a wrong state after copy_data_between_tables() and further open_table_from_share() using this TABLE_SHARE did not populate TABLE::default_field, which further made TABLE::evaluate_update_default_function() crash on access to NULL pointer. Fix: Changing copy_data_between_tables() to restore to->s->default_fields to its original value after the copying loop.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 87d84b1abc6..7cce3bcc323 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -10057,6 +10057,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
sql_mode_t save_sql_mode= thd->variables.sql_mode;
ulonglong prev_insert_id, time_to_report_progress;
Field **dfield_ptr= to->default_field;
+ uint save_to_s_default_fields= to->s->default_fields;
DBUG_ENTER("copy_data_between_tables");
/* Two or 3 stages; Sorting, copying data and update indexes */
@@ -10338,6 +10339,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
*copied= found_count;
*deleted=delete_count;
to->file->ha_release_auto_increment();
+ to->s->default_fields= save_to_s_default_fields;
if (!cleanup_done)
{