Skip to content

Commit 3395ab7

Browse files
vuvovamidenok
authored andcommitted
small cleanup: backup_query_start_time()
1 parent e52a237 commit 3395ab7

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

sql/sp_head.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,7 +3289,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
32893289
Save start time info for the CALL statement and overwrite it with the
32903290
current time for log_slow_statement() to log the individual query timing.
32913291
*/
3292-
thd->get_time(&time_info);
3292+
thd->backup_query_start_time(&time_info);
32933293
thd->set_time();
32943294
}
32953295
thd->store_slow_query_state(&backup_state);
@@ -3357,7 +3357,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
33573357
}
33583358
/* Restore the original query start time */
33593359
if (thd->enable_slow_log)
3360-
thd->set_time(&time_info);
3360+
thd->restore_query_start_time(&time_info);
33613361

33623362
DBUG_RETURN(res || thd->is_error());
33633363
}

sql/sql_class.h

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,12 +2080,21 @@ struct wait_for_commit
20802080
Structure to store the start time for a query
20812081
*/
20822082

2083-
typedef struct
2083+
struct QUERY_START_TIME_INFO
20842084
{
20852085
my_time_t start_time;
2086-
ulong start_time_sec_part;
2086+
ulong start_time_sec_part;
20872087
ulonglong start_utime, utime_after_lock;
2088-
} QUERY_START_TIME_INFO;
2088+
2089+
void backup_query_start_time(QUERY_START_TIME_INFO *backup)
2090+
{
2091+
*backup= *this;
2092+
}
2093+
void restore_query_start_time(QUERY_START_TIME_INFO *backup)
2094+
{
2095+
*this= *backup;
2096+
}
2097+
};
20892098

20902099
extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
20912100

@@ -2097,7 +2106,8 @@ extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
20972106

20982107
class THD :public Statement,
20992108
public MDL_context_owner,
2100-
public Open_tables_state
2109+
public Open_tables_state,
2110+
public QUERY_START_TIME_INFO
21012111
{
21022112
private:
21032113
inline bool is_stmt_prepare() const
@@ -2322,12 +2332,10 @@ class THD :public Statement,
23222332
uint32 file_id; // for LOAD DATA INFILE
23232333
/* remote (peer) port */
23242334
uint16 peer_port;
2325-
my_time_t start_time; // start_time and its sec_part
2326-
ulong start_time_sec_part; // are almost always used separately
23272335
my_hrtime_t user_time;
23282336
// track down slow pthread_create
23292337
ulonglong prior_thr_create_utime, thr_create_utime;
2330-
ulonglong start_utime, utime_after_lock, utime_after_query;
2338+
ulonglong utime_after_query;
23312339

23322340
// Process indicator
23332341
struct {
@@ -3410,20 +3418,6 @@ class THD :public Statement,
34103418
MYSQL_SET_STATEMENT_LOCK_TIME(m_statement_psi,
34113419
(utime_after_lock - start_utime));
34123420
}
3413-
void get_time(QUERY_START_TIME_INFO *time_info)
3414-
{
3415-
time_info->start_time= start_time;
3416-
time_info->start_time_sec_part= start_time_sec_part;
3417-
time_info->start_utime= start_utime;
3418-
time_info->utime_after_lock= utime_after_lock;
3419-
}
3420-
void set_time(QUERY_START_TIME_INFO *time_info)
3421-
{
3422-
start_time= time_info->start_time;
3423-
start_time_sec_part= time_info->start_time_sec_part;
3424-
start_utime= time_info->start_utime;
3425-
utime_after_lock= time_info->utime_after_lock;
3426-
}
34273421
ulonglong current_utime() { return microsecond_interval_timer(); }
34283422

34293423
/* Tell SHOW PROCESSLIST to show time from this point */

0 commit comments

Comments
 (0)