Merge lp:~tsarev/percona-server/5.1_fix_bug_924872 into lp:percona-server/5.1

Proposed by Oleg Tsarev
Status: Work in progress
Proposed branch: lp:~tsarev/percona-server/5.1_fix_bug_924872
Merge into: lp:percona-server/5.1
Diff against target: 6527 lines (+4423/-975)
35 files modified
Percona-Server/mysql-test/include/show_stats.inc (+78/-0)
Percona-Server/mysql-test/include/show_table_index_stats.inc (+20/-0)
Percona-Server/mysql-test/r/access_denied.result (+330/-0)
Percona-Server/mysql-test/r/show_stats.result (+1735/-0)
Percona-Server/mysql-test/r/user_stats.result (+90/-0)
Percona-Server/mysql-test/r/userstat_bug602047.result (+2/-0)
Percona-Server/mysql-test/t/access_denied.test (+559/-0)
Percona-Server/mysql-test/t/show_stats.test (+484/-0)
Percona-Server/mysql-test/t/user_stats.test (+135/-0)
Percona-Server/mysql-test/t/userstat_bug602047.test (+2/-0)
Percona-Server/sql/handler.cc (+112/-64)
Percona-Server/sql/handler.h (+7/-4)
Percona-Server/sql/item.cc (+1/-0)
Percona-Server/sql/mysql_priv.h (+1/-1)
Percona-Server/sql/mysqld.cc (+0/-3)
Percona-Server/sql/set_var.cc (+3/-0)
Percona-Server/sql/sp_head.cc (+1/-0)
Percona-Server/sql/sql_acl.cc (+5/-0)
Percona-Server/sql/sql_base.cc (+1/-0)
Percona-Server/sql/sql_class.cc (+102/-76)
Percona-Server/sql/sql_class.h (+20/-35)
Percona-Server/sql/sql_connect.cc (+473/-524)
Percona-Server/sql/sql_db.cc (+1/-0)
Percona-Server/sql/sql_delete.cc (+2/-2)
Percona-Server/sql/sql_insert.cc (+2/-2)
Percona-Server/sql/sql_parse.cc (+30/-21)
Percona-Server/sql/sql_prepare.cc (+6/-6)
Percona-Server/sql/sql_show.cc (+134/-97)
Percona-Server/sql/sql_trigger.cc (+1/-0)
Percona-Server/sql/sql_update.cc (+2/-2)
Percona-Server/sql/sql_view.cc (+3/-0)
Percona-Server/sql/sql_yacc.yy (+5/-5)
Percona-Server/sql/structs.h (+49/-133)
Percona-Server/sql/table.cc (+1/-0)
Percona-Server/storage/myisam/ha_myisam.cc (+26/-0)
To merge this branch: bzr merge lp:~tsarev/percona-server/5.1_fix_bug_924872
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Needs Fixing
Review via email: mp+91205@code.launchpad.net

This proposal supersedes a proposal from 2012-02-02.

Description of the change

Changes related to userstat feature

Jenkins (no fails related to feature):
http://jenkins.percona.com/view/Percona%20Server%205.1/job/percona-server-5.1-param/238/

Tests:
1) I fixed test userstats_bug602047 (incorrect behavior on --repeat run).
2) I ported following tests from http://code.google.com/p/google-mysql-tools/:
  * access_denied
  * user_stats
  * show_stats
3) sql_connect.cc - added Debug Variable signal_end_connection for activate Debug Signal end_connection after connection close and before end of thread to the handle_one_connection function (required for catch closed connection).
  Alternative way - SHOW PROCESSLIST works worse: affected to collected statistics.
   Disable statistics while wait of close connection is worse too, I need catch changes in statistics related to close of connection.
4) user_stats.tests:
  - I moved all queries to check statistics to include/show_stats.inc
  - I now check all columns of statistics tables.
  - I checked SHOW *_STATISTICS and SELECT * FROM INFORMATION_SCHEMA.*_STATISTICS (originally test checked just SHOW syntax)
  - I checked WHERE and LIKE condition both on SHOW and SELECT syntax
  - I checked results on every combination - SHOW/SELECT, LIKE/WHERE
  - I added checks to THREAD_STATISTICS (this is Percona-specific extension, originally Google patch didn't have it)
  - I fixed sporadic tests fails related to thread concurrency (not completed connection) by wait Debug Signal end_connection
  - I removed sleep from test
  - I added backup of mysql.user before test run (need for correct check of test case).
The bug #924872 and bug #728082 confirmed by this tests.

Code:
1) Removed unnecessary sent_row_count_2: (sql/sql_class.h: class THD). Now uses sent_row_count instead of it.
2) Avoid copy-paste between THREAD_STATS and USER_STATS: moved counter to STATS structure, use it in USER_STATS and THREAD_STATS (sql/structs.h).
3) Replaced bunch of counters diff_* by STATS struct (sql/sql_class.h: class THD, also many small changes in different files).
4) Added increment of access_denied counter (different files, is related to incompleted port from Google patch).
5) Removed unnecessary LOCK_stats mutex (is related to incorrect port from Google patch).
6) Fixed incorrect kind of query detection (is related to incompleted port from Google patch):
  * sql/sql_yacc.yy: SQLCOM_SHOW_[CLIENT|USER|THREAD|TABLE|INDEX]_STATS instead of SQLCOM_SELECT
  * sql/sql_parse.cc: assign CF_STATUS_COMMAND flag for SHOW [CLIENT|USER|THREAD|TABLE|INDEX]_STATS commands
  Without this changes code in the THD::update_stats incorrect works.
7) Fixed comment for THD::get_client_host_port (incorrect moved in one of previous porting)
8) Removed ugly init_user_stats / init_thread_stats function (rudimentary used). Now I use direct memset(..., 0, ...) initialisation.
9) Renamed function update_global_user_stats to update_global_stats (because not only user_stats updated, thread_stats too)
10) Avoid copy-paste between update_global_user_stats_with_user and update_global_user_stats_with_thread by single function update_stats
11) Add set_connections function (related to incomplete port from Google patch) and add call to send_user_stats and send_thread_stats (bug #728082, bug #924872). Without this call statistcs from separated thread didn't aggregated to global_[client|thread|user]_stats.
12) Add counters cleanup to sql_parse.cc: mysql_reset_thd_for_next_command (related to incompleted port from Google patch)
13) Add wild-card processing to:
  * send_user_stats
  * send_thread_stats
  * fill_schema_table_stats
  * fill_schema_index_stats
Without this changes LIKE and WHERE works incorrectly (related to incompleted port from Google patch).
14) Removed unnecessary engine_type from TABLE STATS (changes related to changes from Percona).
15) Removed unnecessary add_thead_stats / add_user_stats functions.
16) Added DBUG_ENTER/DBUG_RETURN/DBUG_VOID_RETURN information to related functions.
17) Fixed code policy / added comments to function for all related code.
18) Added EXTENDED_FOR_USERSTAT macros to storage/myisam/ha_myisam.cc

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

The Jenkins failures are too many to be confident, although none look
like they are directly related to userstat. Please get a cleaner
Jenkins run.

What is the exact source of the patches, tests, etc? I cannot find them by
casually browsing http://code.google.com/p/google-mysql-tools/ .

No need to replace "// foo" comments by "/* foo */"

I am unable to review the whole MP as-is. Maybe other reviews would
be able to, but I'd have doubts in their review quality :)

In order for me to be able to review it, there should be several
smaller MPs. One suggested split would be (might be not fully correct
due to technical details I don't know):

1) Port the Google tests that pass with the current PS code;
2) userstats_bug602047 (incorrect behavior on --repeat run);
3) user_stats.test: 3.1) include/show_stats.inc refactoring, 3.2)
Concurrency fixes (remove sleep, use end_connection debug signal) 3.3)
backup of mysql.user;
4) Code refactorings that do not change behaviour: 4.1) remove
sent_row_count_2, 4.2) remove LOCK_stats, 4.3) STATS struct
refactoring 4.4) etc...
5) Code fixes with associated tests split as necessary.

Yes, such split suggests many MPs, but I don't see any other way for
me to review it.

review: Needs Fixing

Unmerged revisions

424. By Oleg Tsarev

1) Removed unnecessary sent_row_count_2: (sql/sql_class.h: class THD). Now uses sent_row_count instead of it.
2) Avoid copy-paste between THREAD_STATS and USER_STATS: moved counter to STATS structure, use it in USER_STATS and THREAD_STATS (sql/structs.h).
3) Replaced bunch of counters diff_* by STATS struct (sql/sql_class.h: class THD, also many small changes in different files).
4) Added increment of access_denied counter (different files, is related to incompleted port from Google patch).
5) Removed unnecessary LOCK_stats mutex (is related to incorrect port from Google patch).
6) Fixed incorrect kind of query detection (is related to incompleted port from Google patch):
  * sql/sql_yacc.yy: SQLCOM_SHOW_[CLIENT|USER|THREAD|TABLE|INDEX]_STATS instead of SQLCOM_SELECT
  * sql/sql_parse.cc: assign CF_STATUS_COMMAND flag for SHOW [CLIENT|USER|THREAD|TABLE|INDEX]_STATS commands
  Without this changes code in the THD::update_stats incorrect works.
7) Fixed comment for THD::get_client_host_port (incorrect moved in one of previous porting)
8) Removed ugly init_user_stats / init_thread_stats function (rudimentary used). Now I use direct memset(..., 0, ...) initialisation.
9) Renamed function update_global_user_stats to update_global_stats (because not only user_stats updated, thread_stats too)
10) Avoid copy-paste between update_global_user_stats_with_user and update_global_user_stats_with_thread by single function update_stats
11) Add set_connections function (related to incomplete port from Google patch) and add call to send_user_stats and send_thread_stats (bug #728082, bug #924872). Without this call statistcs from separated thread didn't aggregated to global_[client|thread|user]_stats.
12) Add counters cleanup to sql_parse.cc: mysql_reset_thd_for_next_command (related to incompleted port from Google patch)
13) Add wild-card processing to:
  * send_user_stats
  * send_thread_stats
  * fill_schema_table_stats
  * fill_schema_index_stats
Without this changes LIKE and WHERE works incorrectly (related to incompleted port from Google patch).
14) Removed unnecessary engine_type from TABLE STATS (changes related to changes from Percona).
15) Removed unnecessary add_thead_stats / add_user_stats functions.
16) Added DBUG_ENTER/DBUG_RETURN/DBUG_VOID_RETURN information to related functions.
17) Fixed code policy / added comments to function for all related code.
18) Added EXTENDED_FOR_USERSTAT macros to storage/myisam/ha_myisam.cc

423. By Oleg Tsarev

1) I fixed test userstats_bug602047 (incorrect behavior on --repeat run).
2) I ported following tests from http://code.google.com/p/google-mysql-tools/:
  * access_denied
  * user_stats
  * show_stats
3) sql_connect.cc - added Debug Variable signal_end_connection for activate Debug Signal end_connection after connection close and before end of thread to the handle_one_connection function (required for catch closed connection).
  Alternative way - SHOW PROCESSLIST works worse: affected to collected statistics.
   Disable statistics while wait of close connection is worse too, I need catch changes in statistics related to close of connection.
