mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.0
into ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0-marvel client/mysqldump.c: Auto merged mysql-test/t/sp.test: Auto merged mysys/my_malloc.c: Auto merged mysys/my_static.c: Auto merged mysys/safemalloc.c: Auto merged ndb/src/mgmclient/CommandInterpreter.cpp: Auto merged sql/ha_archive.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/ha_ndbcluster.cc: Auto merged sql/handler.cc: Auto merged sql/item_cmpfunc.cc: Auto merged sql/item_func.h: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql-common/client.c: Auto merged sql/sp.cc: Auto merged sql/sp_head.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_update.cc: Auto merged sql/table.cc: Auto merged sql-common/my_time.c: Auto merged mysql-test/r/sp.result: Merged from main 5.0 sql/sql_load.cc: Merged from main 5.0
This commit is contained in:
@@ -329,6 +329,51 @@ static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Prepare triggers for INSERT-like statement.
|
||||
|
||||
SYNOPSIS
|
||||
prepare_triggers_for_insert_stmt()
|
||||
thd The current thread
|
||||
table Table to which insert will happen
|
||||
duplic Type of duplicate handling for insert which will happen
|
||||
|
||||
NOTE
|
||||
Prepare triggers for INSERT-like statement by marking fields
|
||||
used by triggers and inform handlers that batching of UPDATE/DELETE
|
||||
cannot be done if there are BEFORE UPDATE/DELETE triggers.
|
||||
*/
|
||||
|
||||
void prepare_triggers_for_insert_stmt(THD *thd, TABLE *table,
|
||||
enum_duplicates duplic)
|
||||
{
|
||||
if (table->triggers)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (table->triggers->has_triggers(TRG_EVENT_UPDATE,
|
||||
TRG_ACTION_AFTER))
|
||||
{
|
||||
/*
|
||||
The table has AFTER UPDATE triggers that might access to subject
|
||||
table and therefore might need update to be done immediately.
|
||||
So we turn-off the batching.
|
||||
*/
|
||||
(void) table->file->extra(HA_EXTRA_UPDATE_CANNOT_BATCH);
|
||||
}
|
||||
mark_fields_used_by_triggers_for_insert_stmt(thd, table, duplic);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Mark fields used by triggers for INSERT-like statement.
|
||||
|
||||
@@ -589,7 +634,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
|
||||
(MODE_STRICT_TRANS_TABLES |
|
||||
MODE_STRICT_ALL_TABLES)));
|
||||
|
||||
mark_fields_used_by_triggers_for_insert_stmt(thd, table, duplic);
|
||||
prepare_triggers_for_insert_stmt(thd, table, duplic);
|
||||
|
||||
if (table_list->prepare_where(thd, 0, TRUE) ||
|
||||
table_list->prepare_check_option(thd))
|
||||
@@ -2528,8 +2573,8 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
|
||||
table_list->prepare_check_option(thd));
|
||||
|
||||
if (!res)
|
||||
mark_fields_used_by_triggers_for_insert_stmt(thd, table,
|
||||
info.handle_duplicates);
|
||||
prepare_triggers_for_insert_stmt(thd, table,
|
||||
info.handle_duplicates);
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user