diff options
author | Dmitry Shulga <Dmitry.Shulga@Sun.COM> | 2010-09-07 15:53:46 +0700 |
---|---|---|
committer | Dmitry Shulga <Dmitry.Shulga@Sun.COM> | 2010-09-07 15:53:46 +0700 |
commit | 70807d147396b8a0a698a38f4033a91a3b8be90a (patch) | |
tree | c8eb3dcb0911e08facc0443d29a06726e0390312 /sql/sql_trigger.cc | |
parent | 3d5b9792e61d0a5afba550fabd7bfbb3b35a4073 (diff) | |
download | mariadb-git-70807d147396b8a0a698a38f4033a91a3b8be90a.tar.gz |
Fixed bug #55421 - Protocol::end_statement(): Assertion `0' on
multi-table UPDATE IGNORE.
The problem was that if there was an active SELECT statement
during trigger execution, an error risen during the execution
may cause a crash. The fix is to temporary reset LEX::current_select
before trigger execution and restore it afterwards. This way
errors risen during the trigger execution are processed as
if there was no active SELECT.
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r-- | sql/sql_trigger.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index bf4a46a4c67..9348feaa22a 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1989,6 +1989,7 @@ bool Table_triggers_list::process_triggers(THD *thd, bool err_status; Sub_statement_state statement_state; sp_head *sp_trigger= bodies[event][time_type]; + SELECT_LEX *save_current_select; if (sp_trigger == NULL) return FALSE; @@ -2012,11 +2013,19 @@ bool Table_triggers_list::process_triggers(THD *thd, thd->reset_sub_statement_state(&statement_state, SUB_STMT_TRIGGER); + /* + Reset current_select before call execute_trigger() and + restore it after return from one. This way error is set + in case of failure during trigger execution. + */ + save_current_select= thd->lex->current_select; + thd->lex->current_select= NULL; err_status= sp_trigger->execute_trigger(thd, &trigger_table->s->db, &trigger_table->s->table_name, &subject_table_grants[event][time_type]); + thd->lex->current_select= save_current_select; thd->restore_sub_statement_state(&statement_state); |