110
110
diff -ruN a/sql/mysql_priv.h b/sql/mysql_priv.h
111
111
--- a/sql/mysql_priv.h 2010-11-01 08:43:57.000000000 +0000
112
112
+++ b/sql/mysql_priv.h 2010-11-01 08:52:40.000000000 +0000
113
@@ -2091,6 +2091,8 @@
113
@@ -2091,6 +2091,11 @@
114
114
extern my_bool opt_query_cache_strip_comments;
115
115
extern my_bool opt_use_global_long_query_time;
116
116
extern my_bool opt_slow_query_log_microseconds_timestamp;
117
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
117
118
+extern ulong opt_query_response_time_range_base;
118
119
+extern my_bool opt_enable_query_response_time_stats;
120
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
121
+extern SHOW_COMP_OPTION have_response_time_distribution;
119
122
extern my_bool sp_automatic_privileges, opt_noacl;
120
123
extern my_bool opt_old_style_user_limits, trust_function_creators;
121
124
extern uint opt_crash_binlog_innodb;
122
125
diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
123
126
--- a/sql/mysqld.cc 2010-11-01 08:43:57.000000000 +0000
124
127
+++ b/sql/mysqld.cc 2010-11-01 08:52:40.000000000 +0000
127
130
#include "rpl_injector.h"
129
132
+#include "query_response_time.h"
131
133
#ifdef HAVE_SYS_PRCTL_H
132
134
#include <sys/prctl.h>
135
137
my_bool opt_query_cache_strip_comments = 0;
136
138
my_bool opt_use_global_long_query_time= 0;
137
139
my_bool opt_slow_query_log_microseconds_timestamp= 0;
140
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
138
141
+ulong opt_query_response_time_range_base = QRT_DEFAULT_BASE;
139
142
+my_bool opt_enable_query_response_time_stats= 0;
143
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
140
144
my_bool lower_case_file_system= 0;
141
145
my_bool opt_large_pages= 0;
142
146
my_bool opt_myisam_use_mmap= 0;
143
@@ -1385,6 +1389,7 @@
148
MY_LOCALE *my_default_lc_time_names;
150
SHOW_COMP_OPTION have_ssl, have_symlink, have_dlopen, have_query_cache;
151
+SHOW_COMP_OPTION have_response_time_distribution;
152
SHOW_COMP_OPTION have_geometry, have_rtree_keys;
153
SHOW_COMP_OPTION have_crypt, have_compress;
154
SHOW_COMP_OPTION have_community_features;
155
@@ -1385,6 +1391,9 @@
144
156
free_global_thread_stats();
145
157
free_global_table_stats();
146
158
free_global_index_stats();
159
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
147
160
+ query_response_time_free();
161
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
148
162
#ifdef HAVE_REPLICATION
149
163
end_slave_list();
151
@@ -4087,6 +4092,7 @@
165
@@ -4087,6 +4096,9 @@
153
167
init_global_table_stats();
154
168
init_global_index_stats();
169
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
155
170
+ query_response_time_init();
171
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
157
173
/* We have to initialize the storage engines before CSV logging */
159
@@ -5900,6 +5906,8 @@
175
@@ -5900,6 +5912,10 @@
160
176
OPT_USE_GLOBAL_LONG_QUERY_TIME,
161
177
OPT_USE_GLOBAL_LOG_SLOW_CONTROL,
162
178
OPT_SLOW_QUERY_LOG_MICROSECONDS_TIMESTAMP,
179
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
163
180
+ OPT_QRT_RANGE_BASE,
164
181
+ OPT_ENABLE_QRT_STATS,
182
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
165
183
OPT_IGNORE_BUILTIN_INNODB,
166
184
OPT_BINLOG_DIRECT_NON_TRANS_UPDATE,
167
185
OPT_DEFAULT_CHARACTER_SET_OLD
168
@@ -6969,6 +6977,21 @@
186
@@ -6969,6 +6985,23 @@
169
187
"Use microsecond time's precision in slow query log",
170
188
(uchar**) &opt_slow_query_log_microseconds_timestamp, (uchar**) &opt_slow_query_log_microseconds_timestamp,
171
189
0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
190
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
172
191
+ {"query_response_time_range_base", OPT_QRT_RANGE_BASE,
173
192
+ "Select base of log for query_response_time ranges. WARNING: variable change affect only after flush",
174
193
+ (uchar**) &opt_query_response_time_range_base, (uchar**) &opt_query_response_time_range_base,
184
203
+ "Enable or disable query response time statisics collecting",
185
204
+ (uchar**) &opt_enable_query_response_time_stats, (uchar**) &opt_enable_query_response_time_stats,
186
205
+ 0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
206
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
187
207
{"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
188
208
"If set to 1, table names are stored in lowercase on disk and table names "
189
209
"will be case-insensitive. Should be set to 2 if you are using a case-"
210
@@ -8183,6 +8216,11 @@
212
have_query_cache=SHOW_OPTION_NO;
214
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
215
+ have_response_time_distribution= SHOW_OPTION_YES;
216
+#else /* HAVE_RESPONSE_TIME_DISTRIBUTION */
217
+ have_response_time_distribution= SHOW_OPTION_NO;
218
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
220
have_geometry=SHOW_OPTION_YES;
190
222
diff -ruN a/sql/query_response_time.cc b/sql/query_response_time.cc
191
223
--- a/sql/query_response_time.cc 1970-01-01 00:00:00.000000000 +0000
192
224
+++ b/sql/query_response_time.cc 2010-11-02 15:34:52.000000000 +0000
194
226
+#ifdef __FreeBSD__
195
227
+#include <sys/types.h>
196
228
+#include <machine/atomic.h>
197
229
+#endif // __FreeBSD__
198
230
+#include "my_global.h"
231
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
199
232
+#include "mysql_priv.h"
200
233
+#include "mysql_com.h"
201
234
+#include "rpl_tblmap.h"
625
659
+extern ST_SCHEMA_TABLE query_response_time_table;
661
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
627
662
+extern void query_response_time_init ();
628
663
+extern void query_response_time_free ();
629
664
+extern void query_response_time_flush ();
630
665
+extern void query_response_time_collect(ulonglong query_time);
631
666
+extern int query_response_time_fill (THD* thd, TABLE_LIST *tables, COND *cond);
667
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
633
669
+#endif // QUERY_RESPONSE_TIME_H
634
670
diff -ruN a/sql/set_var.cc b/sql/set_var.cc
635
671
--- a/sql/set_var.cc 2010-11-01 08:43:57.000000000 +0000
636
672
+++ b/sql/set_var.cc 2010-11-01 08:52:40.000000000 +0000
637
@@ -1006,6 +1006,10 @@
673
@@ -1006,6 +1006,14 @@
638
674
static sys_var_use_global_long_query_time sys_use_global_long_query_time;
639
675
static sys_var_bool_ptr sys_slow_query_log_microseconds_timestamp(&vars, "slow_query_log_microseconds_timestamp",
640
676
&opt_slow_query_log_microseconds_timestamp);
677
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
641
678
+static sys_var_bool_ptr sys_enable_query_response_time_stats(&vars, "enable_query_response_time_stats",
642
679
+ &opt_enable_query_response_time_stats);
643
680
+static sys_var_long_ptr sys_query_response_time_range_base(&vars, "query_response_time_range_base",
644
681
+ &opt_query_response_time_range_base);
682
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
683
+static sys_var_have_variable sys_have_response_time_distribution(&vars, "have_response_time_distribution",
684
+ &have_response_time_distribution);
645
685
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */
646
686
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries",
647
687
&opt_slow_log, QUERY_LOG_SLOW);
743
790
+ {"total", QRT_TIME_STRING_LENGTH, MYSQL_TYPE_STRING, 0, 0, "", SKIP_OPEN_TABLE },
744
791
+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE }
747
793
ST_SCHEMA_TABLE schema_tables[]=
749
795
{"CHARACTER_SETS", charsets_fields_info, create_schema_table,
750
@@ -7521,6 +7530,8 @@
796
@@ -7521,6 +7529,13 @@
751
797
1, 9, 0, OPEN_TABLE_ONLY},
752
798
{"ROUTINES", proc_fields_info, create_schema_table,
753
799
fill_schema_proc, make_proc_old_format, 0, -1, -1, 0, 0},
800
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
754
801
+ {"QUERY_RESPONSE_TIME", query_response_time_fields_info, create_schema_table,
755
802
+ query_response_time_fill, make_old_format, 0, -1, -1, 0, 0},
803
+#else /* HAVE_RESPONSE_TIME_DISTRIBUTION */
804
+ {"QUERY_RESPONSE_TIME", query_response_time_fields_info, create_schema_table,
805
+ 0, make_old_format, 0, -1, -1, 0, 0},
806
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
756
807
{"SCHEMATA", schema_fields_info, create_schema_table,
757
808
fill_schema_schemata, make_schemata_old_format, 0, 1, -1, 0, 0},
758
809
{"SCHEMA_PRIVILEGES", schema_privileges_fields_info, create_schema_table,
768
819
%token RANGE_SYM /* SQL-2003-R */
769
820
%token READS_SYM /* SQL-2003-R */
770
@@ -10396,6 +10397,13 @@
821
@@ -10396,6 +10397,15 @@
771
822
if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
774
825
+ | QUERY_RESPONSE_TIME_SYM wild_and_where
827
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
777
829
+ lex->sql_command= SQLCOM_SELECT;
778
830
+ if (prepare_schema_table(YYTHD, lex, 0, SCH_QUERY_RESPONSE_TIME))
832
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
781
834
| CREATE PROCEDURE sp_name
784
@@ -10616,6 +10624,8 @@
837
@@ -10616,6 +10626,12 @@
785
838
{ Lex->type|= REFRESH_TABLE_STATS; }
786
839
| INDEX_STATS_SYM
787
840
{ Lex->type|= REFRESH_INDEX_STATS; }
788
841
+ | QUERY_RESPONSE_TIME_SYM
789
+ { Lex->type|= REFRESH_QUERY_RESPONSE_TIME; }
843
+#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
844
+ Lex->type|= REFRESH_QUERY_RESPONSE_TIME;
845
+#endif /* HAVE_RESPONSE_TIME_DISTRIBUTION */
791
848
{ Lex->type|= REFRESH_MASTER; }
793
@@ -11895,6 +11905,7 @@
850
@@ -11895,6 +11911,7 @@
794
851
| PROFILES_SYM {}
810
867
SCH_SCHEMA_PRIVILEGES,
811
868
SCH_SESSION_STATUS,
869
diff -ruN a/configure.in b/configure.in
870
--- a/configure.in 2010-12-07 19:19:42.000000000 +0300
871
+++ b/configure.in 2010-12-07 19:21:39.000000000 +0300
872
@@ -2718,7 +2718,16 @@
873
AC_SUBST(readline_link)
874
AC_SUBST(readline_h_ln_cmd)
876
+AC_ARG_WITH(response_time_distribution,
877
+ AC_HELP_STRING([--without-response_time_distribution],[Disable response_time_distribution feature.]),
878
+ [with_response_time_distribution=$withval],
879
+ [with_response_time_distribution=yes]
882
+if test "$with_response_time_distribution" = "yes"
884
+ AC_DEFINE([HAVE_RESPONSE_TIME_DISTRIBUTION], [1], [If we want to have response_time_distribution])
887
# Include man pages, if desired, adapted to the configured parts.
888
if test X"$with_man" = Xyes