Commit 3395ab73 authored by Sergei Golubchik's avatar Sergei Golubchik Committed by Aleksey Midenkov

small cleanup: backup_query_start_time()

parent e52a237f
...@@ -3289,7 +3289,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp) ...@@ -3289,7 +3289,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
Save start time info for the CALL statement and overwrite it with the Save start time info for the CALL statement and overwrite it with the
current time for log_slow_statement() to log the individual query timing. current time for log_slow_statement() to log the individual query timing.
*/ */
thd->get_time(&time_info); thd->backup_query_start_time(&time_info);
thd->set_time(); thd->set_time();
} }
thd->store_slow_query_state(&backup_state); thd->store_slow_query_state(&backup_state);
...@@ -3357,7 +3357,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp) ...@@ -3357,7 +3357,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
} }
/* Restore the original query start time */ /* Restore the original query start time */
if (thd->enable_slow_log) if (thd->enable_slow_log)
thd->set_time(&time_info); thd->restore_query_start_time(&time_info);
DBUG_RETURN(res || thd->is_error()); DBUG_RETURN(res || thd->is_error());
} }
......
...@@ -2080,12 +2080,21 @@ struct wait_for_commit ...@@ -2080,12 +2080,21 @@ struct wait_for_commit
Structure to store the start time for a query Structure to store the start time for a query
*/ */
typedef struct struct QUERY_START_TIME_INFO
{ {
my_time_t start_time; my_time_t start_time;
ulong start_time_sec_part; ulong start_time_sec_part;
ulonglong start_utime, utime_after_lock; ulonglong start_utime, utime_after_lock;
} QUERY_START_TIME_INFO;
void backup_query_start_time(QUERY_START_TIME_INFO *backup)
{
*backup= *this;
}
void restore_query_start_time(QUERY_START_TIME_INFO *backup)
{
*this= *backup;
}
};
extern "C" void my_message_sql(uint error, const char *str, myf MyFlags); extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
...@@ -2097,7 +2106,8 @@ extern "C" void my_message_sql(uint error, const char *str, myf MyFlags); ...@@ -2097,7 +2106,8 @@ extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
class THD :public Statement, class THD :public Statement,
public MDL_context_owner, public MDL_context_owner,
public Open_tables_state public Open_tables_state,
public QUERY_START_TIME_INFO
{ {
private: private:
inline bool is_stmt_prepare() const inline bool is_stmt_prepare() const
...@@ -2322,12 +2332,10 @@ class THD :public Statement, ...@@ -2322,12 +2332,10 @@ class THD :public Statement,
uint32 file_id; // for LOAD DATA INFILE uint32 file_id; // for LOAD DATA INFILE
/* remote (peer) port */ /* remote (peer) port */
uint16 peer_port; uint16 peer_port;
my_time_t start_time; // start_time and its sec_part
ulong start_time_sec_part; // are almost always used separately
my_hrtime_t user_time; my_hrtime_t user_time;
// track down slow pthread_create // track down slow pthread_create
ulonglong prior_thr_create_utime, thr_create_utime; ulonglong prior_thr_create_utime, thr_create_utime;
ulonglong start_utime, utime_after_lock, utime_after_query; ulonglong utime_after_query;
// Process indicator // Process indicator
struct { struct {
...@@ -3410,20 +3418,6 @@ class THD :public Statement, ...@@ -3410,20 +3418,6 @@ class THD :public Statement,
MYSQL_SET_STATEMENT_LOCK_TIME(m_statement_psi, MYSQL_SET_STATEMENT_LOCK_TIME(m_statement_psi,
(utime_after_lock - start_utime)); (utime_after_lock - start_utime));
} }
void get_time(QUERY_START_TIME_INFO *time_info)
{
time_info->start_time= start_time;
time_info->start_time_sec_part= start_time_sec_part;
time_info->start_utime= start_utime;
time_info->utime_after_lock= utime_after_lock;
}
void set_time(QUERY_START_TIME_INFO *time_info)
{
start_time= time_info->start_time;
start_time_sec_part= time_info->start_time_sec_part;
start_utime= time_info->start_utime;
utime_after_lock= time_info->utime_after_lock;
}
ulonglong current_utime() { return microsecond_interval_timer(); } ulonglong current_utime() { return microsecond_interval_timer(); }
/* Tell SHOW PROCESSLIST to show time from this point */ /* Tell SHOW PROCESSLIST to show time from this point */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment