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

Proposed by Alexey Kopytov
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
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
Laurynas Biveinis (community) Needs Fixing
Stewart Smith (community) Approve
Sergei Glushchenko (community) g2 Approve
Review via email: mp+129699@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Approve G2

review: Approve (g2)
Revision history for this message
Stewart Smith (stewart) :
review: Approve
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

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

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) wrote :

I don't think it makes any practical difference.

review: Approve
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

> 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