1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

Fix for bug #5890 "Triggers fail for DELETE without WHERE".

If we have DELETE with always true WHERE clause we should not use 
optimized delete_all_rows() method for tables with DELETE triggers,
because in this case we will lose side-effect of deletion.


mysql-test/r/trigger.result:
  Added test for bug #5890 "Triggers fail for DELETE without WHERE".
mysql-test/t/trigger.test:
  Added test for bug #5890 "Triggers fail for DELETE without WHERE".
sql/sql_delete.cc:
  mysql_delete(): 
    We should not use optimized delete_all_rows() method for tables
    with DELETE triggers, because in this case we will lose side-effect
    of deletion.
sql/sql_trigger.h:
  Added new Table_triggers_list::has_delete_triggers() method which
  allows to understand quickly if we have some DELETE triggers in
  our list.
This commit is contained in:
unknown
2004-11-12 17:04:07 +03:00
parent e5fd013fdf
commit bb43e8317f
4 changed files with 42 additions and 2 deletions

View File

@@ -62,9 +62,14 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order,
if (thd->lex->duplicates == DUP_IGNORE)
thd->lex->select_lex.no_error= 1;
/* Test if the user wants to delete all rows */
/*
Test if the user wants to delete all rows and deletion doesn't have
any side-effects (because of triggers), so we can use optimized
handler::delete_all_rows() method.
*/
if (!using_limit && const_cond && (!conds || conds->val_int()) &&
!(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)))
!(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) &&
!(table->triggers && table->triggers->has_delete_triggers()))
{
deleted= table->file->records;
if (!(error=table->file->delete_all_rows()))