diff options
Diffstat (limited to 'sql/sql_delete.cc')
| -rw-r--r-- | sql/sql_delete.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index c87c9382630..0f07f01c6fd 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -244,6 +244,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, uint length= 0; SORT_FIELD *sortorder; ha_rows examined_rows; + ha_rows found_rows; table->update_const_key_parts(conds); order= simple_remove_const(order, conds); @@ -264,9 +265,10 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, MYF(MY_FAE | MY_ZEROFILL)); if (!(sortorder= make_unireg_sortorder(order, &length, NULL)) || - (table->sort.found_records = filesort(thd, table, sortorder, length, - select, HA_POS_ERROR, 1, - &examined_rows)) + (table->sort.found_records= filesort(thd, table, sortorder, length, + select, HA_POS_ERROR, + true, + &examined_rows, &found_rows)) == HA_POS_ERROR) { delete select; @@ -368,8 +370,14 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, } } } - else + /* + Don't try unlocking the row if skip_record reported an error since in + this case the transaction might have been rolled back already. + */ + else if (!thd->is_error()) table->file->unlock_row(); // Row failed selection, release lock on it + else + break; } killed_status= thd->killed; if (killed_status != NOT_KILLED || thd->is_error()) |
