• Staale Smedseng's avatar
    Bug #47905 stored procedures with conditional statements not · 64cedd5a
    Staale Smedseng authored
    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().
    64cedd5a
sp_head.cc 104 KB