summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r--sql/sql_delete.cc26
1 files changed, 22 insertions, 4 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index d83937098e2..2967e2a8a20 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -32,7 +32,8 @@
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
SQL_LIST *order, ha_rows limit, ulong options)
{
- int error;
+ bool will_batch;
+ int error, loc_error;
TABLE *table;
SQL_SELECT *select=0;
READ_RECORD info;
@@ -169,6 +170,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
deleted=0L;
init_ftfuncs(thd, select_lex, 1);
thd->proc_info="updating";
+ will_batch= !table->file->start_bulk_delete();
while (!(error=info.read_record(&info)) && !thd->killed &&
!thd->net.report_error)
{
@@ -184,7 +186,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
break;
}
- if (!(error=table->file->delete_row(table->record[0])))
+ if (!(error= table->file->delete_row(table->record[0])))
{
deleted++;
if (table->triggers &&
@@ -220,7 +222,13 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
}
if (thd->killed && !error)
error= 1; // Aborted
- thd->proc_info="end";
+ if (will_batch && (loc_error= table->file->end_bulk_delete()))
+ {
+ if (error != 1)
+ table->file->print_error(loc_error,MYF(0));
+ error=1;
+ }
+ thd->proc_info= "end";
end_read_record(&info);
free_io_cache(table); // Will not do any harm
if (options & OPTION_QUICK)
@@ -615,7 +623,8 @@ void multi_delete::send_error(uint errcode,const char *err)
int multi_delete::do_deletes()
{
- int local_error= 0, counter= 0;
+ int local_error= 0, counter= 0, error;
+ bool will_batch;
DBUG_ENTER("do_deletes");
DBUG_ASSERT(do_delete);
@@ -643,6 +652,7 @@ int multi_delete::do_deletes()
been deleted by foreign key handling
*/
info.ignore_not_found_rows= 1;
+ will_batch= !table->file->start_bulk_delete();
while (!(local_error=info.read_record(&info)) && !thd->killed)
{
if (table->triggers &&
@@ -666,6 +676,14 @@ int multi_delete::do_deletes()
break;
}
}
+ if (will_batch && (error= table->file->end_bulk_delete()))
+ {
+ if (!local_error)
+ {
+ local_error= error;
+ table->file->print_error(local_error,MYF(0));
+ }
+ }
end_read_record(&info);
if (thd->killed && !local_error)
local_error= 1;