summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorAlexander Nozdrin <alexander.nozdrin@oracle.com>2010-10-26 15:48:08 +0400
committerAlexander Nozdrin <alexander.nozdrin@oracle.com>2010-10-26 15:48:08 +0400
commite86b6c0db40116cb0dc223999e45712e1b1908ef (patch)
tree70a95b383eccf00cc30e660b5ea8e69631fca815 /sql/sp_head.cc
parentb431da62147ed8d1ed5433c810a92ed6eadcbf27 (diff)
downloadmariadb-git-e86b6c0db40116cb0dc223999e45712e1b1908ef.tar.gz
Patch for Bug#55850 (Trigger warnings not cleared).
The problem was that the warnings risen by a trigger were not cleared upon successful completion. The warnings should be cleared if the trigger completes successfully. The fix is to skip merging warnings into caller's Warning Info for triggers.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc26
1 files changed, 20 insertions, 6 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 379e81d406e..0d33bd5c599 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -1176,10 +1176,17 @@ find_handler_after_execution(THD *thd, sp_rcontext *ctx)
/**
Execute the routine. The main instruction jump loop is there.
Assume the parameters already set.
+
+ @param thd Thread context.
+ @param merge_da_on_success Flag specifying if Warning Info should be
+ propagated to the caller on Completion
+ Condition or not.
+
@todo
- Will write this SP statement into binlog separately
(TODO: consider changing the condition to "not inside event union")
+ @return Error status.
@retval
FALSE on success
@retval
@@ -1187,7 +1194,7 @@ find_handler_after_execution(THD *thd, sp_rcontext *ctx)
*/
bool
-sp_head::execute(THD *thd)
+sp_head::execute(THD *thd, bool merge_da_on_success)
{
DBUG_ENTER("sp_head::execute");
char saved_cur_db_name_buf[NAME_LEN+1];
@@ -1481,8 +1488,15 @@ sp_head::execute(THD *thd)
thd->stmt_arena= old_arena;
state= EXECUTED;
- /* Restore the caller's original warning information area. */
- saved_warning_info->merge_with_routine_info(thd, thd->warning_info);
+ /*
+ Restore the caller's original warning information area:
+ - warnings generated during trigger execution should not be
+ propagated to the caller on success;
+ - if there was an exception during execution, warning info should be
+ propagated to the caller in any case.
+ */
+ if (err_status || merge_da_on_success)
+ saved_warning_info->merge_with_routine_info(thd, thd->warning_info);
thd->warning_info= saved_warning_info;
done:
@@ -1704,7 +1718,7 @@ sp_head::execute_trigger(THD *thd,
thd->spcont= nctx;
- err_status= execute(thd);
+ err_status= execute(thd, FALSE);
err_with_cleanup:
thd->restore_active_arena(&call_arena, &backup_arena);
@@ -1921,7 +1935,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount,
*/
thd->set_n_backup_active_arena(&call_arena, &backup_arena);
- err_status= execute(thd);
+ err_status= execute(thd, TRUE);
thd->restore_active_arena(&call_arena, &backup_arena);
@@ -2154,7 +2168,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
#endif
if (!err_status)
- err_status= execute(thd);
+ err_status= execute(thd, TRUE);
if (save_log_general)
thd->variables.option_bits &= ~OPTION_LOG_OFF;