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

Proposed by Alexey Kopytov on 2012-10-15
Status: Merged
Approved by: Alexey Kopytov on 2012-10-26
Approved revision: 485
Merged at revision: 502
Proposed branch: lp:~akopytov/percona-server/bug719386-5.1
Merge into: lp:percona-server/5.1
Diff against target: 77 lines (+35/-0)
2 files modified
Percona-Server/sql/sp_head.cc (+20/-0)
Percona-Server/sql/sql_class.h (+15/-0)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug719386-5.1
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+129699@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

> I don't think it makes any practical difference.

Not much of a practical difference, but it's a code quality thing, there is no reason not to add const if it can be added. Anyway, I trust your judgment.

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-05-09 04:14:12 +0000
3+++ Percona-Server/sql/sp_head.cc 2012-10-15 15:43:33 +0000
4@@ -2898,6 +2898,8 @@
5 char *query;
6 uint32 query_length;
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@@ -2907,6 +2909,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@@ -2939,6 +2954,11 @@
34 if (!thd->is_error())
35 thd->main_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-08-20 03:14:02 +0000
48+++ Percona-Server/sql/sql_class.h 2012-10-15 15:43:33 +0000
49@@ -1329,6 +1329,11 @@
50 Ha_data() :ha_ptr(NULL) {}
51 };
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@@ -2217,6 +2222,16 @@
62 start_time= user_time= t;
63 start_utime= utime_after_lock= my_micro_time();
64 }
65+ void get_time(QUERY_START_TIME_INFO *time_info)
66+ {
67+ time_info->start_time= start_time;
68+ time_info->start_utime= start_utime;
69+ }
70+ void set_time(QUERY_START_TIME_INFO *time_info)
71+ {
72+ start_time= time_info->start_time;
73+ start_utime= time_info->start_utime;
74+ }
75 /*TODO: this will be obsolete when we have support for 64 bit my_time_t */
76 inline bool is_valid_time()
77 {

Subscribers

People subscribed via source and target branches