102.1.1
by kinoyasu
add header and rule, as the first step of the reordering patch for separate release |
1 |
# name : slow_extended.patch |
2 |
# introduced : 11 or before |
|
142
by Oleg Tsarev
bug fix 673426 |
3 |
# maintainer : Oleg |
102.1.1
by kinoyasu
add header and rule, as the first step of the reordering patch for separate release |
4 |
# |
5 |
#!!! notice !!! |
|
6 |
# Any small change to this file in the main branch |
|
7 |
# should be done or reviewed by the maintainer! |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
8 |
--- a/include/mysql/plugin.h
|
9 |
+++ b/include/mysql/plugin.h
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
10 |
@@ -694,6 +694,17 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
11 |
/* Increments the row counter, see THD::row_count */ |
12 |
void thd_inc_row_count(MYSQL_THD thd); |
|
13 |
||
14 |
+void increment_thd_innodb_stats(MYSQL_THD thd,
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
15 |
+ unsigned long long trx_id,
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
16 |
+ long io_reads,
|
17 |
+ long long io_read,
|
|
18 |
+ long io_reads_wait_timer,
|
|
19 |
+ long lock_que_wait_timer,
|
|
20 |
+ long que_wait_timer,
|
|
21 |
+ long page_access);
|
|
22 |
+unsigned long thd_log_slow_verbosity(const MYSQL_THD thd);
|
|
23 |
+int thd_opt_slow_log();
|
|
24 |
+#define EXTENDED_SLOWLOG
|
|
25 |
/** |
|
26 |
Create a temporary file. |
|
27 |
||
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
28 |
--- a/include/mysql/plugin.h.pp
|
29 |
+++ b/include/mysql/plugin.h.pp
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
30 |
@@ -122,6 +122,16 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
31 |
char *thd_security_context(void* thd, char *buffer, unsigned int length, |
32 |
unsigned int max_query_len); |
|
33 |
void thd_inc_row_count(void* thd); |
|
34 |
+void increment_thd_innodb_stats(void* thd,
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
35 |
+ unsigned long long trx_id,
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
36 |
+ long io_reads,
|
37 |
+ long long io_read,
|
|
38 |
+ long io_reads_wait_timer,
|
|
39 |
+ long lock_que_wait_timer,
|
|
40 |
+ long que_wait_timer,
|
|
41 |
+ long page_access);
|
|
42 |
+unsigned long thd_log_slow_verbosity(const void* thd);
|
|
43 |
+int thd_opt_slow_log();
|
|
44 |
int mysql_tmpfile(const char *prefix); |
|
45 |
int thd_killed(const void* thd); |
|
46 |
unsigned long thd_get_thread_id(const void* thd); |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
47 |
--- /dev/null
|
48 |
+++ b/patch_info/slow_extended.info
|
|
138.1.1
by Oleg Tsarev
fix bug 673426 |
49 |
@@ -0,0 +1,24 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
50 |
+File=slow_extended.patch
|
51 |
+Name=Extended statistics in slow.log (not InnoDB part)
|
|
54.2.2
by Oleg Tsarev
merge slow_extended_fix_overflow.patch to slow_extended.patch |
52 |
+Version=1.3
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
53 |
+Author=Percona <info@percona.com>
|
54 |
+License=GPL
|
|
55 |
+Comment=
|
|
56 |
+Changelog
|
|
57 |
+2008-11-26
|
|
58 |
+YK: Fix inefficient determination of trx, Make not to call useless gettimeofday when don't use slow log. Make log_slow_queries dynamic (bool).
|
|
59 |
+
|
|
60 |
+2008-11-07
|
|
61 |
+VT: Moved log_slow_rate_limit in SHOW VARIABLE into right place
|
|
62 |
+
|
|
63 |
+2008-11
|
|
64 |
+Arjen Lentz: Fixups (backward compatibility) by Arjen Lentz <arjen@openquery.com.au>
|
|
54.2.2
by Oleg Tsarev
merge slow_extended_fix_overflow.patch to slow_extended.patch |
65 |
+
|
66 |
+2010-07
|
|
54.2.5
by Oleg Tsarev
merge control-global-slow-2.patch to slow_extended.patch |
67 |
+1) Fix overflow of query time and lock time (Bug 600360) (slow_extended_fix_overflow.patch merged)
|
68 |
+2) Control global slow feature merged (control_global_slow.patch merged)
|
|
69 |
+3) Microseconds in slow query log merged (microseconds_in_slow_query_log.patch merged)
|
|
70 |
+4) Now use_global_long_query_time and use_global_log_slow_control are synonims. Add value "all" for use_global_log_slow_control (contol-global_slow-2.patch merged)
|
|
58.1.1
by Oleg Tsarev
merge slow_extended_slave_innodb_stats_fix.patch to slow_extended.patch |
71 |
+5) Fix innodb_stats on replication (Bug 600684)
|
138.1.1
by Oleg Tsarev
fix bug 673426 |
72 |
+6) Change variable types (system/command-line)
|
54.2.5
by Oleg Tsarev
merge control-global-slow-2.patch to slow_extended.patch |
73 |
+
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
74 |
--- a/scripts/mysqldumpslow.sh
|
75 |
+++ b/scripts/mysqldumpslow.sh
|
|
195
by Oleg Tsarev
Port Oleg and Alexey patches to 5.1.55 |
76 |
@@ -101,8 +101,8 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
77 |
s/^#? Time: \d{6}\s+\d+:\d+:\d+.*\n//; |
78 |
my ($user,$host) = s/^#? User\@Host:\s+(\S+)\s+\@\s+(\S+).*\n// ? ($1,$2) : ('',''); |
|
79 |
||
80 |
- s/^# Query_time: ([0-9.]+)\s+Lock_time: ([0-9.]+)\s+Rows_sent: ([0-9.]+).*\n//;
|
|
81 |
- my ($t, $l, $r) = ($1, $2, $3);
|
|
82 |
+ s/^# Query_time: (\d+(\.\d+)?) Lock_time: (\d+(\.\d+)?) Rows_sent: (\d+(\.\d+)?).*\n//;
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
83 |
+ my ($t, $l, $r)= ($1, $3, $5);
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
84 |
$t -= $l unless $opt{l}; |
85 |
||
86 |
# remove fluff that mysqld writes to log when it (re)starts: |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
87 |
--- a/sql/event_scheduler.cc
|
88 |
+++ b/sql/event_scheduler.cc
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
89 |
@@ -193,6 +193,7 @@
|
90 |
thd->client_capabilities|= CLIENT_MULTI_RESULTS; |
|
91 |
pthread_mutex_lock(&LOCK_thread_count); |
|
92 |
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++; |
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
93 |
+ thd->write_to_slow_log= TRUE;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
94 |
pthread_mutex_unlock(&LOCK_thread_count); |
95 |
||
96 |
/* |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
97 |
--- a/sql/filesort.cc
|
98 |
+++ b/sql/filesort.cc
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
99 |
@@ -190,6 +190,7 @@
|
100 |
{ |
|
101 |
status_var_increment(thd->status_var.filesort_scan_count); |
|
102 |
} |
|
103 |
+ thd->query_plan_flags|= QPLAN_FILESORT;
|
|
104 |
#ifdef CAN_TRUST_RANGE |
|
105 |
if (select && select->quick && select->quick->records > 0L) |
|
106 |
{ |
|
107 |
@@ -255,6 +256,7 @@
|
|
108 |
} |
|
109 |
else |
|
110 |
{ |
|
111 |
+ thd->query_plan_flags|= QPLAN_FILESORT_DISK;
|
|
112 |
if (table_sort.buffpek && table_sort.buffpek_len < maxbuffer) |
|
113 |
{ |
|
114 |
x_free(table_sort.buffpek); |
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
115 |
@@ -1203,6 +1205,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
116 |
DBUG_ENTER("merge_buffers"); |
117 |
||
118 |
status_var_increment(current_thd->status_var.filesort_merge_passes); |
|
119 |
+ current_thd->query_plan_fsort_passes++;
|
|
120 |
if (param->not_killable) |
|
121 |
{ |
|
122 |
killed= ¬_killable; |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
123 |
--- a/sql/log.cc
|
124 |
+++ b/sql/log.cc
|
|
54.2.4
by Oleg Tsarev
merge microseconds_in_slow_query_log.patch to slow_extended.patch |
125 |
@@ -524,11 +524,13 @@
|
126 |
*/ |
|
127 |
||
128 |
bool Log_to_csv_event_handler:: |
|
129 |
- log_slow(THD *thd, time_t current_time, time_t query_start_arg,
|
|
130 |
+ log_slow(THD *thd, ulonglong current_utime, time_t query_start_arg,
|
|
131 |
const char *user_host, uint user_host_len, |
|
132 |
ulonglong query_utime, ulonglong lock_utime, bool is_command, |
|
133 |
const char *sql_text, uint sql_text_len) |
|
134 |
{ |
|
135 |
+ time_t current_time= my_time_possible_from_micro(current_utime);
|
|
136 |
+
|
|
137 |
TABLE_LIST table_list; |
|
138 |
TABLE *table; |
|
139 |
bool result= TRUE; |
|
140 |
@@ -754,14 +756,14 @@
|
|
141 |
/** Wrapper around MYSQL_LOG::write() for slow log. */ |
|
142 |
||
143 |
bool Log_to_file_event_handler:: |
|
144 |
- log_slow(THD *thd, time_t current_time, time_t query_start_arg,
|
|
145 |
+ log_slow(THD *thd, ulonglong current_utime, time_t query_start_arg,
|
|
146 |
const char *user_host, uint user_host_len, |
|
147 |
ulonglong query_utime, ulonglong lock_utime, bool is_command, |
|
148 |
const char *sql_text, uint sql_text_len) |
|
149 |
{ |
|
150 |
Silence_log_table_errors error_handler; |
|
151 |
thd->push_internal_handler(&error_handler); |
|
152 |
- bool retval= mysql_slow_log.write(thd, current_time, query_start_arg,
|
|
153 |
+ bool retval= mysql_slow_log.write(thd, current_utime, query_start_arg,
|
|
154 |
user_host, user_host_len, |
|
155 |
query_utime, lock_utime, is_command, |
|
156 |
sql_text, sql_text_len); |
|
157 |
@@ -987,7 +989,7 @@
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
158 |
/* fill in user_host value: the format is "%s[%s] @ %s [%s]" */ |
159 |
user_host_len= (strxnmov(user_host_buff, MAX_USER_HOST_SIZE, |
|
160 |
sctx->priv_user ? sctx->priv_user : "", "[", |
|
161 |
- sctx->user ? sctx->user : "", "] @ ",
|
|
162 |
+ sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""), "] @ ",
|
|
163 |
sctx->host ? sctx->host : "", " [", |
|
164 |
sctx->ip ? sctx->ip : "", "]", NullS) - |
|
165 |
user_host_buff); |
|
54.2.4
by Oleg Tsarev
merge microseconds_in_slow_query_log.patch to slow_extended.patch |
166 |
@@ -995,8 +997,22 @@
|
54.2.2
by Oleg Tsarev
merge slow_extended_fix_overflow.patch to slow_extended.patch |
167 |
current_time= my_time_possible_from_micro(current_utime); |
168 |
if (thd->start_utime) |
|
169 |
{ |
|
170 |
- query_utime= (current_utime - thd->start_utime);
|
|
171 |
- lock_utime= (thd->utime_after_lock - thd->start_utime);
|
|
172 |
+ if(current_utime < thd->start_utime)
|
|
173 |
+ {
|
|
174 |
+ query_utime= 0;
|
|
175 |
+ }
|
|
176 |
+ else
|
|
177 |
+ {
|
|
178 |
+ query_utime= (current_utime - thd->start_utime);
|
|
179 |
+ }
|
|
180 |
+ if(thd->utime_after_lock < thd->start_utime)
|
|
181 |
+ {
|
|
182 |
+ lock_utime= 0;
|
|
183 |
+ }
|
|
184 |
+ else
|
|
185 |
+ {
|
|
186 |
+ lock_utime= (thd->utime_after_lock - thd->start_utime);
|
|
187 |
+ }
|
|
188 |
} |
|
189 |
else |
|
190 |
{ |
|
181.1.1
by Alexey Kopytov
Bug #693818: funcs_1.storedproc fails on 12.4 |
191 |
@@ -1010,8 +1026,21 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
192 |
query_length= command_name[thd->command].length; |
193 |
} |
|
194 |
||
195 |
+ if (!query_length)
|
|
196 |
+ {
|
|
197 |
+ thd->sent_row_count= thd->examined_row_count= 0;
|
|
198 |
+ thd->row_count= 0;
|
|
181.1.1
by Alexey Kopytov
Bug #693818: funcs_1.storedproc fails on 12.4 |
199 |
+ thd->orig_row_count= 0;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
200 |
+ thd->bytes_sent_old= thd->status_var.bytes_sent;
|
201 |
+ thd->tmp_tables_used= thd->tmp_tables_disk_used= 0;
|
|
202 |
+ thd->tmp_tables_size= 0;
|
|
203 |
+ thd->innodb_was_used= FALSE;
|
|
204 |
+ thd->query_plan_flags= QPLAN_NONE;
|
|
205 |
+ thd->query_plan_fsort_passes= 0;
|
|
206 |
+ }
|
|
207 |
+
|
|
208 |
for (current_handler= slow_log_handler_list; *current_handler ;) |
|
54.2.4
by Oleg Tsarev
merge microseconds_in_slow_query_log.patch to slow_extended.patch |
209 |
- error= (*current_handler++)->log_slow(thd, current_time, thd->start_time,
|
210 |
+ error= (*current_handler++)->log_slow(thd, current_utime, thd->start_time,
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
211 |
user_host_buff, user_host_len, |
54.2.4
by Oleg Tsarev
merge microseconds_in_slow_query_log.patch to slow_extended.patch |
212 |
query_utime, lock_utime, is_command, |
213 |
query, query_length) || error; |
|
195
by Oleg Tsarev
Port Oleg and Alexey patches to 5.1.55 |
214 |
@@ -2282,12 +2311,13 @@
|
54.2.4
by Oleg Tsarev
merge microseconds_in_slow_query_log.patch to slow_extended.patch |
215 |
TRUE - error occured |
216 |
*/ |
|
217 |
||
218 |
-bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
|
|
219 |
+bool MYSQL_QUERY_LOG::write(THD *thd, ulonglong current_utime,
|
|
220 |
time_t query_start_arg, const char *user_host, |
|
221 |
uint user_host_len, ulonglong query_utime, |
|
222 |
ulonglong lock_utime, bool is_command, |
|
223 |
const char *sql_text, uint sql_text_len) |
|
224 |
{ |
|
225 |
+ time_t current_time= my_time_possible_from_micro(current_utime);
|
|
226 |
bool error= 0; |
|
227 |
DBUG_ENTER("MYSQL_QUERY_LOG::write"); |
|
228 |
||
195
by Oleg Tsarev
Port Oleg and Alexey patches to 5.1.55 |
229 |
@@ -2309,17 +2339,28 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
230 |
|
231 |
if (!(specialflag & SPECIAL_SHORT_LOG_FORMAT)) |
|
232 |
{ |
|
233 |
- if (current_time != last_time)
|
|
234 |
+ if (opt_log_slow_timestamp_every || current_time != last_time)
|
|
235 |
{ |
|
236 |
last_time= current_time; |
|
237 |
struct tm start; |
|
54.2.4
by Oleg Tsarev
merge microseconds_in_slow_query_log.patch to slow_extended.patch |
238 |
localtime_r(¤t_time, &start); |
239 |
-
|
|
240 |
- buff_len= my_snprintf(buff, sizeof buff,
|
|
241 |
- "# Time: %02d%02d%02d %2d:%02d:%02d\n",
|
|
242 |
- start.tm_year % 100, start.tm_mon + 1,
|
|
243 |
- start.tm_mday, start.tm_hour,
|
|
244 |
- start.tm_min, start.tm_sec);
|
|
245 |
+ if(opt_slow_query_log_microseconds_timestamp)
|
|
246 |
+ {
|
|
247 |
+ ulonglong microsecond = current_utime % (1000 * 1000);
|
|
248 |
+ buff_len= snprintf(buff, sizeof buff,
|
|
249 |
+ "# Time: %02d%02d%02d %2d:%02d:%02d.%010lld\n",
|
|
250 |
+ start.tm_year % 100, start.tm_mon + 1,
|
|
251 |
+ start.tm_mday, start.tm_hour,
|
|
252 |
+ start.tm_min, start.tm_sec,microsecond);
|
|
253 |
+ }
|
|
254 |
+ else
|
|
255 |
+ {
|
|
256 |
+ buff_len= my_snprintf(buff, sizeof buff,
|
|
257 |
+ "# Time: %02d%02d%02d %2d:%02d:%02d\n",
|
|
258 |
+ start.tm_year % 100, start.tm_mon + 1,
|
|
259 |
+ start.tm_mday, start.tm_hour,
|
|
260 |
+ start.tm_min, start.tm_sec);
|
|
261 |
+ }
|
|
262 |
||
263 |
/* Note that my_b_write() assumes it knows the length for this */ |
|
264 |
if (my_b_write(&log_file, (uchar*) buff, buff_len)) |
|
195
by Oleg Tsarev
Port Oleg and Alexey patches to 5.1.55 |
265 |
@@ -2337,12 +2378,64 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
266 |
sprintf(query_time_buff, "%.6f", ulonglong2double(query_utime)/1000000.0); |
267 |
sprintf(lock_time_buff, "%.6f", ulonglong2double(lock_utime)/1000000.0); |
|
268 |
if (my_b_printf(&log_file, |
|
269 |
- "# Query_time: %s Lock_time: %s"
|
|
270 |
- " Rows_sent: %lu Rows_examined: %lu\n",
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
271 |
+ "# Thread_id: %lu Schema: %s Last_errno: %u Killed: %u\n" \
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
272 |
+ "# Query_time: %s Lock_time: %s Rows_sent: %lu Rows_examined: %lu Rows_affected: %lu Rows_read: %lu\n"
|
273 |
+ "# Bytes_sent: %lu Tmp_tables: %lu Tmp_disk_tables: %lu Tmp_table_sizes: %lu\n",
|
|
274 |
+ (ulong) thd->thread_id, (thd->db ? thd->db : ""),
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
275 |
+ thd->last_errno, (uint) thd->killed,
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
276 |
query_time_buff, lock_time_buff, |
277 |
(ulong) thd->sent_row_count, |
|
278 |
- (ulong) thd->examined_row_count) == (uint) -1)
|
|
279 |
+ (ulong) thd->examined_row_count,
|
|
280 |
+ ((long) thd->row_count_func > 0 ) ? (ulong) thd->row_count_func : 0,
|
|
181.1.1
by Alexey Kopytov
Bug #693818: funcs_1.storedproc fails on 12.4 |
281 |
+ thd->row_count - thd->orig_row_count + 1,
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
282 |
+ (ulong) (thd->status_var.bytes_sent - thd->bytes_sent_old),
|
283 |
+ (ulong) thd->tmp_tables_used,
|
|
284 |
+ (ulong) thd->tmp_tables_disk_used,
|
|
285 |
+ (ulong) thd->tmp_tables_size) == (uint) -1)
|
|
286 |
tmp_errno= errno; |
|
5
by kinoyasu
adjust InnoDB_trx_id: at slow_log, clean patches affected |
287 |
+ if (thd->innodb_was_used)
|
288 |
+ {
|
|
289 |
+ char buf[20];
|
|
290 |
+ snprintf(buf, 20, "%llX", thd->innodb_trx_id);
|
|
291 |
+ if (my_b_printf(&log_file,
|
|
292 |
+ "# InnoDB_trx_id: %s\n", buf) == (uint) -1)
|
|
293 |
+ tmp_errno=errno;
|
|
294 |
+ }
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
295 |
+ if ((thd->variables.log_slow_verbosity & SLOG_V_QUERY_PLAN) &&
|
296 |
+ my_b_printf(&log_file,
|
|
297 |
+ "# QC_Hit: %s Full_scan: %s Full_join: %s Tmp_table: %s Tmp_table_on_disk: %s\n" \
|
|
298 |
+ "# Filesort: %s Filesort_on_disk: %s Merge_passes: %lu\n",
|
|
299 |
+ ((thd->query_plan_flags & QPLAN_QC) ? "Yes" : "No"),
|
|
300 |
+ ((thd->query_plan_flags & QPLAN_FULL_SCAN) ? "Yes" : "No"),
|
|
301 |
+ ((thd->query_plan_flags & QPLAN_FULL_JOIN) ? "Yes" : "No"),
|
|
302 |
+ ((thd->query_plan_flags & QPLAN_TMP_TABLE) ? "Yes" : "No"),
|
|
303 |
+ ((thd->query_plan_flags & QPLAN_TMP_DISK) ? "Yes" : "No"),
|
|
304 |
+ ((thd->query_plan_flags & QPLAN_FILESORT) ? "Yes" : "No"),
|
|
305 |
+ ((thd->query_plan_flags & QPLAN_FILESORT_DISK) ? "Yes" : "No"),
|
|
306 |
+ thd->query_plan_fsort_passes) == (uint) -1)
|
|
307 |
+ tmp_errno=errno;
|
|
308 |
+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) && thd->innodb_was_used)
|
|
309 |
+ {
|
|
5
by kinoyasu
adjust InnoDB_trx_id: at slow_log, clean patches affected |
310 |
+ char buf[3][20];
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
311 |
+ snprintf(buf[0], 20, "%.6f", thd->innodb_io_reads_wait_timer / 1000000.0);
|
312 |
+ snprintf(buf[1], 20, "%.6f", thd->innodb_lock_que_wait_timer / 1000000.0);
|
|
313 |
+ snprintf(buf[2], 20, "%.6f", thd->innodb_innodb_que_wait_timer / 1000000.0);
|
|
314 |
+ if (my_b_printf(&log_file,
|
|
315 |
+ "# InnoDB_IO_r_ops: %lu InnoDB_IO_r_bytes: %lu InnoDB_IO_r_wait: %s\n" \
|
|
316 |
+ "# InnoDB_rec_lock_wait: %s InnoDB_queue_wait: %s\n" \
|
|
317 |
+ "# InnoDB_pages_distinct: %lu\n",
|
|
318 |
+ (ulong) thd->innodb_io_reads,
|
|
319 |
+ (ulong) thd->innodb_io_read,
|
|
320 |
+ buf[0], buf[1], buf[2],
|
|
321 |
+ (ulong) thd->innodb_page_access) == (uint) -1)
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
322 |
+ tmp_errno= errno;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
323 |
+ }
|
324 |
+ else
|
|
325 |
+ {
|
|
326 |
+ if ((thd->variables.log_slow_verbosity & SLOG_V_INNODB) &&
|
|
327 |
+ my_b_printf(&log_file,"# No InnoDB statistics available for this query\n") == (uint) -1)
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
328 |
+ tmp_errno= errno;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
329 |
+ }
|
330 |
if (thd->db && strcmp(thd->db, db)) |
|
331 |
{ // Database changed |
|
332 |
if (my_b_printf(&log_file,"use %s;\n",thd->db) == (uint) -1) |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
333 |
--- a/sql/log.h
|
334 |
+++ b/sql/log.h
|
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
335 |
@@ -211,7 +211,7 @@
|
336 |
uint user_host_len, int thread_id, |
|
337 |
const char *command_type, uint command_type_len, |
|
338 |
const char *sql_text, uint sql_text_len); |
|
339 |
- bool write(THD *thd, time_t current_time, time_t query_start_arg,
|
|
340 |
+ bool write(THD *thd, ulonglong current_utime, time_t query_start_arg,
|
|
341 |
const char *user_host, uint user_host_len, |
|
342 |
ulonglong query_utime, ulonglong lock_utime, bool is_command, |
|
343 |
const char *sql_text, uint sql_text_len); |
|
344 |
@@ -425,7 +425,7 @@
|
|
345 |
virtual bool init()= 0; |
|
346 |
virtual void cleanup()= 0; |
|
347 |
||
348 |
- virtual bool log_slow(THD *thd, time_t current_time,
|
|
349 |
+ virtual bool log_slow(THD *thd, ulonglong current_utime,
|
|
350 |
time_t query_start_arg, const char *user_host, |
|
351 |
uint user_host_len, ulonglong query_utime, |
|
352 |
ulonglong lock_utime, bool is_command, |
|
353 |
@@ -454,7 +454,7 @@
|
|
354 |
virtual bool init(); |
|
355 |
virtual void cleanup(); |
|
356 |
||
357 |
- virtual bool log_slow(THD *thd, time_t current_time,
|
|
358 |
+ virtual bool log_slow(THD *thd, ulonglong current_utime,
|
|
359 |
time_t query_start_arg, const char *user_host, |
|
360 |
uint user_host_len, ulonglong query_utime, |
|
361 |
ulonglong lock_utime, bool is_command, |
|
362 |
@@ -486,7 +486,7 @@
|
|
363 |
virtual bool init(); |
|
364 |
virtual void cleanup(); |
|
365 |
||
366 |
- virtual bool log_slow(THD *thd, time_t current_time,
|
|
367 |
+ virtual bool log_slow(THD *thd, ulonglong current_utime,
|
|
368 |
time_t query_start_arg, const char *user_host, |
|
369 |
uint user_host_len, ulonglong query_utime, |
|
370 |
ulonglong lock_utime, bool is_command, |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
371 |
--- a/sql/log_event.cc
|
372 |
+++ b/sql/log_event.cc
|
|
195
by Oleg Tsarev
Port Oleg and Alexey patches to 5.1.55 |
373 |
@@ -3090,6 +3090,7 @@
|
58.1.1
by Oleg Tsarev
merge slow_extended_slave_innodb_stats_fix.patch to slow_extended.patch |
374 |
LEX_STRING new_db; |
375 |
int expected_error,actual_error= 0; |
|
376 |
HA_CREATE_INFO db_options; |
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
377 |
+ bool process_log_slow_statement= false;
|
58.1.1
by Oleg Tsarev
merge slow_extended_slave_innodb_stats_fix.patch to slow_extended.patch |
378 |
|
379 |
/* |
|
380 |
Colleagues: please never free(thd->catalog) in MySQL. This would |
|
195
by Oleg Tsarev
Port Oleg and Alexey patches to 5.1.55 |
381 |
@@ -3271,19 +3272,7 @@
|
58.1.1
by Oleg Tsarev
merge slow_extended_slave_innodb_stats_fix.patch to slow_extended.patch |
382 |
/* Execute the query (note that we bypass dispatch_command()) */ |
383 |
const char* found_semicolon= NULL; |
|
384 |
mysql_parse(thd, thd->query(), thd->query_length(), &found_semicolon); |
|
385 |
- log_slow_statement(thd);
|
|
386 |
-
|
|
387 |
- /*
|
|
388 |
- Resetting the enable_slow_log thd variable.
|
|
389 |
-
|
|
390 |
- We need to reset it back to the opt_log_slow_slave_statements
|
|
391 |
- value after the statement execution (and slow logging
|
|
392 |
- is done). It might have changed if the statement was an
|
|
393 |
- admin statement (in which case, down in mysql_parse execution
|
|
394 |
- thd->enable_slow_log is set to the value of
|
|
395 |
- opt_log_slow_admin_statements).
|
|
396 |
- */
|
|
397 |
- thd->enable_slow_log= opt_log_slow_slave_statements;
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
398 |
+ process_log_slow_statement= true;
|
58.1.1
by Oleg Tsarev
merge slow_extended_slave_innodb_stats_fix.patch to slow_extended.patch |
399 |
} |
400 |
else |
|
401 |
{ |
|
195
by Oleg Tsarev
Port Oleg and Alexey patches to 5.1.55 |
402 |
@@ -3428,11 +3417,27 @@
|
58.1.1
by Oleg Tsarev
merge slow_extended_slave_innodb_stats_fix.patch to slow_extended.patch |
403 |
don't suffer from these assignments to 0 as DROP TEMPORARY |
404 |
TABLE uses the db.table syntax. |
|
405 |
*/ |
|
406 |
+ close_thread_tables(thd);
|
|
407 |
+ if(process_log_slow_statement)
|
|
408 |
+ {
|
|
409 |
+ log_slow_statement(thd);
|
|
410 |
+
|
|
411 |
+ /*
|
|
412 |
+ Resetting the enable_slow_log thd variable.
|
|
413 |
+
|
|
414 |
+ We need to reset it back to the opt_log_slow_slave_statements
|
|
415 |
+ value after the statement execution (and slow logging
|
|
416 |
+ is done). It might have changed if the statement was an
|
|
417 |
+ admin statement (in which case, down in mysql_parse execution
|
|
418 |
+ thd->enable_slow_log is set to the value of
|
|
419 |
+ opt_log_slow_admin_statements).
|
|
420 |
+ */
|
|
421 |
+ thd->enable_slow_log= opt_log_slow_slave_statements;
|
|
422 |
+ }
|
|
423 |
thd->catalog= 0; |
|
424 |
thd->set_db(NULL, 0); /* will free the current database */ |
|
425 |
thd->set_query(NULL, 0); |
|
426 |
DBUG_PRINT("info", ("end: query= 0")); |
|
427 |
- close_thread_tables(thd);
|
|
428 |
/* |
|
429 |
As a disk space optimization, future masters will not log an event for |
|
430 |
LAST_INSERT_ID() if that function returned 0 (and thus they will be able |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
431 |
--- a/sql/mysql_priv.h
|
432 |
+++ b/sql/mysql_priv.h
|
|
195
by Oleg Tsarev
Port Oleg and Alexey patches to 5.1.55 |
433 |
@@ -638,6 +638,106 @@
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
434 |
|
435 |
#define STRING_BUFFER_USUAL_SIZE 80 |
|
436 |
||
437 |
+/* Slow log */
|
|
438 |
+
|
|
439 |
+struct msl_opts
|
|
440 |
+{
|
|
441 |
+ ulong val;
|
|
442 |
+ const char *name;
|
|
443 |
+};
|
|
444 |
+
|
|
445 |
+/* use global log slow control */
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
446 |
+#define SLOG_UG_NONE (1UL << 0)
|
447 |
+#define SLOG_UG_LOG_SLOW_FILTER (1UL << 1)
|
|
448 |
+#define SLOG_UG_LOG_SLOW_RATE_LIMIT (1UL << 2)
|
|
449 |
+#define SLOG_UG_LOG_SLOW_VERBOSITY (1UL << 3)
|
|
450 |
+#define SLOG_UG_LONG_QUERY_TIME (1UL << 4)
|
|
451 |
+#define SLOG_UG_MIN_EXAMINED_ROW_LIMIT (1UL << 5)
|
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
452 |
+#define SLOG_UG_ALL SLOG_UG_LOG_SLOW_FILTER | SLOG_UG_LOG_SLOW_RATE_LIMIT | SLOG_UG_LOG_SLOW_VERBOSITY | SLOG_UG_LONG_QUERY_TIME | SLOG_UG_MIN_EXAMINED_ROW_LIMIT
|
453 |
+/* ... */
|
|
454 |
+#define SLOG_UG_INVALID 1##UL << 31
|
|
455 |
+
|
|
456 |
+static const struct msl_opts slog_use_global[]=
|
|
457 |
+ {
|
|
458 |
+ /* Basic flags */
|
|
459 |
+ { SLOG_UG_NONE , "none" },
|
|
460 |
+ { SLOG_UG_LOG_SLOW_FILTER , "log_slow_filter" },
|
|
461 |
+ { SLOG_UG_LOG_SLOW_RATE_LIMIT , "log_slow_rate_limit" },
|
|
462 |
+ { SLOG_UG_LOG_SLOW_VERBOSITY , "log_slow_verbosity" },
|
|
463 |
+ { SLOG_UG_LONG_QUERY_TIME , "long_query_time" },
|
|
464 |
+ { SLOG_UG_MIN_EXAMINED_ROW_LIMIT , "min_examined_row_limit" },
|
|
465 |
+ /* ... */
|
|
466 |
+ { 0, "" },
|
|
467 |
+ /* Complex flags */
|
|
468 |
+ { SLOG_UG_ALL , "all" },
|
|
469 |
+ /* ... */
|
|
470 |
+ { SLOG_UG_INVALID , (char*)0 }
|
|
471 |
+ };
|
|
472 |
+
|
|
473 |
+#define SLOG_V_MICROTIME 1 << 0
|
|
474 |
+#define SLOG_V_QUERY_PLAN 1 << 1
|
|
475 |
+#define SLOG_V_INNODB 1 << 2
|
|
476 |
+/* ... */
|
|
477 |
+#define SLOG_V_INVALID 1##UL << 31
|
|
478 |
+#define SLOG_V_NONE SLOG_V_MICROTIME
|
|
479 |
+
|
|
480 |
+static const struct msl_opts slog_verb[]=
|
|
481 |
+{
|
|
482 |
+ /* Basic flags */
|
|
483 |
+
|
|
484 |
+ { SLOG_V_MICROTIME, "microtime" },
|
|
485 |
+ { SLOG_V_QUERY_PLAN, "query_plan" },
|
|
486 |
+ { SLOG_V_INNODB, "innodb" },
|
|
487 |
+
|
|
488 |
+ /* End of baisc flags */
|
|
489 |
+
|
|
490 |
+ { 0, "" },
|
|
491 |
+
|
|
492 |
+ /* Complex flags */
|
|
493 |
+
|
|
494 |
+ { SLOG_V_MICROTIME, "minimal" },
|
|
495 |
+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN, "standard" },
|
|
496 |
+ { SLOG_V_MICROTIME|SLOG_V_QUERY_PLAN|SLOG_V_INNODB, "full" },
|
|
497 |
+
|
|
498 |
+ /* End of complex flags */
|
|
499 |
+
|
|
500 |
+ { SLOG_V_INVALID, (char *)0 }
|
|
501 |
+};
|
|
502 |
+
|
|
503 |
+#define QPLAN_NONE 0
|
|
504 |
+#define QPLAN_QC 1 << 0
|
|
505 |
+#define QPLAN_QC_NO 1 << 1
|
|
506 |
+#define QPLAN_FULL_SCAN 1 << 2
|
|
507 |
+#define QPLAN_FULL_JOIN 1 << 3
|
|
508 |
+#define QPLAN_TMP_TABLE 1 << 4
|
|
509 |
+#define QPLAN_TMP_DISK 1 << 5
|
|
510 |
+#define QPLAN_FILESORT 1 << 6
|
|
511 |
+#define QPLAN_FILESORT_DISK 1 << 7
|
|
512 |
+/* ... */
|
|
513 |
+#define QPLAN_MAX 1 << 31
|
|
514 |
+
|
|
515 |
+#define SLOG_F_QC_NO QPLAN_QC_NO
|
|
516 |
+#define SLOG_F_FULL_SCAN QPLAN_FULL_SCAN
|
|
517 |
+#define SLOG_F_FULL_JOIN QPLAN_FULL_JOIN
|
|
518 |
+#define SLOG_F_TMP_TABLE QPLAN_TMP_TABLE
|
|
519 |
+#define SLOG_F_TMP_DISK QPLAN_TMP_DISK
|
|
520 |
+#define SLOG_F_FILESORT QPLAN_FILESORT
|
|
521 |
+#define SLOG_F_FILESORT_DISK QPLAN_FILESORT_DISK
|
|
522 |
+#define SLOG_F_INVALID 1##UL << 31
|
|
523 |
+#define SLOG_F_NONE 0
|
|
524 |
+
|
|
525 |
+static const struct msl_opts slog_filter[]=
|
|
526 |
+{
|
|
527 |
+ { SLOG_F_QC_NO, "qc_miss" },
|
|
528 |
+ { SLOG_F_FULL_SCAN, "full_scan" },
|
|
529 |
+ { SLOG_F_FULL_JOIN, "full_join" },
|
|
530 |
+ { SLOG_F_TMP_TABLE, "tmp_table" },
|
|
531 |
+ { SLOG_F_TMP_DISK, "tmp_table_on_disk" },
|
|
532 |
+ { SLOG_F_FILESORT, "filesort" },
|
|
533 |
+ { SLOG_F_FILESORT_DISK, "filesort_on_disk" },
|
|
534 |
+ { SLOG_F_INVALID, (char *)0 }
|
|
535 |
+};
|
|
536 |
+
|
|
537 |
/* |
|
538 |
Some defines for exit codes for ::is_equal class functions. |
|
539 |
*/ |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
540 |
@@ -2002,6 +2102,10 @@
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
541 |
extern my_bool opt_secure_auth; |
542 |
extern char* opt_secure_file_priv; |
|
543 |
extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements; |
|
544 |
+extern my_bool opt_log_slow_sp_statements;
|
|
545 |
+extern my_bool opt_log_slow_timestamp_every;
|
|
546 |
+extern my_bool opt_use_global_long_query_time;
|
|
547 |
+extern my_bool opt_slow_query_log_microseconds_timestamp;
|
|
548 |
extern my_bool sp_automatic_privileges, opt_noacl; |
|
549 |
extern my_bool opt_old_style_user_limits, trust_function_creators; |
|
550 |
extern uint opt_crash_binlog_innodb; |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
551 |
--- a/sql/mysqld.cc
|
552 |
+++ b/sql/mysqld.cc
|
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
553 |
@@ -520,6 +520,10 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
554 |
char* opt_secure_file_priv= 0; |
555 |
my_bool opt_log_slow_admin_statements= 0; |
|
556 |
my_bool opt_log_slow_slave_statements= 0; |
|
557 |
+my_bool opt_log_slow_sp_statements= 0;
|
|
558 |
+my_bool opt_log_slow_timestamp_every= 0;
|
|
559 |
+my_bool opt_use_global_long_query_time= 0;
|
|
54.2.4
by Oleg Tsarev
merge microseconds_in_slow_query_log.patch to slow_extended.patch |
560 |
+my_bool opt_slow_query_log_microseconds_timestamp= 0;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
561 |
my_bool lower_case_file_system= 0; |
562 |
my_bool opt_large_pages= 0; |
|
563 |
my_bool opt_myisam_use_mmap= 0; |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
564 |
@@ -5798,6 +5802,11 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
565 |
OPT_SECURE_FILE_PRIV, |
566 |
OPT_MIN_EXAMINED_ROW_LIMIT, |
|
567 |
OPT_LOG_SLOW_SLAVE_STATEMENTS, |
|
568 |
+ OPT_LOG_SLOW_RATE_LIMIT,
|
|
569 |
+ OPT_LOG_SLOW_VERBOSITY,
|
|
570 |
+ OPT_LOG_SLOW_FILTER,
|
|
571 |
+ OPT_LOG_SLOW_SP_STATEMENTS,
|
|
572 |
+ OPT_LOG_SLOW_TIMESTAMP_EVERY,
|
|
573 |
#if defined(ENABLED_DEBUG_SYNC) |
|
574 |
OPT_DEBUG_SYNC_TIMEOUT, |
|
575 |
#endif /* defined(ENABLED_DEBUG_SYNC) */ |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
576 |
@@ -5805,6 +5814,9 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
577 |
OPT_SLAVE_EXEC_MODE, |
578 |
OPT_GENERAL_LOG_FILE, |
|
579 |
OPT_SLOW_QUERY_LOG_FILE, |
|
580 |
+ OPT_USE_GLOBAL_LONG_QUERY_TIME,
|
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
581 |
+ OPT_USE_GLOBAL_LOG_SLOW_CONTROL,
|
54.2.4
by Oleg Tsarev
merge microseconds_in_slow_query_log.patch to slow_extended.patch |
582 |
+ OPT_SLOW_QUERY_LOG_MICROSECONDS_TIMESTAMP,
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
583 |
OPT_IGNORE_BUILTIN_INNODB, |
584 |
OPT_BINLOG_DIRECT_NON_TRANS_UPDATE, |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
585 |
OPT_DEFAULT_CHARACTER_SET_OLD, |
586 |
@@ -6825,6 +6837,36 @@
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
587 |
"microsecond precision.", |
77
by kinoyasu
port and adjust the part of the patches to 5.1.49: But query_cache_with_comments.patch, response-time-distribution.patch, mysql_remove_eol_carret.patch, log_connection_error.patch, status_wait_query_cache_mutex.patch and sql_no_fcache.patch were not ported yet. Please port them. |
588 |
&long_query_time, &long_query_time, 0, GET_DOUBLE, |
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
589 |
REQUIRED_ARG, 10, 0, LONG_TIMEOUT, 0, 0, 0}, |
590 |
+ {"log_slow_filter", OPT_LOG_SLOW_FILTER,
|
|
591 |
+ "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
|
|
592 |
+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
|
|
593 |
+ {"log_slow_rate_limit", OPT_LOG_SLOW_RATE_LIMIT,
|
|
594 |
+ "Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.",
|
|
595 |
+ (uchar**) &global_system_variables.log_slow_rate_limit,
|
|
596 |
+ (uchar**) &max_system_variables.log_slow_rate_limit, 0, GET_ULONG,
|
|
597 |
+ REQUIRED_ARG, 1, 1, LONG_MAX, 0, 1L, 0},
|
|
598 |
+ {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
|
|
599 |
+ "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
|
|
600 |
+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_MICROTIME, 0, 0},
|
|
601 |
+ {"log_slow_sp_statements", OPT_LOG_SLOW_SP_STATEMENTS,
|
|
602 |
+ "Log slow statements executed by stored procedure to the slow log if it is open.",
|
|
603 |
+ (uchar**) &opt_log_slow_sp_statements, (uchar**) &opt_log_slow_sp_statements,
|
|
177.3.2
by Oleg Tsarev
fix bug #691234 |
604 |
+ 0, GET_BOOL, OPT_ARG, 1, 0, 1, 0, 1, 0},
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
605 |
+ {"log_slow_timestamp_every", OPT_LOG_SLOW_TIMESTAMP_EVERY,
|
606 |
+ "Timestamp is printed for all records of the slow log even if they are same time.",
|
|
607 |
+ (uchar**) &opt_log_slow_timestamp_every, (uchar**) &opt_log_slow_timestamp_every,
|
|
177.3.2
by Oleg Tsarev
fix bug #691234 |
608 |
+ 0, GET_BOOL, OPT_ARG, 0, 0, 1, 0, 1, 0},
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
609 |
+ {"use_global_log_slow_control", OPT_USE_GLOBAL_LOG_SLOW_CONTROL,
|
54.2.5
by Oleg Tsarev
merge control-global-slow-2.patch to slow_extended.patch |
610 |
+ "Choose flags, wich always use the global variables. Multiple flags allowed in a comma-separated string. [none, log_slow_filter, log_slow_rate_limit, log_slow_verbosity, long_query_time, min_examined_row_limit, all]",
|
138.1.1
by Oleg Tsarev
fix bug 673426 |
611 |
+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_UG_NONE, 0, 0},
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
612 |
+ {"use_global_long_query_time", OPT_USE_GLOBAL_LONG_QUERY_TIME,
|
613 |
+ "Control always use global long_query_time or local long_query_time.",
|
|
614 |
+ (uchar**) &opt_use_global_long_query_time, (uchar**) &opt_use_global_long_query_time,
|
|
177.3.2
by Oleg Tsarev
fix bug #691234 |
615 |
+ 0, GET_BOOL, OPT_ARG, 0, 0, 1, 0, 1, 0},
|
54.2.4
by Oleg Tsarev
merge microseconds_in_slow_query_log.patch to slow_extended.patch |
616 |
+ {"slow_query_log_microseconds_timestamp", OPT_SLOW_QUERY_LOG_MICROSECONDS_TIMESTAMP,
|
617 |
+ "Use microsecond time's precision in slow query log",
|
|
618 |
+ (uchar**) &opt_slow_query_log_microseconds_timestamp, (uchar**) &opt_slow_query_log_microseconds_timestamp,
|
|
177.3.2
by Oleg Tsarev
fix bug #691234 |
619 |
+ 0, GET_BOOL, OPT_ARG, 0, 0, 1, 0, 1, 0},
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
620 |
{"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES, |
621 |
"If set to 1, table names are stored in lowercase on disk and table names " |
|
622 |
"will be case-insensitive. Should be set to 2 if you are using a case-" |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
623 |
@@ -7982,6 +8024,10 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
624 |
global_system_variables.old_passwords= 0; |
625 |
global_system_variables.old_alter_table= 0; |
|
626 |
global_system_variables.binlog_format= BINLOG_FORMAT_UNSPEC; |
|
627 |
+
|
|
628 |
+ global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
629 |
+ global_system_variables.use_global_log_slow_control= SLOG_UG_NONE;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
630 |
+ global_system_variables.log_slow_filter= SLOG_F_NONE;
|
631 |
/* |
|
632 |
Default behavior for 4.1 and 5.0 is to treat NULL values as unequal |
|
633 |
when collecting index statistics for MyISAM tables. |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
634 |
@@ -8485,6 +8531,44 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
635 |
case OPT_BOOTSTRAP: |
636 |
opt_noacl=opt_bootstrap=1; |
|
637 |
break; |
|
638 |
+ case OPT_LOG_SLOW_FILTER:
|
|
639 |
+ if ((global_system_variables.log_slow_filter=
|
|
640 |
+ msl_flag_resolve_by_name(slog_filter, argument,
|
|
641 |
+ SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
|
|
642 |
+ {
|
|
643 |
+ fprintf(stderr,"Invalid argument in log_slow_filter: %s\n", argument);
|
|
644 |
+ exit(1);
|
|
645 |
+ }
|
|
646 |
+ break;
|
|
647 |
+ case OPT_LOG_SLOW_VERBOSITY:
|
|
648 |
+ if ((global_system_variables.log_slow_verbosity=
|
|
649 |
+ msl_flag_resolve_by_name(slog_verb, argument,
|
|
650 |
+ SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
|
|
651 |
+ {
|
|
652 |
+ fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
|
|
653 |
+ exit(1);
|
|
654 |
+ }
|
|
655 |
+ break;
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
656 |
+ case OPT_USE_GLOBAL_LONG_QUERY_TIME:
|
657 |
+ use_global_long_query_time_update(opt_use_global_long_query_time);
|
|
658 |
+ break;
|
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
659 |
+ case OPT_USE_GLOBAL_LOG_SLOW_CONTROL:
|
660 |
+ {
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
661 |
+ ulong &v= global_system_variables.use_global_log_slow_control;
|
662 |
+ v= msl_flag_resolve_by_name(slog_use_global, argument, SLOG_UG_NONE, SLOG_UG_INVALID);
|
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
663 |
+ if (v != SLOG_UG_NONE)
|
664 |
+ {
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
665 |
+ v&= ~SLOG_UG_NONE;
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
666 |
+ }
|
667 |
+ if (v == SLOG_UG_INVALID)
|
|
668 |
+ {
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
669 |
+ fprintf(stderr,"Invalid argument in use_global_log_slow_control: %s\n", argument);
|
670 |
+ exit(1);
|
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
671 |
+ }
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
672 |
+ use_global_long_query_time_update
|
673 |
+ (global_system_variables.use_global_log_slow_control & SLOG_UG_LONG_QUERY_TIME);
|
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
674 |
+ break;
|
675 |
+ }
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
676 |
case OPT_SERVER_ID: |
677 |
server_id_supplied = 1; |
|
678 |
break; |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
679 |
--- a/sql/set_var.cc
|
680 |
+++ b/sql/set_var.cc
|
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
681 |
@@ -162,6 +162,74 @@
|
54.2.5
by Oleg Tsarev
merge control-global-slow-2.patch to slow_extended.patch |
682 |
|
683 |
static sys_var_chain vars = { NULL, NULL }; |
|
684 |
||
685 |
+void use_global_long_query_time_update(bool enable)
|
|
686 |
+{
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
687 |
+ ulong &log_slow_control= global_system_variables.use_global_log_slow_control;
|
688 |
+ opt_use_global_long_query_time= enable;
|
|
689 |
+ if (enable)
|
|
690 |
+ log_slow_control|= SLOG_UG_LONG_QUERY_TIME;
|
|
54.2.5
by Oleg Tsarev
merge control-global-slow-2.patch to slow_extended.patch |
691 |
+ else
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
692 |
+ log_slow_control&= ~SLOG_UG_LONG_QUERY_TIME;
|
693 |
+ log_slow_control&= ~SLOG_UG_NONE;
|
|
694 |
+ if (log_slow_control == 0)
|
|
695 |
+ log_slow_control= SLOG_UG_NONE;
|
|
54.2.5
by Oleg Tsarev
merge control-global-slow-2.patch to slow_extended.patch |
696 |
+}
|
697 |
+
|
|
698 |
+class sys_var_use_global_long_query_time : public sys_var_bool_ptr
|
|
699 |
+{
|
|
700 |
+public:
|
|
701 |
+ sys_var_use_global_long_query_time()
|
|
702 |
+ :sys_var_bool_ptr(&vars,"use_global_long_query_time",&opt_use_global_long_query_time)
|
|
703 |
+ {
|
|
704 |
+ chain_sys_var(&vars);
|
|
705 |
+ }
|
|
706 |
+ virtual bool update(THD *thd, set_var *var)
|
|
707 |
+ {
|
|
708 |
+ bool result = sys_var_bool_ptr::update(thd,var);
|
|
709 |
+ sync();
|
|
710 |
+ return result;
|
|
711 |
+ }
|
|
712 |
+ virtual void set_default(THD *thd, enum_var_type type)
|
|
713 |
+ {
|
|
714 |
+ sys_var_bool_ptr::set_default(thd,type);
|
|
715 |
+ sync();
|
|
716 |
+ }
|
|
717 |
+private:
|
|
718 |
+ void sync()
|
|
719 |
+ {
|
|
720 |
+ use_global_long_query_time_update(opt_use_global_long_query_time);
|
|
721 |
+ }
|
|
722 |
+};
|
|
723 |
+class sys_var_use_global_log_slow_control : public sys_var_thd_msl_flag_correct_none
|
|
724 |
+{
|
|
725 |
+ public:
|
|
726 |
+ sys_var_use_global_log_slow_control() : sys_var_thd_msl_flag_correct_none(
|
|
727 |
+ &vars
|
|
728 |
+ ,"use_global_log_slow_control"
|
|
729 |
+ ,&SV::use_global_log_slow_control
|
|
730 |
+ ,SLOG_UG_NONE,SLOG_UG_NONE,SLOG_UG_INVALID
|
|
731 |
+ ,slog_use_global)
|
|
732 |
+ {
|
|
733 |
+ }
|
|
734 |
+ virtual bool update(THD *thd, set_var *var)
|
|
735 |
+ {
|
|
736 |
+ bool result = sys_var_thd_msl_flag_correct_none::update(thd,var);
|
|
737 |
+ sync();
|
|
738 |
+ return result;
|
|
739 |
+ }
|
|
740 |
+ virtual void set_default(THD *thd, enum_var_type type)
|
|
741 |
+ {
|
|
742 |
+ sys_var_thd_msl_flag_correct_none::set_default(thd,type);
|
|
743 |
+ sync();
|
|
744 |
+ }
|
|
745 |
+private:
|
|
746 |
+ void sync()
|
|
747 |
+ {
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
748 |
+ ulong const &variable= global_system_variables.use_global_log_slow_control;
|
54.2.5
by Oleg Tsarev
merge control-global-slow-2.patch to slow_extended.patch |
749 |
+ use_global_long_query_time_update((variable & SLOG_UG_LONG_QUERY_TIME));
|
750 |
+ }
|
|
751 |
+};
|
|
752 |
+
|
|
753 |
static sys_var_thd_ulong |
|
754 |
sys_auto_increment_increment(&vars, "auto_increment_increment", |
|
755 |
&SV::auto_increment_increment, NULL, NULL, |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
756 |
@@ -901,6 +969,30 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
757 |
QUERY_LOG_GENERAL); |
758 |
static sys_var_log_state sys_var_slow_query_log(&vars, "slow_query_log", &opt_slow_log, |
|
759 |
QUERY_LOG_SLOW); |
|
760 |
+static sys_var_thd_ulong sys_log_slow_rate_limit(&vars, "log_slow_rate_limit",
|
|
761 |
+ &SV::log_slow_rate_limit);
|
|
762 |
+static sys_var_thd_msl_flag sys_log_slow_filter(&vars, "log_slow_filter",
|
|
763 |
+ &SV::log_slow_filter,
|
|
764 |
+ SLOG_F_NONE,
|
|
765 |
+ SLOG_F_NONE,
|
|
766 |
+ SLOG_F_INVALID,
|
|
767 |
+ slog_filter);
|
|
768 |
+static sys_var_thd_msl_flag sys_log_slow_verbosity(&vars, "log_slow_verbosity",
|
|
769 |
+ &SV::log_slow_verbosity,
|
|
770 |
+ SLOG_V_NONE,
|
|
771 |
+ SLOG_V_MICROTIME,
|
|
772 |
+ SLOG_V_INVALID,
|
|
773 |
+ slog_verb);
|
|
54.2.5
by Oleg Tsarev
merge control-global-slow-2.patch to slow_extended.patch |
774 |
+static sys_var_use_global_log_slow_control sys_use_global_log_slow_control;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
775 |
+static sys_var_bool_ptr sys_log_slow_slave_statements(&vars, "log_slow_slave_statements",
|
776 |
+ &opt_log_slow_slave_statements);
|
|
777 |
+static sys_var_bool_ptr sys_log_slow_sp_statements(&vars, "log_slow_sp_statements",
|
|
778 |
+ &opt_log_slow_sp_statements);
|
|
779 |
+static sys_var_bool_ptr sys_log_slow_timestamp_every(&vars, "log_slow_timestamp_every",
|
|
780 |
+ &opt_log_slow_timestamp_every);
|
|
54.2.5
by Oleg Tsarev
merge control-global-slow-2.patch to slow_extended.patch |
781 |
+static sys_var_use_global_long_query_time sys_use_global_long_query_time;
|
54.2.4
by Oleg Tsarev
merge microseconds_in_slow_query_log.patch to slow_extended.patch |
782 |
+static sys_var_bool_ptr sys_slow_query_log_microseconds_timestamp(&vars, "slow_query_log_microseconds_timestamp",
|
783 |
+ &opt_slow_query_log_microseconds_timestamp);
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
784 |
/* Synonym of "slow_query_log" for consistency with SHOW VARIABLES output */ |
785 |
static sys_var_log_state sys_var_log_slow(&vars, "log_slow_queries", |
|
786 |
&opt_slow_log, QUERY_LOG_SLOW); |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
787 |
@@ -3711,6 +3803,203 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
788 |
#endif |
789 |
} |
|
790 |
||
791 |
+/* Slow log stuff */
|
|
792 |
+
|
|
793 |
+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len)
|
|
794 |
+{
|
|
795 |
+ ulong i;
|
|
796 |
+
|
|
797 |
+ for (i=0; opts[i].name; i++)
|
|
798 |
+ {
|
|
799 |
+ if (!my_strnncoll(&my_charset_latin1,
|
|
800 |
+ (const uchar *)name, len,
|
|
801 |
+ (const uchar *)opts[i].name, strlen(opts[i].name)))
|
|
802 |
+ return opts[i].val;
|
|
803 |
+ }
|
|
804 |
+ return opts[i].val;
|
|
805 |
+}
|
|
806 |
+
|
|
807 |
+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
|
|
808 |
+ const ulong none_val, const ulong invalid_val)
|
|
809 |
+{
|
|
810 |
+ const char *p, *e;
|
|
811 |
+ ulong val= none_val;
|
|
812 |
+
|
|
813 |
+ if (!*names_list)
|
|
814 |
+ return val;
|
|
815 |
+
|
|
816 |
+ for (p= e= names_list; ; e++)
|
|
817 |
+ {
|
|
818 |
+ ulong i;
|
|
819 |
+
|
|
820 |
+ if (*e != ',' && *e)
|
|
821 |
+ continue;
|
|
822 |
+ for (i=0; opts[i].name; i++)
|
|
823 |
+ {
|
|
824 |
+ if (!my_strnncoll(&my_charset_latin1,
|
|
825 |
+ (const uchar *)p, e - p,
|
|
826 |
+ (const uchar *)opts[i].name, strlen(opts[i].name)))
|
|
827 |
+ {
|
|
828 |
+ val= val | opts[i].val;
|
|
829 |
+ break;
|
|
830 |
+ }
|
|
831 |
+ }
|
|
832 |
+ if (opts[i].val == invalid_val)
|
|
833 |
+ return invalid_val;
|
|
834 |
+ if (!*e)
|
|
835 |
+ break;
|
|
836 |
+ p= e + 1;
|
|
837 |
+ }
|
|
838 |
+ return val;
|
|
839 |
+}
|
|
840 |
+
|
|
841 |
+const char *msl_option_get_name(const struct msl_opts *opts, ulong val)
|
|
842 |
+{
|
|
843 |
+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
|
|
844 |
+ {
|
|
845 |
+ if (opts[i].val == val)
|
|
846 |
+ return opts[i].name;
|
|
847 |
+ }
|
|
848 |
+ return "*INVALID*";
|
|
849 |
+}
|
|
850 |
+
|
|
851 |
+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val)
|
|
852 |
+{
|
|
853 |
+ uint offset= 0;
|
|
854 |
+
|
|
855 |
+ *buf= '\0';
|
|
856 |
+ for (ulong i=0; opts[i].name && opts[i].name[0]; i++)
|
|
857 |
+ {
|
|
858 |
+ if (opts[i].val & val)
|
|
859 |
+ offset+= snprintf(buf+offset, STRING_BUFFER_USUAL_SIZE - offset - 1,
|
|
860 |
+ "%s%s", (offset ? "," : ""), opts[i].name);
|
|
861 |
+ }
|
|
862 |
+ return buf;
|
|
863 |
+}
|
|
864 |
+
|
|
865 |
+/****************************************************************************
|
|
866 |
+ Functions to handle log_slow_verbosity
|
|
867 |
+****************************************************************************/
|
|
868 |
+
|
|
869 |
+/* Based upon sys_var::check_enum() */
|
|
870 |
+
|
|
871 |
+bool sys_var_thd_msl_option::check(THD *thd, set_var *var)
|
|
872 |
+{
|
|
873 |
+ char buff[STRING_BUFFER_USUAL_SIZE];
|
|
874 |
+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
|
|
875 |
+
|
|
876 |
+ if (var->value->result_type() == STRING_RESULT)
|
|
877 |
+ {
|
|
878 |
+ ulong verb= this->invalid_val;
|
|
879 |
+ if (!(res=var->value->val_str(&str)) ||
|
|
880 |
+ (var->save_result.ulong_value=
|
|
881 |
+ (ulong) (verb= msl_option_resolve_by_name(this->opts, res->ptr(), res->length()))) == this->invalid_val)
|
|
882 |
+ goto err;
|
|
883 |
+ return 0;
|
|
884 |
+ }
|
|
885 |
+
|
|
886 |
+err:
|
|
887 |
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
|
|
888 |
+ return 1;
|
|
889 |
+}
|
|
890 |
+
|
|
891 |
+uchar *sys_var_thd_msl_option::value_ptr(THD *thd, enum_var_type type,
|
|
892 |
+ LEX_STRING *base)
|
|
893 |
+{
|
|
894 |
+ ulong val;
|
|
895 |
+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
|
|
896 |
+ thd->variables.*offset);
|
|
897 |
+ const char *verbosity= msl_option_get_name(this->opts, val);
|
|
898 |
+ return (uchar *) verbosity;
|
|
899 |
+}
|
|
900 |
+
|
|
901 |
+
|
|
902 |
+void sys_var_thd_msl_option::set_default(THD *thd, enum_var_type type)
|
|
903 |
+{
|
|
904 |
+ if (type == OPT_GLOBAL)
|
|
905 |
+ global_system_variables.*offset= (ulong) this->default_val;
|
|
906 |
+ else
|
|
907 |
+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
|
|
908 |
+}
|
|
909 |
+
|
|
910 |
+
|
|
911 |
+bool sys_var_thd_msl_option::update(THD *thd, set_var *var)
|
|
912 |
+{
|
|
913 |
+ if (var->type == OPT_GLOBAL)
|
|
914 |
+ global_system_variables.*offset= var->save_result.ulong_value;
|
|
915 |
+ else
|
|
916 |
+ thd->variables.*offset= var->save_result.ulong_value;
|
|
917 |
+ return 0;
|
|
918 |
+}
|
|
919 |
+
|
|
920 |
+/****************************************************************************
|
|
921 |
+ Functions to handle log_slow_filter
|
|
922 |
+****************************************************************************/
|
|
923 |
+
|
|
924 |
+/* Based upon sys_var::check_enum() */
|
|
925 |
+
|
|
926 |
+bool sys_var_thd_msl_flag::check(THD *thd, set_var *var)
|
|
927 |
+{
|
|
928 |
+ char buff[2 * STRING_BUFFER_USUAL_SIZE];
|
|
929 |
+ String str(buff, sizeof(buff), &my_charset_latin1), *res;
|
|
930 |
+
|
|
931 |
+ if (var->value->result_type() == STRING_RESULT)
|
|
932 |
+ {
|
|
933 |
+ ulong filter= this->none_val;
|
|
934 |
+ if (!(res=var->value->val_str(&str)) ||
|
|
935 |
+ (var->save_result.ulong_value=
|
|
936 |
+ (ulong) (filter= msl_flag_resolve_by_name(this->flags, res->ptr(), this->none_val,
|
|
937 |
+ this->invalid_val))) == this->invalid_val)
|
|
938 |
+ goto err;
|
|
939 |
+ return 0;
|
|
940 |
+ }
|
|
941 |
+
|
|
942 |
+err:
|
|
943 |
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), var->var->name);
|
|
944 |
+ return 1;
|
|
945 |
+}
|
|
946 |
+
|
|
947 |
+uchar *sys_var_thd_msl_flag::value_ptr(THD *thd, enum_var_type type,
|
|
948 |
+ LEX_STRING *base)
|
|
949 |
+{
|
|
950 |
+ ulong val;
|
|
951 |
+ val= ((type == OPT_GLOBAL) ? global_system_variables.*offset :
|
|
952 |
+ thd->variables.*offset);
|
|
953 |
+ msl_flag_get_name(this->flags, this->flags_string, val);
|
|
954 |
+ return (uchar *) this->flags_string;
|
|
955 |
+}
|
|
956 |
+
|
|
957 |
+
|
|
958 |
+void sys_var_thd_msl_flag::set_default(THD *thd, enum_var_type type)
|
|
959 |
+{
|
|
960 |
+ if (type == OPT_GLOBAL)
|
|
961 |
+ global_system_variables.*offset= (ulong) this->default_val;
|
|
962 |
+ else
|
|
963 |
+ thd->variables.*offset= (ulong) (global_system_variables.*offset);
|
|
964 |
+}
|
|
965 |
+
|
|
966 |
+
|
|
967 |
+bool sys_var_thd_msl_flag::update(THD *thd, set_var *var)
|
|
968 |
+{
|
|
969 |
+ if (var->type == OPT_GLOBAL)
|
|
970 |
+ global_system_variables.*offset= var->save_result.ulong_value;
|
|
971 |
+ else
|
|
972 |
+ thd->variables.*offset= var->save_result.ulong_value;
|
|
973 |
+ return 0;
|
|
974 |
+}
|
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
975 |
+bool sys_var_thd_msl_flag_correct_none::update(THD *thd, set_var *var)
|
976 |
+{
|
|
977 |
+ ulong result = var->save_result.ulong_value;
|
|
978 |
+ if (result != none_val)
|
|
979 |
+ result = result & (~none_val);
|
|
980 |
+ if (var->type == OPT_GLOBAL)
|
|
981 |
+ global_system_variables.*offset = result;
|
|
982 |
+ else
|
|
983 |
+ thd->variables.*offset = result;
|
|
984 |
+ return 0;
|
|
985 |
+}
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
986 |
+
|
987 |
+
|
|
988 |
/**************************************************************************** |
|
989 |
Functions to handle table_type |
|
990 |
****************************************************************************/ |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
991 |
--- a/sql/set_var.h
|
992 |
+++ b/sql/set_var.h
|
|
195
by Oleg Tsarev
Port Oleg and Alexey patches to 5.1.55 |
993 |
@@ -569,6 +569,82 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
994 |
}; |
995 |
||
996 |
||
177.4.1
by Oleg Tsarev
fix bug #688643 |
997 |
+extern void use_global_long_query_time_update(bool enable);
|
998 |
+
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
999 |
+class sys_var_thd_msl_option :public sys_var_thd
|
1000 |
+{
|
|
1001 |
+protected:
|
|
1002 |
+ ulong SV::*offset;
|
|
1003 |
+ const ulong none_val;
|
|
1004 |
+ const ulong default_val;
|
|
1005 |
+ const ulong invalid_val;
|
|
1006 |
+ const struct msl_opts *opts;
|
|
1007 |
+public:
|
|
1008 |
+ sys_var_thd_msl_option(sys_var_chain *chain, const char *name_arg, ulong SV::*offset_arg,
|
|
1009 |
+ const ulong none_val_arg,
|
|
1010 |
+ const ulong default_val_arg,
|
|
1011 |
+ const ulong invalid_val_arg,
|
|
1012 |
+ const struct msl_opts *opts_arg)
|
|
1013 |
+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
|
|
1014 |
+ default_val(default_val_arg), invalid_val(invalid_val_arg),
|
|
1015 |
+ opts(opts_arg)
|
|
1016 |
+ { chain_sys_var(chain); }
|
|
1017 |
+ bool check(THD *thd, set_var *var);
|
|
1018 |
+ SHOW_TYPE show_type() { return SHOW_CHAR; }
|
|
1019 |
+ bool check_update_type(Item_result type)
|
|
1020 |
+ {
|
|
1021 |
+ return type != STRING_RESULT; /* Only accept strings */
|
|
1022 |
+ }
|
|
1023 |
+ void set_default(THD *thd, enum_var_type type);
|
|
1024 |
+ bool update(THD *thd, set_var *var);
|
|
1025 |
+ uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
|
|
1026 |
+};
|
|
1027 |
+
|
|
1028 |
+
|
|
1029 |
+class sys_var_thd_msl_flag :public sys_var_thd
|
|
1030 |
+{
|
|
1031 |
+protected:
|
|
1032 |
+ char flags_string[2 * STRING_BUFFER_USUAL_SIZE];
|
|
1033 |
+ ulong SV::*offset;
|
|
1034 |
+ const ulong none_val;
|
|
1035 |
+ const ulong default_val;
|
|
1036 |
+ const ulong invalid_val;
|
|
1037 |
+ const struct msl_opts *flags;
|
|
1038 |
+public:
|
|
1039 |
+ sys_var_thd_msl_flag(sys_var_chain *chain, const char *name_arg, ulong SV::*offset_arg,
|
|
1040 |
+ const ulong none_val_arg,
|
|
1041 |
+ const ulong default_val_arg,
|
|
1042 |
+ const ulong invalid_val_arg,
|
|
1043 |
+ const struct msl_opts *flags_arg)
|
|
1044 |
+ :sys_var_thd(name_arg), offset(offset_arg), none_val(none_val_arg),
|
|
1045 |
+ default_val(default_val_arg), invalid_val(invalid_val_arg),
|
|
1046 |
+ flags(flags_arg)
|
|
1047 |
+ { chain_sys_var(chain); }
|
|
1048 |
+ bool check(THD *thd, set_var *var);
|
|
1049 |
+ SHOW_TYPE show_type() { return SHOW_CHAR; }
|
|
1050 |
+ bool check_update_type(Item_result type)
|
|
1051 |
+ {
|
|
1052 |
+ return type != STRING_RESULT; /* Only accept strings */
|
|
1053 |
+ }
|
|
1054 |
+ void set_default(THD *thd, enum_var_type type);
|
|
1055 |
+ bool update(THD *thd, set_var *var);
|
|
1056 |
+ uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
|
|
1057 |
+};
|
|
1058 |
+
|
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
1059 |
+class sys_var_thd_msl_flag_correct_none : public sys_var_thd_msl_flag
|
1060 |
+{
|
|
1061 |
+ public:
|
|
1062 |
+ sys_var_thd_msl_flag_correct_none(sys_var_chain *chain, const char *name_arg, ulong SV::*offset_arg,
|
|
1063 |
+ const ulong none_val_arg,
|
|
1064 |
+ const ulong default_val_arg,
|
|
1065 |
+ const ulong invalid_val_arg,
|
|
1066 |
+ const struct msl_opts *flags_arg)
|
|
1067 |
+ : sys_var_thd_msl_flag(chain,name_arg,offset_arg,none_val_arg,default_val_arg,invalid_val_arg,flags_arg)
|
|
1068 |
+ {
|
|
1069 |
+ }
|
|
1070 |
+ virtual bool update(THD *thd, set_var *var);
|
|
1071 |
+};
|
|
1072 |
+
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1073 |
class sys_var_thd_storage_engine :public sys_var_thd |
1074 |
{ |
|
1075 |
protected: |
|
195
by Oleg Tsarev
Port Oleg and Alexey patches to 5.1.55 |
1076 |
@@ -1470,3 +1546,10 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1077 |
bool process_key_caches(process_key_cache_t func); |
1078 |
void delete_elements(I_List<NAMED_LIST> *list, |
|
1079 |
void (*free_element)(const char*, uchar*)); |
|
1080 |
+
|
|
1081 |
+/* Slow log functions */
|
|
1082 |
+ulong msl_option_resolve_by_name(const struct msl_opts *opts, const char *name, ulong len);
|
|
1083 |
+ulong msl_flag_resolve_by_name(const struct msl_opts *opts, const char *names_list,
|
|
1084 |
+ const ulong none_val, const ulong invalid_val);
|
|
1085 |
+const char *msl_option_get_name(const struct msl_opts *opts, ulong val);
|
|
1086 |
+char *msl_flag_get_name(const struct msl_opts *opts, char *buf, ulong val);
|
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
1087 |
--- a/sql/slave.cc
|
1088 |
+++ b/sql/slave.cc
|
|
149.1.1
by Oleg Tsarev
port Oleg's patches to 5.1.53 |
1089 |
@@ -1834,6 +1834,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1090 |
+ MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */ |
1091 |
thd->slave_thread = 1; |
|
1092 |
thd->enable_slow_log= opt_log_slow_slave_statements; |
|
1093 |
+ thd->write_to_slow_log= opt_log_slow_slave_statements;
|
|
1094 |
set_slave_thread_options(thd); |
|
1095 |
thd->client_capabilities = CLIENT_LOCAL_FILES; |
|
1096 |
pthread_mutex_lock(&LOCK_thread_count); |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
1097 |
--- a/sql/sp_head.cc
|
1098 |
+++ b/sql/sp_head.cc
|
|
77
by kinoyasu
port and adjust the part of the patches to 5.1.49: But query_cache_with_comments.patch, response-time-distribution.patch, mysql_remove_eol_carret.patch, log_connection_error.patch, status_wait_query_cache_mutex.patch and sql_no_fcache.patch were not ported yet. Please port them. |
1099 |
@@ -1987,7 +1987,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1100 |
DBUG_PRINT("info",(" %.*s: eval args done", (int) m_name.length, |
1101 |
m_name.str)); |
|
1102 |
} |
|
1103 |
- if (!(m_flags & LOG_SLOW_STATEMENTS) && thd->enable_slow_log)
|
|
1104 |
+ if (!(m_flags & LOG_SLOW_STATEMENTS || opt_log_slow_sp_statements) && thd->enable_slow_log)
|
|
1105 |
{ |
|
1106 |
DBUG_PRINT("info", ("Disabling slow log for the execution")); |
|
1107 |
save_enable_slow_log= true; |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
1108 |
--- a/sql/sql_cache.cc
|
1109 |
+++ b/sql/sql_cache.cc
|
|
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
1110 |
@@ -1704,6 +1704,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1111 |
|
1112 |
thd->limit_found_rows = query->found_rows(); |
|
1113 |
thd->status_var.last_query_cost= 0.0; |
|
1114 |
+ thd->query_plan_flags|= QPLAN_QC;
|
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
1115 |
if (!thd->main_da.is_set()) |
1116 |
thd->main_da.disable_status(); |
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1117 |
|
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
1118 |
@@ -1713,6 +1714,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1119 |
err_unlock: |
1120 |
unlock(); |
|
1121 |
err: |
|
1122 |
+ thd->query_plan_flags|= QPLAN_QC_NO;
|
|
1123 |
DBUG_RETURN(0); // Query was not cached |
|
1124 |
} |
|
1125 |
||
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
1126 |
--- a/sql/sql_class.cc
|
1127 |
+++ b/sql/sql_class.cc
|
|
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
1128 |
@@ -341,6 +341,37 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1129 |
thd->row_count++; |
1130 |
} |
|
1131 |
||
1132 |
+extern "C"
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
1133 |
+void increment_thd_innodb_stats(THD* thd,
|
1134 |
+ unsigned long long trx_id,
|
|
1135 |
+ long io_reads,
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1136 |
+ long long io_read,
|
1137 |
+ long io_reads_wait_timer,
|
|
1138 |
+ long lock_que_wait_timer,
|
|
1139 |
+ long que_wait_timer,
|
|
1140 |
+ long page_access)
|
|
1141 |
+{
|
|
1142 |
+ thd->innodb_was_used = TRUE;
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
1143 |
+ thd->innodb_trx_id = trx_id;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1144 |
+ thd->innodb_io_reads += io_reads;
|
1145 |
+ thd->innodb_io_read += io_read;
|
|
1146 |
+ thd->innodb_io_reads_wait_timer += io_reads_wait_timer;
|
|
1147 |
+ thd->innodb_lock_que_wait_timer += lock_que_wait_timer;
|
|
1148 |
+ thd->innodb_innodb_que_wait_timer += que_wait_timer;
|
|
1149 |
+ thd->innodb_page_access += page_access;
|
|
1150 |
+}
|
|
1151 |
+
|
|
1152 |
+extern "C"
|
|
1153 |
+unsigned long thd_log_slow_verbosity(const THD *thd)
|
|
1154 |
+{
|
|
1155 |
+ return (unsigned long) thd->variables.log_slow_verbosity;
|
|
1156 |
+}
|
|
1157 |
+
|
|
1158 |
+extern "C"
|
|
1159 |
+int thd_opt_slow_log()
|
|
1160 |
+{
|
|
1161 |
+ return (int) opt_slow_log;
|
|
1162 |
+}
|
|
1163 |
||
1164 |
/** |
|
1165 |
Dumps a text description of a thread, its security context |
|
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
1166 |
@@ -761,6 +792,8 @@
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
1167 |
bool THD::handle_error(uint sql_errno, const char *message, |
1168 |
MYSQL_ERROR::enum_warning_level level) |
|
1169 |
{ |
|
1170 |
+ last_errno = sql_errno;
|
|
1171 |
+
|
|
1172 |
for (Internal_error_handler *error_handler= m_internal_handler; |
|
1173 |
error_handler; |
|
1174 |
error_handler= error_handler->m_prev_internal_handler) |
|
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
1175 |
@@ -3177,6 +3210,12 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1176 |
first_successful_insert_id_in_prev_stmt; |
1177 |
backup->first_successful_insert_id_in_cur_stmt= |
|
1178 |
first_successful_insert_id_in_cur_stmt; |
|
1179 |
+ backup->innodb_io_reads= innodb_io_reads;
|
|
1180 |
+ backup->innodb_io_read= innodb_io_read;
|
|
1181 |
+ backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer;
|
|
1182 |
+ backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer;
|
|
1183 |
+ backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
|
|
1184 |
+ backup->innodb_page_access= innodb_page_access;
|
|
1185 |
||
1186 |
if ((!lex->requires_prelocking() || is_update_query(lex->sql_command)) && |
|
1187 |
!current_stmt_binlog_row_based) |
|
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
1188 |
@@ -3196,6 +3235,14 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1189 |
cuted_fields= 0; |
1190 |
transaction.savepoints= 0; |
|
1191 |
first_successful_insert_id_in_cur_stmt= 0; |
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
1192 |
+ last_errno= 0;
|
1193 |
+ innodb_trx_id= 0;
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1194 |
+ innodb_io_reads= 0;
|
1195 |
+ innodb_io_read= 0;
|
|
1196 |
+ innodb_io_reads_wait_timer= 0;
|
|
1197 |
+ innodb_lock_que_wait_timer= 0;
|
|
1198 |
+ innodb_innodb_que_wait_timer= 0;
|
|
1199 |
+ innodb_page_access= 0;
|
|
1200 |
} |
|
1201 |
||
1202 |
||
133
by kinoyasu
port maintainer-Yasufumi patches for 5.1.52 |
1203 |
@@ -3258,6 +3305,12 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1204 |
*/ |
1205 |
examined_row_count+= backup->examined_row_count; |
|
1206 |
cuted_fields+= backup->cuted_fields; |
|
1207 |
+ innodb_io_reads+= backup->innodb_io_reads;
|
|
1208 |
+ innodb_io_read+= backup->innodb_io_read;
|
|
1209 |
+ innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer;
|
|
1210 |
+ innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer;
|
|
1211 |
+ innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
|
|
1212 |
+ innodb_page_access+= backup->innodb_page_access;
|
|
1213 |
DBUG_VOID_RETURN; |
|
1214 |
} |
|
1215 |
||
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
1216 |
--- a/sql/sql_class.h
|
1217 |
+++ b/sql/sql_class.h
|
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
1218 |
@@ -402,6 +402,18 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1219 |
DATE_TIME_FORMAT *datetime_format; |
1220 |
DATE_TIME_FORMAT *time_format; |
|
1221 |
my_bool sysdate_is_now; |
|
1222 |
+
|
|
1223 |
+ ulong log_slow_rate_limit;
|
|
1224 |
+ ulong log_slow_filter;
|
|
1225 |
+ ulong log_slow_verbosity;
|
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
1226 |
+ ulong use_global_log_slow_control;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1227 |
+
|
1228 |
+ ulong innodb_io_reads;
|
|
1229 |
+ ulonglong innodb_io_read;
|
|
1230 |
+ ulong innodb_io_reads_wait_timer;
|
|
1231 |
+ ulong innodb_lock_que_wait_timer;
|
|
1232 |
+ ulong innodb_innodb_que_wait_timer;
|
|
1233 |
+ ulong innodb_page_access;
|
|
1234 |
}; |
|
1235 |
||
1236 |
||
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
1237 |
@@ -998,6 +1010,14 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1238 |
uint in_sub_stmt; |
1239 |
bool enable_slow_log; |
|
1240 |
bool last_insert_id_used; |
|
1241 |
+
|
|
1242 |
+ ulong innodb_io_reads;
|
|
1243 |
+ ulonglong innodb_io_read;
|
|
1244 |
+ ulong innodb_io_reads_wait_timer;
|
|
1245 |
+ ulong innodb_lock_que_wait_timer;
|
|
1246 |
+ ulong innodb_innodb_que_wait_timer;
|
|
1247 |
+ ulong innodb_page_access;
|
|
1248 |
+
|
|
1249 |
SAVEPOINT *savepoints; |
|
1250 |
enum enum_check_fields count_cuted_fields; |
|
1251 |
}; |
|
106
by kinoyasu
Port Yasufumi maintaining patches to 5.1.50: |
1252 |
@@ -1425,6 +1445,26 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1253 |
thr_lock_type update_lock_default; |
1254 |
Delayed_insert *di; |
|
1255 |
||
1256 |
+ bool write_to_slow_log;
|
|
1257 |
+
|
|
1258 |
+ ulonglong bytes_sent_old;
|
|
1259 |
+ ulong tmp_tables_used;
|
|
1260 |
+ ulong tmp_tables_disk_used;
|
|
1261 |
+ ulonglong tmp_tables_size;
|
|
1262 |
+ bool innodb_was_used;
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
1263 |
+ ulonglong innodb_trx_id;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1264 |
+ ulong innodb_io_reads;
|
1265 |
+ ulonglong innodb_io_read;
|
|
1266 |
+ ulong innodb_io_reads_wait_timer;
|
|
1267 |
+ ulong innodb_lock_que_wait_timer;
|
|
1268 |
+ ulong innodb_innodb_que_wait_timer;
|
|
1269 |
+ ulong innodb_page_access;
|
|
1270 |
+
|
|
1271 |
+ ulong query_plan_flags;
|
|
1272 |
+ ulong query_plan_fsort_passes;
|
|
1273 |
+
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
1274 |
+ uint last_errno;
|
1275 |
+
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1276 |
/* <> 0 if we are inside of trigger or stored function. */ |
1277 |
uint in_sub_stmt; |
|
1278 |
/* TRUE when the current top has SQL_LOG_BIN ON */ |
|
181.1.1
by Alexey Kopytov
Bug #693818: funcs_1.storedproc fails on 12.4 |
1279 |
@@ -1777,6 +1817,11 @@
|
1280 |
create_sort_index(); may differ from examined_row_count. |
|
1281 |
*/ |
|
1282 |
ulong row_count; |
|
1283 |
+ /*
|
|
1284 |
+ Original row_count value at the start of query execution
|
|
1285 |
+ (used by the slow_extended patch).
|
|
1286 |
+ */
|
|
1287 |
+ ulong orig_row_count;
|
|
1288 |
pthread_t real_id; /* For debugging */ |
|
1289 |
my_thread_id thread_id; |
|
1290 |
uint tmp_table, global_read_lock; |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
1291 |
--- a/sql/sql_connect.cc
|
1292 |
+++ b/sql/sql_connect.cc
|
|
1293 |
@@ -1288,6 +1288,15 @@
|
|
1294 |
if (login_connection(thd)) |
|
1295 |
goto end_thread; |
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1296 |
|
1297 |
+ /*
|
|
1298 |
+ If rate limiting of slow log writes is enabled, decide whether to log this
|
|
1299 |
+ new thread's queries or not. Uses extremely simple algorithm. :)
|
|
1300 |
+ */
|
|
1301 |
+ thd->write_to_slow_log= FALSE;
|
|
1302 |
+ if (thd->variables.log_slow_rate_limit <= 1 ||
|
|
1303 |
+ (thd->thread_id % thd->variables.log_slow_rate_limit) == 0)
|
|
1304 |
+ thd->write_to_slow_log= TRUE;
|
|
1305 |
+
|
|
232.3.2
by Oleg Tsarev
Bug: #794776 |
1306 |
prepare_new_connection_state(thd); |
1307 |
||
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1308 |
while (!net->error && net->vio != 0 && |
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
1309 |
--- a/sql/sql_parse.cc
|
1310 |
+++ b/sql/sql_parse.cc
|
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
1311 |
@@ -1699,7 +1699,10 @@
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
1312 |
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); |
1313 |
DBUG_RETURN(error); |
|
1314 |
} |
|
1315 |
-
|
|
1316 |
+#define SLOG_UG_SETUP(session,value,flag,global) do { \
|
|
1317 |
+ if(value & flag) \
|
|
1318 |
+ session = global; \
|
|
1319 |
+ } while(false);
|
|
1320 |
||
1321 |
void log_slow_statement(THD *thd) |
|
1322 |
{ |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
1323 |
@@ -1713,6 +1716,40 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1324 |
if (unlikely(thd->in_sub_stmt)) |
1325 |
DBUG_VOID_RETURN; // Don't set time for sub stmt |
|
1326 |
||
1327 |
+ /* Follow the slow log filter configuration. */
|
|
1328 |
+ if (thd->variables.log_slow_filter != SLOG_F_NONE &&
|
|
1329 |
+ (!(thd->variables.log_slow_filter & thd->query_plan_flags) ||
|
|
1330 |
+ ((thd->variables.log_slow_filter & SLOG_F_QC_NO) &&
|
|
1331 |
+ (thd->query_plan_flags & QPLAN_QC))))
|
|
1332 |
+ DBUG_VOID_RETURN;
|
|
1333 |
+
|
|
1334 |
+ /*
|
|
1335 |
+ Low long_query_time value most likely means user is debugging stuff and even
|
|
1336 |
+ though some thread's queries are not supposed to be logged b/c of the rate
|
|
1337 |
+ limit, if one of them takes long enough (>= 1 second) it will be sensible
|
|
1338 |
+ to make an exception and write to slow log anyway.
|
|
1339 |
+ */
|
|
1340 |
+
|
|
1341 |
+ ulonglong end_utime_of_query= thd->current_utime();
|
|
1342 |
+
|
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
1343 |
+ /* use_global_log_slow_control */
|
1344 |
+ {
|
|
177.4.1
by Oleg Tsarev
fix bug #688643 |
1345 |
+ system_variables const &g= global_system_variables; // global
|
1346 |
+ system_variables &s= thd->variables; // session
|
|
1347 |
+ ulong const &value= g.use_global_log_slow_control;
|
|
54.2.3
by Oleg Tsarev
merge control-global-slow.patch to slow_extended.patch |
1348 |
+ SLOG_UG_SETUP(s.log_slow_filter, value, SLOG_UG_LOG_SLOW_FILTER, g.log_slow_filter);
|
1349 |
+ SLOG_UG_SETUP(s.log_slow_rate_limit, value, SLOG_UG_LOG_SLOW_RATE_LIMIT, g.log_slow_rate_limit);
|
|
1350 |
+ SLOG_UG_SETUP(s.log_slow_verbosity, value, SLOG_UG_LOG_SLOW_VERBOSITY, g.log_slow_verbosity);
|
|
1351 |
+ SLOG_UG_SETUP(s.long_query_time, value, SLOG_UG_LONG_QUERY_TIME, g.long_query_time);
|
|
1352 |
+ SLOG_UG_SETUP(s.min_examined_row_limit, value, SLOG_UG_MIN_EXAMINED_ROW_LIMIT, g.min_examined_row_limit);
|
|
1353 |
+ }
|
|
1354 |
+
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1355 |
+ /* Do not log this thread's queries due to rate limiting. */
|
1356 |
+ if (thd->write_to_slow_log != TRUE
|
|
1357 |
+ && (thd->variables.long_query_time >= 1000000
|
|
1358 |
+ || (ulong) (end_utime_of_query - thd->utime_after_lock) < 1000000))
|
|
1359 |
+ DBUG_VOID_RETURN;
|
|
1360 |
+
|
|
1361 |
/* |
|
1362 |
Do not log administrative statements unless the appropriate option is |
|
1363 |
set. |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
1364 |
@@ -2099,6 +2136,9 @@
|
77
by kinoyasu
port and adjust the part of the patches to 5.1.49: But query_cache_with_comments.patch, response-time-distribution.patch, mysql_remove_eol_carret.patch, log_connection_error.patch, status_wait_query_cache_mutex.patch and sql_no_fcache.patch were not ported yet. Please port them. |
1365 |
context.resolve_in_table_list_only(select_lex-> |
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1366 |
table_list.first); |
1367 |
||
181.1.1
by Alexey Kopytov
Bug #693818: funcs_1.storedproc fails on 12.4 |
1368 |
+ /* Save the original row_count value for extended stats in slow query log */
|
1369 |
+ thd->orig_row_count= thd->row_count;
|
|
1370 |
+
|
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1371 |
/* |
1372 |
Reset warning count for each query that uses tables |
|
1373 |
A better approach would be to reset this for any commands |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
1374 |
@@ -5828,6 +5868,21 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1375 |
thd->rand_used= 0; |
1376 |
thd->sent_row_count= thd->examined_row_count= 0; |
|
1377 |
||
1378 |
+ thd->bytes_sent_old= thd->status_var.bytes_sent;
|
|
1379 |
+ thd->tmp_tables_used= thd->tmp_tables_disk_used= 0;
|
|
1380 |
+ thd->tmp_tables_size= 0;
|
|
1381 |
+ thd->innodb_was_used= FALSE;
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
1382 |
+ thd->innodb_trx_id= 0;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1383 |
+ thd->innodb_io_reads= 0;
|
1384 |
+ thd->innodb_io_read= 0;
|
|
1385 |
+ thd->innodb_io_reads_wait_timer= 0;
|
|
1386 |
+ thd->innodb_lock_que_wait_timer= 0;
|
|
1387 |
+ thd->innodb_innodb_que_wait_timer= 0;
|
|
1388 |
+ thd->innodb_page_access= 0;
|
|
1389 |
+ thd->query_plan_flags= QPLAN_NONE;
|
|
1390 |
+ thd->query_plan_fsort_passes= 0;
|
|
4
by kinoyasu
Last_errno: Killed: InnoDB_trx_id: are added to slow_log |
1391 |
+ thd->last_errno= 0;
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1392 |
+
|
1393 |
/* |
|
1394 |
Because we come here only for start of top-statements, binlog format is |
|
1395 |
constant inside a complex statement (using stored functions) etc. |
|
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
1396 |
--- a/sql/sql_select.cc
|
1397 |
+++ b/sql/sql_select.cc
|
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
1398 |
@@ -6794,7 +6794,10 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1399 |
{ |
1400 |
join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED; |
|
1401 |
if (statistics) |
|
1402 |
+ {
|
|
1403 |
status_var_increment(join->thd->status_var.select_scan_count); |
|
1404 |
+ join->thd->query_plan_flags|= QPLAN_FULL_SCAN;
|
|
1405 |
+ }
|
|
1406 |
} |
|
1407 |
} |
|
1408 |
else |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
1409 |
@@ -6808,7 +6811,10 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1410 |
{ |
1411 |
join->thd->server_status|=SERVER_QUERY_NO_INDEX_USED; |
|
1412 |
if (statistics) |
|
1413 |
+ {
|
|
1414 |
status_var_increment(join->thd->status_var.select_full_join_count); |
|
1415 |
+ join->thd->query_plan_flags|= QPLAN_FULL_JOIN;
|
|
1416 |
+ }
|
|
1417 |
} |
|
1418 |
} |
|
1419 |
if (!table->no_keyread) |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
1420 |
@@ -10012,6 +10018,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1421 |
(ulong) rows_limit,test(group))); |
1422 |
||
1423 |
status_var_increment(thd->status_var.created_tmp_tables); |
|
1424 |
+ thd->query_plan_flags|= QPLAN_TMP_TABLE;
|
|
1425 |
||
1426 |
if (use_temp_pool && !(test_flags & TEST_KEEP_TMP_TABLES)) |
|
1427 |
temp_pool_slot = bitmap_lock_set_next(&temp_pool); |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
1428 |
@@ -10893,6 +10900,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1429 |
goto err; |
1430 |
} |
|
1431 |
status_var_increment(table->in_use->status_var.created_tmp_disk_tables); |
|
1432 |
+ table->in_use->query_plan_flags|= QPLAN_TMP_DISK;
|
|
1433 |
share->db_record_offset= 1; |
|
1434 |
DBUG_RETURN(0); |
|
1435 |
err: |
|
225.1.1
by Oleg Tsarev
complete patch porting to 5.1.57 |
1436 |
@@ -10911,6 +10919,14 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
1437 |
save_proc_info=thd->proc_info; |
1438 |
thd_proc_info(thd, "removing tmp table"); |
|
1439 |
||
1440 |
+ thd->tmp_tables_used++;
|
|
1441 |
+ if (entry->file)
|
|
1442 |
+ {
|
|
1443 |
+ thd->tmp_tables_size += entry->file->stats.data_file_length;
|
|
1444 |
+ if (entry->file->ht->db_type != DB_TYPE_HEAP)
|
|
1445 |
+ thd->tmp_tables_disk_used++;
|
|
1446 |
+ }
|
|
1447 |
+
|
|
1448 |
// Release latches since this can take a long time |
|
1449 |
ha_release_temporary_latches(thd); |
|
1450 |
||
243
by Stewart Smith
regenerate slow_extended.patch to attempt to fix hunk apply failure on CentOS 5 hosts. |
1451 |
--- a/sql/sql_show.cc
|
1452 |
+++ b/sql/sql_show.cc
|
|
176
by Oleg Tsarev
port Oleg's and Alexey's patches to 5.1.54 |
1453 |
@@ -1971,8 +1971,17 @@
|
88.1.1
by Oleg Tsarev
fix bug 612954 |
1454 |
table->field[4]->store(command_name[tmp->command].str, |
1455 |
command_name[tmp->command].length, cs); |
|
1456 |
/* MYSQL_TIME */ |
|
1457 |
- table->field[5]->store((longlong)(tmp->start_time ?
|
|
1458 |
- now - tmp->start_time : 0), FALSE);
|
|
94
by Oleg Tsarev
fix bug 610525 |
1459 |
+ longlong value_in_time_column= 0;
|
1460 |
+ if(tmp->start_time)
|
|
88.1.1
by Oleg Tsarev
fix bug 612954 |
1461 |
+ {
|
1462 |
+ value_in_time_column = (now - tmp->start_time);
|
|
94
by Oleg Tsarev
fix bug 610525 |
1463 |
+ if(value_in_time_column > now)
|
1464 |
+ {
|
|
1465 |
+ value_in_time_column= 0;
|
|
1466 |
+ }
|
|
88.1.1
by Oleg Tsarev
fix bug 612954 |
1467 |
+ }
|
1468 |
+ table->field[5]->store(value_in_time_column, FALSE);
|
|
1469 |
+
|
|
1470 |
/* STATE */ |
|
1471 |
#ifndef EMBEDDED_LIBRARY |
|
1472 |
val= (char*) (tmp->locked ? "Locked" : |