1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-34958: after Trigger doesn't work correctly with bulk insert

This bug has the same nature as the issues
  MDEV-34718: Trigger doesn't work correctly with bulk update
  MDEV-24411: Trigger doesn't work correctly with bulk insert

To fix the issue covering all use cases, resetting the thd->bulk_param
temporary to the value nullptr before invoking triggers and restoring
its original value on finishing execution of a trigger is moved to the method
  Table_triggers_list::process_triggers
that be invoked ultimately for any kind of triggers.
This commit is contained in:
Dmitry Shulga
2024-12-13 09:29:23 +07:00
parent 0b7fa4c267
commit 54c1031b74
6 changed files with 133 additions and 31 deletions

View File

@ -812,17 +812,13 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
delete_history);
if (delete_record)
{
void *save_bulk_param= thd->bulk_param;
thd->bulk_param= nullptr;
if (!delete_history && table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_BEFORE, FALSE))
{
error= 1;
thd->bulk_param= save_bulk_param;
break;
}
thd->bulk_param= save_bulk_param;
// no LIMIT / OFFSET
if (returning && result->send_data(returning->item_list) < 0)
@ -853,16 +849,13 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (likely(!error))
{
deleted++;
thd->bulk_param= nullptr;
if (!delete_history && table->triggers &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_AFTER, FALSE))
{
error= 1;
thd->bulk_param= save_bulk_param;
break;
}
thd->bulk_param= save_bulk_param;
if (!--limit && using_limit)
{
error= -1;