1 diff -r d35bd12bba15 BUILD/Makefile.in
2 --- a/BUILD/Makefile.in Mon Dec 22 22:51:44 2008 -0800
3 +++ b/BUILD/Makefile.in Mon Dec 22 22:53:26 2008 -0800
6 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
11 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
12 diff -r d35bd12bba15 Docs/Makefile.in
13 --- a/Docs/Makefile.in Mon Dec 22 22:51:44 2008 -0800
14 +++ b/Docs/Makefile.in Mon Dec 22 22:53:26 2008 -0800
17 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
22 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
23 diff -r d35bd12bba15 Makefile.in
24 --- a/Makefile.in Mon Dec 22 22:51:44 2008 -0800
25 +++ b/Makefile.in Mon Dec 22 22:53:26 2008 -0800
28 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
33 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
34 diff -r d35bd12bba15 SSL/Makefile.in
35 --- a/SSL/Makefile.in Mon Dec 22 22:51:44 2008 -0800
36 +++ b/SSL/Makefile.in Mon Dec 22 22:53:26 2008 -0800
39 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
44 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
45 diff -r d35bd12bba15 aclocal.m4
46 --- a/aclocal.m4 Mon Dec 22 22:51:44 2008 -0800
47 +++ b/aclocal.m4 Mon Dec 22 22:53:26 2008 -0800
50 # Append ld.so.conf contents to the search path
51 if test -f /etc/ld.so.conf; then
52 - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
53 + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
54 sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
58 # Is the compiler the GNU C compiler?
59 with_gcc=$_LT_AC_TAGVAR(GCC, $1)
61 +gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
62 +gcc_ver=\`gcc -dumpversion\`
67 @@ -4438,11 +4441,11 @@
69 # Dependencies to place before the objects being linked to create a
71 -predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
72 +predep_objects=\`echo $lt_[]_LT_AC_TAGVAR(predep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
74 # Dependencies to place after the objects being linked to create a
76 -postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
77 +postdep_objects=\`echo $lt_[]_LT_AC_TAGVAR(postdep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
79 # Dependencies to place before the objects being linked to create a
83 # The library search path used internally by the compiler when linking
85 -compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
86 +compiler_lib_search_path=\`echo $lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
88 # Method to check whether dependent libraries are shared objects.
89 deplibs_check_method=$lt_deplibs_check_method
91 link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
93 # Compile-time system search path for libraries
94 -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
95 +sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
97 # Run-time system search path for libraries
98 sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
106 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
107 @@ -6402,6 +6406,7 @@
112 AC_MSG_RESULT([$SED])
115 diff -r d35bd12bba15 client/Makefile.in
116 --- a/client/Makefile.in Mon Dec 22 22:51:44 2008 -0800
117 +++ b/client/Makefile.in Mon Dec 22 22:53:26 2008 -0800
120 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
125 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
126 diff -r d35bd12bba15 cmd-line-utils/Makefile.in
127 --- a/cmd-line-utils/Makefile.in Mon Dec 22 22:51:44 2008 -0800
128 +++ b/cmd-line-utils/Makefile.in Mon Dec 22 22:53:26 2008 -0800
131 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
136 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
137 diff -r d35bd12bba15 cmd-line-utils/libedit/Makefile.in
138 --- a/cmd-line-utils/libedit/Makefile.in Mon Dec 22 22:51:44 2008 -0800
139 +++ b/cmd-line-utils/libedit/Makefile.in Mon Dec 22 22:53:26 2008 -0800
142 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
147 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
148 diff -r d35bd12bba15 cmd-line-utils/readline/Makefile.in
149 --- a/cmd-line-utils/readline/Makefile.in Mon Dec 22 22:51:44 2008 -0800
150 +++ b/cmd-line-utils/readline/Makefile.in Mon Dec 22 22:53:26 2008 -0800
153 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
158 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
159 diff -r d35bd12bba15 configure
160 --- a/configure Mon Dec 22 22:51:44 2008 -0800
161 +++ b/configure Mon Dec 22 22:53:26 2008 -0800
162 @@ -38236,7 +38236,91 @@
163 # We also disable for SCO for the time being, the headers for the
164 # thread library we use conflicts with other headers.
168 + # most systems require the program be linked with librt library to use
169 + # the function clock_gettime
170 + my_save_LIBS="$LIBS"
173 +echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
174 +echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6
175 +if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
176 + echo $ECHO_N "(cached) $ECHO_C" >&6
178 + ac_check_lib_save_LIBS=$LIBS
180 +cat >conftest.$ac_ext <<_ACEOF
183 +cat confdefs.h >>conftest.$ac_ext
184 +cat >>conftest.$ac_ext <<_ACEOF
185 +/* end confdefs.h. */
187 +/* Override any gcc2 internal prototype to avoid an error. */
191 +/* We use char because int might match the return type of a gcc2
192 + builtin and then its argument prototype would still apply. */
193 +char clock_gettime ();
202 +rm -f conftest.$ac_objext conftest$ac_exeext
203 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
204 + (eval $ac_link) 2>conftest.er1
206 + grep -v '^ *+' conftest.er1 >conftest.err
208 + cat conftest.err >&5
209 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
210 + (exit $ac_status); } &&
211 + { ac_try='test -z "$ac_c_werror_flag"
212 + || test ! -s conftest.err'
213 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
214 + (eval $ac_try) 2>&5
216 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
217 + (exit $ac_status); }; } &&
218 + { ac_try='test -s conftest$ac_exeext'
219 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
220 + (eval $ac_try) 2>&5
222 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
223 + (exit $ac_status); }; }; then
224 + ac_cv_lib_rt_clock_gettime=yes
226 + echo "$as_me: failed program was:" >&5
227 +sed 's/^/| /' conftest.$ac_ext >&5
229 +ac_cv_lib_rt_clock_gettime=no
231 +rm -f conftest.err conftest.$ac_objext \
232 + conftest$ac_exeext conftest.$ac_ext
233 +LIBS=$ac_check_lib_save_LIBS
235 +echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
236 +echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6
237 +if test $ac_cv_lib_rt_clock_gettime = yes; then
238 + cat >>confdefs.h <<_ACEOF
239 +#define HAVE_LIBRT 1
247 + LIBS="$my_save_LIBS"
250 + LIBS="$LIBS $LIBRT"
252 for ac_func in clock_gettime
254 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
255 @@ -41644,7 +41728,7 @@
259 -CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
260 +CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
264 @@ -42984,6 +43068,7 @@
265 s,@MAKE_SHELL@,$MAKE_SHELL,;t t
266 s,@TERMCAP_LIB@,$TERMCAP_LIB,;t t
267 s,@LIBEDIT_LOBJECTS@,$LIBEDIT_LOBJECTS,;t t
268 +s,@LIBRT@,$LIBRT,;t t
269 s,@tools_dirs@,$tools_dirs,;t t
270 s,@openssl_libs@,$openssl_libs,;t t
271 s,@openssl_includes@,$openssl_includes,;t t
272 diff -r d35bd12bba15 configure.in
273 --- a/configure.in Mon Dec 22 22:51:44 2008 -0800
274 +++ b/configure.in Mon Dec 22 22:53:26 2008 -0800
275 @@ -2098,7 +2098,18 @@
276 # We also disable for SCO for the time being, the headers for the
277 # thread library we use conflicts with other headers.
279 - *) AC_CHECK_FUNCS(clock_gettime)
281 + # most systems require the program be linked with librt library to use
282 + # the function clock_gettime
283 + my_save_LIBS="$LIBS"
285 + AC_CHECK_LIB(rt,clock_gettime)
287 + LIBS="$my_save_LIBS"
290 + LIBS="$LIBS $LIBRT"
291 + AC_CHECK_FUNCS(clock_gettime)
295 @@ -2713,7 +2724,7 @@
296 AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
299 -CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
300 +CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
302 AC_SUBST(CLIENT_LIBS)
303 AC_SUBST(NON_THREADED_LIBS)
304 diff -r d35bd12bba15 dbug/Makefile.in
305 --- a/dbug/Makefile.in Mon Dec 22 22:51:44 2008 -0800
306 +++ b/dbug/Makefile.in Mon Dec 22 22:53:26 2008 -0800
309 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
314 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
315 diff -r d35bd12bba15 extra/Makefile.in
316 --- a/extra/Makefile.in Mon Dec 22 22:51:44 2008 -0800
317 +++ b/extra/Makefile.in Mon Dec 22 22:53:26 2008 -0800
320 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
325 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
326 diff -r d35bd12bba15 extra/yassl/Makefile.in
327 --- a/extra/yassl/Makefile.in Mon Dec 22 22:51:44 2008 -0800
328 +++ b/extra/yassl/Makefile.in Mon Dec 22 22:53:26 2008 -0800
331 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
336 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
337 diff -r d35bd12bba15 extra/yassl/src/Makefile.in
338 --- a/extra/yassl/src/Makefile.in Mon Dec 22 22:51:44 2008 -0800
339 +++ b/extra/yassl/src/Makefile.in Mon Dec 22 22:53:26 2008 -0800
342 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
347 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
348 diff -r d35bd12bba15 extra/yassl/taocrypt/Makefile.in
349 --- a/extra/yassl/taocrypt/Makefile.in Mon Dec 22 22:51:44 2008 -0800
350 +++ b/extra/yassl/taocrypt/Makefile.in Mon Dec 22 22:53:26 2008 -0800
353 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
358 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
359 diff -r d35bd12bba15 extra/yassl/taocrypt/benchmark/Makefile.in
360 --- a/extra/yassl/taocrypt/benchmark/Makefile.in Mon Dec 22 22:51:44 2008 -0800
361 +++ b/extra/yassl/taocrypt/benchmark/Makefile.in Mon Dec 22 22:53:26 2008 -0800
364 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
369 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
370 diff -r d35bd12bba15 extra/yassl/taocrypt/src/Makefile.in
371 --- a/extra/yassl/taocrypt/src/Makefile.in Mon Dec 22 22:51:44 2008 -0800
372 +++ b/extra/yassl/taocrypt/src/Makefile.in Mon Dec 22 22:53:26 2008 -0800
375 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
380 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
381 diff -r d35bd12bba15 extra/yassl/taocrypt/test/Makefile.in
382 --- a/extra/yassl/taocrypt/test/Makefile.in Mon Dec 22 22:51:44 2008 -0800
383 +++ b/extra/yassl/taocrypt/test/Makefile.in Mon Dec 22 22:53:26 2008 -0800
386 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
391 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
392 diff -r d35bd12bba15 extra/yassl/testsuite/Makefile.in
393 --- a/extra/yassl/testsuite/Makefile.in Mon Dec 22 22:51:44 2008 -0800
394 +++ b/extra/yassl/testsuite/Makefile.in Mon Dec 22 22:53:26 2008 -0800
397 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
402 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
403 diff -r d35bd12bba15 heap/Makefile.in
404 --- a/heap/Makefile.in Mon Dec 22 22:51:44 2008 -0800
405 +++ b/heap/Makefile.in Mon Dec 22 22:53:26 2008 -0800
408 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
413 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
414 diff -r d35bd12bba15 include/Makefile.in
415 --- a/include/Makefile.in Mon Dec 22 22:51:44 2008 -0800
416 +++ b/include/Makefile.in Mon Dec 22 22:53:26 2008 -0800
419 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
424 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
425 diff -r d35bd12bba15 include/mysql_com.h
426 --- a/include/mysql_com.h Mon Dec 22 22:51:44 2008 -0800
427 +++ b/include/mysql_com.h Mon Dec 22 22:53:26 2008 -0800
430 #define REFRESH_MASTER 128 /* Remove all bin logs in the index
431 and truncate the index */
432 +#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
433 +#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
434 +#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
435 +#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
436 +#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
438 /* The following can't be set with mysql_refresh() */
439 #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
440 diff -r d35bd12bba15 libmysql/Makefile.in
441 --- a/libmysql/Makefile.in Mon Dec 22 22:51:44 2008 -0800
442 +++ b/libmysql/Makefile.in Mon Dec 22 22:53:26 2008 -0800
445 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
450 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
451 diff -r d35bd12bba15 libmysql_r/Makefile.in
452 --- a/libmysql_r/Makefile.in Mon Dec 22 22:51:44 2008 -0800
453 +++ b/libmysql_r/Makefile.in Mon Dec 22 22:53:26 2008 -0800
456 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
459 LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
461 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
462 diff -r d35bd12bba15 libmysqld/Makefile.in
463 --- a/libmysqld/Makefile.in Mon Dec 22 22:51:44 2008 -0800
464 +++ b/libmysqld/Makefile.in Mon Dec 22 22:53:26 2008 -0800
467 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
472 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
473 diff -r d35bd12bba15 libmysqld/examples/Makefile.in
474 --- a/libmysqld/examples/Makefile.in Mon Dec 22 22:51:44 2008 -0800
475 +++ b/libmysqld/examples/Makefile.in Mon Dec 22 22:53:26 2008 -0800
478 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
481 LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
483 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
484 diff -r d35bd12bba15 man/Makefile.in
485 --- a/man/Makefile.in Mon Dec 22 22:51:44 2008 -0800
486 +++ b/man/Makefile.in Mon Dec 22 22:53:26 2008 -0800
489 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
494 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
495 diff -r d35bd12bba15 myisam/Makefile.in
496 --- a/myisam/Makefile.in Mon Dec 22 22:51:44 2008 -0800
497 +++ b/myisam/Makefile.in Mon Dec 22 22:53:26 2008 -0800
500 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
505 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
506 diff -r d35bd12bba15 myisammrg/Makefile.in
507 --- a/myisammrg/Makefile.in Mon Dec 22 22:51:44 2008 -0800
508 +++ b/myisammrg/Makefile.in Mon Dec 22 22:53:26 2008 -0800
511 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
516 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
517 diff -r d35bd12bba15 mysql-test/Makefile.in
518 --- a/mysql-test/Makefile.in Mon Dec 22 22:51:44 2008 -0800
519 +++ b/mysql-test/Makefile.in Mon Dec 22 22:53:26 2008 -0800
522 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
527 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
528 diff -r d35bd12bba15 mysql-test/ndb/Makefile.in
529 --- a/mysql-test/ndb/Makefile.in Mon Dec 22 22:51:44 2008 -0800
530 +++ b/mysql-test/ndb/Makefile.in Mon Dec 22 22:53:26 2008 -0800
533 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
538 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
539 diff -r d35bd12bba15 mysql-test/r/information_schema.result
540 --- a/mysql-test/r/information_schema.result Mon Dec 22 22:51:44 2008 -0800
541 +++ b/mysql-test/r/information_schema.result Mon Dec 22 22:53:26 2008 -0800
548 COLLATION_CHARACTER_SET_APPLICABILITY
568 TABLE_CONSTRAINTS TABLE_CONSTRAINTS
569 TABLE_PRIVILEGES TABLE_PRIVILEGES
570 +TABLE_STATISTICS TABLE_STATISTICS
572 tables_priv tables_priv
576 TABLE_CONSTRAINTS TABLE_CONSTRAINTS
577 TABLE_PRIVILEGES TABLE_PRIVILEGES
578 +TABLE_STATISTICS TABLE_STATISTICS
580 tables_priv tables_priv
584 TABLE_CONSTRAINTS TABLE_CONSTRAINTS
585 TABLE_PRIVILEGES TABLE_PRIVILEGES
586 +TABLE_STATISTICS TABLE_STATISTICS
588 tables_priv tables_priv
590 @@ -594,12 +601,13 @@
591 where table_schema='information_schema' limit 2;
592 TABLE_NAME TABLE_TYPE ENGINE
593 CHARACTER_SETS SYSTEM VIEW MEMORY
594 -COLLATIONS SYSTEM VIEW MEMORY
595 +CLIENT_STATISTICS SYSTEM VIEW MEMORY
596 show tables from information_schema like "T%";
597 Tables_in_information_schema (T%)
603 create database information_schema;
604 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
607 TABLE_CONSTRAINTS SYSTEM VIEW
608 TABLE_PRIVILEGES SYSTEM VIEW
609 +TABLE_STATISTICS SYSTEM VIEW
611 create table t1(a int);
612 ERROR 42S02: Unknown table 't1' in information_schema
619 select table_name from tables where table_name='user';
622 CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
623 CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
628 drop table t_crashme;
629 select table_schema,table_name, column_name from
630 @@ -790,18 +800,20 @@
631 TABLE_NAME COLUMN_NAME PRIVILEGES
632 COLUMNS TABLE_NAME select
633 COLUMN_PRIVILEGES TABLE_NAME select
634 +INDEX_STATISTICS TABLE_NAME select
635 KEY_COLUMN_USAGE TABLE_NAME select
636 STATISTICS TABLE_NAME select
637 TABLES TABLE_NAME select
638 TABLE_CONSTRAINTS TABLE_NAME select
639 TABLE_PRIVILEGES TABLE_NAME select
640 +TABLE_STATISTICS TABLE_NAME select
641 VIEWS TABLE_NAME select
642 delete from mysql.user where user='mysqltest_4';
643 delete from mysql.db where user='mysqltest_4';
645 SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
646 table_schema count(*)
647 -information_schema 17
648 +information_schema 21
650 create table t1 (i int, j int);
651 create trigger trg1 before insert on t1 for each row
652 @@ -1187,10 +1199,12 @@
654 table_name column_name
655 CHARACTER_SETS CHARACTER_SET_NAME
656 +CLIENT_STATISTICS CLIENT
657 COLLATIONS COLLATION_NAME
658 COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
660 COLUMN_PRIVILEGES TABLE_SCHEMA
661 +INDEX_STATISTICS TABLE_SCHEMA
662 KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
664 ROUTINES ROUTINE_SCHEMA
665 @@ -1200,8 +1214,10 @@
667 TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
668 TABLE_PRIVILEGES TABLE_SCHEMA
669 +TABLE_STATISTICS TABLE_SCHEMA
670 TRIGGERS TRIGGER_SCHEMA
671 USER_PRIVILEGES GRANTEE
672 +USER_STATISTICS USER
674 SELECT t.table_name, c1.column_name
675 FROM information_schema.tables t
676 @@ -1219,10 +1235,12 @@
678 table_name column_name
679 CHARACTER_SETS CHARACTER_SET_NAME
680 +CLIENT_STATISTICS CLIENT
681 COLLATIONS COLLATION_NAME
682 COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
684 COLUMN_PRIVILEGES TABLE_SCHEMA
685 +INDEX_STATISTICS TABLE_SCHEMA
686 KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
688 ROUTINES ROUTINE_SCHEMA
689 @@ -1232,8 +1250,10 @@
691 TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
692 TABLE_PRIVILEGES TABLE_SCHEMA
693 +TABLE_STATISTICS TABLE_SCHEMA
694 TRIGGERS TRIGGER_SCHEMA
695 USER_PRIVILEGES GRANTEE
696 +USER_STATISTICS USER
698 SELECT MAX(table_name) FROM information_schema.tables;
700 @@ -1302,10 +1322,12 @@
701 group by t.table_name order by num1, t.table_name;
702 table_name group_concat(t.table_schema, '.', t.table_name) num1
703 CHARACTER_SETS information_schema.CHARACTER_SETS 1
704 +CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
705 COLLATIONS information_schema.COLLATIONS 1
706 COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
707 COLUMNS information_schema.COLUMNS 1
708 COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
709 +INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
710 KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
711 PROFILING information_schema.PROFILING 1
712 ROUTINES information_schema.ROUTINES 1
713 @@ -1315,8 +1337,10 @@
714 TABLES information_schema.TABLES 1
715 TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
716 TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
717 +TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
718 TRIGGERS information_schema.TRIGGERS 1
719 USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
720 +USER_STATISTICS information_schema.USER_STATISTICS 1
721 VIEWS information_schema.VIEWS 1
722 show global status like "Uptime_%";
724 diff -r d35bd12bba15 mysql-test/r/information_schema_db.result
725 --- a/mysql-test/r/information_schema_db.result Mon Dec 22 22:51:44 2008 -0800
726 +++ b/mysql-test/r/information_schema_db.result Mon Dec 22 22:53:26 2008 -0800
729 Tables_in_information_schema
733 COLLATION_CHARACTER_SET_APPLICABILITY
749 show tables from INFORMATION_SCHEMA like 'T%';
750 Tables_in_information_schema (T%)
756 create database `inf%`;
757 create database mbase;
758 diff -r d35bd12bba15 mysql-test/r/mysqlshow.result
759 --- a/mysql-test/r/mysqlshow.result Mon Dec 22 22:51:44 2008 -0800
760 +++ b/mysql-test/r/mysqlshow.result Mon Dec 22 22:53:26 2008 -0800
763 +---------------------------------------+
765 +| CLIENT_STATISTICS |
767 | COLLATION_CHARACTER_SET_APPLICABILITY |
769 | COLUMN_PRIVILEGES |
770 +| INDEX_STATISTICS |
776 | TABLE_CONSTRAINTS |
778 +| TABLE_STATISTICS |
783 +---------------------------------------+
784 Database: INFORMATION_SCHEMA
785 @@ -102,10 +106,12 @@
787 +---------------------------------------+
789 +| CLIENT_STATISTICS |
791 | COLLATION_CHARACTER_SET_APPLICABILITY |
793 | COLUMN_PRIVILEGES |
794 +| INDEX_STATISTICS |
800 | TABLE_CONSTRAINTS |
802 +| TABLE_STATISTICS |
807 +---------------------------------------+
808 Wildcard: inf_rmation_schema
809 diff -r d35bd12bba15 mysys/Makefile.in
810 --- a/mysys/Makefile.in Mon Dec 22 22:51:44 2008 -0800
811 +++ b/mysys/Makefile.in Mon Dec 22 22:53:26 2008 -0800
814 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
819 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
820 diff -r d35bd12bba15 ndb/Makefile.in
821 --- a/ndb/Makefile.in Mon Dec 22 22:51:44 2008 -0800
822 +++ b/ndb/Makefile.in Mon Dec 22 22:53:26 2008 -0800
825 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
830 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
831 diff -r d35bd12bba15 ndb/docs/Makefile.in
832 --- a/ndb/docs/Makefile.in Mon Dec 22 22:51:44 2008 -0800
833 +++ b/ndb/docs/Makefile.in Mon Dec 22 22:53:26 2008 -0800
836 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
841 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
842 diff -r d35bd12bba15 ndb/include/Makefile.in
843 --- a/ndb/include/Makefile.in Mon Dec 22 22:51:44 2008 -0800
844 +++ b/ndb/include/Makefile.in Mon Dec 22 22:53:26 2008 -0800
847 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
852 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
853 diff -r d35bd12bba15 ndb/src/Makefile.in
854 --- a/ndb/src/Makefile.in Mon Dec 22 22:51:44 2008 -0800
855 +++ b/ndb/src/Makefile.in Mon Dec 22 22:53:26 2008 -0800
858 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
863 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
864 diff -r d35bd12bba15 ndb/src/common/Makefile.in
865 --- a/ndb/src/common/Makefile.in Mon Dec 22 22:51:44 2008 -0800
866 +++ b/ndb/src/common/Makefile.in Mon Dec 22 22:53:26 2008 -0800
869 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
874 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
875 diff -r d35bd12bba15 ndb/src/common/debugger/Makefile.in
876 --- a/ndb/src/common/debugger/Makefile.in Mon Dec 22 22:51:44 2008 -0800
877 +++ b/ndb/src/common/debugger/Makefile.in Mon Dec 22 22:53:26 2008 -0800
880 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
885 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
886 diff -r d35bd12bba15 ndb/src/common/debugger/signaldata/Makefile.in
887 --- a/ndb/src/common/debugger/signaldata/Makefile.in Mon Dec 22 22:51:44 2008 -0800
888 +++ b/ndb/src/common/debugger/signaldata/Makefile.in Mon Dec 22 22:53:26 2008 -0800
891 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
896 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
897 diff -r d35bd12bba15 ndb/src/common/logger/Makefile.in
898 --- a/ndb/src/common/logger/Makefile.in Mon Dec 22 22:51:44 2008 -0800
899 +++ b/ndb/src/common/logger/Makefile.in Mon Dec 22 22:53:26 2008 -0800
902 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
907 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
908 diff -r d35bd12bba15 ndb/src/common/mgmcommon/Makefile.in
909 --- a/ndb/src/common/mgmcommon/Makefile.in Mon Dec 22 22:51:44 2008 -0800
910 +++ b/ndb/src/common/mgmcommon/Makefile.in Mon Dec 22 22:53:26 2008 -0800
913 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
918 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
919 diff -r d35bd12bba15 ndb/src/common/portlib/Makefile.in
920 --- a/ndb/src/common/portlib/Makefile.in Mon Dec 22 22:51:44 2008 -0800
921 +++ b/ndb/src/common/portlib/Makefile.in Mon Dec 22 22:53:26 2008 -0800
924 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
929 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
930 diff -r d35bd12bba15 ndb/src/common/transporter/Makefile.in
931 --- a/ndb/src/common/transporter/Makefile.in Mon Dec 22 22:51:44 2008 -0800
932 +++ b/ndb/src/common/transporter/Makefile.in Mon Dec 22 22:53:26 2008 -0800
935 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
940 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
941 diff -r d35bd12bba15 ndb/src/common/util/Makefile.in
942 --- a/ndb/src/common/util/Makefile.in Mon Dec 22 22:51:44 2008 -0800
943 +++ b/ndb/src/common/util/Makefile.in Mon Dec 22 22:53:26 2008 -0800
946 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
951 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
952 diff -r d35bd12bba15 ndb/src/cw/Makefile.in
953 --- a/ndb/src/cw/Makefile.in Mon Dec 22 22:51:44 2008 -0800
954 +++ b/ndb/src/cw/Makefile.in Mon Dec 22 22:53:26 2008 -0800
957 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
962 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
963 diff -r d35bd12bba15 ndb/src/cw/cpcd/Makefile.in
964 --- a/ndb/src/cw/cpcd/Makefile.in Mon Dec 22 22:51:44 2008 -0800
965 +++ b/ndb/src/cw/cpcd/Makefile.in Mon Dec 22 22:53:26 2008 -0800
968 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
973 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
974 diff -r d35bd12bba15 ndb/src/kernel/Makefile.in
975 --- a/ndb/src/kernel/Makefile.in Mon Dec 22 22:51:44 2008 -0800
976 +++ b/ndb/src/kernel/Makefile.in Mon Dec 22 22:53:26 2008 -0800
979 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
984 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
985 diff -r d35bd12bba15 ndb/src/kernel/blocks/Makefile.in
986 --- a/ndb/src/kernel/blocks/Makefile.in Mon Dec 22 22:51:44 2008 -0800
987 +++ b/ndb/src/kernel/blocks/Makefile.in Mon Dec 22 22:53:26 2008 -0800
990 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
995 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
996 diff -r d35bd12bba15 ndb/src/kernel/blocks/backup/Makefile.in
997 --- a/ndb/src/kernel/blocks/backup/Makefile.in Mon Dec 22 22:51:44 2008 -0800
998 +++ b/ndb/src/kernel/blocks/backup/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1001 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1006 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1007 diff -r d35bd12bba15 ndb/src/kernel/blocks/cmvmi/Makefile.in
1008 --- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1009 +++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1012 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1017 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1018 diff -r d35bd12bba15 ndb/src/kernel/blocks/dbacc/Makefile.in
1019 --- a/ndb/src/kernel/blocks/dbacc/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1020 +++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1023 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1028 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1029 diff -r d35bd12bba15 ndb/src/kernel/blocks/dbdict/Makefile.in
1030 --- a/ndb/src/kernel/blocks/dbdict/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1031 +++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1034 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1039 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1040 diff -r d35bd12bba15 ndb/src/kernel/blocks/dbdih/Makefile.in
1041 --- a/ndb/src/kernel/blocks/dbdih/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1042 +++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1045 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1050 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1051 diff -r d35bd12bba15 ndb/src/kernel/blocks/dblqh/Makefile.in
1052 --- a/ndb/src/kernel/blocks/dblqh/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1053 +++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1056 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1061 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1062 diff -r d35bd12bba15 ndb/src/kernel/blocks/dbtc/Makefile.in
1063 --- a/ndb/src/kernel/blocks/dbtc/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1064 +++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1067 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1072 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1073 diff -r d35bd12bba15 ndb/src/kernel/blocks/dbtup/Makefile.in
1074 --- a/ndb/src/kernel/blocks/dbtup/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1075 +++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1078 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1083 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1084 diff -r d35bd12bba15 ndb/src/kernel/blocks/dbtux/Makefile.in
1085 --- a/ndb/src/kernel/blocks/dbtux/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1086 +++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1089 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1094 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1095 diff -r d35bd12bba15 ndb/src/kernel/blocks/dbutil/Makefile.in
1096 --- a/ndb/src/kernel/blocks/dbutil/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1097 +++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1100 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1105 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1106 diff -r d35bd12bba15 ndb/src/kernel/blocks/ndbcntr/Makefile.in
1107 --- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1108 +++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1111 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1116 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1117 diff -r d35bd12bba15 ndb/src/kernel/blocks/ndbfs/Makefile.in
1118 --- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1119 +++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1122 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1127 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1128 diff -r d35bd12bba15 ndb/src/kernel/blocks/qmgr/Makefile.in
1129 --- a/ndb/src/kernel/blocks/qmgr/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1130 +++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1133 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1138 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1139 diff -r d35bd12bba15 ndb/src/kernel/blocks/suma/Makefile.in
1140 --- a/ndb/src/kernel/blocks/suma/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1141 +++ b/ndb/src/kernel/blocks/suma/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1144 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1149 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1150 diff -r d35bd12bba15 ndb/src/kernel/blocks/trix/Makefile.in
1151 --- a/ndb/src/kernel/blocks/trix/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1152 +++ b/ndb/src/kernel/blocks/trix/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1155 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1160 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1161 diff -r d35bd12bba15 ndb/src/kernel/error/Makefile.in
1162 --- a/ndb/src/kernel/error/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1163 +++ b/ndb/src/kernel/error/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1166 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1171 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1172 diff -r d35bd12bba15 ndb/src/kernel/vm/Makefile.in
1173 --- a/ndb/src/kernel/vm/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1174 +++ b/ndb/src/kernel/vm/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1177 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1182 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1183 diff -r d35bd12bba15 ndb/src/mgmapi/Makefile.in
1184 --- a/ndb/src/mgmapi/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1185 +++ b/ndb/src/mgmapi/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1188 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1193 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1194 diff -r d35bd12bba15 ndb/src/mgmclient/Makefile.in
1195 --- a/ndb/src/mgmclient/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1196 +++ b/ndb/src/mgmclient/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1199 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1204 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1205 diff -r d35bd12bba15 ndb/src/mgmsrv/Makefile.in
1206 --- a/ndb/src/mgmsrv/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1207 +++ b/ndb/src/mgmsrv/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1210 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1215 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1216 diff -r d35bd12bba15 ndb/src/ndbapi/Makefile.in
1217 --- a/ndb/src/ndbapi/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1218 +++ b/ndb/src/ndbapi/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1221 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1226 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1227 diff -r d35bd12bba15 ndb/test/Makefile.in
1228 --- a/ndb/test/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1229 +++ b/ndb/test/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1232 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1237 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1238 diff -r d35bd12bba15 ndb/test/ndbapi/Makefile.in
1239 --- a/ndb/test/ndbapi/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1240 +++ b/ndb/test/ndbapi/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1243 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1248 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1249 diff -r d35bd12bba15 ndb/test/ndbapi/bank/Makefile.in
1250 --- a/ndb/test/ndbapi/bank/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1251 +++ b/ndb/test/ndbapi/bank/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1254 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1259 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1260 diff -r d35bd12bba15 ndb/test/run-test/Makefile.in
1261 --- a/ndb/test/run-test/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1262 +++ b/ndb/test/run-test/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1265 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1270 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1271 diff -r d35bd12bba15 ndb/test/src/Makefile.in
1272 --- a/ndb/test/src/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1273 +++ b/ndb/test/src/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1276 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1281 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1282 diff -r d35bd12bba15 ndb/test/tools/Makefile.in
1283 --- a/ndb/test/tools/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1284 +++ b/ndb/test/tools/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1287 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1292 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1293 diff -r d35bd12bba15 ndb/tools/Makefile.in
1294 --- a/ndb/tools/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1295 +++ b/ndb/tools/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1298 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1303 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1304 diff -r d35bd12bba15 netware/Makefile.in
1305 --- a/netware/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1306 +++ b/netware/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1309 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1314 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1315 diff -r d35bd12bba15 os2/Makefile.in
1316 --- a/os2/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1317 +++ b/os2/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1320 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1325 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1326 diff -r d35bd12bba15 os2/include/Makefile.in
1327 --- a/os2/include/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1328 +++ b/os2/include/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1331 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1336 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1337 diff -r d35bd12bba15 os2/include/sys/Makefile.in
1338 --- a/os2/include/sys/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1339 +++ b/os2/include/sys/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1342 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1347 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1348 diff -r d35bd12bba15 patch_info/userstats.info
1349 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1350 +++ b/patch_info/userstats.info Mon Dec 22 22:53:26 2008 -0800
1352 +File=userstatsv2.patch
1353 +Name=SHOW USER/TABLE/INDEX statistics
1357 +Comment=Added INFORMATION_SCHEMA.*_STATISTICS
1359 +YK: fix behavior for prepared statements
1362 +YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
1365 +YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
1366 diff -r d35bd12bba15 pstack/Makefile.in
1367 --- a/pstack/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1368 +++ b/pstack/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1371 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1376 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1377 diff -r d35bd12bba15 pstack/aout/Makefile.in
1378 --- a/pstack/aout/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1379 +++ b/pstack/aout/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1382 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1387 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1388 diff -r d35bd12bba15 regex/Makefile.in
1389 --- a/regex/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1390 +++ b/regex/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1393 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1398 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1399 diff -r d35bd12bba15 scripts/Makefile.in
1400 --- a/scripts/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1401 +++ b/scripts/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1404 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1409 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1410 diff -r d35bd12bba15 server-tools/Makefile.in
1411 --- a/server-tools/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1412 +++ b/server-tools/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1415 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1420 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1421 diff -r d35bd12bba15 server-tools/instance-manager/Makefile.in
1422 --- a/server-tools/instance-manager/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1423 +++ b/server-tools/instance-manager/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1426 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1431 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1432 diff -r d35bd12bba15 sql/Makefile.in
1433 --- a/sql/Makefile.in Mon Dec 22 22:51:44 2008 -0800
1434 +++ b/sql/Makefile.in Mon Dec 22 22:53:26 2008 -0800
1437 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1442 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1443 diff -r d35bd12bba15 sql/ha_innodb.cc
1444 --- a/sql/ha_innodb.cc Mon Dec 22 22:51:44 2008 -0800
1445 +++ b/sql/ha_innodb.cc Mon Dec 22 22:53:26 2008 -0800
1446 @@ -3316,6 +3316,8 @@
1448 error = row_insert_for_mysql((byte*) record, prebuilt);
1450 + if (error == DB_SUCCESS) rows_changed++;
1452 if (error == DB_SUCCESS && auto_inc_used) {
1454 /* Fetch the value that was set in the autoincrement field */
1455 @@ -3588,6 +3590,8 @@
1459 + if (error == DB_SUCCESS) rows_changed++;
1461 innodb_srv_conc_exit_innodb(prebuilt->trx);
1463 error = convert_error_code_to_mysql(error, user_thd);
1464 @@ -3635,6 +3639,8 @@
1465 innodb_srv_conc_enter_innodb(prebuilt->trx);
1467 error = row_update_for_mysql((byte*) record, prebuilt);
1469 + if (error == DB_SUCCESS) rows_changed++;
1471 innodb_srv_conc_exit_innodb(prebuilt->trx);
1473 @@ -4068,6 +4074,9 @@
1474 if (ret == DB_SUCCESS) {
1478 + if (active_index >= 0 && active_index < MAX_KEY)
1479 + index_rows_read[active_index]++;
1481 } else if (ret == DB_RECORD_NOT_FOUND) {
1482 error = HA_ERR_END_OF_FILE;
1483 diff -r d35bd12bba15 sql/ha_myisam.cc
1484 --- a/sql/ha_myisam.cc Mon Dec 22 22:51:44 2008 -0800
1485 +++ b/sql/ha_myisam.cc Mon Dec 22 22:53:26 2008 -0800
1487 if ((error= update_auto_increment()))
1490 - return mi_write(file,buf);
1491 + int error=mi_write(file,buf);
1492 + if (!error) rows_changed++;
1496 int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
1497 @@ -1518,13 +1520,17 @@
1498 statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
1499 if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
1500 table->timestamp_field->set_time();
1501 - return mi_update(file,old_data,new_data);
1502 + int error=mi_update(file,old_data,new_data);
1503 + if (!error) rows_changed++;
1507 int ha_myisam::delete_row(const byte * buf)
1509 statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
1510 - return mi_delete(file,buf);
1511 + int error=mi_delete(file,buf);
1512 + if (!error) rows_changed++;
1516 int ha_myisam::index_read(byte * buf, const byte * key,
1517 @@ -1535,6 +1541,13 @@
1519 int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
1520 table->status=error ? STATUS_NOT_FOUND: 0;
1524 + int inx = (active_index == -1) ? file->lastinx : active_index;
1525 + if (inx >= 0 && inx < MAX_KEY)
1526 + index_rows_read[inx]++;
1531 @@ -1545,6 +1558,13 @@
1533 int error=mi_rkey(file,buf,index, key, key_len, find_flag);
1534 table->status=error ? STATUS_NOT_FOUND: 0;
1539 + if (inx >= 0 && inx < MAX_KEY)
1540 + index_rows_read[inx]++;
1545 @@ -1555,6 +1575,13 @@
1547 int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
1548 table->status=error ? STATUS_NOT_FOUND: 0;
1552 + int inx = (active_index == -1) ? file->lastinx : active_index;
1553 + if (inx >= 0 && inx < MAX_KEY)
1554 + index_rows_read[inx]++;
1559 @@ -1565,6 +1592,13 @@
1561 int error=mi_rnext(file,buf,active_index);
1562 table->status=error ? STATUS_NOT_FOUND: 0;
1566 + int inx = (active_index == -1) ? file->lastinx : active_index;
1567 + if (inx >= 0 && inx < MAX_KEY)
1568 + index_rows_read[inx]++;
1573 @@ -1575,6 +1609,13 @@
1575 int error=mi_rprev(file,buf, active_index);
1576 table->status=error ? STATUS_NOT_FOUND: 0;
1580 + int inx = (active_index == -1) ? file->lastinx : active_index;
1581 + if (inx >= 0 && inx < MAX_KEY)
1582 + index_rows_read[inx]++;
1587 @@ -1585,6 +1626,13 @@
1589 int error=mi_rfirst(file, buf, active_index);
1590 table->status=error ? STATUS_NOT_FOUND: 0;
1594 + int inx = (active_index == -1) ? file->lastinx : active_index;
1595 + if (inx >= 0 && inx < MAX_KEY)
1596 + index_rows_read[inx]++;
1601 @@ -1595,6 +1643,13 @@
1603 int error=mi_rlast(file, buf, active_index);
1604 table->status=error ? STATUS_NOT_FOUND: 0;
1608 + int inx = (active_index == -1) ? file->lastinx : active_index;
1609 + if (inx >= 0 && inx < MAX_KEY)
1610 + index_rows_read[inx]++;
1615 @@ -1611,6 +1666,13 @@
1616 error= mi_rnext_same(file,buf);
1617 } while (error == HA_ERR_RECORD_DELETED);
1618 table->status=error ? STATUS_NOT_FOUND: 0;
1622 + int inx = (active_index == -1) ? file->lastinx : active_index;
1623 + if (inx >= 0 && inx < MAX_KEY)
1624 + index_rows_read[inx]++;
1629 @@ -1628,6 +1690,7 @@
1631 int error=mi_scan(file, buf);
1632 table->status=error ? STATUS_NOT_FOUND: 0;
1633 + if (!error) rows_read++;
1637 @@ -1642,6 +1705,7 @@
1639 int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
1640 table->status=error ? STATUS_NOT_FOUND: 0;
1641 + if (!error) rows_read++;
1645 diff -r d35bd12bba15 sql/handler.cc
1646 --- a/sql/handler.cc Mon Dec 22 22:51:44 2008 -0800
1647 +++ b/sql/handler.cc Mon Dec 22 22:53:26 2008 -0800
1650 tc_log->unlog(cookie, xid);
1651 DBUG_EXECUTE_IF("crash_commit_after", abort(););
1652 + if (is_real_trans)
1653 + thd->diff_commit_trans++;
1656 start_waiting_global_read_lock(thd);
1658 thd->transaction.cleanup();
1661 + thd->diff_rollback_trans++;
1662 #endif /* USING_TRANSACTIONS */
1664 thd->transaction_rollback_request= FALSE;
1665 @@ -1212,6 +1215,7 @@
1666 statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
1667 *ht=0; // keep it conveniently zero-filled
1669 + thd->diff_rollback_trans++;
1673 @@ -1442,6 +1446,8 @@
1675 dupp_ref=ref+ALIGN_SIZE(ref_length);
1677 + rows_read = rows_changed = 0;
1678 + memset(index_rows_read, 0, sizeof(index_rows_read));
1682 @@ -2276,6 +2282,111 @@
1686 +// Updates the global table stats with the TABLE this handler represents.
1687 +void handler::update_global_table_stats() {
1688 + if (!opt_userstat_running) {
1689 + rows_read = rows_changed = 0;
1693 + if (!rows_read && !rows_changed) return; // Nothing to update.
1694 + // table_cache_key is db_name + '\0' + table_name + '\0'.
1695 + if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
1697 + TABLE_STATS* table_stats;
1698 + char key[NAME_LEN * 2 + 2];
1699 + // [db] + '.' + [table]
1700 + sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
1702 + pthread_mutex_lock(&LOCK_global_table_stats);
1703 + // Gets the global table stats, creating one if necessary.
1704 + if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
1707 + if (!(table_stats = ((TABLE_STATS*)
1708 + my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
1710 + sql_print_error("Allocating table stats failed.");
1713 + strncpy(table_stats->table, key, sizeof(table_stats->table));
1714 + table_stats->rows_read = 0;
1715 + table_stats->rows_changed = 0;
1716 + table_stats->rows_changed_x_indexes = 0;
1717 + table_stats->engine_type = (int) ht->db_type;
1719 + if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
1721 + sql_print_error("Inserting table stats failed.");
1722 + my_free((char*)table_stats, 0);
1726 + // Updates the global table stats.
1727 + table_stats->rows_read += rows_read;
1728 + table_stats->rows_changed += rows_changed;
1729 + table_stats->rows_changed_x_indexes +=
1730 + rows_changed * (table->s->keys ? table->s->keys : 1);
1731 + current_thd->diff_total_read_rows += rows_read;
1732 + rows_read = rows_changed = 0;
1734 + pthread_mutex_unlock(&LOCK_global_table_stats);
1737 +// Updates the global index stats with this handler's accumulated index reads.
1738 +void handler::update_global_index_stats() {
1739 + // table_cache_key is db_name + '\0' + table_name + '\0'.
1740 + if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
1742 + if (!opt_userstat_running) {
1743 + for (int x = 0; x < table->s->keys; x++) {
1744 + index_rows_read[x] = 0;
1749 + for (int x = 0; x < table->s->keys; x++) {
1750 + if (index_rows_read[x]) {
1751 + // Rows were read using this index.
1752 + KEY* key_info = &table->key_info[x];
1754 + if (!key_info->name) continue;
1756 + INDEX_STATS* index_stats;
1757 + char key[NAME_LEN * 3 + 3];
1758 + // [db] + '.' + [table] + '.' + [index]
1759 + sprintf(key, "%s.%s.%s", table->s->table_cache_key,
1760 + table->s->table_name, key_info->name);
1762 + pthread_mutex_lock(&LOCK_global_index_stats);
1763 + // Gets the global index stats, creating one if necessary.
1764 + if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
1767 + if (!(index_stats = ((INDEX_STATS*)
1768 + my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
1770 + sql_print_error("Allocating index stats failed.");
1773 + strncpy(index_stats->index, key, sizeof(index_stats->index));
1774 + index_stats->rows_read = 0;
1776 + if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
1778 + sql_print_error("Inserting index stats failed.");
1779 + my_free((char*)index_stats, 0);
1783 + // Updates the global index stats.
1784 + index_stats->rows_read += index_rows_read[x];
1785 + index_rows_read[x] = 0;
1787 + pthread_mutex_unlock(&LOCK_global_index_stats);
1792 /****************************************************************************
1793 ** Some general functions that isn't in the handler class
1794 diff -r d35bd12bba15 sql/handler.h
1795 --- a/sql/handler.h Mon Dec 22 22:51:44 2008 -0800
1796 +++ b/sql/handler.h Mon Dec 22 22:53:26 2008 -0800
1798 #if defined(HAVE_BERKELEY_DB) || defined(HAVE_INNOBASE_DB) || \
1799 defined(HAVE_NDBCLUSTER_DB)
1800 #define USING_TRANSACTIONS
1804 +#error MAX_KEY is too large. Values up to 128 are supported.
1807 // the following is for checking tables
1809 bool auto_increment_column_changed;
1810 bool implicit_emptied; /* Can be !=0 only if HEAP */
1811 const COND *pushed_cond;
1812 + ulonglong rows_read;
1813 + ulonglong rows_changed;
1814 + ulonglong index_rows_read[MAX_KEY];
1816 handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
1818 @@ -615,8 +622,10 @@
1819 ref_length(sizeof(my_off_t)), block_size(0),
1820 raid_type(0), ft_handler(0), inited(NONE),
1821 locked(FALSE), implicit_emptied(0),
1824 + pushed_cond(NULL), rows_read(0), rows_changed(0)
1826 + memset(index_rows_read, 0, sizeof(index_rows_read));
1828 virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
1829 virtual handler *clone(MEM_ROOT *mem_root);
1830 int ha_open(const char *name, int mode, int test_if_locked);
1831 @@ -625,7 +634,11 @@
1832 virtual void print_error(int error, myf errflag);
1833 virtual bool get_error_message(int error, String *buf);
1834 uint get_dup_key(int error);
1835 - void change_table_ptr(TABLE *table_arg) { table=table_arg; }
1836 + void change_table_ptr(TABLE *table_arg) {
1838 + rows_read = rows_changed = 0;
1839 + memset(index_rows_read, 0, sizeof(index_rows_read));
1841 virtual double scan_time()
1842 { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
1843 virtual double read_time(uint index, uint ranges, ha_rows rows)
1845 virtual bool is_crashed() const { return 0; }
1846 virtual bool auto_repair() const { return 0; }
1848 + void update_global_table_stats();
1849 + void update_global_index_stats();
1852 default rename_table() and delete_table() rename/delete files with a
1853 given name and extensions from bas_ext()
1854 diff -r d35bd12bba15 sql/lex.h
1855 --- a/sql/lex.h Mon Dec 22 22:51:44 2008 -0800
1856 +++ b/sql/lex.h Mon Dec 22 22:53:26 2008 -0800
1858 { "CHECKSUM", SYM(CHECKSUM_SYM)},
1859 { "CIPHER", SYM(CIPHER_SYM)},
1860 { "CLIENT", SYM(CLIENT_SYM)},
1861 + { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
1862 { "CLOSE", SYM(CLOSE_SYM)},
1863 { "CODE", SYM(CODE_SYM)},
1864 { "COLLATE", SYM(COLLATE_SYM)},
1866 { "IN", SYM(IN_SYM)},
1867 { "INDEX", SYM(INDEX_SYM)},
1868 { "INDEXES", SYM(INDEXES)},
1869 + { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
1870 { "INFILE", SYM(INFILE)},
1871 { "INNER", SYM(INNER_SYM)},
1872 { "INNOBASE", SYM(INNOBASE_SYM)},
1874 { "SIGNED", SYM(SIGNED_SYM)},
1875 { "SIMPLE", SYM(SIMPLE_SYM)},
1876 { "SLAVE", SYM(SLAVE)},
1877 + { "SLOW", SYM(SLOW_SYM)},
1878 { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
1879 { "SMALLINT", SYM(SMALLINT)},
1880 { "SOME", SYM(ANY_SYM)},
1882 { "TABLE", SYM(TABLE_SYM)},
1883 { "TABLES", SYM(TABLES)},
1884 { "TABLESPACE", SYM(TABLESPACE)},
1885 + { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
1886 { "TEMPORARY", SYM(TEMPORARY)},
1887 { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
1888 { "TERMINATED", SYM(TERMINATED)},
1890 { "USE", SYM(USE_SYM)},
1891 { "USER", SYM(USER)},
1892 { "USER_RESOURCES", SYM(RESOURCES)},
1893 + { "USER_STATISTICS", SYM(USER_STATS_SYM)},
1894 { "USE_FRM", SYM(USE_FRM)},
1895 { "USING", SYM(USING)},
1896 { "UTC_DATE", SYM(UTC_DATE_SYM)},
1897 diff -r d35bd12bba15 sql/log.cc
1898 --- a/sql/log.cc Mon Dec 22 22:51:44 2008 -0800
1899 +++ b/sql/log.cc Mon Dec 22 22:53:26 2008 -0800
1900 @@ -1899,18 +1899,24 @@
1901 thd->current_insert_id);
1904 + if (file == &log_file)
1905 + thd->binlog_bytes_written += e.data_written;
1907 if (thd->insert_id_used)
1909 Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
1912 + if (file == &log_file)
1913 + thd->binlog_bytes_written += e.data_written;
1917 Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
1920 + if (file == &log_file)
1921 + thd->binlog_bytes_written += e.data_written;
1923 if (thd->user_var_events.elements)
1925 @@ -1926,6 +1932,8 @@
1926 user_var_event->charset_number);
1929 + if (file == &log_file)
1930 + thd->binlog_bytes_written += e.data_written;
1934 @@ -1936,6 +1944,8 @@
1936 if (event_info->write(file))
1938 + if (file == &log_file)
1939 + thd->binlog_bytes_written += event_info->data_written;
1941 if (file == &log_file) // we are writing to the real log (disk)
1943 @@ -2057,6 +2067,7 @@
1945 if (qinfo.write(&log_file))
1947 + thd->binlog_bytes_written += qinfo.data_written;
1949 /* Read from the file used to cache the queries .*/
1950 if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
1951 @@ -2103,6 +2114,7 @@
1952 /* write the first half of the split header */
1953 if (my_b_write(&log_file, header, carry))
1955 + thd->binlog_bytes_written += carry;
1958 copy fixed second half of header to cache so the correct
1959 @@ -2171,6 +2183,8 @@
1960 /* Write data to the binary log file */
1961 if (my_b_write(&log_file, cache->read_pos, length))
1963 + thd->binlog_bytes_written += length;
1965 cache->read_pos=cache->read_end; // Mark buffer used up
1966 DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
1967 } while ((length=my_b_fill(cache)));
1968 @@ -2179,6 +2193,8 @@
1970 if (commit_event->write(&log_file))
1972 + thd->binlog_bytes_written += commit_event->data_written;
1977 diff -r d35bd12bba15 sql/mysql_priv.h
1978 --- a/sql/mysql_priv.h Mon Dec 22 22:51:44 2008 -0800
1979 +++ b/sql/mysql_priv.h Mon Dec 22 22:53:26 2008 -0800
1980 @@ -818,7 +818,15 @@
1981 bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
1982 void init_max_user_conn(void);
1983 void init_update_queries(void);
1984 +void init_global_user_stats(void);
1985 +void init_global_table_stats(void);
1986 +void init_global_index_stats(void);
1987 +void init_global_client_stats(void);
1988 void free_max_user_conn(void);
1989 +void free_global_user_stats(void);
1990 +void free_global_table_stats(void);
1991 +void free_global_index_stats(void);
1992 +void free_global_client_stats(void);
1993 pthread_handler_t handle_one_connection(void *arg);
1994 pthread_handler_t handle_bootstrap(void *arg);
1995 void end_thread(THD *thd,bool put_in_cache);
1996 @@ -1396,6 +1404,7 @@
1997 extern ulong max_connections,max_connect_errors, connect_timeout;
1998 extern ulong slave_net_timeout, slave_trans_retries;
1999 extern uint max_user_connections;
2000 +extern ulonglong denied_connections;
2001 extern ulong what_to_log,flush_time;
2002 extern ulong query_buff_size, thread_stack;
2003 extern ulong max_prepared_stmt_count, prepared_stmt_count;
2004 @@ -1426,6 +1435,7 @@
2005 extern my_bool opt_safe_show_db, opt_local_infile;
2006 extern my_bool opt_slave_compressed_protocol, use_temp_pool;
2007 extern my_bool opt_readonly, lower_case_file_system;
2008 +extern my_bool opt_userstat_running;
2009 extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
2010 extern my_bool opt_secure_auth;
2011 extern char* opt_secure_file_priv;
2012 @@ -1472,6 +1482,14 @@
2013 extern struct system_variables max_system_variables;
2014 extern struct system_status_var global_status_var;
2015 extern struct rand_struct sql_rand;
2016 +extern HASH global_user_stats;
2017 +extern HASH global_client_stats;
2018 +extern pthread_mutex_t LOCK_global_user_client_stats;
2019 +extern HASH global_table_stats;
2020 +extern pthread_mutex_t LOCK_global_table_stats;
2021 +extern HASH global_index_stats;
2022 +extern pthread_mutex_t LOCK_global_index_stats;
2023 +extern pthread_mutex_t LOCK_stats;
2025 extern const char *opt_date_time_formats[];
2026 extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
2027 diff -r d35bd12bba15 sql/mysqld.cc
2028 --- a/sql/mysqld.cc Mon Dec 22 22:51:44 2008 -0800
2029 +++ b/sql/mysqld.cc Mon Dec 22 22:53:26 2008 -0800
2031 uint opt_large_page_size= 0;
2032 my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
2033 char* opt_slow_logname= 0;
2034 +my_bool opt_userstat_running= 0;
2036 True if there is at least one per-hour limit for some user, so we should
2037 check them before each query (and possibly reset counters when hour is
2039 ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
2040 ulong max_connections, max_connect_errors;
2041 uint max_user_connections= 0;
2042 +ulonglong denied_connections = 0;
2044 Limit of the total number of prepared statements in the server.
2045 Is necessary to protect the server against out-of-memory attacks.
2046 @@ -550,6 +552,10 @@
2047 LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
2048 LOCK_global_system_variables,
2049 LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
2050 +pthread_mutex_t LOCK_stats;
2051 +pthread_mutex_t LOCK_global_user_client_stats;
2052 +pthread_mutex_t LOCK_global_table_stats;
2053 +pthread_mutex_t LOCK_global_index_stats;
2055 The below lock protects access to two global server variables:
2056 max_prepared_stmt_count and prepared_stmt_count. These variables
2057 @@ -1191,6 +1197,10 @@
2058 x_free(opt_secure_file_priv);
2059 bitmap_free(&temp_pool);
2060 free_max_user_conn();
2061 + free_global_user_stats();
2062 + free_global_client_stats();
2063 + free_global_table_stats();
2064 + free_global_index_stats();
2065 #ifdef HAVE_REPLICATION
2067 free_list(&replicate_do_db);
2068 @@ -1305,6 +1315,10 @@
2069 (void) pthread_cond_destroy(&COND_thread_cache);
2070 (void) pthread_cond_destroy(&COND_flush_thread_cache);
2071 (void) pthread_cond_destroy(&COND_manager);
2072 + (void) pthread_mutex_destroy(&LOCK_stats);
2073 + (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
2074 + (void) pthread_mutex_destroy(&LOCK_global_table_stats);
2075 + (void) pthread_mutex_destroy(&LOCK_global_index_stats);
2078 #endif /*EMBEDDED_LIBRARY*/
2079 @@ -3152,6 +3166,10 @@
2080 (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
2081 (void) pthread_cond_init(&COND_rpl_status, NULL);
2083 + (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
2084 + (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
2085 + (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
2086 + (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
2088 /* Parameter for threads created for connections */
2089 (void) pthread_attr_init(&connection_attrib);
2090 @@ -3423,6 +3441,10 @@
2091 sql_print_error("Out of memory");
2095 + init_global_table_stats();
2096 + init_global_index_stats();
2100 sql_print_error("Can't init databases");
2101 @@ -3505,6 +3527,8 @@
2103 init_max_user_conn();
2104 init_update_queries();
2105 + init_global_user_stats();
2106 + init_global_client_stats();
2110 @@ -4189,6 +4213,7 @@
2112 DBUG_PRINT("error",("Too many connections"));
2113 close_connection(thd, ER_CON_COUNT_ERROR, 1);
2114 + statistic_increment(denied_connections, &LOCK_status);
2118 @@ -5007,6 +5032,7 @@
2121 OPT_SLOW_QUERY_LOG_FILE,
2122 + OPT_USERSTAT_RUNNING,
2123 OPT_INNODB_ROLLBACK_ON_TIMEOUT,
2124 OPT_SECURE_FILE_PRIV,
2125 OPT_KEEP_FILES_ON_CREATE,
2126 @@ -6450,6 +6476,10 @@
2127 (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
2128 REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
2130 + {"userstat_running", OPT_USERSTAT_RUNNING,
2131 + "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
2132 + (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
2133 + 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
2134 {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
2137 diff -r d35bd12bba15 sql/set_var.cc
2138 --- a/sql/set_var.cc Mon Dec 22 22:51:44 2008 -0800
2139 +++ b/sql/set_var.cc Mon Dec 22 22:53:26 2008 -0800
2141 sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
2142 &SV::read_buff_size);
2143 sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
2144 +sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
2145 sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
2146 &SV::read_rnd_buff_size);
2147 sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
2149 &sys_trans_alloc_block_size,
2150 &sys_trans_prealloc_size,
2152 + &sys_userstat_running,
2154 #ifdef HAVE_BERKELEY_DB
2156 @@ -1171,6 +1173,7 @@
2157 {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
2158 {sys_updatable_views_with_limit.name,
2159 (char*) &sys_updatable_views_with_limit,SHOW_SYS},
2160 + {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
2161 {sys_version.name, (char*) &sys_version, SHOW_SYS},
2162 #ifdef HAVE_BERKELEY_DB
2163 {sys_version_bdb.name, (char*) &sys_version_bdb, SHOW_SYS},
2164 diff -r d35bd12bba15 sql/share/Makefile.in
2165 --- a/sql/share/Makefile.in Mon Dec 22 22:51:44 2008 -0800
2166 +++ b/sql/share/Makefile.in Mon Dec 22 22:53:26 2008 -0800
2169 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
2174 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
2175 diff -r d35bd12bba15 sql/sql_base.cc
2176 --- a/sql/sql_base.cc Mon Dec 22 22:51:44 2008 -0800
2177 +++ b/sql/sql_base.cc Mon Dec 22 22:53:26 2008 -0800
2178 @@ -624,6 +624,12 @@
2179 DBUG_ENTER("close_thread_table");
2180 DBUG_ASSERT(table->key_read == 0);
2181 DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
2185 + table->file->update_global_table_stats();
2186 + table->file->update_global_index_stats();
2189 *table_ptr=table->next;
2190 if (table->needs_reopen_or_name_lock() ||
2193 DBUG_ENTER("close_temporary");
2194 char path[FN_REFLEN];
2196 + table->file->update_global_table_stats();
2197 + table->file->update_global_index_stats();
2198 db_type table_type=table->s->db_type;
2199 strmov(path,table->s->path);
2200 free_io_cache(table);
2201 diff -r d35bd12bba15 sql/sql_class.cc
2202 --- a/sql/sql_class.cc Mon Dec 22 22:51:44 2008 -0800
2203 +++ b/sql/sql_class.cc Mon Dec 22 22:53:26 2008 -0800
2204 @@ -236,6 +236,13 @@
2205 bzero(ha_data, sizeof(ha_data));
2207 binlog_evt_union.do_union= FALSE;
2210 + bytes_received = 0;
2212 + binlog_bytes_written = 0;
2213 + updated_row_count = 0;
2214 + sent_row_count_2 = 0;
2216 dbug_sentry=THD_SENTRY_MAGIC;
2218 @@ -369,6 +376,88 @@
2219 total_warn_count= 0;
2221 bzero((char *) &status_var, sizeof(status_var));
2225 +// Resets stats in a THD.
2226 +void THD::reset_stats(void) {
2227 + current_connect_time = time(NULL);
2228 + last_global_update_time = current_connect_time;
2229 + reset_diff_stats();
2232 +// Resets the 'diff' stats, which are used to update global stats.
2233 +void THD::reset_diff_stats(void) {
2234 + diff_total_busy_time = 0;
2235 + diff_total_cpu_time = 0;
2236 + diff_total_bytes_received = 0;
2237 + diff_total_bytes_sent = 0;
2238 + diff_total_binlog_bytes_written = 0;
2239 + diff_total_sent_rows = 0;
2240 + diff_total_updated_rows = 0;
2241 + diff_total_read_rows = 0;
2242 + diff_select_commands = 0;
2243 + diff_update_commands = 0;
2244 + diff_other_commands = 0;
2245 + diff_commit_trans = 0;
2246 + diff_rollback_trans = 0;
2247 + diff_denied_connections = 0;
2248 + diff_lost_connections = 0;
2249 + diff_access_denied_errors = 0;
2250 + diff_empty_queries = 0;
2253 +// Updates 'diff' stats of a THD.
2254 +void THD::update_stats(bool ran_command) {
2255 + if (opt_userstat_running) {
2256 + diff_total_busy_time += busy_time;
2257 + diff_total_cpu_time += cpu_time;
2258 + diff_total_bytes_received += bytes_received;
2259 + diff_total_bytes_sent += bytes_sent;
2260 + diff_total_binlog_bytes_written += binlog_bytes_written;
2261 + diff_total_sent_rows += sent_row_count_2;
2262 + diff_total_updated_rows += updated_row_count;
2263 + // diff_total_read_rows is updated in handler.cc.
2265 + if (ran_command) {
2266 + // The replication thread has the COM_CONNECT command.
2267 + if ((old_command == COM_QUERY || command == COM_CONNECT) &&
2268 + (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
2270 + if (lex->sql_command == SQLCOM_SELECT) {
2271 + if (lex->orig_sql_command == SQLCOM_END) {
2272 + diff_select_commands++;
2273 + if (!sent_row_count_2)
2274 + diff_empty_queries++;
2276 + // 'SHOW ' commands become SQLCOM_SELECT.
2277 + diff_other_commands++;
2278 + // 'SHOW ' commands shouldn't inflate total sent row count.
2279 + diff_total_sent_rows -= sent_row_count_2;
2281 + } else if (is_update_query(lex->sql_command)) {
2282 + diff_update_commands++;
2284 + diff_other_commands++;
2288 + // diff_commit_trans is updated in handler.cc.
2289 + // diff_rollback_trans is updated in handler.cc.
2290 + // diff_denied_connections is updated in sql_parse.cc.
2291 + // diff_lost_connections is updated in sql_parse.cc.
2292 + // diff_access_denied_errors is updated in sql_parse.cc.
2294 + /* reset counters to zero to avoid double-counting since values
2295 + are already store in diff_total_*. */
2299 + bytes_received = 0;
2301 + binlog_bytes_written = 0;
2302 + updated_row_count = 0;
2303 + sent_row_count_2 = 0;
2309 void THD::change_user(void)
2311 + pthread_mutex_lock(&LOCK_status);
2312 + add_to_status(&global_status_var, &status_var);
2313 + pthread_mutex_unlock(&LOCK_status);
2317 @@ -892,6 +984,33 @@
2321 +char *THD::get_client_host_port(THD *client)
2323 + Security_context *client_sctx= client->security_ctx;
2324 + char *client_host= NULL;
2326 + if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
2327 + security_ctx->host_or_ip[0])
2329 + if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
2330 + my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
2331 + "%s:%u", client_sctx->host_or_ip, client->peer_port);
2334 + client_host= this->strdup(client_sctx->host_or_ip[0] ?
2335 + client_sctx->host_or_ip :
2336 + client_sctx->host ? client_sctx->host : "");
2338 + return client_host;
2341 +const char *get_client_host(THD *client)
2343 + return client->security_ctx->host_or_ip[0] ?
2344 + client->security_ctx->host_or_ip :
2345 + client->security_ctx->host ? client->security_ctx->host : "";
2349 struct Item_change_record: public ilink
2351 @@ -1062,6 +1181,7 @@
2354 thd->sent_row_count++;
2355 + thd->sent_row_count_2++;
2358 if (!thd->net.report_error)
2359 @@ -1154,6 +1274,7 @@
2360 select_export::~select_export()
2362 thd->sent_row_count=row_count;
2363 + thd->sent_row_count_2=row_count;
2367 @@ -2088,6 +2209,7 @@
2368 if (likely(thd != 0))
2369 { /* current_thd==0 when close_connection() calls net_send_error() */
2370 thd->status_var.bytes_sent+= length;
2371 + thd->bytes_sent+= length;
2375 @@ -2095,6 +2217,7 @@
2376 void thd_increment_bytes_received(ulong length)
2378 current_thd->status_var.bytes_received+= length;
2379 + current_thd->bytes_received+= length;
2383 diff -r d35bd12bba15 sql/sql_class.h
2384 --- a/sql/sql_class.h Mon Dec 22 22:51:44 2008 -0800
2385 +++ b/sql/sql_class.h Mon Dec 22 22:53:26 2008 -0800
2386 @@ -1292,6 +1292,8 @@
2387 first byte of the packet in do_command()
2389 enum enum_server_command command;
2390 + // Used to save the command, before it is set to COM_SLEEP.
2391 + enum enum_server_command old_command;
2393 uint32 file_id; // for LOAD DATA INFILE
2395 @@ -1481,6 +1483,8 @@
2396 /* variables.transaction_isolation is reset to this after each commit */
2397 enum_tx_isolation session_tx_isolation;
2398 enum_check_fields count_cuted_fields;
2399 + ha_rows updated_row_count;
2400 + ha_rows sent_row_count_2; /* for userstat */
2402 DYNAMIC_ARRAY user_var_events; /* For user variables replication */
2403 MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
2404 @@ -1587,6 +1591,49 @@
2406 LOG_INFO* current_linfo;
2407 NET* slave_net; // network connection from slave -> m.
2410 + Used to update global user stats. The global user stats are updated
2411 + occasionally with the 'diff' variables. After the update, the 'diff'
2412 + variables are reset to 0.
2414 + // Time when the current thread connected to MySQL.
2415 + time_t current_connect_time;
2416 + // Last time when THD stats were updated in global_user_stats.
2417 + time_t last_global_update_time;
2418 + // Busy (non-idle) time for just one command.
2420 + // Busy time not updated in global_user_stats yet.
2421 + double diff_total_busy_time;
2422 + // Cpu (non-idle) time for just one thread.
2424 + // Cpu time not updated in global_user_stats yet.
2425 + double diff_total_cpu_time;
2426 + /* bytes counting */
2427 + ulonglong bytes_received;
2428 + ulonglong diff_total_bytes_received;
2429 + ulonglong bytes_sent;
2430 + ulonglong diff_total_bytes_sent;
2431 + ulonglong binlog_bytes_written;
2432 + ulonglong diff_total_binlog_bytes_written;
2434 + // Number of rows not reflected in global_user_stats yet.
2435 + ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
2436 + // Number of commands not reflected in global_user_stats yet.
2437 + ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
2438 + // Number of transactions not reflected in global_user_stats yet.
2439 + ulonglong diff_commit_trans, diff_rollback_trans;
2440 + // Number of connection errors not reflected in global_user_stats yet.
2441 + ulonglong diff_denied_connections, diff_lost_connections;
2442 + // Number of db access denied, not reflected in global_user_stats yet.
2443 + ulonglong diff_access_denied_errors;
2444 + // Number of queries that return 0 rows
2445 + ulonglong diff_empty_queries;
2447 + // Per account query delay in miliseconds. When not 0, sleep this number of
2448 + // milliseconds before every SQL command.
2449 + ulonglong query_delay_millis;
2451 /* Used by the sys_var class to store temporary values */
2454 @@ -1642,6 +1689,11 @@
2457 void init_for_queries();
2458 + void reset_stats(void);
2459 + void reset_diff_stats(void);
2460 + // ran_command is true when this is called immediately after a
2461 + // command has been run.
2462 + void update_stats(bool ran_command);
2463 void change_user(void);
2465 void cleanup_after_query();
2466 @@ -1871,7 +1923,13 @@
2468 *p_db_length= db_length;
2471 + // Returns string as 'IP:port' for the client-side of the connnection represented
2472 + // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
2473 + // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
2476 + char *get_client_host_port(THD *client);
2480 @@ -1915,6 +1973,11 @@
2481 MEM_ROOT main_mem_root;
2484 +// Returns string as 'IP' for the client-side of the connection represented by
2485 +// 'client'. Does not allocate memory. May return "".
2486 +const char *get_client_host(THD *client);
2488 +#define LIST_PROCESS_HOST_LEN 64
2490 #define tmp_disable_binlog(A) \
2491 {ulonglong tmp_disable_binlog__save_options= (A)->options; \
2492 diff -r d35bd12bba15 sql/sql_delete.cc
2493 --- a/sql/sql_delete.cc Mon Dec 22 22:51:44 2008 -0800
2494 +++ b/sql/sql_delete.cc Mon Dec 22 22:53:26 2008 -0800
2496 send_ok(thd,deleted);
2497 DBUG_PRINT("info",("%ld records deleted",(long) deleted));
2499 + thd->updated_row_count += deleted;
2500 DBUG_RETURN(error >= 0 || thd->net.report_error);
2504 thd->row_count_func= deleted;
2505 ::send_ok(thd, deleted);
2507 + thd->updated_row_count += deleted;
2511 diff -r d35bd12bba15 sql/sql_insert.cc
2512 --- a/sql/sql_insert.cc Mon Dec 22 22:51:44 2008 -0800
2513 +++ b/sql/sql_insert.cc Mon Dec 22 22:53:26 2008 -0800
2515 thd->row_count_func= info.copied + info.deleted + updated;
2516 ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
2518 + thd->updated_row_count += thd->row_count_func;
2519 thd->abort_on_warning= 0;
2522 @@ -3036,6 +3037,7 @@
2523 autoinc_value_of_first_inserted_row : thd->insert_id_used ?
2524 thd->last_insert_id : 0;
2525 ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
2526 + thd->updated_row_count += thd->row_count_func;
2530 diff -r d35bd12bba15 sql/sql_lex.h
2531 --- a/sql/sql_lex.h Mon Dec 22 22:51:44 2008 -0800
2532 +++ b/sql/sql_lex.h Mon Dec 22 22:53:26 2008 -0800
2534 When a command is added here, be sure it's also added in mysqld.cc
2535 in "struct show_var_st status_vars[]= {" ...
2537 + // TODO(mcallaghan): update status_vars in mysqld to export these
2538 + SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
2539 + SQLCOM_SHOW_CLIENT_STATS,
2540 /* This should be the last !!! */
2543 diff -r d35bd12bba15 sql/sql_parse.cc
2544 --- a/sql/sql_parse.cc Mon Dec 22 22:51:44 2008 -0800
2545 +++ b/sql/sql_parse.cc Mon Dec 22 22:53:26 2008 -0800
2547 const char *table_name);
2548 static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
2550 +// Increments connection count for user.
2551 +static int increment_connection_count(THD* thd, bool use_lock);
2553 +// Uses the THD to update the global stats by user name and client IP
2554 +void update_global_user_stats(THD* thd, bool create_user, time_t now);
2556 const char *any_db="*any*"; // Special symbol for check_access
2558 const char *command_name[]={
2559 @@ -145,6 +151,17 @@
2560 #ifndef EMBEDDED_LIBRARY
2561 static bool do_command(THD *thd);
2562 #endif // EMBEDDED_LIBRARY
2564 +HASH global_user_stats;
2565 +HASH global_client_stats;
2566 +// Protects global_user_stats and global_client_stats
2567 +extern pthread_mutex_t LOCK_global_user_client_stats;
2569 +HASH global_table_stats;
2570 +extern pthread_mutex_t LOCK_global_table_stats;
2572 +HASH global_index_stats;
2573 +extern pthread_mutex_t LOCK_global_index_stats;
2576 extern void win_install_sigabrt_handler(void);
2578 mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
2581 + thd->diff_access_denied_errors++;
2582 net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
2583 thd->main_security_ctx.user,
2584 thd->main_security_ctx.host_or_ip,
2585 @@ -536,12 +554,190 @@
2586 void init_max_user_conn(void)
2588 #ifndef NO_EMBEDDED_ACCESS_CHECKS
2589 - (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
2591 - (hash_get_key) get_key_conn, (hash_free_key) free_user,
2595 + if (hash_init(&hash_user_connections,system_charset_info,max_connections,
2597 + (hash_get_key) get_key_conn, (hash_free_key) free_user,
2599 + sql_print_error("Initializing hash_user_connections failed.");
2605 +byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
2606 + my_bool not_used __attribute__((unused)))
2608 + *length = strlen(user_stats->user);
2609 + return (byte*)user_stats->user;
2612 +void free_user_stats(USER_STATS* user_stats)
2614 + my_free((char*)user_stats, MYF(0));
2617 +void init_user_stats(USER_STATS *user_stats,
2619 + const char *priv_user,
2620 + uint total_connections,
2621 + uint concurrent_connections,
2622 + time_t connected_time,
2625 + ulonglong bytes_received,
2626 + ulonglong bytes_sent,
2627 + ulonglong binlog_bytes_written,
2628 + ha_rows rows_fetched,
2629 + ha_rows rows_updated,
2630 + ha_rows rows_read,
2631 + ulonglong select_commands,
2632 + ulonglong update_commands,
2633 + ulonglong other_commands,
2634 + ulonglong commit_trans,
2635 + ulonglong rollback_trans,
2636 + ulonglong denied_connections,
2637 + ulonglong lost_connections,
2638 + ulonglong access_denied_errors,
2639 + ulonglong empty_queries)
2641 + DBUG_ENTER("init_user_stats");
2642 + DBUG_PRINT("info",
2643 + ("Add user_stats entry for user %s - priv_user %s",
2644 + user, priv_user));
2645 + strncpy(user_stats->user, user, sizeof(user_stats->user));
2646 + strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
2648 + user_stats->total_connections = total_connections;
2649 + user_stats->concurrent_connections = concurrent_connections;
2650 + user_stats->connected_time = connected_time;
2651 + user_stats->busy_time = busy_time;
2652 + user_stats->cpu_time = cpu_time;
2653 + user_stats->bytes_received = bytes_received;
2654 + user_stats->bytes_sent = bytes_sent;
2655 + user_stats->binlog_bytes_written = binlog_bytes_written;
2656 + user_stats->rows_fetched = rows_fetched;
2657 + user_stats->rows_updated = rows_updated;
2658 + user_stats->rows_read = rows_read;
2659 + user_stats->select_commands = select_commands;
2660 + user_stats->update_commands = update_commands;
2661 + user_stats->other_commands = other_commands;
2662 + user_stats->commit_trans = commit_trans;
2663 + user_stats->rollback_trans = rollback_trans;
2664 + user_stats->denied_connections = denied_connections;
2665 + user_stats->lost_connections = lost_connections;
2666 + user_stats->access_denied_errors = access_denied_errors;
2667 + user_stats->empty_queries = empty_queries;
2671 +void add_user_stats(USER_STATS *user_stats,
2672 + uint total_connections,
2673 + uint concurrent_connections,
2674 + time_t connected_time,
2677 + ulonglong bytes_received,
2678 + ulonglong bytes_sent,
2679 + ulonglong binlog_bytes_written,
2680 + ha_rows rows_fetched,
2681 + ha_rows rows_updated,
2682 + ha_rows rows_read,
2683 + ulonglong select_commands,
2684 + ulonglong update_commands,
2685 + ulonglong other_commands,
2686 + ulonglong commit_trans,
2687 + ulonglong rollback_trans,
2688 + ulonglong denied_connections,
2689 + ulonglong lost_connections,
2690 + ulonglong access_denied_errors,
2691 + ulonglong empty_queries)
2693 + user_stats->total_connections += total_connections;
2694 + user_stats->concurrent_connections += concurrent_connections;
2695 + user_stats->connected_time += connected_time;
2696 + user_stats->busy_time += busy_time;
2697 + user_stats->cpu_time += cpu_time;
2698 + user_stats->bytes_received += bytes_received;
2699 + user_stats->bytes_sent += bytes_sent;
2700 + user_stats->binlog_bytes_written += binlog_bytes_written;
2701 + user_stats->rows_fetched += rows_fetched;
2702 + user_stats->rows_updated += rows_updated;
2703 + user_stats->rows_read += rows_read;
2704 + user_stats->select_commands += select_commands;
2705 + user_stats->update_commands += update_commands;
2706 + user_stats->other_commands += other_commands;
2707 + user_stats->commit_trans += commit_trans;
2708 + user_stats->rollback_trans += rollback_trans;
2709 + user_stats->denied_connections += denied_connections;
2710 + user_stats->lost_connections += lost_connections;
2711 + user_stats->access_denied_errors += access_denied_errors;
2712 + user_stats->empty_queries += empty_queries;
2715 +void init_global_user_stats(void)
2717 + if (hash_init(&global_user_stats, system_charset_info, max_connections,
2718 + 0, 0, (hash_get_key)get_key_user_stats,
2719 + (hash_free_key)free_user_stats, 0)) {
2720 + sql_print_error("Initializing global_user_stats failed.");
2725 +void init_global_client_stats(void)
2727 + if (hash_init(&global_client_stats, system_charset_info, max_connections,
2728 + 0, 0, (hash_get_key)get_key_user_stats,
2729 + (hash_free_key)free_user_stats, 0)) {
2730 + sql_print_error("Initializing global_client_stats failed.");
2735 +extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
2736 + my_bool not_used __attribute__((unused)))
2738 + *length = strlen(table_stats->table);
2739 + return (byte*)table_stats->table;
2742 +extern "C" void free_table_stats(TABLE_STATS* table_stats)
2744 + my_free((char*)table_stats, MYF(0));
2747 +void init_global_table_stats(void)
2749 + if (hash_init(&global_table_stats, system_charset_info, max_connections,
2750 + 0, 0, (hash_get_key)get_key_table_stats,
2751 + (hash_free_key)free_table_stats, 0)) {
2752 + sql_print_error("Initializing global_table_stats failed.");
2757 +extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
2758 + my_bool not_used __attribute__((unused)))
2760 + *length = strlen(index_stats->index);
2761 + return (byte*)index_stats->index;
2764 +extern "C" void free_index_stats(INDEX_STATS* index_stats)
2766 + my_free((char*)index_stats, MYF(0));
2769 +void init_global_index_stats(void)
2771 + if (hash_init(&global_index_stats, system_charset_info, max_connections,
2772 + 0, 0, (hash_get_key)get_key_index_stats,
2773 + (hash_free_key)free_index_stats, 0)) {
2774 + sql_print_error("Initializing global_index_stats failed.");
2782 @@ -599,7 +795,10 @@
2787 + statistic_increment(denied_connections, &LOCK_status);
2788 uc->connections--; // no need for decrease_user_connections() here
2790 (void) pthread_mutex_unlock(&LOCK_user_conn);
2793 @@ -646,6 +845,25 @@
2794 #endif /* NO_EMBEDDED_ACCESS_CHECKS */
2797 +void free_global_user_stats(void)
2799 + hash_free(&global_user_stats);
2802 +void free_global_table_stats(void)
2804 + hash_free(&global_table_stats);
2807 +void free_global_index_stats(void)
2809 + hash_free(&global_index_stats);
2812 +void free_global_client_stats(void)
2814 + hash_free(&global_client_stats);
2819 @@ -698,6 +916,214 @@
2820 return uc_update_queries[command] != 0;
2823 +// 'mysql_system_user' is used for when the user is not defined for a THD.
2824 +static char mysql_system_user[] = "#mysql_system#";
2826 +// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
2827 +static char* get_valid_user_string(char* user) {
2828 + return user ? user : mysql_system_user;
2831 +// Increments the global stats connection count for an entry from
2832 +// global_client_stats or global_user_stats. Returns 0 on success
2834 +static int increment_count_by_name(const char *name, const char *role_name,
2835 + HASH *users_or_clients, THD *thd)
2837 + USER_STATS* user_stats;
2839 + if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
2842 + // First connection for this user or client
2843 + if (!(user_stats = ((USER_STATS*)
2844 + my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
2846 + return 1; // Out of memory
2849 + init_user_stats(user_stats, name, role_name,
2850 + 0, 0, // connections
2852 + 0, 0, 0, // bytes sent, received and written
2853 + 0, 0, 0, // rows fetched, updated and read
2854 + 0, 0, 0, // select, update and other commands
2855 + 0, 0, // commit and rollback trans
2856 + thd->diff_denied_connections,
2857 + 0, // lost connections
2858 + 0, // access denied errors
2859 + 0); // empty queries
2861 + if (my_hash_insert(users_or_clients, (byte*)user_stats))
2863 + my_free((char*)user_stats, 0);
2864 + return 1; // Out of memory
2867 + user_stats->total_connections++;
2871 +// Increments the global user and client stats connection count. If 'use_lock'
2872 +// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
2873 +// 0 on success, 1 on error.
2874 +static int increment_connection_count(THD* thd, bool use_lock)
2876 + char* user_string = get_valid_user_string(thd->main_security_ctx.user);
2877 + const char* client_string = get_client_host(thd);
2878 + int return_value = 0;
2880 + if (!opt_userstat_running)
2881 + return return_value;
2883 + if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
2885 + if (increment_count_by_name(user_string, user_string,
2886 + &global_user_stats, thd))
2891 + if (increment_count_by_name(client_string,
2893 + &global_client_stats, thd))
2900 + if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
2901 + return return_value;
2904 +// Used to update the global user and client stats.
2905 +static void update_global_user_stats_with_user(THD* thd,
2906 + USER_STATS* user_stats,
2909 + user_stats->connected_time += now - thd->last_global_update_time;
2910 + thd->last_global_update_time = now;
2911 + user_stats->busy_time += thd->diff_total_busy_time;
2912 + user_stats->cpu_time += thd->diff_total_cpu_time;
2913 + user_stats->bytes_received += thd->diff_total_bytes_received;
2914 + user_stats->bytes_sent += thd->diff_total_bytes_sent;
2915 + user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
2916 + user_stats->rows_fetched += thd->diff_total_sent_rows;
2917 + user_stats->rows_updated += thd->diff_total_updated_rows;
2918 + user_stats->rows_read += thd->diff_total_read_rows;
2919 + user_stats->select_commands += thd->diff_select_commands;
2920 + user_stats->update_commands += thd->diff_update_commands;
2921 + user_stats->other_commands += thd->diff_other_commands;
2922 + user_stats->commit_trans += thd->diff_commit_trans;
2923 + user_stats->rollback_trans += thd->diff_rollback_trans;
2924 + user_stats->denied_connections += thd->diff_denied_connections;
2925 + user_stats->lost_connections += thd->diff_lost_connections;
2926 + user_stats->access_denied_errors += thd->diff_access_denied_errors;
2927 + user_stats->empty_queries += thd->diff_empty_queries;
2930 +// Updates the global stats of a user or client
2931 +void update_global_user_stats(THD* thd, bool create_user, time_t now)
2933 + if (opt_userstat_running) {
2934 + char* user_string = get_valid_user_string(thd->main_security_ctx.user);
2935 + const char* client_string = get_client_host(thd);
2937 + USER_STATS* user_stats;
2938 + pthread_mutex_lock(&LOCK_global_user_client_stats);
2940 + // Update by user name
2941 + if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
2942 + (byte*)user_string,
2943 + strlen(user_string)))) {
2945 + update_global_user_stats_with_user(thd, user_stats, now);
2947 + // Create the entry
2948 + if (create_user) {
2949 + increment_count_by_name(user_string, user_string,
2950 + &global_user_stats, thd);
2954 + // Update by client IP
2955 + if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
2956 + (byte*)client_string,
2957 + strlen(client_string)))) {
2958 + // Found by client IP
2959 + update_global_user_stats_with_user(thd, user_stats, now);
2961 + // Create the entry
2962 + if (create_user) {
2963 + increment_count_by_name(client_string,
2965 + &global_client_stats, thd);
2968 + thd->reset_diff_stats();
2970 + pthread_mutex_unlock(&LOCK_global_user_client_stats);
2972 + thd->reset_diff_stats();
2976 +// Determines the concurrent number of connections of current threads.
2977 +static void set_connections_stats()
2979 + USER_STATS* user_stats;
2981 + pthread_mutex_lock(&LOCK_global_user_client_stats);
2982 + pthread_mutex_lock(&LOCK_thread_count);
2984 + // Resets all concurrent connections to 0.
2985 + for (int i = 0; i < global_user_stats.records; ++i) {
2986 + user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
2987 + user_stats->concurrent_connections = 0;
2989 + for (int i = 0; i < global_client_stats.records; ++i) {
2990 + user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
2991 + user_stats->concurrent_connections = 0;
2994 + I_List_iterator<THD> it(threads);
2996 + time_t now = time(NULL);
2997 + // Iterates through the current threads.
2998 + while ((thd = it++)) {
2999 + char* user_string = get_valid_user_string(thd->main_security_ctx.user);
3000 + if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
3001 + (byte*)user_string,
3002 + strlen(user_string)))) {
3004 + user_stats->concurrent_connections++;
3005 + update_global_user_stats_with_user(thd, user_stats, now);
3007 + // The user name should exist.
3008 + if (user_string == mysql_system_user) {
3009 + // Only create the user if it is the mysql_system_user
3010 + increment_count_by_name(user_string, user_string,
3011 + &global_user_stats, thd);
3015 + const char* client_string = get_client_host(thd);
3016 + if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
3017 + (byte*)client_string,
3018 + strlen(client_string)))) {
3020 + user_stats->concurrent_connections++;
3021 + update_global_user_stats_with_user(thd, user_stats, now);
3023 + // Do nothing, unlike what is done for global_user_stats
3025 + thd->reset_diff_stats();
3027 + pthread_mutex_unlock(&LOCK_thread_count);
3028 + pthread_mutex_unlock(&LOCK_global_user_client_stats);
3032 Reset per-hour user resource limits when it has been more than
3033 an hour since they were last checked
3034 @@ -1184,6 +1610,8 @@
3035 my_net_set_read_timeout(net, connect_timeout);
3036 my_net_set_write_timeout(net, connect_timeout);
3038 + bool create_user = true;
3040 if ((error=check_connection(thd)))
3041 { // Wrong permissions
3043 @@ -1193,8 +1621,22 @@
3044 my_sleep(1000); /* must wait after eof() */
3046 statistic_increment(aborted_connects,&LOCK_status);
3047 + thd->diff_denied_connections++;
3048 + if (error == -2) {
3049 + // Do not create statistics for a user who does not exist, or failed
3050 + // to authenticate.
3051 + create_user = false;
3056 + thd->reset_stats();
3057 + // Updates global user connection stats.
3058 + if (increment_connection_count(thd, true)) {
3059 + net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
3064 netware_reg_user(sctx->ip, sctx->user, "MySQL");
3066 @@ -1251,6 +1693,7 @@
3067 net->vio && net->error && net->report_error)
3069 statistic_increment(aborted_threads, &LOCK_status);
3070 + thd->diff_lost_connections++;
3073 if (net->error && net->vio != 0 && net->report_error)
3074 @@ -1270,6 +1713,8 @@
3077 close_connection(thd, 0, 1);
3078 + thd->update_stats(false);
3079 + update_global_user_stats(thd, create_user, time(NULL));
3082 If end_thread returns, we are either running with --one-thread
3083 @@ -1601,6 +2046,13 @@
3085 thd->clear_error(); // Clear error message
3087 + thd->updated_row_count=0;
3090 + thd->bytes_received=0;
3091 + thd->bytes_sent=0;
3092 + thd->binlog_bytes_written=0;
3094 net_new_transaction(net);
3096 packet_length= my_net_read(net);
3097 @@ -1759,6 +2211,9 @@
3100 thd->command=command;
3101 + // To increment the corrent command counter for user stats, 'command' must
3102 + // be saved because it is set to COM_SLEEP at the end of this function.
3103 + thd->old_command = command;
3105 Commands which always take a long time are logged into
3106 the slow log only if opt_log_slow_admin_statements is set.
3107 @@ -4424,6 +4879,15 @@
3108 if (check_global_access(thd,RELOAD_ACL))
3111 + if(lex->type & REFRESH_SLOW_QUERY_LOG) {
3112 + /* We are only flushing slow query log */
3113 + mysql_slow_log.new_file(1);
3121 reload_acl_and_cache() will tell us if we are allowed to write to the
3123 @@ -4731,6 +5195,7 @@
3125 if (check_global_access(thd, SUPER_ACL))
3127 + thd->diff_access_denied_errors++;
3128 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
3129 goto create_sp_error;
3131 @@ -5567,6 +6032,7 @@
3134 const char *db_name= db ? db : thd->db;
3135 + thd->diff_access_denied_errors++;
3136 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3137 sctx->priv_user, sctx->priv_host, db_name);
3139 @@ -5602,6 +6068,7 @@
3140 { // We can never grant this
3141 DBUG_PRINT("error",("No possible access"));
3143 + thd->diff_access_denied_errors++;
3144 my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
3147 @@ -5634,11 +6101,15 @@
3149 DBUG_PRINT("error",("Access denied"));
3152 + // increment needs !no_errors condition, otherwise double counting.
3153 + thd->diff_access_denied_errors++;
3154 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3155 sctx->priv_user, sctx->priv_host,
3156 (db ? db : (thd->db ?
3158 "unknown"))); /* purecov: tested */
3160 DBUG_RETURN(TRUE); /* purecov: tested */
3161 #endif /* NO_EMBEDDED_ACCESS_CHECKS */
3163 @@ -5672,6 +6143,7 @@
3164 if ((thd->security_ctx->master_access & want_access))
3166 get_privilege_desc(command, sizeof(command), want_access);
3167 + thd->diff_access_denied_errors++;
3168 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
3170 #endif /* NO_EMBEDDED_ACCESS_CHECKS */
3171 @@ -5704,6 +6176,7 @@
3173 if (!thd->col_access && check_grant_db(thd, dst_db_name))
3175 + thd->diff_access_denied_errors++;
3176 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3177 thd->security_ctx->priv_user,
3178 thd->security_ctx->priv_host,
3179 @@ -5735,6 +6208,12 @@
3180 check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
3184 + case SCH_USER_STATS:
3185 + case SCH_CLIENT_STATS:
3186 + return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
3187 + case SCH_TABLE_STATS:
3188 + case SCH_INDEX_STATS:
3189 case SCH_OPEN_TABLES:
3192 @@ -5788,8 +6267,8 @@
3193 #ifndef NO_EMBEDDED_ACCESS_CHECKS
3194 TABLE_LIST *org_tables= tables;
3196 + Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
3197 TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
3198 - Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
3200 The check that first_not_own_table is not reached is for the case when
3201 the given table list refers to the list for prelocking (contains tables
3202 @@ -5806,9 +6285,12 @@
3203 (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
3207 + thd->diff_access_denied_errors++;
3208 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3209 sctx->priv_user, sctx->priv_host,
3210 INFORMATION_SCHEMA_NAME.str);
3215 @@ -6317,6 +6799,30 @@
3218 mysql_reset_thd_for_next_command(thd);
3220 + int start_time_error = 0;
3221 + int end_time_error = 0;
3222 + struct timeval start_time, end_time;
3223 + double start_usecs = 0;
3224 + double end_usecs = 0;
3226 + int cputime_error = 0;
3227 + struct timespec tp;
3228 + double start_cpu_nsecs = 0;
3229 + double end_cpu_nsecs = 0;
3231 + if (opt_userstat_running) {
3232 +#ifdef HAVE_CLOCK_GETTIME
3233 + /* get start cputime */
3234 + if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3235 + start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3238 + // Gets the start time, in order to measure how long this command takes.
3239 + if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3240 + start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3244 if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
3246 @@ -6396,6 +6902,39 @@
3247 *found_semicolon= NULL;
3250 + if (opt_userstat_running) {
3251 + // Gets the end time.
3252 + if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3253 + end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3256 + // Calculates the difference between the end and start times.
3257 + if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3258 + thd->busy_time = (end_usecs - start_usecs) / 1000000;
3259 + // In case there are bad values, 2629743 is the #seconds in a month.
3260 + if (thd->busy_time > 2629743) {
3261 + thd->busy_time = 0;
3264 + // end time went back in time, or gettimeofday() failed.
3265 + thd->busy_time = 0;
3268 +#ifdef HAVE_CLOCK_GETTIME
3269 + /* get end cputime */
3270 + if (!cputime_error &&
3271 + !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3272 + end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3274 + if (start_cpu_nsecs && !cputime_error)
3275 + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3277 + thd->cpu_time = 0;
3279 + // Updates THD stats and the global user stats.
3280 + thd->update_stats(true);
3281 + update_global_user_stats(thd, true, time(NULL));
3286 @@ -7407,8 +7946,35 @@
3287 pthread_mutex_unlock(&LOCK_active_mi);
3290 - if (options & REFRESH_USER_RESOURCES)
3291 - reset_mqh((LEX_USER *) NULL);
3292 + if (options & REFRESH_TABLE_STATS)
3294 + pthread_mutex_lock(&LOCK_global_table_stats);
3295 + free_global_table_stats();
3296 + init_global_table_stats();
3297 + pthread_mutex_unlock(&LOCK_global_table_stats);
3299 + if (options & REFRESH_INDEX_STATS)
3301 + pthread_mutex_lock(&LOCK_global_index_stats);
3302 + free_global_index_stats();
3303 + init_global_index_stats();
3304 + pthread_mutex_unlock(&LOCK_global_index_stats);
3306 + if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
3308 + pthread_mutex_lock(&LOCK_global_user_client_stats);
3309 + if (options & REFRESH_USER_STATS)
3311 + free_global_user_stats();
3312 + init_global_user_stats();
3314 + if (options & REFRESH_CLIENT_STATS)
3316 + free_global_client_stats();
3317 + init_global_client_stats();
3319 + pthread_mutex_unlock(&LOCK_global_user_client_stats);
3321 *write_to_binlog= tmp_write_to_binlog;
3324 diff -r d35bd12bba15 sql/sql_prepare.cc
3325 --- a/sql/sql_prepare.cc Mon Dec 22 22:51:44 2008 -0800
3326 +++ b/sql/sql_prepare.cc Mon Dec 22 22:53:26 2008 -0800
3329 #include <mysql_com.h>
3332 +// Uses the THD to update the global stats by user name and client IP
3333 +void update_global_user_stats(THD* thd, bool create_user, time_t now);
3335 /* A result class used to send cursor rows using the binary protocol. */
3337 @@ -1910,8 +1913,32 @@
3338 /* First of all clear possible warnings from the previous command */
3339 mysql_reset_thd_for_next_command(thd);
3341 + int start_time_error = 0;
3342 + int end_time_error = 0;
3343 + struct timeval start_time, end_time;
3344 + double start_usecs = 0;
3345 + double end_usecs = 0;
3347 + int cputime_error = 0;
3348 + struct timespec tp;
3349 + double start_cpu_nsecs = 0;
3350 + double end_cpu_nsecs = 0;
3352 + if (opt_userstat_running) {
3353 +#ifdef HAVE_CLOCK_GETTIME
3354 + /* get start cputime */
3355 + if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3356 + start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3359 + // Gets the start time, in order to measure how long this command takes.
3360 + if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3361 + start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3365 if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
3366 - DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
3367 + goto end; /* out of memory: error is set in Sql_alloc */
3369 if (thd->stmt_map.insert(thd, stmt))
3371 @@ -1919,7 +1946,7 @@
3372 The error is set in the insert. The statement itself
3373 will be also deleted there (this is how the hash works).
3379 /* Reset warnings from previous command */
3380 @@ -1941,6 +1968,40 @@
3381 thd->stmt_map.erase(stmt);
3383 /* check_prepared_statemnt sends the metadata packet in case of success */
3385 + if (opt_userstat_running) {
3386 + // Gets the end time.
3387 + if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3388 + end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3391 + // Calculates the difference between the end and start times.
3392 + if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3393 + thd->busy_time = (end_usecs - start_usecs) / 1000000;
3394 + // In case there are bad values, 2629743 is the #seconds in a month.
3395 + if (thd->busy_time > 2629743) {
3396 + thd->busy_time = 0;
3399 + // end time went back in time, or gettimeofday() failed.
3400 + thd->busy_time = 0;
3403 +#ifdef HAVE_CLOCK_GETTIME
3404 + /* get end cputime */
3405 + if (!cputime_error &&
3406 + !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3407 + end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3409 + if (start_cpu_nsecs && !cputime_error)
3410 + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3412 + thd->cpu_time = 0;
3414 + // Updates THD stats and the global user stats.
3415 + thd->update_stats(true);
3416 + update_global_user_stats(thd, true, time(NULL));
3421 @@ -2281,8 +2342,32 @@
3422 /* First of all clear possible warnings from the previous command */
3423 mysql_reset_thd_for_next_command(thd);
3425 + int start_time_error = 0;
3426 + int end_time_error = 0;
3427 + struct timeval start_time, end_time;
3428 + double start_usecs = 0;
3429 + double end_usecs = 0;
3431 + int cputime_error = 0;
3432 + struct timespec tp;
3433 + double start_cpu_nsecs = 0;
3434 + double end_cpu_nsecs = 0;
3436 + if (opt_userstat_running) {
3437 +#ifdef HAVE_CLOCK_GETTIME
3438 + /* get start cputime */
3439 + if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3440 + start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3443 + // Gets the start time, in order to measure how long this command takes.
3444 + if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3445 + start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3449 if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
3453 #ifdef ENABLED_PROFILING
3454 thd->profiling.set_query_source(stmt->query, stmt->query_length);
3455 @@ -2325,11 +2410,46 @@
3456 test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
3457 if (!(specialflag & SPECIAL_NO_PRIOR))
3458 my_pthread_setprio(pthread_self(), WAIT_PRIOR);
3462 set_params_data_err:
3463 my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
3464 reset_stmt_params(stmt);
3467 + if (opt_userstat_running) {
3468 + // Gets the end time.
3469 + if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3470 + end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3473 + // Calculates the difference between the end and start times.
3474 + if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3475 + thd->busy_time = (end_usecs - start_usecs) / 1000000;
3476 + // In case there are bad values, 2629743 is the #seconds in a month.
3477 + if (thd->busy_time > 2629743) {
3478 + thd->busy_time = 0;
3481 + // end time went back in time, or gettimeofday() failed.
3482 + thd->busy_time = 0;
3485 +#ifdef HAVE_CLOCK_GETTIME
3486 + /* get end cputime */
3487 + if (!cputime_error &&
3488 + !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3489 + end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3491 + if (start_cpu_nsecs && !cputime_error)
3492 + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3494 + thd->cpu_time = 0;
3496 + // Updates THD stats and the global user stats.
3497 + thd->update_stats(true);
3498 + update_global_user_stats(thd, true, time(NULL));
3503 @@ -2423,6 +2543,31 @@
3505 /* First of all clear possible warnings from the previous command */
3506 mysql_reset_thd_for_next_command(thd);
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;
3514 + int cputime_error = 0;
3515 + struct timespec tp;
3516 + double start_cpu_nsecs = 0;
3517 + double end_cpu_nsecs = 0;
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;
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;
3532 statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
3533 if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
3535 @@ -2455,6 +2600,39 @@
3536 thd->restore_backup_statement(stmt, &stmt_backup);
3537 thd->stmt_arena= thd;
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;
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;
3553 + // end time went back in time, or gettimeofday() failed.
3554 + thd->busy_time = 0;
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;
3563 + if (start_cpu_nsecs && !cputime_error)
3564 + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3566 + thd->cpu_time = 0;
3568 + // Updates THD stats and the global user stats.
3569 + thd->update_stats(true);
3570 + update_global_user_stats(thd, true, time(NULL));
3575 @@ -2487,6 +2665,30 @@
3576 /* First of all clear possible warnings from the previous command */
3577 mysql_reset_thd_for_next_command(thd);
3579 + int start_time_error = 0;
3580 + int end_time_error = 0;
3581 + struct timeval start_time, end_time;
3582 + double start_usecs = 0;
3583 + double end_usecs = 0;
3585 + int cputime_error = 0;
3586 + struct timespec tp;
3587 + double start_cpu_nsecs = 0;
3588 + double end_cpu_nsecs = 0;
3590 + if (opt_userstat_running) {
3591 +#ifdef HAVE_CLOCK_GETTIME
3592 + /* get start cputime */
3593 + if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3594 + start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3597 + // Gets the start time, in order to measure how long this command takes.
3598 + if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3599 + start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3603 statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
3604 if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
3606 @@ -2502,6 +2704,39 @@
3607 stmt->state= Query_arena::PREPARED;
3611 + if (opt_userstat_running) {
3612 + // Gets the end time.
3613 + if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3614 + end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3617 + // Calculates the difference between the end and start times.
3618 + if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3619 + thd->busy_time = (end_usecs - start_usecs) / 1000000;
3620 + // In case there are bad values, 2629743 is the #seconds in a month.
3621 + if (thd->busy_time > 2629743) {
3622 + thd->busy_time = 0;
3625 + // end time went back in time, or gettimeofday() failed.
3626 + thd->busy_time = 0;
3629 +#ifdef HAVE_CLOCK_GETTIME
3630 + /* get end cputime */
3631 + if (!cputime_error &&
3632 + !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3633 + end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3635 + if (start_cpu_nsecs && !cputime_error)
3636 + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3638 + thd->cpu_time = 0;
3640 + // Updates THD stats and the global user stats.
3641 + thd->update_stats(true);
3642 + update_global_user_stats(thd, true, time(NULL));
3646 diff -r d35bd12bba15 sql/sql_show.cc
3647 --- a/sql/sql_show.cc Mon Dec 22 22:51:44 2008 -0800
3648 +++ b/sql/sql_show.cc Mon Dec 22 22:53:26 2008 -0800
3650 sctx->master_access);
3651 if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
3653 + thd->diff_access_denied_errors++;
3654 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3655 sctx->priv_user, sctx->host_or_ip, dbname);
3656 mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
3657 @@ -1858,6 +1859,300 @@
3662 + Aggregate values for mapped_user entries by their role.
3665 + aggregate_user_stats
3666 + all_user_stats - input to aggregate
3667 + agg_user_stats - returns aggregated values
3674 +aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
3676 + DBUG_ENTER("aggregate_user_stats");
3677 + if (hash_init(agg_user_stats, system_charset_info,
3678 + max(all_user_stats->records, 1),
3679 + 0, 0, (hash_get_key)get_key_user_stats,
3680 + (hash_free_key)free_user_stats, 0))
3682 + sql_print_error("Malloc in aggregate_user_stats failed");
3686 + for (int i = 0; i < all_user_stats->records; ++i) {
3687 + USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
3688 + USER_STATS *agg_user;
3689 + if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
3690 + (byte*)user->priv_user,
3691 + strlen(user->priv_user))))
3693 + // First entry for this role.
3695 + (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
3697 + sql_print_error("Malloc in aggregate_user_stats failed");
3701 + init_user_stats(agg_user, user->priv_user, user->priv_user,
3702 + user->total_connections, user->concurrent_connections,
3703 + user->connected_time, user->busy_time, user->cpu_time,
3704 + user->bytes_received, user->bytes_sent,
3705 + user->binlog_bytes_written,
3706 + user->rows_fetched, user->rows_updated, user->rows_read,
3707 + user->select_commands, user->update_commands,
3708 + user->other_commands,
3709 + user->commit_trans, user->rollback_trans,
3710 + user->denied_connections, user->lost_connections,
3711 + user->access_denied_errors, user->empty_queries);
3713 + if (my_hash_insert(agg_user_stats, (byte*)agg_user))
3716 + my_free((char*)agg_user, 0);
3717 + sql_print_error("Malloc in aggregate_user_stats failed");
3723 + // Aggregate with existing values for this role.
3724 + add_user_stats(agg_user,
3725 + user->total_connections, user->concurrent_connections,
3726 + user->connected_time, user->busy_time, user->cpu_time,
3727 + user->bytes_received, user->bytes_sent,
3728 + user->binlog_bytes_written,
3729 + user->rows_fetched, user->rows_updated, user->rows_read,
3730 + user->select_commands, user->update_commands,
3731 + user->other_commands,
3732 + user->commit_trans, user->rollback_trans,
3733 + user->denied_connections, user->lost_connections,
3734 + user->access_denied_errors, user->empty_queries);
3737 + DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
3738 + all_user_stats->records, agg_user_stats->records));
3743 + Write result to network for SHOW USER_STATISTICS
3747 + all_user_stats - values to return
3754 +int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
3756 + DBUG_ENTER("send_user_stats");
3757 + for (int i = 0; i < all_user_stats->records; ++i) {
3758 + restore_record(table, s->default_values);
3759 + USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
3760 + table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
3761 + table->field[1]->store((longlong)user_stats->total_connections);
3762 + table->field[2]->store((longlong)user_stats->concurrent_connections);
3763 + table->field[3]->store((longlong)user_stats->connected_time);
3764 + table->field[4]->store((longlong)user_stats->busy_time);
3765 + table->field[5]->store((longlong)user_stats->cpu_time);
3766 + table->field[6]->store((longlong)user_stats->bytes_received);
3767 + table->field[7]->store((longlong)user_stats->bytes_sent);
3768 + table->field[8]->store((longlong)user_stats->binlog_bytes_written);
3769 + table->field[9]->store((longlong)user_stats->rows_fetched);
3770 + table->field[10]->store((longlong)user_stats->rows_updated);
3771 + table->field[11]->store((longlong)user_stats->rows_read);
3772 + table->field[12]->store((longlong)user_stats->select_commands);
3773 + table->field[13]->store((longlong)user_stats->update_commands);
3774 + table->field[14]->store((longlong)user_stats->other_commands);
3775 + table->field[15]->store((longlong)user_stats->commit_trans);
3776 + table->field[16]->store((longlong)user_stats->rollback_trans);
3777 + table->field[17]->store((longlong)user_stats->denied_connections);
3778 + table->field[18]->store((longlong)user_stats->lost_connections);
3779 + table->field[19]->store((longlong)user_stats->access_denied_errors);
3780 + table->field[20]->store((longlong)user_stats->empty_queries);
3781 + if (schema_table_store_record(thd, table))
3783 + DBUG_PRINT("error", ("store record error"));
3791 + Process SHOW USER_STATISTICS
3794 + mysqld_show_user_stats
3795 + thd - current thread
3796 + wild - limit results to the entry for this user
3797 + with_roles - when true, display role for mapped users
3805 +int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3807 + TABLE *table= tables->table;
3808 + DBUG_ENTER("fill_schema_user_stats");
3810 + if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
3813 + // Iterates through all the global stats and sends them to the client.
3814 + // Pattern matching on the client IP is supported.
3816 + pthread_mutex_lock(&LOCK_global_user_client_stats);
3817 + int result= send_user_stats(thd, &global_user_stats, table);
3818 + pthread_mutex_unlock(&LOCK_global_user_client_stats);
3822 + DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
3826 + DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
3831 + Process SHOW CLIENT_STATISTICS
3834 + mysqld_show_client_stats
3835 + thd - current thread
3836 + wild - limit results to the entry for this client
3844 +int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3846 + TABLE *table= tables->table;
3847 + DBUG_ENTER("fill_schema_client_stats");
3849 + if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
3852 + // Iterates through all the global stats and sends them to the client.
3853 + // Pattern matching on the client IP is supported.
3855 + pthread_mutex_lock(&LOCK_global_user_client_stats);
3856 + int result= send_user_stats(thd, &global_client_stats, table);
3857 + pthread_mutex_unlock(&LOCK_global_user_client_stats);
3861 + DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
3865 + DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
3870 +// Sends the global table stats back to the client.
3871 +int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3873 + TABLE *table= tables->table;
3874 + DBUG_ENTER("fill_schema_table_stats");
3875 + char *table_full_name, *table_schema;
3877 + pthread_mutex_lock(&LOCK_global_table_stats);
3878 + for (int i = 0; i < global_table_stats.records; ++i) {
3879 + restore_record(table, s->default_values);
3880 + TABLE_STATS *table_stats =
3881 + (TABLE_STATS*)hash_element(&global_table_stats, i);
3883 + table_full_name= thd->strdup(table_stats->table);
3884 + table_schema= strsep(&table_full_name, ".");
3886 + TABLE_LIST tmp_table;
3887 + bzero((char*) &tmp_table,sizeof(tmp_table));
3888 + tmp_table.table_name= table_full_name;
3889 + tmp_table.db= table_schema;
3890 + tmp_table.grant.privilege= 0;
3891 + if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
3892 + &tmp_table.grant.privilege, 0, 0,
3893 + is_schema_db(table_schema)) ||
3894 + grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
3897 + table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
3898 + table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
3899 + table->field[2]->store((longlong)table_stats->rows_read, TRUE);
3900 + table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
3901 + table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
3903 + if (schema_table_store_record(thd, table))
3905 + VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
3909 + pthread_mutex_unlock(&LOCK_global_table_stats);
3913 +// Sends the global index stats back to the client.
3914 +int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3916 + TABLE *table= tables->table;
3917 + DBUG_ENTER("fill_schema_index_stats");
3918 + char *index_full_name, *table_schema, *table_name;
3920 + pthread_mutex_lock(&LOCK_global_index_stats);
3921 + for (int i = 0; i < global_index_stats.records; ++i) {
3922 + restore_record(table, s->default_values);
3923 + INDEX_STATS *index_stats =
3924 + (INDEX_STATS*)hash_element(&global_index_stats, i);
3926 + index_full_name= thd->strdup(index_stats->index);
3927 + table_schema= strsep(&index_full_name, ".");
3928 + table_name= strsep(&index_full_name, ".");
3930 + TABLE_LIST tmp_table;
3931 + bzero((char*) &tmp_table,sizeof(tmp_table));
3932 + tmp_table.table_name= table_name;
3933 + tmp_table.db= table_schema;
3934 + tmp_table.grant.privilege= 0;
3935 + if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
3936 + &tmp_table.grant.privilege, 0, 0,
3937 + is_schema_db(table_schema)) ||
3938 + grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
3941 + table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
3942 + table->field[1]->store(table_name, strlen(table_name), system_charset_info);
3943 + table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
3944 + table->field[3]->store((longlong)index_stats->rows_read, TRUE);
3946 + if (schema_table_store_record(thd, table))
3948 + VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
3952 + pthread_mutex_unlock(&LOCK_global_index_stats);
3956 /* collect status for all running threads */
3958 @@ -4468,6 +4763,77 @@
3959 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3962 +ST_FIELD_INFO user_stats_fields_info[]=
3964 + {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
3965 + {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
3966 + {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
3967 + {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
3968 + {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
3969 + {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
3970 + {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
3971 + {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
3972 + {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
3973 + {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
3974 + {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
3975 + {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
3976 + {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
3977 + {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
3978 + {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
3979 + {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
3980 + {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
3981 + {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
3982 + {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
3983 + {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
3984 + {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
3985 + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3988 +ST_FIELD_INFO client_stats_fields_info[]=
3990 + {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
3991 + {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
3992 + {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
3993 + {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
3994 + {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
3995 + {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
3996 + {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
3997 + {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
3998 + {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
3999 + {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
4000 + {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
4001 + {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
4002 + {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
4003 + {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
4004 + {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
4005 + {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
4006 + {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
4007 + {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
4008 + {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
4009 + {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
4010 + {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
4011 + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
4015 +ST_FIELD_INFO table_stats_fields_info[]=
4017 + {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
4018 + {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
4019 + {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
4020 + {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
4021 + {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
4022 + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
4025 +ST_FIELD_INFO index_stats_fields_info[]=
4027 + {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
4028 + {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
4029 + {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
4030 + {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
4031 + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
4035 Description of ST_FIELD_INFO in table.h
4036 @@ -4477,6 +4843,8 @@
4038 {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
4039 fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
4040 + {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
4041 + fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
4042 {"COLLATIONS", collation_fields_info, create_schema_table,
4043 fill_schema_collation, make_old_format, 0, -1, -1, 0},
4044 {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
4045 @@ -4485,6 +4853,8 @@
4046 get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
4047 {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
4048 fill_schema_column_privileges, 0, 0, -1, -1, 0},
4049 + {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
4050 + fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
4051 {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
4052 get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
4053 {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
4054 @@ -4510,10 +4880,14 @@
4055 get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
4056 {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
4057 fill_schema_table_privileges, 0, 0, -1, -1, 0},
4058 + {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
4059 + fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
4060 {"TRIGGERS", triggers_fields_info, create_schema_table,
4061 get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
4062 {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
4063 fill_schema_user_privileges, 0, 0, -1, -1, 0},
4064 + {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
4065 + fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
4066 {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
4067 make_old_format, 0, -1, -1, 1},
4068 {"VIEWS", view_fields_info, create_schema_table,
4069 diff -r d35bd12bba15 sql/sql_update.cc
4070 --- a/sql/sql_update.cc Mon Dec 22 22:51:44 2008 -0800
4071 +++ b/sql/sql_update.cc Mon Dec 22 22:53:26 2008 -0800
4073 (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
4074 send_ok(thd, (ulong) thd->row_count_func,
4075 thd->insert_id_used ? thd->last_insert_id : 0L,buff);
4076 - DBUG_PRINT("info",("%ld records updated", (long) updated));
4077 + thd->updated_row_count += thd->row_count_func;
4078 + DBUG_PRINT("info",("%d records updated",updated));
4080 thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
4081 thd->abort_on_warning= 0;
4082 @@ -1832,5 +1833,6 @@
4083 (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
4084 ::send_ok(thd, (ulong) thd->row_count_func,
4085 thd->insert_id_used ? thd->last_insert_id : 0L,buff);
4086 + thd->updated_row_count += thd->row_count_func;
4089 diff -r d35bd12bba15 sql/sql_yacc.yy
4090 --- a/sql/sql_yacc.yy Mon Dec 22 22:51:44 2008 -0800
4091 +++ b/sql/sql_yacc.yy Mon Dec 22 22:53:26 2008 -0800
4096 +%token CLIENT_STATS_SYM
4104 +%token INDEX_STATS_SYM
4120 +%token TABLE_STATS_SYM
4122 %token TEMPTABLE_SYM
4128 +%token USER_STATS_SYM
4132 @@ -8244,6 +8249,38 @@
4134 Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
4136 + | CLIENT_STATS_SYM wild_and_where
4139 + Lex->sql_command = SQLCOM_SELECT;
4140 + lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
4141 + if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
4144 + | USER_STATS_SYM wild_and_where
4147 + lex->sql_command = SQLCOM_SELECT;
4148 + lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
4149 + if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
4152 + | TABLE_STATS_SYM wild_and_where
4155 + lex->sql_command= SQLCOM_SELECT;
4156 + lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
4157 + if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
4160 + | INDEX_STATS_SYM wild_and_where
4163 + lex->sql_command= SQLCOM_SELECT;
4164 + lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
4165 + if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
4168 | CREATE PROCEDURE sp_name
4171 @@ -8448,9 +8485,14 @@
4172 | LOGS_SYM { Lex->type|= REFRESH_LOG; }
4173 | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
4174 | SLAVE { Lex->type|= REFRESH_SLAVE; }
4175 + | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
4176 | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
4177 | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
4178 - | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
4179 + | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
4180 + | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
4181 + | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
4182 + | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
4183 + | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
4187 @@ -9439,6 +9481,7 @@
4191 + | CLIENT_STATS_SYM {}
4195 @@ -9491,6 +9534,7 @@
4199 + | INDEX_STATS_SYM {}
4203 @@ -9600,6 +9644,7 @@
4211 @@ -9616,6 +9661,7 @@
4215 + | TABLE_STATS_SYM {}
4219 @@ -9636,6 +9682,7 @@
4223 + | USER_STATS_SYM {}
4227 diff -r d35bd12bba15 sql/structs.h
4228 --- a/sql/structs.h Mon Dec 22 22:51:44 2008 -0800
4229 +++ b/sql/structs.h Mon Dec 22 22:53:26 2008 -0800
4230 @@ -273,6 +273,98 @@
4234 +typedef struct st_user_stats {
4235 + char user[USERNAME_LENGTH + 1];
4236 + // Account name the user is mapped to when this is a user from mapped_user.
4237 + // Otherwise, the same value as user.
4238 + char priv_user[USERNAME_LENGTH + 1];
4239 + uint total_connections;
4240 + uint concurrent_connections;
4241 + time_t connected_time; // in seconds
4242 + double busy_time; // in seconds
4243 + double cpu_time; // in seconds
4244 + ulonglong bytes_received;
4245 + ulonglong bytes_sent;
4246 + ulonglong binlog_bytes_written;
4247 + ha_rows rows_fetched, rows_updated, rows_read;
4248 + ulonglong select_commands, update_commands, other_commands;
4249 + ulonglong commit_trans, rollback_trans;
4250 + ulonglong denied_connections, lost_connections;
4251 + ulonglong access_denied_errors;
4252 + ulonglong empty_queries;
4255 +/* Lookup function for hash tables with USER_STATS entries */
4256 +extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
4257 + my_bool not_used __attribute__((unused)));
4259 +/* Free all memory for a hash table with USER_STATS entries */
4260 +extern void free_user_stats(USER_STATS* user_stats);
4262 +/* Intialize an instance of USER_STATS */
4264 +init_user_stats(USER_STATS *user_stats,
4266 + const char *priv_user,
4267 + uint total_connections,
4268 + uint concurrent_connections,
4269 + time_t connected_time,
4272 + ulonglong bytes_received,
4273 + ulonglong bytes_sent,
4274 + ulonglong binlog_bytes_written,
4275 + ha_rows rows_fetched,
4276 + ha_rows rows_updated,
4277 + ha_rows rows_read,
4278 + ulonglong select_commands,
4279 + ulonglong update_commands,
4280 + ulonglong other_commands,
4281 + ulonglong commit_trans,
4282 + ulonglong rollback_trans,
4283 + ulonglong denied_connections,
4284 + ulonglong lost_connections,
4285 + ulonglong access_denied_errors,
4286 + ulonglong empty_queries);
4288 +/* Increment values of an instance of USER_STATS */
4290 +add_user_stats(USER_STATS *user_stats,
4291 + uint total_connections,
4292 + uint concurrent_connections,
4293 + time_t connected_time,
4296 + ulonglong bytes_received,
4297 + ulonglong bytes_sent,
4298 + ulonglong binlog_bytes_written,
4299 + ha_rows rows_fetched,
4300 + ha_rows rows_updated,
4301 + ha_rows rows_read,
4302 + ulonglong select_commands,
4303 + ulonglong update_commands,
4304 + ulonglong other_commands,
4305 + ulonglong commit_trans,
4306 + ulonglong rollback_trans,
4307 + ulonglong denied_connections,
4308 + ulonglong lost_connections,
4309 + ulonglong access_denied_errors,
4310 + ulonglong empty_queries);
4312 +typedef struct st_table_stats {
4313 + char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
4314 + ulonglong rows_read, rows_changed;
4315 + ulonglong rows_changed_x_indexes;
4316 + /* Stores enum db_type, but forward declarations cannot be done */
4320 +typedef struct st_index_stats {
4321 + char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
4322 + ulonglong rows_read;
4326 /* Bits in form->update */
4327 #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
4328 #define REG_NEW_RECORD 2 /* Write a new record if not found */
4329 diff -r d35bd12bba15 sql/table.h
4330 --- a/sql/table.h Mon Dec 22 22:51:44 2008 -0800
4331 +++ b/sql/table.h Mon Dec 22 22:53:26 2008 -0800
4332 @@ -371,10 +371,12 @@
4333 enum enum_schema_tables
4338 SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
4340 SCH_COLUMN_PRIVILEGES,
4342 SCH_KEY_COLUMN_USAGE,
4345 @@ -387,8 +389,10 @@
4346 SCH_TABLE_CONSTRAINTS,
4348 SCH_TABLE_PRIVILEGES,
4351 SCH_USER_PRIVILEGES,
4356 diff -r d35bd12bba15 strings/Makefile.in
4357 --- a/strings/Makefile.in Mon Dec 22 22:51:44 2008 -0800
4358 +++ b/strings/Makefile.in Mon Dec 22 22:53:26 2008 -0800
4361 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4366 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4367 diff -r d35bd12bba15 support-files/MacOSX/Makefile.in
4368 --- a/support-files/MacOSX/Makefile.in Mon Dec 22 22:51:44 2008 -0800
4369 +++ b/support-files/MacOSX/Makefile.in Mon Dec 22 22:53:26 2008 -0800
4372 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4377 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4378 diff -r d35bd12bba15 support-files/Makefile.in
4379 --- a/support-files/Makefile.in Mon Dec 22 22:51:44 2008 -0800
4380 +++ b/support-files/Makefile.in Mon Dec 22 22:53:26 2008 -0800
4383 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4388 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4389 diff -r d35bd12bba15 support-files/RHEL4-SElinux/Makefile.in
4390 --- a/support-files/RHEL4-SElinux/Makefile.in Mon Dec 22 22:51:44 2008 -0800
4391 +++ b/support-files/RHEL4-SElinux/Makefile.in Mon Dec 22 22:53:26 2008 -0800
4394 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4399 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4400 diff -r d35bd12bba15 tests/Makefile.in
4401 --- a/tests/Makefile.in Mon Dec 22 22:51:44 2008 -0800
4402 +++ b/tests/Makefile.in Mon Dec 22 22:53:26 2008 -0800
4405 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4408 LIBS = @CLIENT_LIBS@
4410 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4411 diff -r d35bd12bba15 tools/Makefile.in
4412 --- a/tools/Makefile.in Mon Dec 22 22:51:44 2008 -0800
4413 +++ b/tools/Makefile.in Mon Dec 22 22:53:26 2008 -0800
4416 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4421 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4422 diff -r d35bd12bba15 vio/Makefile.in
4423 --- a/vio/Makefile.in Mon Dec 22 22:51:44 2008 -0800
4424 +++ b/vio/Makefile.in Mon Dec 22 22:53:26 2008 -0800
4427 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4432 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4433 diff -r d35bd12bba15 win/Makefile.in
4434 --- a/win/Makefile.in Mon Dec 22 22:51:44 2008 -0800
4435 +++ b/win/Makefile.in Mon Dec 22 22:53:26 2008 -0800
4438 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4443 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4444 diff -r d35bd12bba15 zlib/Makefile.in
4445 --- a/zlib/Makefile.in Mon Dec 22 22:51:44 2008 -0800
4446 +++ b/zlib/Makefile.in Mon Dec 22 22:53:26 2008 -0800
4449 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4452 LIBS = $(NON_THREADED_LIBS)
4454 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@