revision-id: 7c93e1c438bf9faacc0e9472cd52a41add5421b5 (mariadb-10.2.22-71-g7c93e1c438b) parent(s): 55adcb51fc716ab43f027fc35e4ff414b4e91953 author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2019-03-14 13:39:44 +0100 message: c --- sql/log_event.cc | 9 +++++++++ sql/sql_load.cc | 8 ++++++++ sql/sql_select.cc | 11 +++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 8990e1953b6..c17c7ef6e06 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -12845,6 +12845,14 @@ Rows_log_event::write_row(rpl_group_info *rgi, if (table->file->ha_table_flags() & HA_DUPLICATE_POS) { DBUG_PRINT("info",("Locating offending record using rnd_pos()")); + error= table->file->ha_rnd_init(0); + if (error) + { + DBUG_PRINT("info",("rnd_init() returns error %d",error)); + table->file->print_error(error, MYF(0)); + DBUG_RETURN(error); + } + error= table->file->ha_rnd_pos(table->record[1], table->file->dup_ref); if (error) { @@ -12854,6 +12862,7 @@ Rows_log_event::write_row(rpl_group_info *rgi, table->file->print_error(error, MYF(0)); DBUG_RETURN(error); } + table->file->ha_rnd_end(); } else { diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 8c2f17dac3f..2fd9caef575 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -638,6 +638,12 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, thd->abort_on_warning= !ignore && thd->is_strict_mode(); + /* Prepare table for random positioning (importent for innodb) */ + if (table_list->table->file->ha_rnd_init(0)) + { + error= 1; + goto err; + } thd_progress_init(thd, 2); if (table_list->table->validate_default_values_of_unset_fields(thd)) { @@ -657,6 +663,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, set_fields, set_values, read_info, *ex->enclosed, skip_lines, ignore); + table_list->table->file->ha_rnd_end(); + thd_proc_info(thd, "End bulk insert"); if (!error) thd_progress_next_stage(thd); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 40b14e33480..4c401ea9011 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -20318,8 +20318,10 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ } /* Prepare table for random positioning */ - if ((error= table->file->ha_index_end()) || - (error= table->file->ha_rnd_init(0))) + bool rnd_inited= (table->file->inited == handler::RND); + if (!rnd_inited && + ((error= table->file->ha_index_end()) || + (error= table->file->ha_rnd_init(0)))) DBUG_RETURN(NESTED_LOOP_ERROR); if (table->file->ha_rnd_pos(table->record[1],table->file->dup_ref)) { @@ -20334,8 +20336,9 @@ end_unique_update(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), table->file->print_error(error,MYF(0)); /* purecov: inspected */ DBUG_RETURN(NESTED_LOOP_ERROR); /* purecov: inspected */ } - if ((error= table->file->ha_rnd_end()) || - (error= table->file->ha_index_init(0, 0))) + if (!rnd_inited && + ((error= table->file->ha_rnd_end()) || + (error= table->file->ha_index_init(0, 0)))) DBUG_RETURN(NESTED_LOOP_ERROR); } if (join->thd->check_killed())