Merge lp:~laurynas-biveinis/percona-server/bug810272 into lp:percona-server/5.5
- bug810272
- Merge into 5.5
Status: | Merged |
---|---|
Approved by: | Alexey Kopytov |
Approved revision: | no longer in the source branch. |
Merged at revision: | 198 |
Proposed branch: | lp:~laurynas-biveinis/percona-server/bug810272 |
Merge into: | lp:percona-server/5.5 |
Diff against target: |
701 lines (+115/-130) 1 file modified
patches/response_time_distribution.patch (+115/-130) |
To merge this branch: | bzr merge lp:~laurynas-biveinis/percona-server/bug810272 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexey Kopytov (community) | Approve | ||
Laurynas Biveinis (community) | Needs Resubmitting | ||
Oleg Tsarev (community) | Approve | ||
Review via email: mp+82548@code.launchpad.net |
Commit message
Fix bug 810272 (bogus snprintf return value checking and compilation
warning).
The warning is
sql/query_
expression < 0 is always false
and it indicates that the if clause is dead code, because of the wrong
assumption that snprintf returns a negative value on buffer truncate
(and the old code stores that value in an unsigned type anyway).
The fix:
- Drops buffer overflow check and returns the truncated buffer instead.
- Replaces snprintf with my_snprintf.
- Removes pre- and post-snprintf buffer writes.
- Removes STRING_OVERFLOW, QRT_STRING_
QRT_POSITIVE_
and QRT_TOTAL_
- Re-records the testcases.
Description of the change
Fix bug 810272 (bogus snprintf return value checking and compilation
warning).
The warning is
sql/query_
expression < 0 is always false
and it indicates that the if clause is dead code, because of the wrong
assumption that snprintf returns a negative value on buffer truncate
(and the old code stores that value in an unsigned type anyway).
The fix:
- Increases TIME_STRING_
by 1 to enable snprintf output buffer truncate detection.
- Changes the type of result_length to int to match the return type of
snprintf.
- Replaces the if condition with the proper buffer truncate check.
I have Jenkins-tested this branch together with other warning fixes, but now I have split it to separate MP with separate Jenkins test, which will be available at
http://
Alexey Kopytov (akopytov) wrote : | # |
According to the C99, Linux and BSD man pages, snprintf(buf, n, ...) writes at most (n-1) characters excluding the terminating zero, always produces a zero-terminated string, and returns values >= n if and only if the output was truncated. So it's not clear what extending the buffer by 1 byte has to do with overflow detection.
Windows, however, is a different creature (surprise, surprise!). In case of overflow, it returns a negative value and does not add the terminating zero.
Which makes snprintf() unusable for portable applications. That's why my_snprintf() is used (5.1 has a few places when the C library snprintf() is used, but they were all fixed in 5.5).
Now the problem with my_snprintf() is that it does not indicate an overflow. That is, it always produces a zero-terminated string and writes at most n characters including the terminating zero. But it always returns the number of characters written, excluding the terminating zero, i.e. at most (n-1).
What I suggest is that we simply get rid of that overflow detection check. Is it really that important to print "TOO BIG STRING" if time gets truncated? I don't think so.
Alexey Kopytov (akopytov) wrote : | # |
I meant to say "What I suggest is that we use my_snprintf() and simpy get rid of that overflow detection check".
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Ack. As I read the Linux snprintf man page, my (wrong) understanding was that '\0' may very well get truncated, thus the check. I will redo with my_snprintf.
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Redid with my_snprintf and without buffer overflow checks. Tested locally, Jenkins results will be at
http://
----
Fix bug 810272 (bogus snprintf return value checking and compilation
warning).
The warning is
sql/query_
expression < 0 is always false
and it indicates that the if clause is dead code, because of the wrong
assumption that snprintf returns a negative value on buffer truncate
(and the old code stores that value in an unsigned type anyway).
The fix:
- Drops buffer overflow check and returns the truncated buffer instead.
- Replaces snprintf with my_snprintf.
- Removes pre- and post-snprintf buffer writes.
- Removes STRING_OVERFLOW, QRT_STRING_
QRT_POSITIVE_
and QRT_TOTAL_
- Re-records the testcases.
Alexey Kopytov (akopytov) wrote : | # |
The string_
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
The unused argument removed, callers updated, also print_time is made static now.
Jenkins results for this (and other unrelated changes) are at
http://
There are no Jenkins results for this change in isolation.
Preview Diff
1 | === modified file 'patches/response_time_distribution.patch' |
2 | --- patches/response_time_distribution.patch 2011-10-31 16:12:50 +0000 |
3 | +++ patches/response_time_distribution.patch 2011-11-18 09:02:25 +0000 |
4 | @@ -297,10 +297,10 @@ |
5 | + 131072.000000 0 0.000000 |
6 | + 262144.000000 0 0.000000 |
7 | + 524288.000000 0 0.000000 |
8 | -+ 1048576.00000 0 0.000000 |
9 | -+ 2097152.00000 0 0.000000 |
10 | -+ 4194304.00000 0 0.000000 |
11 | -+ 8388608.00000 0 0.000000 |
12 | ++1048576.000000 0 0.000000 |
13 | ++2097152.000000 0 0.000000 |
14 | ++4194304.000000 0 0.000000 |
15 | ++8388608.000000 0 0.000000 |
16 | +TOO LONG 0 TOO LONG |
17 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
18 | +time count total |
19 | @@ -343,10 +343,10 @@ |
20 | + 131072.000000 0 0.000000 |
21 | + 262144.000000 0 0.000000 |
22 | + 524288.000000 0 0.000000 |
23 | -+ 1048576.00000 0 0.000000 |
24 | -+ 2097152.00000 0 0.000000 |
25 | -+ 4194304.00000 0 0.000000 |
26 | -+ 8388608.00000 0 0.000000 |
27 | ++1048576.000000 0 0.000000 |
28 | ++2097152.000000 0 0.000000 |
29 | ++4194304.000000 0 0.000000 |
30 | ++8388608.000000 0 0.000000 |
31 | +TOO LONG 0 TOO LONG |
32 | +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default; |
33 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default; |
34 | @@ -448,10 +448,10 @@ |
35 | + 131072.000000 0 0.000000 |
36 | + 262144.000000 0 0.000000 |
37 | + 524288.000000 0 0.000000 |
38 | -+ 1048576.00000 0 0.000000 |
39 | -+ 2097152.00000 0 0.000000 |
40 | -+ 4194304.00000 0 0.000000 |
41 | -+ 8388608.00000 0 0.000000 |
42 | ++1048576.000000 0 0.000000 |
43 | ++2097152.000000 0 0.000000 |
44 | ++4194304.000000 0 0.000000 |
45 | ++8388608.000000 0 0.000000 |
46 | +TOO LONG 0 TOO LONG |
47 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
48 | +time count total |
49 | @@ -494,10 +494,10 @@ |
50 | + 131072.000000 0 0.000000 |
51 | + 262144.000000 0 0.000000 |
52 | + 524288.000000 0 0.000000 |
53 | -+ 1048576.00000 0 0.000000 |
54 | -+ 2097152.00000 0 0.000000 |
55 | -+ 4194304.00000 0 0.000000 |
56 | -+ 8388608.00000 0 0.000000 |
57 | ++1048576.000000 0 0.000000 |
58 | ++2097152.000000 0 0.000000 |
59 | ++4194304.000000 0 0.000000 |
60 | ++8388608.000000 0 0.000000 |
61 | +TOO LONG 0 TOO LONG |
62 | +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default; |
63 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default; |
64 | @@ -572,7 +572,7 @@ |
65 | + 1000.000000 0 0.000000 |
66 | + 10000.000000 0 0.000000 |
67 | + 100000.000000 0 0.000000 |
68 | -+ 1000000.00000 0 0.000000 |
69 | ++1000000.000000 0 0.000000 |
70 | +TOO LONG 0 TOO LONG |
71 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
72 | +time count total |
73 | @@ -588,7 +588,7 @@ |
74 | + 1000.000000 0 0.000000 |
75 | + 10000.000000 0 0.000000 |
76 | + 100000.000000 0 0.000000 |
77 | -+ 1000000.00000 0 0.000000 |
78 | ++1000000.000000 0 0.000000 |
79 | +TOO LONG 0 TOO LONG |
80 | +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default; |
81 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default; |
82 | @@ -666,7 +666,7 @@ |
83 | + 16807.000000 0 0.000000 |
84 | + 117649.000000 0 0.000000 |
85 | + 823543.000000 0 0.000000 |
86 | -+ 5764801.00000 0 0.000000 |
87 | ++5764801.000000 0 0.000000 |
88 | +TOO LONG 0 TOO LONG |
89 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
90 | +time count total |
91 | @@ -685,7 +685,7 @@ |
92 | + 16807.000000 0 0.000000 |
93 | + 117649.000000 0 0.000000 |
94 | + 823543.000000 0 0.000000 |
95 | -+ 5764801.00000 0 0.000000 |
96 | ++5764801.000000 0 0.000000 |
97 | +TOO LONG 0 TOO LONG |
98 | +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default; |
99 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default; |
100 | @@ -753,7 +753,7 @@ |
101 | + 1.000000 34 12.250000 |
102 | + 156.000000 33 77.099997 |
103 | + 24336.000000 0 0.000000 |
104 | -+ 3796416.00000 0 0.000000 |
105 | ++3796416.000000 0 0.000000 |
106 | +TOO LONG 0 TOO LONG |
107 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
108 | +time count total |
109 | @@ -762,7 +762,7 @@ |
110 | + 1.000000 34 12.250000 |
111 | + 156.000000 33 77.099997 |
112 | + 24336.000000 0 0.000000 |
113 | -+ 3796416.00000 0 0.000000 |
114 | ++3796416.000000 0 0.000000 |
115 | +TOO LONG 0 TOO LONG |
116 | +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default; |
117 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default; |
118 | @@ -829,7 +829,7 @@ |
119 | + 0.001000 0 0.000000 |
120 | + 1.000000 34 12.250000 |
121 | + 1000.000000 33 77.099997 |
122 | -+ 1000000.00000 0 0.000000 |
123 | ++1000000.000000 0 0.000000 |
124 | +TOO LONG 0 TOO LONG |
125 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
126 | +time count total |
127 | @@ -837,7 +837,7 @@ |
128 | + 0.001000 0 0.000000 |
129 | + 1.000000 34 12.250000 |
130 | + 1000.000000 33 77.099997 |
131 | -+ 1000000.00000 0 0.000000 |
132 | ++1000000.000000 0 0.000000 |
133 | +TOO LONG 0 TOO LONG |
134 | +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default; |
135 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default; |
136 | @@ -906,7 +906,7 @@ |
137 | + 0.001000 0 0.000000 |
138 | + 1.000000 34 12.250000 |
139 | + 1000.000000 33 77.099997 |
140 | -+ 1000000.00000 0 0.000000 |
141 | ++1000000.000000 0 0.000000 |
142 | +TOO LONG 0 TOO LONG |
143 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
144 | +time count total |
145 | @@ -914,7 +914,7 @@ |
146 | + 0.001000 0 0.000000 |
147 | + 1.000000 34 12.250000 |
148 | + 1000.000000 33 77.099997 |
149 | -+ 1000000.00000 0 0.000000 |
150 | ++1000000.000000 0 0.000000 |
151 | +TOO LONG 0 TOO LONG |
152 | +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default; |
153 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default; |
154 | @@ -972,10 +972,10 @@ |
155 | + 131072.000000 0 0.000000 |
156 | + 262144.000000 0 0.000000 |
157 | + 524288.000000 0 0.000000 |
158 | -+ 1048576.00000 0 0.000000 |
159 | -+ 2097152.00000 0 0.000000 |
160 | -+ 4194304.00000 0 0.000000 |
161 | -+ 8388608.00000 0 0.000000 |
162 | ++1048576.000000 0 0.000000 |
163 | ++2097152.000000 0 0.000000 |
164 | ++4194304.000000 0 0.000000 |
165 | ++8388608.000000 0 0.000000 |
166 | +TOO LONG 0 TOO LONG |
167 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
168 | +time count total |
169 | @@ -1018,10 +1018,10 @@ |
170 | + 131072.000000 0 0.000000 |
171 | + 262144.000000 0 0.000000 |
172 | + 524288.000000 0 0.000000 |
173 | -+ 1048576.00000 0 0.000000 |
174 | -+ 2097152.00000 0 0.000000 |
175 | -+ 4194304.00000 0 0.000000 |
176 | -+ 8388608.00000 0 0.000000 |
177 | ++1048576.000000 0 0.000000 |
178 | ++2097152.000000 0 0.000000 |
179 | ++4194304.000000 0 0.000000 |
180 | ++8388608.000000 0 0.000000 |
181 | +TOO LONG 0 TOO LONG |
182 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; |
183 | +SET SESSION query_exec_time=0.31; |
184 | @@ -1158,10 +1158,10 @@ |
185 | + 131072.000000 0 0.000000 |
186 | + 262144.000000 0 0.000000 |
187 | + 524288.000000 0 0.000000 |
188 | -+ 1048576.00000 0 0.000000 |
189 | -+ 2097152.00000 0 0.000000 |
190 | -+ 4194304.00000 0 0.000000 |
191 | -+ 8388608.00000 0 0.000000 |
192 | ++1048576.000000 0 0.000000 |
193 | ++2097152.000000 0 0.000000 |
194 | ++4194304.000000 0 0.000000 |
195 | ++8388608.000000 0 0.000000 |
196 | +TOO LONG 0 TOO LONG |
197 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
198 | +time count total |
199 | @@ -1204,10 +1204,10 @@ |
200 | + 131072.000000 0 0.000000 |
201 | + 262144.000000 0 0.000000 |
202 | + 524288.000000 0 0.000000 |
203 | -+ 1048576.00000 0 0.000000 |
204 | -+ 2097152.00000 0 0.000000 |
205 | -+ 4194304.00000 0 0.000000 |
206 | -+ 8388608.00000 0 0.000000 |
207 | ++1048576.000000 0 0.000000 |
208 | ++2097152.000000 0 0.000000 |
209 | ++4194304.000000 0 0.000000 |
210 | ++8388608.000000 0 0.000000 |
211 | +TOO LONG 0 TOO LONG |
212 | +SET SESSION query_exec_time=default; |
213 | +SET SESSION query_exec_time=0.1; |
214 | @@ -1255,10 +1255,10 @@ |
215 | + 131072.000000 0 0.000000 |
216 | + 262144.000000 0 0.000000 |
217 | + 524288.000000 0 0.000000 |
218 | -+ 1048576.00000 0 0.000000 |
219 | -+ 2097152.00000 0 0.000000 |
220 | -+ 4194304.00000 0 0.000000 |
221 | -+ 8388608.00000 0 0.000000 |
222 | ++1048576.000000 0 0.000000 |
223 | ++2097152.000000 0 0.000000 |
224 | ++4194304.000000 0 0.000000 |
225 | ++8388608.000000 0 0.000000 |
226 | +TOO LONG 0 TOO LONG |
227 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
228 | +time count total |
229 | @@ -1301,10 +1301,10 @@ |
230 | + 131072.000000 0 0.000000 |
231 | + 262144.000000 0 0.000000 |
232 | + 524288.000000 0 0.000000 |
233 | -+ 1048576.00000 0 0.000000 |
234 | -+ 2097152.00000 0 0.000000 |
235 | -+ 4194304.00000 0 0.000000 |
236 | -+ 8388608.00000 0 0.000000 |
237 | ++1048576.000000 0 0.000000 |
238 | ++2097152.000000 0 0.000000 |
239 | ++4194304.000000 0 0.000000 |
240 | ++8388608.000000 0 0.000000 |
241 | +TOO LONG 0 TOO LONG |
242 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; |
243 | +SET SESSION query_exec_time=0.31; |
244 | @@ -1441,10 +1441,10 @@ |
245 | + 131072.000000 0 0.000000 |
246 | + 262144.000000 0 0.000000 |
247 | + 524288.000000 0 0.000000 |
248 | -+ 1048576.00000 0 0.000000 |
249 | -+ 2097152.00000 0 0.000000 |
250 | -+ 4194304.00000 0 0.000000 |
251 | -+ 8388608.00000 0 0.000000 |
252 | ++1048576.000000 0 0.000000 |
253 | ++2097152.000000 0 0.000000 |
254 | ++4194304.000000 0 0.000000 |
255 | ++8388608.000000 0 0.000000 |
256 | +TOO LONG 0 TOO LONG |
257 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
258 | +time count total |
259 | @@ -1487,10 +1487,10 @@ |
260 | + 131072.000000 0 0.000000 |
261 | + 262144.000000 0 0.000000 |
262 | + 524288.000000 0 0.000000 |
263 | -+ 1048576.00000 0 0.000000 |
264 | -+ 2097152.00000 0 0.000000 |
265 | -+ 4194304.00000 0 0.000000 |
266 | -+ 8388608.00000 0 0.000000 |
267 | ++1048576.000000 0 0.000000 |
268 | ++2097152.000000 0 0.000000 |
269 | ++4194304.000000 0 0.000000 |
270 | ++8388608.000000 0 0.000000 |
271 | +TOO LONG 0 TOO LONG |
272 | +SET SESSION query_exec_time=default; |
273 | +SET SESSION query_exec_time=0.1; |
274 | @@ -1511,7 +1511,7 @@ |
275 | + 1000.000000 0 0.000000 |
276 | + 10000.000000 0 0.000000 |
277 | + 100000.000000 0 0.000000 |
278 | -+ 1000000.00000 0 0.000000 |
279 | ++1000000.000000 0 0.000000 |
280 | +TOO LONG 0 TOO LONG |
281 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
282 | +time count total |
283 | @@ -1527,7 +1527,7 @@ |
284 | + 1000.000000 0 0.000000 |
285 | + 10000.000000 0 0.000000 |
286 | + 100000.000000 0 0.000000 |
287 | -+ 1000000.00000 0 0.000000 |
288 | ++1000000.000000 0 0.000000 |
289 | +TOO LONG 0 TOO LONG |
290 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; |
291 | +SET SESSION query_exec_time=0.31; |
292 | @@ -1637,7 +1637,7 @@ |
293 | + 1000.000000 0 0.000000 |
294 | + 10000.000000 0 0.000000 |
295 | + 100000.000000 0 0.000000 |
296 | -+ 1000000.00000 0 0.000000 |
297 | ++1000000.000000 0 0.000000 |
298 | +TOO LONG 0 TOO LONG |
299 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
300 | +time count total |
301 | @@ -1653,7 +1653,7 @@ |
302 | + 1000.000000 0 0.000000 |
303 | + 10000.000000 0 0.000000 |
304 | + 100000.000000 0 0.000000 |
305 | -+ 1000000.00000 0 0.000000 |
306 | ++1000000.000000 0 0.000000 |
307 | +TOO LONG 0 TOO LONG |
308 | +SET SESSION query_exec_time=default; |
309 | +SET SESSION query_exec_time=0.1; |
310 | @@ -1677,7 +1677,7 @@ |
311 | + 16807.000000 0 0.000000 |
312 | + 117649.000000 0 0.000000 |
313 | + 823543.000000 0 0.000000 |
314 | -+ 5764801.00000 0 0.000000 |
315 | ++5764801.000000 0 0.000000 |
316 | +TOO LONG 0 TOO LONG |
317 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
318 | +time count total |
319 | @@ -1696,7 +1696,7 @@ |
320 | + 16807.000000 0 0.000000 |
321 | + 117649.000000 0 0.000000 |
322 | + 823543.000000 0 0.000000 |
323 | -+ 5764801.00000 0 0.000000 |
324 | ++5764801.000000 0 0.000000 |
325 | +TOO LONG 0 TOO LONG |
326 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; |
327 | +SET SESSION query_exec_time=0.31; |
328 | @@ -1809,7 +1809,7 @@ |
329 | + 16807.000000 0 0.000000 |
330 | + 117649.000000 0 0.000000 |
331 | + 823543.000000 0 0.000000 |
332 | -+ 5764801.00000 0 0.000000 |
333 | ++5764801.000000 0 0.000000 |
334 | +TOO LONG 0 TOO LONG |
335 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
336 | +time count total |
337 | @@ -1828,7 +1828,7 @@ |
338 | + 16807.000000 0 0.000000 |
339 | + 117649.000000 0 0.000000 |
340 | + 823543.000000 0 0.000000 |
341 | -+ 5764801.00000 0 0.000000 |
342 | ++5764801.000000 0 0.000000 |
343 | +TOO LONG 0 TOO LONG |
344 | +SET SESSION query_exec_time=default; |
345 | +SET SESSION query_exec_time=0.1; |
346 | @@ -1842,7 +1842,7 @@ |
347 | + 1.000000 0 0.000000 |
348 | + 156.000000 0 0.000000 |
349 | + 24336.000000 0 0.000000 |
350 | -+ 3796416.00000 0 0.000000 |
351 | ++3796416.000000 0 0.000000 |
352 | +TOO LONG 0 TOO LONG |
353 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
354 | +time count total |
355 | @@ -1851,7 +1851,7 @@ |
356 | + 1.000000 0 0.000000 |
357 | + 156.000000 0 0.000000 |
358 | + 24336.000000 0 0.000000 |
359 | -+ 3796416.00000 0 0.000000 |
360 | ++3796416.000000 0 0.000000 |
361 | +TOO LONG 0 TOO LONG |
362 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; |
363 | +SET SESSION query_exec_time=0.31; |
364 | @@ -1954,7 +1954,7 @@ |
365 | + 1.000000 11 4.050000 |
366 | + 156.000000 11 25.699999 |
367 | + 24336.000000 0 0.000000 |
368 | -+ 3796416.00000 0 0.000000 |
369 | ++3796416.000000 0 0.000000 |
370 | +TOO LONG 0 TOO LONG |
371 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
372 | +time count total |
373 | @@ -1963,7 +1963,7 @@ |
374 | + 1.000000 11 4.050000 |
375 | + 156.000000 11 25.699999 |
376 | + 24336.000000 0 0.000000 |
377 | -+ 3796416.00000 0 0.000000 |
378 | ++3796416.000000 0 0.000000 |
379 | +TOO LONG 0 TOO LONG |
380 | +SET SESSION query_exec_time=default; |
381 | +SET SESSION query_exec_time=0.1; |
382 | @@ -1976,7 +1976,7 @@ |
383 | + 0.001000 0 0.000000 |
384 | + 1.000000 0 0.000000 |
385 | + 1000.000000 0 0.000000 |
386 | -+ 1000000.00000 0 0.000000 |
387 | ++1000000.000000 0 0.000000 |
388 | +TOO LONG 0 TOO LONG |
389 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
390 | +time count total |
391 | @@ -1984,7 +1984,7 @@ |
392 | + 0.001000 0 0.000000 |
393 | + 1.000000 0 0.000000 |
394 | + 1000.000000 0 0.000000 |
395 | -+ 1000000.00000 0 0.000000 |
396 | ++1000000.000000 0 0.000000 |
397 | +TOO LONG 0 TOO LONG |
398 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; |
399 | +SET SESSION query_exec_time=0.31; |
400 | @@ -2086,7 +2086,7 @@ |
401 | + 0.001000 0 0.000000 |
402 | + 1.000000 11 4.050000 |
403 | + 1000.000000 11 25.699999 |
404 | -+ 1000000.00000 0 0.000000 |
405 | ++1000000.000000 0 0.000000 |
406 | +TOO LONG 0 TOO LONG |
407 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
408 | +time count total |
409 | @@ -2094,7 +2094,7 @@ |
410 | + 0.001000 0 0.000000 |
411 | + 1.000000 11 4.050000 |
412 | + 1000.000000 11 25.699999 |
413 | -+ 1000000.00000 0 0.000000 |
414 | ++1000000.000000 0 0.000000 |
415 | +TOO LONG 0 TOO LONG |
416 | +SET SESSION query_exec_time=default; |
417 | +SET SESSION query_exec_time=0.1; |
418 | @@ -2109,7 +2109,7 @@ |
419 | + 0.001000 0 0.000000 |
420 | + 1.000000 0 0.000000 |
421 | + 1000.000000 0 0.000000 |
422 | -+ 1000000.00000 0 0.000000 |
423 | ++1000000.000000 0 0.000000 |
424 | +TOO LONG 0 TOO LONG |
425 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
426 | +time count total |
427 | @@ -2117,7 +2117,7 @@ |
428 | + 0.001000 0 0.000000 |
429 | + 1.000000 0 0.000000 |
430 | + 1000.000000 0 0.000000 |
431 | -+ 1000000.00000 0 0.000000 |
432 | ++1000000.000000 0 0.000000 |
433 | +TOO LONG 0 TOO LONG |
434 | +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; |
435 | +SET SESSION query_exec_time=0.31; |
436 | @@ -2219,7 +2219,7 @@ |
437 | + 0.001000 0 0.000000 |
438 | + 1.000000 11 4.050000 |
439 | + 1000.000000 11 25.699999 |
440 | -+ 1000000.00000 0 0.000000 |
441 | ++1000000.000000 0 0.000000 |
442 | +TOO LONG 0 TOO LONG |
443 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
444 | +time count total |
445 | @@ -2227,7 +2227,7 @@ |
446 | + 0.001000 0 0.000000 |
447 | + 1.000000 11 4.050000 |
448 | + 1000.000000 11 25.699999 |
449 | -+ 1000000.00000 0 0.000000 |
450 | ++1000000.000000 0 0.000000 |
451 | +TOO LONG 0 TOO LONG |
452 | +SET SESSION query_exec_time=default; |
453 | +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default; |
454 | @@ -2317,10 +2317,10 @@ |
455 | + 131072.000000 0 0.000000 |
456 | + 262144.000000 0 0.000000 |
457 | + 524288.000000 0 0.000000 |
458 | -+ 1048576.00000 0 0.000000 |
459 | -+ 2097152.00000 0 0.000000 |
460 | -+ 4194304.00000 0 0.000000 |
461 | -+ 8388608.00000 0 0.000000 |
462 | ++1048576.000000 0 0.000000 |
463 | ++2097152.000000 0 0.000000 |
464 | ++4194304.000000 0 0.000000 |
465 | ++8388608.000000 0 0.000000 |
466 | +TOO LONG 0 TOO LONG |
467 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
468 | +time count total |
469 | @@ -2363,10 +2363,10 @@ |
470 | + 131072.000000 0 0.000000 |
471 | + 262144.000000 0 0.000000 |
472 | + 524288.000000 0 0.000000 |
473 | -+ 1048576.00000 0 0.000000 |
474 | -+ 2097152.00000 0 0.000000 |
475 | -+ 4194304.00000 0 0.000000 |
476 | -+ 8388608.00000 0 0.000000 |
477 | ++1048576.000000 0 0.000000 |
478 | ++2097152.000000 0 0.000000 |
479 | ++4194304.000000 0 0.000000 |
480 | ++8388608.000000 0 0.000000 |
481 | +TOO LONG 0 TOO LONG |
482 | +SET SESSION query_exec_time=default; |
483 | +SET SESSION query_exec_time=0.1; |
484 | @@ -2441,10 +2441,10 @@ |
485 | + 131072.000000 0 0.000000 |
486 | + 262144.000000 0 0.000000 |
487 | + 524288.000000 0 0.000000 |
488 | -+ 1048576.00000 0 0.000000 |
489 | -+ 2097152.00000 0 0.000000 |
490 | -+ 4194304.00000 0 0.000000 |
491 | -+ 8388608.00000 0 0.000000 |
492 | ++1048576.000000 0 0.000000 |
493 | ++2097152.000000 0 0.000000 |
494 | ++4194304.000000 0 0.000000 |
495 | ++8388608.000000 0 0.000000 |
496 | +TOO LONG 0 TOO LONG |
497 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
498 | +time count total |
499 | @@ -2487,10 +2487,10 @@ |
500 | + 131072.000000 0 0.000000 |
501 | + 262144.000000 0 0.000000 |
502 | + 524288.000000 0 0.000000 |
503 | -+ 1048576.00000 0 0.000000 |
504 | -+ 2097152.00000 0 0.000000 |
505 | -+ 4194304.00000 0 0.000000 |
506 | -+ 8388608.00000 0 0.000000 |
507 | ++1048576.000000 0 0.000000 |
508 | ++2097152.000000 0 0.000000 |
509 | ++4194304.000000 0 0.000000 |
510 | ++8388608.000000 0 0.000000 |
511 | +TOO LONG 0 TOO LONG |
512 | +SET SESSION query_exec_time=default; |
513 | +SET SESSION query_exec_time=0.1; |
514 | @@ -2538,7 +2538,7 @@ |
515 | + 1000.000000 0 0.000000 |
516 | + 10000.000000 0 0.000000 |
517 | + 100000.000000 0 0.000000 |
518 | -+ 1000000.00000 0 0.000000 |
519 | ++1000000.000000 0 0.000000 |
520 | +TOO LONG 0 TOO LONG |
521 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
522 | +time count total |
523 | @@ -2554,7 +2554,7 @@ |
524 | + 1000.000000 0 0.000000 |
525 | + 10000.000000 0 0.000000 |
526 | + 100000.000000 0 0.000000 |
527 | -+ 1000000.00000 0 0.000000 |
528 | ++1000000.000000 0 0.000000 |
529 | +TOO LONG 0 TOO LONG |
530 | +SET SESSION query_exec_time=default; |
531 | +SET SESSION query_exec_time=0.1; |
532 | @@ -2605,7 +2605,7 @@ |
533 | + 16807.000000 0 0.000000 |
534 | + 117649.000000 0 0.000000 |
535 | + 823543.000000 0 0.000000 |
536 | -+ 5764801.00000 0 0.000000 |
537 | ++5764801.000000 0 0.000000 |
538 | +TOO LONG 0 TOO LONG |
539 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
540 | +time count total |
541 | @@ -2624,7 +2624,7 @@ |
542 | + 16807.000000 0 0.000000 |
543 | + 117649.000000 0 0.000000 |
544 | + 823543.000000 0 0.000000 |
545 | -+ 5764801.00000 0 0.000000 |
546 | ++5764801.000000 0 0.000000 |
547 | +TOO LONG 0 TOO LONG |
548 | +SET SESSION query_exec_time=default; |
549 | +SET SESSION query_exec_time=0.1; |
550 | @@ -2665,7 +2665,7 @@ |
551 | + 1.000000 55 8.450000 |
552 | + 156.000000 11 25.699999 |
553 | + 24336.000000 0 0.000000 |
554 | -+ 3796416.00000 0 0.000000 |
555 | ++3796416.000000 0 0.000000 |
556 | +TOO LONG 0 TOO LONG |
557 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
558 | +time count total |
559 | @@ -2674,7 +2674,7 @@ |
560 | + 1.000000 55 8.450000 |
561 | + 156.000000 11 25.699999 |
562 | + 24336.000000 0 0.000000 |
563 | -+ 3796416.00000 0 0.000000 |
564 | ++3796416.000000 0 0.000000 |
565 | +TOO LONG 0 TOO LONG |
566 | +SET SESSION query_exec_time=default; |
567 | +SET SESSION query_exec_time=0.1; |
568 | @@ -2714,7 +2714,7 @@ |
569 | + 0.001000 0 0.000000 |
570 | + 1.000000 55 8.450000 |
571 | + 1000.000000 11 25.699999 |
572 | -+ 1000000.00000 0 0.000000 |
573 | ++1000000.000000 0 0.000000 |
574 | +TOO LONG 0 TOO LONG |
575 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
576 | +time count total |
577 | @@ -2722,7 +2722,7 @@ |
578 | + 0.001000 0 0.000000 |
579 | + 1.000000 55 8.450000 |
580 | + 1000.000000 11 25.699999 |
581 | -+ 1000000.00000 0 0.000000 |
582 | ++1000000.000000 0 0.000000 |
583 | +TOO LONG 0 TOO LONG |
584 | +SET SESSION query_exec_time=default; |
585 | +SET SESSION query_exec_time=0.1; |
586 | @@ -2764,7 +2764,7 @@ |
587 | + 0.001000 0 0.000000 |
588 | + 1.000000 55 8.450000 |
589 | + 1000.000000 11 25.699999 |
590 | -+ 1000000.00000 0 0.000000 |
591 | ++1000000.000000 0 0.000000 |
592 | +TOO LONG 0 TOO LONG |
593 | +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; |
594 | +time count total |
595 | @@ -2772,7 +2772,7 @@ |
596 | + 0.001000 0 0.000000 |
597 | + 1.000000 55 8.450000 |
598 | + 1000.000000 11 25.699999 |
599 | -+ 1000000.00000 0 0.000000 |
600 | ++1000000.000000 0 0.000000 |
601 | +TOO LONG 0 TOO LONG |
602 | +SET SESSION query_exec_time=default; |
603 | +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default; |
604 | @@ -3002,7 +3002,7 @@ |
605 | extern bool in_bootstrap; |
606 | --- /dev/null |
607 | +++ b/sql/query_response_time.cc |
608 | -@@ -0,0 +1,310 @@ |
609 | +@@ -0,0 +1,302 @@ |
610 | +#include "mysql_version.h" |
611 | +#include "my_global.h" |
612 | +#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION |
613 | @@ -3021,7 +3021,6 @@ |
614 | +#define MAXIMUM_BASE QRT_MAXIMUM_BASE |
615 | +#define POSITIVE_POWER_FILLER QRT_POSITIVE_POWER_FILLER |
616 | +#define NEGATIVE_POWER_FILLER QRT_NEGATIVE_POWER_FILLER |
617 | -+#define STRING_OVERFLOW QRT_STRING_OVERFLOW |
618 | +#define TIME_OVERFLOW QRT_TIME_OVERFLOW |
619 | +#define DEFAULT_BASE QRT_DEFAULT_BASE |
620 | + |
621 | @@ -3142,20 +3141,13 @@ |
622 | + ulonglong m_bound[OVERALL_POWER_COUNT]; |
623 | +}; |
624 | + |
625 | -+void print_time(char* buffer, std::size_t buffer_size, std::size_t string_positive_power_length, const char* format, uint64 value) |
626 | ++static |
627 | ++void print_time(char* buffer, std::size_t buffer_size, const char* format, |
628 | ++ uint64 value) |
629 | +{ |
630 | -+ memset(buffer,'X',buffer_size); |
631 | -+ buffer[string_positive_power_length]= '.'; |
632 | + ulonglong second= (value / MILLION); |
633 | + ulonglong microsecond= (value % MILLION); |
634 | -+ std::size_t result_length= snprintf(buffer,buffer_size,format,second,microsecond); |
635 | -+ if(result_length < 0) |
636 | -+ { |
637 | -+ assert(sizeof(STRING_OVERFLOW) <= buffer_size); |
638 | -+ memcpy(buffer, STRING_OVERFLOW, sizeof(STRING_OVERFLOW)); |
639 | -+ return; |
640 | -+ } |
641 | -+ buffer[result_length]= 0; |
642 | ++ my_snprintf(buffer, buffer_size, format, second, microsecond); |
643 | +} |
644 | + |
645 | +class time_collector |
646 | @@ -3248,8 +3240,8 @@ |
647 | + } |
648 | + else |
649 | + { |
650 | -+ print_time(time,sizeof(time),TIME_STRING_POSITIVE_POWER_LENGTH,TIME_STRING_FORMAT,this->bound(i)); |
651 | -+ print_time(total,sizeof(total),TOTAL_STRING_POSITIVE_POWER_LENGTH,TOTAL_STRING_FORMAT,this->total(i)); |
652 | ++ print_time(time, sizeof(time), TIME_STRING_FORMAT, this->bound(i)); |
653 | ++ print_time(total, sizeof(total), TOTAL_STRING_FORMAT, this->total(i)); |
654 | + } |
655 | + fields[0]->store(time,strlen(time),system_charset_info); |
656 | + fields[1]->store(this->count(i)); |
657 | @@ -3315,7 +3307,7 @@ |
658 | +#endif // HAVE_RESPONSE_TIME_DISTRIBUTION |
659 | --- /dev/null |
660 | +++ b/sql/query_response_time.h |
661 | -@@ -0,0 +1,71 @@ |
662 | +@@ -0,0 +1,64 @@ |
663 | +#ifndef QUERY_RESPONSE_TIME_H |
664 | +#define QUERY_RESPONSE_TIME_H |
665 | + |
666 | @@ -3348,18 +3340,13 @@ |
667 | + and number 7234 result is: |
668 | + ' 7234' |
669 | +*/ |
670 | -+#define QRT_POSITIVE_POWER_FILLER " " |
671 | ++#define QRT_POSITIVE_POWER_FILLER "" |
672 | +/* |
673 | + Filler for fractional number. Similiary to whole number |
674 | +*/ |
675 | +#define QRT_NEGATIVE_POWER_FILLER "0" |
676 | + |
677 | +/* |
678 | -+ Message if string overflow (string overflow - internal error, this string say about bug in QRT) |
679 | -+*/ |
680 | -+#define QRT_STRING_OVERFLOW "TOO BIG STRING" |
681 | -+ |
682 | -+/* |
683 | + Message if time too big for statistic collecting (very long query) |
684 | +*/ |
685 | +#define QRT_TIME_OVERFLOW "TOO LONG" |
686 | @@ -3368,13 +3355,11 @@ |
687 | + |
688 | +#define QRT_TIME_STRING_LENGTH \ |
689 | + max( (QRT_TIME_STRING_POSITIVE_POWER_LENGTH + 1 /* '.' */ + 6 /*QRT_TIME_STRING_NEGATIVE_POWER_LENGTH*/), \ |
690 | -+ max( (sizeof(QRT_TIME_OVERFLOW) - 1), \ |
691 | -+ (sizeof(QRT_STRING_OVERFLOW) - 1) ) ) |
692 | ++ (sizeof(QRT_TIME_OVERFLOW) - 1) ) |
693 | + |
694 | +#define QRT_TOTAL_STRING_LENGTH \ |
695 | + max( (QRT_TOTAL_STRING_POSITIVE_POWER_LENGTH + 1 /* '.' */ + 6 /*QRT_TOTAL_STRING_NEGATIVE_POWER_LENGTH*/), \ |
696 | -+ max( (sizeof(QRT_TIME_OVERFLOW) - 1), \ |
697 | -+ (sizeof(QRT_STRING_OVERFLOW) - 1) ) ) |
698 | ++ (sizeof(QRT_TIME_OVERFLOW) - 1) ) |
699 | + |
700 | +extern ST_SCHEMA_TABLE query_response_time_table; |
701 | + |
LGTM
Nice work, thank you!