diff --git a/sql/filesort.h b/sql/filesort.h index 9f71da02c96..7f54de266e6 100644 --- a/sql/filesort.h +++ b/sql/filesort.h @@ -54,8 +54,11 @@ public: /* TRUE means sort operation must produce table rowids. - FALSE means that it halso has an option of producing {sort_key, - addon_fields} pairs. + FALSE means that it also has an option of producing {sort_key, addon_fields} + pairs. + + Usually initialized with value of join_tab->keep_current_rowid to allow for + a call to table->file->position() using these table rowids. */ bool sort_positions; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 81c3141c252..ab0d5d35927 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -1234,6 +1234,13 @@ multi_delete::initialize_tables(JOIN *join) { TABLE_LIST *tbl= walk->correspondent_table->find_table_for_update(); tables_to_delete_from|= tbl->table->map; + + /* + Ensure that filesort re-reads the row from the engine before + delete is called. + */ + join->map2table[tbl->table->tablenr]->keep_current_rowid= true; + if (delete_while_scanning && unique_table(thd, tbl, join->tables_list, 0)) {