4) user_stats.tests:
  - I moved all queries to check statistics to include/show_stats.inc
  - I now check all columns of statistics tables.
  - I checked SHOW *_STATISTICS and SELECT * FROM INFORMATION_SCHEMA.*_STATISTICS (originally test checked just SHOW syntax)
  - I checked WHERE and LIKE condition both on SHOW and SELECT syntax
  - I checked results on every combination - SHOW/SELECT, LIKE/WHERE
  - I added checks to THREAD_STATISTICS (this is Percona-specific extension, originally Google patch didn't have it)
  - I fixed sporadic tests fails related to thread concurrency (not completed connection) by wait Debug Signal end_connection
  - I removed sleep from test
  - I added backup of mysql.user before test run (need for correct check of test case).
The bug #924872 and bug #728082 confirmed by this tests.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'Percona-Server/mysql-test/include/show_stats.inc'
--- Percona-Server/mysql-test/include/show_stats.inc 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/include/show_stats.inc 2012-02-02 06:11:26 +0000
@@ -0,0 +1,78 @@
1--disable_query_log
2
3set global userstat_running=OFF;
4set global thread_statistics=OFF;
5
6--let found=`select count(*) from information_schema.processlist where user='$user'`
7
8if ($found)
9{
10
11--let host=`select Host from information_schema.processlist where user='$user'`
12--let thread=`select Id from information_schema.processlist where user='$user'`
13
14eval select count(*) as Host from information_schema.client_statistics where client='$host';
15eval select count(*) as Thread from information_schema.thread_statistics where thread_id='$thread';
16eval select count(*) as User from information_schema.user_statistics where user='$user';
17}
18
19# 3 - client_statistics
20# 2 - thread_statistics
21# 1 - user_statistics
22# 0 - complete loop
23
24--let i=3
25
26while($i)
27{
28
29--let client_query=show client_statistics like '$host'
30--let thread_query=show thread_statistics like '$thread'
31--let user_query=show user_statistics like '$user'
32--let show_like_query=`SELECT CASE $i WHEN 3 THEN "$client_query" WHEN 2 THEN "$thread_query" WHEN 1 THEN "$user_query" END`
33
34--let client_query=show client_statistics where Client='$host'
35--let thread_query=show thread_statistics where Thread_id='$thread'
36--let user_query=show user_statistics where User='$user'
37--let show_where_query=`SELECT CASE $i WHEN 3 THEN "$client_query" WHEN 2 THEN "$thread_query" WHEN 1 THEN "$user_query" END`
38
39--let client_query=select * from information_schema.client_statistics where Client like '$host'
40--let thread_query=select * from information_schema.thread_statistics where Thread_id like '$thread'
41--let user_query=select * from information_schema.user_statistics where User like '$user'
42--let select_like_query=`SELECT CASE $i WHEN 3 THEN "$client_query" WHEN 2 THEN "$thread_query" WHEN 1 THEN "$user_query" END`
43
44--let client_query=select * from information_schema.client_statistics where Client='$host'
45--let thread_query=select * from information_schema.thread_statistics where Thread_id='$thread'
46--let user_query=select * from information_schema.user_statistics where User='$user'
47--let select_where_query=`SELECT CASE $i WHEN 3 THEN "$client_query" WHEN 2 THEN "$thread_query" WHEN 1 THEN "$user_query" END`
48
49--let name=`SELECT CASE $i WHEN 3 THEN "Client" WHEN 2 THEN "Thread" WHEN 1 THEN "User" END`
50
51--echo #
52--echo # $name statistics
53--echo #
54
55--echo # SHOW | LIKE
56--replace_column 1 X 4 X 5 X 6 X 7 X 8 X 9 X
57eval $show_like_query;
58
59--echo # SHOW | WHERE
60--replace_column 1 X 4 X 5 X 6 X 7 X 8 X 9 X
61eval $show_where_query;
62
63--echo # SELECT | LIKE
64--replace_column 1 X 4 X 5 X 6 X 7 X 8 X 9 X
65eval $select_like_query;
66
67--echo # SELECT | WHERE
68--replace_column 1 X 4 X 5 X 6 X 7 X 8 X 9 X
69eval $select_where_query;
70
71dec $i;
72
73}
74
75set global userstat_running=ON;
76set global thread_statistics=ON;
77
78--enable_query_log
079
=== added file 'Percona-Server/mysql-test/include/show_table_index_stats.inc'
--- Percona-Server/mysql-test/include/show_table_index_stats.inc 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/include/show_table_index_stats.inc 2012-02-02 06:11:26 +0000
@@ -0,0 +1,20 @@
1if ($schema)
2{
3if ($table)
4{
5
6eval show table_statistics like '$schema.$table';
7eval show table_statistics where Table_schema='$schema' and Table_name='$table';
8eval select * from information_schema.table_statistics where Table_schema like '$schema' and Table_name like '$table';
9eval select * from information_schema.table_statistics where Table_schema='$schema' and Table_name='$table';
10
11if ($index)
12{
13eval show index_statistics like '$schema.$table.$index';
14eval show index_statistics where Table_schema='$schema' and Table_name='$table' and Index_name='$index';
15eval select * from information_schema.index_statistics where Table_schema like '$schema' and Table_name like '$table' and Index_name like '$index';
16eval select * from information_schema.index_statistics where Table_schema='$schema' and Table_name='$table' and Index_name='$index';
17}
18
19}
20}
021
=== added file 'Percona-Server/mysql-test/r/access_denied.result'
--- Percona-Server/mysql-test/r/access_denied.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/r/access_denied.result 2012-02-02 06:11:26 +0000
@@ -0,0 +1,330 @@
1create table mysql.user_bak like mysql.user;
2insert into mysql.user_bak select * from mysql.user;
3set global userstat_running=ON;
4grant create user on *.* to mysqltest_1@localhost;
5grant create user on *.* to mysqltest_2@localhost;
6drop table if exists t1;
7drop database if exists mysqltest;
8flush user_statistics;
9create database mysqltest;
10show create database mysqltest;
11Database Create Database
12mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
13create table mysqltest.t1(a int);
14create table mysqltest.empty(a int);
15insert into mysqltest.t1 values(1);
16grant select on `mysqltest`.* to mysqltest_1@localhost;
17select current_user();
18current_user()
19mysqltest_1@localhost
20select * from mysqltest.empty;
21a
22drop database mysqltest;
23ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
24create database mysqltest_db;
25ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_db'
26show create database mysqltest_db;
27ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_db'
28grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
29ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my\_1'
30grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
31ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my_%'
32show grants for root@localhost;
33ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql'
34grant select on `my\_1`.* to mysqltest_2@localhost;
35ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my\_1'
36mysqltest_1 access_denied=7
37show user_statistics like 'mysqltest_%';
38User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
39mysqltest_1 X X X X X X X X X X X X X X X X X X 7 X
40select current_user();
41current_user()
42root@localhost
43create database information_schema;
44ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
45alter database information_schema upgrade data directory name;
46ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
47drop database information_schema;
48ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
49drop table information_schema.tables;
50ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
51alter table information_schema.tables;
52ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
53revoke select on `mysqltest`.* from mysqltest_1@localhost;
54use information_schema;
55create temporary table schemata(f1 char(10));
56ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
57grant all on information_schema.* to 'user1'@'localhost';
58ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
59grant select on information_schema.* to 'user1'@'localhost';
60ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
61root access_denied=8
62show user_statistics like 'root';
63User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
64root X X X X X X X X X X X X X X X X X X 8 X
65drop user mysqltest_1@localhost;
66drop database mysqltest;
67show tables;
68Tables_in_test
69connect(localhost,root,z,test2,MASTER_PORT,MASTER_SOCKET);
70ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
71connect(localhost,root,z,test,MASTER_PORT,MASTER_SOCKET);
72ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
73root access_denied=10
74show user_statistics like 'root%';
75User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
76root 2 X X X X X X X X X X X X X X X X X 10 X
77grant ALL on *.* to test@localhost identified by "gambling";
78grant ALL on *.* to test@127.0.0.1 identified by "gambling";
79show tables;
80Tables_in_test
81connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
82ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
83connect(localhost,test,,test,MASTER_PORT,MASTER_SOCKET);
84ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
85connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
86ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
87connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
88ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
89test access_denied=4
90show user_statistics like 'test';
91User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
92test 1 X X X X X X X X X X X X X X X X X 4 X
93drop user test@localhost;
94drop user test@127.0.0.1;
95flush privileges;
96SET NAMES binary;
97create database mysqltest_1;
98create database mysqltest_2;
99create table mysqltest_1.t1 select 1 a, 2 q;
100create table mysqltest_1.t2 select 1 b, 2 r;
101create table mysqltest_2.t1 select 1 c, 2 s;
102create table mysqltest_2.t2 select 1 d, 2 t;
103grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost;
104grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost;
105grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost;
106grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost;
107SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
108WHERE GRANTEE = '''mysqltest_3''@''localhost'''
109ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE;
110GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
111'mysqltest_3'@'localhost' NULL mysqltest_1 t1 a UPDATE NO
112'mysqltest_3'@'localhost' NULL mysqltest_2 t1 c SELECT NO
113'mysqltest_3'@'localhost' NULL mysqltest_1 t2 b SELECT NO
114'mysqltest_3'@'localhost' NULL mysqltest_2 t2 d UPDATE NO
115SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES
116WHERE GRANTEE = '''mysqltest_3''@''localhost'''
117ORDER BY TABLE_NAME,PRIVILEGE_TYPE;
118GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
119SELECT * from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES
120WHERE GRANTEE = '''mysqltest_3''@''localhost'''
121ORDER BY TABLE_SCHEMA,PRIVILEGE_TYPE;
122GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
123SELECT * from INFORMATION_SCHEMA.USER_PRIVILEGES
124WHERE GRANTEE = '''mysqltest_3''@''localhost'''
125 ORDER BY TABLE_CATALOG,PRIVILEGE_TYPE;
126GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
127'mysqltest_3'@'localhost' NULL USAGE NO
128mysqltest_3 access_denied=0
129show user_statistics like 'mysqltest_3';
130User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
131mysqltest_3 X X X X X X X X X X X X X X X X X X 0 X
132update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1;
133ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for column 'q' in table 't1'
134update mysqltest_1.t2, mysqltest_2.t2 set d=20 where d=1;
135ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'd' in table 't2'
136update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1;
137ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't1'
138update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1;
139ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1'
140update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2;
141ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 's' in table 't1'
142mysqltest_3 access_denied=5
143show user_statistics like 'mysqltest_3';
144User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
145mysqltest_3 X X X X X X X X X X X X X X X X X X 5 X
146update mysqltest_1.t1, mysqltest_2.t2 set a=10,d=10;
147update mysqltest_1.t1, mysqltest_2.t1 set a=20 where c=20;
148select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
149a q b r
15010 2 1 2
151select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
152c s d t
1531 2 10 2
154revoke all on mysqltest_1.t1 from mysqltest_3@localhost;
155revoke all on mysqltest_1.t2 from mysqltest_3@localhost;
156revoke all on mysqltest_2.t1 from mysqltest_3@localhost;
157revoke all on mysqltest_2.t2 from mysqltest_3@localhost;
158grant all on mysqltest_2.* to mysqltest_3@localhost;
159grant select on *.* to mysqltest_3@localhost;
160grant select on mysqltest_2.t1 to mysqltest_3@localhost;
161flush privileges;
162use mysqltest_1;
163update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600;
164update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
165ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1'
166use mysqltest_2;
167update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
168ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1'
169update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200;
170ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't2'
171update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200;
172ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1'
173mysqltest_3 access_denied=9
174show user_statistics like 'mysqltest_3';
175User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
176mysqltest_3 2 X X X X X X X X X X X X X X X X X 9 X
177select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
178a q b r
17910 2 1 2
180select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
181c s d t
182500 2 600 2
183delete from mysql.user where user='mysqltest_3';
184delete from mysql.db where user="mysqltest_3";
185delete from mysql.tables_priv where user="mysqltest_3";
186delete from mysql.columns_priv where user="mysqltest_3";
187flush privileges;
188drop database mysqltest_1;
189drop database mysqltest_2;
190create database mysqltest_2;
191grant select, insert, update on `mysqltest\_2`.* to mysqltest_1@localhost;
192set sql_log_off = 1;
193ERROR 42000: Access denied; you need the SUPER privilege for this operation
194set sql_log_bin = 0;
195ERROR 42000: Access denied; you need the SUPER privilege for this operation
196mysqltest_2 access_denied=2
197show user_statistics like 'mysqltest_2';
198User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
199mysqltest_2 X X X X X X X X X X X X X X X X X X 2 X
200revoke select, insert, update on `mysqltest\_2`.* from mysqltest_1@localhost;
201delete from mysql.user where user like 'mysqltest\_2';
202delete from mysql.db where user like 'mysqltest\_2';
203drop database mysqltest_2;
204flush privileges;
205drop database if exists db2;
206create database db2;
207use db2;
208create table t2 (s1 int);
209insert into t2 values (0);
210grant usage on db2.* to user1@localhost;
211grant select on db2.* to user1@localhost;
212grant usage on db2.* to user2@localhost;
213grant select,insert,update,delete,create routine on db2.* to user2@localhost;
214grant create routine on db2.* to user1@localhost;
215flush privileges;
216use db2;
217create procedure p () insert into t2 values (1);
218use db2;
219call p();
220ERROR 42000: execute command denied to user 'user2'@'localhost' for routine 'db2.p'
221show user_statistics like 'user%';
222User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
223user2 X X X X X X X X X X X X X X X X X X 1 X
224user1 X X X X X X X X X X X X X X X X X X 0 X
225create procedure q () insert into t2 values (2);
226grant usage on procedure db2.q to user2@localhost with grant option;
227grant execute on procedure db2.q to user1@localhost;
228use db2;
229alter procedure p modifies sql data;
230drop procedure p;
231alter procedure q modifies sql data;
232ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db2.q'
233drop procedure q;
234ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db2.q'
235user1 access_denied=2, user2 access_denied=1
236show user_statistics like 'user%';
237User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
238user2 X X X X X X X X X X X X X X X X X X 1 X
239user1 X X X X X X X X X X X X X X X X X X 2 X
240use db2;
241alter procedure q modifies sql data;
242drop procedure q;
243revoke all on db2.* from user1@localhost;
244revoke all on db2.* from user2@localhost;
245flush privileges;
246use test;
247select type,db,name from mysql.proc;
248type db name
249PROCEDURE mtr add_suppression
250PROCEDURE mtr check_testcase
251PROCEDURE mtr check_warnings
252PROCEDURE mtr force_restart
253drop database db2;
254select type,db,name from mysql.proc;
255type db name
256PROCEDURE mtr add_suppression
257PROCEDURE mtr check_testcase
258PROCEDURE mtr check_warnings
259PROCEDURE mtr force_restart
260delete from mysql.user where user='user1' or user='user2';
261delete from mysql.user where user='' and host='%';
262delete from mysql.procs_priv where user='user1' or user='user2';
263delete from mysql.procs_priv where user='' and host='%';
264delete from mysql.db where user='user2';
265flush privileges;
266grant usage on *.* to usera@localhost;
267grant usage on *.* to userb@localhost;
268grant usage on *.* to userc@localhost;
269create database sptest;
270create table t1 ( u varchar(64), i int );
271create procedure sptest.p1(i int) insert into test.t1 values (user(), i);
272grant insert on t1 to usera@localhost;
273grant execute on procedure sptest.p1 to usera@localhost;
274show grants for usera@localhost;
275Grants for usera@localhost
276GRANT USAGE ON *.* TO 'usera'@'localhost'
277GRANT INSERT ON `test`.`t1` TO 'usera'@'localhost'
278GRANT EXECUTE ON PROCEDURE `sptest`.`p1` TO 'usera'@'localhost'
279grant execute on procedure sptest.p1 to userc@localhost with grant option;
280show grants for userc@localhost;
281Grants for userc@localhost
282GRANT USAGE ON *.* TO 'userc'@'localhost'
283GRANT EXECUTE ON PROCEDURE `sptest`.`p1` TO 'userc'@'localhost' WITH GRANT OPTION
284call sptest.p1(1);
285grant execute on procedure sptest.p1 to userb@localhost;
286ERROR 42000: grant command denied to user 'usera'@'localhost' for routine 'sptest.p1'
287drop procedure sptest.p1;
288ERROR 42000: alter routine command denied to user 'usera'@'localhost' for routine 'sptest.p1'
289usera access_denied=2
290show user_statistics like 'usera%';
291User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
292usera X X X X X X X X X X X X X X X X X X 2 X
293call sptest.p1(2);
294ERROR 42000: execute command denied to user 'userb'@'localhost' for routine 'sptest.p1'
295grant execute on procedure sptest.p1 to userb@localhost;
296ERROR 42000: execute command denied to user 'userb'@'localhost' for routine 'sptest.p1'
297drop procedure sptest.p1;
298ERROR 42000: alter routine command denied to user 'userb'@'localhost' for routine 'sptest.p1'
299userb access_denied=3
300show user_statistics like 'userb';
301User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
302userb X X X X X X X X X X X X X X X X X X 3 X
303call sptest.p1(3);
304grant execute on procedure sptest.p1 to userb@localhost;
305drop procedure sptest.p1;
306ERROR 42000: alter routine command denied to user 'userc'@'localhost' for routine 'sptest.p1'
307userc access_denied=1
308show user_statistics like 'userc';
309User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
310userc X X X X X X X X X X X X X X X X X X 1 X
311call sptest.p1(4);
312grant execute on procedure sptest.p1 to userb@localhost;
313ERROR 42000: grant command denied to user 'userb'@'localhost' for routine 'sptest.p1'
314drop procedure sptest.p1;
315ERROR 42000: alter routine command denied to user 'userb'@'localhost' for routine 'sptest.p1'
316userb access_denied=5
317show user_statistics like 'userb';
318User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
319userb X X X X X X X X X X X X X X X X X X 5 X
320use test;
321drop database sptest;
322delete from mysql.user where user='usera' or user='userb' or user='userc';
323delete from mysql.procs_priv where user='usera' or user='userb' or user='userc';
324delete from mysql.tables_priv where user='usera';
325flush privileges;
326drop table t1;
327set global userstat_running=default;
328delete from mysql.user;
329insert into mysql.user select * from mysql.user_bak;
330drop table mysql.user_bak;
0331
=== added file 'Percona-Server/mysql-test/r/show_stats.result'
--- Percona-Server/mysql-test/r/show_stats.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/r/show_stats.result 2012-02-02 06:11:26 +0000
@@ -0,0 +1,1735 @@
1drop table if exists t1;
2update mysql.db set User = 'hide' where User = '';
3create table mysql.user_bak like mysql.user;
4insert into mysql.user_bak select * from mysql.user where length(User) = 0;
5delete from mysql.user where length(User) = 0;
6flush privileges;
7SET GLOBAL DEBUG='+d,signal_end_connection';
8create table t2 (a int not null primary key, b int not null) engine=innodb;
9create table t3 (a int not null primary key, b int not null, index bx(b)) engine=myisam;
10set global userstat_running=ON;
11set global thread_statistics=ON;
12flush client_statistics;
13flush thread_statistics;
14flush user_statistics;
15Host
161
17Thread
181
19User
201
21#
22# Client statistics
23#
24# SHOW | LIKE
25Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
26X 1 1 X X X X X X 0 0 0 0 0 2 0 0 0 0 0 0
27# SHOW | WHERE
28Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
29X 1 1 X X X X X X 0 0 0 0 0 2 0 0 0 0 0 0
30# SELECT | LIKE
31CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
32X 1 1 X X X X X X 0 0 0 0 0 2 0 0 0 0 0 0
33# SELECT | WHERE
34CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
35X 1 1 X X X X X X 0 0 0 0 0 2 0 0 0 0 0 0
36#
37# Thread statistics
38#
39# SHOW | LIKE
40Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
41X 1 0 X X X X X X 0 0 0 0 0 1 0 0 0 0 0 0
42# SHOW | WHERE
43Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
44X 1 0 X X X X X X 0 0 0 0 0 1 0 0 0 0 0 0
45# SELECT | LIKE
46THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
47X 1 0 X X X X X X 0 0 0 0 0 1 0 0 0 0 0 0
48# SELECT | WHERE
49THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
50X 1 0 X X X X X X 0 0 0 0 0 1 0 0 0 0 0 0
51#
52# User statistics
53#
54# SHOW | LIKE
55User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
56X 1 1 X X X X X X 0 0 0 0 0 0 0 0 0 0 0 0
57# SHOW | WHERE
58User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
59X 1 1 X X X X X X 0 0 0 0 0 0 0 0 0 0 0 0
60# SELECT | LIKE
61USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
62X 1 1 X X X X X X 0 0 0 0 0 0 0 0 0 0 0 0
63# SELECT | WHERE
64USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
65X 1 1 X X X X X X 0 0 0 0 0 0 0 0 0 0 0 0
66flush client_statistics;
67flush thread_statistics;
68flush user_statistics;
69create table t1 (a int not null primary key, b int not null) engine=innodb;
70Host
711
72Thread
731
74User
751
76#
77# Client statistics
78#
79# SHOW | LIKE
80Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
81X 1 1 X X X X X X 0 0 0 0 1 2 0 0 0 0 0 0
82# SHOW | WHERE
83Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
84X 1 1 X X X X X X 0 0 0 0 1 2 0 0 0 0 0 0
85# SELECT | LIKE
86CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
87X 1 1 X X X X X X 0 0 0 0 1 2 0 0 0 0 0 0
88# SELECT | WHERE
89CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
90X 1 1 X X X X X X 0 0 0 0 1 2 0 0 0 0 0 0
91#
92# Thread statistics
93#
94# SHOW | LIKE
95Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
96X 1 0 X X X X X X 0 0 0 0 1 1 0 0 0 0 0 0
97# SHOW | WHERE
98Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
99X 1 0 X X X X X X 0 0 0 0 1 1 0 0 0 0 0 0
100# SELECT | LIKE
101THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
102X 1 0 X X X X X X 0 0 0 0 1 1 0 0 0 0 0 0
103# SELECT | WHERE
104THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
105X 1 0 X X X X X X 0 0 0 0 1 1 0 0 0 0 0 0
106#
107# User statistics
108#
109# SHOW | LIKE
110User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
111X 1 1 X X X X X X 0 0 0 0 1 0 0 0 0 0 0 0
112# SHOW | WHERE
113User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
114X 1 1 X X X X X X 0 0 0 0 1 0 0 0 0 0 0 0
115# SELECT | LIKE
116USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
117X 1 1 X X X X X X 0 0 0 0 1 0 0 0 0 0 0 0
118# SELECT | WHERE
119USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
120X 1 1 X X X X X X 0 0 0 0 1 0 0 0 0 0 0 0
121flush client_statistics;
122flush thread_statistics;
123flush user_statistics;
124flush table_statistics;
125flush index_statistics;
126insert into t1 values (1,1), (2,2);
127Host
1281
129Thread
1301
131User
1321
133#
134# Client statistics
135#
136# SHOW | LIKE
137Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
138X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
139# SHOW | WHERE
140Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
141X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
142# SELECT | LIKE
143CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
144X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
145# SELECT | WHERE
146CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
147X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
148#
149# Thread statistics
150#
151# SHOW | LIKE
152Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
153X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
154# SHOW | WHERE
155Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
156X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
157# SELECT | LIKE
158THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
159X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
160# SELECT | WHERE
161THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
162X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
163#
164# User statistics
165#
166# SHOW | LIKE
167User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
168X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
169# SHOW | WHERE
170User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
171X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
172# SELECT | LIKE
173USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
174X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
175# SELECT | WHERE
176USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
177X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
178show table_statistics like 'test.t1';
179Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
180test t1 0 2 2
181show table_statistics where Table_schema='test' and Table_name='t1';
182Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
183test t1 0 2 2
184select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
185TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
186test t1 0 2 2
187select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
188TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
189test t1 0 2 2
190create table test.tmy(i int) engine=myisam;
191insert into test.tmy values (1);
192show table_statistics like 'test.tmy';
193Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
194test tmy 0 1 1
195show table_statistics where Table_schema='test' and Table_name='tmy';
196Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
197test tmy 0 1 1
198select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 'tmy';
199TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
200test tmy 0 1 1
201select * from information_schema.table_statistics where Table_schema='test' and Table_name='tmy';
202TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
203test tmy 0 1 1
204drop table test.tmy;
205show table_statistics like 'test.t1';
206Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
207test t1 0 2 2
208show table_statistics where Table_schema='test' and Table_name='t1';
209Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
210test t1 0 2 2
211select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
212TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
213test t1 0 2 2
214select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
215TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
216test t1 0 2 2
217""
218Test insert select
219""
220flush client_statistics;
221flush thread_statistics;
222flush user_statistics;
223flush table_statistics;
224flush index_statistics;
225insert into t2 select * from t1;
226Host
2271
228Thread
2291
230User
2311
232#
233# Client statistics
234#
235# SHOW | LIKE
236Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
237X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
238# SHOW | WHERE
239Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
240X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
241# SELECT | LIKE
242CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
243X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
244# SELECT | WHERE
245CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
246X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
247#
248# Thread statistics
249#
250# SHOW | LIKE
251Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
252X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
253# SHOW | WHERE
254Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
255X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
256# SELECT | LIKE
257THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
258X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
259# SELECT | WHERE
260THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
261X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
262#
263# User statistics
264#
265# SHOW | LIKE
266User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
267X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
268# SHOW | WHERE
269User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
270X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
271# SELECT | LIKE
272USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
273X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
274# SELECT | WHERE
275USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
276X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
277show table_statistics like 'test.t1';
278Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
279test t1 2 0 0
280show table_statistics where Table_schema='test' and Table_name='t1';
281Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
282test t1 2 0 0
283select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
284TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
285test t1 2 0 0
286select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
287TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
288test t1 2 0 0
289show index_statistics like 'test.t1.PRIMARY';
290Table_schema Table_name Index_name Rows_read
291test t1 PRIMARY 2
292show index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
293Table_schema Table_name Index_name Rows_read
294test t1 PRIMARY 2
295select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't1' and Index_name like 'PRIMARY';
296TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
297test t1 PRIMARY 2
298select * from information_schema.index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
299TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
300test t1 PRIMARY 2
301show table_statistics like 'test.t2';
302Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
303test t2 0 2 2
304show table_statistics where Table_schema='test' and Table_name='t2';
305Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
306test t2 0 2 2
307select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't2';
308TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
309test t2 0 2 2
310select * from information_schema.table_statistics where Table_schema='test' and Table_name='t2';
311TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
312test t2 0 2 2
313""
314Test update with PK scans
315""
316insert into t1 values (0,0);
317select count(*) from t1;
318count(*)
3193
320flush client_statistics;
321flush thread_statistics;
322flush user_statistics;
323flush table_statistics;
324flush index_statistics;
325update t1 set a = 3 where a = 1;
326Host
3271
328Thread
3291
330User
3311
332#
333# Client statistics
334#
335# SHOW | LIKE
336Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
337X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
338# SHOW | WHERE
339Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
340X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
341# SELECT | LIKE
342CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
343X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
344# SELECT | WHERE
345CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
346X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
347#
348# Thread statistics
349#
350# SHOW | LIKE
351Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
352X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
353# SHOW | WHERE
354Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
355X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
356# SELECT | LIKE
357THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
358X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
359# SELECT | WHERE
360THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
361X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
362#
363# User statistics
364#
365# SHOW | LIKE
366User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
367X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
368# SHOW | WHERE
369User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
370X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
371# SELECT | LIKE
372USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
373X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
374# SELECT | WHERE
375USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
376X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
377update t1 set a = 4 where b = 2;
378Host
3791
380Thread
3811
382User
3831
384#
385# Client statistics
386#
387# SHOW | LIKE
388Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
389X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
390# SHOW | WHERE
391Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
392X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
393# SELECT | LIKE
394CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
395X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
396# SELECT | WHERE
397CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
398X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
399#
400# Thread statistics
401#
402# SHOW | LIKE
403Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
404X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
405# SHOW | WHERE
406Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
407X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
408# SELECT | LIKE
409THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
410X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
411# SELECT | WHERE
412THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
413X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
414#
415# User statistics
416#
417# SHOW | LIKE
418User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
419X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
420# SHOW | WHERE
421User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
422X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
423# SELECT | LIKE
424USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
425X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
426# SELECT | WHERE
427USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
428X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
429show table_statistics like 'test.t1';
430Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
431test t1 5 2 2
432show table_statistics where Table_schema='test' and Table_name='t1';
433Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
434test t1 5 2 2
435select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
436TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
437test t1 5 2 2
438select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
439TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
440test t1 5 2 2
441show index_statistics like 'test.t1.PRIMARY';
442Table_schema Table_name Index_name Rows_read
443test t1 PRIMARY 5
444show index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
445Table_schema Table_name Index_name Rows_read
446test t1 PRIMARY 5
447select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't1' and Index_name like 'PRIMARY';
448TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
449test t1 PRIMARY 5
450select * from information_schema.index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
451TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
452test t1 PRIMARY 5
453update t1 set a = 4 where b < 0;
454Host
4551
456Thread
4571
458User
4591
460#
461# Client statistics
462#
463# SHOW | LIKE
464Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
465X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
466# SHOW | WHERE
467Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
468X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
469# SELECT | LIKE
470CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
471X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
472# SELECT | WHERE
473CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
474X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
475#
476# Thread statistics
477#
478# SHOW | LIKE
479Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
480X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
481# SHOW | WHERE
482Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
483X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
484# SELECT | LIKE
485THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
486X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
487# SELECT | WHERE
488THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
489X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
490#
491# User statistics
492#
493# SHOW | LIKE
494User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
495X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
496# SHOW | WHERE
497User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
498X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
499# SELECT | LIKE
500USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
501X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
502# SELECT | WHERE
503USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
504X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
505""
506Test update with secondary index scans and MyISAM
507""
508insert into t3 values (0,0);
509insert into t3 values (1,1);
510insert into t3 values (2,2);
511flush client_statistics;
512flush thread_statistics;
513flush user_statistics;
514flush table_statistics;
515flush index_statistics;
516update t3 set a = 4 where b = 1;
517Host
5181
519Thread
5201
521User
5221
523#
524# Client statistics
525#
526# SHOW | LIKE
527Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
528X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
529# SHOW | WHERE
530Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
531X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
532# SELECT | LIKE
533CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
534X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
535# SELECT | WHERE
536CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
537X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
538#
539# Thread statistics
540#
541# SHOW | LIKE
542Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
543X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
544# SHOW | WHERE
545Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
546X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
547# SELECT | LIKE
548THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
549X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
550# SELECT | WHERE
551THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
552X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
553#
554# User statistics
555#
556# SHOW | LIKE
557User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
558X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
559# SHOW | WHERE
560User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
561X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
562# SELECT | LIKE
563USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
564X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
565# SELECT | WHERE
566USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
567X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
568show table_statistics like 'test.t3';
569Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
570test t3 1 1 2
571show table_statistics where Table_schema='test' and Table_name='t3';
572Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
573test t3 1 1 2
574select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't3';
575TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
576test t3 1 1 2
577select * from information_schema.table_statistics where Table_schema='test' and Table_name='t3';
578TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
579test t3 1 1 2
580show index_statistics like 'test.t3.bx';
581Table_schema Table_name Index_name Rows_read
582test t3 bx 1
583show index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
584Table_schema Table_name Index_name Rows_read
585test t3 bx 1
586select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't3' and Index_name like 'bx';
587TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
588test t3 bx 1
589select * from information_schema.index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
590TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
591test t3 bx 1
592""
593Test delete with PK scans
594""
595flush client_statistics;
596flush thread_statistics;
597flush user_statistics;
598flush table_statistics;
599flush index_statistics;
600delete from t1 where a = 3;
601Host
6021
603Thread
6041
605User
6061
607#
608# Client statistics
609#
610# SHOW | LIKE
611Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
612X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
613# SHOW | WHERE
614Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
615X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
616# SELECT | LIKE
617CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
618X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
619# SELECT | WHERE
620CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
621X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
622#
623# Thread statistics
624#
625# SHOW | LIKE
626Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
627X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
628# SHOW | WHERE
629Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
630X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
631# SELECT | LIKE
632THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
633X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
634# SELECT | WHERE
635THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
636X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
637#
638# User statistics
639#
640# SHOW | LIKE
641User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
642X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
643# SHOW | WHERE
644User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
645X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
646# SELECT | LIKE
647USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
648X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
649# SELECT | WHERE
650USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
651X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
652delete from t1 where b = 2;
653Host
6541
655Thread
6561
657User
6581
659#
660# Client statistics
661#
662# SHOW | LIKE
663Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
664X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
665# SHOW | WHERE
666Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
667X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
668# SELECT | LIKE
669CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
670X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
671# SELECT | WHERE
672CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
673X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
674#
675# Thread statistics
676#
677# SHOW | LIKE
678Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
679X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
680# SHOW | WHERE
681Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
682X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
683# SELECT | LIKE
684THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
685X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
686# SELECT | WHERE
687THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
688X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
689#
690# User statistics
691#
692# SHOW | LIKE
693User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
694X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
695# SHOW | WHERE
696User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
697X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
698# SELECT | LIKE
699USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
700X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
701# SELECT | WHERE
702USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
703X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
704show table_statistics like 'test.t1';
705Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
706test t1 3 2 2
707show table_statistics where Table_schema='test' and Table_name='t1';
708Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
709test t1 3 2 2
710select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
711TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
712test t1 3 2 2
713select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
714TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
715test t1 3 2 2
716show index_statistics like 'test.t1.PRIMARY';
717Table_schema Table_name Index_name Rows_read
718test t1 PRIMARY 3
719show index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
720Table_schema Table_name Index_name Rows_read
721test t1 PRIMARY 3
722select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't1' and Index_name like 'PRIMARY';
723TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
724test t1 PRIMARY 3
725select * from information_schema.index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
726TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
727test t1 PRIMARY 3
728delete from t1 where b < 0;
729Host
7301
731Thread
7321
733User
7341
735#
736# Client statistics
737#
738# SHOW | LIKE
739Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
740X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
741# SHOW | WHERE
742Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
743X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
744# SELECT | LIKE
745CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
746X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
747# SELECT | WHERE
748CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
749X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
750#
751# Thread statistics
752#
753# SHOW | LIKE
754Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
755X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
756# SHOW | WHERE
757Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
758X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
759# SELECT | LIKE
760THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
761X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
762# SELECT | WHERE
763THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
764X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
765#
766# User statistics
767#
768# SHOW | LIKE
769User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
770X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
771# SHOW | WHERE
772User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
773X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
774# SELECT | LIKE
775USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
776X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
777# SELECT | WHERE
778USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
779X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
780""
781Test delete with secondary index scans
782""
783flush client_statistics;
784flush thread_statistics;
785flush user_statistics;
786flush table_statistics;
787flush index_statistics;
788delete from t3 where b = 1;
789Host
7901
791Thread
7921
793User
7941
795#
796# Client statistics
797#
798# SHOW | LIKE
799Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
800X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
801# SHOW | WHERE
802Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
803X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
804# SELECT | LIKE
805CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
806X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
807# SELECT | WHERE
808CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
809X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
810#
811# Thread statistics
812#
813# SHOW | LIKE
814Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
815X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
816# SHOW | WHERE
817Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
818X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
819# SELECT | LIKE
820THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
821X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
822# SELECT | WHERE
823THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
824X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
825#
826# User statistics
827#
828# SHOW | LIKE
829User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
830X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
831# SHOW | WHERE
832User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
833X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
834# SELECT | LIKE
835USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
836X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
837# SELECT | WHERE
838USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
839X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
840show table_statistics like 'test.t3';
841Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
842test t3 1 1 2
843show table_statistics where Table_schema='test' and Table_name='t3';
844Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
845test t3 1 1 2
846select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't3';
847TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
848test t3 1 1 2
849select * from information_schema.table_statistics where Table_schema='test' and Table_name='t3';
850TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
851test t3 1 1 2
852show index_statistics like 'test.t3.bx';
853Table_schema Table_name Index_name Rows_read
854test t3 bx 1
855show index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
856Table_schema Table_name Index_name Rows_read
857test t3 bx 1
858select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't3' and Index_name like 'bx';
859TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
860test t3 bx 1
861select * from information_schema.index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
862TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
863test t3 bx 1
864delete from t3 where b < 0;
865Host
8661
867Thread
8681
869User
8701
871#
872# Client statistics
873#
874# SHOW | LIKE
875Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
876X 1 1 X X X X X X 4 1 0 4 2 10 0 0 0 0 0 0
877# SHOW | WHERE
878Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
879X 1 1 X X X X X X 4 1 0 4 2 10 0 0 0 0 0 0
880# SELECT | LIKE
881CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
882X 1 1 X X X X X X 4 1 0 4 2 10 0 0 0 0 0 0
883# SELECT | WHERE
884CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
885X 1 1 X X X X X X 4 1 0 4 2 10 0 0 0 0 0 0
886#
887# Thread statistics
888#
889# SHOW | LIKE
890Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
891X 1 0 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
892# SHOW | WHERE
893Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
894X 1 0 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
895# SELECT | LIKE
896THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
897X 1 0 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
898# SELECT | WHERE
899THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
900X 1 0 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
901#
902# User statistics
903#
904# SHOW | LIKE
905User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
906X 1 1 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
907# SHOW | WHERE
908User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
909X 1 1 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
910# SELECT | LIKE
911USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
912X 1 1 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
913# SELECT | WHERE
914USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
915X 1 1 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
916""
917Test select with PK scans
918""
919insert into t1 values (1,1), (2,2);
920flush client_statistics;
921flush thread_statistics;
922flush user_statistics;
923flush table_statistics;
924flush index_statistics;
925select count(*) from t1 where a = 1;
926count(*)
9271
928Host
9291
930Thread
9311
932User
9331
934#
935# Client statistics
936#
937# SHOW | LIKE
938Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
939X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
940# SHOW | WHERE
941Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
942X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
943# SELECT | LIKE
944CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
945X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
946# SELECT | WHERE
947CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
948X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
949#
950# Thread statistics
951#
952# SHOW | LIKE
953Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
954X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
955# SHOW | WHERE
956Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
957X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
958# SELECT | LIKE
959THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
960X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
961# SELECT | WHERE
962THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
963X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
964#
965# User statistics
966#
967# SHOW | LIKE
968User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
969X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
970# SHOW | WHERE
971User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
972X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
973# SELECT | LIKE
974USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
975X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
976# SELECT | WHERE
977USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
978X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
979select count(*) from t1 where b < 0;
980count(*)
9810
982Host
9831
984Thread
9851
986User
9871
988#
989# Client statistics
990#
991# SHOW | LIKE
992Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
993X 1 1 X X X X X X 2 0 0 2 0 6 0 0 0 0 0 0
994# SHOW | WHERE
995Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
996X 1 1 X X X X X X 2 0 0 2 0 6 0 0 0 0 0 0
997# SELECT | LIKE
998CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
999X 1 1 X X X X X X 2 0 0 2 0 6 0 0 0 0 0 0
1000# SELECT | WHERE
1001CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1002X 1 1 X X X X X X 2 0 0 2 0 6 0 0 0 0 0 0
1003#
1004# Thread statistics
1005#
1006# SHOW | LIKE
1007Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1008X 1 0 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1009# SHOW | WHERE
1010Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1011X 1 0 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1012# SELECT | LIKE
1013THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1014X 1 0 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1015# SELECT | WHERE
1016THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1017X 1 0 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1018#
1019# User statistics
1020#
1021# SHOW | LIKE
1022User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1023X 1 1 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1024# SHOW | WHERE
1025User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1026X 1 1 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1027# SELECT | LIKE
1028USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1029X 1 1 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1030# SELECT | WHERE
1031USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1032X 1 1 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1033show table_statistics like 'test.t1';
1034Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1035test t1 4 0 0
1036show table_statistics where Table_schema='test' and Table_name='t1';
1037Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1038test t1 4 0 0
1039select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
1040TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1041test t1 4 0 0
1042select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
1043TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1044test t1 4 0 0
1045show index_statistics like 'test.t1.PRIMARY';
1046Table_schema Table_name Index_name Rows_read
1047test t1 PRIMARY 4
1048show index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
1049Table_schema Table_name Index_name Rows_read
1050test t1 PRIMARY 4
1051select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't1' and Index_name like 'PRIMARY';
1052TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1053test t1 PRIMARY 4
1054select * from information_schema.index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
1055TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1056test t1 PRIMARY 4
1057""
1058Test select with secondary scans
1059""
1060insert into t3 values (1,1);
1061analyze table t3;
1062Table Op Msg_type Msg_text
1063test.t3 analyze status OK
1064explain select * from t3 where b < 0;
1065id select_type table type possible_keys key key_len ref rows Extra
10661 SIMPLE t3 range bx bx 4 NULL 1 Using where
1067flush client_statistics;
1068flush thread_statistics;
1069flush user_statistics;
1070flush table_statistics;
1071flush index_statistics;
1072select * from t3 where b = 1;
1073a b
10741 1
1075Host
10761
1077Thread
10781
1079User
10801
1081#
1082# Client statistics
1083#
1084# SHOW | LIKE
1085Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1086X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1087# SHOW | WHERE
1088Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1089X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1090# SELECT | LIKE
1091CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1092X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1093# SELECT | WHERE
1094CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1095X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1096#
1097# Thread statistics
1098#
1099# SHOW | LIKE
1100Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1101X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1102# SHOW | WHERE
1103Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1104X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1105# SELECT | LIKE
1106THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1107X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1108# SELECT | WHERE
1109THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1110X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1111#
1112# User statistics
1113#
1114# SHOW | LIKE
1115User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1116X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1117# SHOW | WHERE
1118User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1119X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1120# SELECT | LIKE
1121USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1122X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1123# SELECT | WHERE
1124USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1125X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1126select * from t3 where b < 0;
1127a b
1128Host
11291
1130Thread
11311
1132User
11331
1134#
1135# Client statistics
1136#
1137# SHOW | LIKE
1138Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1139X 1 1 X X X X X X 1 0 0 2 0 6 0 0 0 0 0 1
1140# SHOW | WHERE
1141Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1142X 1 1 X X X X X X 1 0 0 2 0 6 0 0 0 0 0 1
1143# SELECT | LIKE
1144CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1145X 1 1 X X X X X X 1 0 0 2 0 6 0 0 0 0 0 1
1146# SELECT | WHERE
1147CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1148X 1 1 X X X X X X 1 0 0 2 0 6 0 0 0 0 0 1
1149#
1150# Thread statistics
1151#
1152# SHOW | LIKE
1153Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1154X 1 0 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1155# SHOW | WHERE
1156Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1157X 1 0 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1158# SELECT | LIKE
1159THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1160X 1 0 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1161# SELECT | WHERE
1162THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1163X 1 0 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1164#
1165# User statistics
1166#
1167# SHOW | LIKE
1168User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1169X 1 1 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1170# SHOW | WHERE
1171User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1172X 1 1 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1173# SELECT | LIKE
1174USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1175X 1 1 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1176# SELECT | WHERE
1177USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1178X 1 1 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1179show table_statistics like 'test.t3';
1180Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1181test t3 2 0 0
1182show table_statistics where Table_schema='test' and Table_name='t3';
1183Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1184test t3 2 0 0
1185select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't3';
1186TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1187test t3 2 0 0
1188select * from information_schema.table_statistics where Table_schema='test' and Table_name='t3';
1189TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1190test t3 2 0 0
1191show index_statistics like 'test.t3.bx';
1192Table_schema Table_name Index_name Rows_read
1193test t3 bx 2
1194show index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
1195Table_schema Table_name Index_name Rows_read
1196test t3 bx 2
1197select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't3' and Index_name like 'bx';
1198TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1199test t3 bx 2
1200select * from information_schema.index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
1201TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1202test t3 bx 2
1203""
1204Test denied connections
1205""
1206create user foo@localhost identified by 'bar';
1207grant all on test.t1 to foo@localhost with max_user_connections 2;
1208flush client_statistics;
1209flush thread_statistics;
1210flush user_statistics;
1211select current_user();
1212current_user()
1213foo@localhost
1214Host
12151
1216Thread
12171
1218User
12191
1220#
1221# Client statistics
1222#
1223# SHOW | LIKE
1224Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1225X 2 2 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1226# SHOW | WHERE
1227Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1228X 2 2 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1229# SELECT | LIKE
1230CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1231X 2 2 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1232# SELECT | WHERE
1233CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1234X 2 2 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1235#
1236# Thread statistics
1237#
1238# SHOW | LIKE
1239Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1240X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1241# SHOW | WHERE
1242Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1243X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1244# SELECT | LIKE
1245THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1246X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1247# SELECT | WHERE
1248THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1249X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1250#
1251# User statistics
1252#
1253# SHOW | LIKE
1254User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1255X 1 1 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1256# SHOW | WHERE
1257User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1258X 1 1 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1259# SELECT | LIKE
1260USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1261X 1 1 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1262# SELECT | WHERE
1263USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1264X 1 1 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1265SET DEBUG_SYNC='now WAIT_FOR end_connection';
1266SET DEBUG_SYNC='now SIGNAL empty';
1267set global userstat_running=OFF;
1268set global userstat_running=ON;
1269#
1270# Client statistics
1271#
1272# SHOW | LIKE
1273Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1274X 2 1 X X X X X X 1 0 0 1 0 7 0 0 0 0 0 0
1275# SHOW | WHERE
1276Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1277X 2 1 X X X X X X 1 0 0 1 0 7 0 0 0 0 0 0
1278# SELECT | LIKE
1279CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1280X 2 1 X X X X X X 1 0 0 1 0 7 0 0 0 0 0 0
1281# SELECT | WHERE
1282CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1283X 2 1 X X X X X X 1 0 0 1 0 7 0 0 0 0 0 0
1284#
1285# Thread statistics
1286#
1287# SHOW | LIKE
1288Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1289X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1290# SHOW | WHERE
1291Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1292X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1293# SELECT | LIKE
1294THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1295X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1296# SELECT | WHERE
1297THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1298X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1299#
1300# User statistics
1301#
1302# SHOW | LIKE
1303User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1304X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1305# SHOW | WHERE
1306User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1307X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1308# SELECT | LIKE
1309USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1310X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1311# SELECT | WHERE
1312USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1313X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1314connect(localhost,foo,wrong,test,MASTER_PORT,MASTER_SOCKET);
1315ERROR 28000: Access denied for user 'foo'@'localhost' (using password: YES)
1316SET DEBUG_SYNC='now WAIT_FOR end_connection';
1317SET DEBUG_SYNC='now SIGNAL empty';
1318set global userstat_running=OFF;
1319set global userstat_running=ON;
1320#
1321# Client statistics
1322#
1323# SHOW | LIKE
1324Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1325X 2 1 X X X X X X 1 0 0 1 0 12 0 0 1 0 1 0
1326# SHOW | WHERE
1327Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1328X 2 1 X X X X X X 1 0 0 1 0 12 0 0 1 0 1 0
1329# SELECT | LIKE
1330CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1331X 2 1 X X X X X X 1 0 0 1 0 12 0 0 1 0 1 0
1332# SELECT | WHERE
1333CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1334X 2 1 X X X X X X 1 0 0 1 0 12 0 0 1 0 1 0
1335#
1336# Thread statistics
1337#
1338# SHOW | LIKE
1339Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1340X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1341# SHOW | WHERE
1342Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1343X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1344# SELECT | LIKE
1345THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1346X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1347# SELECT | WHERE
1348THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1349X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1350#
1351# User statistics
1352#
1353# SHOW | LIKE
1354User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1355X 1 0 X X X X X X 1 0 0 1 0 0 0 0 1 0 1 0
1356# SHOW | WHERE
1357User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1358X 1 0 X X X X X X 1 0 0 1 0 0 0 0 1 0 1 0
1359# SELECT | LIKE
1360USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1361X 1 0 X X X X X X 1 0 0 1 0 0 0 0 1 0 1 0
1362# SELECT | WHERE
1363USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1364X 1 0 X X X X X X 1 0 0 1 0 0 0 0 1 0 1 0
1365""
1366Test access denied
1367echo ""
1368flush client_statistics;
1369flush thread_statistics;
1370flush user_statistics;
1371select current_user();
1372current_user()
1373foo@localhost
1374select count(*) from t1;
1375count(*)
13763
1377select * from t3;
1378ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 't3'
1379Host
13801
1381Thread
13821
1383User
13841
1385#
1386# Client statistics
1387#
1388# SHOW | LIKE
1389Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1390X 2 2 X X X X X X 2 0 3 3 0 2 1 0 0 0 1 1
1391# SHOW | WHERE
1392Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1393X 2 2 X X X X X X 2 0 3 3 0 2 1 0 0 0 1 1
1394# SELECT | LIKE
1395CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1396X 2 2 X X X X X X 2 0 3 3 0 2 1 0 0 0 1 1
1397# SELECT | WHERE
1398CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1399X 2 2 X X X X X X 2 0 3 3 0 2 1 0 0 0 1 1
1400#
1401# Thread statistics
1402#
1403# SHOW | LIKE
1404Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1405X 1 0 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1406# SHOW | WHERE
1407Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1408X 1 0 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1409# SELECT | LIKE
1410THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1411X 1 0 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1412# SELECT | WHERE
1413THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1414X 1 0 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1415#
1416# User statistics
1417#
1418# SHOW | LIKE
1419User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1420X 1 1 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1421# SHOW | WHERE
1422User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1423X 1 1 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1424# SELECT | LIKE
1425USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1426X 1 1 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1427# SELECT | WHERE
1428USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1429X 1 1 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1430SET DEBUG_SYNC='now WAIT_FOR end_connection';
1431SET DEBUG_SYNC='now SIGNAL empty';
1432set global userstat_running=OFF;
1433set global userstat_running=ON;
1434""
1435Test rollback and commit
1436echo ""
1437set autocommit=0;
1438flush client_statistics;
1439flush thread_statistics;
1440flush user_statistics;
1441insert into t1 values (10,10);
1442commit;
1443Host
14441
1445Thread
14461
1447User
14481
1449#
1450# Client statistics
1451#
1452# SHOW | LIKE
1453Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1454X 1 1 X X X X X X 0 1 0 0 1 3 1 0 0 0 0 0
1455# SHOW | WHERE
1456Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1457X 1 1 X X X X X X 0 1 0 0 1 3 1 0 0 0 0 0
1458# SELECT | LIKE
1459CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1460X 1 1 X X X X X X 0 1 0 0 1 3 1 0 0 0 0 0
1461# SELECT | WHERE
1462CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1463X 1 1 X X X X X X 0 1 0 0 1 3 1 0 0 0 0 0
1464#
1465# Thread statistics
1466#
1467# SHOW | LIKE
1468Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1469X 1 0 X X X X X X 0 1 0 0 1 2 1 0 0 0 0 0
1470# SHOW | WHERE
1471Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1472X 1 0 X X X X X X 0 1 0 0 1 2 1 0 0 0 0 0
1473# SELECT | LIKE
1474THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1475X 1 0 X X X X X X 0 1 0 0 1 2 1 0 0 0 0 0
1476# SELECT | WHERE
1477THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1478X 1 0 X X X X X X 0 1 0 0 1 2 1 0 0 0 0 0
1479#
1480# User statistics
1481#
1482# SHOW | LIKE
1483User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1484X 1 1 X X X X X X 0 1 0 0 1 1 1 0 0 0 0 0
1485# SHOW | WHERE
1486User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1487X 1 1 X X X X X X 0 1 0 0 1 1 1 0 0 0 0 0
1488# SELECT | LIKE
1489USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1490X 1 1 X X X X X X 0 1 0 0 1 1 1 0 0 0 0 0
1491# SELECT | WHERE
1492USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1493X 1 1 X X X X X X 0 1 0 0 1 1 1 0 0 0 0 0
1494insert into t1 values (11,11);
1495rollback;
1496Host
14971
1498Thread
14991
1500User
15011
1502#
1503# Client statistics
1504#
1505# SHOW | LIKE
1506Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1507X 1 1 X X X X X X 0 2 0 0 2 6 1 1 0 0 0 0
1508# SHOW | WHERE
1509Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1510X 1 1 X X X X X X 0 2 0 0 2 6 1 1 0 0 0 0
1511# SELECT | LIKE
1512CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1513X 1 1 X X X X X X 0 2 0 0 2 6 1 1 0 0 0 0
1514# SELECT | WHERE
1515CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1516X 1 1 X X X X X X 0 2 0 0 2 6 1 1 0 0 0 0
1517#
1518# Thread statistics
1519#
1520# SHOW | LIKE
1521Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1522X 1 0 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1523# SHOW | WHERE
1524Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1525X 1 0 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1526# SELECT | LIKE
1527THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1528X 1 0 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1529# SELECT | WHERE
1530THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1531X 1 0 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1532#
1533# User statistics
1534#
1535# SHOW | LIKE
1536User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1537X 1 1 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1538# SHOW | WHERE
1539User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1540X 1 1 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1541# SELECT | LIKE
1542USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1543X 1 1 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1544# SELECT | WHERE
1545USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1546X 1 1 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1547select * from t1;
1548a b
15490 0
15501 1
15512 2
155210 10
1553""
1554Test empty queries
1555echo ""
1556flush client_statistics;
1557flush thread_statistics;
1558flush user_statistics;
1559select * from t1 where a < -1;
1560a b
1561select * from t1 where a < -3;
1562a b
1563Host
15641
1565Thread
15661
1567User
15681
1569#
1570# Client statistics
1571#
1572# SHOW | LIKE
1573Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1574X 1 1 X X X X X X 0 0 1 2 0 2 0 0 0 0 0 2
1575# SHOW | WHERE
1576Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1577X 1 1 X X X X X X 0 0 1 2 0 2 0 0 0 0 0 2
1578# SELECT | LIKE
1579CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1580X 1 1 X X X X X X 0 0 1 2 0 2 0 0 0 0 0 2
1581# SELECT | WHERE
1582CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1583X 1 1 X X X X X X 0 0 1 2 0 2 0 0 0 0 0 2
1584#
1585# Thread statistics
1586#
1587# SHOW | LIKE
1588Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1589X 1 0 X X X X X X 0 0 1 2 0 1 0 0 0 0 0 2
1590# SHOW | WHERE
1591Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1592X 1 0 X X X X X X 0 0 1 2 0 1 0 0 0 0 0 2
1593# SELECT | LIKE
1594THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1595X 1 0 X X X X X X 0 0 1 2 0 1 0 0 0 0 0 2
1596# SELECT | WHERE
1597THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1598X 1 0 X X X X X X 0 0 1 2 0 1 0 0 0 0 0 2
1599#
1600# User statistics
1601#
1602# SHOW | LIKE
1603User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1604X 1 1 X X X X X X 0 0 1 2 0 0 0 0 0 0 0 2
1605# SHOW | WHERE
1606User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1607X 1 1 X X X X X X 0 0 1 2 0 0 0 0 0 0 0 2
1608# SELECT | LIKE
1609USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1610X 1 1 X X X X X X 0 0 1 2 0 0 0 0 0 0 0 2
1611# SELECT | WHERE
1612USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1613X 1 1 X X X X X X 0 0 1 2 0 0 0 0 0 0 0 2
1614""
1615Test lost connections
1616""
1617set global wait_timeout = 1;
1618set global interactive_timeout = 1;
1619flush client_statistics;
1620flush thread_statistics;
1621flush user_statistics;
1622SET DEBUG_SYNC='now WAIT_FOR end_connection';
1623SET DEBUG_SYNC='now SIGNAL empty';
1624set global userstat_running=OFF;
1625set global userstat_running=ON;
1626Host
16271
1628Thread
16291
1630User
16311
1632#
1633# Client statistics
1634#
1635# SHOW | LIKE
1636Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1637X 2 1 X X X X X X 0 0 0 0 0 5 0 0 0 1 0 0
1638# SHOW | WHERE
1639Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1640X 2 1 X X X X X X 0 0 0 0 0 5 0 0 0 1 0 0
1641# SELECT | LIKE
1642CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1643X 2 1 X X X X X X 0 0 0 0 0 5 0 0 0 1 0 0
1644# SELECT | WHERE
1645CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1646X 2 1 X X X X X X 0 0 0 0 0 5 0 0 0 1 0 0
1647#
1648# Thread statistics
1649#
1650# SHOW | LIKE
1651Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1652X 1 0 X X X X X X 0 0 0 0 0 4 0 0 0 0 0 0
1653# SHOW | WHERE
1654Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1655X 1 0 X X X X X X 0 0 0 0 0 4 0 0 0 0 0 0
1656# SELECT | LIKE
1657THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1658X 1 0 X X X X X X 0 0 0 0 0 4 0 0 0 0 0 0
1659# SELECT | WHERE
1660THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1661X 1 0 X X X X X X 0 0 0 0 0 4 0 0 0 0 0 0
1662#
1663# User statistics
1664#
1665# SHOW | LIKE
1666User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1667X 2 1 X X X X X X 0 0 0 0 0 3 0 0 0 1 0 0
1668# SHOW | WHERE
1669User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1670X 2 1 X X X X X X 0 0 0 0 0 3 0 0 0 1 0 0
1671# SELECT | LIKE
1672USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1673X 2 1 X X X X X X 0 0 0 0 0 3 0 0 0 1 0 0
1674# SELECT | WHERE
1675USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1676X 2 1 X X X X X X 0 0 0 0 0 3 0 0 0 1 0 0
1677set global wait_timeout = DEFAULT;
1678set global interactive_timeout = DEFAULT;
1679""
1680Test non-existent users
1681echo ""
1682flush client_statistics;
1683flush thread_statistics;
1684flush user_statistics;
1685connect(localhost,userDNE,,test,MASTER_PORT,MASTER_SOCKET);
1686ERROR 28000: Access denied for user 'userDNE'@'localhost' (using password: NO)
1687SET DEBUG_SYNC='now WAIT_FOR end_connection';
1688SET DEBUG_SYNC='now SIGNAL empty';
1689set global userstat_running=OFF;
1690set global userstat_running=ON;
1691#
1692# Client statistics
1693#
1694# SHOW | LIKE
1695Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1696# SHOW | WHERE
1697Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1698# SELECT | LIKE
1699CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1700# SELECT | WHERE
1701CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1702#
1703# Thread statistics
1704#
1705# SHOW | LIKE
1706Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1707# SHOW | WHERE
1708Thread_id Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1709# SELECT | LIKE
1710THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1711# SELECT | WHERE
1712THREAD_ID TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1713#
1714# User statistics
1715#
1716# SHOW | LIKE
1717User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1718# SHOW | WHERE
1719User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1720# SELECT | LIKE
1721USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1722# SELECT | WHERE
1723USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1724drop table t1;
1725drop table t2;
1726drop table t3;
1727drop user foo@localhost;
1728update mysql.db set User='' where User='hide';
1729insert into mysql.user select * from mysql.user_bak;
1730drop table mysql.user_bak;
1731flush privileges;
1732set global userstat_running=default;
1733set global thread_statistics=default;
1734set global debug='reset';
1735set debug_sync='reset';
01736
=== added file 'Percona-Server/mysql-test/r/user_stats.result'
--- Percona-Server/mysql-test/r/user_stats.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/r/user_stats.result 2012-02-02 06:11:26 +0000
@@ -0,0 +1,90 @@
1set global userstat_running=ON;
2drop database if exists mysqltest;
3flush user_statistics;
4create database mysqltest;
5show create database mysqltest;
6Database Create Database
7mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
8create table mysqltest.t1(a int);
9create table mysqltest.empty(a int);
10insert into mysqltest.t1 values(1);
11grant select on `mysqltest`.* to mysqltest_1@localhost;
12grant usage on `mysqltest`.* to mysqltest_2@localhost;
13grant drop on `mysqltest`.* to mysqltest_3@localhost;
14grant create user on *.* to mysqltest_4@localhost;
15grant create user on *.* to mysqltest_1@localhost;
16select current_user();
17current_user()
18mysqltest_1@localhost
19select * from mysqltest.empty;
20a
21drop database mysqltest;
22ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
23create database mysqltest_db;
24ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_db'
25show user_statistics like 'mysqltest_%';
26User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
27mysqltest_1 X X X X X X X X X X X X X X X X X X 2 1
28mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
29show create database mysqltest_db;
30ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_db'
31show user_statistics like 'mysqltest_%';
32User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
33mysqltest_1 X X X X X X X X X X X X X X X X X X 3 1
34mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
35grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
36ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my\_1'
37show user_statistics like 'mysqltest_%';
38User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
39mysqltest_1 X X X X X X X X X X X X X X X X X X 4 1
40mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
41grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
42ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my_%'
43show user_statistics like 'mysqltest_%';
44User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
45mysqltest_1 X X X X X X X X X X X X X X X X X X 5 1
46mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
47show grants for root@localhost;
48ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql'
49show user_statistics like 'mysqltest_%';
50User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
51mysqltest_1 X X X X X X X X X X X X X X X X X X 6 1
52mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
53grant select on `my\_1`.* to mysqltest_2@localhost;
54ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my\_1'
55show user_statistics like 'mysqltest_%';
56User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
57mysqltest_1 X X X X X X X X X X X X X X X X X X 7 1
58mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
59select current_user();
60current_user()
61root@localhost
62create database information_schema;
63ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
64alter database information_schema upgrade data directory name;
65ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
66drop database information_schema;
67ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
68drop table information_schema.tables;
69ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
70alter table information_schema.tables;
71ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
72use information_schema;
73create temporary table schemata(f1 char(10));
74ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
75show user_statistics like 'root';
76User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
77root X X X X X X X X X X X X X X X X X X 6 0
78grant all on information_schema.* to 'user1'@'localhost';
79ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
80grant select on information_schema.* to 'user1'@'localhost';
81ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
82show user_statistics like 'root';
83User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
84root X X X X X X X X X X X X X X X X X X 8 0
85drop user mysqltest_1@localhost;
86drop user mysqltest_2@localhost;
87drop user mysqltest_3@localhost;
88drop user mysqltest_4@localhost;
89drop database mysqltest;
90set global userstat_running=default;
091
=== modified file 'Percona-Server/mysql-test/r/userstat_bug602047.result'
--- Percona-Server/mysql-test/r/userstat_bug602047.result 2011-11-24 01:59:48 +0000
+++ Percona-Server/mysql-test/r/userstat_bug602047.result 2012-02-02 06:11:26 +0000
@@ -1,6 +1,8 @@
1DROP TABLE IF EXISTS t1;1DROP TABLE IF EXISTS t1;
2SET @userstat_running_old= @@userstat_running;2SET @userstat_running_old= @@userstat_running;
3SET GLOBAL userstat_running=ON;3SET GLOBAL userstat_running=ON;
4FLUSH TABLE_STATISTICS;
5FLUSH INDEX_STATISTICS;
4CREATE TABLE t1 ( id int(10), PRIMARY KEY (id)) ENGINE=InnoDB;6CREATE TABLE t1 ( id int(10), PRIMARY KEY (id)) ENGINE=InnoDB;
5INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);7INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
6SELECT COUNT(*) FROM t1;8SELECT COUNT(*) FROM t1;
79
=== added file 'Percona-Server/mysql-test/t/access_denied.test'
--- Percona-Server/mysql-test/t/access_denied.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/t/access_denied.test 2012-02-02 06:11:26 +0000
@@ -0,0 +1,559 @@
1# Test of counter for Access_denied for "show user_statistics".
2#
3# The errors to be counted include
4# from *** include/mysqld_error.h:
5# ER_DBACCESS_DENIED_ERROR 1044
6# ER_ACCESS_DENIED_ERROR 1045
7# ER_TABLEACCESS_DENIED_ERROR 1142
8# ER_COLUMNACCESS_DENIED_ERROR 1143
9# ER_SPECIFIC_ACCESS_DENIED_ERROR 1227
10# ER_PROCACCESS_DENIED_ERROR 1370
11#
12# All test cases are gleaned from other tests,
13# specifically, for the counter Access_denied
14# Access_denied is #20 from "show user_statistics".
15# shield all other counters to make the test deterministic
16
17# Grant tests not performed with embedded server
18-- source include/not_embedded.inc
19
20create table mysql.user_bak like mysql.user;
21insert into mysql.user_bak select * from mysql.user;
22
23set global userstat_running=ON;
24grant create user on *.* to mysqltest_1@localhost;
25grant create user on *.* to mysqltest_2@localhost;
26
27connection default;
28# Cleanup
29--disable_warnings
30drop table if exists t1;
31--enable_warnings
32
33#
34# 1044
35#
36
37# Cleanup
38--disable_warnings
39drop database if exists mysqltest;
40--enable_warnings
41
42flush user_statistics;
43
44#
45# Test of access_denied
46#
47
48create database mysqltest;
49show create database mysqltest;
50create table mysqltest.t1(a int);
51create table mysqltest.empty(a int);
52insert into mysqltest.t1 values(1);
53grant select on `mysqltest`.* to mysqltest_1@localhost;
54
55# User with 1 empty query
56connection default;
57connect (user1,localhost,mysqltest_1,,);
58select current_user();
59select * from mysqltest.empty;
60
61--error 1044
62drop database mysqltest;
63
64--error 1044
65create database mysqltest_db;
66
67--error 1044
68show create database mysqltest_db;
69
70--error 1044
71grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
72
73--error 1044
74grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
75
76--error 1044
77show grants for root@localhost;
78
79--error 1044
80grant select on `my\_1`.* to mysqltest_2@localhost;
81
82connection default;
83--echo mysqltest_1 access_denied=7
84--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
85show user_statistics like 'mysqltest_%';
86
87disconnect user1;
88
89select current_user();
90
91--error 1044
92create database information_schema;
93
94--error 1044
95alter database information_schema upgrade data directory name;
96
97--error 1044
98drop database information_schema;
99
100--error 1044
101drop table information_schema.tables;
102
103--error 1044
104alter table information_schema.tables;
105
106revoke select on `mysqltest`.* from mysqltest_1@localhost;
107
108#
109# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
110#
111use information_schema;
112--error 1044
113create temporary table schemata(f1 char(10));
114
115#
116# Bug #10734 Grant of privileges other than 'select' and 'create view' should fail on schema
117#
118--error 1044
119grant all on information_schema.* to 'user1'@'localhost';
120--error 1044
121grant select on information_schema.* to 'user1'@'localhost';
122
123--echo root access_denied=8
124--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
125show user_statistics like 'root';
126
127
128drop user mysqltest_1@localhost;
129
130drop database mysqltest;
131
132#
133# ================================== end of error 1044 =========================================
134#
135
136#
137# error 1045
138#
139# This test is to check various cases of connections
140# with right and wrong password, with and without database
141# Unfortunately the check is incomplete as we can't connect without database
142
143
144connect (con1,localhost,root,,test);
145show tables;
146
147--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
148--error 1045
149connect (fail_con,localhost,root,z,test2);
150
151--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
152--error 1045
153connect (fail_con,localhost,root,z,);
154
155--echo root access_denied=10
156--replace_column 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
157show user_statistics like 'root%';
158
159grant ALL on *.* to test@localhost identified by "gambling";
160grant ALL on *.* to test@127.0.0.1 identified by "gambling";
161
162disconnect con1;
163
164# Now check this user with different databases
165connect (con4,localhost,test,gambling,test);
166show tables;
167
168--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
169--error 1045
170connect (fail_con,localhost,test,,test2);
171--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
172--error 1045
173connect (fail_con,localhost,test,,"");
174--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
175--error 1045
176connect (fail_con,localhost,test,zorro,test2);
177--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
178--error 1045
179connect (fail_con,localhost,test,zorro,);
180
181--echo test access_denied=4
182--replace_column 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
183show user_statistics like 'test';
184
185# clean up
186drop user test@localhost;
187drop user test@127.0.0.1;
188flush privileges;
189
190disconnect con4;
191
192
193#
194# ================================== end of error 1045 =========================================
195#
196
197
198#
199# error 1142 and 1143
200#
201
202connect (master,localhost,root,,);
203connection master;
204SET NAMES binary;
205
206#
207# Bug#7391: Cross-database multi-table UPDATE security problem
208#
209create database mysqltest_1;
210create database mysqltest_2;
211create table mysqltest_1.t1 select 1 a, 2 q;
212create table mysqltest_1.t2 select 1 b, 2 r;
213create table mysqltest_2.t1 select 1 c, 2 s;
214create table mysqltest_2.t2 select 1 d, 2 t;
215
216#test the column privileges
217grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost;
218grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost;
219grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost;
220grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost;
221
222connect (conn1,localhost,mysqltest_3,,);
223connection conn1;
224
225# the following four stmts generate no error messages.
226# check_access in sql_parse.cc needs !no_errors predicate
227SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
228 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
229 ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE;
230SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES
231 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
232 ORDER BY TABLE_NAME,PRIVILEGE_TYPE;
233SELECT * from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES
234 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
235 ORDER BY TABLE_SCHEMA,PRIVILEGE_TYPE;
236SELECT * from INFORMATION_SCHEMA.USER_PRIVILEGES
237 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
238 ORDER BY TABLE_CATALOG,PRIVILEGE_TYPE;
239
240connection default;
241--echo mysqltest_3 access_denied=0
242--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
243show user_statistics like 'mysqltest_3';
244
245connection conn1;
246--error 1143
247update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1;
248--error 1143
249update mysqltest_1.t2, mysqltest_2.t2 set d=20 where d=1;
250--error 1142
251update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1;
252--error 1142
253update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1;
254--error 1143
255update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2;
256
257connection default;
258--echo mysqltest_3 access_denied=5
259--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
260show user_statistics like 'mysqltest_3';
261
262connection conn1;
263
264#the following two should work
265update mysqltest_1.t1, mysqltest_2.t2 set a=10,d=10;
266update mysqltest_1.t1, mysqltest_2.t1 set a=20 where c=20;
267connection master;
268select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
269select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
270revoke all on mysqltest_1.t1 from mysqltest_3@localhost;
271revoke all on mysqltest_1.t2 from mysqltest_3@localhost;
272revoke all on mysqltest_2.t1 from mysqltest_3@localhost;
273revoke all on mysqltest_2.t2 from mysqltest_3@localhost;
274
275#test the db/table level privileges
276grant all on mysqltest_2.* to mysqltest_3@localhost;
277grant select on *.* to mysqltest_3@localhost;
278# Next grant is needed to trigger bug#7391. Do not optimize!
279grant select on mysqltest_2.t1 to mysqltest_3@localhost;
280flush privileges;
281disconnect conn1;
282connect (conn2,localhost,mysqltest_3,,);
283connection conn2;
284use mysqltest_1;
285update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600;
286# the following failed before, should fail now.
287--error 1142
288update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
289use mysqltest_2;
290#the following used to succeed, it must fail now.
291--error 1142
292update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
293--error 1142
294update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200;
295--error 1142
296update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200;
297
298connection default;
299--echo mysqltest_3 access_denied=9
300--replace_column 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
301show user_statistics like 'mysqltest_3';
302
303#lets see the result
304connection master;
305select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
306select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
307
308delete from mysql.user where user='mysqltest_3';
309delete from mysql.db where user="mysqltest_3";
310delete from mysql.tables_priv where user="mysqltest_3";
311delete from mysql.columns_priv where user="mysqltest_3";
312flush privileges;
313drop database mysqltest_1;
314drop database mysqltest_2;
315
316#
317# ================================== end of error 1142/1143 =========================================
318#
319
320
321#
322# error 1227
323#
324
325create database mysqltest_2;
326grant select, insert, update on `mysqltest\_2`.* to mysqltest_1@localhost;
327connect (con10,localhost,mysqltest_2,,);
328connection con10;
329--error 1227
330set sql_log_off = 1;
331--error 1227
332set sql_log_bin = 0;
333
334connection default;
335--echo mysqltest_2 access_denied=2
336--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
337show user_statistics like 'mysqltest_2';
338
339disconnect con10;
340connection default;
341revoke select, insert, update on `mysqltest\_2`.* from mysqltest_1@localhost;
342delete from mysql.user where user like 'mysqltest\_2';
343delete from mysql.db where user like 'mysqltest\_2';
344drop database mysqltest_2;
345flush privileges;
346
347#
348# ================================== end of error 1227 =========================================
349#
350
351#
352# error 1370
353#
354#
355# Testing SQL SECURITY of stored procedures
356#
357
358connect (con1root,localhost,root,,);
359
360#
361# BUG#2777
362#
363
364connection con1root;
365--disable_warnings
366drop database if exists db2;
367--enable_warnings
368
369create database db2;
370
371use db2;
372
373create table t2 (s1 int);
374insert into t2 values (0);
375
376grant usage on db2.* to user1@localhost;
377grant select on db2.* to user1@localhost;
378grant usage on db2.* to user2@localhost;
379grant select,insert,update,delete,create routine on db2.* to user2@localhost;
380grant create routine on db2.* to user1@localhost;
381flush privileges;
382
383connect (con2user1,localhost,user1,,);
384
385connection con2user1;
386use db2;
387
388create procedure p () insert into t2 values (1);
389
390connect (con4user2,localhost,user2,,);
391
392connection con4user2;
393use db2;
394
395# This should not work, since p is executed with definer's (user1's) rights.
396--error 1370
397call p();
398
399connection default;
400# user1 access_denied=0, user2 access_denied=1
401--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
402show user_statistics like 'user%';
403
404connection con4user2;
405create procedure q () insert into t2 values (2);
406
407connection con1root;
408grant usage on procedure db2.q to user2@localhost with grant option;
409
410connection con4user2;
411grant execute on procedure db2.q to user1@localhost;
412
413# still connection con2user1 in db2
414connection con2user1;
415use db2;
416
417# This should work:
418alter procedure p modifies sql data;
419drop procedure p;
420
421# This should NOT work
422--error 1370
423alter procedure q modifies sql data;
424--error 1370
425drop procedure q;
426
427connection default;
428--echo user1 access_denied=2, user2 access_denied=1
429--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
430show user_statistics like 'user%';
431
432connection con1root;
433use db2;
434# But root always can
435alter procedure q modifies sql data;
436drop procedure q;
437
438
439# Clean up
440#Still connection con1root;
441
442revoke all on db2.* from user1@localhost;
443revoke all on db2.* from user2@localhost;
444
445flush privileges;
446
447disconnect con2user1;
448
449disconnect con4user2;
450use test;
451select type,db,name from mysql.proc;
452
453
454drop database db2;
455
456# Make sure the routines are gone
457select type,db,name from mysql.proc;
458# Get rid of the users
459delete from mysql.user where user='user1' or user='user2';
460delete from mysql.user where user='' and host='%';
461# And any routine privileges
462delete from mysql.procs_priv where user='user1' or user='user2';
463# Delete the grants to user ''@'%' that was created above
464delete from mysql.procs_priv where user='' and host='%';
465delete from mysql.db where user='user2';
466flush privileges;
467
468#
469# Test the new security acls
470#
471grant usage on *.* to usera@localhost;
472grant usage on *.* to userb@localhost;
473grant usage on *.* to userc@localhost;
474create database sptest;
475create table t1 ( u varchar(64), i int );
476create procedure sptest.p1(i int) insert into test.t1 values (user(), i);
477grant insert on t1 to usera@localhost;
478grant execute on procedure sptest.p1 to usera@localhost;
479show grants for usera@localhost;
480grant execute on procedure sptest.p1 to userc@localhost with grant option;
481show grants for userc@localhost;
482
483connect (con2usera,localhost,usera,,);
484connect (con3userb,localhost,userb,,);
485connect (con4userc,localhost,userc,,);
486
487connection con2usera;
488call sptest.p1(1);
489--error 1370
490grant execute on procedure sptest.p1 to userb@localhost;
491
492--error 1370
493drop procedure sptest.p1;
494
495connection default;
496--echo usera access_denied=2
497--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
498show user_statistics like 'usera%';
499
500connection con3userb;
501--error 1370
502call sptest.p1(2);
503--error 1370
504grant execute on procedure sptest.p1 to userb@localhost;
505--error 1370
506drop procedure sptest.p1;
507
508connection default;
509--echo userb access_denied=3
510--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
511show user_statistics like 'userb';
512
513
514connection con4userc;
515call sptest.p1(3);
516grant execute on procedure sptest.p1 to userb@localhost;
517--error 1370
518drop procedure sptest.p1;
519
520connection default;
521--echo userc access_denied=1
522--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
523show user_statistics like 'userc';
524
525connection con3userb;
526call sptest.p1(4);
527--error 1370
528grant execute on procedure sptest.p1 to userb@localhost;
529--error 1370
530drop procedure sptest.p1;
531
532connection default;
533--echo userb access_denied=5
534--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X 21 X
535show user_statistics like 'userb';
536
537connection con1root;
538
539#cleanup
540disconnect con4userc;
541disconnect con3userb;
542disconnect con2usera;
543use test;
544drop database sptest;
545delete from mysql.user where user='usera' or user='userb' or user='userc';
546delete from mysql.procs_priv where user='usera' or user='userb' or user='userc';
547delete from mysql.tables_priv where user='usera';
548flush privileges;
549drop table t1;
550set global userstat_running=default;
551
552delete from mysql.user;
553insert into mysql.user select * from mysql.user_bak;
554drop table mysql.user_bak;
555
556#
557# ================================== end of error 1370 =========================================
558#
559
0560
=== added file 'Percona-Server/mysql-test/t/show_stats.test'
--- Percona-Server/mysql-test/t/show_stats.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/t/show_stats.test 2012-02-02 06:11:26 +0000
@@ -0,0 +1,484 @@
1# Uses GRANT commands that usually disabled in embedded server
2--source include/not_embedded.inc
3--source include/have_innodb.inc
4--source include/have_debug.inc
5--let wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST
6--disable_warnings
7drop table if exists t1;
8
9update mysql.db set User = 'hide' where User = '';
10create table mysql.user_bak like mysql.user;
11insert into mysql.user_bak select * from mysql.user where length(User) = 0;
12delete from mysql.user where length(User) = 0;
13flush privileges;
14
15--enable_warnings
16
17SET GLOBAL DEBUG='+d,signal_end_connection';
18
19create table t2 (a int not null primary key, b int not null) engine=innodb;
20create table t3 (a int not null primary key, b int not null, index bx(b)) engine=myisam;
21
22set global userstat_running=ON;
23set global thread_statistics=ON;
24
25flush client_statistics;
26flush thread_statistics;
27flush user_statistics;
28
29--let user=root
30--source include/show_stats.inc
31
32flush client_statistics;
33flush thread_statistics;
34flush user_statistics;
35
36create table t1 (a int not null primary key, b int not null) engine=innodb;
37
38--let user=root
39--source include/show_stats.inc
40
41flush client_statistics;
42flush thread_statistics;
43flush user_statistics;
44
45flush table_statistics;
46flush index_statistics;
47
48insert into t1 values (1,1), (2,2);
49
50--let user=root
51--source include/show_stats.inc
52
53--let schema=test
54--let table=t1
55--let index=
56--source include/show_table_index_stats.inc
57
58create table test.tmy(i int) engine=myisam;
59insert into test.tmy values (1);
60
61--let schema=test
62--let table=tmy
63--let index=
64--source include/show_table_index_stats.inc
65
66drop table test.tmy;
67
68--let schema=test
69--let table=t1
70--let index=
71--source include/show_table_index_stats.inc
72
73# Test insert select
74
75echo "";
76echo Test insert select;
77echo "";
78
79flush client_statistics;
80flush thread_statistics;
81flush user_statistics;
82
83flush table_statistics;
84flush index_statistics;
85
86insert into t2 select * from t1;
87
88--let user=root
89--source include/show_stats.inc
90
91--let schema=test
92--let table=t1
93--let index=PRIMARY
94--source include/show_table_index_stats.inc
95
96--let schema=test
97--let table=t2
98--let index=
99--source include/show_table_index_stats.inc
100
101# Test update with PK scans
102
103echo "";
104echo Test update with PK scans;
105echo "";
106
107insert into t1 values (0,0);
108select count(*) from t1;
109
110flush client_statistics;
111flush thread_statistics;
112flush user_statistics;
113
114flush table_statistics;
115flush index_statistics;
116
117update t1 set a = 3 where a = 1;
118
119--let user=root
120--source include/show_stats.inc
121
122update t1 set a = 4 where b = 2;
123
124--let user=root
125--source include/show_stats.inc
126
127--let schema=test
128--let table=t1
129--let index=PRIMARY
130--source include/show_table_index_stats.inc
131
132update t1 set a = 4 where b < 0;
133
134--let user=root
135--source include/show_stats.inc
136
137# Test update with secondary index scans and MyISAM
138
139echo "";
140echo Test update with secondary index scans and MyISAM;
141echo "";
142
143insert into t3 values (0,0);
144insert into t3 values (1,1);
145insert into t3 values (2,2);
146
147flush client_statistics;
148flush thread_statistics;
149flush user_statistics;
150
151flush table_statistics;
152flush index_statistics;
153
154update t3 set a = 4 where b = 1;
155
156--let user=root
157--source include/show_stats.inc
158
159--let schema=test
160--let table=t3
161--let index=bx
162--source include/show_table_index_stats.inc
163
164# Test delete with PK scans
165
166echo "";
167echo Test delete with PK scans;
168echo "";
169
170flush client_statistics;
171flush thread_statistics;
172flush user_statistics;
173
174flush table_statistics;
175flush index_statistics;
176
177delete from t1 where a = 3;
178
179--let user=root
180--source include/show_stats.inc
181
182delete from t1 where b = 2;
183
184--let user=root
185--source include/show_stats.inc
186
187--let schema=test
188--let table=t1
189--let index=PRIMARY
190--source include/show_table_index_stats.inc
191
192delete from t1 where b < 0;
193
194--let user=root
195--source include/show_stats.inc
196
197# Test delete with secondary index scans
198
199echo "";
200echo Test delete with secondary index scans;
201echo "";
202
203flush client_statistics;
204flush thread_statistics;
205flush user_statistics;
206
207flush table_statistics;
208flush index_statistics;
209
210delete from t3 where b = 1;
211
212--let user=root
213--source include/show_stats.inc
214
215--let schema=test
216--let table=t3
217--let index=bx
218--source include/show_table_index_stats.inc
219
220delete from t3 where b < 0;
221
222--let user=root
223--source include/show_stats.inc
224
225# Test select on PK index
226
227echo "";
228echo Test select with PK scans;
229echo "";
230
231insert into t1 values (1,1), (2,2);
232
233flush client_statistics;
234flush thread_statistics;
235flush user_statistics;
236
237flush table_statistics;
238flush index_statistics;
239
240select count(*) from t1 where a = 1;
241
242--let user=root
243--source include/show_stats.inc
244
245select count(*) from t1 where b < 0;
246
247--let user=root
248--source include/show_stats.inc
249
250--let schema=test
251--let table=t1
252--let index=PRIMARY
253--source include/show_table_index_stats.inc
254
255# Test select on secondary index
256
257echo "";
258echo Test select with secondary scans;
259echo "";
260
261insert into t3 values (1,1);
262analyze table t3;
263explain select * from t3 where b < 0;
264
265flush client_statistics;
266flush thread_statistics;
267flush user_statistics;
268
269flush table_statistics;
270flush index_statistics;
271
272select * from t3 where b = 1;
273
274--let user=root
275--source include/show_stats.inc
276
277select * from t3 where b < 0;
278
279--let user=root
280--source include/show_stats.inc
281
282--let schema=test
283--let table=t3
284--let index=bx
285--source include/show_table_index_stats.inc
286
287#
288# Test denied connections
289#
290
291echo "";
292echo Test denied connections;
293echo "";
294
295# user level connection limit to force denied connections.
296create user foo@localhost identified by 'bar';
297grant all on test.t1 to foo@localhost with max_user_connections 2;
298
299flush client_statistics;
300flush thread_statistics;
301flush user_statistics;
302
303connect (foo0, localhost, foo, bar,,);
304select current_user();
305
306connection default;
307
308--let user=foo
309--source include/show_stats.inc
310
311disconnect foo0;
312SET DEBUG_SYNC='now WAIT_FOR end_connection';
313SET DEBUG_SYNC='now SIGNAL empty';
314set global userstat_running=OFF;
315--source include/wait_condition.inc
316set global userstat_running=ON;
317
318--let user=foo
319--source include/show_stats.inc
320
321--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
322--error 1045
323connect (foo0, localhost, foo, wrong,,);
324
325connection default;
326SET DEBUG_SYNC='now WAIT_FOR end_connection';
327SET DEBUG_SYNC='now SIGNAL empty';
328set global userstat_running=OFF;
329--source include/wait_condition.inc
330set global userstat_running=ON;
331
332--let user=foo
333--source include/show_stats.inc
334
335# Test access denied
336
337echo "";
338echo Test access denied
339echo "";
340
341flush client_statistics;
342flush thread_statistics;
343flush user_statistics;
344
345connect (foo0, localhost, foo, bar,,);
346select current_user();
347
348select count(*) from t1;
349--error 1142
350select * from t3;
351
352connection default;
353
354--let user=foo
355--source include/show_stats.inc
356
357# TODO(mcallaghan): this is a bug
358#let $val=query_get_value(show user_statistics like 'foo', Access_denied, 1);
359#echo Access_denied should be 1 and is $val;
360
361disconnect foo0;
362SET DEBUG_SYNC='now WAIT_FOR end_connection';
363SET DEBUG_SYNC='now SIGNAL empty';
364set global userstat_running=OFF;
365--source include/wait_condition.inc
366set global userstat_running=ON;
367
368# Test rollback and commit
369
370echo "";
371echo Test rollback and commit
372echo "";
373
374set autocommit=0;
375flush client_statistics;
376flush thread_statistics;
377flush user_statistics;
378
379insert into t1 values (10,10);
380commit;
381
382--let user=root
383--source include/show_stats.inc
384
385insert into t1 values (11,11);
386rollback;
387
388--let user=root
389--source include/show_stats.inc
390
391select * from t1;
392
393# Test empty queries
394
395echo "";
396echo Test empty queries
397echo "";
398
399flush client_statistics;
400flush thread_statistics;
401flush user_statistics;
402
403select * from t1 where a < -1;
404select * from t1 where a < -3;
405
406--let user=root
407--source include/show_stats.inc
408
409#
410# Test lost connections
411#
412
413echo "";
414echo Test lost connections;
415echo "";
416
417set global wait_timeout = 1;
418set global interactive_timeout = 1;
419
420flush client_statistics;
421flush thread_statistics;
422flush user_statistics;
423
424# this connection will get timed out and aborted.
425connect (abortconn, localhost, root,,,);
426
427connection default;
428SET DEBUG_SYNC='now WAIT_FOR end_connection';
429SET DEBUG_SYNC='now SIGNAL empty';
430set global userstat_running=OFF;
431--source include/wait_condition.inc
432set global userstat_running=ON;
433
434--let user=root
435--source include/show_stats.inc
436
437set global wait_timeout = DEFAULT;
438set global interactive_timeout = DEFAULT;
439
440#
441# Test non-existent users
442#
443
444echo "";
445echo Test non-existent users
446echo "";
447
448flush client_statistics;
449flush thread_statistics;
450flush user_statistics;
451
452--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
453--error 1045
454connect (userDNE, localhost, userDNE,,,);
455
456connection default;
457SET DEBUG_SYNC='now WAIT_FOR end_connection';
458SET DEBUG_SYNC='now SIGNAL empty';
459set global userstat_running=OFF;
460--source include/wait_condition.inc
461set global userstat_running=ON;
462
463# userDNE should not exist in the output.
464--let user=userDNE
465--let host=hostDNE
466--let thread=`select max(Id)+1 from information_schema.processlist`
467--source include/show_stats.inc
468
469# Cleanup
470
471drop table t1;
472drop table t2;
473drop table t3;
474drop user foo@localhost;
475
476update mysql.db set User='' where User='hide';
477insert into mysql.user select * from mysql.user_bak;
478drop table mysql.user_bak;
479flush privileges;
480
481set global userstat_running=default;
482set global thread_statistics=default;
483set global debug='reset';
484set debug_sync='reset';
0485
=== added file 'Percona-Server/mysql-test/t/user_stats.test'
--- Percona-Server/mysql-test/t/user_stats.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/t/user_stats.test 2012-02-02 06:11:26 +0000
@@ -0,0 +1,135 @@
1# Uses GRANT commands that usually disabled in embedded server
2-- source include/not_embedded.inc
3-- source include/have_innodb.inc
4
5set global userstat_running=ON;
6
7# Cleanup
8--disable_warnings
9drop database if exists mysqltest;
10--enable_warnings
11
12flush user_statistics;
13
14#
15# Test of access_denied
16#
17
18create database mysqltest;
19show create database mysqltest;
20create table mysqltest.t1(a int);
21create table mysqltest.empty(a int);
22insert into mysqltest.t1 values(1);
23grant select on `mysqltest`.* to mysqltest_1@localhost;
24grant usage on `mysqltest`.* to mysqltest_2@localhost;
25grant drop on `mysqltest`.* to mysqltest_3@localhost;
26
27# User with 0 empty queries
28grant create user on *.* to mysqltest_4@localhost;
29connect (user4,localhost,mysqltest_4,,);
30
31# User with 1 empty query
32connection default;
33grant create user on *.* to mysqltest_1@localhost;
34connect (user1,localhost,mysqltest_1,,);
35select current_user();
36select * from mysqltest.empty;
37
38--error 1044
39drop database mysqltest;
40
41--error 1044
42create database mysqltest_db;
43
44connection default;
45--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X
46show user_statistics like 'mysqltest_%';
47
48connection user1;
49--error 1044
50show create database mysqltest_db;
51
52connection default;
53--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X
54show user_statistics like 'mysqltest_%';
55connection user1;
56
57--error 1044
58grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
59
60connection default;
61--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X
62show user_statistics like 'mysqltest_%';
63connection user1;
64
65--error 1044
66grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
67
68connection default;
69--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X
70show user_statistics like 'mysqltest_%';
71connection user1;
72
73--error 1044
74show grants for root@localhost;
75
76connection default;
77--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X
78show user_statistics like 'mysqltest_%';
79connection user1;
80
81--error 1044
82grant select on `my\_1`.* to mysqltest_2@localhost;
83connection default;
84--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X
85show user_statistics like 'mysqltest_%';
86
87connection default;
88disconnect user4;
89disconnect user1;
90
91select current_user();
92
93--error 1044
94create database information_schema;
95
96--error 1044
97alter database information_schema upgrade data directory name;
98
99--error 1044
100drop database information_schema;
101
102--error 1044
103drop table information_schema.tables;
104
105--error 1044
106alter table information_schema.tables;
107
108#
109# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
110#
111use information_schema;
112--error 1044
113create temporary table schemata(f1 char(10));
114
115--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X
116show user_statistics like 'root';
117
118#
119# Bug #10734 Grant of privileges other than 'select' and 'create view' should fail on schema
120#
121--error 1044
122grant all on information_schema.* to 'user1'@'localhost';
123--error 1044
124grant select on information_schema.* to 'user1'@'localhost';
125
126--replace_column 2 X 3 X 4 X 5 X 6 X 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 15 X 16 X 17 X 18 X 19 X
127show user_statistics like 'root';
128
129
130drop user mysqltest_1@localhost;
131drop user mysqltest_2@localhost;
132drop user mysqltest_3@localhost;
133drop user mysqltest_4@localhost;
134drop database mysqltest;
135set global userstat_running=default;
0136
=== modified file 'Percona-Server/mysql-test/t/userstat_bug602047.test'
--- Percona-Server/mysql-test/t/userstat_bug602047.test 2011-11-24 01:59:48 +0000
+++ Percona-Server/mysql-test/t/userstat_bug602047.test 2012-02-02 06:11:26 +0000
@@ -4,6 +4,8 @@
4--enable_warnings4--enable_warnings
5SET @userstat_running_old= @@userstat_running;5SET @userstat_running_old= @@userstat_running;
6SET GLOBAL userstat_running=ON;6SET GLOBAL userstat_running=ON;
7FLUSH TABLE_STATISTICS;
8FLUSH INDEX_STATISTICS;
7CREATE TABLE t1 ( id int(10), PRIMARY KEY (id)) ENGINE=InnoDB;9CREATE TABLE t1 ( id int(10), PRIMARY KEY (id)) ENGINE=InnoDB;
8INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);10INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
9SELECT COUNT(*) FROM t1; 11SELECT COUNT(*) FROM t1;
1012
=== modified file 'Percona-Server/sql/handler.cc'
--- Percona-Server/sql/handler.cc 2011-11-24 16:33:30 +0000
+++ Percona-Server/sql/handler.cc 2012-02-02 06:11:26 +0000
@@ -1199,7 +1199,7 @@
1199 }1199 }
1200 DBUG_EXECUTE_IF("crash_commit_after", DBUG_SUICIDE(););1200 DBUG_EXECUTE_IF("crash_commit_after", DBUG_SUICIDE(););
1201 if (is_real_trans)1201 if (is_real_trans)
1202 thd->diff_commit_trans++;1202 thd->diff_stats.commit_trans++;
1203end:1203end:
1204 if (rw_trans)1204 if (rw_trans)
1205 start_waiting_global_read_lock(thd);1205 start_waiting_global_read_lock(thd);
@@ -1331,7 +1331,7 @@
1331 if (is_real_trans)1331 if (is_real_trans)
1332 thd->transaction.cleanup();1332 thd->transaction.cleanup();
13331333
1334 thd->diff_rollback_trans++;1334 thd->diff_stats.rollback_trans++;
1335#endif /* USING_TRANSACTIONS */1335#endif /* USING_TRANSACTIONS */
1336 if (all)1336 if (all)
1337 thd->transaction_rollback_request= FALSE;1337 thd->transaction_rollback_request= FALSE;
@@ -1771,7 +1771,7 @@
1771 ha_info->reset(); /* keep it conveniently zero-filled */1771 ha_info->reset(); /* keep it conveniently zero-filled */
1772 }1772 }
1773 trans->ha_list= sv->ha_list;1773 trans->ha_list= sv->ha_list;
1774 thd->diff_rollback_trans++;1774 thd->diff_stats.rollback_trans++;
1775 DBUG_RETURN(error);1775 DBUG_RETURN(error);
1776}1776}
17771777
@@ -3610,110 +3610,158 @@
3610 return;3610 return;
3611}3611}
36123612
3613// Updates the global table stats with the TABLE this handler represents.3613/**
3614void handler::update_global_table_stats() {3614 Updates the global table stats with the TABLE this handler represents.
3615 if (!opt_userstat_running) {3615*/
3616 rows_read = rows_changed = 0;3616void handler::update_global_table_stats()
3617 return;3617{
3618 }3618 DBUG_ENTER("handler::update_global_table_stats");
36193619
3620 if (!rows_read && !rows_changed) return; // Nothing to update.3620 if (!opt_userstat_running)
3621 // table_cache_key is db_name + '\0' + table_name + '\0'.3621 {
3622 if (!table->s || !table->s->table_cache_key.str || !table->s->table_name.str) return;3622 rows_read= 0;
3623 rows_changed= 0;
3624 DBUG_VOID_RETURN;
3625 }
3626
3627 if (!rows_read && !rows_changed)
3628 {
3629 /* Noting to update */
3630 DBUG_VOID_RETURN;
3631 }
3632
3633 /* table_cache_key is db_name + '\0' + table_name + '\0' */
3634 if (!table->s ||
3635 !table->s->table_cache_key.str ||
3636 !table->s->table_name.str)
3637 {
3638 /* Noting to update */
3639 DBUG_VOID_RETURN;
3640 }
36233641
3624 TABLE_STATS* table_stats;3642 TABLE_STATS* table_stats;
3625 char key[NAME_LEN * 2 + 2];3643 char key[NAME_LEN*2 + 2];
3626 // [db] + '.' + [table]3644 /* [db] + '.' + [table] */
3627 sprintf(key, "%s.%s", table->s->table_cache_key.str, table->s->table_name.str);3645 sprintf(key, "%s.%s",
3646 table->s->table_cache_key.str,
3647 table->s->table_name.str);
36283648
3629 pthread_mutex_lock(&LOCK_global_table_stats);3649 pthread_mutex_lock(&LOCK_global_table_stats);
3630 // Gets the global table stats, creating one if necessary.3650 /* Gets the global table stats, creating one if necessary. */
3631 if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,3651 if (!(table_stats= (TABLE_STATS *)hash_search(&global_table_stats,
3632 (uchar*)key,3652 (uchar*)key,
3633 strlen(key)))) {3653 strlen(key))))
3634 if (!(table_stats = ((TABLE_STATS*)3654 {
3635 my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {3655 if (!(table_stats= (TABLE_STATS *)my_malloc(sizeof(TABLE_STATS),
3636 // Out of memory.3656 MYF(MY_WME | MY_ZEROFILL))))
3657 {
3658 /* Out of memory. */
3637 sql_print_error("Allocating table stats failed.");3659 sql_print_error("Allocating table stats failed.");
3638 goto end;3660 goto end;
3639 }3661 }
3640 strncpy(table_stats->table, key, sizeof(table_stats->table));3662 strncpy(table_stats->table, key, sizeof(table_stats->table));
3641 table_stats->rows_read = 0;3663 table_stats->rows_read= 0;
3642 table_stats->rows_changed = 0;3664 table_stats->rows_changed= 0;
3643 table_stats->rows_changed_x_indexes = 0;3665 table_stats->rows_changed_x_indexes= 0;
3644 table_stats->engine_type = (int) ht->db_type;
36453666
3646 if (my_hash_insert(&global_table_stats, (uchar*)table_stats)) {3667 if (my_hash_insert(&global_table_stats, (uchar*)table_stats)) {
3647 // Out of memory.3668 /* Out of memory. */
3648 sql_print_error("Inserting table stats failed.");3669 sql_print_error("Inserting table stats failed.");
3649 my_free((char*)table_stats, 0);3670 my_free((char*)table_stats, 0);
3650 goto end;3671 goto end;
3651 }3672 }
3652 }3673 }
3653 // Updates the global table stats.3674 /* Updates the current thread stats. */
3654 table_stats->rows_read += rows_read;3675 current_thd->diff_stats.rows_read+= rows_read;
3655 table_stats->rows_changed += rows_changed;3676 /* Updates the global table stats. */
3656 table_stats->rows_changed_x_indexes +=3677 table_stats->rows_read+= rows_read;
3657 rows_changed * (table->s->keys ? table->s->keys : 1);3678 table_stats->rows_changed+= rows_changed;
3658 current_thd->diff_total_read_rows += rows_read;3679 table_stats->rows_changed_x_indexes+=
3659 rows_read = rows_changed = 0;3680 rows_changed * (table->s->keys ? table->s->keys : 1);
3681 /* Reset handler stats */
3682 rows_read= 0;
3683 rows_changed= 0;
3660end:3684end:
3661 pthread_mutex_unlock(&LOCK_global_table_stats);3685 pthread_mutex_unlock(&LOCK_global_table_stats);
3686 DBUG_VOID_RETURN;
3662}3687}
36633688
3664// Updates the global index stats with this handler's accumulated index reads.3689/**
3665void handler::update_global_index_stats() {3690 Updates the global index stats with this handler's accumulated index reads.
3666 // table_cache_key is db_name + '\0' + table_name + '\0'.3691*/
3667 if (!table->s || !table->s->table_cache_key.str || !table->s->table_name.str) return;3692void handler::update_global_index_stats()
36683693{
3669 if (!opt_userstat_running) {3694 DBUG_ENTER("handler::update_global_index_stats");
3670 for (uint x = 0; x < table->s->keys; x++) {3695
3671 index_rows_read[x] = 0;3696 /* table_cache_key is db_name + '\0' + table_name + '\0'. */
3697 if (!table->s ||
3698 !table->s->table_cache_key.str ||
3699 !table->s->table_name.str)
3700 {
3701 DBUG_VOID_RETURN;
3702 }
3703
3704 if (!opt_userstat_running)
3705 {
3706 for (uint x= 0; x < table->s->keys; x++)
3707 {
3708 index_rows_read[x]= 0;
3672 }3709 }
3673 return;3710 DBUG_VOID_RETURN;
3674 }3711 }
36753712
3676 for (uint x = 0; x < table->s->keys; x++) {3713 for (uint x= 0; x < table->s->keys; x++)
3677 if (index_rows_read[x]) {3714 {
3678 // Rows were read using this index.3715 if (index_rows_read[x])
3679 KEY* key_info = &table->key_info[x];3716 {
3717 /* Rows were read using this index. */
3718 KEY* key_info= &table->key_info[x];
36803719
3681 if (!key_info->name) continue;3720 if (!key_info->name)
3721 {
3722 continue;
3723 }
36823724
3683 INDEX_STATS* index_stats;3725 INDEX_STATS* index_stats;
3684 char key[NAME_LEN * 3 + 3];3726 char key[NAME_LEN * 3 + 3];
3685 // [db] + '.' + [table] + '.' + [index]3727 /* [db] + '.' + [table] + '.' + [index] */
3686 sprintf(key, "%s.%s.%s", table->s->table_cache_key.str,3728 sprintf(key, "%s.%s.%s",
3687 table->s->table_name.str, key_info->name);3729 table->s->table_cache_key.str,
3730 table->s->table_name.str,
3731 key_info->name);
36883732
3689 pthread_mutex_lock(&LOCK_global_index_stats);3733 pthread_mutex_lock(&LOCK_global_index_stats);
3690 // Gets the global index stats, creating one if necessary.3734 /* Gets the global index stats, creating one if necessary. */
3691 if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,3735 if (!(index_stats= (INDEX_STATS *)hash_search(&global_index_stats,
3692 (uchar*)key,3736 (uchar*)key,
3693 strlen(key)))) {3737 strlen(key))))
3694 if (!(index_stats = ((INDEX_STATS*)3738 {
3695 my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {3739 if (!(index_stats= (INDEX_STATS *)my_malloc(sizeof(INDEX_STATS),
3696 // Out of memory.3740 MYF(MY_WME | MY_ZEROFILL))))
3741 {
3742 /* Out of memory. */
3697 sql_print_error("Allocating index stats failed.");3743 sql_print_error("Allocating index stats failed.");
3698 goto end;3744 goto end;
3699 }3745 }
3700 strncpy(index_stats->index, key, sizeof(index_stats->index));3746 strncpy(index_stats->index, key, sizeof(index_stats->index));
3701 index_stats->rows_read = 0;3747 index_stats->rows_read= 0;
37023748
3703 if (my_hash_insert(&global_index_stats, (uchar*)index_stats)) {3749 if (my_hash_insert(&global_index_stats, (uchar*)index_stats))
3704 // Out of memory.3750 {
3751 /* Out of memory. */
3705 sql_print_error("Inserting index stats failed.");3752 sql_print_error("Inserting index stats failed.");
3706 my_free((char*)index_stats, 0);3753 my_free((char*)index_stats, 0);
3707 goto end;3754 goto end;
3708 }3755 }
3709 }3756 }
3710 // Updates the global index stats.3757 /* Updates the global index stats. */
3711 index_stats->rows_read += index_rows_read[x];3758 index_stats->rows_read+= index_rows_read[x];
3712 index_rows_read[x] = 0;3759 index_rows_read[x]= 0;
3713end:3760 end:
3714 pthread_mutex_unlock(&LOCK_global_index_stats);3761 pthread_mutex_unlock(&LOCK_global_index_stats);
3715 }3762 }
3716 }3763 }
3764 DBUG_VOID_RETURN;
3717}3765}
37183766
3719/****************************************************************************3767/****************************************************************************
37203768
=== modified file 'Percona-Server/sql/handler.h'
--- Percona-Server/sql/handler.h 2012-01-17 14:05:16 +0000
+++ Percona-Server/sql/handler.h 2012-02-02 06:11:26 +0000
@@ -1179,7 +1179,9 @@
1179 ref_length(sizeof(my_off_t)),1179 ref_length(sizeof(my_off_t)),
1180 ft_handler(0), inited(NONE),1180 ft_handler(0), inited(NONE),
1181 locked(FALSE), implicit_emptied(0),1181 locked(FALSE), implicit_emptied(0),
1182 pushed_cond(0), rows_read(0), rows_changed(0), next_insert_id(0), insert_id_for_cur_row(0),1182 pushed_cond(0),
1183 rows_read(0), rows_changed(0),
1184 next_insert_id(0), insert_id_for_cur_row(0),
1183 auto_inc_intervals_count(0)1185 auto_inc_intervals_count(0)
1184 {1186 {
1185 memset(index_rows_read, 0, sizeof(index_rows_read));1187 memset(index_rows_read, 0, sizeof(index_rows_read));
@@ -1305,9 +1307,10 @@
1305 uint get_dup_key(int error);1307 uint get_dup_key(int error);
1306 virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share)1308 virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share)
1307 {1309 {
1308 table= table_arg;1310 table= table_arg;
1309 table_share= share;1311 table_share= share;
1310 rows_read = rows_changed = 0;1312 rows_read= 0;
1313 rows_changed= 0;
1311 memset(index_rows_read, 0, sizeof(index_rows_read));1314 memset(index_rows_read, 0, sizeof(index_rows_read));
1312 }1315 }
1313 virtual double scan_time()1316 virtual double scan_time()
13141317
=== modified file 'Percona-Server/sql/item.cc'
--- Percona-Server/sql/item.cc 2011-07-07 08:06:59 +0000
+++ Percona-Server/sql/item.cc 2012-02-02 06:11:26 +0000
@@ -4435,6 +4435,7 @@
4435 db, tab, field_name) &4435 db, tab, field_name) &
4436 VIEW_ANY_ACL)))4436 VIEW_ANY_ACL)))
4437 {4437 {
4438 thd->diff_stats.access_denied_errors++;
4438 my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),4439 my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
4439 "ANY", thd->security_ctx->priv_user,4440 "ANY", thd->security_ctx->priv_user,
4440 thd->security_ctx->host_or_ip, field_name, tab);4441 thd->security_ctx->host_or_ip, field_name, tab);
44414442
=== modified file 'Percona-Server/sql/mysql_priv.h'
--- Percona-Server/sql/mysql_priv.h 2011-11-24 02:01:21 +0000
+++ Percona-Server/sql/mysql_priv.h 2012-02-02 06:11:26 +0000
@@ -1175,6 +1175,7 @@
1175void mysql_init_multi_delete(LEX *lex);1175void mysql_init_multi_delete(LEX *lex);
1176bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);1176bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
1177void init_max_user_conn(void);1177void init_max_user_conn(void);
1178void set_connections_stats();
1178void init_update_queries(void);1179void init_update_queries(void);
1179void init_global_user_stats(void);1180void init_global_user_stats(void);
1180void init_global_table_stats(void);1181void init_global_table_stats(void);
@@ -2195,7 +2196,6 @@
2195extern pthread_mutex_t LOCK_global_table_stats;2196extern pthread_mutex_t LOCK_global_table_stats;
2196extern HASH global_index_stats;2197extern HASH global_index_stats;
2197extern pthread_mutex_t LOCK_global_index_stats;2198extern pthread_mutex_t LOCK_global_index_stats;
2198extern pthread_mutex_t LOCK_stats;
21992199
2200extern const char *opt_date_time_formats[];2200extern const char *opt_date_time_formats[];
2201extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];2201extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
22022202
=== modified file 'Percona-Server/sql/mysqld.cc'
--- Percona-Server/sql/mysqld.cc 2012-01-30 04:30:33 +0000
+++ Percona-Server/sql/mysqld.cc 2012-02-02 06:11:26 +0000
@@ -724,7 +724,6 @@
724 LOCK_global_system_variables,724 LOCK_global_system_variables,
725 LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,725 LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
726 LOCK_connection_count;726 LOCK_connection_count;
727pthread_mutex_t LOCK_stats;
728pthread_mutex_t LOCK_global_user_client_stats;727pthread_mutex_t LOCK_global_user_client_stats;
729pthread_mutex_t LOCK_global_table_stats;728pthread_mutex_t LOCK_global_table_stats;
730pthread_mutex_t LOCK_global_index_stats;729pthread_mutex_t LOCK_global_index_stats;
@@ -1537,7 +1536,6 @@
1537 (void) pthread_cond_destroy(&COND_thread_cache);1536 (void) pthread_cond_destroy(&COND_thread_cache);
1538 (void) pthread_cond_destroy(&COND_flush_thread_cache);1537 (void) pthread_cond_destroy(&COND_flush_thread_cache);
1539 (void) pthread_cond_destroy(&COND_manager);1538 (void) pthread_cond_destroy(&COND_manager);
1540 (void) pthread_mutex_destroy(&LOCK_stats);
1541 (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);1539 (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
1542 (void) pthread_mutex_destroy(&LOCK_global_table_stats);1540 (void) pthread_mutex_destroy(&LOCK_global_table_stats);
1543 (void) pthread_mutex_destroy(&LOCK_global_index_stats);1541 (void) pthread_mutex_destroy(&LOCK_global_index_stats);
@@ -3735,7 +3733,6 @@
3735#endif3733#endif
3736 (void) pthread_mutex_init(&LOCK_server_started, MY_MUTEX_INIT_FAST);3734 (void) pthread_mutex_init(&LOCK_server_started, MY_MUTEX_INIT_FAST);
3737 (void) pthread_cond_init(&COND_server_started,NULL);3735 (void) pthread_cond_init(&COND_server_started,NULL);
3738 (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
3739 (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);3736 (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
3740 (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);3737 (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
3741 (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);3738 (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
37423739
=== modified file 'Percona-Server/sql/set_var.cc'
--- Percona-Server/sql/set_var.cc 2012-01-30 04:30:33 +0000
+++ Percona-Server/sql/set_var.cc 2012-02-02 06:11:26 +0000
@@ -1152,6 +1152,7 @@
1152 -1 : 0);1152 -1 : 0);
1153 else1153 else
1154 {1154 {
1155 thd->diff_stats.access_denied_errors++;
1155 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");1156 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
1156 return 1;1157 return 1;
1157 }1158 }
@@ -3283,6 +3284,7 @@
3283#ifndef NO_EMBEDDED_ACCESS_CHECKS3284#ifndef NO_EMBEDDED_ACCESS_CHECKS
3284 if (!(thd->security_ctx->master_access & SUPER_ACL))3285 if (!(thd->security_ctx->master_access & SUPER_ACL))
3285 {3286 {
3287 thd->diff_stats.access_denied_errors++;
3286 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");3288 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
3287 return 1;3289 return 1;
3288 }3290 }
@@ -3321,6 +3323,7 @@
3321 return 0;3323 return 0;
3322 else3324 else
3323 {3325 {
3326 thd->diff_stats.access_denied_errors++;
3324 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");3327 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
3325 return 1;3328 return 1;
3326 }3329 }
33273330
=== modified file 'Percona-Server/sql/sp_head.cc'
--- Percona-Server/sql/sp_head.cc 2011-11-24 16:33:30 +0000
+++ Percona-Server/sql/sp_head.cc 2012-02-02 06:11:26 +0000
@@ -1556,6 +1556,7 @@
1556 char priv_desc[128];1556 char priv_desc[128];
1557 get_privilege_desc(priv_desc, sizeof(priv_desc), TRIGGER_ACL);1557 get_privilege_desc(priv_desc, sizeof(priv_desc), TRIGGER_ACL);
15581558
1559 thd->diff_stats.access_denied_errors++;
1559 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), priv_desc,1560 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), priv_desc,
1560 thd->security_ctx->priv_user, thd->security_ctx->host_or_ip,1561 thd->security_ctx->priv_user, thd->security_ctx->host_or_ip,
1561 table_name->str);1562 table_name->str);
15621563
=== modified file 'Percona-Server/sql/sql_acl.cc'
--- Percona-Server/sql/sql_acl.cc 2011-07-03 15:47:37 +0000
+++ Percona-Server/sql/sql_acl.cc 2012-02-02 06:11:26 +0000
@@ -3068,6 +3068,7 @@
3068 char command[128];3068 char command[128];
3069 get_privilege_desc(command, sizeof(command),3069 get_privilege_desc(command, sizeof(command),
3070 table_list->grant.want_privilege);3070 table_list->grant.want_privilege);
3071 thd->diff_stats.access_denied_errors++;
3071 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),3072 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
3072 command, thd->security_ctx->priv_user,3073 command, thd->security_ctx->priv_user,
3073 thd->security_ctx->host_or_ip, table_list->alias);3074 thd->security_ctx->host_or_ip, table_list->alias);
@@ -4051,6 +4052,7 @@
4051 {4052 {
4052 char command[128];4053 char command[128];
4053 get_privilege_desc(command, sizeof(command), want_access);4054 get_privilege_desc(command, sizeof(command), want_access);
4055 thd->diff_stats.access_denied_errors++;
4054 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),4056 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
4055 command,4057 command,
4056 sctx->priv_user,4058 sctx->priv_user,
@@ -4118,6 +4120,7 @@
4118 rw_unlock(&LOCK_grant);4120 rw_unlock(&LOCK_grant);
4119 char command[128];4121 char command[128];
4120 get_privilege_desc(command, sizeof(command), want_access);4122 get_privilege_desc(command, sizeof(command), want_access);
4123 thd->diff_stats.access_denied_errors++;
4121 my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),4124 my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
4122 command,4125 command,
4123 sctx->priv_user,4126 sctx->priv_user,
@@ -4283,6 +4286,7 @@
4283 Do not give an error message listing a column name unless the user has4286 Do not give an error message listing a column name unless the user has
4284 privilege to see all columns.4287 privilege to see all columns.
4285 */4288 */
4289 thd->diff_stats.access_denied_errors++;
4286 if (using_column_privileges)4290 if (using_column_privileges)
4287 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),4291 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
4288 command, sctx->priv_user,4292 command, sctx->priv_user,
@@ -4418,6 +4422,7 @@
4418 command= "alter routine";4422 command= "alter routine";
4419 else if (want_access & GRANT_ACL)4423 else if (want_access & GRANT_ACL)
4420 command= "grant";4424 command= "grant";
4425 thd->diff_stats.access_denied_errors++;
4421 my_error(ER_PROCACCESS_DENIED_ERROR, MYF(0),4426 my_error(ER_PROCACCESS_DENIED_ERROR, MYF(0),
4422 command, user, host, table ? buff : "unknown");4427 command, user, host, table ? buff : "unknown");
4423 }4428 }
44244429
=== modified file 'Percona-Server/sql/sql_base.cc'
--- Percona-Server/sql/sql_base.cc 2011-11-24 16:33:30 +0000
+++ Percona-Server/sql/sql_base.cc 2012-02-02 06:11:26 +0000
@@ -8101,6 +8101,7 @@
8101 field_table_name, fld->field_name) &8101 field_table_name, fld->field_name) &
8102 VIEW_ANY_ACL)))8102 VIEW_ANY_ACL)))
8103 {8103 {
8104 thd->diff_stats.access_denied_errors++;
8104 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), "ANY",8105 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), "ANY",
8105 thd->security_ctx->priv_user,8106 thd->security_ctx->priv_user,
8106 thd->security_ctx->host_or_ip,8107 thd->security_ctx->host_or_ip,
81078108
=== modified file 'Percona-Server/sql/sql_class.cc'
--- Percona-Server/sql/sql_class.cc 2011-11-24 02:00:51 +0000
+++ Percona-Server/sql/sql_class.cc 2012-02-02 06:11:26 +0000
@@ -725,14 +725,13 @@
725 bzero(ha_data, sizeof(ha_data));725 bzero(ha_data, sizeof(ha_data));
726 mysys_var=0;726 mysys_var=0;
727 binlog_evt_union.do_union= FALSE;727 binlog_evt_union.do_union= FALSE;
728 enable_slow_log= 0;728 enable_slow_log= 0;
729 busy_time = 0;729 busy_time= 0;
730 cpu_time = 0;730 cpu_time= 0;
731 bytes_received = 0;731 bytes_received= 0;
732 bytes_sent = 0;732 bytes_sent= 0;
733 binlog_bytes_written = 0;733 binlog_bytes_written= 0;
734 updated_row_count = 0;734 updated_row_count= 0;
735 sent_row_count_2 = 0;
736#ifndef DBUG_OFF735#ifndef DBUG_OFF
737 dbug_sentry=THD_SENTRY_MAGIC;736 dbug_sentry=THD_SENTRY_MAGIC;
738#endif737#endif
@@ -947,83 +946,109 @@
947 clear_slow_extended();946 clear_slow_extended();
948}947}
949948
950// Resets stats in a THD.949
950/**
951 Resets stats in a THD.
952*/
951void THD::reset_stats(void) {953void THD::reset_stats(void) {
952 current_connect_time = time(NULL);954 current_connect_time= time(NULL);
953 last_global_update_time = current_connect_time;955 diff_stats.connected_time= current_connect_time;
954 reset_diff_stats();956 reset_diff_stats();
955}957}
956958
957// Resets the 'diff' stats, which are used to update global stats.959
960/**
961 Resets the 'diff' stats, which are used to update global stats.
962*/
958void THD::reset_diff_stats(void) {963void THD::reset_diff_stats(void) {
959 diff_total_busy_time = 0;964 diff_stats.busy_time= 0;
960 diff_total_cpu_time = 0;965 diff_stats.cpu_time= 0;
961 diff_total_bytes_received = 0;966 diff_stats.bytes_received= 0;
962 diff_total_bytes_sent = 0;967 diff_stats.bytes_sent= 0;
963 diff_total_binlog_bytes_written = 0;968 diff_stats.binlog_bytes_written= 0;
964 diff_total_sent_rows = 0;969 diff_stats.rows_fetched= 0;
965 diff_total_updated_rows = 0;970 diff_stats.rows_updated= 0;
966 diff_total_read_rows = 0;971 diff_stats.rows_read= 0;
967 diff_select_commands = 0;972 diff_stats.select_commands= 0;
968 diff_update_commands = 0;973 diff_stats.update_commands= 0;
969 diff_other_commands = 0;974 diff_stats.other_commands= 0;
970 diff_commit_trans = 0;975 diff_stats.commit_trans= 0;
971 diff_rollback_trans = 0;976 diff_stats.rollback_trans= 0;
972 diff_denied_connections = 0;977 diff_stats.denied_connections= 0;
973 diff_lost_connections = 0;978 diff_stats.lost_connections= 0;
974 diff_access_denied_errors = 0;979 diff_stats.access_denied_errors= 0;
975 diff_empty_queries = 0;980 diff_stats.empty_queries= 0;
976}981}
977982
978// Updates 'diff' stats of a THD.983
984/**
985 Updates 'diff' stats of a THD.
986*/
979void THD::update_stats(bool ran_command) {987void THD::update_stats(bool ran_command) {
988 DBUG_ENTER("THD::update_stats");
989 DBUG_PRINT("query",("%-.4096s", query()));
980 if (opt_userstat_running) {990 if (opt_userstat_running) {
981 diff_total_busy_time += busy_time;991 diff_stats.busy_time+= busy_time;
982 diff_total_cpu_time += cpu_time;992 diff_stats.cpu_time+= cpu_time;
983 diff_total_bytes_received += bytes_received;993 diff_stats.bytes_received+= bytes_received;
984 diff_total_bytes_sent += bytes_sent;994 diff_stats.bytes_sent+= bytes_sent;
985 diff_total_binlog_bytes_written += binlog_bytes_written;995 diff_stats.binlog_bytes_written+= binlog_bytes_written;
986 diff_total_sent_rows += sent_row_count_2;996 diff_stats.rows_fetched+= sent_row_count;
987 diff_total_updated_rows += updated_row_count;997 diff_stats.rows_updated+= updated_row_count;
988 // diff_total_read_rows is updated in handler.cc.998 /* diff_stats.rows_read is updated in handler.cc. */
989999
990 if (ran_command) {1000 if (ran_command)
991 // The replication thread has the COM_CONNECT command.1001 {
992 if ((old_command == COM_QUERY || command == COM_CONNECT) &&1002 /* The replication thread has the COM_CONNECT command. */
993 (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {1003 if ((old_command == COM_QUERY ||
994 // A SQL query.1004 command == COM_CONNECT) &&
995 if (lex->sql_command == SQLCOM_SELECT) {1005 (lex->sql_command >= 0 &&
996 diff_select_commands++;1006 lex->sql_command < SQLCOM_END))
997 if (!sent_row_count_2)1007 {
998 diff_empty_queries++;1008 /* A SQL query. */
999 } else if (! sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) {1009 if (lex->sql_command == SQLCOM_SELECT)
1000 // 'SHOW ' commands become SQLCOM_SELECT.1010 {
1001 diff_other_commands++;1011 diff_stats.select_commands++;
1002 // 'SHOW ' commands shouldn't inflate total sent row count.1012 if (!sent_row_count)
1003 diff_total_sent_rows -= sent_row_count_2;1013 {
1004 } else if (is_update_query(lex->sql_command)) {1014 diff_stats.empty_queries++;
1005 diff_update_commands++;1015 }
1006 } else {1016 }
1007 diff_other_commands++;1017 else if (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND)
1018 {
1019 /* 'SHOW ' commands become SQLCOM_SELECT. */
1020 diff_stats.other_commands++;
1021 /* 'SHOW ' commands shouldn't inflate total sent row count. */
1022 diff_stats.rows_fetched-= sent_row_count;
1023 }
1024 else if (is_update_query(lex->sql_command))
1025 {
1026 diff_stats.update_commands++;
1027 }
1028 else
1029 {
1030 diff_stats.other_commands++;
1031 }
1008 }1032 }
1009 }1033 }
1010 }1034 /* diff_stats.commit_trans is updated in handler.cc. */
1011 // diff_commit_trans is updated in handler.cc.1035 /* diff_stats.rollback_trans is updated in handler.cc. */
1012 // diff_rollback_trans is updated in handler.cc.1036 /* diff_stats.denied_connections is updated in sql_parse.cc. */
1013 // diff_denied_connections is updated in sql_parse.cc.1037 /* diff_stats.lost_connections is updated in sql_parse.cc. */
1014 // diff_lost_connections is updated in sql_parse.cc.1038 /* diff_stats.access_denied_errors is updated in sql_parse.cc.*/
1015 // diff_access_denied_errors is updated in sql_parse.cc.
10161039
1017 /* reset counters to zero to avoid double-counting since values1040 /*
1018 are already store in diff_total_*. */1041 reset counters to zero to avoid double-counting since values
1042 are already store in diff_stats.*.
1043 */
1019 }1044 }
1020 busy_time = 0;1045 busy_time= 0;
1021 cpu_time = 0;1046 cpu_time= 0;
1022 bytes_received = 0;1047 bytes_received= 0;
1023 bytes_sent = 0;1048 bytes_sent= 0;
1024 binlog_bytes_written = 0;1049 binlog_bytes_written= 0;
1025 updated_row_count = 0;1050 updated_row_count= 0;
1026 sent_row_count_2 = 0;1051 DBUG_VOID_RETURN;
1027}1052}
10281053
1029/*1054/*
@@ -1888,8 +1913,10 @@
1888 */1913 */
1889 buffer.set(buff, sizeof(buff), &my_charset_bin);1914 buffer.set(buff, sizeof(buff), &my_charset_bin);
1890 }1915 }
1916
1917 DBUG_PRINT("query",("%-.4096s", thd->query()));
1891 thd->sent_row_count++;1918 thd->sent_row_count++;
1892 thd->sent_row_count_2++;1919
1893 if (thd->is_error())1920 if (thd->is_error())
1894 {1921 {
1895 protocol->remove_last_row();1922 protocol->remove_last_row();
@@ -1993,8 +2020,7 @@
19932020
1994select_export::~select_export()2021select_export::~select_export()
1995{2022{
1996 thd->sent_row_count=row_count;2023 thd->sent_row_count= row_count;
1997 thd->sent_row_count_2=row_count;
1998}2024}
19992025
20002026
@@ -3027,7 +3053,7 @@
3027 if (likely(thd != 0))3053 if (likely(thd != 0))
3028 { /* current_thd==0 when close_connection() calls net_send_error() */3054 { /* current_thd==0 when close_connection() calls net_send_error() */
3029 thd->status_var.bytes_sent+= length;3055 thd->status_var.bytes_sent+= length;
3030 thd->bytes_sent+= length;3056 thd->bytes_sent+= length;
3031 }3057 }
3032}3058}
30333059
@@ -3035,7 +3061,7 @@
3035void thd_increment_bytes_received(ulong length)3061void thd_increment_bytes_received(ulong length)
3036{3062{
3037 current_thd->status_var.bytes_received+= length;3063 current_thd->status_var.bytes_received+= length;
3038 current_thd->bytes_received+= length;3064 current_thd->bytes_received+= length;
3039}3065}
30403066
30413067
30423068
=== modified file 'Percona-Server/sql/sql_class.h'
--- Percona-Server/sql/sql_class.h 2012-01-30 04:30:33 +0000
+++ Percona-Server/sql/sql_class.h 2012-02-02 06:11:26 +0000
@@ -1906,7 +1906,6 @@
1906 enum_tx_isolation session_tx_isolation;1906 enum_tx_isolation session_tx_isolation;
1907 enum_check_fields count_cuted_fields;1907 enum_check_fields count_cuted_fields;
1908 ha_rows updated_row_count;1908 ha_rows updated_row_count;
1909 ha_rows sent_row_count_2; /* for userstat */
19101909
1911 DYNAMIC_ARRAY user_var_events; /* For user variables replication */1910 DYNAMIC_ARRAY user_var_events; /* For user variables replication */
1912 MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */1911 MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
@@ -2001,41 +2000,23 @@
2001 occasionally with the 'diff' variables. After the update, the 'diff'2000 occasionally with the 'diff' variables. After the update, the 'diff'
2002 variables are reset to 0.2001 variables are reset to 0.
2003 */2002 */
2004 // Time when the current thread connected to MySQL.2003 /* Time when the current thread connected to MySQL. */
2005 time_t current_connect_time;2004 time_t current_connect_time;
2006 // Last time when THD stats were updated in global_user_stats.2005 /* Busy (non-idle) time for just one command. */
2007 time_t last_global_update_time;
2008 // Busy (non-idle) time for just one command.
2009 double busy_time;2006 double busy_time;
2010 // Busy time not updated in global_user_stats yet.2007 /* Cpu (non-idle) time for just one thread. */
2011 double diff_total_busy_time;
2012 // Cpu (non-idle) time for just one thread.
2013 double cpu_time;2008 double cpu_time;
2014 // Cpu time not updated in global_user_stats yet.
2015 double diff_total_cpu_time;
2016 /* bytes counting */2009 /* bytes counting */
2017 ulonglong bytes_received;2010 ulonglong bytes_received;
2018 ulonglong diff_total_bytes_received;
2019 ulonglong bytes_sent;2011 ulonglong bytes_sent;
2020 ulonglong diff_total_bytes_sent;
2021 ulonglong binlog_bytes_written;2012 ulonglong binlog_bytes_written;
2022 ulonglong diff_total_binlog_bytes_written;2013
20232014 STATS diff_stats;
2024 // Number of rows not reflected in global_user_stats yet.2015
2025 ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;2016 /*
2026 // Number of commands not reflected in global_user_stats yet.2017 Per account query delay in miliseconds. When not 0, sleep this number of
2027 ulonglong diff_select_commands, diff_update_commands, diff_other_commands;2018 milliseconds before every SQL command.
2028 // Number of transactions not reflected in global_user_stats yet.2019 */
2029 ulonglong diff_commit_trans, diff_rollback_trans;
2030 // Number of connection errors not reflected in global_user_stats yet.
2031 ulonglong diff_denied_connections, diff_lost_connections;
2032 // Number of db access denied, not reflected in global_user_stats yet.
2033 ulonglong diff_access_denied_errors;
2034 // Number of queries that return 0 rows
2035 ulonglong diff_empty_queries;
2036
2037 // Per account query delay in miliseconds. When not 0, sleep this number of
2038 // milliseconds before every SQL command.
2039 ulonglong query_delay_millis;2020 ulonglong query_delay_millis;
20402021
2041 /* Used by the sys_var class to store temporary values */2022 /* Used by the sys_var class to store temporary values */
@@ -2105,8 +2086,10 @@
2105 void init_for_queries();2086 void init_for_queries();
2106 void reset_stats(void);2087 void reset_stats(void);
2107 void reset_diff_stats(void);2088 void reset_diff_stats(void);
2108 // ran_command is true when this is called immediately after a2089 /*
2109 // command has been run.2090 ran_command is true when this is called immediately after a
2091 command has been run.
2092 */
2110 void update_stats(bool ran_command);2093 void update_stats(bool ran_command);
2111 void change_user(void);2094 void change_user(void);
2112 void cleanup(void);2095 void cleanup(void);
@@ -2477,13 +2460,15 @@
2477 *p_db= strmake(db, db_length);2460 *p_db= strmake(db, db_length);
2478 *p_db_length= db_length;2461 *p_db_length= db_length;
2479 return FALSE;2462 return FALSE;
2480
2481 // Returns string as 'IP:port' for the client-side of the connnection represented
2482 // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
2483 // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
2484 }2463 }
2485 thd_scheduler scheduler;2464 thd_scheduler scheduler;
24862465
2466 /*
2467 Returns string as 'IP:port' for the client-side of the connnection
2468 represented by 'client' as displayed by SHOW PROCESSLIST.
2469 Allocates memory from the heap of this THD and that is not reclaimed
2470 immediately, so use sparingly. May return NULL.
2471 */
2487 char *get_client_host_port(THD *client);2472 char *get_client_host_port(THD *client);
24882473
2489public:2474public:
24902475
=== modified file 'Percona-Server/sql/sql_connect.cc'
--- Percona-Server/sql/sql_connect.cc 2011-11-24 01:59:48 +0000
+++ Percona-Server/sql/sql_connect.cc 2012-02-02 06:11:26 +0000
@@ -20,6 +20,7 @@
20*/20*/
2121
22#include "mysql_priv.h"22#include "mysql_priv.h"
23#include "debug_sync.h"
2324
24/** Size of the header fields of an authentication packet. */25/** Size of the header fields of an authentication packet. */
25#define AUTH_PACKET_HEADER_SIZE_PROTO_41 3226#define AUTH_PACKET_HEADER_SIZE_PROTO_41 32
@@ -30,24 +31,26 @@
30extern void win_install_sigabrt_handler();31extern void win_install_sigabrt_handler();
31#endif32#endif
3233
33// Increments connection count for user.34/* Increments connection count for user. */
34static int increment_connection_count(THD* thd, bool use_lock);35/*static int increment_connection_count(THD* thd, bool use_lock);*/
3536
36// Uses the THD to update the global stats by user name and client IP37/* Uses the THD to update the global stats by user name and client hostname */
37void update_global_user_stats(THD* thd, bool create_user, time_t now);38/*void update_global_stats(THD* thd, bool create_user, time_t now);*/
3839
39HASH global_user_stats;40/* Set stats for concurrent connections displayed by mysqld_show(). */
41/*void set_connections_stats();*/
42
40HASH global_client_stats;43HASH global_client_stats;
44HASH global_index_stats;
45HASH global_table_stats;
41HASH global_thread_stats;46HASH global_thread_stats;
42// Protects global_user_stats and global_client_stats47HASH global_user_stats;
48
49/* Protects global_user_stats and global_client_stats */
43extern pthread_mutex_t LOCK_global_user_client_stats;50extern pthread_mutex_t LOCK_global_user_client_stats;
4451extern pthread_mutex_t LOCK_global_index_stats;
45HASH global_table_stats;
46extern pthread_mutex_t LOCK_global_table_stats;52extern pthread_mutex_t LOCK_global_table_stats;
4753
48HASH global_index_stats;
49extern pthread_mutex_t LOCK_global_index_stats;
50
51/*54/*
52 Get structure for logging connection data for the current user55 Get structure for logging connection data for the current user
53*/56*/
@@ -59,6 +62,7 @@
59 const char *host,62 const char *host,
60 USER_RESOURCES *mqh)63 USER_RESOURCES *mqh)
61{64{
65 DBUG_ENTER("get_or_create_user_conn");
62 int return_val= 0;66 int return_val= 0;
63 size_t temp_len, user_len;67 size_t temp_len, user_len;
64 char temp_user[USER_HOST_BUFF_SIZE];68 char temp_user[USER_HOST_BUFF_SIZE];
@@ -70,8 +74,8 @@
70 user_len= strlen(user);74 user_len= strlen(user);
71 temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1;75 temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1;
72 (void) pthread_mutex_lock(&LOCK_user_conn);76 (void) pthread_mutex_lock(&LOCK_user_conn);
73 if (!(uc = (struct user_conn *) hash_search(&hash_user_connections,77 if (!(uc= (struct user_conn *) hash_search(&hash_user_connections,
74 (uchar*) temp_user, temp_len)))78 (uchar*) temp_user, temp_len)))
75 {79 {
76 /* First connection for user; Create a user connection object */80 /* First connection for user; Create a user connection object */
77 if (!(uc= ((struct user_conn*)81 if (!(uc= ((struct user_conn*)
@@ -101,567 +105,504 @@
101 uc->connections++;105 uc->connections++;
102end:106end:
103 (void) pthread_mutex_unlock(&LOCK_user_conn);107 (void) pthread_mutex_unlock(&LOCK_user_conn);
104 return return_val;108 DBUG_RETURN(return_val);
105109
106}110}
107111
108extern "C" uchar *get_key_user_stats(USER_STATS *user_stats, size_t *length,112extern "C" uchar *get_key_index_stats(INDEX_STATS* index_stats,
109 my_bool not_used __attribute__((unused)))113 size_t* length,
110{114 my_bool not_used __attribute__((unused)))
111 *length = strlen(user_stats->user);115{
112 return (uchar*)user_stats->user;116 DBUG_ENTER("get_key_index_stats");
113}117 *length= strlen(index_stats->index);
114118 DBUG_RETURN((uchar*)index_stats->index);
115extern "C" uchar *get_key_thread_stats(THREAD_STATS *thread_stats, size_t *length,119}
116 my_bool not_used __attribute__((unused)))120
117{121
118 *length = sizeof(my_thread_id);122extern "C" uchar *get_key_table_stats(TABLE_STATS* table_stats,
119 return (uchar*)&(thread_stats->id);123 size_t* length,
120}124 my_bool not_used __attribute__((unused)))
125{
126 DBUG_ENTER("get_key_table_stats");
127 *length= strlen(table_stats->table);
128 DBUG_RETURN((uchar*)table_stats->table);
129}
130
131
132extern "C" uchar *get_key_thread_stats(THREAD_STATS* thread_stats,
133 size_t* length,
134 my_bool not_used __attribute__((unused)))
135{
136 DBUG_ENTER("get_key_thread_stats");
137 *length= sizeof(my_thread_id);
138 DBUG_RETURN((uchar*)&(thread_stats->id));
139}
140
141
142extern "C" uchar *get_key_user_stats(USER_STATS* user_stats,
143 size_t* length,
144 my_bool not_used __attribute__((unused)))
145{
146 DBUG_ENTER("get_key_user_stats");
147 *length= strlen(user_stats->user);
148 DBUG_RETURN((uchar*)user_stats->user);
149}
150
151
152extern "C" void free_index_stats(INDEX_STATS* index_stats)
153{
154 my_free((char*)index_stats, MYF(0));
155}
156
157
158extern "C" void free_table_stats(TABLE_STATS* table_stats)
159{
160 my_free((char*)table_stats, MYF(0));
161}
162
163
164void free_thread_stats(THREAD_STATS* thread_stats)
165{
166 my_free((char*)thread_stats, MYF(0));
167}
168
121169
122void free_user_stats(USER_STATS* user_stats)170void free_user_stats(USER_STATS* user_stats)
123{171{
124 my_free((char*)user_stats, MYF(0));172 my_free((char*)user_stats, MYF(0));
125}173}
126174
127void free_thread_stats(THREAD_STATS* thread_stats)175void free_global_client_stats(void)
128{176{
129 my_free((char*)thread_stats, MYF(0));177 hash_free(&global_client_stats);
130}178}
131179
132void init_user_stats(USER_STATS *user_stats,180
133 const char *user,181void free_global_index_stats(void)
134 const char *priv_user,182{
135 uint total_connections,183 hash_free(&global_index_stats);
136 uint concurrent_connections,184}
137 time_t connected_time,185
138 double busy_time,186
139 double cpu_time,187void free_global_table_stats(void)
140 ulonglong bytes_received,188{
141 ulonglong bytes_sent,189 hash_free(&global_table_stats);
142 ulonglong binlog_bytes_written,190}
143 ha_rows rows_fetched,191
144 ha_rows rows_updated,192
145 ha_rows rows_read,193void free_global_thread_stats(void)
146 ulonglong select_commands,194{
147 ulonglong update_commands,195 hash_free(&global_thread_stats);
148 ulonglong other_commands,196}
149 ulonglong commit_trans,197
150 ulonglong rollback_trans,198
151 ulonglong denied_connections,199void free_global_user_stats(void)
152 ulonglong lost_connections,200{
153 ulonglong access_denied_errors,201 hash_free(&global_user_stats);
154 ulonglong empty_queries)202}
155{203
156 DBUG_ENTER("init_user_stats");204
157 DBUG_PRINT("info",205void init_stats(STATS* stats)
158 ("Add user_stats entry for user %s - priv_user %s",206{
159 user, priv_user));207 memset(stats, 0, sizeof(stats));
208}
209
210
211void init_thread_stats(THREAD_STATS* thread_stats, my_thread_id id)
212{
213 thread_stats->id= id;
214 init_stats(&thread_stats->stats);
215}
216
217
218void init_user_stats(USER_STATS *user_stats, const char *user)
219{
160 strncpy(user_stats->user, user, sizeof(user_stats->user));220 strncpy(user_stats->user, user, sizeof(user_stats->user));
161 strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));221 init_stats(&user_stats->stats);
162222}
163 user_stats->total_connections = total_connections;223
164 user_stats->concurrent_connections = concurrent_connections;
165 user_stats->connected_time = connected_time;
166 user_stats->busy_time = busy_time;
167 user_stats->cpu_time = cpu_time;
168 user_stats->bytes_received = bytes_received;
169 user_stats->bytes_sent = bytes_sent;
170 user_stats->binlog_bytes_written = binlog_bytes_written;
171 user_stats->rows_fetched = rows_fetched;
172 user_stats->rows_updated = rows_updated;
173 user_stats->rows_read = rows_read;
174 user_stats->select_commands = select_commands;
175 user_stats->update_commands = update_commands;
176 user_stats->other_commands = other_commands;
177 user_stats->commit_trans = commit_trans;
178 user_stats->rollback_trans = rollback_trans;
179 user_stats->denied_connections = denied_connections;
180 user_stats->lost_connections = lost_connections;
181 user_stats->access_denied_errors = access_denied_errors;
182 user_stats->empty_queries = empty_queries;
183 DBUG_VOID_RETURN;
184}
185
186void init_thread_stats(THREAD_STATS *thread_stats,
187 my_thread_id id,
188 uint total_connections,
189 uint concurrent_connections,
190 time_t connected_time,
191 double busy_time,
192 double cpu_time,
193 ulonglong bytes_received,
194 ulonglong bytes_sent,
195 ulonglong binlog_bytes_written,
196 ha_rows rows_fetched,
197 ha_rows rows_updated,
198 ha_rows rows_read,
199 ulonglong select_commands,
200 ulonglong update_commands,
201 ulonglong other_commands,
202 ulonglong commit_trans,
203 ulonglong rollback_trans,
204 ulonglong denied_connections,
205 ulonglong lost_connections,
206 ulonglong access_denied_errors,
207 ulonglong empty_queries)
208{
209 DBUG_ENTER("init_thread_stats");
210 DBUG_PRINT("info",
211 ("Add thread_stats entry for thread %lu",
212 id));
213 thread_stats->id = id;
214
215 thread_stats->total_connections = total_connections;
216 thread_stats->concurrent_connections = concurrent_connections;
217 thread_stats->connected_time = connected_time;
218 thread_stats->busy_time = busy_time;
219 thread_stats->cpu_time = cpu_time;
220 thread_stats->bytes_received = bytes_received;
221 thread_stats->bytes_sent = bytes_sent;
222 thread_stats->binlog_bytes_written = binlog_bytes_written;
223 thread_stats->rows_fetched = rows_fetched;
224 thread_stats->rows_updated = rows_updated;
225 thread_stats->rows_read = rows_read;
226 thread_stats->select_commands = select_commands;
227 thread_stats->update_commands = update_commands;
228 thread_stats->other_commands = other_commands;
229 thread_stats->commit_trans = commit_trans;
230 thread_stats->rollback_trans = rollback_trans;
231 thread_stats->denied_connections = denied_connections;
232 thread_stats->lost_connections = lost_connections;
233 thread_stats->access_denied_errors = access_denied_errors;
234 thread_stats->empty_queries = empty_queries;
235 DBUG_VOID_RETURN;
236}
237
238void add_user_stats(USER_STATS *user_stats,
239 uint total_connections,
240 uint concurrent_connections,
241 time_t connected_time,
242 double busy_time,
243 double cpu_time,
244 ulonglong bytes_received,
245 ulonglong bytes_sent,
246 ulonglong binlog_bytes_written,
247 ha_rows rows_fetched,
248 ha_rows rows_updated,
249 ha_rows rows_read,
250 ulonglong select_commands,
251 ulonglong update_commands,
252 ulonglong other_commands,
253 ulonglong commit_trans,
254 ulonglong rollback_trans,
255 ulonglong denied_connections,
256 ulonglong lost_connections,
257 ulonglong access_denied_errors,
258 ulonglong empty_queries)
259{
260 user_stats->total_connections += total_connections;
261 user_stats->concurrent_connections += concurrent_connections;
262 user_stats->connected_time += connected_time;
263 user_stats->busy_time += busy_time;
264 user_stats->cpu_time += cpu_time;
265 user_stats->bytes_received += bytes_received;
266 user_stats->bytes_sent += bytes_sent;
267 user_stats->binlog_bytes_written += binlog_bytes_written;
268 user_stats->rows_fetched += rows_fetched;
269 user_stats->rows_updated += rows_updated;
270 user_stats->rows_read += rows_read;
271 user_stats->select_commands += select_commands;
272 user_stats->update_commands += update_commands;
273 user_stats->other_commands += other_commands;
274 user_stats->commit_trans += commit_trans;
275 user_stats->rollback_trans += rollback_trans;
276 user_stats->denied_connections += denied_connections;
277 user_stats->lost_connections += lost_connections;
278 user_stats->access_denied_errors += access_denied_errors;
279 user_stats->empty_queries += empty_queries;
280}
281
282void add_thread_stats(THREAD_STATS *thread_stats,
283 uint total_connections,
284 uint concurrent_connections,
285 time_t connected_time,
286 double busy_time,
287 double cpu_time,
288 ulonglong bytes_received,
289 ulonglong bytes_sent,
290 ulonglong binlog_bytes_written,
291 ha_rows rows_fetched,
292 ha_rows rows_updated,
293 ha_rows rows_read,
294 ulonglong select_commands,
295 ulonglong update_commands,
296 ulonglong other_commands,
297 ulonglong commit_trans,
298 ulonglong rollback_trans,
299 ulonglong denied_connections,
300 ulonglong lost_connections,
301 ulonglong access_denied_errors,
302 ulonglong empty_queries)
303{
304 thread_stats->total_connections += total_connections;
305 thread_stats->concurrent_connections += concurrent_connections;
306 thread_stats->connected_time += connected_time;
307 thread_stats->busy_time += busy_time;
308 thread_stats->cpu_time += cpu_time;
309 thread_stats->bytes_received += bytes_received;
310 thread_stats->bytes_sent += bytes_sent;
311 thread_stats->binlog_bytes_written += binlog_bytes_written;
312 thread_stats->rows_fetched += rows_fetched;
313 thread_stats->rows_updated += rows_updated;
314 thread_stats->rows_read += rows_read;
315 thread_stats->select_commands += select_commands;
316 thread_stats->update_commands += update_commands;
317 thread_stats->other_commands += other_commands;
318 thread_stats->commit_trans += commit_trans;
319 thread_stats->rollback_trans += rollback_trans;
320 thread_stats->denied_connections += denied_connections;
321 thread_stats->lost_connections += lost_connections;
322 thread_stats->access_denied_errors += access_denied_errors;
323 thread_stats->empty_queries += empty_queries;
324}
325
326void init_global_user_stats(void)
327{
328 if (hash_init(&global_user_stats, system_charset_info, max_connections,
329 0, 0, (hash_get_key)get_key_user_stats,
330 (hash_free_key)free_user_stats, 0)) {
331 sql_print_error("Initializing global_user_stats failed.");
332 exit(1);
333 }
334}
335224
336void init_global_client_stats(void)225void init_global_client_stats(void)
337{226{
227 DBUG_ENTER("init_global_client_stats");
338 if (hash_init(&global_client_stats, system_charset_info, max_connections,228 if (hash_init(&global_client_stats, system_charset_info, max_connections,
339 0, 0, (hash_get_key)get_key_user_stats,229 0, 0, (hash_get_key)get_key_user_stats,
340 (hash_free_key)free_user_stats, 0)) {230 (hash_free_key)free_user_stats, 0))
341 sql_print_error("Initializing global_client_stats failed.");231 {
342 exit(1);232 sql_print_error("Initializing global_client_stats failed.");
343 }233 exit(1);
344}234 }
345235 DBUG_VOID_RETURN;
346void init_global_thread_stats(void)236}
347{237
348 if (hash_init(&global_thread_stats, &my_charset_bin, max_connections,238
349 0, 0, (hash_get_key)get_key_thread_stats,239void init_global_index_stats(void)
350 (hash_free_key)free_thread_stats, 0)) {240{
351 sql_print_error("Initializing global_client_stats failed.");241 if (hash_init(&global_index_stats, system_charset_info, max_connections,
352 exit(1);242 0, 0, (hash_get_key)get_key_index_stats,
353 }243 (hash_free_key)free_index_stats, 0))
354}244 {
355245 sql_print_error("Initializing global_index_stats failed.");
356extern "C" uchar *get_key_table_stats(TABLE_STATS *table_stats, size_t *length,246 exit(1);
357 my_bool not_used __attribute__((unused)))247 }
358{248}
359 *length = strlen(table_stats->table);249
360 return (uchar*)table_stats->table;
361}
362
363extern "C" void free_table_stats(TABLE_STATS* table_stats)
364{
365 my_free((char*)table_stats, MYF(0));
366}
367250
368void init_global_table_stats(void)251void init_global_table_stats(void)
369{252{
253 DBUG_ENTER("init_global_table_stats");
370 if (hash_init(&global_table_stats, system_charset_info, max_connections,254 if (hash_init(&global_table_stats, system_charset_info, max_connections,
371 0, 0, (hash_get_key)get_key_table_stats,255 0, 0, (hash_get_key)get_key_table_stats,
372 (hash_free_key)free_table_stats, 0)) {256 (hash_free_key)free_table_stats, 0))
257 {
373 sql_print_error("Initializing global_table_stats failed.");258 sql_print_error("Initializing global_table_stats failed.");
374 exit(1);259 exit(1);
375 }260 }
376}261 DBUG_VOID_RETURN;
377262}
378extern "C" uchar *get_key_index_stats(INDEX_STATS *index_stats, size_t *length,263
379 my_bool not_used __attribute__((unused)))264
380{265void init_global_thread_stats(void)
381 *length = strlen(index_stats->index);266{
382 return (uchar*)index_stats->index;267 DBUG_ENTER("init_global_thread_stats");
383}268 if (hash_init(&global_thread_stats, &my_charset_bin, max_connections,
384269 0, 0, (hash_get_key)get_key_thread_stats,
385extern "C" void free_index_stats(INDEX_STATS* index_stats)270 (hash_free_key)free_thread_stats, 0))
386{271 {
387 my_free((char*)index_stats, MYF(0));272 sql_print_error("Initializing global_thread_stats failed.");
388}273 exit(1);
389274 }
390void init_global_index_stats(void)275 DBUG_VOID_RETURN;
391{276}
392 if (hash_init(&global_index_stats, system_charset_info, max_connections,277
393 0, 0, (hash_get_key)get_key_index_stats,278
394 (hash_free_key)free_index_stats, 0)) {279void init_global_user_stats(void)
395 sql_print_error("Initializing global_index_stats failed.");280{
396 exit(1);281 DBUG_ENTER("init_global_user_stats");
397 }282 if (hash_init(&global_user_stats, system_charset_info, max_connections,
398}283 0, 0, (hash_get_key)get_key_user_stats,
399284 (hash_free_key)free_user_stats, 0))
400void free_global_user_stats(void)285 {
401{286 sql_print_error("Initializing global_user_stats failed.");
402 hash_free(&global_user_stats);287 exit(1);
403}288 }
404289 DBUG_VOID_RETURN;
405void free_global_thread_stats(void)290}
406{291
407 hash_free(&global_thread_stats);292
408}293/* 'mysql_system_user' is used for when the user is not defined for a THD. */
409294static char mysql_system_user[]= "#mysql_system#";
410void free_global_table_stats(void)295
411{296/**
412 hash_free(&global_table_stats);297 Stringify the user name (system user too)
413}298
414299 @retval user if user is not NULL.
415void free_global_index_stats(void)300 @retval mysqld_system_user if user is NULL.
416{301*/
417 hash_free(&global_index_stats);302static const char* get_valid_user_string(const char* user)
418}303{
419
420void free_global_client_stats(void)
421{
422 hash_free(&global_client_stats);
423}
424
425// 'mysql_system_user' is used for when the user is not defined for a THD.
426static char mysql_system_user[] = "#mysql_system#";
427
428// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
429static char* get_valid_user_string(char* user) {
430 return user ? user : mysql_system_user;304 return user ? user : mysql_system_user;
431}305}
432306
433// Increments the global stats connection count for an entry from307/**
434// global_client_stats or global_user_stats. Returns 0 on success308 Increments the global stats connection count for an entry from
435// and 1 on error.309 global_client_stats or global_user_stats.
436static int increment_count_by_name(const char *name, const char *role_name,310
437 HASH *users_or_clients, THD *thd)311 @retval 0 on success.
312 @retval 1 on error.
313*/
314static int increment_count_by_name(const char *name,
315 HASH *collection,
316 THD *thd)
438{317{
439 USER_STATS* user_stats;318 DBUG_ENTER("increment_count_by_name");
319 USER_STATS* stats;
440320
441 if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, (uchar*) name,321 if (!(stats= (USER_STATS*)hash_search(collection,
442 strlen(name))))322 (uchar*) name,
323 strlen(name))))
443 {324 {
444 // First connection for this user or client325 /* First connection for this user or client */
445 if (!(user_stats = ((USER_STATS*)326 if (!(stats= ((USER_STATS*)my_malloc(sizeof(USER_STATS),
446 my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))327 MYF(MY_WME | MY_ZEROFILL)))))
447 {328 {
448 return 1; // Out of memory329 /* Out of memory */
330 DBUG_RETURN(1);
449 }331 }
450332
451 init_user_stats(user_stats, name, role_name,333 init_user_stats(stats, name);
452 0, 0, // connections334 stats->stats.denied_connections= thd->diff_stats.denied_connections;
453 0, 0, 0, // time
454 0, 0, 0, // bytes sent, received and written
455 0, 0, 0, // rows fetched, updated and read
456 0, 0, 0, // select, update and other commands
457 0, 0, // commit and rollback trans
458 thd->diff_denied_connections,
459 0, // lost connections
460 0, // access denied errors
461 0); // empty queries
462335
463 if (my_hash_insert(users_or_clients, (uchar*)user_stats))336 if (my_hash_insert(collection, (uchar*)stats))
464 {337 {
465 my_free((char*)user_stats, 0);338 my_free((char*)stats, 0);
466 return 1; // Out of memory339 /* Out of memory */
340 DBUG_RETURN(1);
467 }341 }
468 }342 }
469 user_stats->total_connections++;343 stats->stats.total_connections++;
470 return 0;344 DBUG_RETURN(0);
471}345}
472346
473static int increment_count_by_id(my_thread_id id,347static int increment_count_by_id(my_thread_id id,
474 HASH *users_or_clients, THD *thd)348 HASH *collection,
349 THD *thd)
475{350{
476 THREAD_STATS* thread_stats;351 DBUG_ENTER("increment_count_by_id");
352 THREAD_STATS* stats;
477353
478 if (!(thread_stats = (THREAD_STATS*)hash_search(users_or_clients, (uchar*) &id,354 if (!(stats= (THREAD_STATS*)hash_search(collection,
479 sizeof(my_thread_id))))355 (uchar*) &id,
356 sizeof(my_thread_id))))
480 {357 {
481 // First connection for this user or client358 /* First connection for this user or client */
482 if (!(thread_stats = ((THREAD_STATS*)359 if (!(stats= ((THREAD_STATS*)my_malloc(sizeof(THREAD_STATS),
483 my_malloc(sizeof(THREAD_STATS), MYF(MY_WME | MY_ZEROFILL)))))360 MYF(MY_WME | MY_ZEROFILL)))))
484 {361 {
485 return 1; // Out of memory362 /* Out of memory */
363 DBUG_RETURN(1);
486 }364 }
487365
488 init_thread_stats(thread_stats, id,366 init_thread_stats(stats, id);
489 0, 0, // connections367 stats->stats.denied_connections= thd->diff_stats.denied_connections;
490 0, 0, 0, // time368 if (my_hash_insert(collection, (uchar*)stats))
491 0, 0, 0, // bytes sent, received and written
492 0, 0, 0, // rows fetched, updated and read
493 0, 0, 0, // select, update and other commands
494 0, 0, // commit and rollback trans
495 thd->diff_denied_connections,
496 0, // lost connections
497 0, // access denied errors
498 0); // empty queries
499
500 if (my_hash_insert(users_or_clients, (uchar*)thread_stats))
501 {369 {
502 my_free((char*)thread_stats, 0);370 my_free((char*)stats, 0);
503 return 1; // Out of memory371 /* Out of memory */
372 DBUG_RETURN(1);
504 }373 }
505 }374 }
506 thread_stats->total_connections++;375 stats->stats.total_connections++;
507 return 0;376 DBUG_RETURN(0);
508}377}
509378
510// Increments the global user and client stats connection count. If 'use_lock'379/**
511// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns380 Increments the global client, thread and user stats connection count.
512// 0 on success, 1 on error.381
513static int increment_connection_count(THD* thd, bool use_lock)382 @retval 0 on success.
383 @retval 1 on error.
384*/
385static int increment_connection_count(THD* thd)
514{386{
515 char* user_string = get_valid_user_string(thd->main_security_ctx.user);387 DBUG_ENTER("increment_connection_count");
516 const char* client_string = get_client_host(thd);388 const char* user_string= get_valid_user_string(thd->main_security_ctx.user);
517 int return_value = 0;389 const char* client_string= get_client_host(thd);
390 int return_value= 0;
518391
519 if (!opt_userstat_running)392 if (!opt_userstat_running)
520 return return_value;
521
522 if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
523
524 if (increment_count_by_name(user_string, user_string,
525 &global_user_stats, thd))
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches