diff options
author | Staale Smedseng <staale.smedseng@sun.com> | 2010-02-11 21:10:13 +0100 |
---|---|---|
committer | Staale Smedseng <staale.smedseng@sun.com> | 2010-02-11 21:10:13 +0100 |
commit | f4a16558c81af480d1cd9e09bd3965e598c561ac (patch) | |
tree | 59f859c91e2e9f4104dd10eeb963568d1499067c /sql/sp_head.cc | |
parent | 323a8ddc8362442721f276bf640620b0f66c2b0e (diff) | |
download | mariadb-git-f4a16558c81af480d1cd9e09bd3965e598c561ac.tar.gz |
Bug #47905 stored procedures with conditional statements not
being logged to slow query log
The problem is that the execution time for a multi-statement
stored procedure as a whole may not be accurate, and thus not
be entered into the slow query log even if the total time
exceeds long_query_time. The reason for this is that
THD::utime_after_lock used for time calculation may be reset
at the start of each new statement, possibly leaving the total
SP execution equal to the time spent executing the last
statement in the SP.
This patch stores the utime on start of SP execution, and
restores it on exit of SP execution. A test is added.
mysql-test/suite/sys_vars/r/slow_query_log_func.result:
New test results for #47905.
mysql-test/suite/sys_vars/t/slow_query_log_func.test:
New test case for #47905.
sql/sp_head.cc:
Save and restore the THD::utime_after_lock on entry and
exit of execute_procedure().
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r-- | sql/sp_head.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 45cb4eebb09..8a626cabd90 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1848,6 +1848,8 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) { bool err_status= FALSE; uint params = m_pcont->context_var_count(); + /* Query start time may be reset in a multi-stmt SP; keep this for later. */ + ulonglong utime_before_sp_exec= thd->utime_after_lock; sp_rcontext *save_spcont, *octx; sp_rcontext *nctx = NULL; bool save_enable_slow_log= false; @@ -2040,6 +2042,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) delete nctx; thd->spcont= save_spcont; + thd->utime_after_lock= utime_before_sp_exec; DBUG_RETURN(err_status); } |