diff options
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r-- | sql/sql_delete.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index e653324d9bf..19f3135c594 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -217,7 +217,19 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, thd->proc_info="updating"; if (table->triggers) + { table->triggers->mark_fields_used(thd, TRG_EVENT_DELETE); + if (table->triggers->has_triggers(TRG_EVENT_DELETE, + TRG_ACTION_AFTER)) + { + /* + The table has AFTER DELETE triggers that might access to subject table + and therefore might need delete to be done immediately. So we turn-off + the batching. + */ + (void) table->file->extra(HA_EXTRA_DELETE_CANNOT_BATCH); + } + } while (!(error=info.read_record(&info)) && !thd->killed && !thd->net.report_error) @@ -540,7 +552,19 @@ multi_delete::initialize_tables(JOIN *join) else normal_tables= 1; if (tbl->triggers) + { tbl->triggers->mark_fields_used(thd, TRG_EVENT_DELETE); + if (tbl->triggers->has_triggers(TRG_EVENT_DELETE, + TRG_ACTION_AFTER)) + { + /* + The table has AFTER DELETE triggers that might access to subject + table and therefore might need delete to be done immediately. + So we turn-off the batching. + */ + (void) tbl->file->extra(HA_EXTRA_DELETE_CANNOT_BATCH); + } + } } else if ((tab->type != JT_SYSTEM && tab->type != JT_CONST) && walk == delete_tables) |