mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug#23771 AFTER UPDATE trigger not invoked when there are no changes of the data
The problem is that AFTER UPDATE triggers will fire only if the new data is different from the old data on the row. The trigger should fire regardless of whether there are changes to the data. The solution is to fire the trigger on UPDATE even if there are no changes to the value (because the value is the same).
This commit is contained in:
@ -643,14 +643,6 @@ int mysql_update(THD *thd,
|
||||
updated++;
|
||||
else
|
||||
error= 0;
|
||||
|
||||
if (table->triggers &&
|
||||
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
|
||||
TRG_ACTION_AFTER, TRUE))
|
||||
{
|
||||
error= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!ignore ||
|
||||
table->file->is_fatal_error(error, HA_CHECK_DUP_KEY))
|
||||
@ -669,6 +661,14 @@ int mysql_update(THD *thd,
|
||||
}
|
||||
}
|
||||
|
||||
if (table->triggers &&
|
||||
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
|
||||
TRG_ACTION_AFTER, TRUE))
|
||||
{
|
||||
error= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!--limit && using_limit)
|
||||
{
|
||||
/*
|
||||
@ -1644,12 +1644,12 @@ bool multi_update::send_data(List<Item> ¬_used_values)
|
||||
trans_safe= 0;
|
||||
thd->transaction.stmt.modified_non_trans_table= TRUE;
|
||||
}
|
||||
if (table->triggers &&
|
||||
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
|
||||
TRG_ACTION_AFTER, TRUE))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
}
|
||||
if (table->triggers &&
|
||||
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
|
||||
TRG_ACTION_AFTER, TRUE))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1881,12 +1881,12 @@ int multi_update::do_updates()
|
||||
updated++;
|
||||
else
|
||||
local_error= 0;
|
||||
|
||||
if (table->triggers &&
|
||||
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
|
||||
TRG_ACTION_AFTER, TRUE))
|
||||
goto err2;
|
||||
}
|
||||
|
||||
if (table->triggers &&
|
||||
table->triggers->process_triggers(thd, TRG_EVENT_UPDATE,
|
||||
TRG_ACTION_AFTER, TRUE))
|
||||
goto err2;
|
||||
}
|
||||
|
||||
if (updated != org_updated)
|
||||
|
Reference in New Issue
Block a user