1 diff -r 1270c564d514 BUILD/Makefile.in
2 --- a/BUILD/Makefile.in Mon Dec 22 00:26:39 2008 -0800
3 +++ b/BUILD/Makefile.in Mon Dec 22 00:31:13 2008 -0800
6 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
11 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
12 diff -r 1270c564d514 Docs/Makefile.in
13 --- a/Docs/Makefile.in Mon Dec 22 00:26:39 2008 -0800
14 +++ b/Docs/Makefile.in Mon Dec 22 00:31:13 2008 -0800
17 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
22 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
23 diff -r 1270c564d514 Makefile.in
24 --- a/Makefile.in Mon Dec 22 00:26:39 2008 -0800
25 +++ b/Makefile.in Mon Dec 22 00:31:13 2008 -0800
28 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
33 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
34 diff -r 1270c564d514 SSL/Makefile.in
35 --- a/SSL/Makefile.in Mon Dec 22 00:26:39 2008 -0800
36 +++ b/SSL/Makefile.in Mon Dec 22 00:31:13 2008 -0800
39 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
44 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
45 diff -r 1270c564d514 client/Makefile.in
46 --- a/client/Makefile.in Mon Dec 22 00:26:39 2008 -0800
47 +++ b/client/Makefile.in Mon Dec 22 00:31:13 2008 -0800
50 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
55 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
56 diff -r 1270c564d514 cmd-line-utils/Makefile.in
57 --- a/cmd-line-utils/Makefile.in Mon Dec 22 00:26:39 2008 -0800
58 +++ b/cmd-line-utils/Makefile.in Mon Dec 22 00:31:13 2008 -0800
61 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
66 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
67 diff -r 1270c564d514 cmd-line-utils/libedit/Makefile.in
68 --- a/cmd-line-utils/libedit/Makefile.in Mon Dec 22 00:26:39 2008 -0800
69 +++ b/cmd-line-utils/libedit/Makefile.in Mon Dec 22 00:31:13 2008 -0800
72 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
77 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
78 diff -r 1270c564d514 cmd-line-utils/readline/Makefile.in
79 --- a/cmd-line-utils/readline/Makefile.in Mon Dec 22 00:26:39 2008 -0800
80 +++ b/cmd-line-utils/readline/Makefile.in Mon Dec 22 00:31:13 2008 -0800
83 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
88 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
89 diff -r 1270c564d514 configure.in
90 --- a/configure.in Mon Dec 22 00:26:39 2008 -0800
91 +++ b/configure.in Mon Dec 22 00:31:13 2008 -0800
92 @@ -2098,7 +2098,18 @@
93 # We also disable for SCO for the time being, the headers for the
94 # thread library we use conflicts with other headers.
96 - *) AC_CHECK_FUNCS(clock_gettime)
98 + # most systems require the program be linked with librt library to use
99 + # the function clock_gettime
100 + my_save_LIBS="$LIBS"
102 + AC_CHECK_LIB(rt,clock_gettime)
104 + LIBS="$my_save_LIBS"
107 + LIBS="$LIBS $LIBRT"
108 + AC_CHECK_FUNCS(clock_gettime)
112 @@ -2713,7 +2724,7 @@
113 AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
116 -CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
117 +CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS $LIBRT"
119 AC_SUBST(CLIENT_LIBS)
120 AC_SUBST(NON_THREADED_LIBS)
121 diff -r 1270c564d514 dbug/Makefile.in
122 --- a/dbug/Makefile.in Mon Dec 22 00:26:39 2008 -0800
123 +++ b/dbug/Makefile.in Mon Dec 22 00:31:13 2008 -0800
126 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
131 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
132 diff -r 1270c564d514 extra/Makefile.in
133 --- a/extra/Makefile.in Mon Dec 22 00:26:39 2008 -0800
134 +++ b/extra/Makefile.in Mon Dec 22 00:31:13 2008 -0800
137 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
142 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
143 diff -r 1270c564d514 extra/yassl/Makefile.in
144 --- a/extra/yassl/Makefile.in Mon Dec 22 00:26:39 2008 -0800
145 +++ b/extra/yassl/Makefile.in Mon Dec 22 00:31:13 2008 -0800
148 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
153 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
154 diff -r 1270c564d514 extra/yassl/src/Makefile.in
155 --- a/extra/yassl/src/Makefile.in Mon Dec 22 00:26:39 2008 -0800
156 +++ b/extra/yassl/src/Makefile.in Mon Dec 22 00:31:13 2008 -0800
159 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
164 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
165 diff -r 1270c564d514 extra/yassl/taocrypt/Makefile.in
166 --- a/extra/yassl/taocrypt/Makefile.in Mon Dec 22 00:26:39 2008 -0800
167 +++ b/extra/yassl/taocrypt/Makefile.in Mon Dec 22 00:31:13 2008 -0800
170 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
175 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
176 diff -r 1270c564d514 extra/yassl/taocrypt/benchmark/Makefile.in
177 --- a/extra/yassl/taocrypt/benchmark/Makefile.in Mon Dec 22 00:26:39 2008 -0800
178 +++ b/extra/yassl/taocrypt/benchmark/Makefile.in Mon Dec 22 00:31:13 2008 -0800
181 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
186 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
187 diff -r 1270c564d514 extra/yassl/taocrypt/src/Makefile.in
188 --- a/extra/yassl/taocrypt/src/Makefile.in Mon Dec 22 00:26:39 2008 -0800
189 +++ b/extra/yassl/taocrypt/src/Makefile.in Mon Dec 22 00:31:13 2008 -0800
192 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
197 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
198 diff -r 1270c564d514 extra/yassl/taocrypt/test/Makefile.in
199 --- a/extra/yassl/taocrypt/test/Makefile.in Mon Dec 22 00:26:39 2008 -0800
200 +++ b/extra/yassl/taocrypt/test/Makefile.in Mon Dec 22 00:31:13 2008 -0800
203 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
208 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
209 diff -r 1270c564d514 extra/yassl/testsuite/Makefile.in
210 --- a/extra/yassl/testsuite/Makefile.in Mon Dec 22 00:26:39 2008 -0800
211 +++ b/extra/yassl/testsuite/Makefile.in Mon Dec 22 00:31:13 2008 -0800
214 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
219 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
220 diff -r 1270c564d514 heap/Makefile.in
221 --- a/heap/Makefile.in Mon Dec 22 00:26:39 2008 -0800
222 +++ b/heap/Makefile.in Mon Dec 22 00:31:13 2008 -0800
225 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
230 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
231 diff -r 1270c564d514 include/Makefile.in
232 --- a/include/Makefile.in Mon Dec 22 00:26:39 2008 -0800
233 +++ b/include/Makefile.in Mon Dec 22 00:31:13 2008 -0800
236 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
241 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
242 diff -r 1270c564d514 include/mysql_com.h
243 --- a/include/mysql_com.h Mon Dec 22 00:26:39 2008 -0800
244 +++ b/include/mysql_com.h Mon Dec 22 00:31:13 2008 -0800
247 #define REFRESH_MASTER 128 /* Remove all bin logs in the index
248 and truncate the index */
249 +#define REFRESH_TABLE_STATS 256 /* Refresh table stats hash table */
250 +#define REFRESH_INDEX_STATS 512 /* Refresh index stats hash table */
251 +#define REFRESH_USER_STATS 1024 /* Refresh user stats hash table */
252 +#define REFRESH_SLOW_QUERY_LOG 4096 /* Flush slow query log and rotate*/
253 +#define REFRESH_CLIENT_STATS 8192 /* Refresh client stats hash table */
255 /* The following can't be set with mysql_refresh() */
256 #define REFRESH_READ_LOCK 16384 /* Lock tables for read */
257 diff -r 1270c564d514 libmysql/Makefile.in
258 --- a/libmysql/Makefile.in Mon Dec 22 00:26:39 2008 -0800
259 +++ b/libmysql/Makefile.in Mon Dec 22 00:31:13 2008 -0800
262 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
267 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
268 diff -r 1270c564d514 libmysql_r/Makefile.in
269 --- a/libmysql_r/Makefile.in Mon Dec 22 00:26:39 2008 -0800
270 +++ b/libmysql_r/Makefile.in Mon Dec 22 00:31:13 2008 -0800
273 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
276 LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
278 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
279 diff -r 1270c564d514 libmysqld/Makefile.in
280 --- a/libmysqld/Makefile.in Mon Dec 22 00:26:39 2008 -0800
281 +++ b/libmysqld/Makefile.in Mon Dec 22 00:31:13 2008 -0800
284 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
289 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
290 diff -r 1270c564d514 libmysqld/examples/Makefile.in
291 --- a/libmysqld/examples/Makefile.in Mon Dec 22 00:26:39 2008 -0800
292 +++ b/libmysqld/examples/Makefile.in Mon Dec 22 00:31:13 2008 -0800
295 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
298 LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ $(yassl_libs)
300 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
301 diff -r 1270c564d514 man/Makefile.in
302 --- a/man/Makefile.in Mon Dec 22 00:26:39 2008 -0800
303 +++ b/man/Makefile.in Mon Dec 22 00:31:13 2008 -0800
306 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
311 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
312 diff -r 1270c564d514 myisam/Makefile.in
313 --- a/myisam/Makefile.in Mon Dec 22 00:26:39 2008 -0800
314 +++ b/myisam/Makefile.in Mon Dec 22 00:31:13 2008 -0800
317 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
322 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
323 diff -r 1270c564d514 myisammrg/Makefile.in
324 --- a/myisammrg/Makefile.in Mon Dec 22 00:26:39 2008 -0800
325 +++ b/myisammrg/Makefile.in Mon Dec 22 00:31:13 2008 -0800
328 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
333 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
334 diff -r 1270c564d514 mysql-test/Makefile.in
335 --- a/mysql-test/Makefile.in Mon Dec 22 00:26:39 2008 -0800
336 +++ b/mysql-test/Makefile.in Mon Dec 22 00:31:13 2008 -0800
339 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
344 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
345 diff -r 1270c564d514 mysql-test/ndb/Makefile.in
346 --- a/mysql-test/ndb/Makefile.in Mon Dec 22 00:26:39 2008 -0800
347 +++ b/mysql-test/ndb/Makefile.in Mon Dec 22 00:31:13 2008 -0800
350 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
355 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
356 diff -r 1270c564d514 mysql-test/r/information_schema.result
357 --- a/mysql-test/r/information_schema.result Mon Dec 22 00:26:39 2008 -0800
358 +++ b/mysql-test/r/information_schema.result Mon Dec 22 00:31:13 2008 -0800
365 COLLATION_CHARACTER_SET_APPLICABILITY
385 TABLE_CONSTRAINTS TABLE_CONSTRAINTS
386 TABLE_PRIVILEGES TABLE_PRIVILEGES
387 +TABLE_STATISTICS TABLE_STATISTICS
389 tables_priv tables_priv
393 TABLE_CONSTRAINTS TABLE_CONSTRAINTS
394 TABLE_PRIVILEGES TABLE_PRIVILEGES
395 +TABLE_STATISTICS TABLE_STATISTICS
397 tables_priv tables_priv
401 TABLE_CONSTRAINTS TABLE_CONSTRAINTS
402 TABLE_PRIVILEGES TABLE_PRIVILEGES
403 +TABLE_STATISTICS TABLE_STATISTICS
405 tables_priv tables_priv
407 @@ -594,12 +601,13 @@
408 where table_schema='information_schema' limit 2;
409 TABLE_NAME TABLE_TYPE ENGINE
410 CHARACTER_SETS SYSTEM VIEW MEMORY
411 -COLLATIONS SYSTEM VIEW MEMORY
412 +CLIENT_STATISTICS SYSTEM VIEW MEMORY
413 show tables from information_schema like "T%";
414 Tables_in_information_schema (T%)
420 create database information_schema;
421 ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
424 TABLE_CONSTRAINTS SYSTEM VIEW
425 TABLE_PRIVILEGES SYSTEM VIEW
426 +TABLE_STATISTICS SYSTEM VIEW
428 create table t1(a int);
429 ERROR 42S02: Unknown table 't1' in information_schema
436 select table_name from tables where table_name='user';
439 CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
440 CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
445 drop table t_crashme;
446 select table_schema,table_name, column_name from
447 @@ -790,18 +800,20 @@
448 TABLE_NAME COLUMN_NAME PRIVILEGES
449 COLUMNS TABLE_NAME select
450 COLUMN_PRIVILEGES TABLE_NAME select
451 +INDEX_STATISTICS TABLE_NAME select
452 KEY_COLUMN_USAGE TABLE_NAME select
453 STATISTICS TABLE_NAME select
454 TABLES TABLE_NAME select
455 TABLE_CONSTRAINTS TABLE_NAME select
456 TABLE_PRIVILEGES TABLE_NAME select
457 +TABLE_STATISTICS TABLE_NAME select
458 VIEWS TABLE_NAME select
459 delete from mysql.user where user='mysqltest_4';
460 delete from mysql.db where user='mysqltest_4';
462 SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
463 table_schema count(*)
464 -information_schema 17
465 +information_schema 21
467 create table t1 (i int, j int);
468 create trigger trg1 before insert on t1 for each row
469 @@ -1187,10 +1199,12 @@
471 table_name column_name
472 CHARACTER_SETS CHARACTER_SET_NAME
473 +CLIENT_STATISTICS CLIENT
474 COLLATIONS COLLATION_NAME
475 COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
477 COLUMN_PRIVILEGES TABLE_SCHEMA
478 +INDEX_STATISTICS TABLE_SCHEMA
479 KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
481 ROUTINES ROUTINE_SCHEMA
482 @@ -1200,8 +1214,10 @@
484 TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
485 TABLE_PRIVILEGES TABLE_SCHEMA
486 +TABLE_STATISTICS TABLE_SCHEMA
487 TRIGGERS TRIGGER_SCHEMA
488 USER_PRIVILEGES GRANTEE
489 +USER_STATISTICS USER
491 SELECT t.table_name, c1.column_name
492 FROM information_schema.tables t
493 @@ -1219,10 +1235,12 @@
495 table_name column_name
496 CHARACTER_SETS CHARACTER_SET_NAME
497 +CLIENT_STATISTICS CLIENT
498 COLLATIONS COLLATION_NAME
499 COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
501 COLUMN_PRIVILEGES TABLE_SCHEMA
502 +INDEX_STATISTICS TABLE_SCHEMA
503 KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
505 ROUTINES ROUTINE_SCHEMA
506 @@ -1232,8 +1250,10 @@
508 TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
509 TABLE_PRIVILEGES TABLE_SCHEMA
510 +TABLE_STATISTICS TABLE_SCHEMA
511 TRIGGERS TRIGGER_SCHEMA
512 USER_PRIVILEGES GRANTEE
513 +USER_STATISTICS USER
515 SELECT MAX(table_name) FROM information_schema.tables;
517 @@ -1302,10 +1322,12 @@
518 group by t.table_name order by num1, t.table_name;
519 table_name group_concat(t.table_schema, '.', t.table_name) num1
520 CHARACTER_SETS information_schema.CHARACTER_SETS 1
521 +CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
522 COLLATIONS information_schema.COLLATIONS 1
523 COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
524 COLUMNS information_schema.COLUMNS 1
525 COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1
526 +INDEX_STATISTICS information_schema.INDEX_STATISTICS 1
527 KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1
528 PROFILING information_schema.PROFILING 1
529 ROUTINES information_schema.ROUTINES 1
530 @@ -1315,8 +1337,10 @@
531 TABLES information_schema.TABLES 1
532 TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1
533 TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
534 +TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
535 TRIGGERS information_schema.TRIGGERS 1
536 USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
537 +USER_STATISTICS information_schema.USER_STATISTICS 1
538 VIEWS information_schema.VIEWS 1
539 show global status like "Uptime_%";
541 diff -r 1270c564d514 mysql-test/r/information_schema_db.result
542 --- a/mysql-test/r/information_schema_db.result Mon Dec 22 00:26:39 2008 -0800
543 +++ b/mysql-test/r/information_schema_db.result Mon Dec 22 00:31:13 2008 -0800
546 Tables_in_information_schema
550 COLLATION_CHARACTER_SET_APPLICABILITY
566 show tables from INFORMATION_SCHEMA like 'T%';
567 Tables_in_information_schema (T%)
573 create database `inf%`;
574 create database mbase;
575 diff -r 1270c564d514 mysql-test/r/mysqlshow.result
576 --- a/mysql-test/r/mysqlshow.result Mon Dec 22 00:26:39 2008 -0800
577 +++ b/mysql-test/r/mysqlshow.result Mon Dec 22 00:31:13 2008 -0800
580 +---------------------------------------+
582 +| CLIENT_STATISTICS |
584 | COLLATION_CHARACTER_SET_APPLICABILITY |
586 | COLUMN_PRIVILEGES |
587 +| INDEX_STATISTICS |
593 | TABLE_CONSTRAINTS |
595 +| TABLE_STATISTICS |
600 +---------------------------------------+
601 Database: INFORMATION_SCHEMA
602 @@ -102,10 +106,12 @@
604 +---------------------------------------+
606 +| CLIENT_STATISTICS |
608 | COLLATION_CHARACTER_SET_APPLICABILITY |
610 | COLUMN_PRIVILEGES |
611 +| INDEX_STATISTICS |
617 | TABLE_CONSTRAINTS |
619 +| TABLE_STATISTICS |
624 +---------------------------------------+
625 Wildcard: inf_rmation_schema
626 diff -r 1270c564d514 mysys/Makefile.in
627 --- a/mysys/Makefile.in Mon Dec 22 00:26:39 2008 -0800
628 +++ b/mysys/Makefile.in Mon Dec 22 00:31:13 2008 -0800
631 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
636 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
637 diff -r 1270c564d514 ndb/Makefile.in
638 --- a/ndb/Makefile.in Mon Dec 22 00:26:39 2008 -0800
639 +++ b/ndb/Makefile.in Mon Dec 22 00:31:13 2008 -0800
642 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
647 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
648 diff -r 1270c564d514 ndb/docs/Makefile.in
649 --- a/ndb/docs/Makefile.in Mon Dec 22 00:26:39 2008 -0800
650 +++ b/ndb/docs/Makefile.in Mon Dec 22 00:31:13 2008 -0800
653 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
658 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
659 diff -r 1270c564d514 ndb/include/Makefile.in
660 --- a/ndb/include/Makefile.in Mon Dec 22 00:26:39 2008 -0800
661 +++ b/ndb/include/Makefile.in Mon Dec 22 00:31:13 2008 -0800
664 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
669 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
670 diff -r 1270c564d514 ndb/src/Makefile.in
671 --- a/ndb/src/Makefile.in Mon Dec 22 00:26:39 2008 -0800
672 +++ b/ndb/src/Makefile.in Mon Dec 22 00:31:13 2008 -0800
675 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
680 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
681 diff -r 1270c564d514 ndb/src/common/Makefile.in
682 --- a/ndb/src/common/Makefile.in Mon Dec 22 00:26:39 2008 -0800
683 +++ b/ndb/src/common/Makefile.in Mon Dec 22 00:31:13 2008 -0800
686 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
691 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
692 diff -r 1270c564d514 ndb/src/common/debugger/Makefile.in
693 --- a/ndb/src/common/debugger/Makefile.in Mon Dec 22 00:26:39 2008 -0800
694 +++ b/ndb/src/common/debugger/Makefile.in Mon Dec 22 00:31:13 2008 -0800
697 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
702 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
703 diff -r 1270c564d514 ndb/src/common/debugger/signaldata/Makefile.in
704 --- a/ndb/src/common/debugger/signaldata/Makefile.in Mon Dec 22 00:26:39 2008 -0800
705 +++ b/ndb/src/common/debugger/signaldata/Makefile.in Mon Dec 22 00:31:13 2008 -0800
708 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
713 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
714 diff -r 1270c564d514 ndb/src/common/logger/Makefile.in
715 --- a/ndb/src/common/logger/Makefile.in Mon Dec 22 00:26:39 2008 -0800
716 +++ b/ndb/src/common/logger/Makefile.in Mon Dec 22 00:31:13 2008 -0800
719 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
724 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
725 diff -r 1270c564d514 ndb/src/common/mgmcommon/Makefile.in
726 --- a/ndb/src/common/mgmcommon/Makefile.in Mon Dec 22 00:26:39 2008 -0800
727 +++ b/ndb/src/common/mgmcommon/Makefile.in Mon Dec 22 00:31:13 2008 -0800
730 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
735 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
736 diff -r 1270c564d514 ndb/src/common/portlib/Makefile.in
737 --- a/ndb/src/common/portlib/Makefile.in Mon Dec 22 00:26:39 2008 -0800
738 +++ b/ndb/src/common/portlib/Makefile.in Mon Dec 22 00:31:13 2008 -0800
741 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
746 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
747 diff -r 1270c564d514 ndb/src/common/transporter/Makefile.in
748 --- a/ndb/src/common/transporter/Makefile.in Mon Dec 22 00:26:39 2008 -0800
749 +++ b/ndb/src/common/transporter/Makefile.in Mon Dec 22 00:31:13 2008 -0800
752 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
757 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
758 diff -r 1270c564d514 ndb/src/common/util/Makefile.in
759 --- a/ndb/src/common/util/Makefile.in Mon Dec 22 00:26:39 2008 -0800
760 +++ b/ndb/src/common/util/Makefile.in Mon Dec 22 00:31:13 2008 -0800
763 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
768 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
769 diff -r 1270c564d514 ndb/src/cw/Makefile.in
770 --- a/ndb/src/cw/Makefile.in Mon Dec 22 00:26:39 2008 -0800
771 +++ b/ndb/src/cw/Makefile.in Mon Dec 22 00:31:13 2008 -0800
774 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
779 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
780 diff -r 1270c564d514 ndb/src/cw/cpcd/Makefile.in
781 --- a/ndb/src/cw/cpcd/Makefile.in Mon Dec 22 00:26:39 2008 -0800
782 +++ b/ndb/src/cw/cpcd/Makefile.in Mon Dec 22 00:31:13 2008 -0800
785 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
790 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
791 diff -r 1270c564d514 ndb/src/kernel/Makefile.in
792 --- a/ndb/src/kernel/Makefile.in Mon Dec 22 00:26:39 2008 -0800
793 +++ b/ndb/src/kernel/Makefile.in Mon Dec 22 00:31:13 2008 -0800
796 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
801 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
802 diff -r 1270c564d514 ndb/src/kernel/blocks/Makefile.in
803 --- a/ndb/src/kernel/blocks/Makefile.in Mon Dec 22 00:26:39 2008 -0800
804 +++ b/ndb/src/kernel/blocks/Makefile.in Mon Dec 22 00:31:13 2008 -0800
807 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
812 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
813 diff -r 1270c564d514 ndb/src/kernel/blocks/backup/Makefile.in
814 --- a/ndb/src/kernel/blocks/backup/Makefile.in Mon Dec 22 00:26:39 2008 -0800
815 +++ b/ndb/src/kernel/blocks/backup/Makefile.in Mon Dec 22 00:31:13 2008 -0800
818 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
823 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
824 diff -r 1270c564d514 ndb/src/kernel/blocks/cmvmi/Makefile.in
825 --- a/ndb/src/kernel/blocks/cmvmi/Makefile.in Mon Dec 22 00:26:39 2008 -0800
826 +++ b/ndb/src/kernel/blocks/cmvmi/Makefile.in Mon Dec 22 00:31:13 2008 -0800
829 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
834 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
835 diff -r 1270c564d514 ndb/src/kernel/blocks/dbacc/Makefile.in
836 --- a/ndb/src/kernel/blocks/dbacc/Makefile.in Mon Dec 22 00:26:39 2008 -0800
837 +++ b/ndb/src/kernel/blocks/dbacc/Makefile.in Mon Dec 22 00:31:13 2008 -0800
840 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
845 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
846 diff -r 1270c564d514 ndb/src/kernel/blocks/dbdict/Makefile.in
847 --- a/ndb/src/kernel/blocks/dbdict/Makefile.in Mon Dec 22 00:26:39 2008 -0800
848 +++ b/ndb/src/kernel/blocks/dbdict/Makefile.in Mon Dec 22 00:31:13 2008 -0800
851 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
856 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
857 diff -r 1270c564d514 ndb/src/kernel/blocks/dbdih/Makefile.in
858 --- a/ndb/src/kernel/blocks/dbdih/Makefile.in Mon Dec 22 00:26:39 2008 -0800
859 +++ b/ndb/src/kernel/blocks/dbdih/Makefile.in Mon Dec 22 00:31:13 2008 -0800
862 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
867 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
868 diff -r 1270c564d514 ndb/src/kernel/blocks/dblqh/Makefile.in
869 --- a/ndb/src/kernel/blocks/dblqh/Makefile.in Mon Dec 22 00:26:39 2008 -0800
870 +++ b/ndb/src/kernel/blocks/dblqh/Makefile.in Mon Dec 22 00:31:13 2008 -0800
873 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
878 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
879 diff -r 1270c564d514 ndb/src/kernel/blocks/dbtc/Makefile.in
880 --- a/ndb/src/kernel/blocks/dbtc/Makefile.in Mon Dec 22 00:26:39 2008 -0800
881 +++ b/ndb/src/kernel/blocks/dbtc/Makefile.in Mon Dec 22 00:31:13 2008 -0800
884 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
889 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
890 diff -r 1270c564d514 ndb/src/kernel/blocks/dbtup/Makefile.in
891 --- a/ndb/src/kernel/blocks/dbtup/Makefile.in Mon Dec 22 00:26:39 2008 -0800
892 +++ b/ndb/src/kernel/blocks/dbtup/Makefile.in Mon Dec 22 00:31:13 2008 -0800
895 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
900 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
901 diff -r 1270c564d514 ndb/src/kernel/blocks/dbtux/Makefile.in
902 --- a/ndb/src/kernel/blocks/dbtux/Makefile.in Mon Dec 22 00:26:39 2008 -0800
903 +++ b/ndb/src/kernel/blocks/dbtux/Makefile.in Mon Dec 22 00:31:13 2008 -0800
906 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
911 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
912 diff -r 1270c564d514 ndb/src/kernel/blocks/dbutil/Makefile.in
913 --- a/ndb/src/kernel/blocks/dbutil/Makefile.in Mon Dec 22 00:26:39 2008 -0800
914 +++ b/ndb/src/kernel/blocks/dbutil/Makefile.in Mon Dec 22 00:31:13 2008 -0800
917 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
922 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
923 diff -r 1270c564d514 ndb/src/kernel/blocks/ndbcntr/Makefile.in
924 --- a/ndb/src/kernel/blocks/ndbcntr/Makefile.in Mon Dec 22 00:26:39 2008 -0800
925 +++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.in Mon Dec 22 00:31:13 2008 -0800
928 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
933 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
934 diff -r 1270c564d514 ndb/src/kernel/blocks/ndbfs/Makefile.in
935 --- a/ndb/src/kernel/blocks/ndbfs/Makefile.in Mon Dec 22 00:26:39 2008 -0800
936 +++ b/ndb/src/kernel/blocks/ndbfs/Makefile.in Mon Dec 22 00:31:13 2008 -0800
939 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
944 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
945 diff -r 1270c564d514 ndb/src/kernel/blocks/qmgr/Makefile.in
946 --- a/ndb/src/kernel/blocks/qmgr/Makefile.in Mon Dec 22 00:26:39 2008 -0800
947 +++ b/ndb/src/kernel/blocks/qmgr/Makefile.in Mon Dec 22 00:31:13 2008 -0800
950 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
955 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
956 diff -r 1270c564d514 ndb/src/kernel/blocks/suma/Makefile.in
957 --- a/ndb/src/kernel/blocks/suma/Makefile.in Mon Dec 22 00:26:39 2008 -0800
958 +++ b/ndb/src/kernel/blocks/suma/Makefile.in Mon Dec 22 00:31:13 2008 -0800
961 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
966 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
967 diff -r 1270c564d514 ndb/src/kernel/blocks/trix/Makefile.in
968 --- a/ndb/src/kernel/blocks/trix/Makefile.in Mon Dec 22 00:26:39 2008 -0800
969 +++ b/ndb/src/kernel/blocks/trix/Makefile.in Mon Dec 22 00:31:13 2008 -0800
972 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
977 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
978 diff -r 1270c564d514 ndb/src/kernel/error/Makefile.in
979 --- a/ndb/src/kernel/error/Makefile.in Mon Dec 22 00:26:39 2008 -0800
980 +++ b/ndb/src/kernel/error/Makefile.in Mon Dec 22 00:31:13 2008 -0800
983 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
988 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
989 diff -r 1270c564d514 ndb/src/kernel/vm/Makefile.in
990 --- a/ndb/src/kernel/vm/Makefile.in Mon Dec 22 00:26:39 2008 -0800
991 +++ b/ndb/src/kernel/vm/Makefile.in Mon Dec 22 00:31:13 2008 -0800
994 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
999 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1000 diff -r 1270c564d514 ndb/src/mgmapi/Makefile.in
1001 --- a/ndb/src/mgmapi/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1002 +++ b/ndb/src/mgmapi/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1005 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1010 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1011 diff -r 1270c564d514 ndb/src/mgmclient/Makefile.in
1012 --- a/ndb/src/mgmclient/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1013 +++ b/ndb/src/mgmclient/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1016 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1021 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1022 diff -r 1270c564d514 ndb/src/mgmsrv/Makefile.in
1023 --- a/ndb/src/mgmsrv/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1024 +++ b/ndb/src/mgmsrv/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1027 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1032 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1033 diff -r 1270c564d514 ndb/src/ndbapi/Makefile.in
1034 --- a/ndb/src/ndbapi/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1035 +++ b/ndb/src/ndbapi/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1038 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1043 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1044 diff -r 1270c564d514 ndb/test/Makefile.in
1045 --- a/ndb/test/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1046 +++ b/ndb/test/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1049 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1054 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1055 diff -r 1270c564d514 ndb/test/ndbapi/Makefile.in
1056 --- a/ndb/test/ndbapi/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1057 +++ b/ndb/test/ndbapi/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1060 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1065 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1066 diff -r 1270c564d514 ndb/test/ndbapi/bank/Makefile.in
1067 --- a/ndb/test/ndbapi/bank/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1068 +++ b/ndb/test/ndbapi/bank/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1071 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1076 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1077 diff -r 1270c564d514 ndb/test/run-test/Makefile.in
1078 --- a/ndb/test/run-test/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1079 +++ b/ndb/test/run-test/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1082 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1087 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1088 diff -r 1270c564d514 ndb/test/src/Makefile.in
1089 --- a/ndb/test/src/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1090 +++ b/ndb/test/src/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1093 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1098 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1099 diff -r 1270c564d514 ndb/test/tools/Makefile.in
1100 --- a/ndb/test/tools/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1101 +++ b/ndb/test/tools/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1104 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1109 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1110 diff -r 1270c564d514 ndb/tools/Makefile.in
1111 --- a/ndb/tools/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1112 +++ b/ndb/tools/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1115 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1120 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1121 diff -r 1270c564d514 netware/Makefile.in
1122 --- a/netware/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1123 +++ b/netware/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1126 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1131 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1132 diff -r 1270c564d514 os2/Makefile.in
1133 --- a/os2/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1134 +++ b/os2/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1137 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1142 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1143 diff -r 1270c564d514 os2/include/Makefile.in
1144 --- a/os2/include/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1145 +++ b/os2/include/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1148 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1153 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1154 diff -r 1270c564d514 os2/include/sys/Makefile.in
1155 --- a/os2/include/sys/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1156 +++ b/os2/include/sys/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1159 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1164 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1165 diff -r 1270c564d514 patch_info/userstats.info
1166 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1167 +++ b/patch_info/userstats.info Mon Dec 22 00:31:13 2008 -0800
1169 +File=userstatsv2.patch
1170 +Name=SHOW USER/TABLE/INDEX statistics
1174 +Comment=Added INFORMATION_SCHEMA.*_STATISTICS
1176 +YK: fix behavior for prepared statements
1179 +YK: add switch variable "userstat_running" to control INFORMATION_SCHEMA.*_STATISTICS (default:OFF)
1182 +YK: fixed "Row_sent: 0" problem at microslow_innodb.patch
1183 diff -r 1270c564d514 pstack/Makefile.in
1184 --- a/pstack/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1185 +++ b/pstack/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1188 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1193 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1194 diff -r 1270c564d514 pstack/aout/Makefile.in
1195 --- a/pstack/aout/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1196 +++ b/pstack/aout/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1199 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1204 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1205 diff -r 1270c564d514 regex/Makefile.in
1206 --- a/regex/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1207 +++ b/regex/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1210 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1215 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1216 diff -r 1270c564d514 scripts/Makefile.in
1217 --- a/scripts/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1218 +++ b/scripts/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1221 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1226 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1227 diff -r 1270c564d514 server-tools/Makefile.in
1228 --- a/server-tools/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1229 +++ b/server-tools/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1232 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1237 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1238 diff -r 1270c564d514 server-tools/instance-manager/Makefile.in
1239 --- a/server-tools/instance-manager/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1240 +++ b/server-tools/instance-manager/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1243 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1248 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1249 diff -r 1270c564d514 sql/Makefile.in
1250 --- a/sql/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1251 +++ b/sql/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1254 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1259 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1260 diff -r 1270c564d514 sql/ha_innodb.cc
1261 --- a/sql/ha_innodb.cc Mon Dec 22 00:26:39 2008 -0800
1262 +++ b/sql/ha_innodb.cc Mon Dec 22 00:31:13 2008 -0800
1263 @@ -3316,6 +3316,8 @@
1265 error = row_insert_for_mysql((byte*) record, prebuilt);
1267 + if (error == DB_SUCCESS) rows_changed++;
1269 if (error == DB_SUCCESS && auto_inc_used) {
1271 /* Fetch the value that was set in the autoincrement field */
1272 @@ -3588,6 +3590,8 @@
1276 + if (error == DB_SUCCESS) rows_changed++;
1278 innodb_srv_conc_exit_innodb(prebuilt->trx);
1280 error = convert_error_code_to_mysql(error, user_thd);
1281 @@ -3635,6 +3639,8 @@
1282 innodb_srv_conc_enter_innodb(prebuilt->trx);
1284 error = row_update_for_mysql((byte*) record, prebuilt);
1286 + if (error == DB_SUCCESS) rows_changed++;
1288 innodb_srv_conc_exit_innodb(prebuilt->trx);
1290 @@ -4068,6 +4074,9 @@
1291 if (ret == DB_SUCCESS) {
1295 + if (active_index >= 0 && active_index < MAX_KEY)
1296 + index_rows_read[active_index]++;
1298 } else if (ret == DB_RECORD_NOT_FOUND) {
1299 error = HA_ERR_END_OF_FILE;
1300 diff -r 1270c564d514 sql/ha_myisam.cc
1301 --- a/sql/ha_myisam.cc Mon Dec 22 00:26:39 2008 -0800
1302 +++ b/sql/ha_myisam.cc Mon Dec 22 00:31:13 2008 -0800
1304 if ((error= update_auto_increment()))
1307 - return mi_write(file,buf);
1308 + int error=mi_write(file,buf);
1309 + if (!error) rows_changed++;
1313 int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
1314 @@ -1518,13 +1520,17 @@
1315 statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
1316 if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
1317 table->timestamp_field->set_time();
1318 - return mi_update(file,old_data,new_data);
1319 + int error=mi_update(file,old_data,new_data);
1320 + if (!error) rows_changed++;
1324 int ha_myisam::delete_row(const byte * buf)
1326 statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
1327 - return mi_delete(file,buf);
1328 + int error=mi_delete(file,buf);
1329 + if (!error) rows_changed++;
1333 int ha_myisam::index_read(byte * buf, const byte * key,
1334 @@ -1535,6 +1541,13 @@
1336 int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
1337 table->status=error ? STATUS_NOT_FOUND: 0;
1341 + int inx = (active_index == -1) ? file->lastinx : active_index;
1342 + if (inx >= 0 && inx < MAX_KEY)
1343 + index_rows_read[inx]++;
1348 @@ -1545,6 +1558,13 @@
1350 int error=mi_rkey(file,buf,index, key, key_len, find_flag);
1351 table->status=error ? STATUS_NOT_FOUND: 0;
1356 + if (inx >= 0 && inx < MAX_KEY)
1357 + index_rows_read[inx]++;
1362 @@ -1555,6 +1575,13 @@
1364 int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
1365 table->status=error ? STATUS_NOT_FOUND: 0;
1369 + int inx = (active_index == -1) ? file->lastinx : active_index;
1370 + if (inx >= 0 && inx < MAX_KEY)
1371 + index_rows_read[inx]++;
1376 @@ -1565,6 +1592,13 @@
1378 int error=mi_rnext(file,buf,active_index);
1379 table->status=error ? STATUS_NOT_FOUND: 0;
1383 + int inx = (active_index == -1) ? file->lastinx : active_index;
1384 + if (inx >= 0 && inx < MAX_KEY)
1385 + index_rows_read[inx]++;
1390 @@ -1575,6 +1609,13 @@
1392 int error=mi_rprev(file,buf, active_index);
1393 table->status=error ? STATUS_NOT_FOUND: 0;
1397 + int inx = (active_index == -1) ? file->lastinx : active_index;
1398 + if (inx >= 0 && inx < MAX_KEY)
1399 + index_rows_read[inx]++;
1404 @@ -1585,6 +1626,13 @@
1406 int error=mi_rfirst(file, buf, active_index);
1407 table->status=error ? STATUS_NOT_FOUND: 0;
1411 + int inx = (active_index == -1) ? file->lastinx : active_index;
1412 + if (inx >= 0 && inx < MAX_KEY)
1413 + index_rows_read[inx]++;
1418 @@ -1595,6 +1643,13 @@
1420 int error=mi_rlast(file, buf, active_index);
1421 table->status=error ? STATUS_NOT_FOUND: 0;
1425 + int inx = (active_index == -1) ? file->lastinx : active_index;
1426 + if (inx >= 0 && inx < MAX_KEY)
1427 + index_rows_read[inx]++;
1432 @@ -1611,6 +1666,13 @@
1433 error= mi_rnext_same(file,buf);
1434 } while (error == HA_ERR_RECORD_DELETED);
1435 table->status=error ? STATUS_NOT_FOUND: 0;
1439 + int inx = (active_index == -1) ? file->lastinx : active_index;
1440 + if (inx >= 0 && inx < MAX_KEY)
1441 + index_rows_read[inx]++;
1446 @@ -1628,6 +1690,7 @@
1448 int error=mi_scan(file, buf);
1449 table->status=error ? STATUS_NOT_FOUND: 0;
1450 + if (!error) rows_read++;
1454 @@ -1642,6 +1705,7 @@
1456 int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
1457 table->status=error ? STATUS_NOT_FOUND: 0;
1458 + if (!error) rows_read++;
1462 diff -r 1270c564d514 sql/handler.cc
1463 --- a/sql/handler.cc Mon Dec 22 00:26:39 2008 -0800
1464 +++ b/sql/handler.cc Mon Dec 22 00:31:13 2008 -0800
1467 tc_log->unlog(cookie, xid);
1468 DBUG_EXECUTE_IF("crash_commit_after", abort(););
1469 + if (is_real_trans)
1470 + thd->diff_commit_trans++;
1473 start_waiting_global_read_lock(thd);
1475 thd->transaction.cleanup();
1478 + thd->diff_rollback_trans++;
1479 #endif /* USING_TRANSACTIONS */
1481 thd->transaction_rollback_request= FALSE;
1482 @@ -1212,6 +1215,7 @@
1483 statistic_increment(thd->status_var.ha_rollback_count,&LOCK_status);
1484 *ht=0; // keep it conveniently zero-filled
1486 + thd->diff_rollback_trans++;
1490 @@ -1442,6 +1446,8 @@
1492 dupp_ref=ref+ALIGN_SIZE(ref_length);
1494 + rows_read = rows_changed = 0;
1495 + memset(index_rows_read, 0, sizeof(index_rows_read));
1499 @@ -2276,6 +2282,111 @@
1503 +// Updates the global table stats with the TABLE this handler represents.
1504 +void handler::update_global_table_stats() {
1505 + if (!opt_userstat_running) {
1506 + rows_read = rows_changed = 0;
1510 + if (!rows_read && !rows_changed) return; // Nothing to update.
1511 + // table_cache_key is db_name + '\0' + table_name + '\0'.
1512 + if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
1514 + TABLE_STATS* table_stats;
1515 + char key[NAME_LEN * 2 + 2];
1516 + // [db] + '.' + [table]
1517 + sprintf(key, "%s.%s", table->s->table_cache_key, table->s->table_name);
1519 + pthread_mutex_lock(&LOCK_global_table_stats);
1520 + // Gets the global table stats, creating one if necessary.
1521 + if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
1524 + if (!(table_stats = ((TABLE_STATS*)
1525 + my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
1527 + sql_print_error("Allocating table stats failed.");
1530 + strncpy(table_stats->table, key, sizeof(table_stats->table));
1531 + table_stats->rows_read = 0;
1532 + table_stats->rows_changed = 0;
1533 + table_stats->rows_changed_x_indexes = 0;
1534 + table_stats->engine_type = (int) ht->db_type;
1536 + if (my_hash_insert(&global_table_stats, (byte*)table_stats)) {
1538 + sql_print_error("Inserting table stats failed.");
1539 + my_free((char*)table_stats, 0);
1543 + // Updates the global table stats.
1544 + table_stats->rows_read += rows_read;
1545 + table_stats->rows_changed += rows_changed;
1546 + table_stats->rows_changed_x_indexes +=
1547 + rows_changed * (table->s->keys ? table->s->keys : 1);
1548 + current_thd->diff_total_read_rows += rows_read;
1549 + rows_read = rows_changed = 0;
1551 + pthread_mutex_unlock(&LOCK_global_table_stats);
1554 +// Updates the global index stats with this handler's accumulated index reads.
1555 +void handler::update_global_index_stats() {
1556 + // table_cache_key is db_name + '\0' + table_name + '\0'.
1557 + if (!table->s || !table->s->table_cache_key || !table->s->table_name) return;
1559 + if (!opt_userstat_running) {
1560 + for (int x = 0; x < table->s->keys; x++) {
1561 + index_rows_read[x] = 0;
1566 + for (int x = 0; x < table->s->keys; x++) {
1567 + if (index_rows_read[x]) {
1568 + // Rows were read using this index.
1569 + KEY* key_info = &table->key_info[x];
1571 + if (!key_info->name) continue;
1573 + INDEX_STATS* index_stats;
1574 + char key[NAME_LEN * 3 + 3];
1575 + // [db] + '.' + [table] + '.' + [index]
1576 + sprintf(key, "%s.%s.%s", table->s->table_cache_key,
1577 + table->s->table_name, key_info->name);
1579 + pthread_mutex_lock(&LOCK_global_index_stats);
1580 + // Gets the global index stats, creating one if necessary.
1581 + if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
1584 + if (!(index_stats = ((INDEX_STATS*)
1585 + my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
1587 + sql_print_error("Allocating index stats failed.");
1590 + strncpy(index_stats->index, key, sizeof(index_stats->index));
1591 + index_stats->rows_read = 0;
1593 + if (my_hash_insert(&global_index_stats, (byte*)index_stats)) {
1595 + sql_print_error("Inserting index stats failed.");
1596 + my_free((char*)index_stats, 0);
1600 + // Updates the global index stats.
1601 + index_stats->rows_read += index_rows_read[x];
1602 + index_rows_read[x] = 0;
1604 + pthread_mutex_unlock(&LOCK_global_index_stats);
1609 /****************************************************************************
1610 ** Some general functions that isn't in the handler class
1611 diff -r 1270c564d514 sql/handler.h
1612 --- a/sql/handler.h Mon Dec 22 00:26:39 2008 -0800
1613 +++ b/sql/handler.h Mon Dec 22 00:31:13 2008 -0800
1615 #if defined(HAVE_BERKELEY_DB) || defined(HAVE_INNOBASE_DB) || \
1616 defined(HAVE_NDBCLUSTER_DB)
1617 #define USING_TRANSACTIONS
1621 +#error MAX_KEY is too large. Values up to 128 are supported.
1624 // the following is for checking tables
1626 bool auto_increment_column_changed;
1627 bool implicit_emptied; /* Can be !=0 only if HEAP */
1628 const COND *pushed_cond;
1629 + ulonglong rows_read;
1630 + ulonglong rows_changed;
1631 + ulonglong index_rows_read[MAX_KEY];
1633 handler(const handlerton *ht_arg, TABLE *table_arg) :table(table_arg),
1635 @@ -615,8 +622,10 @@
1636 ref_length(sizeof(my_off_t)), block_size(0),
1637 raid_type(0), ft_handler(0), inited(NONE),
1638 locked(FALSE), implicit_emptied(0),
1641 + pushed_cond(NULL), rows_read(0), rows_changed(0)
1643 + memset(index_rows_read, 0, sizeof(index_rows_read));
1645 virtual ~handler(void) { DBUG_ASSERT(locked == FALSE); /* TODO: DBUG_ASSERT(inited == NONE); */ }
1646 virtual handler *clone(MEM_ROOT *mem_root);
1647 int ha_open(const char *name, int mode, int test_if_locked);
1648 @@ -625,7 +634,11 @@
1649 virtual void print_error(int error, myf errflag);
1650 virtual bool get_error_message(int error, String *buf);
1651 uint get_dup_key(int error);
1652 - void change_table_ptr(TABLE *table_arg) { table=table_arg; }
1653 + void change_table_ptr(TABLE *table_arg) {
1655 + rows_read = rows_changed = 0;
1656 + memset(index_rows_read, 0, sizeof(index_rows_read));
1658 virtual double scan_time()
1659 { return ulonglong2double(data_file_length) / IO_SIZE + 2; }
1660 virtual double read_time(uint index, uint ranges, ha_rows rows)
1662 virtual bool is_crashed() const { return 0; }
1663 virtual bool auto_repair() const { return 0; }
1665 + void update_global_table_stats();
1666 + void update_global_index_stats();
1669 default rename_table() and delete_table() rename/delete files with a
1670 given name and extensions from bas_ext()
1671 diff -r 1270c564d514 sql/lex.h
1672 --- a/sql/lex.h Mon Dec 22 00:26:39 2008 -0800
1673 +++ b/sql/lex.h Mon Dec 22 00:31:13 2008 -0800
1675 { "CHECKSUM", SYM(CHECKSUM_SYM)},
1676 { "CIPHER", SYM(CIPHER_SYM)},
1677 { "CLIENT", SYM(CLIENT_SYM)},
1678 + { "CLIENT_STATISTICS", SYM(CLIENT_STATS_SYM)},
1679 { "CLOSE", SYM(CLOSE_SYM)},
1680 { "CODE", SYM(CODE_SYM)},
1681 { "COLLATE", SYM(COLLATE_SYM)},
1683 { "IN", SYM(IN_SYM)},
1684 { "INDEX", SYM(INDEX_SYM)},
1685 { "INDEXES", SYM(INDEXES)},
1686 + { "INDEX_STATISTICS", SYM(INDEX_STATS_SYM)},
1687 { "INFILE", SYM(INFILE)},
1688 { "INNER", SYM(INNER_SYM)},
1689 { "INNOBASE", SYM(INNOBASE_SYM)},
1691 { "SIGNED", SYM(SIGNED_SYM)},
1692 { "SIMPLE", SYM(SIMPLE_SYM)},
1693 { "SLAVE", SYM(SLAVE)},
1694 + { "SLOW", SYM(SLOW_SYM)},
1695 { "SNAPSHOT", SYM(SNAPSHOT_SYM)},
1696 { "SMALLINT", SYM(SMALLINT)},
1697 { "SOME", SYM(ANY_SYM)},
1699 { "TABLE", SYM(TABLE_SYM)},
1700 { "TABLES", SYM(TABLES)},
1701 { "TABLESPACE", SYM(TABLESPACE)},
1702 + { "TABLE_STATISTICS", SYM(TABLE_STATS_SYM)},
1703 { "TEMPORARY", SYM(TEMPORARY)},
1704 { "TEMPTABLE", SYM(TEMPTABLE_SYM)},
1705 { "TERMINATED", SYM(TERMINATED)},
1707 { "USE", SYM(USE_SYM)},
1708 { "USER", SYM(USER)},
1709 { "USER_RESOURCES", SYM(RESOURCES)},
1710 + { "USER_STATISTICS", SYM(USER_STATS_SYM)},
1711 { "USE_FRM", SYM(USE_FRM)},
1712 { "USING", SYM(USING)},
1713 { "UTC_DATE", SYM(UTC_DATE_SYM)},
1714 diff -r 1270c564d514 sql/log.cc
1715 --- a/sql/log.cc Mon Dec 22 00:26:39 2008 -0800
1716 +++ b/sql/log.cc Mon Dec 22 00:31:13 2008 -0800
1717 @@ -1899,18 +1899,24 @@
1718 thd->current_insert_id);
1721 + if (file == &log_file)
1722 + thd->binlog_bytes_written += e.data_written;
1724 if (thd->insert_id_used)
1726 Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
1729 + if (file == &log_file)
1730 + thd->binlog_bytes_written += e.data_written;
1734 Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
1737 + if (file == &log_file)
1738 + thd->binlog_bytes_written += e.data_written;
1740 if (thd->user_var_events.elements)
1742 @@ -1926,6 +1932,8 @@
1743 user_var_event->charset_number);
1746 + if (file == &log_file)
1747 + thd->binlog_bytes_written += e.data_written;
1751 @@ -1936,6 +1944,8 @@
1753 if (event_info->write(file))
1755 + if (file == &log_file)
1756 + thd->binlog_bytes_written += event_info->data_written;
1758 if (file == &log_file) // we are writing to the real log (disk)
1760 @@ -2057,6 +2067,7 @@
1762 if (qinfo.write(&log_file))
1764 + thd->binlog_bytes_written += qinfo.data_written;
1766 /* Read from the file used to cache the queries .*/
1767 if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
1768 @@ -2103,6 +2114,7 @@
1769 /* write the first half of the split header */
1770 if (my_b_write(&log_file, header, carry))
1772 + thd->binlog_bytes_written += carry;
1775 copy fixed second half of header to cache so the correct
1776 @@ -2171,6 +2183,8 @@
1777 /* Write data to the binary log file */
1778 if (my_b_write(&log_file, cache->read_pos, length))
1780 + thd->binlog_bytes_written += length;
1782 cache->read_pos=cache->read_end; // Mark buffer used up
1783 DBUG_EXECUTE_IF("half_binlogged_transaction", goto DBUG_skip_commit;);
1784 } while ((length=my_b_fill(cache)));
1785 @@ -2179,6 +2193,8 @@
1787 if (commit_event->write(&log_file))
1789 + thd->binlog_bytes_written += commit_event->data_written;
1794 diff -r 1270c564d514 sql/mysql_priv.h
1795 --- a/sql/mysql_priv.h Mon Dec 22 00:26:39 2008 -0800
1796 +++ b/sql/mysql_priv.h Mon Dec 22 00:31:13 2008 -0800
1797 @@ -818,7 +818,15 @@
1798 bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
1799 void init_max_user_conn(void);
1800 void init_update_queries(void);
1801 +void init_global_user_stats(void);
1802 +void init_global_table_stats(void);
1803 +void init_global_index_stats(void);
1804 +void init_global_client_stats(void);
1805 void free_max_user_conn(void);
1806 +void free_global_user_stats(void);
1807 +void free_global_table_stats(void);
1808 +void free_global_index_stats(void);
1809 +void free_global_client_stats(void);
1810 pthread_handler_t handle_one_connection(void *arg);
1811 pthread_handler_t handle_bootstrap(void *arg);
1812 void end_thread(THD *thd,bool put_in_cache);
1813 @@ -1396,6 +1404,7 @@
1814 extern ulong max_connections,max_connect_errors, connect_timeout;
1815 extern ulong slave_net_timeout, slave_trans_retries;
1816 extern uint max_user_connections;
1817 +extern ulonglong denied_connections;
1818 extern ulong what_to_log,flush_time;
1819 extern ulong query_buff_size, thread_stack;
1820 extern ulong max_prepared_stmt_count, prepared_stmt_count;
1821 @@ -1426,6 +1435,7 @@
1822 extern my_bool opt_safe_show_db, opt_local_infile;
1823 extern my_bool opt_slave_compressed_protocol, use_temp_pool;
1824 extern my_bool opt_readonly, lower_case_file_system;
1825 +extern my_bool opt_userstat_running;
1826 extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
1827 extern my_bool opt_secure_auth;
1828 extern char* opt_secure_file_priv;
1829 @@ -1472,6 +1482,14 @@
1830 extern struct system_variables max_system_variables;
1831 extern struct system_status_var global_status_var;
1832 extern struct rand_struct sql_rand;
1833 +extern HASH global_user_stats;
1834 +extern HASH global_client_stats;
1835 +extern pthread_mutex_t LOCK_global_user_client_stats;
1836 +extern HASH global_table_stats;
1837 +extern pthread_mutex_t LOCK_global_table_stats;
1838 +extern HASH global_index_stats;
1839 +extern pthread_mutex_t LOCK_global_index_stats;
1840 +extern pthread_mutex_t LOCK_stats;
1842 extern const char *opt_date_time_formats[];
1843 extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
1844 diff -r 1270c564d514 sql/mysqld.cc
1845 --- a/sql/mysqld.cc Mon Dec 22 00:26:39 2008 -0800
1846 +++ b/sql/mysqld.cc Mon Dec 22 00:31:13 2008 -0800
1848 uint opt_large_page_size= 0;
1849 my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
1850 char* opt_slow_logname= 0;
1851 +my_bool opt_userstat_running= 0;
1853 True if there is at least one per-hour limit for some user, so we should
1854 check them before each query (and possibly reset counters when hour is
1856 ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
1857 ulong max_connections, max_connect_errors;
1858 uint max_user_connections= 0;
1859 +ulonglong denied_connections = 0;
1861 Limit of the total number of prepared statements in the server.
1862 Is necessary to protect the server against out-of-memory attacks.
1863 @@ -550,6 +552,10 @@
1864 LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
1865 LOCK_global_system_variables,
1866 LOCK_user_conn, LOCK_slave_list, LOCK_active_mi;
1867 +pthread_mutex_t LOCK_stats;
1868 +pthread_mutex_t LOCK_global_user_client_stats;
1869 +pthread_mutex_t LOCK_global_table_stats;
1870 +pthread_mutex_t LOCK_global_index_stats;
1872 The below lock protects access to two global server variables:
1873 max_prepared_stmt_count and prepared_stmt_count. These variables
1874 @@ -1191,6 +1197,10 @@
1875 x_free(opt_secure_file_priv);
1876 bitmap_free(&temp_pool);
1877 free_max_user_conn();
1878 + free_global_user_stats();
1879 + free_global_client_stats();
1880 + free_global_table_stats();
1881 + free_global_index_stats();
1882 #ifdef HAVE_REPLICATION
1884 free_list(&replicate_do_db);
1885 @@ -1305,6 +1315,10 @@
1886 (void) pthread_cond_destroy(&COND_thread_cache);
1887 (void) pthread_cond_destroy(&COND_flush_thread_cache);
1888 (void) pthread_cond_destroy(&COND_manager);
1889 + (void) pthread_mutex_destroy(&LOCK_stats);
1890 + (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
1891 + (void) pthread_mutex_destroy(&LOCK_global_table_stats);
1892 + (void) pthread_mutex_destroy(&LOCK_global_index_stats);
1895 #endif /*EMBEDDED_LIBRARY*/
1896 @@ -3152,6 +3166,10 @@
1897 (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
1898 (void) pthread_cond_init(&COND_rpl_status, NULL);
1900 + (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
1901 + (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
1902 + (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
1903 + (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
1905 /* Parameter for threads created for connections */
1906 (void) pthread_attr_init(&connection_attrib);
1907 @@ -3423,6 +3441,10 @@
1908 sql_print_error("Out of memory");
1912 + init_global_table_stats();
1913 + init_global_index_stats();
1917 sql_print_error("Can't init databases");
1918 @@ -3505,6 +3527,8 @@
1920 init_max_user_conn();
1921 init_update_queries();
1922 + init_global_user_stats();
1923 + init_global_client_stats();
1927 @@ -4189,6 +4213,7 @@
1929 DBUG_PRINT("error",("Too many connections"));
1930 close_connection(thd, ER_CON_COUNT_ERROR, 1);
1931 + statistic_increment(denied_connections, &LOCK_status);
1935 @@ -5007,6 +5032,7 @@
1938 OPT_SLOW_QUERY_LOG_FILE,
1939 + OPT_USERSTAT_RUNNING,
1940 OPT_USE_GLOBAL_LONG_QUERY_TIME,
1941 OPT_INNODB_ROLLBACK_ON_TIMEOUT,
1942 OPT_SECURE_FILE_PRIV,
1943 @@ -6450,6 +6476,10 @@
1944 (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
1945 REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
1947 + {"userstat_running", OPT_USERSTAT_RUNNING,
1948 + "Control USER_STATISTICS, CLIENT_STATISTICS, INDEX_STATISTICS and TABLE_STATISTICS running",
1949 + (gptr*) &opt_userstat_running, (gptr*) &opt_userstat_running,
1950 + 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
1951 {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1954 diff -r 1270c564d514 sql/set_var.cc
1955 --- a/sql/set_var.cc Mon Dec 22 00:26:39 2008 -0800
1956 +++ b/sql/set_var.cc Mon Dec 22 00:31:13 2008 -0800
1958 sys_var_thd_ulong sys_read_buff_size("read_buffer_size",
1959 &SV::read_buff_size);
1960 sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
1961 +sys_var_bool_ptr sys_userstat_running("userstat_running", &opt_userstat_running);
1962 sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size",
1963 &SV::read_rnd_buff_size);
1964 sys_var_thd_ulong sys_div_precincrement("div_precision_increment",
1966 &sys_trans_alloc_block_size,
1967 &sys_trans_prealloc_size,
1969 + &sys_userstat_running,
1971 #ifdef HAVE_BERKELEY_DB
1973 @@ -1171,6 +1173,7 @@
1974 {sys_tx_isolation.name, (char*) &sys_tx_isolation, SHOW_SYS},
1975 {sys_updatable_views_with_limit.name,
1976 (char*) &sys_updatable_views_with_limit,SHOW_SYS},
1977 + {sys_userstat_running.name, (char*) &sys_userstat_running, SHOW_SYS},
1978 {sys_use_global_long_query_time.name, (char*) &sys_use_global_long_query_time, SHOW_SYS},
1979 {sys_version.name, (char*) &sys_version, SHOW_SYS},
1980 #ifdef HAVE_BERKELEY_DB
1981 diff -r 1270c564d514 sql/share/Makefile.in
1982 --- a/sql/share/Makefile.in Mon Dec 22 00:26:39 2008 -0800
1983 +++ b/sql/share/Makefile.in Mon Dec 22 00:31:13 2008 -0800
1986 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
1991 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
1992 diff -r 1270c564d514 sql/sql_base.cc
1993 --- a/sql/sql_base.cc Mon Dec 22 00:26:39 2008 -0800
1994 +++ b/sql/sql_base.cc Mon Dec 22 00:31:13 2008 -0800
1995 @@ -624,6 +624,12 @@
1996 DBUG_ENTER("close_thread_table");
1997 DBUG_ASSERT(table->key_read == 0);
1998 DBUG_ASSERT(!table->file || table->file->inited == handler::NONE);
2002 + table->file->update_global_table_stats();
2003 + table->file->update_global_index_stats();
2006 *table_ptr=table->next;
2007 if (table->needs_reopen_or_name_lock() ||
2010 DBUG_ENTER("close_temporary");
2011 char path[FN_REFLEN];
2013 + table->file->update_global_table_stats();
2014 + table->file->update_global_index_stats();
2015 db_type table_type=table->s->db_type;
2016 strmov(path,table->s->path);
2017 free_io_cache(table);
2018 diff -r 1270c564d514 sql/sql_class.cc
2019 --- a/sql/sql_class.cc Mon Dec 22 00:26:39 2008 -0800
2020 +++ b/sql/sql_class.cc Mon Dec 22 00:31:13 2008 -0800
2021 @@ -236,6 +236,13 @@
2022 bzero(ha_data, sizeof(ha_data));
2024 binlog_evt_union.do_union= FALSE;
2027 + bytes_received = 0;
2029 + binlog_bytes_written = 0;
2030 + updated_row_count = 0;
2031 + sent_row_count_2 = 0;
2033 dbug_sentry=THD_SENTRY_MAGIC;
2035 @@ -369,6 +376,88 @@
2036 total_warn_count= 0;
2038 bzero((char *) &status_var, sizeof(status_var));
2042 +// Resets stats in a THD.
2043 +void THD::reset_stats(void) {
2044 + current_connect_time = time(NULL);
2045 + last_global_update_time = current_connect_time;
2046 + reset_diff_stats();
2049 +// Resets the 'diff' stats, which are used to update global stats.
2050 +void THD::reset_diff_stats(void) {
2051 + diff_total_busy_time = 0;
2052 + diff_total_cpu_time = 0;
2053 + diff_total_bytes_received = 0;
2054 + diff_total_bytes_sent = 0;
2055 + diff_total_binlog_bytes_written = 0;
2056 + diff_total_sent_rows = 0;
2057 + diff_total_updated_rows = 0;
2058 + diff_total_read_rows = 0;
2059 + diff_select_commands = 0;
2060 + diff_update_commands = 0;
2061 + diff_other_commands = 0;
2062 + diff_commit_trans = 0;
2063 + diff_rollback_trans = 0;
2064 + diff_denied_connections = 0;
2065 + diff_lost_connections = 0;
2066 + diff_access_denied_errors = 0;
2067 + diff_empty_queries = 0;
2070 +// Updates 'diff' stats of a THD.
2071 +void THD::update_stats(bool ran_command) {
2072 + if (opt_userstat_running) {
2073 + diff_total_busy_time += busy_time;
2074 + diff_total_cpu_time += cpu_time;
2075 + diff_total_bytes_received += bytes_received;
2076 + diff_total_bytes_sent += bytes_sent;
2077 + diff_total_binlog_bytes_written += binlog_bytes_written;
2078 + diff_total_sent_rows += sent_row_count_2;
2079 + diff_total_updated_rows += updated_row_count;
2080 + // diff_total_read_rows is updated in handler.cc.
2082 + if (ran_command) {
2083 + // The replication thread has the COM_CONNECT command.
2084 + if ((old_command == COM_QUERY || command == COM_CONNECT) &&
2085 + (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
2087 + if (lex->sql_command == SQLCOM_SELECT) {
2088 + if (lex->orig_sql_command == SQLCOM_END) {
2089 + diff_select_commands++;
2090 + if (!sent_row_count_2)
2091 + diff_empty_queries++;
2093 + // 'SHOW ' commands become SQLCOM_SELECT.
2094 + diff_other_commands++;
2095 + // 'SHOW ' commands shouldn't inflate total sent row count.
2096 + diff_total_sent_rows -= sent_row_count_2;
2098 + } else if (is_update_query(lex->sql_command)) {
2099 + diff_update_commands++;
2101 + diff_other_commands++;
2105 + // diff_commit_trans is updated in handler.cc.
2106 + // diff_rollback_trans is updated in handler.cc.
2107 + // diff_denied_connections is updated in sql_parse.cc.
2108 + // diff_lost_connections is updated in sql_parse.cc.
2109 + // diff_access_denied_errors is updated in sql_parse.cc.
2111 + /* reset counters to zero to avoid double-counting since values
2112 + are already store in diff_total_*. */
2116 + bytes_received = 0;
2118 + binlog_bytes_written = 0;
2119 + updated_row_count = 0;
2120 + sent_row_count_2 = 0;
2126 void THD::change_user(void)
2128 + pthread_mutex_lock(&LOCK_status);
2129 + add_to_status(&global_status_var, &status_var);
2130 + pthread_mutex_unlock(&LOCK_status);
2134 @@ -892,6 +984,33 @@
2138 +char *THD::get_client_host_port(THD *client)
2140 + Security_context *client_sctx= client->security_ctx;
2141 + char *client_host= NULL;
2143 + if (client->peer_port && (client_sctx->host || client_sctx->ip) &&
2144 + security_ctx->host_or_ip[0])
2146 + if ((client_host= this->alloc(LIST_PROCESS_HOST_LEN+1)))
2147 + my_snprintf((char *) client_host, LIST_PROCESS_HOST_LEN,
2148 + "%s:%u", client_sctx->host_or_ip, client->peer_port);
2151 + client_host= this->strdup(client_sctx->host_or_ip[0] ?
2152 + client_sctx->host_or_ip :
2153 + client_sctx->host ? client_sctx->host : "");
2155 + return client_host;
2158 +const char *get_client_host(THD *client)
2160 + return client->security_ctx->host_or_ip[0] ?
2161 + client->security_ctx->host_or_ip :
2162 + client->security_ctx->host ? client->security_ctx->host : "";
2166 struct Item_change_record: public ilink
2168 @@ -1062,6 +1181,7 @@
2171 thd->sent_row_count++;
2172 + thd->sent_row_count_2++;
2175 if (!thd->net.report_error)
2176 @@ -1154,6 +1274,7 @@
2177 select_export::~select_export()
2179 thd->sent_row_count=row_count;
2180 + thd->sent_row_count_2=row_count;
2184 @@ -2088,6 +2209,7 @@
2185 if (likely(thd != 0))
2186 { /* current_thd==0 when close_connection() calls net_send_error() */
2187 thd->status_var.bytes_sent+= length;
2188 + thd->bytes_sent+= length;
2192 @@ -2095,6 +2217,7 @@
2193 void thd_increment_bytes_received(ulong length)
2195 current_thd->status_var.bytes_received+= length;
2196 + current_thd->bytes_received+= length;
2200 diff -r 1270c564d514 sql/sql_class.h
2201 --- a/sql/sql_class.h Mon Dec 22 00:26:39 2008 -0800
2202 +++ b/sql/sql_class.h Mon Dec 22 00:31:13 2008 -0800
2203 @@ -1298,6 +1298,8 @@
2204 first byte of the packet in do_command()
2206 enum enum_server_command command;
2207 + // Used to save the command, before it is set to COM_SLEEP.
2208 + enum enum_server_command old_command;
2210 uint32 file_id; // for LOAD DATA INFILE
2212 @@ -1487,6 +1489,8 @@
2213 /* variables.transaction_isolation is reset to this after each commit */
2214 enum_tx_isolation session_tx_isolation;
2215 enum_check_fields count_cuted_fields;
2216 + ha_rows updated_row_count;
2217 + ha_rows sent_row_count_2; /* for userstat */
2219 DYNAMIC_ARRAY user_var_events; /* For user variables replication */
2220 MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
2221 @@ -1593,6 +1597,49 @@
2223 LOG_INFO* current_linfo;
2224 NET* slave_net; // network connection from slave -> m.
2227 + Used to update global user stats. The global user stats are updated
2228 + occasionally with the 'diff' variables. After the update, the 'diff'
2229 + variables are reset to 0.
2231 + // Time when the current thread connected to MySQL.
2232 + time_t current_connect_time;
2233 + // Last time when THD stats were updated in global_user_stats.
2234 + time_t last_global_update_time;
2235 + // Busy (non-idle) time for just one command.
2237 + // Busy time not updated in global_user_stats yet.
2238 + double diff_total_busy_time;
2239 + // Cpu (non-idle) time for just one thread.
2241 + // Cpu time not updated in global_user_stats yet.
2242 + double diff_total_cpu_time;
2243 + /* bytes counting */
2244 + ulonglong bytes_received;
2245 + ulonglong diff_total_bytes_received;
2246 + ulonglong bytes_sent;
2247 + ulonglong diff_total_bytes_sent;
2248 + ulonglong binlog_bytes_written;
2249 + ulonglong diff_total_binlog_bytes_written;
2251 + // Number of rows not reflected in global_user_stats yet.
2252 + ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
2253 + // Number of commands not reflected in global_user_stats yet.
2254 + ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
2255 + // Number of transactions not reflected in global_user_stats yet.
2256 + ulonglong diff_commit_trans, diff_rollback_trans;
2257 + // Number of connection errors not reflected in global_user_stats yet.
2258 + ulonglong diff_denied_connections, diff_lost_connections;
2259 + // Number of db access denied, not reflected in global_user_stats yet.
2260 + ulonglong diff_access_denied_errors;
2261 + // Number of queries that return 0 rows
2262 + ulonglong diff_empty_queries;
2264 + // Per account query delay in miliseconds. When not 0, sleep this number of
2265 + // milliseconds before every SQL command.
2266 + ulonglong query_delay_millis;
2268 /* Used by the sys_var class to store temporary values */
2271 @@ -1648,6 +1695,11 @@
2274 void init_for_queries();
2275 + void reset_stats(void);
2276 + void reset_diff_stats(void);
2277 + // ran_command is true when this is called immediately after a
2278 + // command has been run.
2279 + void update_stats(bool ran_command);
2280 void change_user(void);
2282 void cleanup_after_query();
2283 @@ -1877,7 +1929,13 @@
2285 *p_db_length= db_length;
2288 + // Returns string as 'IP:port' for the client-side of the connnection represented
2289 + // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
2290 + // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
2293 + char *get_client_host_port(THD *client);
2297 @@ -1921,6 +1979,11 @@
2298 MEM_ROOT main_mem_root;
2301 +// Returns string as 'IP' for the client-side of the connection represented by
2302 +// 'client'. Does not allocate memory. May return "".
2303 +const char *get_client_host(THD *client);
2305 +#define LIST_PROCESS_HOST_LEN 64
2307 #define tmp_disable_binlog(A) \
2308 {ulonglong tmp_disable_binlog__save_options= (A)->options; \
2309 diff -r 1270c564d514 sql/sql_delete.cc
2310 --- a/sql/sql_delete.cc Mon Dec 22 00:26:39 2008 -0800
2311 +++ b/sql/sql_delete.cc Mon Dec 22 00:31:13 2008 -0800
2313 send_ok(thd,deleted);
2314 DBUG_PRINT("info",("%ld records deleted",(long) deleted));
2316 + thd->updated_row_count += deleted;
2317 DBUG_RETURN(error >= 0 || thd->net.report_error);
2321 thd->row_count_func= deleted;
2322 ::send_ok(thd, deleted);
2324 + thd->updated_row_count += deleted;
2328 diff -r 1270c564d514 sql/sql_insert.cc
2329 --- a/sql/sql_insert.cc Mon Dec 22 00:26:39 2008 -0800
2330 +++ b/sql/sql_insert.cc Mon Dec 22 00:31:13 2008 -0800
2332 thd->row_count_func= info.copied + info.deleted + updated;
2333 ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
2335 + thd->updated_row_count += thd->row_count_func;
2336 thd->abort_on_warning= 0;
2339 @@ -3036,6 +3037,7 @@
2340 autoinc_value_of_first_inserted_row : thd->insert_id_used ?
2341 thd->last_insert_id : 0;
2342 ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
2343 + thd->updated_row_count += thd->row_count_func;
2347 diff -r 1270c564d514 sql/sql_lex.h
2348 --- a/sql/sql_lex.h Mon Dec 22 00:26:39 2008 -0800
2349 +++ b/sql/sql_lex.h Mon Dec 22 00:31:13 2008 -0800
2351 When a command is added here, be sure it's also added in mysqld.cc
2352 in "struct show_var_st status_vars[]= {" ...
2354 + // TODO(mcallaghan): update status_vars in mysqld to export these
2355 + SQLCOM_SHOW_USER_STATS, SQLCOM_SHOW_TABLE_STATS, SQLCOM_SHOW_INDEX_STATS,
2356 + SQLCOM_SHOW_CLIENT_STATS,
2357 /* This should be the last !!! */
2360 diff -r 1270c564d514 sql/sql_parse.cc
2361 --- a/sql/sql_parse.cc Mon Dec 22 00:26:39 2008 -0800
2362 +++ b/sql/sql_parse.cc Mon Dec 22 00:31:13 2008 -0800
2364 const char *table_name);
2365 static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
2367 +// Increments connection count for user.
2368 +static int increment_connection_count(THD* thd, bool use_lock);
2370 +// Uses the THD to update the global stats by user name and client IP
2371 +void update_global_user_stats(THD* thd, bool create_user, time_t now);
2373 const char *any_db="*any*"; // Special symbol for check_access
2375 const char *command_name[]={
2376 @@ -145,6 +151,17 @@
2377 #ifndef EMBEDDED_LIBRARY
2378 static bool do_command(THD *thd);
2379 #endif // EMBEDDED_LIBRARY
2381 +HASH global_user_stats;
2382 +HASH global_client_stats;
2383 +// Protects global_user_stats and global_client_stats
2384 +extern pthread_mutex_t LOCK_global_user_client_stats;
2386 +HASH global_table_stats;
2387 +extern pthread_mutex_t LOCK_global_table_stats;
2389 +HASH global_index_stats;
2390 +extern pthread_mutex_t LOCK_global_index_stats;
2393 extern void win_install_sigabrt_handler(void);
2395 mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE));
2398 + thd->diff_access_denied_errors++;
2399 net_printf_error(thd, ER_ACCESS_DENIED_ERROR,
2400 thd->main_security_ctx.user,
2401 thd->main_security_ctx.host_or_ip,
2402 @@ -536,12 +554,190 @@
2403 void init_max_user_conn(void)
2405 #ifndef NO_EMBEDDED_ACCESS_CHECKS
2406 - (void) hash_init(&hash_user_connections,system_charset_info,max_connections,
2408 - (hash_get_key) get_key_conn, (hash_free_key) free_user,
2412 + if (hash_init(&hash_user_connections,system_charset_info,max_connections,
2414 + (hash_get_key) get_key_conn, (hash_free_key) free_user,
2416 + sql_print_error("Initializing hash_user_connections failed.");
2422 +byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
2423 + my_bool not_used __attribute__((unused)))
2425 + *length = strlen(user_stats->user);
2426 + return (byte*)user_stats->user;
2429 +void free_user_stats(USER_STATS* user_stats)
2431 + my_free((char*)user_stats, MYF(0));
2434 +void init_user_stats(USER_STATS *user_stats,
2436 + const char *priv_user,
2437 + uint total_connections,
2438 + uint concurrent_connections,
2439 + time_t connected_time,
2442 + ulonglong bytes_received,
2443 + ulonglong bytes_sent,
2444 + ulonglong binlog_bytes_written,
2445 + ha_rows rows_fetched,
2446 + ha_rows rows_updated,
2447 + ha_rows rows_read,
2448 + ulonglong select_commands,
2449 + ulonglong update_commands,
2450 + ulonglong other_commands,
2451 + ulonglong commit_trans,
2452 + ulonglong rollback_trans,
2453 + ulonglong denied_connections,
2454 + ulonglong lost_connections,
2455 + ulonglong access_denied_errors,
2456 + ulonglong empty_queries)
2458 + DBUG_ENTER("init_user_stats");
2459 + DBUG_PRINT("info",
2460 + ("Add user_stats entry for user %s - priv_user %s",
2461 + user, priv_user));
2462 + strncpy(user_stats->user, user, sizeof(user_stats->user));
2463 + strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
2465 + user_stats->total_connections = total_connections;
2466 + user_stats->concurrent_connections = concurrent_connections;
2467 + user_stats->connected_time = connected_time;
2468 + user_stats->busy_time = busy_time;
2469 + user_stats->cpu_time = cpu_time;
2470 + user_stats->bytes_received = bytes_received;
2471 + user_stats->bytes_sent = bytes_sent;
2472 + user_stats->binlog_bytes_written = binlog_bytes_written;
2473 + user_stats->rows_fetched = rows_fetched;
2474 + user_stats->rows_updated = rows_updated;
2475 + user_stats->rows_read = rows_read;
2476 + user_stats->select_commands = select_commands;
2477 + user_stats->update_commands = update_commands;
2478 + user_stats->other_commands = other_commands;
2479 + user_stats->commit_trans = commit_trans;
2480 + user_stats->rollback_trans = rollback_trans;
2481 + user_stats->denied_connections = denied_connections;
2482 + user_stats->lost_connections = lost_connections;
2483 + user_stats->access_denied_errors = access_denied_errors;
2484 + user_stats->empty_queries = empty_queries;
2488 +void add_user_stats(USER_STATS *user_stats,
2489 + uint total_connections,
2490 + uint concurrent_connections,
2491 + time_t connected_time,
2494 + ulonglong bytes_received,
2495 + ulonglong bytes_sent,
2496 + ulonglong binlog_bytes_written,
2497 + ha_rows rows_fetched,
2498 + ha_rows rows_updated,
2499 + ha_rows rows_read,
2500 + ulonglong select_commands,
2501 + ulonglong update_commands,
2502 + ulonglong other_commands,
2503 + ulonglong commit_trans,
2504 + ulonglong rollback_trans,
2505 + ulonglong denied_connections,
2506 + ulonglong lost_connections,
2507 + ulonglong access_denied_errors,
2508 + ulonglong empty_queries)
2510 + user_stats->total_connections += total_connections;
2511 + user_stats->concurrent_connections += concurrent_connections;
2512 + user_stats->connected_time += connected_time;
2513 + user_stats->busy_time += busy_time;
2514 + user_stats->cpu_time += cpu_time;
2515 + user_stats->bytes_received += bytes_received;
2516 + user_stats->bytes_sent += bytes_sent;
2517 + user_stats->binlog_bytes_written += binlog_bytes_written;
2518 + user_stats->rows_fetched += rows_fetched;
2519 + user_stats->rows_updated += rows_updated;
2520 + user_stats->rows_read += rows_read;
2521 + user_stats->select_commands += select_commands;
2522 + user_stats->update_commands += update_commands;
2523 + user_stats->other_commands += other_commands;
2524 + user_stats->commit_trans += commit_trans;
2525 + user_stats->rollback_trans += rollback_trans;
2526 + user_stats->denied_connections += denied_connections;
2527 + user_stats->lost_connections += lost_connections;
2528 + user_stats->access_denied_errors += access_denied_errors;
2529 + user_stats->empty_queries += empty_queries;
2532 +void init_global_user_stats(void)
2534 + if (hash_init(&global_user_stats, system_charset_info, max_connections,
2535 + 0, 0, (hash_get_key)get_key_user_stats,
2536 + (hash_free_key)free_user_stats, 0)) {
2537 + sql_print_error("Initializing global_user_stats failed.");
2542 +void init_global_client_stats(void)
2544 + if (hash_init(&global_client_stats, system_charset_info, max_connections,
2545 + 0, 0, (hash_get_key)get_key_user_stats,
2546 + (hash_free_key)free_user_stats, 0)) {
2547 + sql_print_error("Initializing global_client_stats failed.");
2552 +extern "C" byte *get_key_table_stats(TABLE_STATS *table_stats, uint *length,
2553 + my_bool not_used __attribute__((unused)))
2555 + *length = strlen(table_stats->table);
2556 + return (byte*)table_stats->table;
2559 +extern "C" void free_table_stats(TABLE_STATS* table_stats)
2561 + my_free((char*)table_stats, MYF(0));
2564 +void init_global_table_stats(void)
2566 + if (hash_init(&global_table_stats, system_charset_info, max_connections,
2567 + 0, 0, (hash_get_key)get_key_table_stats,
2568 + (hash_free_key)free_table_stats, 0)) {
2569 + sql_print_error("Initializing global_table_stats failed.");
2574 +extern "C" byte *get_key_index_stats(INDEX_STATS *index_stats, uint *length,
2575 + my_bool not_used __attribute__((unused)))
2577 + *length = strlen(index_stats->index);
2578 + return (byte*)index_stats->index;
2581 +extern "C" void free_index_stats(INDEX_STATS* index_stats)
2583 + my_free((char*)index_stats, MYF(0));
2586 +void init_global_index_stats(void)
2588 + if (hash_init(&global_index_stats, system_charset_info, max_connections,
2589 + 0, 0, (hash_get_key)get_key_index_stats,
2590 + (hash_free_key)free_index_stats, 0)) {
2591 + sql_print_error("Initializing global_index_stats failed.");
2599 @@ -599,7 +795,10 @@
2604 + statistic_increment(denied_connections, &LOCK_status);
2605 uc->connections--; // no need for decrease_user_connections() here
2607 (void) pthread_mutex_unlock(&LOCK_user_conn);
2610 @@ -646,6 +845,25 @@
2611 #endif /* NO_EMBEDDED_ACCESS_CHECKS */
2614 +void free_global_user_stats(void)
2616 + hash_free(&global_user_stats);
2619 +void free_global_table_stats(void)
2621 + hash_free(&global_table_stats);
2624 +void free_global_index_stats(void)
2626 + hash_free(&global_index_stats);
2629 +void free_global_client_stats(void)
2631 + hash_free(&global_client_stats);
2636 @@ -698,6 +916,214 @@
2637 return uc_update_queries[command] != 0;
2640 +// 'mysql_system_user' is used for when the user is not defined for a THD.
2641 +static char mysql_system_user[] = "#mysql_system#";
2643 +// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
2644 +static char* get_valid_user_string(char* user) {
2645 + return user ? user : mysql_system_user;
2648 +// Increments the global stats connection count for an entry from
2649 +// global_client_stats or global_user_stats. Returns 0 on success
2651 +static int increment_count_by_name(const char *name, const char *role_name,
2652 + HASH *users_or_clients, THD *thd)
2654 + USER_STATS* user_stats;
2656 + if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, name,
2659 + // First connection for this user or client
2660 + if (!(user_stats = ((USER_STATS*)
2661 + my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
2663 + return 1; // Out of memory
2666 + init_user_stats(user_stats, name, role_name,
2667 + 0, 0, // connections
2669 + 0, 0, 0, // bytes sent, received and written
2670 + 0, 0, 0, // rows fetched, updated and read
2671 + 0, 0, 0, // select, update and other commands
2672 + 0, 0, // commit and rollback trans
2673 + thd->diff_denied_connections,
2674 + 0, // lost connections
2675 + 0, // access denied errors
2676 + 0); // empty queries
2678 + if (my_hash_insert(users_or_clients, (byte*)user_stats))
2680 + my_free((char*)user_stats, 0);
2681 + return 1; // Out of memory
2684 + user_stats->total_connections++;
2688 +// Increments the global user and client stats connection count. If 'use_lock'
2689 +// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
2690 +// 0 on success, 1 on error.
2691 +static int increment_connection_count(THD* thd, bool use_lock)
2693 + char* user_string = get_valid_user_string(thd->main_security_ctx.user);
2694 + const char* client_string = get_client_host(thd);
2695 + int return_value = 0;
2697 + if (!opt_userstat_running)
2698 + return return_value;
2700 + if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
2702 + if (increment_count_by_name(user_string, user_string,
2703 + &global_user_stats, thd))
2708 + if (increment_count_by_name(client_string,
2710 + &global_client_stats, thd))
2717 + if (use_lock) pthread_mutex_unlock(&LOCK_global_user_client_stats);
2718 + return return_value;
2721 +// Used to update the global user and client stats.
2722 +static void update_global_user_stats_with_user(THD* thd,
2723 + USER_STATS* user_stats,
2726 + user_stats->connected_time += now - thd->last_global_update_time;
2727 + thd->last_global_update_time = now;
2728 + user_stats->busy_time += thd->diff_total_busy_time;
2729 + user_stats->cpu_time += thd->diff_total_cpu_time;
2730 + user_stats->bytes_received += thd->diff_total_bytes_received;
2731 + user_stats->bytes_sent += thd->diff_total_bytes_sent;
2732 + user_stats->binlog_bytes_written += thd->diff_total_binlog_bytes_written;
2733 + user_stats->rows_fetched += thd->diff_total_sent_rows;
2734 + user_stats->rows_updated += thd->diff_total_updated_rows;
2735 + user_stats->rows_read += thd->diff_total_read_rows;
2736 + user_stats->select_commands += thd->diff_select_commands;
2737 + user_stats->update_commands += thd->diff_update_commands;
2738 + user_stats->other_commands += thd->diff_other_commands;
2739 + user_stats->commit_trans += thd->diff_commit_trans;
2740 + user_stats->rollback_trans += thd->diff_rollback_trans;
2741 + user_stats->denied_connections += thd->diff_denied_connections;
2742 + user_stats->lost_connections += thd->diff_lost_connections;
2743 + user_stats->access_denied_errors += thd->diff_access_denied_errors;
2744 + user_stats->empty_queries += thd->diff_empty_queries;
2747 +// Updates the global stats of a user or client
2748 +void update_global_user_stats(THD* thd, bool create_user, time_t now)
2750 + if (opt_userstat_running) {
2751 + char* user_string = get_valid_user_string(thd->main_security_ctx.user);
2752 + const char* client_string = get_client_host(thd);
2754 + USER_STATS* user_stats;
2755 + pthread_mutex_lock(&LOCK_global_user_client_stats);
2757 + // Update by user name
2758 + if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
2759 + (byte*)user_string,
2760 + strlen(user_string)))) {
2762 + update_global_user_stats_with_user(thd, user_stats, now);
2764 + // Create the entry
2765 + if (create_user) {
2766 + increment_count_by_name(user_string, user_string,
2767 + &global_user_stats, thd);
2771 + // Update by client IP
2772 + if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
2773 + (byte*)client_string,
2774 + strlen(client_string)))) {
2775 + // Found by client IP
2776 + update_global_user_stats_with_user(thd, user_stats, now);
2778 + // Create the entry
2779 + if (create_user) {
2780 + increment_count_by_name(client_string,
2782 + &global_client_stats, thd);
2785 + thd->reset_diff_stats();
2787 + pthread_mutex_unlock(&LOCK_global_user_client_stats);
2789 + thd->reset_diff_stats();
2793 +// Determines the concurrent number of connections of current threads.
2794 +static void set_connections_stats()
2796 + USER_STATS* user_stats;
2798 + pthread_mutex_lock(&LOCK_global_user_client_stats);
2799 + pthread_mutex_lock(&LOCK_thread_count);
2801 + // Resets all concurrent connections to 0.
2802 + for (int i = 0; i < global_user_stats.records; ++i) {
2803 + user_stats = (USER_STATS*)hash_element(&global_user_stats, i);
2804 + user_stats->concurrent_connections = 0;
2806 + for (int i = 0; i < global_client_stats.records; ++i) {
2807 + user_stats = (USER_STATS*)hash_element(&global_client_stats, i);
2808 + user_stats->concurrent_connections = 0;
2811 + I_List_iterator<THD> it(threads);
2813 + time_t now = time(NULL);
2814 + // Iterates through the current threads.
2815 + while ((thd = it++)) {
2816 + char* user_string = get_valid_user_string(thd->main_security_ctx.user);
2817 + if ((user_stats = (USER_STATS*)hash_search(&global_user_stats,
2818 + (byte*)user_string,
2819 + strlen(user_string)))) {
2821 + user_stats->concurrent_connections++;
2822 + update_global_user_stats_with_user(thd, user_stats, now);
2824 + // The user name should exist.
2825 + if (user_string == mysql_system_user) {
2826 + // Only create the user if it is the mysql_system_user
2827 + increment_count_by_name(user_string, user_string,
2828 + &global_user_stats, thd);
2832 + const char* client_string = get_client_host(thd);
2833 + if ((user_stats = (USER_STATS*)hash_search(&global_client_stats,
2834 + (byte*)client_string,
2835 + strlen(client_string)))) {
2837 + user_stats->concurrent_connections++;
2838 + update_global_user_stats_with_user(thd, user_stats, now);
2840 + // Do nothing, unlike what is done for global_user_stats
2842 + thd->reset_diff_stats();
2844 + pthread_mutex_unlock(&LOCK_thread_count);
2845 + pthread_mutex_unlock(&LOCK_global_user_client_stats);
2849 Reset per-hour user resource limits when it has been more than
2850 an hour since they were last checked
2851 @@ -1184,6 +1607,8 @@
2852 my_net_set_read_timeout(net, connect_timeout);
2853 my_net_set_write_timeout(net, connect_timeout);
2855 + bool create_user = true;
2857 if ((error=check_connection(thd)))
2858 { // Wrong permissions
2860 @@ -1193,8 +1618,22 @@
2861 my_sleep(1000); /* must wait after eof() */
2863 statistic_increment(aborted_connects,&LOCK_status);
2864 + thd->diff_denied_connections++;
2865 + if (error == -2) {
2866 + // Do not create statistics for a user who does not exist, or failed
2867 + // to authenticate.
2868 + create_user = false;
2873 + thd->reset_stats();
2874 + // Updates global user connection stats.
2875 + if (increment_connection_count(thd, true)) {
2876 + net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
2881 netware_reg_user(sctx->ip, sctx->user, "MySQL");
2883 @@ -1251,6 +1690,7 @@
2884 net->vio && net->error && net->report_error)
2886 statistic_increment(aborted_threads, &LOCK_status);
2887 + thd->diff_lost_connections++;
2890 if (net->error && net->vio != 0 && net->report_error)
2891 @@ -1270,6 +1710,8 @@
2894 close_connection(thd, 0, 1);
2895 + thd->update_stats(false);
2896 + update_global_user_stats(thd, create_user, time(NULL));
2899 If end_thread returns, we are either running with --one-thread
2900 @@ -1601,6 +2043,13 @@
2902 thd->clear_error(); // Clear error message
2904 + thd->updated_row_count=0;
2907 + thd->bytes_received=0;
2908 + thd->bytes_sent=0;
2909 + thd->binlog_bytes_written=0;
2911 net_new_transaction(net);
2913 packet_length= my_net_read(net);
2914 @@ -1759,6 +2208,9 @@
2917 thd->command=command;
2918 + // To increment the corrent command counter for user stats, 'command' must
2919 + // be saved because it is set to COM_SLEEP at the end of this function.
2920 + thd->old_command = command;
2922 Commands which always take a long time are logged into
2923 the slow log only if opt_log_slow_admin_statements is set.
2924 @@ -4424,6 +4876,15 @@
2925 if (check_global_access(thd,RELOAD_ACL))
2928 + if(lex->type & REFRESH_SLOW_QUERY_LOG) {
2929 + /* We are only flushing slow query log */
2930 + mysql_slow_log.new_file(1);
2938 reload_acl_and_cache() will tell us if we are allowed to write to the
2940 @@ -4731,6 +5192,7 @@
2942 if (check_global_access(thd, SUPER_ACL))
2944 + thd->diff_access_denied_errors++;
2945 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
2946 goto create_sp_error;
2948 @@ -5567,6 +6029,7 @@
2951 const char *db_name= db ? db : thd->db;
2952 + thd->diff_access_denied_errors++;
2953 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
2954 sctx->priv_user, sctx->priv_host, db_name);
2956 @@ -5602,6 +6065,7 @@
2957 { // We can never grant this
2958 DBUG_PRINT("error",("No possible access"));
2960 + thd->diff_access_denied_errors++;
2961 my_error(ER_ACCESS_DENIED_ERROR, MYF(0),
2964 @@ -5634,11 +6098,15 @@
2966 DBUG_PRINT("error",("Access denied"));
2969 + // increment needs !no_errors condition, otherwise double counting.
2970 + thd->diff_access_denied_errors++;
2971 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
2972 sctx->priv_user, sctx->priv_host,
2973 (db ? db : (thd->db ?
2975 "unknown"))); /* purecov: tested */
2977 DBUG_RETURN(TRUE); /* purecov: tested */
2978 #endif /* NO_EMBEDDED_ACCESS_CHECKS */
2980 @@ -5672,6 +6140,7 @@
2981 if ((thd->security_ctx->master_access & want_access))
2983 get_privilege_desc(command, sizeof(command), want_access);
2984 + thd->diff_access_denied_errors++;
2985 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), command);
2987 #endif /* NO_EMBEDDED_ACCESS_CHECKS */
2988 @@ -5704,6 +6173,7 @@
2990 if (!thd->col_access && check_grant_db(thd, dst_db_name))
2992 + thd->diff_access_denied_errors++;
2993 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
2994 thd->security_ctx->priv_user,
2995 thd->security_ctx->priv_host,
2996 @@ -5735,6 +6205,12 @@
2997 check_grant(thd, SELECT_ACL, dst_table, 2, UINT_MAX, FALSE);
3001 + case SCH_USER_STATS:
3002 + case SCH_CLIENT_STATS:
3003 + return check_global_access(thd, SUPER_ACL | PROCESS_ACL);
3004 + case SCH_TABLE_STATS:
3005 + case SCH_INDEX_STATS:
3006 case SCH_OPEN_TABLES:
3009 @@ -5788,8 +6264,8 @@
3010 #ifndef NO_EMBEDDED_ACCESS_CHECKS
3011 TABLE_LIST *org_tables= tables;
3013 + Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
3014 TABLE_LIST *first_not_own_table= thd->lex->first_not_own_table();
3015 - Security_context *sctx= thd->security_ctx, *backup_ctx= thd->security_ctx;
3017 The check that first_not_own_table is not reached is for the case when
3018 the given table list refers to the list for prelocking (contains tables
3019 @@ -5806,9 +6282,12 @@
3020 (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
3024 + thd->diff_access_denied_errors++;
3025 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3026 sctx->priv_user, sctx->priv_host,
3027 INFORMATION_SCHEMA_NAME.str);
3032 @@ -6317,6 +6796,30 @@
3035 mysql_reset_thd_for_next_command(thd);
3037 + int start_time_error = 0;
3038 + int end_time_error = 0;
3039 + struct timeval start_time, end_time;
3040 + double start_usecs = 0;
3041 + double end_usecs = 0;
3043 + int cputime_error = 0;
3044 + struct timespec tp;
3045 + double start_cpu_nsecs = 0;
3046 + double end_cpu_nsecs = 0;
3048 + if (opt_userstat_running) {
3049 +#ifdef HAVE_CLOCK_GETTIME
3050 + /* get start cputime */
3051 + if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3052 + start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3055 + // Gets the start time, in order to measure how long this command takes.
3056 + if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3057 + start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3061 if (query_cache_send_result_to_client(thd, (char*) inBuf, length) <= 0)
3063 @@ -6396,6 +6899,39 @@
3064 *found_semicolon= NULL;
3067 + if (opt_userstat_running) {
3068 + // Gets the end time.
3069 + if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3070 + end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3073 + // Calculates the difference between the end and start times.
3074 + if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3075 + thd->busy_time = (end_usecs - start_usecs) / 1000000;
3076 + // In case there are bad values, 2629743 is the #seconds in a month.
3077 + if (thd->busy_time > 2629743) {
3078 + thd->busy_time = 0;
3081 + // end time went back in time, or gettimeofday() failed.
3082 + thd->busy_time = 0;
3085 +#ifdef HAVE_CLOCK_GETTIME
3086 + /* get end cputime */
3087 + if (!cputime_error &&
3088 + !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3089 + end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3091 + if (start_cpu_nsecs && !cputime_error)
3092 + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3094 + thd->cpu_time = 0;
3096 + // Updates THD stats and the global user stats.
3097 + thd->update_stats(true);
3098 + update_global_user_stats(thd, true, time(NULL));
3103 @@ -7407,8 +7943,35 @@
3104 pthread_mutex_unlock(&LOCK_active_mi);
3107 - if (options & REFRESH_USER_RESOURCES)
3108 - reset_mqh((LEX_USER *) NULL);
3109 + if (options & REFRESH_TABLE_STATS)
3111 + pthread_mutex_lock(&LOCK_global_table_stats);
3112 + free_global_table_stats();
3113 + init_global_table_stats();
3114 + pthread_mutex_unlock(&LOCK_global_table_stats);
3116 + if (options & REFRESH_INDEX_STATS)
3118 + pthread_mutex_lock(&LOCK_global_index_stats);
3119 + free_global_index_stats();
3120 + init_global_index_stats();
3121 + pthread_mutex_unlock(&LOCK_global_index_stats);
3123 + if (options & (REFRESH_USER_STATS | REFRESH_CLIENT_STATS))
3125 + pthread_mutex_lock(&LOCK_global_user_client_stats);
3126 + if (options & REFRESH_USER_STATS)
3128 + free_global_user_stats();
3129 + init_global_user_stats();
3131 + if (options & REFRESH_CLIENT_STATS)
3133 + free_global_client_stats();
3134 + init_global_client_stats();
3136 + pthread_mutex_unlock(&LOCK_global_user_client_stats);
3138 *write_to_binlog= tmp_write_to_binlog;
3141 diff -r 1270c564d514 sql/sql_prepare.cc
3142 --- a/sql/sql_prepare.cc Mon Dec 22 00:26:39 2008 -0800
3143 +++ b/sql/sql_prepare.cc Mon Dec 22 00:31:13 2008 -0800
3146 #include <mysql_com.h>
3149 +// Uses the THD to update the global stats by user name and client IP
3150 +void update_global_user_stats(THD* thd, bool create_user, time_t now);
3152 /* A result class used to send cursor rows using the binary protocol. */
3154 @@ -1910,8 +1913,32 @@
3155 /* First of all clear possible warnings from the previous command */
3156 mysql_reset_thd_for_next_command(thd);
3158 + int start_time_error = 0;
3159 + int end_time_error = 0;
3160 + struct timeval start_time, end_time;
3161 + double start_usecs = 0;
3162 + double end_usecs = 0;
3164 + int cputime_error = 0;
3165 + struct timespec tp;
3166 + double start_cpu_nsecs = 0;
3167 + double end_cpu_nsecs = 0;
3169 + if (opt_userstat_running) {
3170 +#ifdef HAVE_CLOCK_GETTIME
3171 + /* get start cputime */
3172 + if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3173 + start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3176 + // Gets the start time, in order to measure how long this command takes.
3177 + if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3178 + start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3182 if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
3183 - DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
3184 + goto end; /* out of memory: error is set in Sql_alloc */
3186 if (thd->stmt_map.insert(thd, stmt))
3188 @@ -1919,7 +1946,7 @@
3189 The error is set in the insert. The statement itself
3190 will be also deleted there (this is how the hash works).
3196 /* Reset warnings from previous command */
3197 @@ -1941,6 +1968,40 @@
3198 thd->stmt_map.erase(stmt);
3200 /* check_prepared_statemnt sends the metadata packet in case of success */
3202 + if (opt_userstat_running) {
3203 + // Gets the end time.
3204 + if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3205 + end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3208 + // Calculates the difference between the end and start times.
3209 + if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3210 + thd->busy_time = (end_usecs - start_usecs) / 1000000;
3211 + // In case there are bad values, 2629743 is the #seconds in a month.
3212 + if (thd->busy_time > 2629743) {
3213 + thd->busy_time = 0;
3216 + // end time went back in time, or gettimeofday() failed.
3217 + thd->busy_time = 0;
3220 +#ifdef HAVE_CLOCK_GETTIME
3221 + /* get end cputime */
3222 + if (!cputime_error &&
3223 + !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3224 + end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3226 + if (start_cpu_nsecs && !cputime_error)
3227 + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3229 + thd->cpu_time = 0;
3231 + // Updates THD stats and the global user stats.
3232 + thd->update_stats(true);
3233 + update_global_user_stats(thd, true, time(NULL));
3238 @@ -2281,8 +2342,32 @@
3239 /* First of all clear possible warnings from the previous command */
3240 mysql_reset_thd_for_next_command(thd);
3242 + int start_time_error = 0;
3243 + int end_time_error = 0;
3244 + struct timeval start_time, end_time;
3245 + double start_usecs = 0;
3246 + double end_usecs = 0;
3248 + int cputime_error = 0;
3249 + struct timespec tp;
3250 + double start_cpu_nsecs = 0;
3251 + double end_cpu_nsecs = 0;
3253 + if (opt_userstat_running) {
3254 +#ifdef HAVE_CLOCK_GETTIME
3255 + /* get start cputime */
3256 + if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3257 + start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3260 + // Gets the start time, in order to measure how long this command takes.
3261 + if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3262 + start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3266 if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
3270 #ifdef ENABLED_PROFILING
3271 thd->profiling.set_query_source(stmt->query, stmt->query_length);
3272 @@ -2325,11 +2410,46 @@
3273 test(flags & (ulong) CURSOR_TYPE_READ_ONLY));
3274 if (!(specialflag & SPECIAL_NO_PRIOR))
3275 my_pthread_setprio(pthread_self(), WAIT_PRIOR);
3279 set_params_data_err:
3280 my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_execute");
3281 reset_stmt_params(stmt);
3284 + if (opt_userstat_running) {
3285 + // Gets the end time.
3286 + if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3287 + end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3290 + // Calculates the difference between the end and start times.
3291 + if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3292 + thd->busy_time = (end_usecs - start_usecs) / 1000000;
3293 + // In case there are bad values, 2629743 is the #seconds in a month.
3294 + if (thd->busy_time > 2629743) {
3295 + thd->busy_time = 0;
3298 + // end time went back in time, or gettimeofday() failed.
3299 + thd->busy_time = 0;
3302 +#ifdef HAVE_CLOCK_GETTIME
3303 + /* get end cputime */
3304 + if (!cputime_error &&
3305 + !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3306 + end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3308 + if (start_cpu_nsecs && !cputime_error)
3309 + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3311 + thd->cpu_time = 0;
3313 + // Updates THD stats and the global user stats.
3314 + thd->update_stats(true);
3315 + update_global_user_stats(thd, true, time(NULL));
3320 @@ -2423,6 +2543,31 @@
3322 /* First of all clear possible warnings from the previous command */
3323 mysql_reset_thd_for_next_command(thd);
3325 + int start_time_error = 0;
3326 + int end_time_error = 0;
3327 + struct timeval start_time, end_time;
3328 + double start_usecs = 0;
3329 + double end_usecs = 0;
3331 + int cputime_error = 0;
3332 + struct timespec tp;
3333 + double start_cpu_nsecs = 0;
3334 + double end_cpu_nsecs = 0;
3336 + if (opt_userstat_running) {
3337 +#ifdef HAVE_CLOCK_GETTIME
3338 + /* get start cputime */
3339 + if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3340 + start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3343 + // Gets the start time, in order to measure how long this command takes.
3344 + if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3345 + start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3349 statistic_increment(thd->status_var.com_stmt_fetch, &LOCK_status);
3350 if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_fetch")))
3352 @@ -2455,6 +2600,39 @@
3353 thd->restore_backup_statement(stmt, &stmt_backup);
3354 thd->stmt_arena= thd;
3356 + if (opt_userstat_running) {
3357 + // Gets the end time.
3358 + if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3359 + end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3362 + // Calculates the difference between the end and start times.
3363 + if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3364 + thd->busy_time = (end_usecs - start_usecs) / 1000000;
3365 + // In case there are bad values, 2629743 is the #seconds in a month.
3366 + if (thd->busy_time > 2629743) {
3367 + thd->busy_time = 0;
3370 + // end time went back in time, or gettimeofday() failed.
3371 + thd->busy_time = 0;
3374 +#ifdef HAVE_CLOCK_GETTIME
3375 + /* get end cputime */
3376 + if (!cputime_error &&
3377 + !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3378 + end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3380 + if (start_cpu_nsecs && !cputime_error)
3381 + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3383 + thd->cpu_time = 0;
3385 + // Updates THD stats and the global user stats.
3386 + thd->update_stats(true);
3387 + update_global_user_stats(thd, true, time(NULL));
3392 @@ -2487,6 +2665,30 @@
3393 /* First of all clear possible warnings from the previous command */
3394 mysql_reset_thd_for_next_command(thd);
3396 + int start_time_error = 0;
3397 + int end_time_error = 0;
3398 + struct timeval start_time, end_time;
3399 + double start_usecs = 0;
3400 + double end_usecs = 0;
3402 + int cputime_error = 0;
3403 + struct timespec tp;
3404 + double start_cpu_nsecs = 0;
3405 + double end_cpu_nsecs = 0;
3407 + if (opt_userstat_running) {
3408 +#ifdef HAVE_CLOCK_GETTIME
3409 + /* get start cputime */
3410 + if (!(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3411 + start_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3414 + // Gets the start time, in order to measure how long this command takes.
3415 + if (!(start_time_error = gettimeofday(&start_time, NULL))) {
3416 + start_usecs = start_time.tv_sec * 1000000.0 + start_time.tv_usec;
3420 statistic_increment(thd->status_var.com_stmt_reset, &LOCK_status);
3421 if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
3423 @@ -2502,6 +2704,39 @@
3424 stmt->state= Query_arena::PREPARED;
3428 + if (opt_userstat_running) {
3429 + // Gets the end time.
3430 + if (!(end_time_error = gettimeofday(&end_time, NULL))) {
3431 + end_usecs = end_time.tv_sec * 1000000.0 + end_time.tv_usec;
3434 + // Calculates the difference between the end and start times.
3435 + if (start_usecs && end_usecs >= start_usecs && !start_time_error && !end_time_error) {
3436 + thd->busy_time = (end_usecs - start_usecs) / 1000000;
3437 + // In case there are bad values, 2629743 is the #seconds in a month.
3438 + if (thd->busy_time > 2629743) {
3439 + thd->busy_time = 0;
3442 + // end time went back in time, or gettimeofday() failed.
3443 + thd->busy_time = 0;
3446 +#ifdef HAVE_CLOCK_GETTIME
3447 + /* get end cputime */
3448 + if (!cputime_error &&
3449 + !(cputime_error = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)))
3450 + end_cpu_nsecs = tp.tv_sec*1000000000.0+tp.tv_nsec;
3452 + if (start_cpu_nsecs && !cputime_error)
3453 + thd->cpu_time = (end_cpu_nsecs - start_cpu_nsecs) / 1000000000;
3455 + thd->cpu_time = 0;
3457 + // Updates THD stats and the global user stats.
3458 + thd->update_stats(true);
3459 + update_global_user_stats(thd, true, time(NULL));
3463 diff -r 1270c564d514 sql/sql_show.cc
3464 --- a/sql/sql_show.cc Mon Dec 22 00:26:39 2008 -0800
3465 +++ b/sql/sql_show.cc Mon Dec 22 00:31:13 2008 -0800
3467 sctx->master_access);
3468 if (!(db_access & DB_ACLS) && (!grant_option || check_grant_db(thd,dbname)))
3470 + thd->diff_access_denied_errors++;
3471 my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
3472 sctx->priv_user, sctx->host_or_ip, dbname);
3473 mysql_log.write(thd,COM_INIT_DB,ER(ER_DBACCESS_DENIED_ERROR),
3474 @@ -1858,6 +1859,300 @@
3479 + Aggregate values for mapped_user entries by their role.
3482 + aggregate_user_stats
3483 + all_user_stats - input to aggregate
3484 + agg_user_stats - returns aggregated values
3491 +aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
3493 + DBUG_ENTER("aggregate_user_stats");
3494 + if (hash_init(agg_user_stats, system_charset_info,
3495 + max(all_user_stats->records, 1),
3496 + 0, 0, (hash_get_key)get_key_user_stats,
3497 + (hash_free_key)free_user_stats, 0))
3499 + sql_print_error("Malloc in aggregate_user_stats failed");
3503 + for (int i = 0; i < all_user_stats->records; ++i) {
3504 + USER_STATS *user = (USER_STATS*)hash_element(all_user_stats, i);
3505 + USER_STATS *agg_user;
3506 + if (!(agg_user = (USER_STATS*)hash_search(agg_user_stats,
3507 + (byte*)user->priv_user,
3508 + strlen(user->priv_user))))
3510 + // First entry for this role.
3512 + (USER_STATS*) my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL))))
3514 + sql_print_error("Malloc in aggregate_user_stats failed");
3518 + init_user_stats(agg_user, user->priv_user, user->priv_user,
3519 + user->total_connections, user->concurrent_connections,
3520 + user->connected_time, user->busy_time, user->cpu_time,
3521 + user->bytes_received, user->bytes_sent,
3522 + user->binlog_bytes_written,
3523 + user->rows_fetched, user->rows_updated, user->rows_read,
3524 + user->select_commands, user->update_commands,
3525 + user->other_commands,
3526 + user->commit_trans, user->rollback_trans,
3527 + user->denied_connections, user->lost_connections,
3528 + user->access_denied_errors, user->empty_queries);
3530 + if (my_hash_insert(agg_user_stats, (byte*)agg_user))
3533 + my_free((char*)agg_user, 0);
3534 + sql_print_error("Malloc in aggregate_user_stats failed");
3540 + // Aggregate with existing values for this role.
3541 + add_user_stats(agg_user,
3542 + user->total_connections, user->concurrent_connections,
3543 + user->connected_time, user->busy_time, user->cpu_time,
3544 + user->bytes_received, user->bytes_sent,
3545 + user->binlog_bytes_written,
3546 + user->rows_fetched, user->rows_updated, user->rows_read,
3547 + user->select_commands, user->update_commands,
3548 + user->other_commands,
3549 + user->commit_trans, user->rollback_trans,
3550 + user->denied_connections, user->lost_connections,
3551 + user->access_denied_errors, user->empty_queries);
3554 + DBUG_PRINT("exit", ("aggregated %d input into %d output entries",
3555 + all_user_stats->records, agg_user_stats->records));
3560 + Write result to network for SHOW USER_STATISTICS
3564 + all_user_stats - values to return
3571 +int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
3573 + DBUG_ENTER("send_user_stats");
3574 + for (int i = 0; i < all_user_stats->records; ++i) {
3575 + restore_record(table, s->default_values);
3576 + USER_STATS *user_stats = (USER_STATS*)hash_element(all_user_stats, i);
3577 + table->field[0]->store(user_stats->user, strlen(user_stats->user), system_charset_info);
3578 + table->field[1]->store((longlong)user_stats->total_connections);
3579 + table->field[2]->store((longlong)user_stats->concurrent_connections);
3580 + table->field[3]->store((longlong)user_stats->connected_time);
3581 + table->field[4]->store((longlong)user_stats->busy_time);
3582 + table->field[5]->store((longlong)user_stats->cpu_time);
3583 + table->field[6]->store((longlong)user_stats->bytes_received);
3584 + table->field[7]->store((longlong)user_stats->bytes_sent);
3585 + table->field[8]->store((longlong)user_stats->binlog_bytes_written);
3586 + table->field[9]->store((longlong)user_stats->rows_fetched);
3587 + table->field[10]->store((longlong)user_stats->rows_updated);
3588 + table->field[11]->store((longlong)user_stats->rows_read);
3589 + table->field[12]->store((longlong)user_stats->select_commands);
3590 + table->field[13]->store((longlong)user_stats->update_commands);
3591 + table->field[14]->store((longlong)user_stats->other_commands);
3592 + table->field[15]->store((longlong)user_stats->commit_trans);
3593 + table->field[16]->store((longlong)user_stats->rollback_trans);
3594 + table->field[17]->store((longlong)user_stats->denied_connections);
3595 + table->field[18]->store((longlong)user_stats->lost_connections);
3596 + table->field[19]->store((longlong)user_stats->access_denied_errors);
3597 + table->field[20]->store((longlong)user_stats->empty_queries);
3598 + if (schema_table_store_record(thd, table))
3600 + DBUG_PRINT("error", ("store record error"));
3608 + Process SHOW USER_STATISTICS
3611 + mysqld_show_user_stats
3612 + thd - current thread
3613 + wild - limit results to the entry for this user
3614 + with_roles - when true, display role for mapped users
3622 +int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3624 + TABLE *table= tables->table;
3625 + DBUG_ENTER("fill_schema_user_stats");
3627 + if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
3630 + // Iterates through all the global stats and sends them to the client.
3631 + // Pattern matching on the client IP is supported.
3633 + pthread_mutex_lock(&LOCK_global_user_client_stats);
3634 + int result= send_user_stats(thd, &global_user_stats, table);
3635 + pthread_mutex_unlock(&LOCK_global_user_client_stats);
3639 + DBUG_PRINT("exit", ("fill_schema_user_stats result is 0"));
3643 + DBUG_PRINT("exit", ("fill_schema_user_stats result is 1"));
3648 + Process SHOW CLIENT_STATISTICS
3651 + mysqld_show_client_stats
3652 + thd - current thread
3653 + wild - limit results to the entry for this client
3661 +int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3663 + TABLE *table= tables->table;
3664 + DBUG_ENTER("fill_schema_client_stats");
3666 + if (check_global_access(thd, SUPER_ACL | PROCESS_ACL))
3669 + // Iterates through all the global stats and sends them to the client.
3670 + // Pattern matching on the client IP is supported.
3672 + pthread_mutex_lock(&LOCK_global_user_client_stats);
3673 + int result= send_user_stats(thd, &global_client_stats, table);
3674 + pthread_mutex_unlock(&LOCK_global_user_client_stats);
3678 + DBUG_PRINT("exit", ("mysqld_show_client_stats result is 0"));
3682 + DBUG_PRINT("exit", ("mysqld_show_client_stats result is 1"));
3687 +// Sends the global table stats back to the client.
3688 +int fill_schema_table_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3690 + TABLE *table= tables->table;
3691 + DBUG_ENTER("fill_schema_table_stats");
3692 + char *table_full_name, *table_schema;
3694 + pthread_mutex_lock(&LOCK_global_table_stats);
3695 + for (int i = 0; i < global_table_stats.records; ++i) {
3696 + restore_record(table, s->default_values);
3697 + TABLE_STATS *table_stats =
3698 + (TABLE_STATS*)hash_element(&global_table_stats, i);
3700 + table_full_name= thd->strdup(table_stats->table);
3701 + table_schema= strsep(&table_full_name, ".");
3703 + TABLE_LIST tmp_table;
3704 + bzero((char*) &tmp_table,sizeof(tmp_table));
3705 + tmp_table.table_name= table_full_name;
3706 + tmp_table.db= table_schema;
3707 + tmp_table.grant.privilege= 0;
3708 + if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
3709 + &tmp_table.grant.privilege, 0, 0,
3710 + is_schema_db(table_schema)) ||
3711 + grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
3714 + table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
3715 + table->field[1]->store(table_full_name, strlen(table_full_name), system_charset_info);
3716 + table->field[2]->store((longlong)table_stats->rows_read, TRUE);
3717 + table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
3718 + table->field[4]->store((longlong)table_stats->rows_changed_x_indexes, TRUE);
3720 + if (schema_table_store_record(thd, table))
3722 + VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
3726 + pthread_mutex_unlock(&LOCK_global_table_stats);
3730 +// Sends the global index stats back to the client.
3731 +int fill_schema_index_stats(THD* thd, TABLE_LIST* tables, COND* cond)
3733 + TABLE *table= tables->table;
3734 + DBUG_ENTER("fill_schema_index_stats");
3735 + char *index_full_name, *table_schema, *table_name;
3737 + pthread_mutex_lock(&LOCK_global_index_stats);
3738 + for (int i = 0; i < global_index_stats.records; ++i) {
3739 + restore_record(table, s->default_values);
3740 + INDEX_STATS *index_stats =
3741 + (INDEX_STATS*)hash_element(&global_index_stats, i);
3743 + index_full_name= thd->strdup(index_stats->index);
3744 + table_schema= strsep(&index_full_name, ".");
3745 + table_name= strsep(&index_full_name, ".");
3747 + TABLE_LIST tmp_table;
3748 + bzero((char*) &tmp_table,sizeof(tmp_table));
3749 + tmp_table.table_name= table_name;
3750 + tmp_table.db= table_schema;
3751 + tmp_table.grant.privilege= 0;
3752 + if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
3753 + &tmp_table.grant.privilege, 0, 0,
3754 + is_schema_db(table_schema)) ||
3755 + grant_option && check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
3758 + table->field[0]->store(table_schema, strlen(table_schema), system_charset_info);
3759 + table->field[1]->store(table_name, strlen(table_name), system_charset_info);
3760 + table->field[2]->store(index_full_name, strlen(index_full_name), system_charset_info);
3761 + table->field[3]->store((longlong)index_stats->rows_read, TRUE);
3763 + if (schema_table_store_record(thd, table))
3765 + VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
3769 + pthread_mutex_unlock(&LOCK_global_index_stats);
3773 /* collect status for all running threads */
3775 @@ -4468,6 +4763,77 @@
3776 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3779 +ST_FIELD_INFO user_stats_fields_info[]=
3781 + {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
3782 + {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
3783 + {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
3784 + {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
3785 + {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
3786 + {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
3787 + {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
3788 + {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
3789 + {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
3790 + {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
3791 + {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
3792 + {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
3793 + {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
3794 + {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
3795 + {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
3796 + {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
3797 + {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
3798 + {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
3799 + {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
3800 + {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
3801 + {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
3802 + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3805 +ST_FIELD_INFO client_stats_fields_info[]=
3807 + {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
3808 + {"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections"},
3809 + {"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections"},
3810 + {"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time"},
3811 + {"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Busy_time"},
3812 + {"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Cpu_time"},
3813 + {"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_received"},
3814 + {"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Bytes_sent"},
3815 + {"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Binlog_bytes_written"},
3816 + {"ROWS_FETCHED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_fetched"},
3817 + {"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_updated"},
3818 + {"TABLE_ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Table_rows_read"},
3819 + {"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Select_commands"},
3820 + {"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Update_commands"},
3821 + {"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Other_commands"},
3822 + {"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Commit_transactions"},
3823 + {"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rollback_transactions"},
3824 + {"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Denied_connections"},
3825 + {"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Lost_connections"},
3826 + {"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Access_denied"},
3827 + {"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Empty_queries"},
3828 + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3832 +ST_FIELD_INFO table_stats_fields_info[]=
3834 + {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
3835 + {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
3836 + {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
3837 + {"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed"},
3838 + {"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_changed_x_#indexes"},
3839 + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3842 +ST_FIELD_INFO index_stats_fields_info[]=
3844 + {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema"},
3845 + {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"},
3846 + {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"},
3847 + {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Rows_read"},
3848 + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
3852 Description of ST_FIELD_INFO in table.h
3853 @@ -4477,6 +4843,8 @@
3855 {"CHARACTER_SETS", charsets_fields_info, create_schema_table,
3856 fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
3857 + {"CLIENT_STATISTICS", client_stats_fields_info, create_schema_table,
3858 + fill_schema_client_stats, make_old_format, 0, -1, -1, 0},
3859 {"COLLATIONS", collation_fields_info, create_schema_table,
3860 fill_schema_collation, make_old_format, 0, -1, -1, 0},
3861 {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
3862 @@ -4485,6 +4853,8 @@
3863 get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
3864 {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
3865 fill_schema_column_privileges, 0, 0, -1, -1, 0},
3866 + {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table,
3867 + fill_schema_index_stats, make_old_format, 0, -1, -1, 0},
3868 {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
3869 get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
3870 {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
3871 @@ -4510,10 +4880,14 @@
3872 get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
3873 {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
3874 fill_schema_table_privileges, 0, 0, -1, -1, 0},
3875 + {"TABLE_STATISTICS", table_stats_fields_info, create_schema_table,
3876 + fill_schema_table_stats, make_old_format, 0, -1, -1, 0},
3877 {"TRIGGERS", triggers_fields_info, create_schema_table,
3878 get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
3879 {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table,
3880 fill_schema_user_privileges, 0, 0, -1, -1, 0},
3881 + {"USER_STATISTICS", user_stats_fields_info, create_schema_table,
3882 + fill_schema_user_stats, make_old_format, 0, -1, -1, 0},
3883 {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
3884 make_old_format, 0, -1, -1, 1},
3885 {"VIEWS", view_fields_info, create_schema_table,
3886 diff -r 1270c564d514 sql/sql_update.cc
3887 --- a/sql/sql_update.cc Mon Dec 22 00:26:39 2008 -0800
3888 +++ b/sql/sql_update.cc Mon Dec 22 00:31:13 2008 -0800
3890 (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
3891 send_ok(thd, (ulong) thd->row_count_func,
3892 thd->insert_id_used ? thd->last_insert_id : 0L,buff);
3893 - DBUG_PRINT("info",("%ld records updated", (long) updated));
3894 + thd->updated_row_count += thd->row_count_func;
3895 + DBUG_PRINT("info",("%d records updated",updated));
3897 thd->count_cuted_fields= CHECK_FIELD_IGNORE; /* calc cuted fields */
3898 thd->abort_on_warning= 0;
3899 @@ -1832,5 +1833,6 @@
3900 (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
3901 ::send_ok(thd, (ulong) thd->row_count_func,
3902 thd->insert_id_used ? thd->last_insert_id : 0L,buff);
3903 + thd->updated_row_count += thd->row_count_func;
3906 diff -r 1270c564d514 sql/sql_yacc.yy
3907 --- a/sql/sql_yacc.yy Mon Dec 22 00:26:39 2008 -0800
3908 +++ b/sql/sql_yacc.yy Mon Dec 22 00:31:13 2008 -0800
3913 +%token CLIENT_STATS_SYM
3921 +%token INDEX_STATS_SYM
3937 +%token TABLE_STATS_SYM
3939 %token TEMPTABLE_SYM
3945 +%token USER_STATS_SYM
3949 @@ -8244,6 +8249,38 @@
3951 Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
3953 + | CLIENT_STATS_SYM wild_and_where
3956 + Lex->sql_command = SQLCOM_SELECT;
3957 + lex->orig_sql_command= SQLCOM_SHOW_CLIENT_STATS;
3958 + if (prepare_schema_table(YYTHD, lex, 0, SCH_CLIENT_STATS))
3961 + | USER_STATS_SYM wild_and_where
3964 + lex->sql_command = SQLCOM_SELECT;
3965 + lex->orig_sql_command= SQLCOM_SHOW_USER_STATS;
3966 + if (prepare_schema_table(YYTHD, lex, 0, SCH_USER_STATS))
3969 + | TABLE_STATS_SYM wild_and_where
3972 + lex->sql_command= SQLCOM_SELECT;
3973 + lex->orig_sql_command= SQLCOM_SHOW_TABLE_STATS;
3974 + if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_STATS))
3977 + | INDEX_STATS_SYM wild_and_where
3980 + lex->sql_command= SQLCOM_SELECT;
3981 + lex->orig_sql_command= SQLCOM_SHOW_INDEX_STATS;
3982 + if (prepare_schema_table(YYTHD, lex, 0, SCH_INDEX_STATS))
3985 | CREATE PROCEDURE sp_name
3988 @@ -8448,9 +8485,14 @@
3989 | LOGS_SYM { Lex->type|= REFRESH_LOG; }
3990 | STATUS_SYM { Lex->type|= REFRESH_STATUS; }
3991 | SLAVE { Lex->type|= REFRESH_SLAVE; }
3992 + | SLOW_SYM QUERY_SYM LOGS_SYM { Lex->type |= REFRESH_SLOW_QUERY_LOG; }
3993 | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
3994 | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
3995 - | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; };
3996 + | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
3997 + | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
3998 + | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
3999 + | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
4000 + | INDEX_STATS_SYM { Lex->type|= REFRESH_INDEX_STATS; };
4004 @@ -9439,6 +9481,7 @@
4008 + | CLIENT_STATS_SYM {}
4012 @@ -9491,6 +9534,7 @@
4016 + | INDEX_STATS_SYM {}
4020 @@ -9600,6 +9644,7 @@
4028 @@ -9616,6 +9661,7 @@
4032 + | TABLE_STATS_SYM {}
4036 @@ -9636,6 +9682,7 @@
4040 + | USER_STATS_SYM {}
4044 diff -r 1270c564d514 sql/structs.h
4045 --- a/sql/structs.h Mon Dec 22 00:26:39 2008 -0800
4046 +++ b/sql/structs.h Mon Dec 22 00:31:13 2008 -0800
4047 @@ -273,6 +273,98 @@
4051 +typedef struct st_user_stats {
4052 + char user[USERNAME_LENGTH + 1];
4053 + // Account name the user is mapped to when this is a user from mapped_user.
4054 + // Otherwise, the same value as user.
4055 + char priv_user[USERNAME_LENGTH + 1];
4056 + uint total_connections;
4057 + uint concurrent_connections;
4058 + time_t connected_time; // in seconds
4059 + double busy_time; // in seconds
4060 + double cpu_time; // in seconds
4061 + ulonglong bytes_received;
4062 + ulonglong bytes_sent;
4063 + ulonglong binlog_bytes_written;
4064 + ha_rows rows_fetched, rows_updated, rows_read;
4065 + ulonglong select_commands, update_commands, other_commands;
4066 + ulonglong commit_trans, rollback_trans;
4067 + ulonglong denied_connections, lost_connections;
4068 + ulonglong access_denied_errors;
4069 + ulonglong empty_queries;
4072 +/* Lookup function for hash tables with USER_STATS entries */
4073 +extern byte *get_key_user_stats(USER_STATS *user_stats, uint *length,
4074 + my_bool not_used __attribute__((unused)));
4076 +/* Free all memory for a hash table with USER_STATS entries */
4077 +extern void free_user_stats(USER_STATS* user_stats);
4079 +/* Intialize an instance of USER_STATS */
4081 +init_user_stats(USER_STATS *user_stats,
4083 + const char *priv_user,
4084 + uint total_connections,
4085 + uint concurrent_connections,
4086 + time_t connected_time,
4089 + ulonglong bytes_received,
4090 + ulonglong bytes_sent,
4091 + ulonglong binlog_bytes_written,
4092 + ha_rows rows_fetched,
4093 + ha_rows rows_updated,
4094 + ha_rows rows_read,
4095 + ulonglong select_commands,
4096 + ulonglong update_commands,
4097 + ulonglong other_commands,
4098 + ulonglong commit_trans,
4099 + ulonglong rollback_trans,
4100 + ulonglong denied_connections,
4101 + ulonglong lost_connections,
4102 + ulonglong access_denied_errors,
4103 + ulonglong empty_queries);
4105 +/* Increment values of an instance of USER_STATS */
4107 +add_user_stats(USER_STATS *user_stats,
4108 + uint total_connections,
4109 + uint concurrent_connections,
4110 + time_t connected_time,
4113 + ulonglong bytes_received,
4114 + ulonglong bytes_sent,
4115 + ulonglong binlog_bytes_written,
4116 + ha_rows rows_fetched,
4117 + ha_rows rows_updated,
4118 + ha_rows rows_read,
4119 + ulonglong select_commands,
4120 + ulonglong update_commands,
4121 + ulonglong other_commands,
4122 + ulonglong commit_trans,
4123 + ulonglong rollback_trans,
4124 + ulonglong denied_connections,
4125 + ulonglong lost_connections,
4126 + ulonglong access_denied_errors,
4127 + ulonglong empty_queries);
4129 +typedef struct st_table_stats {
4130 + char table[NAME_LEN * 2 + 2]; // [db] + '.' + [table] + '\0'
4131 + ulonglong rows_read, rows_changed;
4132 + ulonglong rows_changed_x_indexes;
4133 + /* Stores enum db_type, but forward declarations cannot be done */
4137 +typedef struct st_index_stats {
4138 + char index[NAME_LEN * 3 + 3]; // [db] + '.' + [table] + '.' + [index] + '\0'
4139 + ulonglong rows_read;
4143 /* Bits in form->update */
4144 #define REG_MAKE_DUPP 1 /* Make a copy of record when read */
4145 #define REG_NEW_RECORD 2 /* Write a new record if not found */
4146 diff -r 1270c564d514 sql/table.h
4147 --- a/sql/table.h Mon Dec 22 00:26:39 2008 -0800
4148 +++ b/sql/table.h Mon Dec 22 00:31:13 2008 -0800
4149 @@ -371,10 +371,12 @@
4150 enum enum_schema_tables
4155 SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
4157 SCH_COLUMN_PRIVILEGES,
4159 SCH_KEY_COLUMN_USAGE,
4162 @@ -387,8 +389,10 @@
4163 SCH_TABLE_CONSTRAINTS,
4165 SCH_TABLE_PRIVILEGES,
4168 SCH_USER_PRIVILEGES,
4173 diff -r 1270c564d514 strings/Makefile.in
4174 --- a/strings/Makefile.in Mon Dec 22 00:26:39 2008 -0800
4175 +++ b/strings/Makefile.in Mon Dec 22 00:31:13 2008 -0800
4178 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4183 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4184 diff -r 1270c564d514 support-files/MacOSX/Makefile.in
4185 --- a/support-files/MacOSX/Makefile.in Mon Dec 22 00:26:39 2008 -0800
4186 +++ b/support-files/MacOSX/Makefile.in Mon Dec 22 00:31:13 2008 -0800
4189 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4194 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4195 diff -r 1270c564d514 support-files/Makefile.in
4196 --- a/support-files/Makefile.in Mon Dec 22 00:26:39 2008 -0800
4197 +++ b/support-files/Makefile.in Mon Dec 22 00:31:13 2008 -0800
4200 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4205 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4206 diff -r 1270c564d514 support-files/RHEL4-SElinux/Makefile.in
4207 --- a/support-files/RHEL4-SElinux/Makefile.in Mon Dec 22 00:26:39 2008 -0800
4208 +++ b/support-files/RHEL4-SElinux/Makefile.in Mon Dec 22 00:31:13 2008 -0800
4211 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4216 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4217 diff -r 1270c564d514 tests/Makefile.in
4218 --- a/tests/Makefile.in Mon Dec 22 00:26:39 2008 -0800
4219 +++ b/tests/Makefile.in Mon Dec 22 00:31:13 2008 -0800
4222 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4225 LIBS = @CLIENT_LIBS@
4227 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4228 diff -r 1270c564d514 tools/Makefile.in
4229 --- a/tools/Makefile.in Mon Dec 22 00:26:39 2008 -0800
4230 +++ b/tools/Makefile.in Mon Dec 22 00:31:13 2008 -0800
4233 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4238 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4239 diff -r 1270c564d514 vio/Makefile.in
4240 --- a/vio/Makefile.in Mon Dec 22 00:26:39 2008 -0800
4241 +++ b/vio/Makefile.in Mon Dec 22 00:31:13 2008 -0800
4244 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4249 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4250 diff -r 1270c564d514 win/Makefile.in
4251 --- a/win/Makefile.in Mon Dec 22 00:26:39 2008 -0800
4252 +++ b/win/Makefile.in Mon Dec 22 00:31:13 2008 -0800
4255 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4260 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@
4261 diff -r 1270c564d514 zlib/Makefile.in
4262 --- a/zlib/Makefile.in Mon Dec 22 00:26:39 2008 -0800
4263 +++ b/zlib/Makefile.in Mon Dec 22 00:31:13 2008 -0800
4266 LIBEDIT_LOBJECTS = @LIBEDIT_LOBJECTS@
4269 LIBS = $(NON_THREADED_LIBS)
4271 LIB_EXTRA_CCFLAGS = @LIB_EXTRA_CCFLAGS@