diff options
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1ecc964c04b..7b98a235ab0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -20967,6 +20967,15 @@ 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 */ } + /* Prepare table for random positioning */ + bool rnd_inited= (table->file->inited == handler::RND); + if (!rnd_inited && + ((error= table->file->ha_index_end()) || + (error= table->file->ha_rnd_init(0)))) + { + table->file->print_error(error, MYF(0)); + DBUG_RETURN(NESTED_LOOP_ERROR); + } if (unlikely(table->file->ha_rnd_pos(table->record[1],table->file->dup_ref))) { table->file->print_error(error,MYF(0)); /* purecov: inspected */ @@ -20980,6 +20989,13 @@ 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 (!rnd_inited && + ((error= table->file->ha_rnd_end()) || + (error= table->file->ha_index_init(0, 0)))) + { + table->file->print_error(error, MYF(0)); + DBUG_RETURN(NESTED_LOOP_ERROR); + } } if (unlikely(join->thd->check_killed())) { |