summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authormskold/marty@mysql.com/linux.site <>2007-04-05 08:39:12 +0200
committermskold/marty@mysql.com/linux.site <>2007-04-05 08:39:12 +0200
commit3e8cf5958b967d0ad8041bc1d99ba46630c2a018 (patch)
tree65f485d2be885f33d90600d09460d7d0e3505d99 /sql/sql_insert.cc
parentb3ce01771a10d0b3ff3e443fac11e6434318e130 (diff)
parentee034c0e594c24ee2bfcbb87af4333e03eecff53 (diff)
downloadmariadb-git-3e8cf5958b967d0ad8041bc1d99ba46630c2a018.tar.gz
Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0
into mysql.com:/windows/Linux_space/MySQL/mysql-5.0-ndb
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc51
1 files changed, 48 insertions, 3 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 0fa027f89d6..955f83de25e 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -330,6 +330,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.
SYNOPSIS
@@ -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);
}