summaryrefslogtreecommitdiff
path: root/sql/sql_delete.cc
diff options
context:
space:
mode:
authorunknown <anozdrin/alik@quad.opbmk>2008-03-25 14:53:23 +0300
committerunknown <anozdrin/alik@quad.opbmk>2008-03-25 14:53:23 +0300
commit04cf5127a4a1fc2f1686b3d120c97b8ba84fe24b (patch)
tree691549a1621a4cb780bbeef2a5bacf6ccfe104e3 /sql/sql_delete.cc
parent90628f25b9654a0450f60908bab5d3678a2c5805 (diff)
parentc9b63800f9ecbc83288f7abc30119314f03295f0 (diff)
downloadmariadb-git-04cf5127a4a1fc2f1686b3d120c97b8ba84fe24b.tar.gz
Merge quad.opbmk:/mnt/raid/alik/MySQL/devel/5.0
into quad.opbmk:/mnt/raid/alik/MySQL/devel/5.0-rt-merged sql/sql_delete.cc: Auto merged
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r--sql/sql_delete.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 52e3ab73de0..94733c2ea42 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -35,6 +35,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
READ_RECORD info;
bool using_limit=limit != HA_POS_ERROR;
bool transactional_table, safe_update, const_cond;
+ bool triggers_applicable;
ha_rows deleted;
uint usable_index= MAX_KEY;
SELECT_LEX *select_lex= &thd->lex->select_lex;
@@ -93,6 +94,11 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
select_lex->no_error= thd->lex->ignore;
+ /* NOTE: TRUNCATE must not invoke triggers. */
+
+ triggers_applicable= table->triggers &&
+ thd->lex->sql_command != SQLCOM_TRUNCATE;
+
/*
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
@@ -102,8 +108,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
*/
if (!using_limit && const_cond && (!conds || conds->val_int()) &&
!(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) &&
- (thd->lex->sql_command == SQLCOM_TRUNCATE ||
- !(table->triggers && table->triggers->has_delete_triggers()))
+ !(triggers_applicable && table->triggers->has_delete_triggers())
)
{
deleted= table->file->records;
@@ -217,7 +222,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
init_ftfuncs(thd, select_lex, 1);
thd->proc_info="updating";
- if (table->triggers)
+ if (triggers_applicable)
{
table->triggers->mark_fields_used(thd, TRG_EVENT_DELETE);
if (table->triggers->has_triggers(TRG_EVENT_DELETE,
@@ -239,7 +244,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (!(select && select->skip_record())&& !thd->net.report_error )
{
- if (table->triggers &&
+ if (triggers_applicable &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_BEFORE, FALSE))
{
@@ -250,7 +255,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
if (!(error=table->file->delete_row(table->record[0])))
{
deleted++;
- if (table->triggers &&
+ if (triggers_applicable &&
table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
TRG_ACTION_AFTER, FALSE))
{