]> git.pld-linux.org Git - packages/mysql.git/blob - mysql-userstatv2.patch
- percona patches updated by Eero Hänninen; rel 2
[packages/mysql.git] / mysql-userstatv2.patch
1 diff -r 1ac0113deff5 BUILD/Makefile.in
2 --- a/BUILD/Makefile.in Mon Jun 01 00:35:44 2009 -0700
3 +++ b/BUILD/Makefile.in Mon Jun 01 00:36:01 2009 -0700
4 @@ -146,6 +146,7 @@
5  LIBDL = @LIBDL@
6  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
7  LIBOBJS = @LIBOBJS@
8 +LIBRT = @LIBRT@
9  LIBS = @LIBS@
10  LIBTOOL = @LIBTOOL@
11  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
12 diff -r 1ac0113deff5 Docs/Makefile.in
13 --- a/Docs/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
14 +++ b/Docs/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
15 @@ -144,6 +144,7 @@
16  LIBDL = @LIBDL@
17  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
18  LIBOBJS = @LIBOBJS@
19 +LIBRT = @LIBRT@
20  LIBS = @LIBS@
21  LIBTOOL = @LIBTOOL@
22  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
23 diff -r 1ac0113deff5 Makefile.in
24 --- a/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
25 +++ b/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
26 @@ -171,6 +171,7 @@
27  LIBDL = @LIBDL@
28  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
29  LIBOBJS = @LIBOBJS@
30 +LIBRT = @LIBRT@
31  LIBS = @LIBS@
32  LIBTOOL = @LIBTOOL@
33  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
34 diff -r 1ac0113deff5 SSL/Makefile.in
35 --- a/SSL/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
36 +++ b/SSL/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
37 @@ -144,6 +144,7 @@
38  LIBDL = @LIBDL@
39  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
40  LIBOBJS = @LIBOBJS@
41 +LIBRT = @LIBRT@
42  LIBS = @LIBS@
43  LIBTOOL = @LIBTOOL@
44  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
45 diff -r 1ac0113deff5 client/Makefile.in
46 --- a/client/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
47 +++ b/client/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
48 @@ -247,6 +247,7 @@
49  LIBDL = @LIBDL@
50  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
51  LIBOBJS = @LIBOBJS@
52 +LIBRT = @LIBRT@
53  LIBS = @CLIENT_LIBS@
54  LIBTOOL = @LIBTOOL@
55  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
56 diff -r 1ac0113deff5 cmd-line-utils/Makefile.in
57 --- a/cmd-line-utils/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
58 +++ b/cmd-line-utils/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
59 @@ -157,6 +157,7 @@
60  LIBDL = @LIBDL@
61  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
62  LIBOBJS = @LIBOBJS@
63 +LIBRT = @LIBRT@
64  LIBS = @LIBS@
65  LIBTOOL = @LIBTOOL@
66  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
67 diff -r 1ac0113deff5 cmd-line-utils/libedit/Makefile.in
68 --- a/cmd-line-utils/libedit/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
69 +++ b/cmd-line-utils/libedit/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
70 @@ -166,6 +166,7 @@
71  LIBDL = @LIBDL@
72  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
73  LIBOBJS = @LIBOBJS@
74 +LIBRT = @LIBRT@
75  LIBS = @LIBS@
76  LIBTOOL = @LIBTOOL@
77  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
78 diff -r 1ac0113deff5 cmd-line-utils/readline/Makefile.in
79 --- a/cmd-line-utils/readline/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
80 +++ b/cmd-line-utils/readline/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
81 @@ -173,6 +173,7 @@
82  LIBDL = @LIBDL@
83  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
84  LIBOBJS = @LIBOBJS@
85 +LIBRT = @LIBRT@
86  LIBS = @LIBS@
87  LIBTOOL = @LIBTOOL@
88  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
89 diff -r 1ac0113deff5 configure
90 --- a/configure Mon Jun 01 00:35:44 2009 -0700
91 +++ b/configure Mon Jun 01 00:36:01 2009 -0700
92 @@ -35333,7 +35333,91 @@
93         # We also disable for SCO for the time being, the headers for the
94         # thread library we use conflicts with other headers.
95      ;;
96 - *)
97 +*)
98 +   # most systems require the program be linked with librt library to use
99 +   # the function clock_gettime
100 +   my_save_LIBS="$LIBS"
101 +   LIBS=""
102 +
103 +echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
104 +echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
105 +if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
106 +  echo $ECHO_N "(cached) $ECHO_C" >&6
107 +else
108 +  ac_check_lib_save_LIBS=$LIBS
109 +LIBS="-lrt  $LIBS"
110 +cat >conftest.$ac_ext <<_ACEOF
111 +/* confdefs.h.  */
112 +_ACEOF
113 +cat confdefs.h >>conftest.$ac_ext
114 +cat >>conftest.$ac_ext <<_ACEOF
115 +/* end confdefs.h.  */
116 +
117 +/* Override any gcc2 internal prototype to avoid an error.  */
118 +#ifdef __cplusplus
119 +extern "C"
120 +#endif
121 +/* We use char because int might match the return type of a gcc2
122 +   builtin and then its argument prototype would still apply.  */
123 +char clock_gettime ();
124 +int
125 +main ()
126 +{
127 +clock_gettime ();
128 +  ;
129 +  return 0;
130 +}
131 +_ACEOF
132 +rm -f conftest.$ac_objext conftest$ac_exeext
133 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
134 +  (eval $ac_link) 2>conftest.er1
135 +  ac_status=$?
136 +  grep -v '^ *+' conftest.er1 >conftest.err
137 +  rm -f conftest.er1
138 +  cat conftest.err >&5
139 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
140 +  (exit $ac_status); } &&
141 +        { ac_try='test -z "$ac_c_werror_flag"
142 +                        || test ! -s conftest.err'
143 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
144 +  (eval $ac_try) 2>&5
145 +  ac_status=$?
146 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
147 +  (exit $ac_status); }; } &&
148 +        { ac_try='test -s conftest$ac_exeext'
149 +  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
150 +  (eval $ac_try) 2>&5
151 +  ac_status=$?
152 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
153 +  (exit $ac_status); }; }; then
154 +  ac_cv_lib_rt_clock_gettime=yes
155 +else
156 +  echo "$as_me: failed program was:" >&5
157 +sed 's/^/| /' conftest.$ac_ext >&5
158 +
159 +ac_cv_lib_rt_clock_gettime=no
160 +fi
161 +rm -f conftest.err conftest.$ac_objext \
162 +      conftest$ac_exeext conftest.$ac_ext
163 +LIBS=$ac_check_lib_save_LIBS
164 +fi
165 +echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
166 +echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
167 +if test $ac_cv_lib_rt_clock_gettime = yes; then
168 +  cat >>confdefs.h <<_ACEOF
169 +#define HAVE_LIBRT 1
170 +_ACEOF
171 +
172 +  LIBS="-lrt $LIBS"
173 +
174 +fi
175 +
176 +   LIBRT=$LIBS
177 +   LIBS="$my_save_LIBS"
178 +
179 +
180 +   LIBS="$LIBS $LIBRT"
181 +
182  for ac_func in clock_gettime
183  do
184  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
185 @@ -38777,7 +38861,7 @@
186  
187  fi
188  
189 -CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
190 +CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
191  
192  
193  
194 diff -r 1ac0113deff5 configure.in
195 --- a/configure.in      Mon Jun 01 00:35:44 2009 -0700
196 +++ b/configure.in      Mon Jun 01 00:36:01 2009 -0700
197 @@ -2122,7 +2122,18 @@
198         # We also disable for SCO for the time being, the headers for the
199         # thread library we use conflicts with other headers.
200      ;;
201 - *) AC_CHECK_FUNCS(clock_gettime)
202 +*) 
203 +   # most systems require the program be linked with librt library to use
204 +   # the function clock_gettime 
205 +   my_save_LIBS="$LIBS"
206 +   LIBS=""
207 +   AC_CHECK_LIB(rt,clock_gettime)
208 +   LIBRT=$LIBS
209 +   LIBS="$my_save_LIBS"
210 +   AC_SUBST(LIBRT)
211 +
212 +   LIBS="$LIBS $LIBRT"
213 +   AC_CHECK_FUNCS(clock_gettime)
214      ;;
215  esac
216  
217 @@ -2758,7 +2769,7 @@
218    AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
219  fi
220  
221 -CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
222 +CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
223  
224  AC_SUBST(CLIENT_LIBS)
225  AC_SUBST(NON_THREADED_LIBS)
226 diff -r 1ac0113deff5 dbug/Makefile.in
227 --- a/dbug/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
228 +++ b/dbug/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
229 @@ -192,6 +192,7 @@
230  LIBDL = @LIBDL@
231  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
232  LIBOBJS = @LIBOBJS@
233 +LIBRT = @LIBRT@
234  LIBS = @LIBS@
235  LIBTOOL = @LIBTOOL@
236  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
237 diff -r 1ac0113deff5 extra/Makefile.in
238 --- a/extra/Makefile.in Mon Jun 01 00:35:44 2009 -0700
239 +++ b/extra/Makefile.in Mon Jun 01 00:36:01 2009 -0700
240 @@ -240,6 +240,7 @@
241  LIBDL = @LIBDL@
242  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
243  LIBOBJS = @LIBOBJS@
244 +LIBRT = @LIBRT@
245  LIBS = @LIBS@
246  LIBTOOL = @LIBTOOL@
247  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
248 diff -r 1ac0113deff5 extra/yassl/Makefile.in
249 --- a/extra/yassl/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
250 +++ b/extra/yassl/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
251 @@ -142,6 +142,7 @@
252  LIBDL = @LIBDL@
253  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
254  LIBOBJS = @LIBOBJS@
255 +LIBRT = @LIBRT@
256  LIBS = @LIBS@
257  LIBTOOL = @LIBTOOL@
258  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
259 diff -r 1ac0113deff5 extra/yassl/src/Makefile.in
260 --- a/extra/yassl/src/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
261 +++ b/extra/yassl/src/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
262 @@ -151,6 +151,7 @@
263  LIBDL = @LIBDL@
264  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
265  LIBOBJS = @LIBOBJS@
266 +LIBRT = @LIBRT@
267  LIBS = @LIBS@
268  LIBTOOL = @LIBTOOL@
269  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
270 diff -r 1ac0113deff5 extra/yassl/taocrypt/Makefile.in
271 --- a/extra/yassl/taocrypt/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
272 +++ b/extra/yassl/taocrypt/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
273 @@ -142,6 +142,7 @@
274  LIBDL = @LIBDL@
275  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
276  LIBOBJS = @LIBOBJS@
277 +LIBRT = @LIBRT@
278  LIBS = @LIBS@
279  LIBTOOL = @LIBTOOL@
280  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
281 diff -r 1ac0113deff5 extra/yassl/taocrypt/benchmark/Makefile.in
282 --- a/extra/yassl/taocrypt/benchmark/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
283 +++ b/extra/yassl/taocrypt/benchmark/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
284 @@ -153,6 +153,7 @@
285  LIBDL = @LIBDL@
286  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
287  LIBOBJS = @LIBOBJS@
288 +LIBRT = @LIBRT@
289  LIBS = @LIBS@
290  LIBTOOL = @LIBTOOL@
291  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
292 diff -r 1ac0113deff5 extra/yassl/taocrypt/src/Makefile.in
293 --- a/extra/yassl/taocrypt/src/Makefile.in      Mon Jun 01 00:35:44 2009 -0700
294 +++ b/extra/yassl/taocrypt/src/Makefile.in      Mon Jun 01 00:36:01 2009 -0700
295 @@ -164,6 +164,7 @@
296  LIBDL = @LIBDL@
297  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
298  LIBOBJS = @LIBOBJS@
299 +LIBRT = @LIBRT@
300  LIBS = @LIBS@
301  LIBTOOL = @LIBTOOL@
302  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
303 diff -r 1ac0113deff5 extra/yassl/taocrypt/test/Makefile.in
304 --- a/extra/yassl/taocrypt/test/Makefile.in     Mon Jun 01 00:35:44 2009 -0700
305 +++ b/extra/yassl/taocrypt/test/Makefile.in     Mon Jun 01 00:36:01 2009 -0700
306 @@ -153,6 +153,7 @@
307  LIBDL = @LIBDL@
308  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
309  LIBOBJS = @LIBOBJS@
310 +LIBRT = @LIBRT@
311  LIBS = @LIBS@
312  LIBTOOL = @LIBTOOL@
313  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
314 diff -r 1ac0113deff5 extra/yassl/testsuite/Makefile.in
315 --- a/extra/yassl/testsuite/Makefile.in Mon Jun 01 00:35:44 2009 -0700
316 +++ b/extra/yassl/testsuite/Makefile.in Mon Jun 01 00:36:01 2009 -0700
317 @@ -156,6 +156,7 @@
318  LIBDL = @LIBDL@
319  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
320  LIBOBJS = @LIBOBJS@
321 +LIBRT = @LIBRT@
322  LIBS = @LIBS@
323  LIBTOOL = @LIBTOOL@
324  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
325 diff -r 1ac0113deff5 heap/Makefile.in
326 --- a/heap/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
327 +++ b/heap/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
328 @@ -202,6 +202,7 @@
329  LIBDL = @LIBDL@
330  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
331  LIBOBJS = @LIBOBJS@
332 +LIBRT = @LIBRT@
333  LIBS = @LIBS@
334  LIBTOOL = @LIBTOOL@
335  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
336 diff -r 1ac0113deff5 include/Makefile.in
337 --- a/include/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
338 +++ b/include/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
339 @@ -160,6 +160,7 @@
340  LIBDL = @LIBDL@
341  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
342  LIBOBJS = @LIBOBJS@
343 +LIBRT = @LIBRT@
344  LIBS = @LIBS@
345  LIBTOOL = @LIBTOOL@
346  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
347 diff -r 1ac0113deff5 include/mysql_com.h
348 --- a/include/mysql_com.h       Mon Jun 01 00:35:44 2009 -0700
349 +++ b/include/mysql_com.h       Mon Jun 01 00:36:01 2009 -0700
350 @@ -106,6 +106,11 @@
351                                            thread */
352  #define REFRESH_MASTER          128     /* Remove all bin logs in the index
353                                            and truncate the index */
354 +#define REFRESH_TABLE_STATS     256     /* Refresh table stats hash table */
355 +#define REFRESH_INDEX_STATS     512     /* Refresh index stats hash table */
356 +#define REFRESH_USER_STATS      1024    /* Refresh user stats hash table */
357 +#define REFRESH_SLOW_QUERY_LOG  4096    /* Flush slow query log and rotate*/
358 +#define REFRESH_CLIENT_STATS    8192    /* Refresh client stats hash table */
359  
360  /* The following can't be set with mysql_refresh() */
361  #define REFRESH_READ_LOCK      16384   /* Lock tables for read */
362 diff -r 1ac0113deff5 libmysql/Makefile.in
363 --- a/libmysql/Makefile.in      Mon Jun 01 00:35:44 2009 -0700
364 +++ b/libmysql/Makefile.in      Mon Jun 01 00:36:01 2009 -0700
365 @@ -224,6 +224,7 @@
366  LIBDL = @LIBDL@
367  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
368  LIBOBJS = @LIBOBJS@
369 +LIBRT = @LIBRT@
370  LIBS = @CLIENT_LIBS@ 
371  LIBTOOL = @LIBTOOL@
372  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
373 diff -r 1ac0113deff5 libmysql_r/Makefile.in
374 --- a/libmysql_r/Makefile.in    Mon Jun 01 00:35:44 2009 -0700
375 +++ b/libmysql_r/Makefile.in    Mon Jun 01 00:36:01 2009 -0700
376 @@ -221,6 +221,7 @@
377  LIBDL = @LIBDL@
378  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
379  LIBOBJS = @LIBOBJS@
380 +LIBRT = @LIBRT@
381  LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
382  LIBTOOL = @LIBTOOL@
383  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
384 diff -r 1ac0113deff5 libmysqld/Makefile.in
385 --- a/libmysqld/Makefile.in     Mon Jun 01 00:35:44 2009 -0700
386 +++ b/libmysqld/Makefile.in     Mon Jun 01 00:36:01 2009 -0700
387 @@ -246,6 +246,7 @@
388  LIBDL = @LIBDL@
389  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
390  LIBOBJS = @LIBOBJS@
391 +LIBRT = @LIBRT@
392  LIBS = @LIBS@
393  LIBTOOL = @LIBTOOL@
394  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
395 diff -r 1ac0113deff5 libmysqld/examples/Makefile.in
396 --- a/libmysqld/examples/Makefile.in    Mon Jun 01 00:35:44 2009 -0700
397 +++ b/libmysqld/examples/Makefile.in    Mon Jun 01 00:36:01 2009 -0700
398 @@ -192,6 +192,7 @@
399  LIBDL = @LIBDL@
400  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
401  LIBOBJS = @LIBOBJS@
402 +LIBRT = @LIBRT@
403  LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
404  LIBTOOL = @LIBTOOL@
405  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
406 diff -r 1ac0113deff5 man/Makefile.in
407 --- a/man/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
408 +++ b/man/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
409 @@ -151,6 +151,7 @@
410  LIBDL = @LIBDL@
411  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
412  LIBOBJS = @LIBOBJS@
413 +LIBRT = @LIBRT@
414  LIBS = @LIBS@
415  LIBTOOL = @LIBTOOL@
416  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
417 diff -r 1ac0113deff5 myisam/Makefile.in
418 --- a/myisam/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
419 +++ b/myisam/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
420 @@ -235,6 +235,7 @@
421  LIBDL = @LIBDL@
422  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
423  LIBOBJS = @LIBOBJS@
424 +LIBRT = @LIBRT@
425  LIBS = @LIBS@
426  LIBTOOL = @LIBTOOL@
427  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
428 diff -r 1ac0113deff5 myisammrg/Makefile.in
429 --- a/myisammrg/Makefile.in     Mon Jun 01 00:35:44 2009 -0700
430 +++ b/myisammrg/Makefile.in     Mon Jun 01 00:36:01 2009 -0700
431 @@ -183,6 +183,7 @@
432  LIBDL = @LIBDL@
433  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
434  LIBOBJS = @LIBOBJS@
435 +LIBRT = @LIBRT@
436  LIBS = @LIBS@
437  LIBTOOL = @LIBTOOL@
438  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
439 diff -r 1ac0113deff5 mysql-test/Makefile.in
440 --- a/mysql-test/Makefile.in    Mon Jun 01 00:35:44 2009 -0700
441 +++ b/mysql-test/Makefile.in    Mon Jun 01 00:36:01 2009 -0700
442 @@ -161,6 +161,7 @@
443  LIBDL = @LIBDL@
444  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
445  LIBOBJS = @LIBOBJS@
446 +LIBRT = @LIBRT@
447  LIBS = @LIBS@
448  LIBTOOL = @LIBTOOL@
449  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
450 diff -r 1ac0113deff5 mysql-test/ndb/Makefile.in
451 --- a/mysql-test/ndb/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
452 +++ b/mysql-test/ndb/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
453 @@ -147,6 +147,7 @@
454  LIBDL = @LIBDL@
455  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
456  LIBOBJS = @LIBOBJS@
457 +LIBRT = @LIBRT@
458  LIBS = @LIBS@
459  LIBTOOL = @LIBTOOL@
460  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
461 diff -r 1ac0113deff5 mysql-test/r/information_schema.result
462 --- a/mysql-test/r/information_schema.result    Mon Jun 01 00:35:44 2009 -0700
463 +++ b/mysql-test/r/information_schema.result    Mon Jun 01 00:36:01 2009 -0700
464 @@ -37,10 +37,12 @@
465  select * from v1;
466  c
467  CHARACTER_SETS
468 +CLIENT_STATISTICS
469  COLLATIONS
470  COLLATION_CHARACTER_SET_APPLICABILITY
471  COLUMNS
472  COLUMN_PRIVILEGES
473 +INDEX_STATISTICS
474  KEY_COLUMN_USAGE
475  PROFILING
476  ROUTINES
477 @@ -50,8 +52,10 @@
478  TABLES
479  TABLE_CONSTRAINTS
480  TABLE_PRIVILEGES
481 +TABLE_STATISTICS
482  TRIGGERS
483  USER_PRIVILEGES
484 +USER_STATISTICS
485  VIEWS
486  columns_priv
487  db
488 @@ -83,6 +87,7 @@
489  TABLES TABLES
490  TABLE_CONSTRAINTS      TABLE_CONSTRAINTS
491  TABLE_PRIVILEGES       TABLE_PRIVILEGES
492 +TABLE_STATISTICS       TABLE_STATISTICS
493  TRIGGERS       TRIGGERS
494  tables_priv    tables_priv
495  time_zone      time_zone
496 @@ -102,6 +107,7 @@
497  TABLES TABLES
498  TABLE_CONSTRAINTS      TABLE_CONSTRAINTS
499  TABLE_PRIVILEGES       TABLE_PRIVILEGES
500 +TABLE_STATISTICS       TABLE_STATISTICS
501  TRIGGERS       TRIGGERS
502  tables_priv    tables_priv
503  time_zone      time_zone
504 @@ -121,6 +127,7 @@
505  TABLES TABLES
506  TABLE_CONSTRAINTS      TABLE_CONSTRAINTS
507  TABLE_PRIVILEGES       TABLE_PRIVILEGES
508 +TABLE_STATISTICS       TABLE_STATISTICS
509  TRIGGERS       TRIGGERS
510  tables_priv    tables_priv
511  time_zone      time_zone
512 @@ -594,12 +601,13 @@
513  where table_schema='information_schema' limit 2;
514  TABLE_NAME     TABLE_TYPE      ENGINE
515  CHARACTER_SETS SYSTEM VIEW     MEMORY
516 -COLLATIONS     SYSTEM VIEW     MEMORY
517 +CLIENT_STATISTICS      SYSTEM VIEW     MEMORY
518  show tables from information_schema like "T%";
519  Tables_in_information_schema (T%)
520  TABLES
521  TABLE_CONSTRAINTS
522  TABLE_PRIVILEGES
523 +TABLE_STATISTICS
524  TRIGGERS
525  create database information_schema;
526  ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
527 @@ -609,6 +617,7 @@
528  TABLES SYSTEM VIEW
529  TABLE_CONSTRAINTS      SYSTEM VIEW
530  TABLE_PRIVILEGES       SYSTEM VIEW
531 +TABLE_STATISTICS       SYSTEM VIEW
532  TRIGGERS       SYSTEM VIEW
533  create table t1(a int);
534  ERROR 42S02: Unknown table 't1' in information_schema
535 @@ -621,6 +630,7 @@
536  TABLES
537  TABLE_CONSTRAINTS
538  TABLE_PRIVILEGES
539 +TABLE_STATISTICS
540  TRIGGERS
541  select table_name from tables where table_name='user';
542  table_name
543 @@ -730,7 +740,7 @@
544  CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
545  CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
546  count(*)
547 -102
548 +106
549  drop view a2, a1;
550  drop table t_crashme;
551  select table_schema,table_name, column_name from
552 @@ -790,18 +800,20 @@
553  TABLE_NAME     COLUMN_NAME     PRIVILEGES
554  COLUMNS        TABLE_NAME      select
555  COLUMN_PRIVILEGES      TABLE_NAME      select
556 +INDEX_STATISTICS       TABLE_NAME      select
557  KEY_COLUMN_USAGE       TABLE_NAME      select
558  STATISTICS     TABLE_NAME      select
559  TABLES TABLE_NAME      select
560  TABLE_CONSTRAINTS      TABLE_NAME      select
561  TABLE_PRIVILEGES       TABLE_NAME      select
562 +TABLE_STATISTICS       TABLE_NAME      select
563  VIEWS  TABLE_NAME      select
564  delete from mysql.user where user='mysqltest_4';
565  delete from mysql.db where user='mysqltest_4';
566  flush privileges;
567  SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
568  table_schema   count(*)
569 -information_schema     17
570 +information_schema     21
571  mysql  17
572  create table t1 (i int, j int);
573  create trigger trg1 before insert on t1 for each row
574 @@ -1187,10 +1199,12 @@
575          );
576  table_name     column_name
577  CHARACTER_SETS CHARACTER_SET_NAME
578 +CLIENT_STATISTICS      CLIENT
579  COLLATIONS     COLLATION_NAME
580  COLLATION_CHARACTER_SET_APPLICABILITY  COLLATION_NAME
581  COLUMNS        TABLE_SCHEMA
582  COLUMN_PRIVILEGES      TABLE_SCHEMA
583 +INDEX_STATISTICS       TABLE_SCHEMA
584  KEY_COLUMN_USAGE       CONSTRAINT_SCHEMA
585  PROFILING      QUERY_ID
586  ROUTINES       ROUTINE_SCHEMA
587 @@ -1200,8 +1214,10 @@
588  TABLES TABLE_SCHEMA
589  TABLE_CONSTRAINTS      CONSTRAINT_SCHEMA
590  TABLE_PRIVILEGES       TABLE_SCHEMA
591 +TABLE_STATISTICS       TABLE_SCHEMA
592  TRIGGERS       TRIGGER_SCHEMA
593  USER_PRIVILEGES        GRANTEE
594 +USER_STATISTICS        USER
595  VIEWS  TABLE_SCHEMA
596  SELECT t.table_name, c1.column_name
597  FROM information_schema.tables t
598 @@ -1219,10 +1235,12 @@
599          );
600  table_name     column_name
601  CHARACTER_SETS CHARACTER_SET_NAME
602 +CLIENT_STATISTICS      CLIENT
603  COLLATIONS     COLLATION_NAME
604  COLLATION_CHARACTER_SET_APPLICABILITY  COLLATION_NAME
605  COLUMNS        TABLE_SCHEMA
606  COLUMN_PRIVILEGES      TABLE_SCHEMA
607 +INDEX_STATISTICS       TABLE_SCHEMA
608  KEY_COLUMN_USAGE       CONSTRAINT_SCHEMA
609  PROFILING      QUERY_ID
610  ROUTINES       ROUTINE_SCHEMA
611 @@ -1232,8 +1250,10 @@
612  TABLES TABLE_SCHEMA
613  TABLE_CONSTRAINTS      CONSTRAINT_SCHEMA
614  TABLE_PRIVILEGES       TABLE_SCHEMA
615 +TABLE_STATISTICS       TABLE_SCHEMA
616  TRIGGERS       TRIGGER_SCHEMA
617  USER_PRIVILEGES        GRANTEE
618 +USER_STATISTICS        USER
619  VIEWS  TABLE_SCHEMA
620  SELECT MAX(table_name) FROM information_schema.tables;
621  MAX(table_name)
622 @@ -1302,10 +1322,12 @@
623  group by t.table_name order by num1, t.table_name;
624  table_name     group_concat(t.table_schema, '.', t.table_name) num1
625  CHARACTER_SETS information_schema.CHARACTER_SETS       1
626 +CLIENT_STATISTICS      information_schema.CLIENT_STATISTICS    1
627  COLLATIONS     information_schema.COLLATIONS   1
628  COLLATION_CHARACTER_SET_APPLICABILITY  information_schema.COLLATION_CHARACTER_SET_APPLICABILITY        1
629  COLUMNS        information_schema.COLUMNS      1
630  COLUMN_PRIVILEGES      information_schema.COLUMN_PRIVILEGES    1
631 +INDEX_STATISTICS       information_schema.INDEX_STATISTICS     1
632  KEY_COLUMN_USAGE       information_schema.KEY_COLUMN_USAGE     1
633  PROFILING      information_schema.PROFILING    1
634  ROUTINES       information_schema.ROUTINES     1
635 @@ -1315,8 +1337,10 @@
636  TABLES information_schema.TABLES       1
637  TABLE_CONSTRAINTS      information_schema.TABLE_CONSTRAINTS    1
638  TABLE_PRIVILEGES       information_schema.TABLE_PRIVILEGES     1
639 +TABLE_STATISTICS       information_schema.TABLE_STATISTICS     1
640  TRIGGERS       information_schema.TRIGGERS     1
641  USER_PRIVILEGES        information_schema.USER_PRIVILEGES      1
642 +USER_STATISTICS        information_schema.USER_STATISTICS      1
643  VIEWS  information_schema.VIEWS        1
644  show global status like "Uptime_%";
645  Variable_name  Value
646 diff -r 1ac0113deff5 mysql-test/r/information_schema_db.result
647 --- a/mysql-test/r/information_schema_db.result Mon Jun 01 00:35:44 2009 -0700
648 +++ b/mysql-test/r/information_schema_db.result Mon Jun 01 00:36:01 2009 -0700
649 @@ -6,10 +6,12 @@
650  show tables;
651  Tables_in_information_schema
652  CHARACTER_SETS
653 +CLIENT_STATISTICS
654  COLLATIONS
655  COLLATION_CHARACTER_SET_APPLICABILITY
656  COLUMNS
657  COLUMN_PRIVILEGES
658 +INDEX_STATISTICS
659  KEY_COLUMN_USAGE
660  PROFILING
661  ROUTINES
662 @@ -19,14 +21,17 @@
663  TABLES
664  TABLE_CONSTRAINTS
665  TABLE_PRIVILEGES
666 +TABLE_STATISTICS
667  TRIGGERS
668  USER_PRIVILEGES
669 +USER_STATISTICS
670  VIEWS
671  show tables from INFORMATION_SCHEMA like 'T%';
672  Tables_in_information_schema (T%)
673  TABLES
674  TABLE_CONSTRAINTS
675  TABLE_PRIVILEGES
676 +TABLE_STATISTICS
677  TRIGGERS
678  create database `inf%`;
679  create database mbase;
680 diff -r 1ac0113deff5 mysql-test/r/mysqlshow.result
681 --- a/mysql-test/r/mysqlshow.result     Mon Jun 01 00:35:44 2009 -0700
682 +++ b/mysql-test/r/mysqlshow.result     Mon Jun 01 00:36:01 2009 -0700
683 @@ -80,10 +80,12 @@
684  |                Tables                 |
685  +---------------------------------------+
686  | CHARACTER_SETS                        |
687 +| CLIENT_STATISTICS                     |
688  | COLLATIONS                            |
689  | COLLATION_CHARACTER_SET_APPLICABILITY |
690  | COLUMNS                               |
691  | COLUMN_PRIVILEGES                     |
692 +| INDEX_STATISTICS                      |
693  | KEY_COLUMN_USAGE                      |
694  | PROFILING                             |
695  | ROUTINES                              |
696 @@ -93,8 +95,10 @@
697  | TABLES                                |
698  | TABLE_CONSTRAINTS                     |
699  | TABLE_PRIVILEGES                      |
700 +| TABLE_STATISTICS                      |
701  | TRIGGERS                              |
702  | USER_PRIVILEGES                       |
703 +| USER_STATISTICS                       |
704  | VIEWS                                 |
705  +---------------------------------------+
706  Database: INFORMATION_SCHEMA
707 @@ -102,10 +106,12 @@
708  |                Tables                 |
709  +---------------------------------------+
710  | CHARACTER_SETS                        |
711 +| CLIENT_STATISTICS                     |
712  | COLLATIONS                            |
713  | COLLATION_CHARACTER_SET_APPLICABILITY |
714  | COLUMNS                               |
715  | COLUMN_PRIVILEGES                     |
716 +| INDEX_STATISTICS                      |
717  | KEY_COLUMN_USAGE                      |
718  | PROFILING                             |
719  | ROUTINES                              |
720 @@ -115,8 +121,10 @@
721  | TABLES                                |
722  | TABLE_CONSTRAINTS                     |
723  | TABLE_PRIVILEGES                      |
724 +| TABLE_STATISTICS                      |
725  | TRIGGERS                              |
726  | USER_PRIVILEGES                       |
727 +| USER_STATISTICS                       |
728  | VIEWS                                 |
729  +---------------------------------------+
730  Wildcard: inf_rmation_schema
731 diff -r 1ac0113deff5 mysys/Makefile.in
732 --- a/mysys/Makefile.in Mon Jun 01 00:35:44 2009 -0700
733 +++ b/mysys/Makefile.in Mon Jun 01 00:36:01 2009 -0700
734 @@ -228,6 +228,7 @@
735  LIBDL = @LIBDL@
736  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
737  LIBOBJS = @LIBOBJS@
738 +LIBRT = @LIBRT@
739  LIBS = @LIBS@
740  LIBTOOL = @LIBTOOL@
741  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
742 diff -r 1ac0113deff5 ndb/Makefile.in
743 --- a/ndb/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
744 +++ b/ndb/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
745 @@ -171,6 +171,7 @@
746  LIBDL = @LIBDL@
747  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
748  LIBOBJS = @LIBOBJS@
749 +LIBRT = @LIBRT@
750  LIBS = @LIBS@
751  LIBTOOL = @LIBTOOL@
752  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
753 diff -r 1ac0113deff5 ndb/docs/Makefile.in
754 --- a/ndb/docs/Makefile.in      Mon Jun 01 00:35:44 2009 -0700
755 +++ b/ndb/docs/Makefile.in      Mon Jun 01 00:36:01 2009 -0700
756 @@ -149,6 +149,7 @@
757  LIBDL = @LIBDL@
758  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
759  LIBOBJS = @LIBOBJS@
760 +LIBRT = @LIBRT@
761  LIBS = @LIBS@
762  LIBTOOL = @LIBTOOL@
763  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
764 diff -r 1ac0113deff5 ndb/include/Makefile.in
765 --- a/ndb/include/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
766 +++ b/ndb/include/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
767 @@ -179,6 +179,7 @@
768  LIBDL = @LIBDL@
769  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
770  LIBOBJS = @LIBOBJS@
771 +LIBRT = @LIBRT@
772  LIBS = @LIBS@
773  LIBTOOL = @LIBTOOL@
774  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
775 diff -r 1ac0113deff5 ndb/src/Makefile.in
776 --- a/ndb/src/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
777 +++ b/ndb/src/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
778 @@ -204,6 +204,7 @@
779  LIBDL = @LIBDL@
780  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
781  LIBOBJS = @LIBOBJS@
782 +LIBRT = @LIBRT@
783  LIBS = @LIBS@
784  LIBTOOL = @LIBTOOL@
785  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
786 diff -r 1ac0113deff5 ndb/src/common/Makefile.in
787 --- a/ndb/src/common/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
788 +++ b/ndb/src/common/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
789 @@ -174,6 +174,7 @@
790  LIBDL = @LIBDL@
791  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
792  LIBOBJS = @LIBOBJS@
793 +LIBRT = @LIBRT@
794  LIBS = @LIBS@
795  LIBTOOL = @LIBTOOL@
796  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
797 diff -r 1ac0113deff5 ndb/src/common/debugger/Makefile.in
798 --- a/ndb/src/common/debugger/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
799 +++ b/ndb/src/common/debugger/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
800 @@ -206,6 +206,7 @@
801  LIBDL = @LIBDL@
802  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
803  LIBOBJS = @LIBOBJS@
804 +LIBRT = @LIBRT@
805  LIBS = @LIBS@
806  LIBTOOL = @LIBTOOL@
807  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
808 diff -r 1ac0113deff5 ndb/src/common/debugger/signaldata/Makefile.in
809 --- a/ndb/src/common/debugger/signaldata/Makefile.in    Mon Jun 01 00:35:44 2009 -0700
810 +++ b/ndb/src/common/debugger/signaldata/Makefile.in    Mon Jun 01 00:36:01 2009 -0700
811 @@ -211,6 +211,7 @@
812  LIBDL = @LIBDL@
813  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
814  LIBOBJS = @LIBOBJS@
815 +LIBRT = @LIBRT@
816  LIBS = @LIBS@
817  LIBTOOL = @LIBTOOL@
818  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
819 diff -r 1ac0113deff5 ndb/src/common/logger/Makefile.in
820 --- a/ndb/src/common/logger/Makefile.in Mon Jun 01 00:35:44 2009 -0700
821 +++ b/ndb/src/common/logger/Makefile.in Mon Jun 01 00:36:01 2009 -0700
822 @@ -197,6 +197,7 @@
823  LIBDL = @LIBDL@
824  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
825  LIBOBJS = @LIBOBJS@
826 +LIBRT = @LIBRT@
827  LIBS = @LIBS@
828  LIBTOOL = @LIBTOOL@
829  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
830 diff -r 1ac0113deff5 ndb/src/common/mgmcommon/Makefile.in
831 --- a/ndb/src/common/mgmcommon/Makefile.in      Mon Jun 01 00:35:44 2009 -0700
832 +++ b/ndb/src/common/mgmcommon/Makefile.in      Mon Jun 01 00:36:01 2009 -0700
833 @@ -211,6 +211,7 @@
834  LIBDL = @LIBDL@
835  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
836  LIBOBJS = @LIBOBJS@
837 +LIBRT = @LIBRT@
838  LIBS = @LIBS@
839  LIBTOOL = @LIBTOOL@
840  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
841 diff -r 1ac0113deff5 ndb/src/common/portlib/Makefile.in
842 --- a/ndb/src/common/portlib/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
843 +++ b/ndb/src/common/portlib/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
844 @@ -222,6 +222,7 @@
845  LIBDL = @LIBDL@
846  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
847  LIBOBJS = @LIBOBJS@
848 +LIBRT = @LIBRT@
849  LIBS = @LIBS@
850  LIBTOOL = @LIBTOOL@
851  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
852 diff -r 1ac0113deff5 ndb/src/common/transporter/Makefile.in
853 --- a/ndb/src/common/transporter/Makefile.in    Mon Jun 01 00:35:44 2009 -0700
854 +++ b/ndb/src/common/transporter/Makefile.in    Mon Jun 01 00:36:01 2009 -0700
855 @@ -197,6 +197,7 @@
856  LIBDL = @LIBDL@
857  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
858  LIBOBJS = @LIBOBJS@
859 +LIBRT = @LIBRT@
860  LIBS = @LIBS@
861  LIBTOOL = @LIBTOOL@
862  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
863 diff -r 1ac0113deff5 ndb/src/common/util/Makefile.in
864 --- a/ndb/src/common/util/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
865 +++ b/ndb/src/common/util/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
866 @@ -217,6 +217,7 @@
867  LIBDL = @LIBDL@
868  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
869  LIBOBJS = @LIBOBJS@
870 +LIBRT = @LIBRT@
871  LIBS = @LIBS@
872  LIBTOOL = @LIBTOOL@
873  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
874 diff -r 1ac0113deff5 ndb/src/cw/Makefile.in
875 --- a/ndb/src/cw/Makefile.in    Mon Jun 01 00:35:44 2009 -0700
876 +++ b/ndb/src/cw/Makefile.in    Mon Jun 01 00:36:01 2009 -0700
877 @@ -156,6 +156,7 @@
878  LIBDL = @LIBDL@
879  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
880  LIBOBJS = @LIBOBJS@
881 +LIBRT = @LIBRT@
882  LIBS = @LIBS@
883  LIBTOOL = @LIBTOOL@
884  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
885 diff -r 1ac0113deff5 ndb/src/cw/cpcd/Makefile.in
886 --- a/ndb/src/cw/cpcd/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
887 +++ b/ndb/src/cw/cpcd/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
888 @@ -207,6 +207,7 @@
889  LIBDL = @LIBDL@
890  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
891  LIBOBJS = @LIBOBJS@
892 +LIBRT = @LIBRT@
893  LIBS = @LIBS@
894  LIBTOOL = @LIBTOOL@
895  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
896 diff -r 1ac0113deff5 ndb/src/kernel/Makefile.in
897 --- a/ndb/src/kernel/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
898 +++ b/ndb/src/kernel/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
899 @@ -227,6 +227,7 @@
900  LIBDL = @LIBDL@
901  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
902  LIBOBJS = @LIBOBJS@
903 +LIBRT = @LIBRT@
904  LIBS = @LIBS@
905  LIBTOOL = @LIBTOOL@
906  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
907 diff -r 1ac0113deff5 ndb/src/kernel/blocks/Makefile.in
908 --- a/ndb/src/kernel/blocks/Makefile.in Mon Jun 01 00:35:44 2009 -0700
909 +++ b/ndb/src/kernel/blocks/Makefile.in Mon Jun 01 00:36:01 2009 -0700
910 @@ -156,6 +156,7 @@
911  LIBDL = @LIBDL@
912  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
913  LIBOBJS = @LIBOBJS@
914 +LIBRT = @LIBRT@
915  LIBS = @LIBS@
916  LIBTOOL = @LIBTOOL@
917  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
918 diff -r 1ac0113deff5 ndb/src/kernel/blocks/backup/Makefile.in
919 --- a/ndb/src/kernel/blocks/backup/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
920 +++ b/ndb/src/kernel/blocks/backup/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
921 @@ -196,6 +196,7 @@
922  LIBDL = @LIBDL@
923  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
924  LIBOBJS = @LIBOBJS@
925 +LIBRT = @LIBRT@
926  LIBS = @LIBS@
927  LIBTOOL = @LIBTOOL@
928  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
929 diff -r 1ac0113deff5 ndb/src/kernel/blocks/cmvmi/Makefile.in
930 --- a/ndb/src/kernel/blocks/cmvmi/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
931 +++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
932 @@ -196,6 +196,7 @@
933  LIBDL = @LIBDL@
934  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
935  LIBOBJS = @LIBOBJS@
936 +LIBRT = @LIBRT@
937  LIBS = @LIBS@
938  LIBTOOL = @LIBTOOL@
939  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
940 diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbacc/Makefile.in
941 --- a/ndb/src/kernel/blocks/dbacc/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
942 +++ b/ndb/src/kernel/blocks/dbacc/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
943 @@ -196,6 +196,7 @@
944  LIBDL = @LIBDL@
945  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
946  LIBOBJS = @LIBOBJS@
947 +LIBRT = @LIBRT@
948  LIBS = @LIBS@
949  LIBTOOL = @LIBTOOL@
950  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
951 diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbdict/Makefile.in
952 --- a/ndb/src/kernel/blocks/dbdict/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
953 +++ b/ndb/src/kernel/blocks/dbdict/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
954 @@ -206,6 +206,7 @@
955  LIBDL = @LIBDL@
956  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
957  LIBOBJS = @LIBOBJS@
958 +LIBRT = @LIBRT@
959  LIBS = @LIBS@
960  LIBTOOL = @LIBTOOL@
961  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
962 diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbdih/Makefile.in
963 --- a/ndb/src/kernel/blocks/dbdih/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
964 +++ b/ndb/src/kernel/blocks/dbdih/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
965 @@ -203,6 +203,7 @@
966  LIBDL = @LIBDL@
967  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
968  LIBOBJS = @LIBOBJS@
969 +LIBRT = @LIBRT@
970  LIBS = @LIBS@
971  LIBTOOL = @LIBTOOL@
972  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
973 diff -r 1ac0113deff5 ndb/src/kernel/blocks/dblqh/Makefile.in
974 --- a/ndb/src/kernel/blocks/dblqh/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
975 +++ b/ndb/src/kernel/blocks/dblqh/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
976 @@ -204,6 +204,7 @@
977  LIBDL = @LIBDL@
978  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
979  LIBOBJS = @LIBOBJS@
980 +LIBRT = @LIBRT@
981  LIBS = @LIBS@
982  LIBTOOL = @LIBTOOL@
983  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
984 diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbtc/Makefile.in
985 --- a/ndb/src/kernel/blocks/dbtc/Makefile.in    Mon Jun 01 00:35:44 2009 -0700
986 +++ b/ndb/src/kernel/blocks/dbtc/Makefile.in    Mon Jun 01 00:36:01 2009 -0700
987 @@ -196,6 +196,7 @@
988  LIBDL = @LIBDL@
989  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
990  LIBOBJS = @LIBOBJS@
991 +LIBRT = @LIBRT@
992  LIBS = @LIBS@
993  LIBTOOL = @LIBTOOL@
994  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
995 diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbtup/Makefile.in
996 --- a/ndb/src/kernel/blocks/dbtup/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
997 +++ b/ndb/src/kernel/blocks/dbtup/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
998 @@ -204,6 +204,7 @@
999  LIBDL = @LIBDL@
1000  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1001  LIBOBJS = @LIBOBJS@
1002 +LIBRT = @LIBRT@
1003  LIBS = @LIBS@
1004  LIBTOOL = @LIBTOOL@
1005  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1006 diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbtux/Makefile.in
1007 --- a/ndb/src/kernel/blocks/dbtux/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
1008 +++ b/ndb/src/kernel/blocks/dbtux/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
1009 @@ -199,6 +199,7 @@
1010  LIBDL = @LIBDL@
1011  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1012  LIBOBJS = @LIBOBJS@
1013 +LIBRT = @LIBRT@
1014  LIBS = @LIBS@
1015  LIBTOOL = @LIBTOOL@
1016  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1017 diff -r 1ac0113deff5 ndb/src/kernel/blocks/dbutil/Makefile.in
1018 --- a/ndb/src/kernel/blocks/dbutil/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
1019 +++ b/ndb/src/kernel/blocks/dbutil/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
1020 @@ -196,6 +196,7 @@
1021  LIBDL = @LIBDL@
1022  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1023  LIBOBJS = @LIBOBJS@
1024 +LIBRT = @LIBRT@
1025  LIBS = @LIBS@
1026  LIBTOOL = @LIBTOOL@
1027  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1028 diff -r 1ac0113deff5 ndb/src/kernel/blocks/ndbcntr/Makefile.in
1029 --- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Mon Jun 01 00:35:44 2009 -0700
1030 +++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Mon Jun 01 00:36:01 2009 -0700
1031 @@ -197,6 +197,7 @@
1032  LIBDL = @LIBDL@
1033  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1034  LIBOBJS = @LIBOBJS@
1035 +LIBRT = @LIBRT@
1036  LIBS = @LIBS@
1037  LIBTOOL = @LIBTOOL@
1038  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1039 diff -r 1ac0113deff5 ndb/src/kernel/blocks/ndbfs/Makefile.in
1040 --- a/ndb/src/kernel/blocks/ndbfs/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
1041 +++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
1042 @@ -197,6 +197,7 @@
1043  LIBDL = @LIBDL@
1044  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1045  LIBOBJS = @LIBOBJS@
1046 +LIBRT = @LIBRT@
1047  LIBS = @LIBS@
1048  LIBTOOL = @LIBTOOL@
1049  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1050 diff -r 1ac0113deff5 ndb/src/kernel/blocks/qmgr/Makefile.in
1051 --- a/ndb/src/kernel/blocks/qmgr/Makefile.in    Mon Jun 01 00:35:44 2009 -0700
1052 +++ b/ndb/src/kernel/blocks/qmgr/Makefile.in    Mon Jun 01 00:36:01 2009 -0700
1053 @@ -196,6 +196,7 @@
1054  LIBDL = @LIBDL@
1055  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1056  LIBOBJS = @LIBOBJS@
1057 +LIBRT = @LIBRT@
1058  LIBS = @LIBS@
1059  LIBTOOL = @LIBTOOL@
1060  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1061 diff -r 1ac0113deff5 ndb/src/kernel/blocks/suma/Makefile.in
1062 --- a/ndb/src/kernel/blocks/suma/Makefile.in    Mon Jun 01 00:35:44 2009 -0700
1063 +++ b/ndb/src/kernel/blocks/suma/Makefile.in    Mon Jun 01 00:36:01 2009 -0700
1064 @@ -196,6 +196,7 @@
1065  LIBDL = @LIBDL@
1066  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1067  LIBOBJS = @LIBOBJS@
1068 +LIBRT = @LIBRT@
1069  LIBS = @LIBS@
1070  LIBTOOL = @LIBTOOL@
1071  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1072 diff -r 1ac0113deff5 ndb/src/kernel/blocks/trix/Makefile.in
1073 --- a/ndb/src/kernel/blocks/trix/Makefile.in    Mon Jun 01 00:35:44 2009 -0700
1074 +++ b/ndb/src/kernel/blocks/trix/Makefile.in    Mon Jun 01 00:36:01 2009 -0700
1075 @@ -196,6 +196,7 @@
1076  LIBDL = @LIBDL@
1077  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1078  LIBOBJS = @LIBOBJS@
1079 +LIBRT = @LIBRT@
1080  LIBS = @LIBS@
1081  LIBTOOL = @LIBTOOL@
1082  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1083 diff -r 1ac0113deff5 ndb/src/kernel/error/Makefile.in
1084 --- a/ndb/src/kernel/error/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
1085 +++ b/ndb/src/kernel/error/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
1086 @@ -206,6 +206,7 @@
1087  LIBDL = @LIBDL@
1088  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1089  LIBOBJS = @LIBOBJS@
1090 +LIBRT = @LIBRT@
1091  LIBS = @LIBS@
1092  LIBTOOL = @LIBTOOL@
1093  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1094 diff -r 1ac0113deff5 ndb/src/kernel/vm/Makefile.in
1095 --- a/ndb/src/kernel/vm/Makefile.in     Mon Jun 01 00:35:44 2009 -0700
1096 +++ b/ndb/src/kernel/vm/Makefile.in     Mon Jun 01 00:36:01 2009 -0700
1097 @@ -207,6 +207,7 @@
1098  LIBDL = @LIBDL@
1099  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1100  LIBOBJS = @LIBOBJS@
1101 +LIBRT = @LIBRT@
1102  LIBS = @LIBS@
1103  LIBTOOL = @LIBTOOL@
1104  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1105 diff -r 1ac0113deff5 ndb/src/mgmapi/Makefile.in
1106 --- a/ndb/src/mgmapi/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
1107 +++ b/ndb/src/mgmapi/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
1108 @@ -205,6 +205,7 @@
1109  LIBDL = @LIBDL@
1110  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1111  LIBOBJS = @LIBOBJS@
1112 +LIBRT = @LIBRT@
1113  LIBS = @LIBS@
1114  LIBTOOL = @LIBTOOL@
1115  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1116 diff -r 1ac0113deff5 ndb/src/mgmclient/Makefile.in
1117 --- a/ndb/src/mgmclient/Makefile.in     Mon Jun 01 00:35:44 2009 -0700
1118 +++ b/ndb/src/mgmclient/Makefile.in     Mon Jun 01 00:36:01 2009 -0700
1119 @@ -216,6 +216,7 @@
1120  LIBDL = @LIBDL@
1121  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1122  LIBOBJS = @LIBOBJS@
1123 +LIBRT = @LIBRT@
1124  LIBS = @LIBS@
1125  LIBTOOL = @LIBTOOL@
1126  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1127 diff -r 1ac0113deff5 ndb/src/mgmsrv/Makefile.in
1128 --- a/ndb/src/mgmsrv/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
1129 +++ b/ndb/src/mgmsrv/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
1130 @@ -213,6 +213,7 @@
1131  LIBDL = @LIBDL@
1132  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1133  LIBOBJS = @LIBOBJS@
1134 +LIBRT = @LIBRT@
1135  LIBS = @LIBS@
1136  LIBTOOL = @LIBTOOL@
1137  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1138 diff -r 1ac0113deff5 ndb/src/ndbapi/Makefile.in
1139 --- a/ndb/src/ndbapi/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
1140 +++ b/ndb/src/ndbapi/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
1141 @@ -215,6 +215,7 @@
1142  LIBDL = @LIBDL@
1143  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1144  LIBOBJS = @LIBOBJS@
1145 +LIBRT = @LIBRT@
1146  LIBS = @LIBS@
1147  LIBTOOL = @LIBTOOL@
1148  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1149 diff -r 1ac0113deff5 ndb/test/Makefile.in
1150 --- a/ndb/test/Makefile.in      Mon Jun 01 00:35:44 2009 -0700
1151 +++ b/ndb/test/Makefile.in      Mon Jun 01 00:36:01 2009 -0700
1152 @@ -156,6 +156,7 @@
1153  LIBDL = @LIBDL@
1154  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1155  LIBOBJS = @LIBOBJS@
1156 +LIBRT = @LIBRT@
1157  LIBS = @LIBS@
1158  LIBTOOL = @LIBTOOL@
1159  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1160 diff -r 1ac0113deff5 ndb/test/ndbapi/Makefile.in
1161 --- a/ndb/test/ndbapi/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
1162 +++ b/ndb/test/ndbapi/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
1163 @@ -595,6 +595,7 @@
1164  LIBDL = @LIBDL@
1165  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1166  LIBOBJS = @LIBOBJS@
1167 +LIBRT = @LIBRT@
1168  LIBS = @LIBS@
1169  LIBTOOL = @LIBTOOL@
1170  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1171 diff -r 1ac0113deff5 ndb/test/ndbapi/bank/Makefile.in
1172 --- a/ndb/test/ndbapi/bank/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
1173 +++ b/ndb/test/ndbapi/bank/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
1174 @@ -282,6 +282,7 @@
1175  LIBDL = @LIBDL@
1176  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1177  LIBOBJS = @LIBOBJS@
1178 +LIBRT = @LIBRT@
1179  LIBS = @LIBS@
1180  LIBTOOL = @LIBTOOL@
1181  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1182 diff -r 1ac0113deff5 ndb/test/run-test/Makefile.in
1183 --- a/ndb/test/run-test/Makefile.in     Mon Jun 01 00:35:44 2009 -0700
1184 +++ b/ndb/test/run-test/Makefile.in     Mon Jun 01 00:36:01 2009 -0700
1185 @@ -243,6 +243,7 @@
1186  LIBDL = @LIBDL@
1187  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1188  LIBOBJS = @LIBOBJS@
1189 +LIBRT = @LIBRT@
1190  LIBS = @LIBS@
1191  LIBTOOL = @LIBTOOL@
1192  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1193 diff -r 1ac0113deff5 ndb/test/src/Makefile.in
1194 --- a/ndb/test/src/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
1195 +++ b/ndb/test/src/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
1196 @@ -213,6 +213,7 @@
1197  LIBDL = @LIBDL@
1198  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1199  LIBOBJS = @LIBOBJS@
1200 +LIBRT = @LIBRT@
1201  LIBS = @LIBS@
1202  LIBTOOL = @LIBTOOL@
1203  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1204 diff -r 1ac0113deff5 ndb/test/tools/Makefile.in
1205 --- a/ndb/test/tools/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
1206 +++ b/ndb/test/tools/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
1207 @@ -325,6 +325,7 @@
1208  LIBDL = @LIBDL@
1209  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1210  LIBOBJS = @LIBOBJS@
1211 +LIBRT = @LIBRT@
1212  LIBS = @LIBS@
1213  LIBTOOL = @LIBTOOL@
1214  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1215 diff -r 1ac0113deff5 ndb/tools/Makefile.in
1216 --- a/ndb/tools/Makefile.in     Mon Jun 01 00:35:44 2009 -0700
1217 +++ b/ndb/tools/Makefile.in     Mon Jun 01 00:36:01 2009 -0700
1218 @@ -344,6 +344,7 @@
1219  LIBDL = @LIBDL@
1220  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1221  LIBOBJS = @LIBOBJS@
1222 +LIBRT = @LIBRT@
1223  LIBS = @LIBS@
1224  LIBTOOL = @LIBTOOL@
1225  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1226 diff -r 1ac0113deff5 netware/Makefile.in
1227 --- a/netware/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
1228 +++ b/netware/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
1229 @@ -199,6 +199,7 @@
1230  LIBDL = @LIBDL@
1231  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1232  LIBOBJS = @LIBOBJS@
1233 +LIBRT = @LIBRT@
1234  LIBS = @LIBS@
1235  LIBTOOL = @LIBTOOL@
1236  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1237 diff -r 1ac0113deff5 os2/Makefile.in
1238 --- a/os2/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
1239 +++ b/os2/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
1240 @@ -156,6 +156,7 @@
1241  LIBDL = @LIBDL@
1242  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1243  LIBOBJS = @LIBOBJS@
1244 +LIBRT = @LIBRT@
1245  LIBS = @LIBS@
1246  LIBTOOL = @LIBTOOL@
1247  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1248 diff -r 1ac0113deff5 os2/include/Makefile.in
1249 --- a/os2/include/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
1250 +++ b/os2/include/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
1251 @@ -156,6 +156,7 @@
1252  LIBDL = @LIBDL@
1253  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1254  LIBOBJS = @LIBOBJS@
1255 +LIBRT = @LIBRT@
1256  LIBS = @LIBS@
1257  LIBTOOL = @LIBTOOL@
1258  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1259 diff -r 1ac0113deff5 os2/include/sys/Makefile.in
1260 --- a/os2/include/sys/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
1261 +++ b/os2/include/sys/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
1262 @@ -144,6 +144,7 @@
1263  LIBDL = @LIBDL@
1264  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1265  LIBOBJS = @LIBOBJS@
1266 +LIBRT = @LIBRT@
1267  LIBS = @LIBS@
1268  LIBTOOL = @LIBTOOL@
1269  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1270 diff -r 1ac0113deff5 patch_info/userstats.info
1271 --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
1272 +++ b/patch_info/userstats.info Mon Jun 01 00:36:01 2009 -0700
1273 @@ -0,0 +1,14 @@
1274 +File=userstatsv2.patch
1275 +Name=SHOW USER/TABLE/INDEX statistics
1276 +Version=V2
1277 +Author=Google
1278 +License=GPL
1279 +Comment=Added INFORMATION_SCHEMA.*_STATISTICS
1280 +2008-12-01
1281 +YK: fix behavior for prepared statements
1282 +
1283 +2008-11-26
1284 +YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
1285 +
1286 +2008-12-09
1287 +YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
1288 diff -r 1ac0113deff5 pstack/Makefile.in
1289 --- a/pstack/Makefile.in        Mon Jun 01 00:35:44 2009 -0700
1290 +++ b/pstack/Makefile.in        Mon Jun 01 00:36:01 2009 -0700
1291 @@ -196,6 +196,7 @@
1292  LIBDL = @LIBDL@
1293  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1294  LIBOBJS = @LIBOBJS@
1295 +LIBRT = @LIBRT@
1296  LIBS = @LIBS@
1297  LIBTOOL = @LIBTOOL@
1298  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1299 diff -r 1ac0113deff5 pstack/aout/Makefile.in
1300 --- a/pstack/aout/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
1301 +++ b/pstack/aout/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
1302 @@ -134,6 +134,7 @@
1303  LIBDL = @LIBDL@
1304  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1305  LIBOBJS = @LIBOBJS@
1306 +LIBRT = @LIBRT@
1307  LIBS = @LIBS@
1308  LIBTOOL = @LIBTOOL@
1309  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1310 diff -r 1ac0113deff5 regex/Makefile.in
1311 --- a/regex/Makefile.in Mon Jun 01 00:35:44 2009 -0700
1312 +++ b/regex/Makefile.in Mon Jun 01 00:36:01 2009 -0700
1313 @@ -180,6 +180,7 @@
1314  LIBDL = @LIBDL@
1315  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1316  LIBOBJS = @LIBOBJS@
1317 +LIBRT = @LIBRT@
1318  LIBS = @LIBS@
1319  LIBTOOL = @LIBTOOL@
1320  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1321 diff -r 1ac0113deff5 scripts/Makefile.in
1322 --- a/scripts/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
1323 +++ b/scripts/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
1324 @@ -176,6 +176,7 @@
1325  LIBDL = @LIBDL@
1326  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1327  LIBOBJS = @LIBOBJS@
1328 +LIBRT = @LIBRT@
1329  LIBS = @LIBS@
1330  LIBTOOL = @LIBTOOL@
1331  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1332 diff -r 1ac0113deff5 server-tools/Makefile.in
1333 --- a/server-tools/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
1334 +++ b/server-tools/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
1335 @@ -155,6 +155,7 @@
1336  LIBDL = @LIBDL@
1337  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1338  LIBOBJS = @LIBOBJS@
1339 +LIBRT = @LIBRT@
1340  LIBS = @LIBS@
1341  LIBTOOL = @LIBTOOL@
1342  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1343 diff -r 1ac0113deff5 server-tools/instance-manager/Makefile.in
1344 --- a/server-tools/instance-manager/Makefile.in Mon Jun 01 00:35:44 2009 -0700
1345 +++ b/server-tools/instance-manager/Makefile.in Mon Jun 01 00:36:01 2009 -0700
1346 @@ -205,6 +205,7 @@
1347  LIBDL = @LIBDL@
1348  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1349  LIBOBJS = @LIBOBJS@
1350 +LIBRT = @LIBRT@
1351  LIBS = @LIBS@
1352  LIBTOOL = @LIBTOOL@
1353  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1354 diff -r 1ac0113deff5 sql/Makefile.in
1355 --- a/sql/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
1356 +++ b/sql/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
1357 @@ -274,6 +274,7 @@
1358  LIBDL = @LIBDL@
1359  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1360  LIBOBJS = @LIBOBJS@
1361 +LIBRT = @LIBRT@
1362  LIBS = @LIBS@
1363  LIBTOOL = @LIBTOOL@
1364  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1365 diff -r 1ac0113deff5 sql/ha_innodb.cc
1366 --- a/sql/ha_innodb.cc  Mon Jun 01 00:35:44 2009 -0700
1367 +++ b/sql/ha_innodb.cc  Mon Jun 01 00:36:01 2009 -0700
1368 @@ -3338,6 +3338,8 @@
1369  
1370         error = row_insert_for_mysql((byte*) record, prebuilt);
1371  
1372 +        if (error == DB_SUCCESS) rows_changed++;
1373 +
1374         if (error == DB_SUCCESS && auto_inc_used) {
1375  
1376                 /* Fetch the value that was set in the autoincrement field */
1377 @@ -3610,6 +3612,8 @@
1378                 }
1379         }
1380  
1381 +       if (error == DB_SUCCESS) rows_changed++;
1382 +
1383         innodb_srv_conc_exit_innodb(prebuilt->trx);
1384  
1385         error = convert_error_code_to_mysql(error, user_thd);
1386 @@ -3658,6 +3662,8 @@
1387  
1388         error = row_update_for_mysql((byte*) record, prebuilt);
1389  
1390 +       if (error == DB_SUCCESS) rows_changed++;
1391 +
1392         innodb_srv_conc_exit_innodb(prebuilt->trx);
1393  
1394         error = convert_error_code_to_mysql(error, user_thd);
1395 @@ -4089,6 +4095,9 @@
1396         if (ret == DB_SUCCESS) {
1397                 error = 0;
1398                 table->status = 0;
1399 +                rows_read++;
1400 +                if (active_index >= 0 && active_index < MAX_KEY)
1401 +                        index_rows_read[active_index]++;
1402  
1403         } else if (ret == DB_RECORD_NOT_FOUND) {
1404                 error = HA_ERR_END_OF_FILE;
1405 diff -r 1ac0113deff5 sql/ha_myisam.cc
1406 --- a/sql/ha_myisam.cc  Mon Jun 01 00:35:44 2009 -0700
1407 +++ b/sql/ha_myisam.cc  Mon Jun 01 00:36:01 2009 -0700
1408 @@ -670,7 +670,9 @@
1409      if ((error= update_auto_increment()))
1410        return error;
1411    }
1412 -  return mi_write(file,buf);
1413 +  int error=mi_write(file,buf);
1414 +  if (!error) rows_changed++;
1415 +  return error;
1416  }
1417  
1418  int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
1419 @@ -1518,13 +1520,17 @@
1420    statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
1421    if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
1422      table->timestamp_field->set_time();
1423 -  return mi_update(file,old_data,new_data);
1424 +  int error=mi_update(file,old_data,new_data);
1425 +  if (!error) rows_changed++;
1426 +  return error;
1427  }
1428  
1429  int ha_myisam::delete_row(const byte * buf)
1430  {
1431    statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
1432 -  return mi_delete(file,buf);
1433 +  int error=mi_delete(file,buf);
1434 +  if (!error) rows_changed++;
1435 +  return error;
1436  }
1437  
1438  int ha_myisam::index_read(byte * buf, const byte * key,
1439 @@ -1535,6 +1541,13 @@
1440                       &LOCK_status);
1441    int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
1442    table->status=error ? STATUS_NOT_FOUND: 0;
1443 +  if (!error) {
1444 +    rows_read++;
1445 +
1446 +    int inx = (active_index == -1) ? file->lastinx : active_index;
1447 +    if (inx >= 0 && inx < MAX_KEY)
1448 +      index_rows_read[inx]++;
1449 +  }
1450    return error;
1451  }
1452  
1453 @@ -1545,6 +1558,13 @@
1454                       &LOCK_status);
1455    int error=mi_rkey(file,buf,index, key, key_len, find_flag);
1456    table->status=error ? STATUS_NOT_FOUND: 0;
1457 +  if (!error) {
1458 +    rows_read++;
1459 +
1460 +    int inx = index;
1461 +    if (inx >= 0 && inx < MAX_KEY)
1462 +      index_rows_read[inx]++;
1463 +  }
1464    return error;
1465  }
1466  
1467 @@ -1555,6 +1575,13 @@
1468                       &LOCK_status);
1469    int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
1470    table->status=error ? STATUS_NOT_FOUND: 0;
1471 +  if (!error) {
1472 +    rows_read++;
1473 +
1474 +    int inx = (active_index == -1) ? file->lastinx : active_index;
1475 +    if (inx >= 0 && inx < MAX_KEY)
1476 +      index_rows_read[inx]++;
1477 +  }
1478    return error;
1479  }
1480  
1481 @@ -1565,6 +1592,13 @@
1482                       &LOCK_status);
1483    int error=mi_rnext(file,buf,active_index);
1484    table->status=error ? STATUS_NOT_FOUND: 0;
1485 +  if (!error) {
1486 +    rows_read++;
1487 +
1488 +    int inx = (active_index == -1) ? file->lastinx : active_index;
1489 +    if (inx >= 0 && inx < MAX_KEY)
1490 +      index_rows_read[inx]++;
1491 +  }
1492    return error;
1493  }
1494  
1495 @@ -1575,6 +1609,13 @@
1496                       &LOCK_status);
1497    int error=mi_rprev(file,buf, active_index);
1498    table->status=error ? STATUS_NOT_FOUND: 0;
1499 +  if (!error) {
1500 +    rows_read++;
1501 +
1502 +    int inx = (active_index == -1) ? file->lastinx : active_index;
1503 +    if (inx >= 0 && inx < MAX_KEY)
1504 +      index_rows_read[inx]++;
1505 +  }
1506    return error;
1507  }
1508  
1509 @@ -1585,6 +1626,13 @@
1510                       &LOCK_status);
1511    int error=mi_rfirst(file, buf, active_index);
1512    table->status=error ? STATUS_NOT_FOUND: 0;
1513 +  if (!error) {
1514 +    rows_read++;
1515 +
1516 +    int inx = (active_index == -1) ? file->lastinx : active_index;
1517 +    if (inx >= 0 && inx < MAX_KEY)
1518 +      index_rows_read[inx]++;
1519 +  }
1520    return error;
1521  }
1522  
1523 @@ -1595,6 +1643,13 @@
1524                       &LOCK_status);
1525    int error=mi_rlast(file, buf, active_index);
1526    table->status=error ? STATUS_NOT_FOUND: 0;
1527 +  if (!error) {
1528 +    rows_read++;
1529 +
1530 +    int inx = (active_index == -1) ? file->lastinx : active_index;
1531 +    if (inx >= 0 && inx < MAX_KEY)
1532 +      index_rows_read[inx]++;
1533 +  }
1534    return error;
1535  }
1536  
1537 @@ -1611,6 +1666,13 @@
1538      error= mi_rnext_same(file,buf);
1539    } while (error == HA_ERR_RECORD_DELETED);
1540    table->status=error ? STATUS_NOT_FOUND: 0;
1541 +  if (!error) {
1542 +    rows_read++;
1543 +
1544 +    int inx = (active_index == -1) ? file->lastinx : active_index;
1545 +    if (inx >= 0 && inx < MAX_KEY)
1546 +      index_rows_read[inx]++;
1547 +  }
1548    return error;
1549  }
1550  
1551 @@ -1628,6 +1690,7 @@
1552                       &LOCK_status);
1553    int error=mi_scan(file, buf);
1554    table->status=error ? STATUS_NOT_FOUND: 0;
1555 +  if (!error) rows_read++;
1556    return error;
1557  }
1558  
1559 @@ -1642,6 +1705,7 @@
1560                       &LOCK_status);
1561    int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
1562    table->status=error ? STATUS_NOT_FOUND: 0;
1563 +  if (!error) rows_read++;
1564    return error;
1565  }
1566  
1567 diff -r 1ac0113deff5 sql/handler.cc
1568 --- a/sql/handler.cc    Mon Jun 01 00:35:44 2009 -0700
1569 +++ b/sql/handler.cc    Mon Jun 01 00:36:01 2009 -0700
1570 @@ -726,6 +726,8 @@
1571      if (cookie)
1572        tc_log->unlog(cookie, xid);
1573      DBUG_EXECUTE_IF("crash_commit_after", abort(););
1574 +    if (is_real_trans)
1575 +      thd->diff_commit_trans++;
1576  end:
1577      if (is_real_trans)
1578        start_waiting_global_read_lock(thd);
1579 @@ -783,6 +785,7 @@
1580        thd->transaction.cleanup();
1581      }
1582    }
1583 +  thd->diff_rollback_trans++;
1584  #endif /* USING_TRANSACTIONS */
1585    DBUG_RETURN(error);
1586  }
1587 @@ -1223,6 +1226,7 @@
1588      statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
1589      *ht=0; // keep it conveniently zero-filled
1590    }
1591 +  thd->diff_rollback_trans++;
1592    DBUG_RETURN(error);
1593  }
1594  
1595 @@ -1453,6 +1457,8 @@
1596      else
1597        dupp_ref=ref+ALIGN_SIZE(ref_length);
1598    }
1599 +  rows_read = rows_changed = 0;
1600 +  memset(index_rows_read, 0, sizeof(index_rows_read));
1601    DBUG_RETURN(error);
1602  }
1603  
1604 @@ -2287,6 +2293,111 @@
1605    return error;
1606  }
1607  
1608 +// Updates the global table stats with the TABLE this handler represents.
1609 +void handler::update_global_table_stats() {
1610 +  if (!opt_userstat_running) {
1611 +    rows_read = rows_changed = 0;
1612 +    return;
1613 +  }
1614 +
1615 +  if (!rows_read && !rows_changed) return;  // Nothing to update.
1616 +  // table_cache_key is db_name + '\0' + table_name + '\0'.
1617 +  if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
1618 +
1619 +  TABLE_STATS* table_stats;
1620 +  char key[NAME_LEN * 2 + 2];
1621 +  // [db] + '.' + [table]
1622 +  sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
1623 +
1624 +  pthread_mutex_lock(&LOCK_global_table_stats);
1625 +  // Gets the global table stats, creating one if necessary.
1626 +  if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
1627 +                                                (byte*)key,
1628 +                                                strlen(key)))) {
1629 +    if (!(table_stats = ((TABLE_STATS*)
1630 +                         my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
1631 +      // Out of memory.
1632 +      sql_print_error("Allocating table stats failed.");
1633 +      goto end;
1634 +    }
1635 +    strncpy(table_stats->table, key, sizeof(table_stats->table));
1636 +    table_stats->rows_read = 0;
1637 +    table_stats->rows_changed = 0;
1638 +    table_stats->rows_changed_x_indexes = 0;
1639 +    table_stats->engine_type = (int) ht->db_type;
1640 +
1641 +    if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
1642 +      // Out of memory.
1643 +      sql_print_error("Inserting table stats failed.");
1644 +      my_free((char*)table_stats, 0);
1645 +      goto end;
1646 +    }
1647 +  }
1648 +  // Updates the global table stats.
1649 +  table_stats->rows_read += rows_read;
1650 +  table_stats->rows_changed += rows_changed;
1651 +  table_stats->rows_changed_x_indexes +=
1652 +      rows_changed * (table->s->keys ? table->s->keys : 1);
1653 +  current_thd->diff_total_read_rows += rows_read;
1654 +  rows_read = rows_changed = 0;
1655 +end:
1656 +  pthread_mutex_unlock(&LOCK_global_table_stats);
1657 +}
1658 +
1659 +// Updates the global index stats with this handler's accumulated index reads.
1660 +void handler::update_global_index_stats() {
1661 +  // table_cache_key is db_name + '\0' + table_name + '\0'.
1662 +  if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
1663 +
1664 +  if (!opt_userstat_running) {
1665 +    for (int x = 0; x < table->s->keys; x++) {
1666 +      index_rows_read[x] = 0;
1667 +    }
1668 +    return;
1669 +  }
1670 +
1671 +  for (int x = 0; x < table->s->keys; x++) {
1672 +    if (index_rows_read[x]) {
1673 +      // Rows were read using this index.
1674 +      KEY* key_info = &table->key_info[x];
1675 +
1676 +      if (!key_info->name) continue;
1677 +
1678 +      INDEX_STATS* index_stats;
1679 +      char key[NAME_LEN * 3 + 3];
1680 +      // [db] + '.' + [table] + '.' + [index]
1681 +      sprintf(key, "%s.%s.%s",  table->s->table_cache_key,
1682 +              table->s->table_name, key_info->name);
1683 +
1684 +      pthread_mutex_lock(&LOCK_global_index_stats);
1685 +      // Gets the global index stats, creating one if necessary.
1686 +      if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
1687 +                                                    (byte*)key,
1688 +                                                    strlen(key)))) {
1689 +        if (!(index_stats = ((INDEX_STATS*)
1690 +                             my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
1691 +          // Out of memory.
1692 +          sql_print_error("Allocating index stats failed.");
1693 +          goto end;
1694 +        }
1695 +        strncpy(index_stats->index, key, sizeof(index_stats->index));
1696 +        index_stats->rows_read = 0;
1697 +
1698 +        if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
1699 +          // Out of memory.
1700 +          sql_print_error("Inserting index stats failed.");
1701 +          my_free((char*)index_stats, 0);
1702 +          goto end;
1703 +        }
1704 +      }
1705 +      // Updates the global index stats.
1706 +      index_stats->rows_read += index_rows_read[x];
1707 +      index_rows_read[x] = 0;
1708 +end:
1709 +      pthread_mutex_unlock(&LOCK_global_index_stats);
1710 +    }
1711 +  }
1712 +}
1713  
1714  /****************************************************************************
1715  ** Some general functions that isn't in the handler class
1716 diff -r 1ac0113deff5 sql/handler.h
1717 --- a/sql/handler.h     Mon Jun 01 00:35:44 2009 -0700
1718 +++ b/sql/handler.h     Mon Jun 01 00:36:01 2009 -0700
1719 @@ -32,6 +32,10 @@
1720  #define USING_TRANSACTIONS
1721  #endif
1722  
1723 +#if MAX_KEY > 128
1724 +#error MAX_KEY is too large.  Values up to 128 are supported.
1725 +#endif
1726 +
1727  // the following is for checking tables
1728  
1729  #define HA_ADMIN_ALREADY_DONE    1
1730 @@ -604,6 +608,9 @@
1731    bool  auto_increment_column_changed;
1732    bool implicit_emptied;                /* Can be !=0 only if HEAP */
1733    const COND *pushed_cond;
1734 +  ulonglong rows_read;
1735 +  ulonglong rows_changed;
1736 +  ulonglong index_rows_read[MAX_KEY];
1737  
1738    handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
1739      ht(ht_arg),
1740 @@ -615,8 +622,10 @@
1741      ref_length(sizeof(my_off_t)), block_size(0),
1742      raid_type(0), ft_handler(0), inited(NONE),
1743      locked(FALSE), implicit_emptied(0),
1744 -    pushed_cond(NULL)
1745 -    {}
1746 +    pushed_cond(NULL), rows_read(0), rows_changed(0)
1747 +    {
1748 +      memset(index_rows_read, 0, sizeof(index_rows_read));
1749 +    }
1750    virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
1751    virtual handler *clone(MEM_ROOT *mem_root);
1752    int ha_open(const char *name, int mode, int test_if_locked);
1753 @@ -625,7 +634,11 @@
1754    virtual void print_error(int error, myf errflag);
1755    virtual bool get_error_message(int error, String *buf);
1756    uint get_dup_key(int error);
1757 -  void change_table_ptr(TABLE *table_arg) { table=table_arg; }
1758 +  void change_table_ptr(TABLE *table_arg) {
1759 +    table=table_arg;
1760 +    rows_read = rows_changed = 0;
1761 +    memset(index_rows_read, 0, sizeof(index_rows_read));
1762 +  }
1763    virtual double scan_time()
1764      { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
1765    virtual double read_time(uint index, uint ranges, ha_rows rows)
1766 @@ -886,6 +899,9 @@
1767    virtual bool is_crashed() const  { return 0; }
1768    virtual bool auto_repair() const { return 0; }
1769  
1770 +  void update_global_table_stats();
1771 +  void update_global_index_stats();
1772 +
1773    /*
1774      default rename_table() and delete_table() rename/delete files with a
1775      given name and extensions from bas_ext()
1776 diff -r 1ac0113deff5 sql/lex.h
1777 --- a/sql/lex.h Mon Jun 01 00:35:44 2009 -0700
1778 +++ b/sql/lex.h Mon Jun 01 00:36:01 2009 -0700
1779 @@ -109,6 +109,7 @@
1780    { "CHECKSUM",                SYM(CHECKSUM_SYM)},
1781    { "CIPHER",          SYM(CIPHER_SYM)},
1782    { "CLIENT",          SYM(CLIENT_SYM)},
1783 +  { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
1784    { "CLOSE",           SYM(CLOSE_SYM)},
1785    { "CODE",             SYM(CODE_SYM)},
1786    { "COLLATE",         SYM(COLLATE_SYM)},
1787 @@ -238,6 +239,7 @@
1788    { "IN",              SYM(IN_SYM)},
1789    { "INDEX",           SYM(INDEX_SYM)},
1790    { "INDEXES",         SYM(INDEXES)},
1791 +  { "INDEX_STATISTICS",        SYM(INDEX_STATS_SYM)},
1792    { "INFILE",          SYM(INFILE)},
1793    { "INNER",           SYM(INNER_SYM)},
1794    { "INNOBASE",                SYM(INNOBASE_SYM)},
1795 @@ -443,6 +445,7 @@
1796    { "SIGNED",          SYM(SIGNED_SYM)},
1797    { "SIMPLE",          SYM(SIMPLE_SYM)},
1798    { "SLAVE",            SYM(SLAVE)},
1799 +  { "SLOW",             SYM(SLOW_SYM)},
1800    { "SNAPSHOT",         SYM(SNAPSHOT_SYM)},
1801    { "SMALLINT",                SYM(SMALLINT)},
1802    { "SOME",             SYM(ANY_SYM)},
1803 @@ -488,6 +491,7 @@
1804    { "TABLE",           SYM(TABLE_SYM)},
1805    { "TABLES",          SYM(TABLES)},
1806    { "TABLESPACE",      SYM(TABLESPACE)},
1807 +  { "TABLE_STATISTICS",        SYM(TABLE_STATS_SYM)},
1808    { "TEMPORARY",       SYM(TEMPORARY)},
1809    { "TEMPTABLE",       SYM(TEMPTABLE_SYM)},
1810    { "TERMINATED",      SYM(TERMINATED)},
1811 @@ -525,6 +529,7 @@
1812    { "USE",             SYM(USE_SYM)},
1813    { "USER",            SYM(USER)},
1814    { "USER_RESOURCES",  SYM(RESOURCES)},
1815 +  { "USER_STATISTICS", SYM(USER_STATS_SYM)},
1816    { "USE_FRM",         SYM(USE_FRM)},
1817    { "USING",           SYM(USING)},
1818    { "UTC_DATE",         SYM(UTC_DATE_SYM)},
1819 diff -r 1ac0113deff5 sql/log.cc
1820 --- a/sql/log.cc        Mon Jun 01 00:35:44 2009 -0700
1821 +++ b/sql/log.cc        Mon Jun 01 00:36:01 2009 -0700
1822 @@ -1958,18 +1958,24 @@
1823                            thd->current_insert_id);
1824         if (e.write(file))
1825           goto err;
1826 +        if (file == &log_file)
1827 +          thd->binlog_bytes_written += e.data_written;
1828        }
1829        if (thd->insert_id_used)
1830        {
1831         Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
1832         if (e.write(file))
1833           goto err;
1834 +        if (file == &log_file)
1835 +          thd->binlog_bytes_written += e.data_written;
1836        }
1837        if (thd->rand_used)
1838        {
1839         Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
1840         if (e.write(file))
1841           goto err;
1842 +        if (file == &log_file)
1843 +          thd->binlog_bytes_written += e.data_written;
1844        }
1845        if (thd->user_var_events.elements)
1846        {
1847 @@ -1985,6 +1991,8 @@
1848                                user_var_event->charset_number);
1849           if (e.write(file))
1850             goto err;
1851 +         if (file == &log_file)
1852 +                 thd->binlog_bytes_written += e.data_written;
1853         }
1854        }
1855      }
1856 @@ -1995,6 +2003,8 @@
1857  
1858      if (event_info->write(file))
1859        goto err;
1860 +    if (file == &log_file)
1861 +           thd->binlog_bytes_written += event_info->data_written;
1862  
1863      if (file == &log_file) // we are writing to the real log (disk)
1864      {
1865 @@ -2117,6 +2127,7 @@
1866      */
1867      if (qinfo.write(&log_file))
1868        goto err;
1869 +    thd->binlog_bytes_written += qinfo.data_written;
1870  
1871      /* Read from the file used to cache the queries .*/
1872      if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
1873 @@ -2163,6 +2174,7 @@
1874          /* write the first half of the split header */
1875          if (my_b_write(&log_file, header, carry))
1876            goto err;
1877 +        thd->binlog_bytes_written += carry;
1878  
1879          /*
1880            copy fixed second half of header to cache so the correct
1881 @@ -2231,6 +2243,8 @@
1882        /* Write data to the binary log file */
1883        if (my_b_write(&log_file, cache->read_pos, length))
1884          goto err;
1885 +      thd->binlog_bytes_written += length;
1886 +
1887        cache->read_pos=cache->read_end;         // Mark buffer used up
1888        DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
1889      } while ((length=my_b_fill(cache)));
1890 @@ -2239,6 +2253,8 @@
1891  
1892      if (commit_event->write(&log_file))
1893        goto err;
1894 +    thd->binlog_bytes_written += commit_event->data_written;
1895 +
1896  #ifndef DBUG_OFF
1897  DBUG_skip_commit:
1898  #endif
1899 diff -r 1ac0113deff5 sql/mysql_priv.h
1900 --- a/sql/mysql_priv.h  Mon Jun 01 00:35:44 2009 -0700
1901 +++ b/sql/mysql_priv.h  Mon Jun 01 00:36:01 2009 -0700
1902 @@ -837,7 +837,15 @@
1903  bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
1904  void init_max_user_conn(void);
1905  void init_update_queries(void);
1906 +void init_global_user_stats(void);
1907 +void init_global_table_stats(void);
1908 +void init_global_index_stats(void);
1909 +void init_global_client_stats(void);
1910  void free_max_user_conn(void);
1911 +void free_global_user_stats(void);
1912 +void free_global_table_stats(void);
1913 +void free_global_index_stats(void);
1914 +void free_global_client_stats(void);
1915  pthread_handler_t handle_one_connection(void *arg);
1916  pthread_handler_t handle_bootstrap(void *arg);
1917  void end_thread(THD *thd,bool put_in_cache);
1918 @@ -1416,6 +1424,7 @@
1919  extern ulong max_connections,max_connect_errors, connect_timeout;
1920  extern ulong slave_net_timeout, slave_trans_retries;
1921  extern uint max_user_connections;
1922 +extern ulonglong denied_connections;
1923  extern ulong what_to_log,flush_time;
1924  extern ulong query_buff_size, thread_stack;
1925  extern ulong max_prepared_stmt_count, prepared_stmt_count;
1926 @@ -1446,6 +1455,7 @@
1927  extern my_bool opt_safe_show_db, opt_local_infile;
1928  extern my_bool opt_slave_compressed_protocol, use_temp_pool;
1929  extern my_bool opt_readonly, lower_case_file_system;
1930 +extern my_bool opt_userstat_running;
1931  extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
1932  extern my_bool opt_secure_auth;
1933  extern char* opt_secure_file_priv;
1934 @@ -1493,6 +1503,14 @@
1935  extern struct system_variables max_system_variables;
1936  extern struct system_status_var global_status_var;
1937  extern struct rand_struct sql_rand;
1938 +extern HASH global_user_stats;
1939 +extern HASH global_client_stats;
1940 +extern pthread_mutex_t LOCK_global_user_client_stats;
1941 +extern HASH global_table_stats;
1942 +extern pthread_mutex_t LOCK_global_table_stats;
1943 +extern HASH global_index_stats;
1944 +extern pthread_mutex_t LOCK_global_index_stats;
1945 +extern pthread_mutex_t LOCK_stats;
1946  
1947  extern const char *opt_date_time_formats[];
1948  extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
1949 diff -r 1ac0113deff5 sql/mysqld.cc
1950 --- a/sql/mysqld.cc     Mon Jun 01 00:35:44 2009 -0700
1951 +++ b/sql/mysqld.cc     Mon Jun 01 00:36:01 2009 -0700
1952 @@ -417,6 +417,7 @@
1953  uint    opt_large_page_size= 0;
1954  my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
1955  char* opt_slow_logname= 0;
1956 +my_bool opt_userstat_running= 0;
1957  /*
1958    True if there is at least one per-hour limit for some user, so we should
1959    check them before each query (and possibly reset counters when hour is
1960 @@ -453,6 +454,7 @@
1961  ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
1962  ulong max_connections, max_connect_errors;
1963  uint  max_user_connections= 0;
1964 +ulonglong denied_connections = 0;
1965  /*
1966    Limit of the total number of prepared statements in the server.
1967    Is necessary to protect the server against out-of-memory attacks.
1968 @@ -555,6 +557,10 @@
1969                 LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
1970                 LOCK_global_system_variables,
1971                 LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
1972 +pthread_mutex_t LOCK_stats;
1973 +pthread_mutex_t LOCK_global_user_client_stats;
1974 +pthread_mutex_t LOCK_global_table_stats;
1975 +pthread_mutex_t LOCK_global_index_stats;
1976  /*
1977    The below lock protects access to two global server variables:
1978    max_prepared_stmt_count and prepared_stmt_count. These variables
1979 @@ -1196,6 +1202,10 @@
1980    x_free(opt_secure_file_priv);
1981    bitmap_free(&temp_pool);
1982    free_max_user_conn();
1983 +  free_global_user_stats();
1984 +  free_global_client_stats();
1985 +  free_global_table_stats();
1986 +  free_global_index_stats();
1987  #ifdef HAVE_REPLICATION
1988    end_slave_list();
1989    free_list(&replicate_do_db);
1990 @@ -1310,6 +1320,10 @@
1991    (void) pthread_cond_destroy(&COND_thread_cache);
1992    (void) pthread_cond_destroy(&COND_flush_thread_cache);
1993    (void) pthread_cond_destroy(&COND_manager);
1994 +  (void) pthread_mutex_destroy(&LOCK_stats);
1995 +  (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
1996 +  (void) pthread_mutex_destroy(&LOCK_global_table_stats);
1997 +  (void) pthread_mutex_destroy(&LOCK_global_index_stats);
1998  }
1999  
2000  #endif /*EMBEDDED_LIBRARY*/
2001 @@ -3157,6 +3171,10 @@
2002    (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
2003    (void) pthread_cond_init(&COND_rpl_status, NULL);
2004  #endif
2005 +  (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
2006 +  (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
2007 +  (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
2008 +  (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
2009    sp_cache_init();
2010    /* Parameter for threads created for connections */
2011    (void) pthread_attr_init(&connection_attrib);
2012 @@ -3428,6 +3446,10 @@
2013      sql_print_error("Out of memory");
2014      unireg_abort(1);
2015    }
2016 +
2017 +  init_global_table_stats();
2018 +  init_global_index_stats();
2019 +
2020    if (ha_init())
2021    {
2022      sql_print_error("Can't init databases");
2023 @@ -3510,6 +3532,8 @@
2024  
2025    init_max_user_conn();
2026    init_update_queries();
2027 +  init_global_user_stats();
2028 +  init_global_client_stats();
2029    DBUG_RETURN(0);
2030  }
2031  
2032 @@ -4236,6 +4260,7 @@
2033    {
2034      DBUG_PRINT("error",("Too many connections"));
2035      close_connection(thd, ER_CON_COUNT_ERROR, 1);
2036 +    statistic_increment(denied_connections, &LOCK_status);
2037      delete thd;
2038      DBUG_VOID_RETURN;
2039    }
2040 @@ -5056,6 +5081,7 @@
2041    OPT_PROFILING_USE_GETRUSAGE,
2042    OPT_SLOW_LOG,
2043    OPT_SLOW_QUERY_LOG_FILE,
2044 +  OPT_USERSTAT_RUNNING,
2045    OPT_USE_GLOBAL_LONG_QUERY_TIME,
2046    OPT_INNODB_ROLLBACK_ON_TIMEOUT,
2047    OPT_SECURE_FILE_PRIV,
2048 @@ -6523,6 +6549,10 @@
2049     (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
2050     REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
2051     0, 1, 0},
2052 +  {"userstat_running", OPT_USERSTAT_RUNNING,
2053 +   "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
2054 +   (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
2055 +   0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
2056    {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
2057  };
2058  
2059 diff -r 1ac0113deff5 sql/set_var.cc
2060 --- a/sql/set_var.cc    Mon Jun 01 00:35:44 2009 -0700
2061 +++ b/sql/set_var.cc    Mon Jun 01 00:36:01 2009 -0700
2062 @@ -325,6 +325,7 @@
2063  sys_var_thd_ulong      sys_read_buff_size("read_buffer_size",
2064                                            &SV::read_buff_size);
2065  sys_var_bool_ptr       sys_readonly("read_only", &opt_readonly);
2066 +sys_var_bool_ptr       sys_userstat_running("userstat_running", &opt_userstat_running);
2067  sys_var_thd_ulong      sys_read_rnd_buff_size("read_rnd_buffer_size",
2068                                                &SV::read_rnd_buff_size);
2069  sys_var_thd_ulong      sys_div_precincrement("div_precision_increment",
2070 @@ -837,6 +838,7 @@
2071    &sys_trans_alloc_block_size,
2072    &sys_trans_prealloc_size,
2073    &sys_tx_isolation,
2074 +  &sys_userstat_running,
2075    &sys_version,
2076  #ifdef HAVE_BERKELEY_DB
2077    &sys_version_bdb,
2078 @@ -1190,6 +1192,7 @@
2079    {sys_tx_isolation.name,     (char*) &sys_tx_isolation,           SHOW_SYS},
2080    {sys_updatable_views_with_limit.name,
2081                                (char*) &sys_updatable_views_with_limit,SHOW_SYS},
2082 +  {sys_userstat_running.name, (char*) &sys_userstat_running,        SHOW_SYS},
2083    {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
2084    {sys_version.name,          (char*) &sys_version,                 SHOW_SYS},
2085  #ifdef HAVE_BERKELEY_DB
2086 diff -r 1ac0113deff5 sql/share/Makefile.in
2087 --- a/sql/share/Makefile.in     Mon Jun 01 00:35:44 2009 -0700
2088 +++ b/sql/share/Makefile.in     Mon Jun 01 00:36:01 2009 -0700
2089 @@ -144,6 +144,7 @@
2090  LIBDL = @LIBDL@
2091  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
2092  LIBOBJS = @LIBOBJS@
2093 +LIBRT = @LIBRT@
2094  LIBS = @LIBS@
2095  LIBTOOL = @LIBTOOL@
2096  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
2097 diff -r 1ac0113deff5 sql/sql_base.cc
2098 --- a/sql/sql_base.cc   Mon Jun 01 00:35:44 2009 -0700
2099 +++ b/sql/sql_base.cc   Mon Jun 01 00:36:01 2009 -0700
2100 @@ -624,6 +624,12 @@
2101    DBUG_ENTER("close_thread_table");
2102    DBUG_ASSERT(table->key_read == 0);
2103    DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
2104 +  
2105 +  if(table->file)
2106 +  {
2107 +    table->file->update_global_table_stats();
2108 +    table->file->update_global_index_stats();
2109 +  }
2110  
2111    *table_ptr=table->next;
2112    if (table->needs_reopen_or_name_lock() ||
2113 @@ -670,6 +676,9 @@
2114  {
2115    DBUG_ENTER("close_temporary");
2116    char path[FN_REFLEN];
2117 +
2118 +  table->file->update_global_table_stats();
2119 +  table->file->update_global_index_stats();
2120    db_type table_type=table->s->db_type;
2121    strmov(path,table->s->path);
2122    free_io_cache(table);
2123 diff -r 1ac0113deff5 sql/sql_class.cc
2124 --- a/sql/sql_class.cc  Mon Jun 01 00:35:44 2009 -0700
2125 +++ b/sql/sql_class.cc  Mon Jun 01 00:36:01 2009 -0700
2126 @@ -239,6 +239,13 @@
2127    bzero(ha_data, sizeof(ha_data));
2128    mysys_var=0;
2129    binlog_evt_union.do_union= FALSE;
2130 +  busy_time = 0;
2131 +  cpu_time = 0;
2132 +  bytes_received = 0;
2133 +  bytes_sent = 0;
2134 +  binlog_bytes_written = 0;
2135 +  updated_row_count = 0;
2136 +  sent_row_count_2 = 0;
2137  #ifndef DBUG_OFF
2138    dbug_sentry=THD_SENTRY_MAGIC;
2139  #endif
2140 @@ -378,6 +385,88 @@
2141    total_warn_count= 0;
2142    update_charset();
2143    bzero((char *) &status_var, sizeof(status_var));
2144 +  reset_stats();
2145 +}
2146 +
2147 +// Resets stats in a THD.
2148 +void THD::reset_stats(void) {
2149 +  current_connect_time = time(NULL);
2150 +  last_global_update_time = current_connect_time;
2151 +  reset_diff_stats();
2152 +}
2153 +
2154 +// Resets the 'diff' stats, which are used to update global stats.
2155 +void THD::reset_diff_stats(void) {
2156 +  diff_total_busy_time = 0;
2157 +  diff_total_cpu_time = 0;
2158 +  diff_total_bytes_received = 0;
2159 +  diff_total_bytes_sent = 0;
2160 +  diff_total_binlog_bytes_written = 0;
2161 +  diff_total_sent_rows = 0;
2162 +  diff_total_updated_rows = 0;
2163 +  diff_total_read_rows = 0;
2164 +  diff_select_commands = 0;
2165 +  diff_update_commands = 0;
2166 +  diff_other_commands = 0;
2167 +  diff_commit_trans = 0;
2168 +  diff_rollback_trans = 0;
2169 +  diff_denied_connections = 0;
2170 +  diff_lost_connections = 0;
2171 +  diff_access_denied_errors = 0;
2172 +  diff_empty_queries = 0;
2173 +}
2174 +
2175 +// Updates 'diff' stats of a THD.
2176 +void THD::update_stats(bool ran_command) {
2177 +  if (opt_userstat_running) {
2178 +  diff_total_busy_time += busy_time;
2179 +  diff_total_cpu_time += cpu_time;
2180 +  diff_total_bytes_received += bytes_received;
2181 +  diff_total_bytes_sent += bytes_sent;
2182 +  diff_total_binlog_bytes_written += binlog_bytes_written;
2183 +  diff_total_sent_rows += sent_row_count_2;
2184 +  diff_total_updated_rows += updated_row_count;
2185 +  // diff_total_read_rows is updated in handler.cc.
2186 +
2187 +  if (ran_command) {
2188 +    // The replication thread has the COM_CONNECT command.
2189 +    if ((old_command == COM_QUERY || command == COM_CONNECT) &&
2190 +        (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
2191 +      // A SQL query.
2192 +      if (lex->sql_command == SQLCOM_SELECT) {
2193 +        if (lex->orig_sql_command == SQLCOM_END) {
2194 +          diff_select_commands++;
2195 +          if (!sent_row_count_2)
2196 +            diff_empty_queries++;
2197 +        } else {
2198 +          // 'SHOW ' commands become SQLCOM_SELECT.
2199 +          diff_other_commands++;
2200 +          // 'SHOW ' commands shouldn't inflate total sent row count.
2201 +          diff_total_sent_rows -= sent_row_count_2;
2202 +        }
2203 +      } else if (is_update_query(lex->sql_command)) {
2204 +        diff_update_commands++;
2205 +      } else {
2206 +        diff_other_commands++;
2207 +      }
2208 +    }
2209 +  }
2210 +  // diff_commit_trans is updated in handler.cc.
2211 +  // diff_rollback_trans is updated in handler.cc.
2212 +  // diff_denied_connections is updated in sql_parse.cc.
2213 +  // diff_lost_connections is updated in sql_parse.cc.
2214 +  // diff_access_denied_errors is updated in sql_parse.cc.
2215 +
2216 +  /* reset counters to zero to avoid double-counting since values
2217 +     are already store in diff_total_*. */
2218 +  }
2219 +  busy_time = 0;
2220 +  cpu_time = 0;
2221 +  bytes_received = 0;
2222 +  bytes_sent = 0;
2223 +  binlog_bytes_written = 0;
2224 +  updated_row_count = 0;
2225 +  sent_row_count_2 = 0;
2226  }
2227  
2228  
2229 @@ -907,6 +996,33 @@
2230  }
2231  #endif
2232  
2233 +char *THD::get_client_host_port(THD *client)
2234 +{
2235 +  Security_context *client_sctx= client->security_ctx;
2236 +  char *client_host= NULL;
2237 +
2238 +  if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
2239 +      security_ctx->host_or_ip[0])
2240 +  {
2241 +    if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
2242 +      my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
2243 +                  "%s:%u", client_sctx->host_or_ip, client->peer_port);
2244 +  }
2245 +  else
2246 +    client_host= this->strdup(client_sctx->host_or_ip[0] ?
2247 +                              client_sctx->host_or_ip :
2248 +                              client_sctx->host ? client_sctx->host : "");
2249 +
2250 +  return client_host;
2251 +}
2252 +
2253 +const char *get_client_host(THD *client)
2254 +{
2255 +  return client->security_ctx->host_or_ip[0] ?
2256 +      client->security_ctx->host_or_ip :
2257 +      client->security_ctx->host ? client->security_ctx->host : "";
2258 +}
2259 +
2260  
2261  struct Item_change_record: public ilink
2262  {
2263 @@ -1082,6 +1198,7 @@
2264      buffer.set(buff, sizeof(buff), &my_charset_bin);
2265    }
2266    thd->sent_row_count++;
2267 +  thd->sent_row_count_2++;
2268    if (!thd->vio_ok())
2269      DBUG_RETURN(0);
2270    if (!thd->net.report_error)
2271 @@ -1174,6 +1291,7 @@
2272  select_export::~select_export()
2273  {
2274    thd->sent_row_count=row_count;
2275 +  thd->sent_row_count_2=row_count;
2276  }
2277  
2278  
2279 @@ -2108,6 +2226,7 @@
2280    if (likely(thd != 0))
2281    { /* current_thd==0 when close_connection() calls net_send_error() */
2282      thd->status_var.bytes_sent+= length;
2283 +    thd->bytes_sent+= length;
2284    }
2285  }
2286  
2287 @@ -2115,6 +2234,7 @@
2288  void thd_increment_bytes_received(ulong length)
2289  {
2290    current_thd->status_var.bytes_received+= length;
2291 +  current_thd->bytes_received+= length;
2292  }
2293  
2294  
2295 diff -r 1ac0113deff5 sql/sql_class.h
2296 --- a/sql/sql_class.h   Mon Jun 01 00:35:44 2009 -0700
2297 +++ b/sql/sql_class.h   Mon Jun 01 00:36:01 2009 -0700
2298 @@ -1302,6 +1302,8 @@
2299      first byte of the packet in do_command()
2300    */
2301    enum enum_server_command command;
2302 +  // Used to save the command, before it is set to COM_SLEEP.
2303 +  enum enum_server_command old_command;
2304    uint32     server_id;
2305    uint32     file_id;                  // for LOAD DATA INFILE
2306    /*
2307 @@ -1498,6 +1500,8 @@
2308    /* variables.transaction_isolation is reset to this after each commit */
2309    enum_tx_isolation session_tx_isolation;
2310    enum_check_fields count_cuted_fields;
2311 +  ha_rows    updated_row_count;
2312 +  ha_rows    sent_row_count_2; /* for userstat */
2313  
2314    DYNAMIC_ARRAY user_var_events;        /* For user variables replication */
2315    MEM_ROOT      *user_var_events_alloc; /* Allocate above array elements here */
2316 @@ -1607,6 +1611,49 @@
2317    */
2318    LOG_INFO*  current_linfo;
2319    NET*       slave_net;                        // network connection from slave -> m.
2320 +
2321 +  /*
2322 +    Used to update global user stats.  The global user stats are updated
2323 +    occasionally with the 'diff' variables.  After the update, the 'diff'
2324 +    variables are reset to 0.
2325 +   */
2326 +  // Time when the current thread connected to MySQL.
2327 +  time_t current_connect_time;
2328 +  // Last time when THD stats were updated in global_user_stats.
2329 +  time_t last_global_update_time;
2330 +  // Busy (non-idle) time for just one command.
2331 +  double busy_time;
2332 +  // Busy time not updated in global_user_stats yet.
2333 +  double diff_total_busy_time;
2334 +  // Cpu (non-idle) time for just one thread.
2335 +  double cpu_time;
2336 +  // Cpu time not updated in global_user_stats yet.
2337 +  double diff_total_cpu_time;
2338 +  /* bytes counting */
2339 +  ulonglong bytes_received;
2340 +  ulonglong diff_total_bytes_received;
2341 +  ulonglong bytes_sent;
2342 +  ulonglong diff_total_bytes_sent;
2343 +  ulonglong binlog_bytes_written;
2344 +  ulonglong diff_total_binlog_bytes_written;
2345 +
2346 +  // Number of rows not reflected in global_user_stats yet.
2347 +  ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
2348 +  // Number of commands not reflected in global_user_stats yet.
2349 +  ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
2350 +  // Number of transactions not reflected in global_user_stats yet.
2351 +  ulonglong diff_commit_trans, diff_rollback_trans;
2352 +  // Number of connection errors not reflected in global_user_stats yet.
2353 +  ulonglong diff_denied_connections, diff_lost_connections;
2354 +  // Number of db access denied, not reflected in global_user_stats yet.
2355 +  ulonglong diff_access_denied_errors;
2356 +  // Number of queries that return 0 rows
2357 +  ulonglong diff_empty_queries;
2358 +
2359 +  // Per account query delay in miliseconds. When not 0, sleep this number of
2360 +  // milliseconds before every SQL command.
2361 +  ulonglong query_delay_millis;
2362 +
2363    /* Used by the sys_var class to store temporary values */
2364    union
2365    {
2366 @@ -1662,6 +1709,11 @@
2367      alloc_root.
2368    */
2369    void init_for_queries();
2370 +  void reset_stats(void);
2371 +  void reset_diff_stats(void);
2372 +  // ran_command is true when this is called immediately after a
2373 +  // command has been run.
2374 +  void update_stats(bool ran_command);
2375    void change_user(void);
2376    void cleanup(void);
2377    void cleanup_after_query();
2378 @@ -1891,8 +1943,14 @@
2379      if (p_db_length)
2380        *p_db_length= db_length;
2381      return FALSE;
2382 +
2383 +  // Returns string as 'IP:port' for the client-side of the connnection represented
2384 +  // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
2385 +  // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
2386    }
2387  
2388 +  char *get_client_host_port(THD *client);
2389 +
2390  public:
2391    /**
2392      Add an internal error handler to the thread execution context.
2393 @@ -1935,6 +1993,11 @@
2394    MEM_ROOT main_mem_root;
2395  };
2396  
2397 +// Returns string as 'IP' for the client-side of the connection represented by
2398 +// 'client'. Does not allocate memory. May return "".
2399 +const char *get_client_host(THD *client);
2400 +
2401 +#define LIST_PROCESS_HOST_LEN 64
2402  
2403  #define tmp_disable_binlog(A)       \
2404    {ulonglong tmp_disable_binlog__save_options= (A)->options; \
2405 diff -r 1ac0113deff5 sql/sql_delete.cc
2406 --- a/sql/sql_delete.cc Mon Jun 01 00:35:44 2009 -0700
2407 +++ b/sql/sql_delete.cc Mon Jun 01 00:36:01 2009 -0700
2408 @@ -358,6 +358,7 @@
2409      send_ok(thd,deleted);
2410      DBUG_PRINT("info",("%ld records deleted",(long) deleted));
2411    }
2412 +  thd->updated_row_count += deleted;
2413    DBUG_RETURN(error >= 0 || thd->net.report_error);
2414  }
2415  
2416 @@ -869,6 +870,7 @@
2417      thd->row_count_func= deleted;
2418      ::send_ok(thd, deleted);
2419    }
2420 +  thd->updated_row_count += deleted;
2421    return 0;
2422  }
2423  
2424 diff -r 1ac0113deff5 sql/sql_insert.cc
2425 --- a/sql/sql_insert.cc Mon Jun 01 00:35:44 2009 -0700
2426 +++ b/sql/sql_insert.cc Mon Jun 01 00:36:01 2009 -0700
2427 @@ -989,6 +989,7 @@
2428      thd->row_count_func= info.copied + info.deleted + updated;
2429      ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
2430    }
2431 +  thd->updated_row_count += thd->row_count_func;
2432    thd->abort_on_warning= 0;
2433    DBUG_RETURN(FALSE);
2434  
2435 @@ -3064,6 +3065,7 @@
2436      autoinc_value_of_first_inserted_row : thd->insert_id_used ?
2437      thd->last_insert_id : 0;
2438    ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
2439 +  thd->updated_row_count += thd->row_count_func;
2440    DBUG_RETURN(0);
2441  }
2442  
2443 diff -r 1ac0113deff5 sql/sql_lex.h
2444 --- a/sql/sql_lex.h     Mon Jun 01 00:35:44 2009 -0700
2445 +++ b/sql/sql_lex.h     Mon Jun 01 00:36:01 2009 -0700
2446 @@ -101,6 +101,9 @@
2447      When a command is added here, be sure it's also added in mysqld.cc
2448      in "struct show_var_st status_vars[]= {" ...
2449    */
2450 +  // TODO(mcallaghan): update status_vars in mysqld to export these
2451 +  SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
2452 +  SQLCOM_SHOW_CLIENT_STATS,
2453    /* This should be the last !!! */
2454    SQLCOM_END
2455  };
2456 diff -r 1ac0113deff5 sql/sql_parse.cc
2457 --- a/sql/sql_parse.cc  Mon Jun 01 00:35:44 2009 -0700
2458 +++ b/sql/sql_parse.cc  Mon Jun 01 00:36:01 2009 -0700
2459 @@ -78,6 +78,12 @@
2460                                const char *table_name);
2461  static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
2462  
2463 +// Increments connection count for user.
2464 +static int increment_connection_count(THD* thd, bool use_lock);
2465 +
2466 +// Uses the THD to update the global stats by user name and client IP
2467 +void update_global_user_stats(THD* thd, bool create_user, time_t now);
2468 +
2469  const char *any_db="*any*";    // Special symbol for check_access
2470  
2471  const char *command_name[]={
2472 @@ -146,6 +152,17 @@
2473  static bool do_command(THD *thd);
2474  #endif // EMBEDDED_LIBRARY
2475  
2476 +HASH global_user_stats;
2477 +HASH global_client_stats;
2478 +// Protects global_user_stats and global_client_stats
2479 +extern pthread_mutex_t LOCK_global_user_client_stats;
2480 +
2481 +HASH global_table_stats;
2482 +extern pthread_mutex_t LOCK_global_table_stats;
2483 +
2484 +HASH global_index_stats;
2485 +extern pthread_mutex_t LOCK_global_index_stats;
2486 +
2487  #ifdef __WIN__
2488  extern void win_install_sigabrt_handler(void);
2489  #endif
2490 @@ -504,6 +521,7 @@
2491      mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
2492      DBUG_RETURN(-1);
2493    }
2494 +  thd->diff_access_denied_errors++;
2495    net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
2496                     thd->main_security_ctx.user,
2497                     thd->main_security_ctx.host_or_ip,
2498 @@ -536,12 +554,190 @@
2499  void init_max_user_conn(void)
2500  {
2501  #ifndef NO_EMBEDDED_ACCESS_CHECKS
2502 -  (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
2503 -                  0,0,
2504 -                  (hash_get_key) get_key_conn, (hash_free_key) free_user,
2505 -                  0);
2506 -#endif
2507 -}
2508 +  if (hash_init(&hash_user_connections,system_charset_info,max_connections,
2509 +                0,0,
2510 +                (hash_get_key) get_key_conn, (hash_free_key) free_user,
2511 +                0)) {
2512 +    sql_print_error("Initializing hash_user_connections failed.");
2513 +    exit(1);
2514 +  }
2515 +#endif
2516 +}
2517 +
2518 +byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
2519 +                         my_bool not_used __attribute__((unused)))
2520 +{
2521 +  *length = strlen(user_stats->user);
2522 +  return (byte*)user_stats->user;
2523 +}
2524 +
2525 +void free_user_stats(USER_STATS* user_stats)
2526 +{
2527 +  my_free((char*)user_stats, MYF(0));
2528 +}
2529 +
2530 +void init_user_stats(USER_STATS *user_stats,
2531 +                     const char *user,
2532 +                     const char *priv_user,
2533 +                     uint total_connections,
2534 +                     uint concurrent_connections,
2535 +                     time_t connected_time,
2536 +                     double busy_time,
2537 +                     double cpu_time,
2538 +                     ulonglong bytes_received,
2539 +                     ulonglong bytes_sent,
2540 +                     ulonglong binlog_bytes_written,
2541 +                     ha_rows rows_fetched,
2542 +                     ha_rows rows_updated,
2543 +                     ha_rows rows_read,
2544 +                     ulonglong select_commands,
2545 +                     ulonglong update_commands,
2546 +                     ulonglong other_commands,
2547 +                     ulonglong commit_trans,
2548 +                     ulonglong rollback_trans,
2549 +                     ulonglong denied_connections,
2550 +                     ulonglong lost_connections,
2551 +                     ulonglong access_denied_errors,
2552 +                     ulonglong empty_queries)
2553 +{
2554 +  DBUG_ENTER("init_user_stats");
2555 +  DBUG_PRINT("info",
2556 +             ("Add user_stats entry for user %s - priv_user %s",
2557 +              user, priv_user));
2558 +  strncpy(user_stats->user, user, sizeof(user_stats->user));
2559 +  strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
2560 +
2561 +  user_stats->total_connections = total_connections;
2562 +  user_stats->concurrent_connections = concurrent_connections;
2563 +  user_stats->connected_time = connected_time;
2564 +  user_stats->busy_time = busy_time;
2565 +  user_stats->cpu_time = cpu_time;
2566 +  user_stats->bytes_received = bytes_received;
2567 +  user_stats->bytes_sent = bytes_sent;
2568 +  user_stats->binlog_bytes_written = binlog_bytes_written;
2569 +  user_stats->rows_fetched = rows_fetched;
2570 +  user_stats->rows_updated = rows_updated;
2571 +  user_stats->rows_read = rows_read;
2572 +  user_stats->select_commands = select_commands;
2573 +  user_stats->update_commands = update_commands;
2574 +  user_stats->other_commands = other_commands;
2575 +  user_stats->commit_trans = commit_trans;
2576 +  user_stats->rollback_trans = rollback_trans;
2577 +  user_stats->denied_connections = denied_connections;
2578 +  user_stats->lost_connections = lost_connections;
2579 +  user_stats->access_denied_errors = access_denied_errors;
2580 +  user_stats->empty_queries = empty_queries;
2581 +  DBUG_VOID_RETURN;
2582 +}
2583 +
2584 +void add_user_stats(USER_STATS *user_stats,
2585 +                    uint total_connections,
2586 +                    uint concurrent_connections,
2587 +                    time_t connected_time,
2588 +                    double busy_time,
2589 +                    double cpu_time,
2590 +                    ulonglong bytes_received,
2591 +                    ulonglong bytes_sent,
2592 +                    ulonglong binlog_bytes_written,
2593 +                    ha_rows rows_fetched,
2594 +                    ha_rows rows_updated,
2595 +                    ha_rows rows_read,
2596 +                    ulonglong select_commands,
2597 +                    ulonglong update_commands,
2598 +                    ulonglong other_commands,
2599 +                    ulonglong commit_trans,
2600 +                    ulonglong rollback_trans,
2601 +                    ulonglong denied_connections,
2602 +                    ulonglong lost_connections,
2603 +                    ulonglong access_denied_errors,
2604 +                    ulonglong empty_queries)
2605 +{
2606 +  user_stats->total_connections += total_connections;
2607 +  user_stats->concurrent_connections += concurrent_connections;
2608 +  user_stats->connected_time += connected_time;
2609 +  user_stats->busy_time += busy_time;
2610 +  user_stats->cpu_time += cpu_time;
2611 +  user_stats->bytes_received += bytes_received;
2612 +  user_stats->bytes_sent += bytes_sent;
2613 +  user_stats->binlog_bytes_written += binlog_bytes_written;
2614 +  user_stats->rows_fetched += rows_fetched;
2615 +  user_stats->rows_updated += rows_updated;
2616 +  user_stats->rows_read += rows_read;
2617 +  user_stats->select_commands += select_commands;
2618 +  user_stats->update_commands += update_commands;
2619 +  user_stats->other_commands += other_commands;
2620 +  user_stats->commit_trans += commit_trans;
2621 +  user_stats->rollback_trans += rollback_trans;
2622 +  user_stats->denied_connections += denied_connections;
2623 +  user_stats->lost_connections += lost_connections;
2624 +  user_stats->access_denied_errors += access_denied_errors;
2625 +  user_stats->empty_queries += empty_queries;
2626 +}
2627 +
2628 +void init_global_user_stats(void)
2629 +{
2630 +  if (hash_init(&global_user_stats, system_charset_info, max_connections,
2631 +                0, 0, (hash_get_key)get_key_user_stats,
2632 +                (hash_free_key)free_user_stats, 0)) {
2633 +    sql_print_error("Initializing global_user_stats failed.");
2634 +    exit(1);
2635 +  }
2636 +}
2637 +
2638 +void init_global_client_stats(void)
2639 +{
2640 +  if (hash_init(&global_client_stats, system_charset_info, max_connections,
2641 +                0, 0, (hash_get_key)get_key_user_stats,
2642 +                (hash_free_key)free_user_stats, 0)) {
2643 +    sql_print_error("Initializing global_client_stats failed.");
2644 +    exit(1);
2645 +  }
2646 +}
2647 +
2648 +extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
2649 +                                     my_bool not_used __attribute__((unused)))
2650 +{
2651 +  *length = strlen(table_stats->table);
2652 +  return (byte*)table_stats->table;
2653 +}
2654 +
2655 +extern "C" void free_table_stats(TABLE_STATS* table_stats)
2656 +{
2657 +  my_free((char*)table_stats, MYF(0));
2658 +}
2659 +
2660 +void init_global_table_stats(void)
2661 +{
2662 +  if (hash_init(&global_table_stats, system_charset_info, max_connections,
2663 +                0, 0, (hash_get_key)get_key_table_stats,
2664 +                (hash_free_key)free_table_stats, 0)) {
2665 +    sql_print_error("Initializing global_table_stats failed.");
2666 +    exit(1);
2667 +  }
2668 +}
2669 +
2670 +extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
2671 +                                     my_bool not_used __attribute__((unused)))
2672 +{
2673 +  *length = strlen(index_stats->index);
2674 +  return (byte*)index_stats->index;
2675 +}
2676 +
2677 +extern "C" void free_index_stats(INDEX_STATS* index_stats)
2678 +{
2679 +  my_free((char*)index_stats, MYF(0));
2680 +}
2681 +
2682 +void init_global_index_stats(void)
2683 +{
2684 +  if (hash_init(&global_index_stats, system_charset_info, max_connections,
2685 +                0, 0, (hash_get_key)get_key_index_stats,
2686 +                (hash_free_key)free_index_stats, 0)) {
2687 +    sql_print_error("Initializing global_index_stats failed.");
2688 +    exit(1);
2689 +  }
2690 +}
2691 +
2692  
2693  
2694  /*
2695 @@ -599,7 +795,10 @@
2696  
2697    end:
2698    if (error)
2699 +  {
2700 +    statistic_increment(denied_connections, &LOCK_status);
2701      uc->connections--; // no need for decrease_user_connections() here
2702 +  }
2703    (void) pthread_mutex_unlock(&LOCK_user_conn);
2704    DBUG_RETURN(error);
2705  }
2706 @@ -646,6 +845,25 @@
2707  #endif /* NO_EMBEDDED_ACCESS_CHECKS */
2708  }
2709  
2710 +void free_global_user_stats(void)
2711 +{
2712 +  hash_free(&global_user_stats);
2713 +}
2714 +
2715 +void free_global_table_stats(void)
2716 +{
2717 +  hash_free(&global_table_stats);
2718 +}
2719 +
2720 +void free_global_index_stats(void)
2721 +{
2722 +  hash_free(&global_index_stats);
2723 +}
2724 +
2725 +void free_global_client_stats(void)
2726 +{
2727 +  hash_free(&global_client_stats);
2728 +}
2729  
2730  
2731  /*
2732 @@ -698,6 +916,214 @@
2733    return uc_update_queries[command] != 0;
2734  }
2735  
2736 +// 'mysql_system_user' is used for when the user is not defined for a THD.
2737 +static char mysql_system_user[] = "#mysql_system#";
2738 +
2739 +// Returns 'user' if it's not NULL.  Returns 'mysql_system_user' otherwise.
2740 +static char* get_valid_user_string(char* user) {
2741 +  return user ? user : mysql_system_user;
2742 +}
2743 +
2744 +// Increments the global stats connection count for an entry from
2745 +// global_client_stats or global_user_stats. Returns 0 on success
2746 +// and 1 on error.
2747 +static int increment_count_by_name(const char *name, const char *role_name,
2748 +                                   HASH *users_or_clients, THD *thd)
2749 +{
2750 +  USER_STATS* user_stats;
2751 +
2752 +  if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
2753 +                                              strlen(name))))
2754 +  {
2755 +    // First connection for this user or client
2756 +    if (!(user_stats = ((USER_STATS*)
2757 +                        my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
2758 +    {
2759 +      return 1; // Out of memory
2760 +    }
2761 +
2762 +    init_user_stats(user_stats, name, role_name,
2763 +                    0, 0,      // connections
2764 +                    0, 0, 0,   // time
2765 +                    0, 0, 0,   // bytes sent, received and written
2766 +                    0, 0, 0,   // rows fetched, updated and read
2767 +                    0, 0, 0,   // select, update and other commands
2768 +                    0, 0,      // commit and rollback trans
2769 +                    thd->diff_denied_connections,
2770 +                    0,         // lost connections
2771 +                    0,         // access denied errors
2772 +                    0);        // empty queries
2773 +
2774 +    if (my_hash_insert(users_or_clients, (byte*)user_stats))
2775 +    {
2776 +      my_free((char*)user_stats, 0);
2777 +      return 1; // Out of memory
2778 +    }
2779 +  }
2780 +  user_stats->total_connections++;
2781 +  return 0;
2782 +}
2783 +
2784 +// Increments the global user and client stats connection count.  If 'use_lock'
2785 +// is true, LOCK_global_user_client_stats will be locked/unlocked.  Returns
2786 +// 0 on success, 1 on error.
2787 +static int increment_connection_count(THD* thd, bool use_lock)
2788 +{
2789 +  char* user_string = get_valid_user_string(thd->main_security_ctx.user);
2790 +  const char* client_string = get_client_host(thd);
2791 +  int return_value = 0;
2792 +
2793 +  if (!opt_userstat_running)
2794 +    return return_value;
2795 +
2796 +  if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
2797 +
2798 +  if (increment_count_by_name(user_string, user_string,
2799 +                              &global_user_stats, thd))
2800 +  {
2801 +    return_value = 1;
2802 +    goto end;
2803 +  }
2804 +  if (increment_count_by_name(client_string,
2805 +                              user_string,
2806 +                              &global_client_stats, thd))
2807 +  {
2808 +    return_value = 1;
2809 +    goto end;
2810 +  }
2811 +
2812 +end:
2813 +  if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
2814 +  return return_value;
2815 +}
2816 +
2817 +// Used to update the global user and client stats.
2818 +static void update_global_user_stats_with_user(THD* thd,
2819 +                                               USER_STATS* user_stats,
2820 +                                               time_t now)
2821 +{
2822 +  user_stats->connected_time += now - thd->last_global_update_time;
2823 +  thd->last_global_update_time = now;
2824 +  user_stats->busy_time += thd->diff_total_busy_time;
2825 +  user_stats->cpu_time += thd->diff_total_cpu_time;
2826 +  user_stats->bytes_received += thd->diff_total_bytes_received;
2827 +  user_stats->bytes_sent += thd->diff_total_bytes_sent;
2828 +  user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
2829 +  user_stats->rows_fetched += thd->diff_total_sent_rows;
2830 +  user_stats->rows_updated += thd->diff_total_updated_rows;
2831 +  user_stats->rows_read += thd->diff_total_read_rows;
2832 +  user_stats->select_commands += thd->diff_select_commands;
2833 +  user_stats->update_commands += thd->diff_update_commands;
2834 +  user_stats->other_commands += thd->diff_other_commands;
2835 +  user_stats->commit_trans += thd->diff_commit_trans;
2836 +  user_stats->rollback_trans += thd->diff_rollback_trans;
2837 +  user_stats->denied_connections += thd->diff_denied_connections;
2838 +  user_stats->lost_connections += thd->diff_lost_connections;
2839 +  user_stats->access_denied_errors += thd->diff_access_denied_errors;
2840 +  user_stats->empty_queries += thd->diff_empty_queries;
2841 +}
2842 +
2843 +// Updates the global stats of a user or client
2844 +void update_global_user_stats(THD* thd, bool create_user, time_t now)
2845 +{
2846 +  if (opt_userstat_running) {
2847 +  char* user_string = get_valid_user_string(thd->main_security_ctx.user);
2848 +  const char* client_string = get_client_host(thd);
2849 +
2850 +  USER_STATS* user_stats;
2851 +  pthread_mutex_lock(&LOCK_global_user_client_stats);
2852 +
2853 +  // Update by user name
2854 +  if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
2855 +                                             (byte*)user_string,
2856 +                                             strlen(user_string)))) {
2857 +    // Found user.
2858 +    update_global_user_stats_with_user(thd, user_stats, now);
2859 +  } else {
2860 +    // Create the entry
2861 +    if (create_user) {
2862 +      increment_count_by_name(user_string, user_string,
2863 +                              &global_user_stats, thd);
2864 +    }
2865 +  }
2866 +
2867 +  // Update by client IP
2868 +  if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
2869 +                                             (byte*)client_string,
2870 +                                             strlen(client_string)))) {
2871 +    // Found by client IP
2872 +    update_global_user_stats_with_user(thd, user_stats, now);
2873 +  } else {
2874 +    // Create the entry
2875 +    if (create_user) {
2876 +      increment_count_by_name(client_string,
2877 +                              user_string,
2878 +                              &global_client_stats, thd);
2879 +    }
2880 +  }
2881 +  thd->reset_diff_stats();
2882 +
2883 +  pthread_mutex_unlock(&LOCK_global_user_client_stats);
2884 +  } else {
2885 +  thd->reset_diff_stats();
2886 +  }
2887 +}
2888 +
2889 +// Determines the concurrent number of connections of current threads.
2890 +static void set_connections_stats()
2891 +{
2892 +  USER_STATS* user_stats;
2893 +
2894 +  pthread_mutex_lock(&LOCK_global_user_client_stats);
2895 +  pthread_mutex_lock(&LOCK_thread_count);
2896 +
2897 +  // Resets all concurrent connections to 0.
2898 +  for (int i = 0; i < global_user_stats.records; ++i) {
2899 +    user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
2900 +    user_stats->concurrent_connections = 0;
2901 +  }
2902 +  for (int i = 0; i < global_client_stats.records; ++i) {
2903 +    user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
2904 +    user_stats->concurrent_connections = 0;
2905 +  }
2906 +
2907 +  I_List_iterator<THD> it(threads);
2908 +  THD* thd;
2909 +  time_t now = time(NULL);
2910 +  // Iterates through the current threads.
2911 +  while ((thd = it++)) {
2912 +    char* user_string = get_valid_user_string(thd->main_security_ctx.user);
2913 +    if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
2914 +                                               (byte*)user_string,
2915 +                                               strlen(user_string)))) {
2916 +      // Found user.
2917 +      user_stats->concurrent_connections++;
2918 +      update_global_user_stats_with_user(thd, user_stats, now);
2919 +    } else {
2920 +      // The user name should exist.
2921 +      if (user_string == mysql_system_user) {
2922 +        // Only create the user if it is the mysql_system_user
2923 +        increment_count_by_name(user_string, user_string,
2924 +                                &global_user_stats, thd);
2925 +      }
2926 +    }
2927 +
2928 +    const char* client_string = get_client_host(thd);
2929 +    if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
2930 +                                               (byte*)client_string,
2931 +                                               strlen(client_string)))) {
2932 +      // Found user.
2933 +      user_stats->concurrent_connections++;
2934 +      update_global_user_stats_with_user(thd, user_stats, now);
2935 +    } else {
2936 +      // Do nothing, unlike what is done for global_user_stats
2937 +    }
2938 +    thd->reset_diff_stats();
2939 +  }
2940 +  pthread_mutex_unlock(&LOCK_thread_count);
2941 +  pthread_mutex_unlock(&LOCK_global_user_client_stats);
2942 +}
2943 +
2944  /*
2945    Reset per-hour user resource limits when it has been more than
2946    an hour since they were last checked
2947 @@ -1184,6 +1610,8 @@
2948      my_net_set_read_timeout(net, connect_timeout);
2949      my_net_set_write_timeout(net, connect_timeout);
2950  
2951 +    bool create_user = true;
2952 +
2953      if ((error=check_connection(thd)))
2954      {                                          // Wrong permissions
2955        if (error > 0)
2956 @@ -1193,8 +1621,22 @@
2957         my_sleep(1000);                         /* must wait after eof() */
2958  #endif
2959        statistic_increment(aborted_connects,&LOCK_status);
2960 +      thd->diff_denied_connections++;
2961 +      if (error == -2) {
2962 +        // Do not create statistics for a user who does not exist, or failed
2963 +        // to authenticate.
2964 +        create_user = false;
2965 +      }
2966        goto end_thread;
2967      }
2968 +
2969 +    thd->reset_stats();
2970 +    // Updates global user connection stats.
2971 +    if (increment_connection_count(thd, true)) {
2972 +      net_send_error(thd, ER_OUTOFMEMORY);  // Out of memory
2973 +      goto end_thread;
2974 +    }
2975 +
2976  #ifdef __NETWARE__
2977      netware_reg_user(sctx->ip, sctx->user, "MySQL");
2978  #endif
2979 @@ -1251,6 +1693,7 @@
2980          net->vio && net->error && net->report_error)
2981      {
2982        statistic_increment(aborted_threads, &LOCK_status);
2983 +      thd->diff_lost_connections++;
2984      }
2985  
2986      if (net->error && net->vio != 0 && net->report_error)
2987 @@ -1270,6 +1713,8 @@
2988  
2989  end_thread:
2990      close_connection(thd, 0, 1);
2991 +    thd->update_stats(false);
2992 +    update_global_user_stats(thd, create_user, time(NULL));
2993      end_thread(thd,1);
2994      /*
2995        If end_thread returns, we are either running with --one-thread
2996 @@ -1601,6 +2046,13 @@
2997  
2998    thd->clear_error();                          // Clear error message
2999  
3000 +  thd->updated_row_count=0;
3001 +  thd->busy_time=0;
3002 +  thd->cpu_time=0;
3003 +  thd->bytes_received=0;
3004 +  thd->bytes_sent=0;
3005 +  thd->binlog_bytes_written=0;
3006 +
3007    net_new_transaction(net);
3008  
3009    packet_length= my_net_read(net);
3010 @@ -1759,6 +2211,9 @@
3011    }
3012  
3013    thd->command=command;
3014 +  // To increment the corrent command counter for user stats, 'command' must
3015 +  // be saved because it is set to COM_SLEEP at the end of this function.
3016 +  thd->old_command = command;
3017    /*
3018      Commands which always take a long time are logged into
3019      the slow log only if opt_log_slow_admin_statements is set.
3020 @@ -4540,6 +4995,15 @@
3021      if (check_global_access(thd,RELOAD_ACL))
3022        goto error;
3023  
3024 +    if(lex->type & REFRESH_SLOW_QUERY_LOG) {
3025 +        /* We are only flushing slow query log */
3026 +        mysql_slow_log.new_file(1);
3027 +    
3028 +        send_ok(thd);
3029 +        break;
3030 +    }
3031 +
3032 +
3033      /*
3034        reload_acl_and_cache() will tell us if we are allowed to write to the
3035        binlog or not.
3036 @@ -4848,6 +5312,7 @@
3037      {
3038        if (check_global_access(thd, SUPER_ACL))
3039        {
3040 +        thd->diff_access_denied_errors++;
3041          my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
3042          goto create_sp_error;
3043        }
3044 @@ -5692,6 +6157,7 @@
3045        if (!no_errors)
3046        {
3047          const char *db_name= db ? db : thd->db;
3048 +        thd->diff_access_denied_errors++;
3049          my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3050                   sctx->priv_user, sctx->priv_host, db_name);
3051        }
3052 @@ -5727,6 +6193,7 @@
3053    {                                            // We can never grant this
3054      DBUG_PRINT("error",("No possible access"));
3055      if (!no_errors)
3056 +      thd->diff_access_denied_errors++;
3057        my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
3058                 sctx->priv_user,
3059                 sctx->priv_host,
3060 @@ -5759,11 +6226,15 @@
3061  
3062    DBUG_PRINT("error",("Access denied"));
3063    if (!no_errors)
3064 +  {
3065 +    // increment needs !no_errors condition, otherwise double counting.
3066 +    thd->diff_access_denied_errors++;
3067      my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3068               sctx->priv_user, sctx->priv_host,
3069               (db ? db : (thd->db ?
3070                           thd->db :
3071                           "unknown")));          /* purecov: tested */
3072 +  }
3073    DBUG_RETURN(TRUE);                           /* purecov: tested */
3074  #endif /* NO_EMBEDDED_ACCESS_CHECKS */
3075  }
3076 @@ -5797,6 +6268,7 @@
3077    if ((thd->security_ctx->master_access & want_access))
3078      return 0;
3079    get_privilege_desc(command, sizeof(command), want_access);
3080 +  thd->diff_access_denied_errors++;
3081    my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
3082    return 1;
3083  #endif /* NO_EMBEDDED_ACCESS_CHECKS */
3084 @@ -5829,6 +6301,7 @@
3085  
3086        if (!thd->col_access && check_grant_db(thd, dst_db_name))
3087        {
3088 +        thd->diff_access_denied_errors++;
3089          my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3090                   thd->security_ctx->priv_user,
3091                   thd->security_ctx->priv_host,
3092 @@ -5860,6 +6333,12 @@
3093               check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
3094      }
3095  
3096
3097 +  case SCH_USER_STATS:
3098 +  case SCH_CLIENT_STATS:
3099 +     return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
3100 +  case SCH_TABLE_STATS:
3101 +  case SCH_INDEX_STATS:
3102    case SCH_OPEN_TABLES:
3103    case SCH_VARIABLES:
3104    case SCH_STATUS:
3105 @@ -5913,8 +6392,8 @@
3106  #ifndef NO_EMBEDDED_ACCESS_CHECKS
3107    TABLE_LIST *org_tables= tables;
3108  #endif
3109 +  Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
3110    TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
3111 -  Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
3112    /*
3113      The check that first_not_own_table is not reached is for the case when
3114      the given table list refers to the list for prelocking (contains tables
3115 @@ -5931,9 +6410,12 @@
3116          (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
3117      {
3118        if (!no_errors)
3119 +      {
3120 +        thd->diff_access_denied_errors++;
3121          my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3122                   sctx->priv_user, sctx->priv_host,
3123                   INFORMATION_SCHEMA_NAME.str);
3124 +      }
3125        return TRUE;
3126      }
3127      /*
3128 @@ -6443,6 +6925,30 @@
3129    lex_start(thd);
3130    mysql_reset_thd_for_next_command(thd);
3131  
3132 +  int start_time_error = 0;
3133 +  int end_time_error = 0;
3134 +  struct timeval start_time, end_time;
3135 +  double start_usecs = 0;
3136 +  double end_usecs = 0;
3137 +  /* cpu time */
3138 +  int cputime_error = 0;
3139 +  struct timespec tp;
3140 +  double start_cpu_nsecs = 0;
3141 +  double end_cpu_nsecs = 0;
3142 +
3143 +  if (opt_userstat_running) {
3144 +#ifdef HAVE_CLOCK_GETTIME
3145 +    /* get start cputime */ 
3146 +    if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3147 +      start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3148 +#endif
3149 +
3150 +    // Gets the start time, in order to measure how long this command takes.
3151 +    if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3152 +      start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3153 +    }
3154 +  }
3155 +
3156    if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
3157    {
3158      LEX *lex= thd->lex;
3159 @@ -6521,6 +7027,43 @@
3160      *found_semicolon= NULL;
3161    }
3162  
3163 +  if (opt_userstat_running) {
3164 +    // Gets the end time.
3165 +    if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3166 +      end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3167 +    }
3168 +
3169 +    // Calculates the difference between the end and start times.
3170 +    if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3171 +      thd->busy_time = (end_usecs - start_usecs) / 1000000;
3172 +      // In case there are bad values, 2629743 is the #seconds in a month.
3173 +      if (thd->busy_time > 2629743) {
3174 +        thd->busy_time = 0;
3175 +      }
3176 +    } else {
3177 +      // end time went back in time, or gettimeofday() failed.
3178 +      thd->busy_time = 0;
3179 +    }
3180 +
3181 +#ifdef HAVE_CLOCK_GETTIME
3182 +    /* get end cputime */
3183 +    if (!cputime_error &&
3184 +        !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3185 +      end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3186 +#endif
3187 +    if (start_cpu_nsecs && !cputime_error) {
3188 +      thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3189 +      // In case there are bad values, 2629743 is the #seconds in a month.
3190 +      if (thd->cpu_time > 2629743) {
3191 +        thd->cpu_time = 0;
3192 +      }
3193 +    } else
3194 +      thd->cpu_time = 0;
3195 +  }
3196 +  // Updates THD stats and the global user stats.
3197 +  thd->update_stats(true);
3198 +  update_global_user_stats(thd, true, time(NULL));
3199 +
3200    DBUG_VOID_RETURN;
3201  }
3202  
3203 @@ -7532,8 +8075,35 @@
3204     pthread_mutex_unlock(&LOCK_active_mi);
3205   }
3206  #endif
3207 - if (options & REFRESH_USER_RESOURCES)
3208 -   reset_mqh((LEX_USER *) NULL);
3209 +  if (options & REFRESH_TABLE_STATS)
3210 +  {
3211 +    pthread_mutex_lock(&LOCK_global_table_stats);
3212 +    free_global_table_stats();
3213 +    init_global_table_stats();
3214 +    pthread_mutex_unlock(&LOCK_global_table_stats);
3215 +  }
3216 +  if (options & REFRESH_INDEX_STATS)
3217 +  {
3218 +    pthread_mutex_lock(&LOCK_global_index_stats);
3219 +    free_global_index_stats();
3220 +    init_global_index_stats();
3221 +    pthread_mutex_unlock(&LOCK_global_index_stats);
3222 +  }
3223 +  if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
3224 +  {
3225 +    pthread_mutex_lock(&LOCK_global_user_client_stats);
3226 +    if (options & REFRESH_USER_STATS)
3227 +    {
3228 +      free_global_user_stats();
3229 +      init_global_user_stats();
3230 +    }
3231 +    if (options & REFRESH_CLIENT_STATS)
3232 +    {
3233 +      free_global_client_stats();
3234 +      init_global_client_stats();
3235 +    }
3236 +    pthread_mutex_unlock(&LOCK_global_user_client_stats);
3237 +  }
3238   *write_to_binlog= tmp_write_to_binlog;
3239   return result;
3240  }
3241 diff -r 1ac0113deff5 sql/sql_prepare.cc
3242 --- a/sql/sql_prepare.cc        Mon Jun 01 00:35:44 2009 -0700
3243 +++ b/sql/sql_prepare.cc        Mon Jun 01 00:36:01 2009 -0700
3244 @@ -81,6 +81,9 @@
3245  #include <mysql_com.h>
3246  #endif
3247  
3248 +// Uses the THD to update the global stats by user name and client IP
3249 +void update_global_user_stats(THD* thd, bool create_user, time_t now);
3250 +
3251  /* A result class used to send cursor rows using the binary protocol. */
3252  
3253  class Select_fetch_protocol_prep: public select_send
3254 @@ -1910,8 +1913,32 @@
3255    /* First of all clear possible warnings from the previous command */
3256    mysql_reset_thd_for_next_command(thd);
3257  
3258 +  int start_time_error = 0;
3259 +  int end_time_error = 0;
3260 +  struct timeval start_time, end_time;
3261 +  double start_usecs = 0;
3262 +  double end_usecs = 0;
3263 +  /* cpu time */
3264 +  int cputime_error = 0;
3265 +  struct timespec tp;
3266 +  double start_cpu_nsecs = 0;
3267 +  double end_cpu_nsecs = 0;
3268 +
3269 +  if (opt_userstat_running) {
3270 +#ifdef HAVE_CLOCK_GETTIME
3271 +    /* get start cputime */
3272 +    if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3273 +      start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3274 +#endif
3275 +
3276 +    // Gets the start time, in order to measure how long this command takes.
3277 +    if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3278 +      start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3279 +    }
3280 +  }
3281 +
3282    if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
3283 -    DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
3284 +    goto end; /* out of memory: error is set in Sql_alloc */
3285  
3286    if (thd->stmt_map.insert(thd, stmt))
3287    {
3288 @@ -1919,7 +1946,7 @@
3289        The error is set in the insert. The statement itself
3290        will be also deleted there (this is how the hash works).
3291      */
3292 -    DBUG_VOID_RETURN;
3293 +    goto end;
3294    }
3295  
3296    /* Reset warnings from previous command */
3297 @@ -1941,6 +1968,44 @@
3298      thd->stmt_map.erase(stmt);
3299    }
3300    /* check_prepared_statemnt sends the metadata packet in case of success */
3301 +end:
3302 +  if (opt_userstat_running) {
3303 +    // Gets the end time.
3304 +    if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3305 +      end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3306 +    }
3307 +
3308 +    // Calculates the difference between the end and start times.
3309 +    if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3310 +      thd->busy_time = (end_usecs - start_usecs) / 1000000;
3311 +      // In case there are bad values, 2629743 is the #seconds in a month.
3312 +      if (thd->busy_time > 2629743) {
3313 +        thd->busy_time = 0;
3314 +      }
3315 +    } else {
3316 +      // end time went back in time, or gettimeofday() failed.
3317 +      thd->busy_time = 0;
3318 +    }
3319 +
3320 +#ifdef HAVE_CLOCK_GETTIME
3321 +    /* get end cputime */
3322 +    if (!cputime_error &&
3323 +        !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3324 +      end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3325 +#endif
3326 +    if (start_cpu_nsecs && !cputime_error) {
3327 +      thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3328 +      // In case there are bad values, 2629743 is the #seconds in a month.
3329 +      if (thd->cpu_time > 2629743) {
3330 +        thd->cpu_time = 0;
3331 +      }
3332 +    } else
3333 +      thd->cpu_time = 0;
3334 +  }
3335 +  // Updates THD stats and the global user stats.
3336 +  thd->update_stats(true);
3337 +  update_global_user_stats(thd, true, time(NULL));
3338 +
3339    DBUG_VOID_RETURN;
3340  }
3341  
3342 @@ -2281,8 +2346,32 @@
3343    /* First of all clear possible warnings from the previous command */
3344    mysql_reset_thd_for_next_command(thd);
3345  
3346 +  int start_time_error = 0;
3347 +  int end_time_error = 0;
3348 +  struct timeval start_time, end_time;
3349 +  double start_usecs = 0;
3350 +  double end_usecs = 0;
3351 +  /* cpu time */
3352 +  int cputime_error = 0;
3353 +  struct timespec tp;
3354 +  double start_cpu_nsecs = 0;
3355 +  double end_cpu_nsecs = 0;
3356 +
3357 +  if (opt_userstat_running) {
3358 +#ifdef HAVE_CLOCK_GETTIME
3359 +    /* get start cputime */
3360 +    if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3361 +      start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3362 +#endif
3363 +
3364 +    // Gets the start time, in order to measure how long this command takes.
3365 +    if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3366 +      start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3367 +    }
3368 +  }
3369 +
3370    if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
3371 -    DBUG_VOID_RETURN;
3372 +    goto end;
3373  
3374  #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
3375    thd->profiling.set_query_source(stmt->query, stmt->query_length);
3376 @@ -2325,11 +2414,50 @@
3377                         test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
3378    if (!(specialflag & SPECIAL_NO_PRIOR))
3379      my_pthread_setprio(pthread_self(), WAIT_PRIOR);
3380 -  DBUG_VOID_RETURN;
3381 +  goto end;
3382  
3383  set_params_data_err:
3384    my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
3385    reset_stmt_params(stmt);
3386 +
3387 +end:
3388 +  if (opt_userstat_running) {
3389 +    // Gets the end time.
3390 +    if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3391 +      end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3392 +    }
3393 +
3394 +    // Calculates the difference between the end and start times.
3395 +    if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3396 +      thd->busy_time = (end_usecs - start_usecs) / 1000000;
3397 +      // In case there are bad values, 2629743 is the #seconds in a month.
3398 +      if (thd->busy_time > 2629743) {
3399 +        thd->busy_time = 0;
3400 +      }
3401 +    } else {
3402 +      // end time went back in time, or gettimeofday() failed.
3403 +      thd->busy_time = 0;
3404 +    }
3405 +
3406 +#ifdef HAVE_CLOCK_GETTIME
3407 +    /* get end cputime */
3408 +    if (!cputime_error &&
3409 +        !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3410 +      end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3411 +#endif
3412 +    if (start_cpu_nsecs && !cputime_error) {
3413 +      thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3414 +      // In case there are bad values, 2629743 is the #seconds in a month.
3415 +      if (thd->cpu_time > 2629743) {
3416 +        thd->cpu_time = 0;
3417 +      }
3418 +    } else
3419 +      thd->cpu_time = 0;
3420 +  }
3421 +  // Updates THD stats and the global user stats.
3422 +  thd->update_stats(true);
3423 +  update_global_user_stats(thd, true, time(NULL));
3424 +
3425    DBUG_VOID_RETURN;
3426  }
3427  
3428 @@ -2423,6 +2551,31 @@
3429  
3430    /* First of all clear possible warnings from the previous command */
3431    mysql_reset_thd_for_next_command(thd);
3432 +
3433 +  int start_time_error = 0;
3434 +  int end_time_error = 0;
3435 +  struct timeval start_time, end_time;
3436 +  double start_usecs = 0;
3437 +  double end_usecs = 0;
3438 +  /* cpu time */
3439 +  int cputime_error = 0;
3440 +  struct timespec tp;
3441 +  double start_cpu_nsecs = 0;
3442 +  double end_cpu_nsecs = 0;
3443 +
3444 +  if (opt_userstat_running) {
3445 +#ifdef HAVE_CLOCK_GETTIME
3446 +    /* get start cputime */
3447 +    if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3448 +      start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3449 +#endif
3450 +
3451 +    // Gets the start time, in order to measure how long this command takes.
3452 +    if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3453 +      start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3454 +    }
3455 +  }
3456 +
3457    statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
3458    if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
3459      DBUG_VOID_RETURN;
3460 @@ -2455,6 +2608,43 @@
3461    thd->restore_backup_statement(stmt, &stmt_backup);
3462    thd->stmt_arena= thd;
3463  
3464 +  if (opt_userstat_running) {
3465 +    // Gets the end time.
3466 +    if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3467 +      end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3468 +    }
3469 +
3470 +    // Calculates the difference between the end and start times.
3471 +    if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3472 +      thd->busy_time = (end_usecs - start_usecs) / 1000000;
3473 +      // In case there are bad values, 2629743 is the #seconds in a month.
3474 +      if (thd->busy_time > 2629743) {
3475 +        thd->busy_time = 0;
3476 +      }
3477 +    } else {
3478 +      // end time went back in time, or gettimeofday() failed.
3479 +      thd->busy_time = 0;
3480 +    }
3481 +
3482 +#ifdef HAVE_CLOCK_GETTIME
3483 +    /* get end cputime */
3484 +    if (!cputime_error &&
3485 +        !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3486 +      end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3487 +#endif
3488 +    if (start_cpu_nsecs && !cputime_error) {
3489 +      thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3490 +      // In case there are bad values, 2629743 is the #seconds in a month.
3491 +      if (thd->cpu_time > 2629743) {
3492 +        thd->cpu_time = 0;
3493 +      }
3494 +    } else
3495 +      thd->cpu_time = 0;
3496 +  }
3497 +  // Updates THD stats and the global user stats.
3498 +  thd->update_stats(true);
3499 +  update_global_user_stats(thd, true, time(NULL));
3500 +
3501    DBUG_VOID_RETURN;
3502  }
3503  
3504 @@ -2487,6 +2677,30 @@
3505    /* First of all clear possible warnings from the previous command */
3506    mysql_reset_thd_for_next_command(thd);
3507  
3508 +  int start_time_error = 0;
3509 +  int end_time_error = 0;
3510 +  struct timeval start_time, end_time;
3511 +  double start_usecs = 0;
3512 +  double end_usecs = 0;
3513 +  /* cpu time */
3514 +  int cputime_error = 0;
3515 +  struct timespec tp;
3516 +  double start_cpu_nsecs = 0;
3517 +  double end_cpu_nsecs = 0;
3518 +
3519 +  if (opt_userstat_running) {
3520 +#ifdef HAVE_CLOCK_GETTIME
3521 +    /* get start cputime */
3522 +    if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3523 +      start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3524 +#endif
3525 +
3526 +    // Gets the start time, in order to measure how long this command takes.
3527 +    if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3528 +      start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3529 +    }
3530 +  }
3531 +
3532    statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
3533    if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
3534      DBUG_VOID_RETURN;
3535 @@ -2503,6 +2717,43 @@
3536  
3537    send_ok(thd);
3538  
3539 +  if (opt_userstat_running) {
3540 +    // Gets the end time.
3541 +    if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3542 +      end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3543 +    }
3544 +
3545 +    // Calculates the difference between the end and start times.
3546 +    if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3547 +      thd->busy_time = (end_usecs - start_usecs) / 1000000;
3548 +      // In case there are bad values, 2629743 is the #seconds in a month.
3549 +      if (thd->busy_time > 2629743) {
3550 +        thd->busy_time = 0;
3551 +      }
3552 +    } else {
3553 +      // end time went back in time, or gettimeofday() failed.
3554 +      thd->busy_time = 0;
3555 +    }
3556 +
3557 +#ifdef HAVE_CLOCK_GETTIME
3558 +    /* get end cputime */
3559 +    if (!cputime_error &&
3560 +        !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3561 +      end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3562 +#endif
3563 +    if (start_cpu_nsecs && !cputime_error) {
3564 +      thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3565 +      // In case there are bad values, 2629743 is the #seconds in a month.
3566 +      if (thd->cpu_time > 2629743) {
3567 +        thd->cpu_time = 0;
3568 +      }
3569 +    } else
3570 +      thd->cpu_time = 0;
3571 +  }
3572 +  // Updates THD stats and the global user stats.
3573 +  thd->update_stats(true);
3574 +  update_global_user_stats(thd, true, time(NULL));
3575 +
3576    DBUG_VOID_RETURN;
3577  }
3578  
3579 diff -r 1ac0113deff5 sql/sql_show.cc
3580 --- a/sql/sql_show.cc   Mon Jun 01 00:35:44 2009 -0700
3581 +++ b/sql/sql_show.cc   Mon Jun 01 00:36:01 2009 -0700
3582 @@ -540,6 +540,7 @@
3583                 sctx->master_access);
3584    if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
3585    {
3586 +    thd->diff_access_denied_errors++;
3587      my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3588               sctx->priv_user, sctx->host_or_ip, dbname);
3589      mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
3590 @@ -1890,6 +1891,300 @@
3591    DBUG_RETURN(FALSE);
3592  }
3593  
3594 +/*
3595 +   Aggregate values for mapped_user entries by their role.
3596 +
3597 +   SYNOPSIS
3598 +     aggregate_user_stats
3599 +       all_user_stats - input to aggregate
3600 +       agg_user_stats - returns aggregated values
3601 +
3602 +   RETURN
3603 +     0 - OK
3604 +     1 - error
3605 + */
3606 +static int
3607 +aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
3608 +{
3609 +  DBUG_ENTER("aggregate_user_stats");
3610 +  if (hash_init(agg_user_stats, system_charset_info,
3611 +                max(all_user_stats->records, 1),
3612 +                0, 0, (hash_get_key)get_key_user_stats,
3613 +                (hash_free_key)free_user_stats, 0))
3614 +  {
3615 +    sql_print_error("Malloc in aggregate_user_stats failed");
3616 +    DBUG_RETURN(1);
3617 +  }
3618 +
3619 +  for (int i = 0; i < all_user_stats->records; ++i) {
3620 +    USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
3621 +    USER_STATS *agg_user;
3622 +    if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
3623 +                                              (byte*)user->priv_user,
3624 +                                              strlen(user->priv_user))))
3625 +    {
3626 +      // First entry for this role.
3627 +      if (!(agg_user =
3628 +            (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
3629 +      {
3630 +        sql_print_error("Malloc in aggregate_user_stats failed");
3631 +        DBUG_RETURN(1);
3632 +      }
3633 +
3634 +      init_user_stats(agg_user, user->priv_user, user->priv_user,
3635 +                      user->total_connections, user->concurrent_connections,
3636 +                      user->connected_time, user->busy_time, user->cpu_time,
3637 +                      user->bytes_received, user->bytes_sent,
3638 +                      user->binlog_bytes_written,
3639 +                      user->rows_fetched, user->rows_updated, user->rows_read,
3640 +                      user->select_commands, user->update_commands,
3641 +                      user->other_commands,
3642 +                      user->commit_trans, user->rollback_trans,
3643 +                      user->denied_connections, user->lost_connections,
3644 +                      user->access_denied_errors, user->empty_queries);
3645 +
3646 +      if (my_hash_insert(agg_user_stats, (byte*)agg_user))
3647 +      {
3648 +        // Out of memory.
3649 +        my_free((char*)agg_user, 0);
3650 +        sql_print_error("Malloc in aggregate_user_stats failed");
3651 +        DBUG_RETURN(1);
3652 +      }
3653 +    }
3654 +    else
3655 +    {
3656 +      // Aggregate with existing values for this role.
3657 +      add_user_stats(agg_user,
3658 +                     user->total_connections, user->concurrent_connections,
3659 +                     user->connected_time, user->busy_time, user->cpu_time,
3660 +                     user->bytes_received, user->bytes_sent,
3661 +                     user->binlog_bytes_written,
3662 +                     user->rows_fetched, user->rows_updated, user->rows_read,
3663 +                     user->select_commands, user->update_commands,
3664 +                     user->other_commands,
3665 +                     user->commit_trans, user->rollback_trans,
3666 +                     user->denied_connections, user->lost_connections,
3667 +                     user->access_denied_errors, user->empty_queries);
3668 +    }
3669 +  }
3670 +  DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
3671 +                      all_user_stats->records, agg_user_stats->records));
3672 +  DBUG_RETURN(0);
3673 +}
3674 +
3675 +/*
3676 +   Write result to network for SHOW USER_STATISTICS
3677 +
3678 +   SYNOPSIS
3679 +     send_user_stats
3680 +       all_user_stats - values to return
3681 +       table - I_S table
3682 +
3683 +   RETURN
3684 +     0 - OK
3685 +     1 - error
3686 + */
3687 +int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
3688 +{
3689 +  DBUG_ENTER("send_user_stats");
3690 +  for (int i = 0; i < all_user_stats->records; ++i) {
3691 +    restore_record(table, s->default_values);
3692 +    USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
3693 +      table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
3694 +      table->field[1]->store((longlong)user_stats->total_connections);
3695 +      table->field[2]->store((longlong)user_stats->concurrent_connections);
3696 +      table->field[3]->store((longlong)user_stats->connected_time);
3697 +      table->field[4]->store((longlong)user_stats->busy_time);
3698 +      table->field[5]->store((longlong)user_stats->cpu_time);
3699 +      table->field[6]->store((longlong)user_stats->bytes_received);
3700 +      table->field[7]->store((longlong)user_stats->bytes_sent);
3701 +      table->field[8]->store((longlong)user_stats->binlog_bytes_written);
3702 +      table->field[9]->store((longlong)user_stats->rows_fetched);
3703 +      table->field[10]->store((longlong)user_stats->rows_updated);
3704 +      table->field[11]->store((longlong)user_stats->rows_read);
3705 +      table->field[12]->store((longlong)user_stats->select_commands);
3706 +      table->field[13]->store((longlong)user_stats->update_commands);
3707 +      table->field[14]->store((longlong)user_stats->other_commands);
3708 +      table->field[15]->store((longlong)user_stats->commit_trans);
3709 +      table->field[16]->store((longlong)user_stats->rollback_trans);
3710 +      table->field[17]->store((longlong)user_stats->denied_connections);
3711 +      table->field[18]->store((longlong)user_stats->lost_connections);
3712 +      table->field[19]->store((longlong)user_stats->access_denied_errors);
3713 +      table->field[20]->store((longlong)user_stats->empty_queries);
3714 +      if (schema_table_store_record(thd, table))
3715 +      {
3716 +             DBUG_PRINT("error", ("store record error"));
3717 +             DBUG_RETURN(1);
3718 +      }
3719 +  }
3720 +  DBUG_RETURN(0);
3721 +}
3722 +
3723 +/*
3724 +   Process SHOW USER_STATISTICS
3725 +
3726 +   SYNOPSIS
3727 +     mysqld_show_user_stats
3728 +       thd - current thread
3729 +       wild - limit results to the entry for this user
3730 +       with_roles - when true, display role for mapped users
3731 +
3732 +   RETURN
3733 +     0 - OK
3734 +     1 - error
3735 + */
3736 +
3737 +
3738 +int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3739 +{
3740 +  TABLE *table= tables->table;
3741 +  DBUG_ENTER("fill_schema_user_stats");
3742 +
3743 +  if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
3744 +          DBUG_RETURN(1);
3745 +
3746 +  // Iterates through all the global stats and sends them to the client.
3747 +  // Pattern matching on the client IP is supported.
3748 +
3749 +  pthread_mutex_lock(&LOCK_global_user_client_stats);
3750 +  int result= send_user_stats(thd, &global_user_stats, table);
3751 +  pthread_mutex_unlock(&LOCK_global_user_client_stats);
3752 +  if (result)
3753 +    goto err;
3754 +
3755 +  DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
3756 +  DBUG_RETURN(0);
3757 +
3758 + err:
3759 +  DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
3760 +  DBUG_RETURN(1);
3761 +}
3762 +
3763 +/*
3764 +   Process SHOW CLIENT_STATISTICS
3765 +
3766 +   SYNOPSIS
3767 +     mysqld_show_client_stats
3768 +       thd - current thread
3769 +       wild - limit results to the entry for this client
3770 +
3771 +   RETURN
3772 +     0 - OK
3773 +     1 - error
3774 + */
3775 +
3776 +
3777 +int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3778 +{
3779 +  TABLE *table= tables->table;
3780 +  DBUG_ENTER("fill_schema_client_stats");
3781 +
3782 +  if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
3783 +          DBUG_RETURN(1);
3784 +
3785 +  // Iterates through all the global stats and sends them to the client.
3786 +  // Pattern matching on the client IP is supported.
3787 +
3788 +  pthread_mutex_lock(&LOCK_global_user_client_stats);
3789 +  int result= send_user_stats(thd, &global_client_stats, table);
3790 +  pthread_mutex_unlock(&LOCK_global_user_client_stats);
3791 +  if (result)
3792 +    goto err;
3793 +
3794 +  DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
3795 +  DBUG_RETURN(0);
3796 +
3797 + err:
3798 +  DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
3799 +  DBUG_RETURN(1);
3800 +}
3801 +
3802 +
3803 +// Sends the global table stats back to the client.
3804 +int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3805 +{
3806 +  TABLE *table= tables->table;
3807 +  DBUG_ENTER("fill_schema_table_stats");
3808 +  char *table_full_name, *table_schema;
3809 +
3810 +  pthread_mutex_lock(&LOCK_global_table_stats);
3811 +  for (int i = 0; i < global_table_stats.records; ++i) {
3812 +    restore_record(table, s->default_values);
3813 +    TABLE_STATS *table_stats = 
3814 +      (TABLE_STATS*)hash_element(&global_table_stats, i);
3815 +
3816 +    table_full_name= thd->strdup(table_stats->table);
3817 +    table_schema= strsep(&table_full_name, ".");
3818 +
3819 +    TABLE_LIST tmp_table;
3820 +    bzero((char*) &tmp_table,sizeof(tmp_table));
3821 +    tmp_table.table_name= table_full_name;
3822 +    tmp_table.db= table_schema;
3823 +    tmp_table.grant.privilege= 0;
3824 +    if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
3825 +                      &tmp_table.grant.privilege, 0, 0,
3826 +                      is_schema_db(table_schema)) ||
3827 +         grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
3828 +        continue;
3829 +
3830 +    table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
3831 +    table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
3832 +    table->field[2]->store((longlong)table_stats->rows_read, TRUE);
3833 +    table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
3834 +    table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
3835 +
3836 +    if (schema_table_store_record(thd, table))
3837 +    {
3838 +      VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
3839 +      DBUG_RETURN(1);
3840 +    }
3841 +  }
3842 +  pthread_mutex_unlock(&LOCK_global_table_stats);
3843 +  DBUG_RETURN(0);
3844 +}
3845 +
3846 +// Sends the global index stats back to the client.
3847 +int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3848 +{
3849 +  TABLE *table= tables->table;
3850 +  DBUG_ENTER("fill_schema_index_stats");
3851 +  char *index_full_name, *table_schema, *table_name;
3852 +
3853 +  pthread_mutex_lock(&LOCK_global_index_stats);
3854 +  for (int i = 0; i < global_index_stats.records; ++i) {
3855 +    restore_record(table, s->default_values);
3856 +    INDEX_STATS *index_stats =
3857 +      (INDEX_STATS*)hash_element(&global_index_stats, i);
3858 +
3859 +    index_full_name= thd->strdup(index_stats->index);
3860 +    table_schema= strsep(&index_full_name, ".");
3861 +    table_name= strsep(&index_full_name, ".");
3862 +
3863 +    TABLE_LIST tmp_table;
3864 +    bzero((char*) &tmp_table,sizeof(tmp_table));
3865 +    tmp_table.table_name= table_name;
3866 +    tmp_table.db= table_schema;
3867 +    tmp_table.grant.privilege= 0;
3868 +    if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
3869 +                      &tmp_table.grant.privilege, 0, 0,
3870 +                      is_schema_db(table_schema)) ||
3871 +         grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
3872 +        continue;
3873 +
3874 +    table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
3875 +    table->field[1]->store(table_name, strlen(table_name), system_charset_info);
3876 +    table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
3877 +    table->field[3]->store((longlong)index_stats->rows_read, TRUE);
3878 +
3879 +    if (schema_table_store_record(thd, table))
3880 +    { 
3881 +      VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
3882 +      DBUG_RETURN(1);
3883 +    }
3884 +  }
3885 +  pthread_mutex_unlock(&LOCK_global_index_stats);
3886 +  DBUG_RETURN(0);
3887 +}
3888  
3889  /* collect status for all running threads */
3890  
3891 @@ -4500,6 +4795,77 @@
3892    {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3893  };
3894  
3895 +ST_FIELD_INFO user_stats_fields_info[]=
3896 +{
3897 +  {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
3898 +  {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
3899 +  {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
3900 +  {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
3901 +  {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
3902 +  {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
3903 +  {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
3904 +  {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
3905 +  {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
3906 +  {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
3907 +  {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
3908 +  {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
3909 +  {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
3910 +  {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
3911 +  {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
3912 +  {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
3913 +  {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
3914 +  {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
3915 +  {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
3916 +  {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
3917 +  {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
3918 +  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3919 +};
3920 +
3921 +ST_FIELD_INFO client_stats_fields_info[]=
3922 +{
3923 +  {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
3924 +  {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
3925 +  {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
3926 +  {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
3927 +  {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
3928 +  {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
3929 +  {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
3930 +  {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
3931 +  {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
3932 +  {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
3933 +  {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
3934 +  {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
3935 +  {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
3936 +  {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
3937 +  {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
3938 +  {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
3939 +  {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
3940 +  {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
3941 +  {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
3942 +  {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
3943 +  {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
3944 +  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3945 +};
3946 +
3947 +
3948 +ST_FIELD_INFO table_stats_fields_info[]=
3949 +{
3950 +  {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
3951 +  {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
3952 +  {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
3953 +  {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
3954 +  {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
3955 +  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3956 +};
3957 +
3958 +ST_FIELD_INFO index_stats_fields_info[]=
3959 +{
3960 +  {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
3961 +  {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
3962 +  {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
3963 +  {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
3964 +  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3965 +};
3966  
3967  /*
3968    Description of ST_FIELD_INFO in table.h
3969 @@ -4509,6 +4875,8 @@
3970  {
3971    {"CHARACTER_SETS", charsets_fields_info, create_schema_table, 
3972     fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
3973 +  {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table, 
3974 +    fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
3975    {"COLLATIONS", collation_fields_info, create_schema_table, 
3976     fill_schema_collation, make_old_format, 0, -1, -1, 0},
3977    {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
3978 @@ -4517,6 +4885,8 @@
3979     get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
3980    {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
3981      fill_schema_column_privileges, 0, 0, -1, -1, 0},
3982 +  {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
3983 +   fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
3984    {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
3985      get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
3986    {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
3987 @@ -4542,10 +4912,14 @@
3988     get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
3989    {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
3990      fill_schema_table_privileges, 0, 0, -1, -1, 0},
3991 +  {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
3992 +    fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
3993    {"TRIGGERS", triggers_fields_info, create_schema_table,
3994     get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
3995    {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table, 
3996      fill_schema_user_privileges, 0, 0, -1, -1, 0},
3997 +  {"USER_STATISTICS", user_stats_fields_info, create_schema_table, 
3998 +    fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
3999    {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
4000     make_old_format, 0, -1, -1, 1},
4001    {"VIEWS", view_fields_info, create_schema_table, 
4002 diff -r 1ac0113deff5 sql/sql_update.cc
4003 --- a/sql/sql_update.cc Mon Jun 01 00:35:44 2009 -0700
4004 +++ b/sql/sql_update.cc Mon Jun 01 00:36:01 2009 -0700
4005 @@ -604,7 +604,8 @@
4006        (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
4007      send_ok(thd, (ulong) thd->row_count_func,
4008             thd->insert_id_used ? thd->last_insert_id : 0L,buff);
4009 -    DBUG_PRINT("info",("%ld records updated", (long) updated));
4010 +    thd->updated_row_count += thd->row_count_func;
4011 +    DBUG_PRINT("info",("%d records updated",updated));
4012    }
4013    thd->count_cuted_fields= CHECK_FIELD_IGNORE;         /* calc cuted fields */
4014    thd->abort_on_warning= 0;
4015 @@ -1835,5 +1836,6 @@
4016      (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
4017    ::send_ok(thd, (ulong) thd->row_count_func,
4018             thd->insert_id_used ? thd->last_insert_id : 0L,buff);
4019 +  thd->updated_row_count += thd->row_count_func;
4020    return FALSE;
4021  }
4022 diff -r 1ac0113deff5 sql/sql_yacc.yy
4023 --- a/sql/sql_yacc.yy   Mon Jun 01 00:35:44 2009 -0700
4024 +++ b/sql/sql_yacc.yy   Mon Jun 01 00:36:01 2009 -0700
4025 @@ -523,6 +523,7 @@
4026  %token  CHECK_SYM
4027  %token  CIPHER_SYM
4028  %token  CLIENT_SYM
4029 +%token CLIENT_STATS_SYM
4030  %token  CLOSE_SYM
4031  %token  COALESCE
4032  %token  CODE_SYM
4033 @@ -680,6 +681,7 @@
4034  %token  IMPORT
4035  %token  INDEXES
4036  %token  INDEX_SYM
4037 +%token INDEX_STATS_SYM
4038  %token  INFILE
4039  %token  INNER_SYM
4040  %token  INNOBASE_SYM
4041 @@ -909,6 +911,7 @@
4042  %token  SIGNED_SYM
4043  %token  SIMPLE_SYM
4044  %token  SLAVE
4045 +%token  SLOW_SYM
4046  %token  SMALLINT
4047  %token  SNAPSHOT_SYM
4048  %token  SOUNDS_SYM
4049 @@ -949,6 +952,7 @@
4050  %token  TABLES
4051  %token  TABLESPACE
4052  %token  TABLE_SYM
4053 +%token TABLE_STATS_SYM
4054  %token  TEMPORARY
4055  %token  TEMPTABLE_SYM
4056  %token  TERMINATED
4057 @@ -991,6 +995,7 @@
4058  %token  UPGRADE_SYM
4059  %token  USAGE
4060  %token  USER
4061 +%token USER_STATS_SYM
4062  %token  USE_FRM
4063  %token  USE_SYM
4064  %token  USING
4065 @@ -8255,6 +8260,38 @@
4066            {
4067             Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
4068            }
4069 +        | CLIENT_STATS_SYM wild_and_where 
4070 +          {
4071 +           LEX *lex= Lex;
4072 +          Lex->sql_command = SQLCOM_SELECT;
4073 +           lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
4074 +           if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
4075 +             MYSQL_YYABORT;
4076 +          }
4077 +        | USER_STATS_SYM wild_and_where 
4078 +          {
4079 +           LEX *lex= Lex;
4080 +          lex->sql_command = SQLCOM_SELECT;
4081 +           lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
4082 +           if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
4083 +             MYSQL_YYABORT;
4084 +          }
4085 +        | TABLE_STATS_SYM wild_and_where
4086 +          {
4087 +           LEX *lex= Lex;
4088 +           lex->sql_command= SQLCOM_SELECT;
4089 +           lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
4090 +           if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
4091 +             MYSQL_YYABORT;
4092 +          }
4093 +        | INDEX_STATS_SYM wild_and_where
4094 +          {
4095 +           LEX *lex= Lex;
4096 +           lex->sql_command= SQLCOM_SELECT;
4097 +           lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
4098 +           if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
4099 +             MYSQL_YYABORT;
4100 +          }
4101         | CREATE PROCEDURE sp_name
4102           {
4103             LEX *lex= Lex;
4104 @@ -8459,9 +8496,14 @@
4105         | LOGS_SYM      { Lex->type|= REFRESH_LOG; }
4106         | STATUS_SYM    { Lex->type|= REFRESH_STATUS; }
4107          | SLAVE         { Lex->type|= REFRESH_SLAVE; }
4108 +       | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
4109          | MASTER_SYM    { Lex->type|= REFRESH_MASTER; }
4110         | DES_KEY_FILE  { Lex->type|= REFRESH_DES_KEY_FILE; }
4111 -       | RESOURCES     { Lex->type|= REFRESH_USER_RESOURCES; };
4112 +       | RESOURCES     { Lex->type|= REFRESH_USER_RESOURCES; }
4113 +       | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
4114 +       | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
4115 +       | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
4116 +       | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
4117  
4118  opt_table_list:
4119         /* empty */  {;}
4120 @@ -9450,6 +9492,7 @@
4121         | CHAIN_SYM             {}
4122         | CHANGED               {}
4123         | CIPHER_SYM            {}
4124 +       | CLIENT_STATS_SYM      {}
4125         | CLIENT_SYM            {}
4126          | CODE_SYM              {}
4127         | COLLATION_SYM         {}
4128 @@ -9502,6 +9545,7 @@
4129         | HOSTS_SYM             {}
4130         | HOUR_SYM              {}
4131         | IDENTIFIED_SYM        {}
4132 +       | INDEX_STATS_SYM       {}
4133         | INVOKER_SYM           {}
4134         | IMPORT                {}
4135         | INDEXES               {}
4136 @@ -9611,6 +9655,7 @@
4137         | SIMPLE_SYM            {}
4138         | SHARE_SYM             {}
4139         | SHUTDOWN              {}
4140 +       | SLOW_SYM              {}
4141         | SNAPSHOT_SYM          {}
4142         | SOUNDS_SYM            {}
4143         | SOURCE_SYM            {}
4144 @@ -9627,6 +9672,7 @@
4145          | SUSPEND_SYM           {}
4146          | SWAPS_SYM             {}
4147         | SWITCHES_SYM          {}
4148 +       | TABLE_STATS_SYM       {}
4149          | TABLES                {}
4150         | TABLESPACE            {}
4151         | TEMPORARY             {}
4152 @@ -9647,6 +9693,7 @@
4153         | UNKNOWN_SYM           {}
4154         | UNTIL_SYM             {}
4155         | USER                  {}
4156 +       | USER_STATS_SYM        {}
4157         | USE_FRM               {}
4158         | VARIABLES             {}
4159         | VIEW_SYM              {}
4160 diff -r 1ac0113deff5 sql/structs.h
4161 --- a/sql/structs.h     Mon Jun 01 00:35:44 2009 -0700
4162 +++ b/sql/structs.h     Mon Jun 01 00:36:01 2009 -0700
4163 @@ -273,6 +273,98 @@
4164    time_t intime;
4165  } USER_CONN;
4166  
4167 +typedef struct st_user_stats {
4168 +  char user[USERNAME_LENGTH + 1];
4169 +  // Account name the user is mapped to when this is a user from mapped_user.
4170 +  // Otherwise, the same value as user.
4171 +  char priv_user[USERNAME_LENGTH + 1];
4172 +  uint total_connections;
4173 +  uint concurrent_connections;
4174 +  time_t connected_time;  // in seconds
4175 +  double busy_time;       // in seconds
4176 +  double cpu_time;        // in seconds
4177 +  ulonglong bytes_received;
4178 +  ulonglong bytes_sent;
4179 +  ulonglong binlog_bytes_written;
4180 +  ha_rows rows_fetched, rows_updated, rows_read;
4181 +  ulonglong select_commands, update_commands, other_commands;
4182 +  ulonglong commit_trans, rollback_trans;
4183 +  ulonglong denied_connections, lost_connections;
4184 +  ulonglong access_denied_errors;
4185 +  ulonglong empty_queries;
4186 +} USER_STATS;
4187 +
4188 +/* Lookup function for hash tables with USER_STATS entries */
4189 +extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
4190 +                                my_bool not_used __attribute__((unused)));
4191 +
4192 +/* Free all memory for a hash table with USER_STATS entries */
4193 +extern void free_user_stats(USER_STATS* user_stats);
4194 +
4195 +/* Intialize an instance of USER_STATS */
4196 +extern void
4197 +init_user_stats(USER_STATS *user_stats,
4198 +                const char *user,
4199 +                const char *priv_user,
4200 +                uint total_connections,
4201 +                uint concurrent_connections,
4202 +                time_t connected_time,
4203 +                double busy_time,
4204 +                double cpu_time,
4205 +                ulonglong bytes_received,
4206 +                ulonglong bytes_sent,
4207 +                ulonglong binlog_bytes_written,
4208 +                ha_rows rows_fetched,
4209 +                ha_rows rows_updated,
4210 +                ha_rows rows_read,
4211 +                ulonglong select_commands,
4212 +                ulonglong update_commands,
4213 +                ulonglong other_commands,
4214 +                ulonglong commit_trans,
4215 +                ulonglong rollback_trans,
4216 +                ulonglong denied_connections,
4217 +                ulonglong lost_connections,
4218 +                ulonglong access_denied_errors,
4219 +                ulonglong empty_queries);
4220 +
4221 +/* Increment values of an instance of USER_STATS */
4222 +extern void
4223 +add_user_stats(USER_STATS *user_stats,
4224 +               uint total_connections,
4225 +               uint concurrent_connections,
4226 +               time_t connected_time,
4227 +               double busy_time,
4228 +               double cpu_time,
4229 +               ulonglong bytes_received,
4230 +               ulonglong bytes_sent,
4231 +               ulonglong binlog_bytes_written,
4232 +               ha_rows rows_fetched,
4233 +               ha_rows rows_updated,
4234 +               ha_rows rows_read,
4235 +               ulonglong select_commands,
4236 +               ulonglong update_commands,
4237 +               ulonglong other_commands,
4238 +               ulonglong commit_trans,
4239 +               ulonglong rollback_trans,
4240 +               ulonglong denied_connections,
4241 +               ulonglong lost_connections,
4242 +               ulonglong access_denied_errors,
4243 +               ulonglong empty_queries);
4244 +
4245 +typedef struct st_table_stats {
4246 +  char table[NAME_LEN * 2 + 2];  // [db] + '.' + [table] + '\0'
4247 +  ulonglong rows_read, rows_changed;
4248 +  ulonglong rows_changed_x_indexes;
4249 +  /* Stores enum db_type, but forward declarations cannot be done */
4250 +  int engine_type;
4251 +} TABLE_STATS;
4252 +
4253 +typedef struct st_index_stats {
4254 +  char index[NAME_LEN * 3 + 3];  // [db] + '.' + [table] + '.' + [index] + '\0'
4255 +  ulonglong rows_read;
4256 +} INDEX_STATS;
4257 +
4258 +
4259         /* Bits in form->update */
4260  #define REG_MAKE_DUPP          1       /* Make a copy of record when read */
4261  #define REG_NEW_RECORD         2       /* Write a new record if not found */
4262 diff -r 1ac0113deff5 sql/table.h
4263 --- a/sql/table.h       Mon Jun 01 00:35:44 2009 -0700
4264 +++ b/sql/table.h       Mon Jun 01 00:36:01 2009 -0700
4265 @@ -371,10 +371,12 @@
4266  enum enum_schema_tables
4267  {
4268    SCH_CHARSETS= 0,
4269 +  SCH_CLIENT_STATS,
4270    SCH_COLLATIONS,
4271    SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
4272    SCH_COLUMNS,
4273    SCH_COLUMN_PRIVILEGES,
4274 +  SCH_INDEX_STATS,
4275    SCH_KEY_COLUMN_USAGE,
4276    SCH_OPEN_TABLES,
4277    SCH_PROFILES,
4278 @@ -387,8 +389,10 @@
4279    SCH_TABLE_CONSTRAINTS,
4280    SCH_TABLE_NAMES,
4281    SCH_TABLE_PRIVILEGES,
4282 +  SCH_TABLE_STATS,
4283    SCH_TRIGGERS,
4284    SCH_USER_PRIVILEGES,
4285 +  SCH_USER_STATS,
4286    SCH_VARIABLES,
4287    SCH_VIEWS
4288  };
4289 diff -r 1ac0113deff5 strings/Makefile.in
4290 --- a/strings/Makefile.in       Mon Jun 01 00:35:44 2009 -0700
4291 +++ b/strings/Makefile.in       Mon Jun 01 00:36:01 2009 -0700
4292 @@ -342,6 +342,7 @@
4293  LIBDL = @LIBDL@
4294  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4295  LIBOBJS = @LIBOBJS@
4296 +LIBRT = @LIBRT@
4297  LIBS = @LIBS@
4298  LIBTOOL = @LIBTOOL@
4299  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4300 diff -r 1ac0113deff5 support-files/MacOSX/Makefile.in
4301 --- a/support-files/MacOSX/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
4302 +++ b/support-files/MacOSX/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
4303 @@ -148,6 +148,7 @@
4304  LIBDL = @LIBDL@
4305  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4306  LIBOBJS = @LIBOBJS@
4307 +LIBRT = @LIBRT@
4308  LIBS = @LIBS@
4309  LIBTOOL = @LIBTOOL@
4310  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4311 diff -r 1ac0113deff5 support-files/Makefile.in
4312 --- a/support-files/Makefile.in Mon Jun 01 00:35:44 2009 -0700
4313 +++ b/support-files/Makefile.in Mon Jun 01 00:36:01 2009 -0700
4314 @@ -171,6 +171,7 @@
4315  LIBDL = @LIBDL@
4316  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4317  LIBOBJS = @LIBOBJS@
4318 +LIBRT = @LIBRT@
4319  LIBS = @LIBS@
4320  LIBTOOL = @LIBTOOL@
4321  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4322 diff -r 1ac0113deff5 support-files/RHEL4-SElinux/Makefile.in
4323 --- a/support-files/RHEL4-SElinux/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
4324 +++ b/support-files/RHEL4-SElinux/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
4325 @@ -146,6 +146,7 @@
4326  LIBDL = @LIBDL@
4327  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4328  LIBOBJS = @LIBOBJS@
4329 +LIBRT = @LIBRT@
4330  LIBS = @LIBS@
4331  LIBTOOL = @LIBTOOL@
4332  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4333 diff -r 1ac0113deff5 tests/Makefile.in
4334 --- a/tests/Makefile.in Mon Jun 01 00:35:44 2009 -0700
4335 +++ b/tests/Makefile.in Mon Jun 01 00:36:01 2009 -0700
4336 @@ -193,6 +193,7 @@
4337  LIBDL = @LIBDL@
4338  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4339  LIBOBJS = @LIBOBJS@
4340 +LIBRT = @LIBRT@
4341  LIBS = @CLIENT_LIBS@
4342  LIBTOOL = @LIBTOOL@
4343  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4344 diff -r 1ac0113deff5 tools/Makefile.in
4345 --- a/tools/Makefile.in Mon Jun 01 00:35:44 2009 -0700
4346 +++ b/tools/Makefile.in Mon Jun 01 00:36:01 2009 -0700
4347 @@ -167,6 +167,7 @@
4348  LIBDL = @LIBDL@
4349  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4350  LIBOBJS = @LIBOBJS@
4351 +LIBRT = @LIBRT@
4352  LIBS = @LIBS@
4353  LIBTOOL = @LIBTOOL@
4354  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4355 diff -r 1ac0113deff5 vio/Makefile.in
4356 --- a/vio/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
4357 +++ b/vio/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
4358 @@ -176,6 +176,7 @@
4359  LIBDL = @LIBDL@
4360  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4361  LIBOBJS = @LIBOBJS@
4362 +LIBRT = @LIBRT@
4363  LIBS = @LIBS@
4364  LIBTOOL = @LIBTOOL@
4365  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4366 diff -r 1ac0113deff5 win/Makefile.in
4367 --- a/win/Makefile.in   Mon Jun 01 00:35:44 2009 -0700
4368 +++ b/win/Makefile.in   Mon Jun 01 00:36:01 2009 -0700
4369 @@ -144,6 +144,7 @@
4370  LIBDL = @LIBDL@
4371  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4372  LIBOBJS = @LIBOBJS@
4373 +LIBRT = @LIBRT@
4374  LIBS = @LIBS@
4375  LIBTOOL = @LIBTOOL@
4376  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4377 diff -r 1ac0113deff5 zlib/Makefile.in
4378 --- a/zlib/Makefile.in  Mon Jun 01 00:35:44 2009 -0700
4379 +++ b/zlib/Makefile.in  Mon Jun 01 00:36:01 2009 -0700
4380 @@ -187,6 +187,7 @@
4381  LIBDL = @LIBDL@
4382  LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4383  LIBOBJS = @LIBOBJS@
4384 +LIBRT = @LIBRT@
4385  LIBS = $(NON_THREADED_LIBS)
4386  LIBTOOL = @LIBTOOL@
4387  LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
This page took 4.217302 seconds and 4 git commands to generate.