Merge lp:~akopytov/percona-server/bug719386-5.5 into lp:percona-server/5.5

Proposed by Alexey Kopytov on 2012-10-15
Status: Merged
Approved by: Alexey Kopytov on 2012-10-26
Approved revision: 324
Merged at revision: 340
Proposed branch: lp:~akopytov/percona-server/bug719386-5.5
Merge into: lp:percona-server/5.5
Diff against target: 78 lines (+36/-0)
2 files modified
Percona-Server/sql/sp_head.cc (+20/-0)
Percona-Server/sql/sql_class.h (+16/-0)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug719386-5.5
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve on 2012-10-26
Laurynas Biveinis Needs Fixing on 2012-10-26
Stewart Smith (community) Approve on 2012-10-24
Sergei Glushchenko g2 2012-10-15 Approve on 2012-10-23
Review via email: mp+129700@code.launchpad.net
To post a comment you must log in.

Approve g2

review: Approve (g2)
Stewart Smith (stewart) :
review: Approve

I think THD::get_time() method should be const, likewise the arg of THD::set_time().

review: Needs Fixing
Alexey Kopytov (akopytov) wrote :

I don't think it makes any practical difference.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/sql/sp_head.cc'
2--- Percona-Server/sql/sp_head.cc 2012-06-01 12:15:25 +0000
3+++ Percona-Server/sql/sp_head.cc 2012-10-15 15:45:27 +0000
4@@ -3099,6 +3099,8 @@
5 sp_instr_stmt::execute(THD *thd, uint *nextp)
6 {
7 int res;
8+ QUERY_START_TIME_INFO time_info;
9+
10 DBUG_ENTER("sp_instr_stmt::execute");
11 DBUG_PRINT("info", ("command: %d", m_lex_keeper.sql_command()));
12
13@@ -3107,6 +3109,19 @@
14 /* This s-p instr is profilable and will be captured. */
15 thd->profiling.set_query_source(m_query.str, m_query.length);
16 #endif
17+
18+ memset(&time_info, 0, sizeof(time_info));
19+
20+ if (thd->enable_slow_log)
21+ {
22+ /*
23+ Save start time info for the CALL statement and overwrite it with the
24+ current time for log_slow_statement() to log the individual query timing.
25+ */
26+ thd->get_time(&time_info);
27+ thd->set_time();
28+ }
29+
30 if (!(res= alloc_query(thd, m_query.str, m_query.length)) &&
31 !(res=subst_spvars(thd, this, &m_query)))
32 {
33@@ -3143,6 +3158,11 @@
34 if (!thd->is_error())
35 thd->stmt_da->reset_diagnostics_area();
36 }
37+
38+ /* Restore the original query start time */
39+ if (thd->enable_slow_log)
40+ thd->set_time(&time_info);
41+
42 DBUG_RETURN(res || thd->is_error());
43 }
44
45
46=== modified file 'Percona-Server/sql/sql_class.h'
47--- Percona-Server/sql/sql_class.h 2012-09-17 13:08:32 +0000
48+++ Percona-Server/sql/sql_class.h 2012-10-15 15:45:27 +0000
49@@ -1497,6 +1497,12 @@
50
51 extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
52
53+typedef struct
54+{
55+ time_t start_time;
56+ ulonglong start_utime;
57+} QUERY_START_TIME_INFO;
58+
59 /**
60 @class THD
61 For each client connection we create a separate thread with THD serving as
62@@ -2493,6 +2499,16 @@
63 start_time= user_time= t;
64 start_utime= utime_after_lock= my_micro_time();
65 }
66+ void get_time(QUERY_START_TIME_INFO *time_info)
67+ {
68+ time_info->start_time= start_time;
69+ time_info->start_utime= start_utime;
70+ }
71+ void set_time(QUERY_START_TIME_INFO *time_info)
72+ {
73+ start_time= time_info->start_time;
74+ start_utime= time_info->start_utime;
75+ }
76 /*TODO: this will be obsolete when we have support for 64 bit my_time_t */
77 inline bool is_valid_time()
78 {

Subscribers

People subscribed via source and target branches