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

Proposed by Oleg Tsarev on 2012-02-02
Status: Superseded
Proposed branch: lp:~tsarev/percona-server/5.1_fix_bug_728082
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_728082
Reviewer Review Type Date Requested Status
Percona developers 2012-02-02 Pending
Review via email: mp+91204@code.launchpad.net

This proposal supersedes a proposal from 2012-01-29.

This proposal has been superseded by a proposal from 2012-02-02.

Description of the change

Changes related to userstat feature

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

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).

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 #608027). 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.

Unmerged revisions

418. By Oleg Tsarev on 2012-01-28

update from lp:percona-server/5.1

417. By Oleg Tsarev on 2012-01-28

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 #608027). 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

416. By Oleg Tsarev on 2012-01-28

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).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Percona-Server/mysql-test/include/show_stats.inc'
2--- Percona-Server/mysql-test/include/show_stats.inc 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/include/show_stats.inc 2012-02-02 06:08:22 +0000
4@@ -0,0 +1,78 @@
5+--disable_query_log
6+
7+set global userstat_running=OFF;
8+set global thread_statistics=OFF;
9+
10+--let found=`select count(*) from information_schema.processlist where user='$user'`
11+
12+if ($found)
13+{
14+
15+--let host=`select Host from information_schema.processlist where user='$user'`
16+--let thread=`select Id from information_schema.processlist where user='$user'`
17+
18+eval select count(*) as Host from information_schema.client_statistics where client='$host';
19+eval select count(*) as Thread from information_schema.thread_statistics where thread_id='$thread';
20+eval select count(*) as User from information_schema.user_statistics where user='$user';
21+}
22+
23+# 3 - client_statistics
24+# 2 - thread_statistics
25+# 1 - user_statistics
26+# 0 - complete loop
27+
28+--let i=3
29+
30+while($i)
31+{
32+
33+--let client_query=show client_statistics like '$host'
34+--let thread_query=show thread_statistics like '$thread'
35+--let user_query=show user_statistics like '$user'
36+--let show_like_query=`SELECT CASE $i WHEN 3 THEN "$client_query" WHEN 2 THEN "$thread_query" WHEN 1 THEN "$user_query" END`
37+
38+--let client_query=show client_statistics where Client='$host'
39+--let thread_query=show thread_statistics where Thread_id='$thread'
40+--let user_query=show user_statistics where User='$user'
41+--let show_where_query=`SELECT CASE $i WHEN 3 THEN "$client_query" WHEN 2 THEN "$thread_query" WHEN 1 THEN "$user_query" END`
42+
43+--let client_query=select * from information_schema.client_statistics where Client like '$host'
44+--let thread_query=select * from information_schema.thread_statistics where Thread_id like '$thread'
45+--let user_query=select * from information_schema.user_statistics where User like '$user'
46+--let select_like_query=`SELECT CASE $i WHEN 3 THEN "$client_query" WHEN 2 THEN "$thread_query" WHEN 1 THEN "$user_query" END`
47+
48+--let client_query=select * from information_schema.client_statistics where Client='$host'
49+--let thread_query=select * from information_schema.thread_statistics where Thread_id='$thread'
50+--let user_query=select * from information_schema.user_statistics where User='$user'
51+--let select_where_query=`SELECT CASE $i WHEN 3 THEN "$client_query" WHEN 2 THEN "$thread_query" WHEN 1 THEN "$user_query" END`
52+
53+--let name=`SELECT CASE $i WHEN 3 THEN "Client" WHEN 2 THEN "Thread" WHEN 1 THEN "User" END`
54+
55+--echo #
56+--echo # $name statistics
57+--echo #
58+
59+--echo # SHOW | LIKE
60+--replace_column 1 X 4 X 5 X 6 X 7 X 8 X 9 X
61+eval $show_like_query;
62+
63+--echo # SHOW | WHERE
64+--replace_column 1 X 4 X 5 X 6 X 7 X 8 X 9 X
65+eval $show_where_query;
66+
67+--echo # SELECT | LIKE
68+--replace_column 1 X 4 X 5 X 6 X 7 X 8 X 9 X
69+eval $select_like_query;
70+
71+--echo # SELECT | WHERE
72+--replace_column 1 X 4 X 5 X 6 X 7 X 8 X 9 X
73+eval $select_where_query;
74+
75+dec $i;
76+
77+}
78+
79+set global userstat_running=ON;
80+set global thread_statistics=ON;
81+
82+--enable_query_log
83
84=== added file 'Percona-Server/mysql-test/include/show_table_index_stats.inc'
85--- Percona-Server/mysql-test/include/show_table_index_stats.inc 1970-01-01 00:00:00 +0000
86+++ Percona-Server/mysql-test/include/show_table_index_stats.inc 2012-02-02 06:08:22 +0000
87@@ -0,0 +1,20 @@
88+if ($schema)
89+{
90+if ($table)
91+{
92+
93+eval show table_statistics like '$schema.$table';
94+eval show table_statistics where Table_schema='$schema' and Table_name='$table';
95+eval select * from information_schema.table_statistics where Table_schema like '$schema' and Table_name like '$table';
96+eval select * from information_schema.table_statistics where Table_schema='$schema' and Table_name='$table';
97+
98+if ($index)
99+{
100+eval show index_statistics like '$schema.$table.$index';
101+eval show index_statistics where Table_schema='$schema' and Table_name='$table' and Index_name='$index';
102+eval select * from information_schema.index_statistics where Table_schema like '$schema' and Table_name like '$table' and Index_name like '$index';
103+eval select * from information_schema.index_statistics where Table_schema='$schema' and Table_name='$table' and Index_name='$index';
104+}
105+
106+}
107+}
108
109=== added file 'Percona-Server/mysql-test/r/access_denied.result'
110--- Percona-Server/mysql-test/r/access_denied.result 1970-01-01 00:00:00 +0000
111+++ Percona-Server/mysql-test/r/access_denied.result 2012-02-02 06:08:22 +0000
112@@ -0,0 +1,330 @@
113+create table mysql.user_bak like mysql.user;
114+insert into mysql.user_bak select * from mysql.user;
115+set global userstat_running=ON;
116+grant create user on *.* to mysqltest_1@localhost;
117+grant create user on *.* to mysqltest_2@localhost;
118+drop table if exists t1;
119+drop database if exists mysqltest;
120+flush user_statistics;
121+create database mysqltest;
122+show create database mysqltest;
123+Database Create Database
124+mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
125+create table mysqltest.t1(a int);
126+create table mysqltest.empty(a int);
127+insert into mysqltest.t1 values(1);
128+grant select on `mysqltest`.* to mysqltest_1@localhost;
129+select current_user();
130+current_user()
131+mysqltest_1@localhost
132+select * from mysqltest.empty;
133+a
134+drop database mysqltest;
135+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
136+create database mysqltest_db;
137+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_db'
138+show create database mysqltest_db;
139+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_db'
140+grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
141+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my\_1'
142+grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
143+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my_%'
144+show grants for root@localhost;
145+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql'
146+grant select on `my\_1`.* to mysqltest_2@localhost;
147+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my\_1'
148+mysqltest_1 access_denied=7
149+show user_statistics like 'mysqltest_%';
150+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
151+mysqltest_1 X X X X X X X X X X X X X X X X X X 7 X
152+select current_user();
153+current_user()
154+root@localhost
155+create database information_schema;
156+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
157+alter database information_schema upgrade data directory name;
158+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
159+drop database information_schema;
160+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
161+drop table information_schema.tables;
162+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
163+alter table information_schema.tables;
164+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
165+revoke select on `mysqltest`.* from mysqltest_1@localhost;
166+use information_schema;
167+create temporary table schemata(f1 char(10));
168+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
169+grant all on information_schema.* to 'user1'@'localhost';
170+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
171+grant select on information_schema.* to 'user1'@'localhost';
172+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
173+root access_denied=8
174+show user_statistics like 'root';
175+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
176+root X X X X X X X X X X X X X X X X X X 8 X
177+drop user mysqltest_1@localhost;
178+drop database mysqltest;
179+show tables;
180+Tables_in_test
181+connect(localhost,root,z,test2,MASTER_PORT,MASTER_SOCKET);
182+ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
183+connect(localhost,root,z,test,MASTER_PORT,MASTER_SOCKET);
184+ERROR 28000: Access denied for user 'root'@'localhost' (using password: YES)
185+root access_denied=10
186+show user_statistics like 'root%';
187+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
188+root 2 X X X X X X X X X X X X X X X X X 10 X
189+grant ALL on *.* to test@localhost identified by "gambling";
190+grant ALL on *.* to test@127.0.0.1 identified by "gambling";
191+show tables;
192+Tables_in_test
193+connect(localhost,test,,test2,MASTER_PORT,MASTER_SOCKET);
194+ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
195+connect(localhost,test,,test,MASTER_PORT,MASTER_SOCKET);
196+ERROR 28000: Access denied for user 'test'@'localhost' (using password: NO)
197+connect(localhost,test,zorro,test2,MASTER_PORT,MASTER_SOCKET);
198+ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
199+connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
200+ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
201+test access_denied=4
202+show user_statistics like 'test';
203+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
204+test 1 X X X X X X X X X X X X X X X X X 4 X
205+drop user test@localhost;
206+drop user test@127.0.0.1;
207+flush privileges;
208+SET NAMES binary;
209+create database mysqltest_1;
210+create database mysqltest_2;
211+create table mysqltest_1.t1 select 1 a, 2 q;
212+create table mysqltest_1.t2 select 1 b, 2 r;
213+create table mysqltest_2.t1 select 1 c, 2 s;
214+create table mysqltest_2.t2 select 1 d, 2 t;
215+grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost;
216+grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost;
217+grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost;
218+grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost;
219+SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
220+WHERE GRANTEE = '''mysqltest_3''@''localhost'''
221+ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE;
222+GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
223+'mysqltest_3'@'localhost' NULL mysqltest_1 t1 a UPDATE NO
224+'mysqltest_3'@'localhost' NULL mysqltest_2 t1 c SELECT NO
225+'mysqltest_3'@'localhost' NULL mysqltest_1 t2 b SELECT NO
226+'mysqltest_3'@'localhost' NULL mysqltest_2 t2 d UPDATE NO
227+SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES
228+WHERE GRANTEE = '''mysqltest_3''@''localhost'''
229+ORDER BY TABLE_NAME,PRIVILEGE_TYPE;
230+GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE
231+SELECT * from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES
232+WHERE GRANTEE = '''mysqltest_3''@''localhost'''
233+ORDER BY TABLE_SCHEMA,PRIVILEGE_TYPE;
234+GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE
235+SELECT * from INFORMATION_SCHEMA.USER_PRIVILEGES
236+WHERE GRANTEE = '''mysqltest_3''@''localhost'''
237+ ORDER BY TABLE_CATALOG,PRIVILEGE_TYPE;
238+GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE
239+'mysqltest_3'@'localhost' NULL USAGE NO
240+mysqltest_3 access_denied=0
241+show user_statistics like 'mysqltest_3';
242+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
243+mysqltest_3 X X X X X X X X X X X X X X X X X X 0 X
244+update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1;
245+ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for column 'q' in table 't1'
246+update mysqltest_1.t2, mysqltest_2.t2 set d=20 where d=1;
247+ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'd' in table 't2'
248+update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1;
249+ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't1'
250+update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1;
251+ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1'
252+update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2;
253+ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 's' in table 't1'
254+mysqltest_3 access_denied=5
255+show user_statistics like 'mysqltest_3';
256+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
257+mysqltest_3 X X X X X X X X X X X X X X X X X X 5 X
258+update mysqltest_1.t1, mysqltest_2.t2 set a=10,d=10;
259+update mysqltest_1.t1, mysqltest_2.t1 set a=20 where c=20;
260+select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
261+a q b r
262+10 2 1 2
263+select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
264+c s d t
265+1 2 10 2
266+revoke all on mysqltest_1.t1 from mysqltest_3@localhost;
267+revoke all on mysqltest_1.t2 from mysqltest_3@localhost;
268+revoke all on mysqltest_2.t1 from mysqltest_3@localhost;
269+revoke all on mysqltest_2.t2 from mysqltest_3@localhost;
270+grant all on mysqltest_2.* to mysqltest_3@localhost;
271+grant select on *.* to mysqltest_3@localhost;
272+grant select on mysqltest_2.t1 to mysqltest_3@localhost;
273+flush privileges;
274+use mysqltest_1;
275+update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600;
276+update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
277+ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1'
278+use mysqltest_2;
279+update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
280+ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1'
281+update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200;
282+ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't2'
283+update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200;
284+ERROR 42000: UPDATE command denied to user 'mysqltest_3'@'localhost' for table 't1'
285+mysqltest_3 access_denied=9
286+show user_statistics like 'mysqltest_3';
287+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
288+mysqltest_3 2 X X X X X X X X X X X X X X X X X 9 X
289+select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
290+a q b r
291+10 2 1 2
292+select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
293+c s d t
294+500 2 600 2
295+delete from mysql.user where user='mysqltest_3';
296+delete from mysql.db where user="mysqltest_3";
297+delete from mysql.tables_priv where user="mysqltest_3";
298+delete from mysql.columns_priv where user="mysqltest_3";
299+flush privileges;
300+drop database mysqltest_1;
301+drop database mysqltest_2;
302+create database mysqltest_2;
303+grant select, insert, update on `mysqltest\_2`.* to mysqltest_1@localhost;
304+set sql_log_off = 1;
305+ERROR 42000: Access denied; you need the SUPER privilege for this operation
306+set sql_log_bin = 0;
307+ERROR 42000: Access denied; you need the SUPER privilege for this operation
308+mysqltest_2 access_denied=2
309+show user_statistics like 'mysqltest_2';
310+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
311+mysqltest_2 X X X X X X X X X X X X X X X X X X 2 X
312+revoke select, insert, update on `mysqltest\_2`.* from mysqltest_1@localhost;
313+delete from mysql.user where user like 'mysqltest\_2';
314+delete from mysql.db where user like 'mysqltest\_2';
315+drop database mysqltest_2;
316+flush privileges;
317+drop database if exists db2;
318+create database db2;
319+use db2;
320+create table t2 (s1 int);
321+insert into t2 values (0);
322+grant usage on db2.* to user1@localhost;
323+grant select on db2.* to user1@localhost;
324+grant usage on db2.* to user2@localhost;
325+grant select,insert,update,delete,create routine on db2.* to user2@localhost;
326+grant create routine on db2.* to user1@localhost;
327+flush privileges;
328+use db2;
329+create procedure p () insert into t2 values (1);
330+use db2;
331+call p();
332+ERROR 42000: execute command denied to user 'user2'@'localhost' for routine 'db2.p'
333+show user_statistics like 'user%';
334+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
335+user2 X X X X X X X X X X X X X X X X X X 1 X
336+user1 X X X X X X X X X X X X X X X X X X 0 X
337+create procedure q () insert into t2 values (2);
338+grant usage on procedure db2.q to user2@localhost with grant option;
339+grant execute on procedure db2.q to user1@localhost;
340+use db2;
341+alter procedure p modifies sql data;
342+drop procedure p;
343+alter procedure q modifies sql data;
344+ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db2.q'
345+drop procedure q;
346+ERROR 42000: alter routine command denied to user 'user1'@'localhost' for routine 'db2.q'
347+user1 access_denied=2, user2 access_denied=1
348+show user_statistics like 'user%';
349+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
350+user2 X X X X X X X X X X X X X X X X X X 1 X
351+user1 X X X X X X X X X X X X X X X X X X 2 X
352+use db2;
353+alter procedure q modifies sql data;
354+drop procedure q;
355+revoke all on db2.* from user1@localhost;
356+revoke all on db2.* from user2@localhost;
357+flush privileges;
358+use test;
359+select type,db,name from mysql.proc;
360+type db name
361+PROCEDURE mtr add_suppression
362+PROCEDURE mtr check_testcase
363+PROCEDURE mtr check_warnings
364+PROCEDURE mtr force_restart
365+drop database db2;
366+select type,db,name from mysql.proc;
367+type db name
368+PROCEDURE mtr add_suppression
369+PROCEDURE mtr check_testcase
370+PROCEDURE mtr check_warnings
371+PROCEDURE mtr force_restart
372+delete from mysql.user where user='user1' or user='user2';
373+delete from mysql.user where user='' and host='%';
374+delete from mysql.procs_priv where user='user1' or user='user2';
375+delete from mysql.procs_priv where user='' and host='%';
376+delete from mysql.db where user='user2';
377+flush privileges;
378+grant usage on *.* to usera@localhost;
379+grant usage on *.* to userb@localhost;
380+grant usage on *.* to userc@localhost;
381+create database sptest;
382+create table t1 ( u varchar(64), i int );
383+create procedure sptest.p1(i int) insert into test.t1 values (user(), i);
384+grant insert on t1 to usera@localhost;
385+grant execute on procedure sptest.p1 to usera@localhost;
386+show grants for usera@localhost;
387+Grants for usera@localhost
388+GRANT USAGE ON *.* TO 'usera'@'localhost'
389+GRANT INSERT ON `test`.`t1` TO 'usera'@'localhost'
390+GRANT EXECUTE ON PROCEDURE `sptest`.`p1` TO 'usera'@'localhost'
391+grant execute on procedure sptest.p1 to userc@localhost with grant option;
392+show grants for userc@localhost;
393+Grants for userc@localhost
394+GRANT USAGE ON *.* TO 'userc'@'localhost'
395+GRANT EXECUTE ON PROCEDURE `sptest`.`p1` TO 'userc'@'localhost' WITH GRANT OPTION
396+call sptest.p1(1);
397+grant execute on procedure sptest.p1 to userb@localhost;
398+ERROR 42000: grant command denied to user 'usera'@'localhost' for routine 'sptest.p1'
399+drop procedure sptest.p1;
400+ERROR 42000: alter routine command denied to user 'usera'@'localhost' for routine 'sptest.p1'
401+usera access_denied=2
402+show user_statistics like 'usera%';
403+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
404+usera X X X X X X X X X X X X X X X X X X 2 X
405+call sptest.p1(2);
406+ERROR 42000: execute command denied to user 'userb'@'localhost' for routine 'sptest.p1'
407+grant execute on procedure sptest.p1 to userb@localhost;
408+ERROR 42000: execute command denied to user 'userb'@'localhost' for routine 'sptest.p1'
409+drop procedure sptest.p1;
410+ERROR 42000: alter routine command denied to user 'userb'@'localhost' for routine 'sptest.p1'
411+userb access_denied=3
412+show user_statistics like 'userb';
413+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
414+userb X X X X X X X X X X X X X X X X X X 3 X
415+call sptest.p1(3);
416+grant execute on procedure sptest.p1 to userb@localhost;
417+drop procedure sptest.p1;
418+ERROR 42000: alter routine command denied to user 'userc'@'localhost' for routine 'sptest.p1'
419+userc access_denied=1
420+show user_statistics like 'userc';
421+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
422+userc X X X X X X X X X X X X X X X X X X 1 X
423+call sptest.p1(4);
424+grant execute on procedure sptest.p1 to userb@localhost;
425+ERROR 42000: grant command denied to user 'userb'@'localhost' for routine 'sptest.p1'
426+drop procedure sptest.p1;
427+ERROR 42000: alter routine command denied to user 'userb'@'localhost' for routine 'sptest.p1'
428+userb access_denied=5
429+show user_statistics like 'userb';
430+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
431+userb X X X X X X X X X X X X X X X X X X 5 X
432+use test;
433+drop database sptest;
434+delete from mysql.user where user='usera' or user='userb' or user='userc';
435+delete from mysql.procs_priv where user='usera' or user='userb' or user='userc';
436+delete from mysql.tables_priv where user='usera';
437+flush privileges;
438+drop table t1;
439+set global userstat_running=default;
440+delete from mysql.user;
441+insert into mysql.user select * from mysql.user_bak;
442+drop table mysql.user_bak;
443
444=== added file 'Percona-Server/mysql-test/r/show_stats.result'
445--- Percona-Server/mysql-test/r/show_stats.result 1970-01-01 00:00:00 +0000
446+++ Percona-Server/mysql-test/r/show_stats.result 2012-02-02 06:08:22 +0000
447@@ -0,0 +1,1735 @@
448+drop table if exists t1;
449+update mysql.db set User = 'hide' where User = '';
450+create table mysql.user_bak like mysql.user;
451+insert into mysql.user_bak select * from mysql.user where length(User) = 0;
452+delete from mysql.user where length(User) = 0;
453+flush privileges;
454+SET GLOBAL DEBUG='+d,signal_end_connection';
455+create table t2 (a int not null primary key, b int not null) engine=innodb;
456+create table t3 (a int not null primary key, b int not null, index bx(b)) engine=myisam;
457+set global userstat_running=ON;
458+set global thread_statistics=ON;
459+flush client_statistics;
460+flush thread_statistics;
461+flush user_statistics;
462+Host
463+1
464+Thread
465+1
466+User
467+1
468+#
469+# Client statistics
470+#
471+# SHOW | LIKE
472+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
473+X 1 1 X X X X X X 0 0 0 0 0 2 0 0 0 0 0 0
474+# SHOW | WHERE
475+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
476+X 1 1 X X X X X X 0 0 0 0 0 2 0 0 0 0 0 0
477+# SELECT | LIKE
478+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
479+X 1 1 X X X X X X 0 0 0 0 0 2 0 0 0 0 0 0
480+# SELECT | WHERE
481+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
482+X 1 1 X X X X X X 0 0 0 0 0 2 0 0 0 0 0 0
483+#
484+# Thread statistics
485+#
486+# SHOW | LIKE
487+Thread_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
488+X 1 0 X X X X X X 0 0 0 0 0 1 0 0 0 0 0 0
489+# SHOW | WHERE
490+Thread_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
491+X 1 0 X X X X X X 0 0 0 0 0 1 0 0 0 0 0 0
492+# SELECT | LIKE
493+THREAD_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
494+X 1 0 X X X X X X 0 0 0 0 0 1 0 0 0 0 0 0
495+# SELECT | WHERE
496+THREAD_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
497+X 1 0 X X X X X X 0 0 0 0 0 1 0 0 0 0 0 0
498+#
499+# User statistics
500+#
501+# SHOW | LIKE
502+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
503+X 1 1 X X X X X X 0 0 0 0 0 0 0 0 0 0 0 0
504+# SHOW | WHERE
505+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
506+X 1 1 X X X X X X 0 0 0 0 0 0 0 0 0 0 0 0
507+# SELECT | LIKE
508+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
509+X 1 1 X X X X X X 0 0 0 0 0 0 0 0 0 0 0 0
510+# SELECT | WHERE
511+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
512+X 1 1 X X X X X X 0 0 0 0 0 0 0 0 0 0 0 0
513+flush client_statistics;
514+flush thread_statistics;
515+flush user_statistics;
516+create table t1 (a int not null primary key, b int not null) engine=innodb;
517+Host
518+1
519+Thread
520+1
521+User
522+1
523+#
524+# Client statistics
525+#
526+# SHOW | LIKE
527+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
528+X 1 1 X X X X X X 0 0 0 0 1 2 0 0 0 0 0 0
529+# SHOW | WHERE
530+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
531+X 1 1 X X X X X X 0 0 0 0 1 2 0 0 0 0 0 0
532+# SELECT | LIKE
533+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
534+X 1 1 X X X X X X 0 0 0 0 1 2 0 0 0 0 0 0
535+# SELECT | WHERE
536+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
537+X 1 1 X X X X X X 0 0 0 0 1 2 0 0 0 0 0 0
538+#
539+# Thread statistics
540+#
541+# SHOW | LIKE
542+Thread_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
543+X 1 0 X X X X X X 0 0 0 0 1 1 0 0 0 0 0 0
544+# SHOW | WHERE
545+Thread_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
546+X 1 0 X X X X X X 0 0 0 0 1 1 0 0 0 0 0 0
547+# SELECT | LIKE
548+THREAD_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
549+X 1 0 X X X X X X 0 0 0 0 1 1 0 0 0 0 0 0
550+# SELECT | WHERE
551+THREAD_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
552+X 1 0 X X X X X X 0 0 0 0 1 1 0 0 0 0 0 0
553+#
554+# User statistics
555+#
556+# SHOW | LIKE
557+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
558+X 1 1 X X X X X X 0 0 0 0 1 0 0 0 0 0 0 0
559+# SHOW | WHERE
560+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
561+X 1 1 X X X X X X 0 0 0 0 1 0 0 0 0 0 0 0
562+# SELECT | LIKE
563+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
564+X 1 1 X X X X X X 0 0 0 0 1 0 0 0 0 0 0 0
565+# SELECT | WHERE
566+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
567+X 1 1 X X X X X X 0 0 0 0 1 0 0 0 0 0 0 0
568+flush client_statistics;
569+flush thread_statistics;
570+flush user_statistics;
571+flush table_statistics;
572+flush index_statistics;
573+insert into t1 values (1,1), (2,2);
574+Host
575+1
576+Thread
577+1
578+User
579+1
580+#
581+# Client statistics
582+#
583+# SHOW | LIKE
584+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
585+X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
586+# SHOW | WHERE
587+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
588+X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
589+# SELECT | LIKE
590+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
591+X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
592+# SELECT | WHERE
593+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
594+X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
595+#
596+# Thread statistics
597+#
598+# SHOW | LIKE
599+Thread_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
600+X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
601+# SHOW | WHERE
602+Thread_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
603+X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
604+# SELECT | LIKE
605+THREAD_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
606+X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
607+# SELECT | WHERE
608+THREAD_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
609+X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
610+#
611+# User statistics
612+#
613+# SHOW | LIKE
614+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
615+X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
616+# SHOW | WHERE
617+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
618+X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
619+# SELECT | LIKE
620+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
621+X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
622+# SELECT | WHERE
623+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
624+X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
625+show table_statistics like 'test.t1';
626+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
627+test t1 0 2 2
628+show table_statistics where Table_schema='test' and Table_name='t1';
629+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
630+test t1 0 2 2
631+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
632+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
633+test t1 0 2 2
634+select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
635+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
636+test t1 0 2 2
637+create table test.tmy(i int) engine=myisam;
638+insert into test.tmy values (1);
639+show table_statistics like 'test.tmy';
640+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
641+test tmy 0 1 1
642+show table_statistics where Table_schema='test' and Table_name='tmy';
643+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
644+test tmy 0 1 1
645+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 'tmy';
646+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
647+test tmy 0 1 1
648+select * from information_schema.table_statistics where Table_schema='test' and Table_name='tmy';
649+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
650+test tmy 0 1 1
651+drop table test.tmy;
652+show table_statistics like 'test.t1';
653+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
654+test t1 0 2 2
655+show table_statistics where Table_schema='test' and Table_name='t1';
656+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
657+test t1 0 2 2
658+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
659+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
660+test t1 0 2 2
661+select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
662+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
663+test t1 0 2 2
664+""
665+Test insert select
666+""
667+flush client_statistics;
668+flush thread_statistics;
669+flush user_statistics;
670+flush table_statistics;
671+flush index_statistics;
672+insert into t2 select * from t1;
673+Host
674+1
675+Thread
676+1
677+User
678+1
679+#
680+# Client statistics
681+#
682+# SHOW | LIKE
683+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
684+X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
685+# SHOW | WHERE
686+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
687+X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
688+# SELECT | LIKE
689+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
690+X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
691+# SELECT | WHERE
692+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
693+X 1 1 X X X X X X 0 2 0 0 1 4 0 0 0 0 0 0
694+#
695+# Thread statistics
696+#
697+# SHOW | LIKE
698+Thread_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
699+X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
700+# SHOW | WHERE
701+Thread_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
702+X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
703+# SELECT | LIKE
704+THREAD_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
705+X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
706+# SELECT | WHERE
707+THREAD_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
708+X 1 0 X X X X X X 0 2 0 0 1 3 0 0 0 0 0 0
709+#
710+# User statistics
711+#
712+# SHOW | LIKE
713+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
714+X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
715+# SHOW | WHERE
716+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
717+X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
718+# SELECT | LIKE
719+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
720+X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
721+# SELECT | WHERE
722+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
723+X 1 1 X X X X X X 0 2 0 0 1 2 0 0 0 0 0 0
724+show table_statistics like 'test.t1';
725+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
726+test t1 2 0 0
727+show table_statistics where Table_schema='test' and Table_name='t1';
728+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
729+test t1 2 0 0
730+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
731+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
732+test t1 2 0 0
733+select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
734+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
735+test t1 2 0 0
736+show index_statistics like 'test.t1.PRIMARY';
737+Table_schema Table_name Index_name Rows_read
738+test t1 PRIMARY 2
739+show index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
740+Table_schema Table_name Index_name Rows_read
741+test t1 PRIMARY 2
742+select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't1' and Index_name like 'PRIMARY';
743+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
744+test t1 PRIMARY 2
745+select * from information_schema.index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
746+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
747+test t1 PRIMARY 2
748+show table_statistics like 'test.t2';
749+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
750+test t2 0 2 2
751+show table_statistics where Table_schema='test' and Table_name='t2';
752+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
753+test t2 0 2 2
754+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't2';
755+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
756+test t2 0 2 2
757+select * from information_schema.table_statistics where Table_schema='test' and Table_name='t2';
758+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
759+test t2 0 2 2
760+""
761+Test update with PK scans
762+""
763+insert into t1 values (0,0);
764+select count(*) from t1;
765+count(*)
766+3
767+flush client_statistics;
768+flush thread_statistics;
769+flush user_statistics;
770+flush table_statistics;
771+flush index_statistics;
772+update t1 set a = 3 where a = 1;
773+Host
774+1
775+Thread
776+1
777+User
778+1
779+#
780+# Client statistics
781+#
782+# SHOW | LIKE
783+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
784+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
785+# SHOW | WHERE
786+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
787+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
788+# SELECT | LIKE
789+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
790+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
791+# SELECT | WHERE
792+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
793+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
794+#
795+# Thread statistics
796+#
797+# SHOW | LIKE
798+Thread_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
799+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
800+# SHOW | WHERE
801+Thread_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
802+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
803+# SELECT | LIKE
804+THREAD_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
805+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
806+# SELECT | WHERE
807+THREAD_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
808+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
809+#
810+# User statistics
811+#
812+# SHOW | LIKE
813+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
814+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
815+# SHOW | WHERE
816+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
817+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
818+# SELECT | LIKE
819+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
820+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
821+# SELECT | WHERE
822+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
823+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
824+update t1 set a = 4 where b = 2;
825+Host
826+1
827+Thread
828+1
829+User
830+1
831+#
832+# Client statistics
833+#
834+# SHOW | LIKE
835+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
836+X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
837+# SHOW | WHERE
838+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
839+X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
840+# SELECT | LIKE
841+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
842+X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
843+# SELECT | WHERE
844+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
845+X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
846+#
847+# Thread statistics
848+#
849+# SHOW | LIKE
850+Thread_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
851+X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
852+# SHOW | WHERE
853+Thread_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
854+X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
855+# SELECT | LIKE
856+THREAD_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
857+X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
858+# SELECT | WHERE
859+THREAD_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
860+X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
861+#
862+# User statistics
863+#
864+# SHOW | LIKE
865+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
866+X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
867+# SHOW | WHERE
868+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
869+X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
870+# SELECT | LIKE
871+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
872+X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
873+# SELECT | WHERE
874+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
875+X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
876+show table_statistics like 'test.t1';
877+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
878+test t1 5 2 2
879+show table_statistics where Table_schema='test' and Table_name='t1';
880+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
881+test t1 5 2 2
882+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
883+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
884+test t1 5 2 2
885+select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
886+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
887+test t1 5 2 2
888+show index_statistics like 'test.t1.PRIMARY';
889+Table_schema Table_name Index_name Rows_read
890+test t1 PRIMARY 5
891+show index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
892+Table_schema Table_name Index_name Rows_read
893+test t1 PRIMARY 5
894+select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't1' and Index_name like 'PRIMARY';
895+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
896+test t1 PRIMARY 5
897+select * from information_schema.index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
898+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
899+test t1 PRIMARY 5
900+update t1 set a = 4 where b < 0;
901+Host
902+1
903+Thread
904+1
905+User
906+1
907+#
908+# Client statistics
909+#
910+# SHOW | LIKE
911+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
912+X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
913+# SHOW | WHERE
914+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
915+X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
916+# SELECT | LIKE
917+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
918+X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
919+# SELECT | WHERE
920+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
921+X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
922+#
923+# Thread statistics
924+#
925+# SHOW | LIKE
926+Thread_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
927+X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
928+# SHOW | WHERE
929+Thread_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
930+X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
931+# SELECT | LIKE
932+THREAD_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
933+X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
934+# SELECT | WHERE
935+THREAD_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
936+X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
937+#
938+# User statistics
939+#
940+# SHOW | LIKE
941+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
942+X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
943+# SHOW | WHERE
944+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
945+X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
946+# SELECT | LIKE
947+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
948+X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
949+# SELECT | WHERE
950+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
951+X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
952+""
953+Test update with secondary index scans and MyISAM
954+""
955+insert into t3 values (0,0);
956+insert into t3 values (1,1);
957+insert into t3 values (2,2);
958+flush client_statistics;
959+flush thread_statistics;
960+flush user_statistics;
961+flush table_statistics;
962+flush index_statistics;
963+update t3 set a = 4 where b = 1;
964+Host
965+1
966+Thread
967+1
968+User
969+1
970+#
971+# Client statistics
972+#
973+# SHOW | LIKE
974+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
975+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
976+# SHOW | WHERE
977+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
978+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
979+# SELECT | LIKE
980+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
981+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
982+# SELECT | WHERE
983+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
984+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
985+#
986+# Thread statistics
987+#
988+# SHOW | LIKE
989+Thread_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
990+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
991+# SHOW | WHERE
992+Thread_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
993+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
994+# SELECT | LIKE
995+THREAD_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
996+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
997+# SELECT | WHERE
998+THREAD_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
999+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
1000+#
1001+# User statistics
1002+#
1003+# SHOW | LIKE
1004+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1005+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1006+# SHOW | WHERE
1007+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1008+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1009+# SELECT | LIKE
1010+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1011+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1012+# SELECT | WHERE
1013+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1014+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1015+show table_statistics like 'test.t3';
1016+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1017+test t3 1 1 2
1018+show table_statistics where Table_schema='test' and Table_name='t3';
1019+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1020+test t3 1 1 2
1021+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't3';
1022+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1023+test t3 1 1 2
1024+select * from information_schema.table_statistics where Table_schema='test' and Table_name='t3';
1025+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1026+test t3 1 1 2
1027+show index_statistics like 'test.t3.bx';
1028+Table_schema Table_name Index_name Rows_read
1029+test t3 bx 1
1030+show index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
1031+Table_schema Table_name Index_name Rows_read
1032+test t3 bx 1
1033+select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't3' and Index_name like 'bx';
1034+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1035+test t3 bx 1
1036+select * from information_schema.index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
1037+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1038+test t3 bx 1
1039+""
1040+Test delete with PK scans
1041+""
1042+flush client_statistics;
1043+flush thread_statistics;
1044+flush user_statistics;
1045+flush table_statistics;
1046+flush index_statistics;
1047+delete from t1 where a = 3;
1048+Host
1049+1
1050+Thread
1051+1
1052+User
1053+1
1054+#
1055+# Client statistics
1056+#
1057+# SHOW | LIKE
1058+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1059+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
1060+# SHOW | WHERE
1061+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1062+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
1063+# SELECT | LIKE
1064+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1065+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
1066+# SELECT | WHERE
1067+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1068+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
1069+#
1070+# Thread statistics
1071+#
1072+# SHOW | LIKE
1073+Thread_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
1074+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
1075+# SHOW | WHERE
1076+Thread_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
1077+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
1078+# SELECT | LIKE
1079+THREAD_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
1080+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
1081+# SELECT | WHERE
1082+THREAD_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
1083+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
1084+#
1085+# User statistics
1086+#
1087+# SHOW | LIKE
1088+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1089+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1090+# SHOW | WHERE
1091+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1092+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1093+# SELECT | LIKE
1094+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1095+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1096+# SELECT | WHERE
1097+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1098+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1099+delete from t1 where b = 2;
1100+Host
1101+1
1102+Thread
1103+1
1104+User
1105+1
1106+#
1107+# Client statistics
1108+#
1109+# SHOW | LIKE
1110+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1111+X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
1112+# SHOW | WHERE
1113+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1114+X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
1115+# SELECT | LIKE
1116+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1117+X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
1118+# SELECT | WHERE
1119+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1120+X 1 1 X X X X X X 0 2 0 0 2 6 0 0 0 0 0 0
1121+#
1122+# Thread statistics
1123+#
1124+# SHOW | LIKE
1125+Thread_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
1126+X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
1127+# SHOW | WHERE
1128+Thread_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
1129+X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
1130+# SELECT | LIKE
1131+THREAD_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
1132+X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
1133+# SELECT | WHERE
1134+THREAD_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
1135+X 1 0 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
1136+#
1137+# User statistics
1138+#
1139+# SHOW | LIKE
1140+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1141+X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
1142+# SHOW | WHERE
1143+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1144+X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
1145+# SELECT | LIKE
1146+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1147+X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
1148+# SELECT | WHERE
1149+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1150+X 1 1 X X X X X X 0 2 0 0 2 4 0 0 0 0 0 0
1151+show table_statistics like 'test.t1';
1152+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1153+test t1 3 2 2
1154+show table_statistics where Table_schema='test' and Table_name='t1';
1155+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1156+test t1 3 2 2
1157+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
1158+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1159+test t1 3 2 2
1160+select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
1161+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1162+test t1 3 2 2
1163+show index_statistics like 'test.t1.PRIMARY';
1164+Table_schema Table_name Index_name Rows_read
1165+test t1 PRIMARY 3
1166+show index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
1167+Table_schema Table_name Index_name Rows_read
1168+test t1 PRIMARY 3
1169+select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't1' and Index_name like 'PRIMARY';
1170+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1171+test t1 PRIMARY 3
1172+select * from information_schema.index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
1173+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1174+test t1 PRIMARY 3
1175+delete from t1 where b < 0;
1176+Host
1177+1
1178+Thread
1179+1
1180+User
1181+1
1182+#
1183+# Client statistics
1184+#
1185+# SHOW | LIKE
1186+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1187+X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
1188+# SHOW | WHERE
1189+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1190+X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
1191+# SELECT | LIKE
1192+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1193+X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
1194+# SELECT | WHERE
1195+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1196+X 1 1 X X X X X X 4 2 0 4 3 12 0 0 0 0 0 0
1197+#
1198+# Thread statistics
1199+#
1200+# SHOW | LIKE
1201+Thread_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
1202+X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
1203+# SHOW | WHERE
1204+Thread_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
1205+X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
1206+# SELECT | LIKE
1207+THREAD_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
1208+X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
1209+# SELECT | WHERE
1210+THREAD_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
1211+X 1 0 X X X X X X 4 2 0 4 3 9 0 0 0 0 0 0
1212+#
1213+# User statistics
1214+#
1215+# SHOW | LIKE
1216+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1217+X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
1218+# SHOW | WHERE
1219+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1220+X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
1221+# SELECT | LIKE
1222+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1223+X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
1224+# SELECT | WHERE
1225+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1226+X 1 1 X X X X X X 4 2 0 4 3 10 0 0 0 0 0 0
1227+""
1228+Test delete with secondary index scans
1229+""
1230+flush client_statistics;
1231+flush thread_statistics;
1232+flush user_statistics;
1233+flush table_statistics;
1234+flush index_statistics;
1235+delete from t3 where b = 1;
1236+Host
1237+1
1238+Thread
1239+1
1240+User
1241+1
1242+#
1243+# Client statistics
1244+#
1245+# SHOW | LIKE
1246+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1247+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
1248+# SHOW | WHERE
1249+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1250+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
1251+# SELECT | LIKE
1252+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1253+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
1254+# SELECT | WHERE
1255+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1256+X 1 1 X X X X X X 0 1 0 0 1 4 0 0 0 0 0 0
1257+#
1258+# Thread statistics
1259+#
1260+# SHOW | LIKE
1261+Thread_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
1262+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
1263+# SHOW | WHERE
1264+Thread_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
1265+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
1266+# SELECT | LIKE
1267+THREAD_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
1268+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
1269+# SELECT | WHERE
1270+THREAD_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
1271+X 1 0 X X X X X X 0 1 0 0 1 3 0 0 0 0 0 0
1272+#
1273+# User statistics
1274+#
1275+# SHOW | LIKE
1276+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1277+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1278+# SHOW | WHERE
1279+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1280+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1281+# SELECT | LIKE
1282+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1283+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1284+# SELECT | WHERE
1285+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1286+X 1 1 X X X X X X 0 1 0 0 1 2 0 0 0 0 0 0
1287+show table_statistics like 'test.t3';
1288+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1289+test t3 1 1 2
1290+show table_statistics where Table_schema='test' and Table_name='t3';
1291+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1292+test t3 1 1 2
1293+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't3';
1294+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1295+test t3 1 1 2
1296+select * from information_schema.table_statistics where Table_schema='test' and Table_name='t3';
1297+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1298+test t3 1 1 2
1299+show index_statistics like 'test.t3.bx';
1300+Table_schema Table_name Index_name Rows_read
1301+test t3 bx 1
1302+show index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
1303+Table_schema Table_name Index_name Rows_read
1304+test t3 bx 1
1305+select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't3' and Index_name like 'bx';
1306+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1307+test t3 bx 1
1308+select * from information_schema.index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
1309+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1310+test t3 bx 1
1311+delete from t3 where b < 0;
1312+Host
1313+1
1314+Thread
1315+1
1316+User
1317+1
1318+#
1319+# Client statistics
1320+#
1321+# SHOW | LIKE
1322+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1323+X 1 1 X X X X X X 4 1 0 4 2 10 0 0 0 0 0 0
1324+# SHOW | WHERE
1325+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1326+X 1 1 X X X X X X 4 1 0 4 2 10 0 0 0 0 0 0
1327+# SELECT | LIKE
1328+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1329+X 1 1 X X X X X X 4 1 0 4 2 10 0 0 0 0 0 0
1330+# SELECT | WHERE
1331+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1332+X 1 1 X X X X X X 4 1 0 4 2 10 0 0 0 0 0 0
1333+#
1334+# Thread statistics
1335+#
1336+# SHOW | LIKE
1337+Thread_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
1338+X 1 0 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
1339+# SHOW | WHERE
1340+Thread_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
1341+X 1 0 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
1342+# SELECT | LIKE
1343+THREAD_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
1344+X 1 0 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
1345+# SELECT | WHERE
1346+THREAD_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
1347+X 1 0 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
1348+#
1349+# User statistics
1350+#
1351+# SHOW | LIKE
1352+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1353+X 1 1 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
1354+# SHOW | WHERE
1355+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1356+X 1 1 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
1357+# SELECT | LIKE
1358+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1359+X 1 1 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
1360+# SELECT | WHERE
1361+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1362+X 1 1 X X X X X X 4 1 0 4 2 8 0 0 0 0 0 0
1363+""
1364+Test select with PK scans
1365+""
1366+insert into t1 values (1,1), (2,2);
1367+flush client_statistics;
1368+flush thread_statistics;
1369+flush user_statistics;
1370+flush table_statistics;
1371+flush index_statistics;
1372+select count(*) from t1 where a = 1;
1373+count(*)
1374+1
1375+Host
1376+1
1377+Thread
1378+1
1379+User
1380+1
1381+#
1382+# Client statistics
1383+#
1384+# SHOW | LIKE
1385+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1386+X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1387+# SHOW | WHERE
1388+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1389+X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1390+# SELECT | LIKE
1391+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1392+X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1393+# SELECT | WHERE
1394+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1395+X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1396+#
1397+# Thread statistics
1398+#
1399+# SHOW | LIKE
1400+Thread_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
1401+X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1402+# SHOW | WHERE
1403+Thread_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
1404+X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1405+# SELECT | LIKE
1406+THREAD_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
1407+X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1408+# SELECT | WHERE
1409+THREAD_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
1410+X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1411+#
1412+# User statistics
1413+#
1414+# SHOW | LIKE
1415+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1416+X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1417+# SHOW | WHERE
1418+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1419+X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1420+# SELECT | LIKE
1421+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1422+X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1423+# SELECT | WHERE
1424+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1425+X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1426+select count(*) from t1 where b < 0;
1427+count(*)
1428+0
1429+Host
1430+1
1431+Thread
1432+1
1433+User
1434+1
1435+#
1436+# Client statistics
1437+#
1438+# SHOW | LIKE
1439+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1440+X 1 1 X X X X X X 2 0 0 2 0 6 0 0 0 0 0 0
1441+# SHOW | WHERE
1442+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1443+X 1 1 X X X X X X 2 0 0 2 0 6 0 0 0 0 0 0
1444+# SELECT | LIKE
1445+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1446+X 1 1 X X X X X X 2 0 0 2 0 6 0 0 0 0 0 0
1447+# SELECT | WHERE
1448+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1449+X 1 1 X X X X X X 2 0 0 2 0 6 0 0 0 0 0 0
1450+#
1451+# Thread statistics
1452+#
1453+# SHOW | LIKE
1454+Thread_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
1455+X 1 0 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1456+# SHOW | WHERE
1457+Thread_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
1458+X 1 0 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1459+# SELECT | LIKE
1460+THREAD_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
1461+X 1 0 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1462+# SELECT | WHERE
1463+THREAD_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
1464+X 1 0 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1465+#
1466+# User statistics
1467+#
1468+# SHOW | LIKE
1469+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1470+X 1 1 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1471+# SHOW | WHERE
1472+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1473+X 1 1 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1474+# SELECT | LIKE
1475+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1476+X 1 1 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1477+# SELECT | WHERE
1478+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1479+X 1 1 X X X X X X 2 0 0 2 0 4 0 0 0 0 0 0
1480+show table_statistics like 'test.t1';
1481+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1482+test t1 4 0 0
1483+show table_statistics where Table_schema='test' and Table_name='t1';
1484+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1485+test t1 4 0 0
1486+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't1';
1487+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1488+test t1 4 0 0
1489+select * from information_schema.table_statistics where Table_schema='test' and Table_name='t1';
1490+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1491+test t1 4 0 0
1492+show index_statistics like 'test.t1.PRIMARY';
1493+Table_schema Table_name Index_name Rows_read
1494+test t1 PRIMARY 4
1495+show index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
1496+Table_schema Table_name Index_name Rows_read
1497+test t1 PRIMARY 4
1498+select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't1' and Index_name like 'PRIMARY';
1499+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1500+test t1 PRIMARY 4
1501+select * from information_schema.index_statistics where Table_schema='test' and Table_name='t1' and Index_name='PRIMARY';
1502+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1503+test t1 PRIMARY 4
1504+""
1505+Test select with secondary scans
1506+""
1507+insert into t3 values (1,1);
1508+analyze table t3;
1509+Table Op Msg_type Msg_text
1510+test.t3 analyze status OK
1511+explain select * from t3 where b < 0;
1512+id select_type table type possible_keys key key_len ref rows Extra
1513+1 SIMPLE t3 range bx bx 4 NULL 1 Using where
1514+flush client_statistics;
1515+flush thread_statistics;
1516+flush user_statistics;
1517+flush table_statistics;
1518+flush index_statistics;
1519+select * from t3 where b = 1;
1520+a b
1521+1 1
1522+Host
1523+1
1524+Thread
1525+1
1526+User
1527+1
1528+#
1529+# Client statistics
1530+#
1531+# SHOW | LIKE
1532+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1533+X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1534+# SHOW | WHERE
1535+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1536+X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1537+# SELECT | LIKE
1538+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1539+X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1540+# SELECT | WHERE
1541+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1542+X 1 1 X X X X X X 1 0 0 1 0 4 0 0 0 0 0 0
1543+#
1544+# Thread statistics
1545+#
1546+# SHOW | LIKE
1547+Thread_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
1548+X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1549+# SHOW | WHERE
1550+Thread_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
1551+X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1552+# SELECT | LIKE
1553+THREAD_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
1554+X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1555+# SELECT | WHERE
1556+THREAD_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
1557+X 1 0 X X X X X X 1 0 0 1 0 3 0 0 0 0 0 0
1558+#
1559+# User statistics
1560+#
1561+# SHOW | LIKE
1562+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1563+X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1564+# SHOW | WHERE
1565+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1566+X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1567+# SELECT | LIKE
1568+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1569+X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1570+# SELECT | WHERE
1571+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1572+X 1 1 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1573+select * from t3 where b < 0;
1574+a b
1575+Host
1576+1
1577+Thread
1578+1
1579+User
1580+1
1581+#
1582+# Client statistics
1583+#
1584+# SHOW | LIKE
1585+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1586+X 1 1 X X X X X X 1 0 0 2 0 6 0 0 0 0 0 1
1587+# SHOW | WHERE
1588+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1589+X 1 1 X X X X X X 1 0 0 2 0 6 0 0 0 0 0 1
1590+# SELECT | LIKE
1591+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1592+X 1 1 X X X X X X 1 0 0 2 0 6 0 0 0 0 0 1
1593+# SELECT | WHERE
1594+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1595+X 1 1 X X X X X X 1 0 0 2 0 6 0 0 0 0 0 1
1596+#
1597+# Thread statistics
1598+#
1599+# SHOW | LIKE
1600+Thread_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
1601+X 1 0 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1602+# SHOW | WHERE
1603+Thread_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
1604+X 1 0 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1605+# SELECT | LIKE
1606+THREAD_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
1607+X 1 0 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1608+# SELECT | WHERE
1609+THREAD_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
1610+X 1 0 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1611+#
1612+# User statistics
1613+#
1614+# SHOW | LIKE
1615+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1616+X 1 1 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1617+# SHOW | WHERE
1618+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1619+X 1 1 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1620+# SELECT | LIKE
1621+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1622+X 1 1 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1623+# SELECT | WHERE
1624+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1625+X 1 1 X X X X X X 1 0 0 2 0 4 0 0 0 0 0 1
1626+show table_statistics like 'test.t3';
1627+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1628+test t3 2 0 0
1629+show table_statistics where Table_schema='test' and Table_name='t3';
1630+Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
1631+test t3 2 0 0
1632+select * from information_schema.table_statistics where Table_schema like 'test' and Table_name like 't3';
1633+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1634+test t3 2 0 0
1635+select * from information_schema.table_statistics where Table_schema='test' and Table_name='t3';
1636+TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
1637+test t3 2 0 0
1638+show index_statistics like 'test.t3.bx';
1639+Table_schema Table_name Index_name Rows_read
1640+test t3 bx 2
1641+show index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
1642+Table_schema Table_name Index_name Rows_read
1643+test t3 bx 2
1644+select * from information_schema.index_statistics where Table_schema like 'test' and Table_name like 't3' and Index_name like 'bx';
1645+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1646+test t3 bx 2
1647+select * from information_schema.index_statistics where Table_schema='test' and Table_name='t3' and Index_name='bx';
1648+TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
1649+test t3 bx 2
1650+""
1651+Test denied connections
1652+""
1653+create user foo@localhost identified by 'bar';
1654+grant all on test.t1 to foo@localhost with max_user_connections 2;
1655+flush client_statistics;
1656+flush thread_statistics;
1657+flush user_statistics;
1658+select current_user();
1659+current_user()
1660+foo@localhost
1661+Host
1662+1
1663+Thread
1664+1
1665+User
1666+1
1667+#
1668+# Client statistics
1669+#
1670+# SHOW | LIKE
1671+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1672+X 2 2 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1673+# SHOW | WHERE
1674+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1675+X 2 2 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1676+# SELECT | LIKE
1677+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1678+X 2 2 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1679+# SELECT | WHERE
1680+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1681+X 2 2 X X X X X X 1 0 0 1 0 2 0 0 0 0 0 0
1682+#
1683+# Thread statistics
1684+#
1685+# SHOW | LIKE
1686+Thread_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
1687+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1688+# SHOW | WHERE
1689+Thread_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
1690+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1691+# SELECT | LIKE
1692+THREAD_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
1693+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1694+# SELECT | WHERE
1695+THREAD_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
1696+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1697+#
1698+# User statistics
1699+#
1700+# SHOW | LIKE
1701+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_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+X 1 1 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1703+# SHOW | WHERE
1704+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1705+X 1 1 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1706+# SELECT | LIKE
1707+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1708+X 1 1 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1709+# SELECT | WHERE
1710+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_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+X 1 1 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1712+SET DEBUG_SYNC='now WAIT_FOR end_connection';
1713+SET DEBUG_SYNC='now SIGNAL empty';
1714+set global userstat_running=OFF;
1715+set global userstat_running=ON;
1716+#
1717+# Client statistics
1718+#
1719+# SHOW | LIKE
1720+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1721+X 2 1 X X X X X X 1 0 0 1 0 7 0 0 0 0 0 0
1722+# SHOW | WHERE
1723+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1724+X 2 1 X X X X X X 1 0 0 1 0 7 0 0 0 0 0 0
1725+# SELECT | LIKE
1726+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1727+X 2 1 X X X X X X 1 0 0 1 0 7 0 0 0 0 0 0
1728+# SELECT | WHERE
1729+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1730+X 2 1 X X X X X X 1 0 0 1 0 7 0 0 0 0 0 0
1731+#
1732+# Thread statistics
1733+#
1734+# SHOW | LIKE
1735+Thread_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
1736+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1737+# SHOW | WHERE
1738+Thread_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
1739+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1740+# SELECT | LIKE
1741+THREAD_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
1742+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1743+# SELECT | WHERE
1744+THREAD_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
1745+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1746+#
1747+# User statistics
1748+#
1749+# SHOW | LIKE
1750+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1751+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1752+# SHOW | WHERE
1753+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1754+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1755+# SELECT | LIKE
1756+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1757+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1758+# SELECT | WHERE
1759+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1760+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1761+connect(localhost,foo,wrong,test,MASTER_PORT,MASTER_SOCKET);
1762+ERROR 28000: Access denied for user 'foo'@'localhost' (using password: YES)
1763+SET DEBUG_SYNC='now WAIT_FOR end_connection';
1764+SET DEBUG_SYNC='now SIGNAL empty';
1765+set global userstat_running=OFF;
1766+set global userstat_running=ON;
1767+#
1768+# Client statistics
1769+#
1770+# SHOW | LIKE
1771+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1772+X 2 1 X X X X X X 1 0 0 1 0 12 0 0 1 0 1 0
1773+# SHOW | WHERE
1774+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1775+X 2 1 X X X X X X 1 0 0 1 0 12 0 0 1 0 1 0
1776+# SELECT | LIKE
1777+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1778+X 2 1 X X X X X X 1 0 0 1 0 12 0 0 1 0 1 0
1779+# SELECT | WHERE
1780+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1781+X 2 1 X X X X X X 1 0 0 1 0 12 0 0 1 0 1 0
1782+#
1783+# Thread statistics
1784+#
1785+# SHOW | LIKE
1786+Thread_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
1787+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1788+# SHOW | WHERE
1789+Thread_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
1790+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1791+# SELECT | LIKE
1792+THREAD_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
1793+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1794+# SELECT | WHERE
1795+THREAD_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
1796+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 0 0 0 0
1797+#
1798+# User statistics
1799+#
1800+# SHOW | LIKE
1801+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1802+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 1 0 1 0
1803+# SHOW | WHERE
1804+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1805+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 1 0 1 0
1806+# SELECT | LIKE
1807+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1808+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 1 0 1 0
1809+# SELECT | WHERE
1810+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1811+X 1 0 X X X X X X 1 0 0 1 0 0 0 0 1 0 1 0
1812+""
1813+Test access denied
1814+echo ""
1815+flush client_statistics;
1816+flush thread_statistics;
1817+flush user_statistics;
1818+select current_user();
1819+current_user()
1820+foo@localhost
1821+select count(*) from t1;
1822+count(*)
1823+3
1824+select * from t3;
1825+ERROR 42000: SELECT command denied to user 'foo'@'localhost' for table 't3'
1826+Host
1827+1
1828+Thread
1829+1
1830+User
1831+1
1832+#
1833+# Client statistics
1834+#
1835+# SHOW | LIKE
1836+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1837+X 2 2 X X X X X X 2 0 3 3 0 2 1 0 0 0 1 1
1838+# SHOW | WHERE
1839+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1840+X 2 2 X X X X X X 2 0 3 3 0 2 1 0 0 0 1 1
1841+# SELECT | LIKE
1842+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1843+X 2 2 X X X X X X 2 0 3 3 0 2 1 0 0 0 1 1
1844+# SELECT | WHERE
1845+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1846+X 2 2 X X X X X X 2 0 3 3 0 2 1 0 0 0 1 1
1847+#
1848+# Thread statistics
1849+#
1850+# SHOW | LIKE
1851+Thread_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
1852+X 1 0 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1853+# SHOW | WHERE
1854+Thread_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
1855+X 1 0 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1856+# SELECT | LIKE
1857+THREAD_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
1858+X 1 0 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1859+# SELECT | WHERE
1860+THREAD_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
1861+X 1 0 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1862+#
1863+# User statistics
1864+#
1865+# SHOW | LIKE
1866+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1867+X 1 1 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1868+# SHOW | WHERE
1869+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1870+X 1 1 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1871+# SELECT | LIKE
1872+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1873+X 1 1 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1874+# SELECT | WHERE
1875+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1876+X 1 1 X X X X X X 2 0 3 3 0 0 1 0 0 0 1 1
1877+SET DEBUG_SYNC='now WAIT_FOR end_connection';
1878+SET DEBUG_SYNC='now SIGNAL empty';
1879+set global userstat_running=OFF;
1880+set global userstat_running=ON;
1881+""
1882+Test rollback and commit
1883+echo ""
1884+set autocommit=0;
1885+flush client_statistics;
1886+flush thread_statistics;
1887+flush user_statistics;
1888+insert into t1 values (10,10);
1889+commit;
1890+Host
1891+1
1892+Thread
1893+1
1894+User
1895+1
1896+#
1897+# Client statistics
1898+#
1899+# SHOW | LIKE
1900+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1901+X 1 1 X X X X X X 0 1 0 0 1 3 1 0 0 0 0 0
1902+# SHOW | WHERE
1903+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1904+X 1 1 X X X X X X 0 1 0 0 1 3 1 0 0 0 0 0
1905+# SELECT | LIKE
1906+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1907+X 1 1 X X X X X X 0 1 0 0 1 3 1 0 0 0 0 0
1908+# SELECT | WHERE
1909+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1910+X 1 1 X X X X X X 0 1 0 0 1 3 1 0 0 0 0 0
1911+#
1912+# Thread statistics
1913+#
1914+# SHOW | LIKE
1915+Thread_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
1916+X 1 0 X X X X X X 0 1 0 0 1 2 1 0 0 0 0 0
1917+# SHOW | WHERE
1918+Thread_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
1919+X 1 0 X X X X X X 0 1 0 0 1 2 1 0 0 0 0 0
1920+# SELECT | LIKE
1921+THREAD_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
1922+X 1 0 X X X X X X 0 1 0 0 1 2 1 0 0 0 0 0
1923+# SELECT | WHERE
1924+THREAD_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
1925+X 1 0 X X X X X X 0 1 0 0 1 2 1 0 0 0 0 0
1926+#
1927+# User statistics
1928+#
1929+# SHOW | LIKE
1930+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1931+X 1 1 X X X X X X 0 1 0 0 1 1 1 0 0 0 0 0
1932+# SHOW | WHERE
1933+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1934+X 1 1 X X X X X X 0 1 0 0 1 1 1 0 0 0 0 0
1935+# SELECT | LIKE
1936+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1937+X 1 1 X X X X X X 0 1 0 0 1 1 1 0 0 0 0 0
1938+# SELECT | WHERE
1939+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1940+X 1 1 X X X X X X 0 1 0 0 1 1 1 0 0 0 0 0
1941+insert into t1 values (11,11);
1942+rollback;
1943+Host
1944+1
1945+Thread
1946+1
1947+User
1948+1
1949+#
1950+# Client statistics
1951+#
1952+# SHOW | LIKE
1953+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1954+X 1 1 X X X X X X 0 2 0 0 2 6 1 1 0 0 0 0
1955+# SHOW | WHERE
1956+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1957+X 1 1 X X X X X X 0 2 0 0 2 6 1 1 0 0 0 0
1958+# SELECT | LIKE
1959+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1960+X 1 1 X X X X X X 0 2 0 0 2 6 1 1 0 0 0 0
1961+# SELECT | WHERE
1962+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1963+X 1 1 X X X X X X 0 2 0 0 2 6 1 1 0 0 0 0
1964+#
1965+# Thread statistics
1966+#
1967+# SHOW | LIKE
1968+Thread_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
1969+X 1 0 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1970+# SHOW | WHERE
1971+Thread_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
1972+X 1 0 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1973+# SELECT | LIKE
1974+THREAD_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
1975+X 1 0 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1976+# SELECT | WHERE
1977+THREAD_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
1978+X 1 0 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1979+#
1980+# User statistics
1981+#
1982+# SHOW | LIKE
1983+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1984+X 1 1 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1985+# SHOW | WHERE
1986+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
1987+X 1 1 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1988+# SELECT | LIKE
1989+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1990+X 1 1 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1991+# SELECT | WHERE
1992+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
1993+X 1 1 X X X X X X 0 2 0 0 2 4 1 1 0 0 0 0
1994+select * from t1;
1995+a b
1996+0 0
1997+1 1
1998+2 2
1999+10 10
2000+""
2001+Test empty queries
2002+echo ""
2003+flush client_statistics;
2004+flush thread_statistics;
2005+flush user_statistics;
2006+select * from t1 where a < -1;
2007+a b
2008+select * from t1 where a < -3;
2009+a b
2010+Host
2011+1
2012+Thread
2013+1
2014+User
2015+1
2016+#
2017+# Client statistics
2018+#
2019+# SHOW | LIKE
2020+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2021+X 1 1 X X X X X X 0 0 1 2 0 2 0 0 0 0 0 2
2022+# SHOW | WHERE
2023+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2024+X 1 1 X X X X X X 0 0 1 2 0 2 0 0 0 0 0 2
2025+# SELECT | LIKE
2026+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2027+X 1 1 X X X X X X 0 0 1 2 0 2 0 0 0 0 0 2
2028+# SELECT | WHERE
2029+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2030+X 1 1 X X X X X X 0 0 1 2 0 2 0 0 0 0 0 2
2031+#
2032+# Thread statistics
2033+#
2034+# SHOW | LIKE
2035+Thread_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
2036+X 1 0 X X X X X X 0 0 1 2 0 1 0 0 0 0 0 2
2037+# SHOW | WHERE
2038+Thread_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
2039+X 1 0 X X X X X X 0 0 1 2 0 1 0 0 0 0 0 2
2040+# SELECT | LIKE
2041+THREAD_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
2042+X 1 0 X X X X X X 0 0 1 2 0 1 0 0 0 0 0 2
2043+# SELECT | WHERE
2044+THREAD_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
2045+X 1 0 X X X X X X 0 0 1 2 0 1 0 0 0 0 0 2
2046+#
2047+# User statistics
2048+#
2049+# SHOW | LIKE
2050+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2051+X 1 1 X X X X X X 0 0 1 2 0 0 0 0 0 0 0 2
2052+# SHOW | WHERE
2053+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2054+X 1 1 X X X X X X 0 0 1 2 0 0 0 0 0 0 0 2
2055+# SELECT | LIKE
2056+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2057+X 1 1 X X X X X X 0 0 1 2 0 0 0 0 0 0 0 2
2058+# SELECT | WHERE
2059+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2060+X 1 1 X X X X X X 0 0 1 2 0 0 0 0 0 0 0 2
2061+""
2062+Test lost connections
2063+""
2064+set global wait_timeout = 1;
2065+set global interactive_timeout = 1;
2066+flush client_statistics;
2067+flush thread_statistics;
2068+flush user_statistics;
2069+SET DEBUG_SYNC='now WAIT_FOR end_connection';
2070+SET DEBUG_SYNC='now SIGNAL empty';
2071+set global userstat_running=OFF;
2072+set global userstat_running=ON;
2073+Host
2074+1
2075+Thread
2076+1
2077+User
2078+1
2079+#
2080+# Client statistics
2081+#
2082+# SHOW | LIKE
2083+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2084+X 2 1 X X X X X X 0 0 0 0 0 5 0 0 0 1 0 0
2085+# SHOW | WHERE
2086+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2087+X 2 1 X X X X X X 0 0 0 0 0 5 0 0 0 1 0 0
2088+# SELECT | LIKE
2089+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2090+X 2 1 X X X X X X 0 0 0 0 0 5 0 0 0 1 0 0
2091+# SELECT | WHERE
2092+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2093+X 2 1 X X X X X X 0 0 0 0 0 5 0 0 0 1 0 0
2094+#
2095+# Thread statistics
2096+#
2097+# SHOW | LIKE
2098+Thread_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
2099+X 1 0 X X X X X X 0 0 0 0 0 4 0 0 0 0 0 0
2100+# SHOW | WHERE
2101+Thread_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
2102+X 1 0 X X X X X X 0 0 0 0 0 4 0 0 0 0 0 0
2103+# SELECT | LIKE
2104+THREAD_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
2105+X 1 0 X X X X X X 0 0 0 0 0 4 0 0 0 0 0 0
2106+# SELECT | WHERE
2107+THREAD_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
2108+X 1 0 X X X X X X 0 0 0 0 0 4 0 0 0 0 0 0
2109+#
2110+# User statistics
2111+#
2112+# SHOW | LIKE
2113+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2114+X 2 1 X X X X X X 0 0 0 0 0 3 0 0 0 1 0 0
2115+# SHOW | WHERE
2116+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2117+X 2 1 X X X X X X 0 0 0 0 0 3 0 0 0 1 0 0
2118+# SELECT | LIKE
2119+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2120+X 2 1 X X X X X X 0 0 0 0 0 3 0 0 0 1 0 0
2121+# SELECT | WHERE
2122+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2123+X 2 1 X X X X X X 0 0 0 0 0 3 0 0 0 1 0 0
2124+set global wait_timeout = DEFAULT;
2125+set global interactive_timeout = DEFAULT;
2126+""
2127+Test non-existent users
2128+echo ""
2129+flush client_statistics;
2130+flush thread_statistics;
2131+flush user_statistics;
2132+connect(localhost,userDNE,,test,MASTER_PORT,MASTER_SOCKET);
2133+ERROR 28000: Access denied for user 'userDNE'@'localhost' (using password: NO)
2134+SET DEBUG_SYNC='now WAIT_FOR end_connection';
2135+SET DEBUG_SYNC='now SIGNAL empty';
2136+set global userstat_running=OFF;
2137+set global userstat_running=ON;
2138+#
2139+# Client statistics
2140+#
2141+# SHOW | LIKE
2142+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2143+# SHOW | WHERE
2144+Client Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2145+# SELECT | LIKE
2146+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2147+# SELECT | WHERE
2148+CLIENT TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2149+#
2150+# Thread statistics
2151+#
2152+# SHOW | LIKE
2153+Thread_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
2154+# SHOW | WHERE
2155+Thread_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
2156+# SELECT | LIKE
2157+THREAD_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
2158+# SELECT | WHERE
2159+THREAD_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
2160+#
2161+# User statistics
2162+#
2163+# SHOW | LIKE
2164+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2165+# SHOW | WHERE
2166+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2167+# SELECT | LIKE
2168+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2169+# SELECT | WHERE
2170+USER TOTAL_CONNECTIONS CONCURRENT_CONNECTIONS CONNECTED_TIME BUSY_TIME CPU_TIME BYTES_RECEIVED BYTES_SENT BINLOG_BYTES_WRITTEN ROWS_FETCHED ROWS_UPDATED TABLE_ROWS_READ SELECT_COMMANDS UPDATE_COMMANDS OTHER_COMMANDS COMMIT_TRANSACTIONS ROLLBACK_TRANSACTIONS DENIED_CONNECTIONS LOST_CONNECTIONS ACCESS_DENIED EMPTY_QUERIES
2171+drop table t1;
2172+drop table t2;
2173+drop table t3;
2174+drop user foo@localhost;
2175+update mysql.db set User='' where User='hide';
2176+insert into mysql.user select * from mysql.user_bak;
2177+drop table mysql.user_bak;
2178+flush privileges;
2179+set global userstat_running=default;
2180+set global thread_statistics=default;
2181+set global debug='reset';
2182+set debug_sync='reset';
2183
2184=== added file 'Percona-Server/mysql-test/r/user_stats.result'
2185--- Percona-Server/mysql-test/r/user_stats.result 1970-01-01 00:00:00 +0000
2186+++ Percona-Server/mysql-test/r/user_stats.result 2012-02-02 06:08:22 +0000
2187@@ -0,0 +1,90 @@
2188+set global userstat_running=ON;
2189+drop database if exists mysqltest;
2190+flush user_statistics;
2191+create database mysqltest;
2192+show create database mysqltest;
2193+Database Create Database
2194+mysqltest CREATE DATABASE `mysqltest` /*!40100 DEFAULT CHARACTER SET latin1 */
2195+create table mysqltest.t1(a int);
2196+create table mysqltest.empty(a int);
2197+insert into mysqltest.t1 values(1);
2198+grant select on `mysqltest`.* to mysqltest_1@localhost;
2199+grant usage on `mysqltest`.* to mysqltest_2@localhost;
2200+grant drop on `mysqltest`.* to mysqltest_3@localhost;
2201+grant create user on *.* to mysqltest_4@localhost;
2202+grant create user on *.* to mysqltest_1@localhost;
2203+select current_user();
2204+current_user()
2205+mysqltest_1@localhost
2206+select * from mysqltest.empty;
2207+a
2208+drop database mysqltest;
2209+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
2210+create database mysqltest_db;
2211+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_db'
2212+show user_statistics like 'mysqltest_%';
2213+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2214+mysqltest_1 X X X X X X X X X X X X X X X X X X 2 1
2215+mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
2216+show create database mysqltest_db;
2217+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_db'
2218+show user_statistics like 'mysqltest_%';
2219+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2220+mysqltest_1 X X X X X X X X X X X X X X X X X X 3 1
2221+mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
2222+grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
2223+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my\_1'
2224+show user_statistics like 'mysqltest_%';
2225+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2226+mysqltest_1 X X X X X X X X X X X X X X X X X X 4 1
2227+mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
2228+grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
2229+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my_%'
2230+show user_statistics like 'mysqltest_%';
2231+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2232+mysqltest_1 X X X X X X X X X X X X X X X X X X 5 1
2233+mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
2234+show grants for root@localhost;
2235+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql'
2236+show user_statistics like 'mysqltest_%';
2237+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2238+mysqltest_1 X X X X X X X X X X X X X X X X X X 6 1
2239+mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
2240+grant select on `my\_1`.* to mysqltest_2@localhost;
2241+ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my\_1'
2242+show user_statistics like 'mysqltest_%';
2243+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2244+mysqltest_1 X X X X X X X X X X X X X X X X X X 7 1
2245+mysqltest_4 X X X X X X X X X X X X X X X X X X 0 0
2246+select current_user();
2247+current_user()
2248+root@localhost
2249+create database information_schema;
2250+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
2251+alter database information_schema upgrade data directory name;
2252+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
2253+drop database information_schema;
2254+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
2255+drop table information_schema.tables;
2256+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
2257+alter table information_schema.tables;
2258+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
2259+use information_schema;
2260+create temporary table schemata(f1 char(10));
2261+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
2262+show user_statistics like 'root';
2263+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2264+root X X X X X X X X X X X X X X X X X X 6 0
2265+grant all on information_schema.* to 'user1'@'localhost';
2266+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
2267+grant select on information_schema.* to 'user1'@'localhost';
2268+ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
2269+show user_statistics like 'root';
2270+User Total_connections Concurrent_connections Connected_time Busy_time Cpu_time Bytes_received Bytes_sent Binlog_bytes_written Rows_fetched Rows_updated Table_rows_read Select_commands Update_commands Other_commands Commit_transactions Rollback_transactions Denied_connections Lost_connections Access_denied Empty_queries
2271+root X X X X X X X X X X X X X X X X X X 8 0
2272+drop user mysqltest_1@localhost;
2273+drop user mysqltest_2@localhost;
2274+drop user mysqltest_3@localhost;
2275+drop user mysqltest_4@localhost;
2276+drop database mysqltest;
2277+set global userstat_running=default;
2278
2279=== modified file 'Percona-Server/mysql-test/r/userstat_bug602047.result'
2280--- Percona-Server/mysql-test/r/userstat_bug602047.result 2011-11-24 01:59:48 +0000
2281+++ Percona-Server/mysql-test/r/userstat_bug602047.result 2012-02-02 06:08:22 +0000
2282@@ -1,6 +1,8 @@
2283 DROP TABLE IF EXISTS t1;
2284 SET @userstat_running_old= @@userstat_running;
2285 SET GLOBAL userstat_running=ON;
2286+FLUSH TABLE_STATISTICS;
2287+FLUSH INDEX_STATISTICS;
2288 CREATE TABLE t1 ( id int(10), PRIMARY KEY (id)) ENGINE=InnoDB;
2289 INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
2290 SELECT COUNT(*) FROM t1;
2291
2292=== added file 'Percona-Server/mysql-test/t/access_denied.test'
2293--- Percona-Server/mysql-test/t/access_denied.test 1970-01-01 00:00:00 +0000
2294+++ Percona-Server/mysql-test/t/access_denied.test 2012-02-02 06:08:22 +0000
2295@@ -0,0 +1,559 @@
2296+# Test of counter for Access_denied for "show user_statistics".
2297+#
2298+# The errors to be counted include
2299+# from *** include/mysqld_error.h:
2300+# ER_DBACCESS_DENIED_ERROR 1044
2301+# ER_ACCESS_DENIED_ERROR 1045
2302+# ER_TABLEACCESS_DENIED_ERROR 1142
2303+# ER_COLUMNACCESS_DENIED_ERROR 1143
2304+# ER_SPECIFIC_ACCESS_DENIED_ERROR 1227
2305+# ER_PROCACCESS_DENIED_ERROR 1370
2306+#
2307+# All test cases are gleaned from other tests,
2308+# specifically, for the counter Access_denied
2309+# Access_denied is #20 from "show user_statistics".
2310+# shield all other counters to make the test deterministic
2311+
2312+# Grant tests not performed with embedded server
2313+-- source include/not_embedded.inc
2314+
2315+create table mysql.user_bak like mysql.user;
2316+insert into mysql.user_bak select * from mysql.user;
2317+
2318+set global userstat_running=ON;
2319+grant create user on *.* to mysqltest_1@localhost;
2320+grant create user on *.* to mysqltest_2@localhost;
2321+
2322+connection default;
2323+# Cleanup
2324+--disable_warnings
2325+drop table if exists t1;
2326+--enable_warnings
2327+
2328+#
2329+# 1044
2330+#
2331+
2332+# Cleanup
2333+--disable_warnings
2334+drop database if exists mysqltest;
2335+--enable_warnings
2336+
2337+flush user_statistics;
2338+
2339+#
2340+# Test of access_denied
2341+#
2342+
2343+create database mysqltest;
2344+show create database mysqltest;
2345+create table mysqltest.t1(a int);
2346+create table mysqltest.empty(a int);
2347+insert into mysqltest.t1 values(1);
2348+grant select on `mysqltest`.* to mysqltest_1@localhost;
2349+
2350+# User with 1 empty query
2351+connection default;
2352+connect (user1,localhost,mysqltest_1,,);
2353+select current_user();
2354+select * from mysqltest.empty;
2355+
2356+--error 1044
2357+drop database mysqltest;
2358+
2359+--error 1044
2360+create database mysqltest_db;
2361+
2362+--error 1044
2363+show create database mysqltest_db;
2364+
2365+--error 1044
2366+grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
2367+
2368+--error 1044
2369+grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
2370+
2371+--error 1044
2372+show grants for root@localhost;
2373+
2374+--error 1044
2375+grant select on `my\_1`.* to mysqltest_2@localhost;
2376+
2377+connection default;
2378+--echo mysqltest_1 access_denied=7
2379+--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
2380+show user_statistics like 'mysqltest_%';
2381+
2382+disconnect user1;
2383+
2384+select current_user();
2385+
2386+--error 1044
2387+create database information_schema;
2388+
2389+--error 1044
2390+alter database information_schema upgrade data directory name;
2391+
2392+--error 1044
2393+drop database information_schema;
2394+
2395+--error 1044
2396+drop table information_schema.tables;
2397+
2398+--error 1044
2399+alter table information_schema.tables;
2400+
2401+revoke select on `mysqltest`.* from mysqltest_1@localhost;
2402+
2403+#
2404+# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
2405+#
2406+use information_schema;
2407+--error 1044
2408+create temporary table schemata(f1 char(10));
2409+
2410+#
2411+# Bug #10734 Grant of privileges other than 'select' and 'create view' should fail on schema
2412+#
2413+--error 1044
2414+grant all on information_schema.* to 'user1'@'localhost';
2415+--error 1044
2416+grant select on information_schema.* to 'user1'@'localhost';
2417+
2418+--echo root access_denied=8
2419+--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
2420+show user_statistics like 'root';
2421+
2422+
2423+drop user mysqltest_1@localhost;
2424+
2425+drop database mysqltest;
2426+
2427+#
2428+# ================================== end of error 1044 =========================================
2429+#
2430+
2431+#
2432+# error 1045
2433+#
2434+# This test is to check various cases of connections
2435+# with right and wrong password, with and without database
2436+# Unfortunately the check is incomplete as we can't connect without database
2437+
2438+
2439+connect (con1,localhost,root,,test);
2440+show tables;
2441+
2442+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
2443+--error 1045
2444+connect (fail_con,localhost,root,z,test2);
2445+
2446+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
2447+--error 1045
2448+connect (fail_con,localhost,root,z,);
2449+
2450+--echo root access_denied=10
2451+--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
2452+show user_statistics like 'root%';
2453+
2454+grant ALL on *.* to test@localhost identified by "gambling";
2455+grant ALL on *.* to test@127.0.0.1 identified by "gambling";
2456+
2457+disconnect con1;
2458+
2459+# Now check this user with different databases
2460+connect (con4,localhost,test,gambling,test);
2461+show tables;
2462+
2463+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
2464+--error 1045
2465+connect (fail_con,localhost,test,,test2);
2466+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
2467+--error 1045
2468+connect (fail_con,localhost,test,,"");
2469+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
2470+--error 1045
2471+connect (fail_con,localhost,test,zorro,test2);
2472+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
2473+--error 1045
2474+connect (fail_con,localhost,test,zorro,);
2475+
2476+--echo test access_denied=4
2477+--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
2478+show user_statistics like 'test';
2479+
2480+# clean up
2481+drop user test@localhost;
2482+drop user test@127.0.0.1;
2483+flush privileges;
2484+
2485+disconnect con4;
2486+
2487+
2488+#
2489+# ================================== end of error 1045 =========================================
2490+#
2491+
2492+
2493+#
2494+# error 1142 and 1143
2495+#
2496+
2497+connect (master,localhost,root,,);
2498+connection master;
2499+SET NAMES binary;
2500+
2501+#
2502+# Bug#7391: Cross-database multi-table UPDATE security problem
2503+#
2504+create database mysqltest_1;
2505+create database mysqltest_2;
2506+create table mysqltest_1.t1 select 1 a, 2 q;
2507+create table mysqltest_1.t2 select 1 b, 2 r;
2508+create table mysqltest_2.t1 select 1 c, 2 s;
2509+create table mysqltest_2.t2 select 1 d, 2 t;
2510+
2511+#test the column privileges
2512+grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost;
2513+grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost;
2514+grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost;
2515+grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost;
2516+
2517+connect (conn1,localhost,mysqltest_3,,);
2518+connection conn1;
2519+
2520+# the following four stmts generate no error messages.
2521+# check_access in sql_parse.cc needs !no_errors predicate
2522+SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
2523+ WHERE GRANTEE = '''mysqltest_3''@''localhost'''
2524+ ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE;
2525+SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES
2526+ WHERE GRANTEE = '''mysqltest_3''@''localhost'''
2527+ ORDER BY TABLE_NAME,PRIVILEGE_TYPE;
2528+SELECT * from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES
2529+ WHERE GRANTEE = '''mysqltest_3''@''localhost'''
2530+ ORDER BY TABLE_SCHEMA,PRIVILEGE_TYPE;
2531+SELECT * from INFORMATION_SCHEMA.USER_PRIVILEGES
2532+ WHERE GRANTEE = '''mysqltest_3''@''localhost'''
2533+ ORDER BY TABLE_CATALOG,PRIVILEGE_TYPE;
2534+
2535+connection default;
2536+--echo mysqltest_3 access_denied=0
2537+--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
2538+show user_statistics like 'mysqltest_3';
2539+
2540+connection conn1;
2541+--error 1143
2542+update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1;
2543+--error 1143
2544+update mysqltest_1.t2, mysqltest_2.t2 set d=20 where d=1;
2545+--error 1142
2546+update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1;
2547+--error 1142
2548+update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1;
2549+--error 1143
2550+update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2;
2551+
2552+connection default;
2553+--echo mysqltest_3 access_denied=5
2554+--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
2555+show user_statistics like 'mysqltest_3';
2556+
2557+connection conn1;
2558+
2559+#the following two should work
2560+update mysqltest_1.t1, mysqltest_2.t2 set a=10,d=10;
2561+update mysqltest_1.t1, mysqltest_2.t1 set a=20 where c=20;
2562+connection master;
2563+select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
2564+select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
2565+revoke all on mysqltest_1.t1 from mysqltest_3@localhost;
2566+revoke all on mysqltest_1.t2 from mysqltest_3@localhost;
2567+revoke all on mysqltest_2.t1 from mysqltest_3@localhost;
2568+revoke all on mysqltest_2.t2 from mysqltest_3@localhost;
2569+
2570+#test the db/table level privileges
2571+grant all on mysqltest_2.* to mysqltest_3@localhost;
2572+grant select on *.* to mysqltest_3@localhost;
2573+# Next grant is needed to trigger bug#7391. Do not optimize!
2574+grant select on mysqltest_2.t1 to mysqltest_3@localhost;
2575+flush privileges;
2576+disconnect conn1;
2577+connect (conn2,localhost,mysqltest_3,,);
2578+connection conn2;
2579+use mysqltest_1;
2580+update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600;
2581+# the following failed before, should fail now.
2582+--error 1142
2583+update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
2584+use mysqltest_2;
2585+#the following used to succeed, it must fail now.
2586+--error 1142
2587+update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
2588+--error 1142
2589+update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200;
2590+--error 1142
2591+update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200;
2592+
2593+connection default;
2594+--echo mysqltest_3 access_denied=9
2595+--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
2596+show user_statistics like 'mysqltest_3';
2597+
2598+#lets see the result
2599+connection master;
2600+select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
2601+select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
2602+
2603+delete from mysql.user where user='mysqltest_3';
2604+delete from mysql.db where user="mysqltest_3";
2605+delete from mysql.tables_priv where user="mysqltest_3";
2606+delete from mysql.columns_priv where user="mysqltest_3";
2607+flush privileges;
2608+drop database mysqltest_1;
2609+drop database mysqltest_2;
2610+
2611+#
2612+# ================================== end of error 1142/1143 =========================================
2613+#
2614+
2615+
2616+#
2617+# error 1227
2618+#
2619+
2620+create database mysqltest_2;
2621+grant select, insert, update on `mysqltest\_2`.* to mysqltest_1@localhost;
2622+connect (con10,localhost,mysqltest_2,,);
2623+connection con10;
2624+--error 1227
2625+set sql_log_off = 1;
2626+--error 1227
2627+set sql_log_bin = 0;
2628+
2629+connection default;
2630+--echo mysqltest_2 access_denied=2
2631+--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
2632+show user_statistics like 'mysqltest_2';
2633+
2634+disconnect con10;
2635+connection default;
2636+revoke select, insert, update on `mysqltest\_2`.* from mysqltest_1@localhost;
2637+delete from mysql.user where user like 'mysqltest\_2';
2638+delete from mysql.db where user like 'mysqltest\_2';
2639+drop database mysqltest_2;
2640+flush privileges;
2641+
2642+#
2643+# ================================== end of error 1227 =========================================
2644+#
2645+
2646+#
2647+# error 1370
2648+#
2649+#
2650+# Testing SQL SECURITY of stored procedures
2651+#
2652+
2653+connect (con1root,localhost,root,,);
2654+
2655+#
2656+# BUG#2777
2657+#
2658+
2659+connection con1root;
2660+--disable_warnings
2661+drop database if exists db2;
2662+--enable_warnings
2663+
2664+create database db2;
2665+
2666+use db2;
2667+
2668+create table t2 (s1 int);
2669+insert into t2 values (0);
2670+
2671+grant usage on db2.* to user1@localhost;
2672+grant select on db2.* to user1@localhost;
2673+grant usage on db2.* to user2@localhost;
2674+grant select,insert,update,delete,create routine on db2.* to user2@localhost;
2675+grant create routine on db2.* to user1@localhost;
2676+flush privileges;
2677+
2678+connect (con2user1,localhost,user1,,);
2679+
2680+connection con2user1;
2681+use db2;
2682+
2683+create procedure p () insert into t2 values (1);
2684+
2685+connect (con4user2,localhost,user2,,);
2686+
2687+connection con4user2;
2688+use db2;
2689+
2690+# This should not work, since p is executed with definer's (user1's) rights.
2691+--error 1370
2692+call p();
2693+
2694+connection default;
2695+# user1 access_denied=0, user2 access_denied=1
2696+--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
2697+show user_statistics like 'user%';
2698+
2699+connection con4user2;
2700+create procedure q () insert into t2 values (2);
2701+
2702+connection con1root;
2703+grant usage on procedure db2.q to user2@localhost with grant option;
2704+
2705+connection con4user2;
2706+grant execute on procedure db2.q to user1@localhost;
2707+
2708+# still connection con2user1 in db2
2709+connection con2user1;
2710+use db2;
2711+
2712+# This should work:
2713+alter procedure p modifies sql data;
2714+drop procedure p;
2715+
2716+# This should NOT work
2717+--error 1370
2718+alter procedure q modifies sql data;
2719+--error 1370
2720+drop procedure q;
2721+
2722+connection default;
2723+--echo user1 access_denied=2, user2 access_denied=1
2724+--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
2725+show user_statistics like 'user%';
2726+
2727+connection con1root;
2728+use db2;
2729+# But root always can
2730+alter procedure q modifies sql data;
2731+drop procedure q;
2732+
2733+
2734+# Clean up
2735+#Still connection con1root;
2736+
2737+revoke all on db2.* from user1@localhost;
2738+revoke all on db2.* from user2@localhost;
2739+
2740+flush privileges;
2741+
2742+disconnect con2user1;
2743+
2744+disconnect con4user2;
2745+use test;
2746+select type,db,name from mysql.proc;
2747+
2748+
2749+drop database db2;
2750+
2751+# Make sure the routines are gone
2752+select type,db,name from mysql.proc;
2753+# Get rid of the users
2754+delete from mysql.user where user='user1' or user='user2';
2755+delete from mysql.user where user='' and host='%';
2756+# And any routine privileges
2757+delete from mysql.procs_priv where user='user1' or user='user2';
2758+# Delete the grants to user ''@'%' that was created above
2759+delete from mysql.procs_priv where user='' and host='%';
2760+delete from mysql.db where user='user2';
2761+flush privileges;
2762+
2763+#
2764+# Test the new security acls
2765+#
2766+grant usage on *.* to usera@localhost;
2767+grant usage on *.* to userb@localhost;
2768+grant usage on *.* to userc@localhost;
2769+create database sptest;
2770+create table t1 ( u varchar(64), i int );
2771+create procedure sptest.p1(i int) insert into test.t1 values (user(), i);
2772+grant insert on t1 to usera@localhost;
2773+grant execute on procedure sptest.p1 to usera@localhost;
2774+show grants for usera@localhost;
2775+grant execute on procedure sptest.p1 to userc@localhost with grant option;
2776+show grants for userc@localhost;
2777+
2778+connect (con2usera,localhost,usera,,);
2779+connect (con3userb,localhost,userb,,);
2780+connect (con4userc,localhost,userc,,);
2781+
2782+connection con2usera;
2783+call sptest.p1(1);
2784+--error 1370
2785+grant execute on procedure sptest.p1 to userb@localhost;
2786+
2787+--error 1370
2788+drop procedure sptest.p1;
2789+
2790+connection default;
2791+--echo usera access_denied=2
2792+--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
2793+show user_statistics like 'usera%';
2794+
2795+connection con3userb;
2796+--error 1370
2797+call sptest.p1(2);
2798+--error 1370
2799+grant execute on procedure sptest.p1 to userb@localhost;
2800+--error 1370
2801+drop procedure sptest.p1;
2802+
2803+connection default;
2804+--echo userb access_denied=3
2805+--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
2806+show user_statistics like 'userb';
2807+
2808+
2809+connection con4userc;
2810+call sptest.p1(3);
2811+grant execute on procedure sptest.p1 to userb@localhost;
2812+--error 1370
2813+drop procedure sptest.p1;
2814+
2815+connection default;
2816+--echo userc access_denied=1
2817+--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
2818+show user_statistics like 'userc';
2819+
2820+connection con3userb;
2821+call sptest.p1(4);
2822+--error 1370
2823+grant execute on procedure sptest.p1 to userb@localhost;
2824+--error 1370
2825+drop procedure sptest.p1;
2826+
2827+connection default;
2828+--echo userb access_denied=5
2829+--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
2830+show user_statistics like 'userb';
2831+
2832+connection con1root;
2833+
2834+#cleanup
2835+disconnect con4userc;
2836+disconnect con3userb;
2837+disconnect con2usera;
2838+use test;
2839+drop database sptest;
2840+delete from mysql.user where user='usera' or user='userb' or user='userc';
2841+delete from mysql.procs_priv where user='usera' or user='userb' or user='userc';
2842+delete from mysql.tables_priv where user='usera';
2843+flush privileges;
2844+drop table t1;
2845+set global userstat_running=default;
2846+
2847+delete from mysql.user;
2848+insert into mysql.user select * from mysql.user_bak;
2849+drop table mysql.user_bak;
2850+
2851+#
2852+# ================================== end of error 1370 =========================================
2853+#
2854+
2855
2856=== added file 'Percona-Server/mysql-test/t/show_stats.test'
2857--- Percona-Server/mysql-test/t/show_stats.test 1970-01-01 00:00:00 +0000
2858+++ Percona-Server/mysql-test/t/show_stats.test 2012-02-02 06:08:22 +0000
2859@@ -0,0 +1,484 @@
2860+# Uses GRANT commands that usually disabled in embedded server
2861+--source include/not_embedded.inc
2862+--source include/have_innodb.inc
2863+--source include/have_debug.inc
2864+--let wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST
2865+--disable_warnings
2866+drop table if exists t1;
2867+
2868+update mysql.db set User = 'hide' where User = '';
2869+create table mysql.user_bak like mysql.user;
2870+insert into mysql.user_bak select * from mysql.user where length(User) = 0;
2871+delete from mysql.user where length(User) = 0;
2872+flush privileges;
2873+
2874+--enable_warnings
2875+
2876+SET GLOBAL DEBUG='+d,signal_end_connection';
2877+
2878+create table t2 (a int not null primary key, b int not null) engine=innodb;
2879+create table t3 (a int not null primary key, b int not null, index bx(b)) engine=myisam;
2880+
2881+set global userstat_running=ON;
2882+set global thread_statistics=ON;
2883+
2884+flush client_statistics;
2885+flush thread_statistics;
2886+flush user_statistics;
2887+
2888+--let user=root
2889+--source include/show_stats.inc
2890+
2891+flush client_statistics;
2892+flush thread_statistics;
2893+flush user_statistics;
2894+
2895+create table t1 (a int not null primary key, b int not null) engine=innodb;
2896+
2897+--let user=root
2898+--source include/show_stats.inc
2899+
2900+flush client_statistics;
2901+flush thread_statistics;
2902+flush user_statistics;
2903+
2904+flush table_statistics;
2905+flush index_statistics;
2906+
2907+insert into t1 values (1,1), (2,2);
2908+
2909+--let user=root
2910+--source include/show_stats.inc
2911+
2912+--let schema=test
2913+--let table=t1
2914+--let index=
2915+--source include/show_table_index_stats.inc
2916+
2917+create table test.tmy(i int) engine=myisam;
2918+insert into test.tmy values (1);
2919+
2920+--let schema=test
2921+--let table=tmy
2922+--let index=
2923+--source include/show_table_index_stats.inc
2924+
2925+drop table test.tmy;
2926+
2927+--let schema=test
2928+--let table=t1
2929+--let index=
2930+--source include/show_table_index_stats.inc
2931+
2932+# Test insert select
2933+
2934+echo "";
2935+echo Test insert select;
2936+echo "";
2937+
2938+flush client_statistics;
2939+flush thread_statistics;
2940+flush user_statistics;
2941+
2942+flush table_statistics;
2943+flush index_statistics;
2944+
2945+insert into t2 select * from t1;
2946+
2947+--let user=root
2948+--source include/show_stats.inc
2949+
2950+--let schema=test
2951+--let table=t1
2952+--let index=PRIMARY
2953+--source include/show_table_index_stats.inc
2954+
2955+--let schema=test
2956+--let table=t2
2957+--let index=
2958+--source include/show_table_index_stats.inc
2959+
2960+# Test update with PK scans
2961+
2962+echo "";
2963+echo Test update with PK scans;
2964+echo "";
2965+
2966+insert into t1 values (0,0);
2967+select count(*) from t1;
2968+
2969+flush client_statistics;
2970+flush thread_statistics;
2971+flush user_statistics;
2972+
2973+flush table_statistics;
2974+flush index_statistics;
2975+
2976+update t1 set a = 3 where a = 1;
2977+
2978+--let user=root
2979+--source include/show_stats.inc
2980+
2981+update t1 set a = 4 where b = 2;
2982+
2983+--let user=root
2984+--source include/show_stats.inc
2985+
2986+--let schema=test
2987+--let table=t1
2988+--let index=PRIMARY
2989+--source include/show_table_index_stats.inc
2990+
2991+update t1 set a = 4 where b < 0;
2992+
2993+--let user=root
2994+--source include/show_stats.inc
2995+
2996+# Test update with secondary index scans and MyISAM
2997+
2998+echo "";
2999+echo Test update with secondary index scans and MyISAM;
3000+echo "";
3001+
3002+insert into t3 values (0,0);
3003+insert into t3 values (1,1);
3004+insert into t3 values (2,2);
3005+
3006+flush client_statistics;
3007+flush thread_statistics;
3008+flush user_statistics;
3009+
3010+flush table_statistics;
3011+flush index_statistics;
3012+
3013+update t3 set a = 4 where b = 1;
3014+
3015+--let user=root
3016+--source include/show_stats.inc
3017+
3018+--let schema=test
3019+--let table=t3
3020+--let index=bx
3021+--source include/show_table_index_stats.inc
3022+
3023+# Test delete with PK scans
3024+
3025+echo "";
3026+echo Test delete with PK scans;
3027+echo "";
3028+
3029+flush client_statistics;
3030+flush thread_statistics;
3031+flush user_statistics;
3032+
3033+flush table_statistics;
3034+flush index_statistics;
3035+
3036+delete from t1 where a = 3;
3037+
3038+--let user=root
3039+--source include/show_stats.inc
3040+
3041+delete from t1 where b = 2;
3042+
3043+--let user=root
3044+--source include/show_stats.inc
3045+
3046+--let schema=test
3047+--let table=t1
3048+--let index=PRIMARY
3049+--source include/show_table_index_stats.inc
3050+
3051+delete from t1 where b < 0;
3052+
3053+--let user=root
3054+--source include/show_stats.inc
3055+
3056+# Test delete with secondary index scans
3057+
3058+echo "";
3059+echo Test delete with secondary index scans;
3060+echo "";
3061+
3062+flush client_statistics;
3063+flush thread_statistics;
3064+flush user_statistics;
3065+
3066+flush table_statistics;
3067+flush index_statistics;
3068+
3069+delete from t3 where b = 1;
3070+
3071+--let user=root
3072+--source include/show_stats.inc
3073+
3074+--let schema=test
3075+--let table=t3
3076+--let index=bx
3077+--source include/show_table_index_stats.inc
3078+
3079+delete from t3 where b < 0;
3080+
3081+--let user=root
3082+--source include/show_stats.inc
3083+
3084+# Test select on PK index
3085+
3086+echo "";
3087+echo Test select with PK scans;
3088+echo "";
3089+
3090+insert into t1 values (1,1), (2,2);
3091+
3092+flush client_statistics;
3093+flush thread_statistics;
3094+flush user_statistics;
3095+
3096+flush table_statistics;
3097+flush index_statistics;
3098+
3099+select count(*) from t1 where a = 1;
3100+
3101+--let user=root
3102+--source include/show_stats.inc
3103+
3104+select count(*) from t1 where b < 0;
3105+
3106+--let user=root
3107+--source include/show_stats.inc
3108+
3109+--let schema=test
3110+--let table=t1
3111+--let index=PRIMARY
3112+--source include/show_table_index_stats.inc
3113+
3114+# Test select on secondary index
3115+
3116+echo "";
3117+echo Test select with secondary scans;
3118+echo "";
3119+
3120+insert into t3 values (1,1);
3121+analyze table t3;
3122+explain select * from t3 where b < 0;
3123+
3124+flush client_statistics;
3125+flush thread_statistics;
3126+flush user_statistics;
3127+
3128+flush table_statistics;
3129+flush index_statistics;
3130+
3131+select * from t3 where b = 1;
3132+
3133+--let user=root
3134+--source include/show_stats.inc
3135+
3136+select * from t3 where b < 0;
3137+
3138+--let user=root
3139+--source include/show_stats.inc
3140+
3141+--let schema=test
3142+--let table=t3
3143+--let index=bx
3144+--source include/show_table_index_stats.inc
3145+
3146+#
3147+# Test denied connections
3148+#
3149+
3150+echo "";
3151+echo Test denied connections;
3152+echo "";
3153+
3154+# user level connection limit to force denied connections.
3155+create user foo@localhost identified by 'bar';
3156+grant all on test.t1 to foo@localhost with max_user_connections 2;
3157+
3158+flush client_statistics;
3159+flush thread_statistics;
3160+flush user_statistics;
3161+
3162+connect (foo0, localhost, foo, bar,,);
3163+select current_user();
3164+
3165+connection default;
3166+
3167+--let user=foo
3168+--source include/show_stats.inc
3169+
3170+disconnect foo0;
3171+SET DEBUG_SYNC='now WAIT_FOR end_connection';
3172+SET DEBUG_SYNC='now SIGNAL empty';
3173+set global userstat_running=OFF;
3174+--source include/wait_condition.inc
3175+set global userstat_running=ON;
3176+
3177+--let user=foo
3178+--source include/show_stats.inc
3179+
3180+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
3181+--error 1045
3182+connect (foo0, localhost, foo, wrong,,);
3183+
3184+connection default;
3185+SET DEBUG_SYNC='now WAIT_FOR end_connection';
3186+SET DEBUG_SYNC='now SIGNAL empty';
3187+set global userstat_running=OFF;
3188+--source include/wait_condition.inc
3189+set global userstat_running=ON;
3190+
3191+--let user=foo
3192+--source include/show_stats.inc
3193+
3194+# Test access denied
3195+
3196+echo "";
3197+echo Test access denied
3198+echo "";
3199+
3200+flush client_statistics;
3201+flush thread_statistics;
3202+flush user_statistics;
3203+
3204+connect (foo0, localhost, foo, bar,,);
3205+select current_user();
3206+
3207+select count(*) from t1;
3208+--error 1142
3209+select * from t3;
3210+
3211+connection default;
3212+
3213+--let user=foo
3214+--source include/show_stats.inc
3215+
3216+# TODO(mcallaghan): this is a bug
3217+#let $val=query_get_value(show user_statistics like 'foo', Access_denied, 1);
3218+#echo Access_denied should be 1 and is $val;
3219+
3220+disconnect foo0;
3221+SET DEBUG_SYNC='now WAIT_FOR end_connection';
3222+SET DEBUG_SYNC='now SIGNAL empty';
3223+set global userstat_running=OFF;
3224+--source include/wait_condition.inc
3225+set global userstat_running=ON;
3226+
3227+# Test rollback and commit
3228+
3229+echo "";
3230+echo Test rollback and commit
3231+echo "";
3232+
3233+set autocommit=0;
3234+flush client_statistics;
3235+flush thread_statistics;
3236+flush user_statistics;
3237+
3238+insert into t1 values (10,10);
3239+commit;
3240+
3241+--let user=root
3242+--source include/show_stats.inc
3243+
3244+insert into t1 values (11,11);
3245+rollback;
3246+
3247+--let user=root
3248+--source include/show_stats.inc
3249+
3250+select * from t1;
3251+
3252+# Test empty queries
3253+
3254+echo "";
3255+echo Test empty queries
3256+echo "";
3257+
3258+flush client_statistics;
3259+flush thread_statistics;
3260+flush user_statistics;
3261+
3262+select * from t1 where a < -1;
3263+select * from t1 where a < -3;
3264+
3265+--let user=root
3266+--source include/show_stats.inc
3267+
3268+#
3269+# Test lost connections
3270+#
3271+
3272+echo "";
3273+echo Test lost connections;
3274+echo "";
3275+
3276+set global wait_timeout = 1;
3277+set global interactive_timeout = 1;
3278+
3279+flush client_statistics;
3280+flush thread_statistics;
3281+flush user_statistics;
3282+
3283+# this connection will get timed out and aborted.
3284+connect (abortconn, localhost, root,,,);
3285+
3286+connection default;
3287+SET DEBUG_SYNC='now WAIT_FOR end_connection';
3288+SET DEBUG_SYNC='now SIGNAL empty';
3289+set global userstat_running=OFF;
3290+--source include/wait_condition.inc
3291+set global userstat_running=ON;
3292+
3293+--let user=root
3294+--source include/show_stats.inc
3295+
3296+set global wait_timeout = DEFAULT;
3297+set global interactive_timeout = DEFAULT;
3298+
3299+#
3300+# Test non-existent users
3301+#
3302+
3303+echo "";
3304+echo Test non-existent users
3305+echo "";
3306+
3307+flush client_statistics;
3308+flush thread_statistics;
3309+flush user_statistics;
3310+
3311+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
3312+--error 1045
3313+connect (userDNE, localhost, userDNE,,,);
3314+
3315+connection default;
3316+SET DEBUG_SYNC='now WAIT_FOR end_connection';
3317+SET DEBUG_SYNC='now SIGNAL empty';
3318+set global userstat_running=OFF;
3319+--source include/wait_condition.inc
3320+set global userstat_running=ON;
3321+
3322+# userDNE should not exist in the output.
3323+--let user=userDNE
3324+--let host=hostDNE
3325+--let thread=`select max(Id)+1 from information_schema.processlist`
3326+--source include/show_stats.inc
3327+
3328+# Cleanup
3329+
3330+drop table t1;
3331+drop table t2;
3332+drop table t3;
3333+drop user foo@localhost;
3334+
3335+update mysql.db set User='' where User='hide';
3336+insert into mysql.user select * from mysql.user_bak;
3337+drop table mysql.user_bak;
3338+flush privileges;
3339+
3340+set global userstat_running=default;
3341+set global thread_statistics=default;
3342+set global debug='reset';
3343+set debug_sync='reset';
3344
3345=== added file 'Percona-Server/mysql-test/t/user_stats.test'
3346--- Percona-Server/mysql-test/t/user_stats.test 1970-01-01 00:00:00 +0000
3347+++ Percona-Server/mysql-test/t/user_stats.test 2012-02-02 06:08:22 +0000
3348@@ -0,0 +1,135 @@
3349+# Uses GRANT commands that usually disabled in embedded server
3350+-- source include/not_embedded.inc
3351+-- source include/have_innodb.inc
3352+
3353+set global userstat_running=ON;
3354+
3355+# Cleanup
3356+--disable_warnings
3357+drop database if exists mysqltest;
3358+--enable_warnings
3359+
3360+flush user_statistics;
3361+
3362+#
3363+# Test of access_denied
3364+#
3365+
3366+create database mysqltest;
3367+show create database mysqltest;
3368+create table mysqltest.t1(a int);
3369+create table mysqltest.empty(a int);
3370+insert into mysqltest.t1 values(1);
3371+grant select on `mysqltest`.* to mysqltest_1@localhost;
3372+grant usage on `mysqltest`.* to mysqltest_2@localhost;
3373+grant drop on `mysqltest`.* to mysqltest_3@localhost;
3374+
3375+# User with 0 empty queries
3376+grant create user on *.* to mysqltest_4@localhost;
3377+connect (user4,localhost,mysqltest_4,,);
3378+
3379+# User with 1 empty query
3380+connection default;
3381+grant create user on *.* to mysqltest_1@localhost;
3382+connect (user1,localhost,mysqltest_1,,);
3383+select current_user();
3384+select * from mysqltest.empty;
3385+
3386+--error 1044
3387+drop database mysqltest;
3388+
3389+--error 1044
3390+create database mysqltest_db;
3391+
3392+connection default;
3393+--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
3394+show user_statistics like 'mysqltest_%';
3395+
3396+connection user1;
3397+--error 1044
3398+show create database mysqltest_db;
3399+
3400+connection default;
3401+--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
3402+show user_statistics like 'mysqltest_%';
3403+connection user1;
3404+
3405+--error 1044
3406+grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
3407+
3408+connection default;
3409+--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
3410+show user_statistics like 'mysqltest_%';
3411+connection user1;
3412+
3413+--error 1044
3414+grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
3415+
3416+connection default;
3417+--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
3418+show user_statistics like 'mysqltest_%';
3419+connection user1;
3420+
3421+--error 1044
3422+show grants for root@localhost;
3423+
3424+connection default;
3425+--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
3426+show user_statistics like 'mysqltest_%';
3427+connection user1;
3428+
3429+--error 1044
3430+grant select on `my\_1`.* to mysqltest_2@localhost;
3431+connection default;
3432+--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
3433+show user_statistics like 'mysqltest_%';
3434+
3435+connection default;
3436+disconnect user4;
3437+disconnect user1;
3438+
3439+select current_user();
3440+
3441+--error 1044
3442+create database information_schema;
3443+
3444+--error 1044
3445+alter database information_schema upgrade data directory name;
3446+
3447+--error 1044
3448+drop database information_schema;
3449+
3450+--error 1044
3451+drop table information_schema.tables;
3452+
3453+--error 1044
3454+alter table information_schema.tables;
3455+
3456+#
3457+# Bug #9683 INFORMATION_SCH: Creation of temporary table allowed in Information_schema DB
3458+#
3459+use information_schema;
3460+--error 1044
3461+create temporary table schemata(f1 char(10));
3462+
3463+--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
3464+show user_statistics like 'root';
3465+
3466+#
3467+# Bug #10734 Grant of privileges other than 'select' and 'create view' should fail on schema
3468+#
3469+--error 1044
3470+grant all on information_schema.* to 'user1'@'localhost';
3471+--error 1044
3472+grant select on information_schema.* to 'user1'@'localhost';
3473+
3474+--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
3475+show user_statistics like 'root';
3476+
3477+
3478+drop user mysqltest_1@localhost;
3479+drop user mysqltest_2@localhost;
3480+drop user mysqltest_3@localhost;
3481+drop user mysqltest_4@localhost;
3482+drop database mysqltest;
3483+set global userstat_running=default;
3484
3485=== modified file 'Percona-Server/mysql-test/t/userstat_bug602047.test'
3486--- Percona-Server/mysql-test/t/userstat_bug602047.test 2011-11-24 01:59:48 +0000
3487+++ Percona-Server/mysql-test/t/userstat_bug602047.test 2012-02-02 06:08:22 +0000
3488@@ -4,6 +4,8 @@
3489 --enable_warnings
3490 SET @userstat_running_old= @@userstat_running;
3491 SET GLOBAL userstat_running=ON;
3492+FLUSH TABLE_STATISTICS;
3493+FLUSH INDEX_STATISTICS;
3494 CREATE TABLE t1 ( id int(10), PRIMARY KEY (id)) ENGINE=InnoDB;
3495 INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
3496 SELECT COUNT(*) FROM t1;
3497
3498=== modified file 'Percona-Server/sql/handler.cc'
3499--- Percona-Server/sql/handler.cc 2011-11-24 16:33:30 +0000
3500+++ Percona-Server/sql/handler.cc 2012-02-02 06:08:22 +0000
3501@@ -1199,7 +1199,7 @@
3502 }
3503 DBUG_EXECUTE_IF("crash_commit_after", DBUG_SUICIDE(););
3504 if (is_real_trans)
3505- thd->diff_commit_trans++;
3506+ thd->diff_stats.commit_trans++;
3507 end:
3508 if (rw_trans)
3509 start_waiting_global_read_lock(thd);
3510@@ -1331,7 +1331,7 @@
3511 if (is_real_trans)
3512 thd->transaction.cleanup();
3513
3514- thd->diff_rollback_trans++;
3515+ thd->diff_stats.rollback_trans++;
3516 #endif /* USING_TRANSACTIONS */
3517 if (all)
3518 thd->transaction_rollback_request= FALSE;
3519@@ -1771,7 +1771,7 @@
3520 ha_info->reset(); /* keep it conveniently zero-filled */
3521 }
3522 trans->ha_list= sv->ha_list;
3523- thd->diff_rollback_trans++;
3524+ thd->diff_stats.rollback_trans++;
3525 DBUG_RETURN(error);
3526 }
3527
3528@@ -3610,110 +3610,158 @@
3529 return;
3530 }
3531
3532-// Updates the global table stats with the TABLE this handler represents.
3533-void handler::update_global_table_stats() {
3534- if (!opt_userstat_running) {
3535- rows_read = rows_changed = 0;
3536- return;
3537- }
3538-
3539- if (!rows_read && !rows_changed) return; // Nothing to update.
3540- // table_cache_key is db_name + '\0' + table_name + '\0'.
3541- if (!table->s || !table->s->table_cache_key.str || !table->s->table_name.str) return;
3542+/**
3543+ Updates the global table stats with the TABLE this handler represents.
3544+*/
3545+void handler::update_global_table_stats()
3546+{
3547+ DBUG_ENTER("handler::update_global_table_stats");
3548+
3549+ if (!opt_userstat_running)
3550+ {
3551+ rows_read= 0;
3552+ rows_changed= 0;
3553+ DBUG_VOID_RETURN;
3554+ }
3555+
3556+ if (!rows_read && !rows_changed)
3557+ {
3558+ /* Noting to update */
3559+ DBUG_VOID_RETURN;
3560+ }
3561+
3562+ /* table_cache_key is db_name + '\0' + table_name + '\0' */
3563+ if (!table->s ||
3564+ !table->s->table_cache_key.str ||
3565+ !table->s->table_name.str)
3566+ {
3567+ /* Noting to update */
3568+ DBUG_VOID_RETURN;
3569+ }
3570
3571 TABLE_STATS* table_stats;
3572- char key[NAME_LEN * 2 + 2];
3573- // [db] + '.' + [table]
3574- sprintf(key, "%s.%s", table->s->table_cache_key.str, table->s->table_name.str);
3575+ char key[NAME_LEN*2 + 2];
3576+ /* [db] + '.' + [table] */
3577+ sprintf(key, "%s.%s",
3578+ table->s->table_cache_key.str,
3579+ table->s->table_name.str);
3580
3581 pthread_mutex_lock(&LOCK_global_table_stats);
3582- // Gets the global table stats, creating one if necessary.
3583- if (!(table_stats = (TABLE_STATS*)hash_search(&global_table_stats,
3584+ /* Gets the global table stats, creating one if necessary. */
3585+ if (!(table_stats= (TABLE_STATS *)hash_search(&global_table_stats,
3586 (uchar*)key,
3587- strlen(key)))) {
3588- if (!(table_stats = ((TABLE_STATS*)
3589- my_malloc(sizeof(TABLE_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
3590- // Out of memory.
3591+ strlen(key))))
3592+ {
3593+ if (!(table_stats= (TABLE_STATS *)my_malloc(sizeof(TABLE_STATS),
3594+ MYF(MY_WME | MY_ZEROFILL))))
3595+ {
3596+ /* Out of memory. */
3597 sql_print_error("Allocating table stats failed.");
3598 goto end;
3599 }
3600 strncpy(table_stats->table, key, sizeof(table_stats->table));
3601- table_stats->rows_read = 0;
3602- table_stats->rows_changed = 0;
3603- table_stats->rows_changed_x_indexes = 0;
3604- table_stats->engine_type = (int) ht->db_type;
3605+ table_stats->rows_read= 0;
3606+ table_stats->rows_changed= 0;
3607+ table_stats->rows_changed_x_indexes= 0;
3608
3609 if (my_hash_insert(&global_table_stats, (uchar*)table_stats)) {
3610- // Out of memory.
3611+ /* Out of memory. */
3612 sql_print_error("Inserting table stats failed.");
3613 my_free((char*)table_stats, 0);
3614 goto end;
3615 }
3616 }
3617- // Updates the global table stats.
3618- table_stats->rows_read += rows_read;
3619- table_stats->rows_changed += rows_changed;
3620- table_stats->rows_changed_x_indexes +=
3621- rows_changed * (table->s->keys ? table->s->keys : 1);
3622- current_thd->diff_total_read_rows += rows_read;
3623- rows_read = rows_changed = 0;
3624+ /* Updates the current thread stats. */
3625+ current_thd->diff_stats.rows_read+= rows_read;
3626+ /* Updates the global table stats. */
3627+ table_stats->rows_read+= rows_read;
3628+ table_stats->rows_changed+= rows_changed;
3629+ table_stats->rows_changed_x_indexes+=
3630+ rows_changed * (table->s->keys ? table->s->keys : 1);
3631+ /* Reset handler stats */
3632+ rows_read= 0;
3633+ rows_changed= 0;
3634 end:
3635 pthread_mutex_unlock(&LOCK_global_table_stats);
3636+ DBUG_VOID_RETURN;
3637 }
3638
3639-// Updates the global index stats with this handler's accumulated index reads.
3640-void handler::update_global_index_stats() {
3641- // table_cache_key is db_name + '\0' + table_name + '\0'.
3642- if (!table->s || !table->s->table_cache_key.str || !table->s->table_name.str) return;
3643-
3644- if (!opt_userstat_running) {
3645- for (uint x = 0; x < table->s->keys; x++) {
3646- index_rows_read[x] = 0;
3647+/**
3648+ Updates the global index stats with this handler's accumulated index reads.
3649+*/
3650+void handler::update_global_index_stats()
3651+{
3652+ DBUG_ENTER("handler::update_global_index_stats");
3653+
3654+ /* table_cache_key is db_name + '\0' + table_name + '\0'. */
3655+ if (!table->s ||
3656+ !table->s->table_cache_key.str ||
3657+ !table->s->table_name.str)
3658+ {
3659+ DBUG_VOID_RETURN;
3660+ }
3661+
3662+ if (!opt_userstat_running)
3663+ {
3664+ for (uint x= 0; x < table->s->keys; x++)
3665+ {
3666+ index_rows_read[x]= 0;
3667 }
3668- return;
3669+ DBUG_VOID_RETURN;
3670 }
3671
3672- for (uint x = 0; x < table->s->keys; x++) {
3673- if (index_rows_read[x]) {
3674- // Rows were read using this index.
3675- KEY* key_info = &table->key_info[x];
3676+ for (uint x= 0; x < table->s->keys; x++)
3677+ {
3678+ if (index_rows_read[x])
3679+ {
3680+ /* Rows were read using this index. */
3681+ KEY* key_info= &table->key_info[x];
3682
3683- if (!key_info->name) continue;
3684+ if (!key_info->name)
3685+ {
3686+ continue;
3687+ }
3688
3689 INDEX_STATS* index_stats;
3690 char key[NAME_LEN * 3 + 3];
3691- // [db] + '.' + [table] + '.' + [index]
3692- sprintf(key, "%s.%s.%s", table->s->table_cache_key.str,
3693- table->s->table_name.str, key_info->name);
3694+ /* [db] + '.' + [table] + '.' + [index] */
3695+ sprintf(key, "%s.%s.%s",
3696+ table->s->table_cache_key.str,
3697+ table->s->table_name.str,
3698+ key_info->name);
3699
3700 pthread_mutex_lock(&LOCK_global_index_stats);
3701- // Gets the global index stats, creating one if necessary.
3702- if (!(index_stats = (INDEX_STATS*)hash_search(&global_index_stats,
3703+ /* Gets the global index stats, creating one if necessary. */
3704+ if (!(index_stats= (INDEX_STATS *)hash_search(&global_index_stats,
3705 (uchar*)key,
3706- strlen(key)))) {
3707- if (!(index_stats = ((INDEX_STATS*)
3708- my_malloc(sizeof(INDEX_STATS), MYF(MY_WME | MY_ZEROFILL))))) {
3709- // Out of memory.
3710+ strlen(key))))
3711+ {
3712+ if (!(index_stats= (INDEX_STATS *)my_malloc(sizeof(INDEX_STATS),
3713+ MYF(MY_WME | MY_ZEROFILL))))
3714+ {
3715+ /* Out of memory. */
3716 sql_print_error("Allocating index stats failed.");
3717 goto end;
3718 }
3719 strncpy(index_stats->index, key, sizeof(index_stats->index));
3720- index_stats->rows_read = 0;
3721+ index_stats->rows_read= 0;
3722
3723- if (my_hash_insert(&global_index_stats, (uchar*)index_stats)) {
3724- // Out of memory.
3725+ if (my_hash_insert(&global_index_stats, (uchar*)index_stats))
3726+ {
3727+ /* Out of memory. */
3728 sql_print_error("Inserting index stats failed.");
3729 my_free((char*)index_stats, 0);
3730 goto end;
3731 }
3732 }
3733- // Updates the global index stats.
3734- index_stats->rows_read += index_rows_read[x];
3735- index_rows_read[x] = 0;
3736-end:
3737+ /* Updates the global index stats. */
3738+ index_stats->rows_read+= index_rows_read[x];
3739+ index_rows_read[x]= 0;
3740+ end:
3741 pthread_mutex_unlock(&LOCK_global_index_stats);
3742 }
3743 }
3744+ DBUG_VOID_RETURN;
3745 }
3746
3747 /****************************************************************************
3748
3749=== modified file 'Percona-Server/sql/handler.h'
3750--- Percona-Server/sql/handler.h 2012-01-17 14:05:16 +0000
3751+++ Percona-Server/sql/handler.h 2012-02-02 06:08:22 +0000
3752@@ -1179,7 +1179,9 @@
3753 ref_length(sizeof(my_off_t)),
3754 ft_handler(0), inited(NONE),
3755 locked(FALSE), implicit_emptied(0),
3756- pushed_cond(0), rows_read(0), rows_changed(0), next_insert_id(0), insert_id_for_cur_row(0),
3757+ pushed_cond(0),
3758+ rows_read(0), rows_changed(0),
3759+ next_insert_id(0), insert_id_for_cur_row(0),
3760 auto_inc_intervals_count(0)
3761 {
3762 memset(index_rows_read, 0, sizeof(index_rows_read));
3763@@ -1305,9 +1307,10 @@
3764 uint get_dup_key(int error);
3765 virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share)
3766 {
3767- table= table_arg;
3768- table_share= share;
3769- rows_read = rows_changed = 0;
3770+ table= table_arg;
3771+ table_share= share;
3772+ rows_read= 0;
3773+ rows_changed= 0;
3774 memset(index_rows_read, 0, sizeof(index_rows_read));
3775 }
3776 virtual double scan_time()
3777
3778=== modified file 'Percona-Server/sql/item.cc'
3779--- Percona-Server/sql/item.cc 2011-07-07 08:06:59 +0000
3780+++ Percona-Server/sql/item.cc 2012-02-02 06:08:22 +0000
3781@@ -4435,6 +4435,7 @@
3782 db, tab, field_name) &
3783 VIEW_ANY_ACL)))
3784 {
3785+ thd->diff_stats.access_denied_errors++;
3786 my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
3787 "ANY", thd->security_ctx->priv_user,
3788 thd->security_ctx->host_or_ip, field_name, tab);
3789
3790=== modified file 'Percona-Server/sql/mysql_priv.h'
3791--- Percona-Server/sql/mysql_priv.h 2011-11-24 02:01:21 +0000
3792+++ Percona-Server/sql/mysql_priv.h 2012-02-02 06:08:22 +0000
3793@@ -1175,6 +1175,7 @@
3794 void mysql_init_multi_delete(LEX *lex);
3795 bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
3796 void init_max_user_conn(void);
3797+void set_connections_stats();
3798 void init_update_queries(void);
3799 void init_global_user_stats(void);
3800 void init_global_table_stats(void);
3801@@ -2195,7 +2196,6 @@
3802 extern pthread_mutex_t LOCK_global_table_stats;
3803 extern HASH global_index_stats;
3804 extern pthread_mutex_t LOCK_global_index_stats;
3805-extern pthread_mutex_t LOCK_stats;
3806
3807 extern const char *opt_date_time_formats[];
3808 extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
3809
3810=== modified file 'Percona-Server/sql/mysqld.cc'
3811--- Percona-Server/sql/mysqld.cc 2012-01-30 04:30:33 +0000
3812+++ Percona-Server/sql/mysqld.cc 2012-02-02 06:08:22 +0000
3813@@ -724,7 +724,6 @@
3814 LOCK_global_system_variables,
3815 LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
3816 LOCK_connection_count;
3817-pthread_mutex_t LOCK_stats;
3818 pthread_mutex_t LOCK_global_user_client_stats;
3819 pthread_mutex_t LOCK_global_table_stats;
3820 pthread_mutex_t LOCK_global_index_stats;
3821@@ -1537,7 +1536,6 @@
3822 (void) pthread_cond_destroy(&COND_thread_cache);
3823 (void) pthread_cond_destroy(&COND_flush_thread_cache);
3824 (void) pthread_cond_destroy(&COND_manager);
3825- (void) pthread_mutex_destroy(&LOCK_stats);
3826 (void) pthread_mutex_destroy(&LOCK_global_user_client_stats);
3827 (void) pthread_mutex_destroy(&LOCK_global_table_stats);
3828 (void) pthread_mutex_destroy(&LOCK_global_index_stats);
3829@@ -3735,7 +3733,6 @@
3830 #endif
3831 (void) pthread_mutex_init(&LOCK_server_started, MY_MUTEX_INIT_FAST);
3832 (void) pthread_cond_init(&COND_server_started,NULL);
3833- (void) pthread_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
3834 (void) pthread_mutex_init(&LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
3835 (void) pthread_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
3836 (void) pthread_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
3837
3838=== modified file 'Percona-Server/sql/set_var.cc'
3839--- Percona-Server/sql/set_var.cc 2012-01-30 04:30:33 +0000
3840+++ Percona-Server/sql/set_var.cc 2012-02-02 06:08:22 +0000
3841@@ -1152,6 +1152,7 @@
3842 -1 : 0);
3843 else
3844 {
3845+ thd->diff_stats.access_denied_errors++;
3846 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
3847 return 1;
3848 }
3849@@ -3283,6 +3284,7 @@
3850 #ifndef NO_EMBEDDED_ACCESS_CHECKS
3851 if (!(thd->security_ctx->master_access & SUPER_ACL))
3852 {
3853+ thd->diff_stats.access_denied_errors++;
3854 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
3855 return 1;
3856 }
3857@@ -3321,6 +3323,7 @@
3858 return 0;
3859 else
3860 {
3861+ thd->diff_stats.access_denied_errors++;
3862 my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
3863 return 1;
3864 }
3865
3866=== modified file 'Percona-Server/sql/sp_head.cc'
3867--- Percona-Server/sql/sp_head.cc 2011-11-24 16:33:30 +0000
3868+++ Percona-Server/sql/sp_head.cc 2012-02-02 06:08:22 +0000
3869@@ -1556,6 +1556,7 @@
3870 char priv_desc[128];
3871 get_privilege_desc(priv_desc, sizeof(priv_desc), TRIGGER_ACL);
3872
3873+ thd->diff_stats.access_denied_errors++;
3874 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), priv_desc,
3875 thd->security_ctx->priv_user, thd->security_ctx->host_or_ip,
3876 table_name->str);
3877
3878=== modified file 'Percona-Server/sql/sql_acl.cc'
3879--- Percona-Server/sql/sql_acl.cc 2011-07-03 15:47:37 +0000
3880+++ Percona-Server/sql/sql_acl.cc 2012-02-02 06:08:22 +0000
3881@@ -3068,6 +3068,7 @@
3882 char command[128];
3883 get_privilege_desc(command, sizeof(command),
3884 table_list->grant.want_privilege);
3885+ thd->diff_stats.access_denied_errors++;
3886 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
3887 command, thd->security_ctx->priv_user,
3888 thd->security_ctx->host_or_ip, table_list->alias);
3889@@ -4051,6 +4052,7 @@
3890 {
3891 char command[128];
3892 get_privilege_desc(command, sizeof(command), want_access);
3893+ thd->diff_stats.access_denied_errors++;
3894 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
3895 command,
3896 sctx->priv_user,
3897@@ -4118,6 +4120,7 @@
3898 rw_unlock(&LOCK_grant);
3899 char command[128];
3900 get_privilege_desc(command, sizeof(command), want_access);
3901+ thd->diff_stats.access_denied_errors++;
3902 my_error(ER_COLUMNACCESS_DENIED_ERROR, MYF(0),
3903 command,
3904 sctx->priv_user,
3905@@ -4283,6 +4286,7 @@
3906 Do not give an error message listing a column name unless the user has
3907 privilege to see all columns.
3908 */
3909+ thd->diff_stats.access_denied_errors++;
3910 if (using_column_privileges)
3911 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
3912 command, sctx->priv_user,
3913@@ -4418,6 +4422,7 @@
3914 command= "alter routine";
3915 else if (want_access & GRANT_ACL)
3916 command= "grant";
3917+ thd->diff_stats.access_denied_errors++;
3918 my_error(ER_PROCACCESS_DENIED_ERROR, MYF(0),
3919 command, user, host, table ? buff : "unknown");
3920 }
3921
3922=== modified file 'Percona-Server/sql/sql_base.cc'
3923--- Percona-Server/sql/sql_base.cc 2011-11-24 16:33:30 +0000
3924+++ Percona-Server/sql/sql_base.cc 2012-02-02 06:08:22 +0000
3925@@ -8101,6 +8101,7 @@
3926 field_table_name, fld->field_name) &
3927 VIEW_ANY_ACL)))
3928 {
3929+ thd->diff_stats.access_denied_errors++;
3930 my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), "ANY",
3931 thd->security_ctx->priv_user,
3932 thd->security_ctx->host_or_ip,
3933
3934=== modified file 'Percona-Server/sql/sql_class.cc'
3935--- Percona-Server/sql/sql_class.cc 2011-11-24 02:00:51 +0000
3936+++ Percona-Server/sql/sql_class.cc 2012-02-02 06:08:22 +0000
3937@@ -725,14 +725,13 @@
3938 bzero(ha_data, sizeof(ha_data));
3939 mysys_var=0;
3940 binlog_evt_union.do_union= FALSE;
3941- enable_slow_log= 0;
3942- busy_time = 0;
3943- cpu_time = 0;
3944- bytes_received = 0;
3945- bytes_sent = 0;
3946- binlog_bytes_written = 0;
3947- updated_row_count = 0;
3948- sent_row_count_2 = 0;
3949+ enable_slow_log= 0;
3950+ busy_time= 0;
3951+ cpu_time= 0;
3952+ bytes_received= 0;
3953+ bytes_sent= 0;
3954+ binlog_bytes_written= 0;
3955+ updated_row_count= 0;
3956 #ifndef DBUG_OFF
3957 dbug_sentry=THD_SENTRY_MAGIC;
3958 #endif
3959@@ -947,83 +946,109 @@
3960 clear_slow_extended();
3961 }
3962
3963-// Resets stats in a THD.
3964+
3965+/**
3966+ Resets stats in a THD.
3967+*/
3968 void THD::reset_stats(void) {
3969- current_connect_time = time(NULL);
3970- last_global_update_time = current_connect_time;
3971+ current_connect_time= time(NULL);
3972+ diff_stats.connected_time= current_connect_time;
3973 reset_diff_stats();
3974 }
3975
3976-// Resets the 'diff' stats, which are used to update global stats.
3977+
3978+/**
3979+ Resets the 'diff' stats, which are used to update global stats.
3980+*/
3981 void THD::reset_diff_stats(void) {
3982- diff_total_busy_time = 0;
3983- diff_total_cpu_time = 0;
3984- diff_total_bytes_received = 0;
3985- diff_total_bytes_sent = 0;
3986- diff_total_binlog_bytes_written = 0;
3987- diff_total_sent_rows = 0;
3988- diff_total_updated_rows = 0;
3989- diff_total_read_rows = 0;
3990- diff_select_commands = 0;
3991- diff_update_commands = 0;
3992- diff_other_commands = 0;
3993- diff_commit_trans = 0;
3994- diff_rollback_trans = 0;
3995- diff_denied_connections = 0;
3996- diff_lost_connections = 0;
3997- diff_access_denied_errors = 0;
3998- diff_empty_queries = 0;
3999+ diff_stats.busy_time= 0;
4000+ diff_stats.cpu_time= 0;
4001+ diff_stats.bytes_received= 0;
4002+ diff_stats.bytes_sent= 0;
4003+ diff_stats.binlog_bytes_written= 0;
4004+ diff_stats.rows_fetched= 0;
4005+ diff_stats.rows_updated= 0;
4006+ diff_stats.rows_read= 0;
4007+ diff_stats.select_commands= 0;
4008+ diff_stats.update_commands= 0;
4009+ diff_stats.other_commands= 0;
4010+ diff_stats.commit_trans= 0;
4011+ diff_stats.rollback_trans= 0;
4012+ diff_stats.denied_connections= 0;
4013+ diff_stats.lost_connections= 0;
4014+ diff_stats.access_denied_errors= 0;
4015+ diff_stats.empty_queries= 0;
4016 }
4017
4018-// Updates 'diff' stats of a THD.
4019+
4020+/**
4021+ Updates 'diff' stats of a THD.
4022+*/
4023 void THD::update_stats(bool ran_command) {
4024+ DBUG_ENTER("THD::update_stats");
4025+ DBUG_PRINT("query",("%-.4096s", query()));
4026 if (opt_userstat_running) {
4027- diff_total_busy_time += busy_time;
4028- diff_total_cpu_time += cpu_time;
4029- diff_total_bytes_received += bytes_received;
4030- diff_total_bytes_sent += bytes_sent;
4031- diff_total_binlog_bytes_written += binlog_bytes_written;
4032- diff_total_sent_rows += sent_row_count_2;
4033- diff_total_updated_rows += updated_row_count;
4034- // diff_total_read_rows is updated in handler.cc.
4035+ diff_stats.busy_time+= busy_time;
4036+ diff_stats.cpu_time+= cpu_time;
4037+ diff_stats.bytes_received+= bytes_received;
4038+ diff_stats.bytes_sent+= bytes_sent;
4039+ diff_stats.binlog_bytes_written+= binlog_bytes_written;
4040+ diff_stats.rows_fetched+= sent_row_count;
4041+ diff_stats.rows_updated+= updated_row_count;
4042+ /* diff_stats.rows_read is updated in handler.cc. */
4043
4044- if (ran_command) {
4045- // The replication thread has the COM_CONNECT command.
4046- if ((old_command == COM_QUERY || command == COM_CONNECT) &&
4047- (lex->sql_command >= 0 && lex->sql_command < SQLCOM_END)) {
4048- // A SQL query.
4049- if (lex->sql_command == SQLCOM_SELECT) {
4050- diff_select_commands++;
4051- if (!sent_row_count_2)
4052- diff_empty_queries++;
4053- } else if (! sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) {
4054- // 'SHOW ' commands become SQLCOM_SELECT.
4055- diff_other_commands++;
4056- // 'SHOW ' commands shouldn't inflate total sent row count.
4057- diff_total_sent_rows -= sent_row_count_2;
4058- } else if (is_update_query(lex->sql_command)) {
4059- diff_update_commands++;
4060- } else {
4061- diff_other_commands++;
4062+ if (ran_command)
4063+ {
4064+ /* The replication thread has the COM_CONNECT command. */
4065+ if ((old_command == COM_QUERY ||
4066+ command == COM_CONNECT) &&
4067+ (lex->sql_command >= 0 &&
4068+ lex->sql_command < SQLCOM_END))
4069+ {
4070+ /* A SQL query. */
4071+ if (lex->sql_command == SQLCOM_SELECT)
4072+ {
4073+ diff_stats.select_commands++;
4074+ if (!sent_row_count)
4075+ {
4076+ diff_stats.empty_queries++;
4077+ }
4078+ }
4079+ else if (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND)
4080+ {
4081+ /* 'SHOW ' commands become SQLCOM_SELECT. */
4082+ diff_stats.other_commands++;
4083+ /* 'SHOW ' commands shouldn't inflate total sent row count. */
4084+ diff_stats.rows_fetched-= sent_row_count;
4085+ }
4086+ else if (is_update_query(lex->sql_command))
4087+ {
4088+ diff_stats.update_commands++;
4089+ }
4090+ else
4091+ {
4092+ diff_stats.other_commands++;
4093+ }
4094 }
4095 }
4096- }
4097- // diff_commit_trans is updated in handler.cc.
4098- // diff_rollback_trans is updated in handler.cc.
4099- // diff_denied_connections is updated in sql_parse.cc.
4100- // diff_lost_connections is updated in sql_parse.cc.
4101- // diff_access_denied_errors is updated in sql_parse.cc.
4102+ /* diff_stats.commit_trans is updated in handler.cc. */
4103+ /* diff_stats.rollback_trans is updated in handler.cc. */
4104+ /* diff_stats.denied_connections is updated in sql_parse.cc. */
4105+ /* diff_stats.lost_connections is updated in sql_parse.cc. */
4106+ /* diff_stats.access_denied_errors is updated in sql_parse.cc.*/
4107
4108- /* reset counters to zero to avoid double-counting since values
4109- are already store in diff_total_*. */
4110+ /*
4111+ reset counters to zero to avoid double-counting since values
4112+ are already store in diff_stats.*.
4113+ */
4114 }
4115- busy_time = 0;
4116- cpu_time = 0;
4117- bytes_received = 0;
4118- bytes_sent = 0;
4119- binlog_bytes_written = 0;
4120- updated_row_count = 0;
4121- sent_row_count_2 = 0;
4122+ busy_time= 0;
4123+ cpu_time= 0;
4124+ bytes_received= 0;
4125+ bytes_sent= 0;
4126+ binlog_bytes_written= 0;
4127+ updated_row_count= 0;
4128+ DBUG_VOID_RETURN;
4129 }
4130
4131 /*
4132@@ -1888,8 +1913,10 @@
4133 */
4134 buffer.set(buff, sizeof(buff), &my_charset_bin);
4135 }
4136+
4137+ DBUG_PRINT("query",("%-.4096s", thd->query()));
4138 thd->sent_row_count++;
4139- thd->sent_row_count_2++;
4140+
4141 if (thd->is_error())
4142 {
4143 protocol->remove_last_row();
4144@@ -1993,8 +2020,7 @@
4145
4146 select_export::~select_export()
4147 {
4148- thd->sent_row_count=row_count;
4149- thd->sent_row_count_2=row_count;
4150+ thd->sent_row_count= row_count;
4151 }
4152
4153
4154@@ -3027,7 +3053,7 @@
4155 if (likely(thd != 0))
4156 { /* current_thd==0 when close_connection() calls net_send_error() */
4157 thd->status_var.bytes_sent+= length;
4158- thd->bytes_sent+= length;
4159+ thd->bytes_sent+= length;
4160 }
4161 }
4162
4163@@ -3035,7 +3061,7 @@
4164 void thd_increment_bytes_received(ulong length)
4165 {
4166 current_thd->status_var.bytes_received+= length;
4167- current_thd->bytes_received+= length;
4168+ current_thd->bytes_received+= length;
4169 }
4170
4171
4172
4173=== modified file 'Percona-Server/sql/sql_class.h'
4174--- Percona-Server/sql/sql_class.h 2012-01-30 04:30:33 +0000
4175+++ Percona-Server/sql/sql_class.h 2012-02-02 06:08:22 +0000
4176@@ -1906,7 +1906,6 @@
4177 enum_tx_isolation session_tx_isolation;
4178 enum_check_fields count_cuted_fields;
4179 ha_rows updated_row_count;
4180- ha_rows sent_row_count_2; /* for userstat */
4181
4182 DYNAMIC_ARRAY user_var_events; /* For user variables replication */
4183 MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
4184@@ -2001,41 +2000,23 @@
4185 occasionally with the 'diff' variables. After the update, the 'diff'
4186 variables are reset to 0.
4187 */
4188- // Time when the current thread connected to MySQL.
4189+ /* Time when the current thread connected to MySQL. */
4190 time_t current_connect_time;
4191- // Last time when THD stats were updated in global_user_stats.
4192- time_t last_global_update_time;
4193- // Busy (non-idle) time for just one command.
4194+ /* Busy (non-idle) time for just one command. */
4195 double busy_time;
4196- // Busy time not updated in global_user_stats yet.
4197- double diff_total_busy_time;
4198- // Cpu (non-idle) time for just one thread.
4199+ /* Cpu (non-idle) time for just one thread. */
4200 double cpu_time;
4201- // Cpu time not updated in global_user_stats yet.
4202- double diff_total_cpu_time;
4203 /* bytes counting */
4204 ulonglong bytes_received;
4205- ulonglong diff_total_bytes_received;
4206 ulonglong bytes_sent;
4207- ulonglong diff_total_bytes_sent;
4208 ulonglong binlog_bytes_written;
4209- ulonglong diff_total_binlog_bytes_written;
4210-
4211- // Number of rows not reflected in global_user_stats yet.
4212- ha_rows diff_total_sent_rows, diff_total_updated_rows, diff_total_read_rows;
4213- // Number of commands not reflected in global_user_stats yet.
4214- ulonglong diff_select_commands, diff_update_commands, diff_other_commands;
4215- // Number of transactions not reflected in global_user_stats yet.
4216- ulonglong diff_commit_trans, diff_rollback_trans;
4217- // Number of connection errors not reflected in global_user_stats yet.
4218- ulonglong diff_denied_connections, diff_lost_connections;
4219- // Number of db access denied, not reflected in global_user_stats yet.
4220- ulonglong diff_access_denied_errors;
4221- // Number of queries that return 0 rows
4222- ulonglong diff_empty_queries;
4223-
4224- // Per account query delay in miliseconds. When not 0, sleep this number of
4225- // milliseconds before every SQL command.
4226+
4227+ STATS diff_stats;
4228+
4229+ /*
4230+ Per account query delay in miliseconds. When not 0, sleep this number of
4231+ milliseconds before every SQL command.
4232+ */
4233 ulonglong query_delay_millis;
4234
4235 /* Used by the sys_var class to store temporary values */
4236@@ -2105,8 +2086,10 @@
4237 void init_for_queries();
4238 void reset_stats(void);
4239 void reset_diff_stats(void);
4240- // ran_command is true when this is called immediately after a
4241- // command has been run.
4242+ /*
4243+ ran_command is true when this is called immediately after a
4244+ command has been run.
4245+ */
4246 void update_stats(bool ran_command);
4247 void change_user(void);
4248 void cleanup(void);
4249@@ -2477,13 +2460,15 @@
4250 *p_db= strmake(db, db_length);
4251 *p_db_length= db_length;
4252 return FALSE;
4253-
4254- // Returns string as 'IP:port' for the client-side of the connnection represented
4255- // by 'client' as displayed by SHOW PROCESSLIST. Allocates memory from the heap of
4256- // this THD and that is not reclaimed immediately, so use sparingly. May return NULL.
4257 }
4258 thd_scheduler scheduler;
4259
4260+ /*
4261+ Returns string as 'IP:port' for the client-side of the connnection
4262+ represented by 'client' as displayed by SHOW PROCESSLIST.
4263+ Allocates memory from the heap of this THD and that is not reclaimed
4264+ immediately, so use sparingly. May return NULL.
4265+ */
4266 char *get_client_host_port(THD *client);
4267
4268 public:
4269
4270=== modified file 'Percona-Server/sql/sql_connect.cc'
4271--- Percona-Server/sql/sql_connect.cc 2011-11-24 01:59:48 +0000
4272+++ Percona-Server/sql/sql_connect.cc 2012-02-02 06:08:22 +0000
4273@@ -20,6 +20,7 @@
4274 */
4275
4276 #include "mysql_priv.h"
4277+#include "debug_sync.h"
4278
4279 /** Size of the header fields of an authentication packet. */
4280 #define AUTH_PACKET_HEADER_SIZE_PROTO_41 32
4281@@ -30,24 +31,26 @@
4282 extern void win_install_sigabrt_handler();
4283 #endif
4284
4285-// Increments connection count for user.
4286-static int increment_connection_count(THD* thd, bool use_lock);
4287-
4288-// Uses the THD to update the global stats by user name and client IP
4289-void update_global_user_stats(THD* thd, bool create_user, time_t now);
4290-
4291-HASH global_user_stats;
4292+/* Increments connection count for user. */
4293+/*static int increment_connection_count(THD* thd, bool use_lock);*/
4294+
4295+/* Uses the THD to update the global stats by user name and client hostname */
4296+/*void update_global_stats(THD* thd, bool create_user, time_t now);*/
4297+
4298+/* Set stats for concurrent connections displayed by mysqld_show(). */
4299+/*void set_connections_stats();*/
4300+
4301 HASH global_client_stats;
4302+HASH global_index_stats;
4303+HASH global_table_stats;
4304 HASH global_thread_stats;
4305-// Protects global_user_stats and global_client_stats
4306+HASH global_user_stats;
4307+
4308+/* Protects global_user_stats and global_client_stats */
4309 extern pthread_mutex_t LOCK_global_user_client_stats;
4310-
4311-HASH global_table_stats;
4312+extern pthread_mutex_t LOCK_global_index_stats;
4313 extern pthread_mutex_t LOCK_global_table_stats;
4314
4315-HASH global_index_stats;
4316-extern pthread_mutex_t LOCK_global_index_stats;
4317-
4318 /*
4319 Get structure for logging connection data for the current user
4320 */
4321@@ -59,6 +62,7 @@
4322 const char *host,
4323 USER_RESOURCES *mqh)
4324 {
4325+ DBUG_ENTER("get_or_create_user_conn");
4326 int return_val= 0;
4327 size_t temp_len, user_len;
4328 char temp_user[USER_HOST_BUFF_SIZE];
4329@@ -70,8 +74,8 @@
4330 user_len= strlen(user);
4331 temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1;
4332 (void) pthread_mutex_lock(&LOCK_user_conn);
4333- if (!(uc = (struct user_conn *) hash_search(&hash_user_connections,
4334- (uchar*) temp_user, temp_len)))
4335+ if (!(uc= (struct user_conn *) hash_search(&hash_user_connections,
4336+ (uchar*) temp_user, temp_len)))
4337 {
4338 /* First connection for user; Create a user connection object */
4339 if (!(uc= ((struct user_conn*)
4340@@ -101,567 +105,504 @@
4341 uc->connections++;
4342 end:
4343 (void) pthread_mutex_unlock(&LOCK_user_conn);
4344- return return_val;
4345-
4346-}
4347-
4348-extern "C" uchar *get_key_user_stats(USER_STATS *user_stats, size_t *length,
4349- my_bool not_used __attribute__((unused)))
4350-{
4351- *length = strlen(user_stats->user);
4352- return (uchar*)user_stats->user;
4353-}
4354-
4355-extern "C" uchar *get_key_thread_stats(THREAD_STATS *thread_stats, size_t *length,
4356- my_bool not_used __attribute__((unused)))
4357-{
4358- *length = sizeof(my_thread_id);
4359- return (uchar*)&(thread_stats->id);
4360-}
4361+ DBUG_RETURN(return_val);
4362+
4363+}
4364+
4365+extern "C" uchar *get_key_index_stats(INDEX_STATS* index_stats,
4366+ size_t* length,
4367+ my_bool not_used __attribute__((unused)))
4368+{
4369+ DBUG_ENTER("get_key_index_stats");
4370+ *length= strlen(index_stats->index);
4371+ DBUG_RETURN((uchar*)index_stats->index);
4372+}
4373+
4374+
4375+extern "C" uchar *get_key_table_stats(TABLE_STATS* table_stats,
4376+ size_t* length,
4377+ my_bool not_used __attribute__((unused)))
4378+{
4379+ DBUG_ENTER("get_key_table_stats");
4380+ *length= strlen(table_stats->table);
4381+ DBUG_RETURN((uchar*)table_stats->table);
4382+}
4383+
4384+
4385+extern "C" uchar *get_key_thread_stats(THREAD_STATS* thread_stats,
4386+ size_t* length,
4387+ my_bool not_used __attribute__((unused)))
4388+{
4389+ DBUG_ENTER("get_key_thread_stats");
4390+ *length= sizeof(my_thread_id);
4391+ DBUG_RETURN((uchar*)&(thread_stats->id));
4392+}
4393+
4394+
4395+extern "C" uchar *get_key_user_stats(USER_STATS* user_stats,
4396+ size_t* length,
4397+ my_bool not_used __attribute__((unused)))
4398+{
4399+ DBUG_ENTER("get_key_user_stats");
4400+ *length= strlen(user_stats->user);
4401+ DBUG_RETURN((uchar*)user_stats->user);
4402+}
4403+
4404+
4405+extern "C" void free_index_stats(INDEX_STATS* index_stats)
4406+{
4407+ my_free((char*)index_stats, MYF(0));
4408+}
4409+
4410+
4411+extern "C" void free_table_stats(TABLE_STATS* table_stats)
4412+{
4413+ my_free((char*)table_stats, MYF(0));
4414+}
4415+
4416+
4417+void free_thread_stats(THREAD_STATS* thread_stats)
4418+{
4419+ my_free((char*)thread_stats, MYF(0));
4420+}
4421+
4422
4423 void free_user_stats(USER_STATS* user_stats)
4424 {
4425 my_free((char*)user_stats, MYF(0));
4426 }
4427
4428-void free_thread_stats(THREAD_STATS* thread_stats)
4429-{
4430- my_free((char*)thread_stats, MYF(0));
4431-}
4432-
4433-void init_user_stats(USER_STATS *user_stats,
4434- const char *user,
4435- const char *priv_user,
4436- uint total_connections,
4437- uint concurrent_connections,
4438- time_t connected_time,
4439- double busy_time,
4440- double cpu_time,
4441- ulonglong bytes_received,
4442- ulonglong bytes_sent,
4443- ulonglong binlog_bytes_written,
4444- ha_rows rows_fetched,
4445- ha_rows rows_updated,
4446- ha_rows rows_read,
4447- ulonglong select_commands,
4448- ulonglong update_commands,
4449- ulonglong other_commands,
4450- ulonglong commit_trans,
4451- ulonglong rollback_trans,
4452- ulonglong denied_connections,
4453- ulonglong lost_connections,
4454- ulonglong access_denied_errors,
4455- ulonglong empty_queries)
4456-{
4457- DBUG_ENTER("init_user_stats");
4458- DBUG_PRINT("info",
4459- ("Add user_stats entry for user %s - priv_user %s",
4460- user, priv_user));
4461+void free_global_client_stats(void)
4462+{
4463+ hash_free(&global_client_stats);
4464+}
4465+
4466+
4467+void free_global_index_stats(void)
4468+{
4469+ hash_free(&global_index_stats);
4470+}
4471+
4472+
4473+void free_global_table_stats(void)
4474+{
4475+ hash_free(&global_table_stats);
4476+}
4477+
4478+
4479+void free_global_thread_stats(void)
4480+{
4481+ hash_free(&global_thread_stats);
4482+}
4483+
4484+
4485+void free_global_user_stats(void)
4486+{
4487+ hash_free(&global_user_stats);
4488+}
4489+
4490+
4491+void init_stats(STATS* stats)
4492+{
4493+ memset(stats, 0, sizeof(stats));
4494+}
4495+
4496+
4497+void init_thread_stats(THREAD_STATS* thread_stats, my_thread_id id)
4498+{
4499+ thread_stats->id= id;
4500+ init_stats(&thread_stats->stats);
4501+}
4502+
4503+
4504+void init_user_stats(USER_STATS *user_stats, const char *user)
4505+{
4506 strncpy(user_stats->user, user, sizeof(user_stats->user));
4507- strncpy(user_stats->priv_user, priv_user, sizeof(user_stats->priv_user));
4508-
4509- user_stats->total_connections = total_connections;
4510- user_stats->concurrent_connections = concurrent_connections;
4511- user_stats->connected_time = connected_time;
4512- user_stats->busy_time = busy_time;
4513- user_stats->cpu_time = cpu_time;
4514- user_stats->bytes_received = bytes_received;
4515- user_stats->bytes_sent = bytes_sent;
4516- user_stats->binlog_bytes_written = binlog_bytes_written;
4517- user_stats->rows_fetched = rows_fetched;
4518- user_stats->rows_updated = rows_updated;
4519- user_stats->rows_read = rows_read;
4520- user_stats->select_commands = select_commands;
4521- user_stats->update_commands = update_commands;
4522- user_stats->other_commands = other_commands;
4523- user_stats->commit_trans = commit_trans;
4524- user_stats->rollback_trans = rollback_trans;
4525- user_stats->denied_connections = denied_connections;
4526- user_stats->lost_connections = lost_connections;
4527- user_stats->access_denied_errors = access_denied_errors;
4528- user_stats->empty_queries = empty_queries;
4529- DBUG_VOID_RETURN;
4530-}
4531-
4532-void init_thread_stats(THREAD_STATS *thread_stats,
4533- my_thread_id id,
4534- uint total_connections,
4535- uint concurrent_connections,
4536- time_t connected_time,
4537- double busy_time,
4538- double cpu_time,
4539- ulonglong bytes_received,
4540- ulonglong bytes_sent,
4541- ulonglong binlog_bytes_written,
4542- ha_rows rows_fetched,
4543- ha_rows rows_updated,
4544- ha_rows rows_read,
4545- ulonglong select_commands,
4546- ulonglong update_commands,
4547- ulonglong other_commands,
4548- ulonglong commit_trans,
4549- ulonglong rollback_trans,
4550- ulonglong denied_connections,
4551- ulonglong lost_connections,
4552- ulonglong access_denied_errors,
4553- ulonglong empty_queries)
4554-{
4555- DBUG_ENTER("init_thread_stats");
4556- DBUG_PRINT("info",
4557- ("Add thread_stats entry for thread %lu",
4558- id));
4559- thread_stats->id = id;
4560-
4561- thread_stats->total_connections = total_connections;
4562- thread_stats->concurrent_connections = concurrent_connections;
4563- thread_stats->connected_time = connected_time;
4564- thread_stats->busy_time = busy_time;
4565- thread_stats->cpu_time = cpu_time;
4566- thread_stats->bytes_received = bytes_received;
4567- thread_stats->bytes_sent = bytes_sent;
4568- thread_stats->binlog_bytes_written = binlog_bytes_written;
4569- thread_stats->rows_fetched = rows_fetched;
4570- thread_stats->rows_updated = rows_updated;
4571- thread_stats->rows_read = rows_read;
4572- thread_stats->select_commands = select_commands;
4573- thread_stats->update_commands = update_commands;
4574- thread_stats->other_commands = other_commands;
4575- thread_stats->commit_trans = commit_trans;
4576- thread_stats->rollback_trans = rollback_trans;
4577- thread_stats->denied_connections = denied_connections;
4578- thread_stats->lost_connections = lost_connections;
4579- thread_stats->access_denied_errors = access_denied_errors;
4580- thread_stats->empty_queries = empty_queries;
4581- DBUG_VOID_RETURN;
4582-}
4583-
4584-void add_user_stats(USER_STATS *user_stats,
4585- uint total_connections,
4586- uint concurrent_connections,
4587- time_t connected_time,
4588- double busy_time,
4589- double cpu_time,
4590- ulonglong bytes_received,
4591- ulonglong bytes_sent,
4592- ulonglong binlog_bytes_written,
4593- ha_rows rows_fetched,
4594- ha_rows rows_updated,
4595- ha_rows rows_read,
4596- ulonglong select_commands,
4597- ulonglong update_commands,
4598- ulonglong other_commands,
4599- ulonglong commit_trans,
4600- ulonglong rollback_trans,
4601- ulonglong denied_connections,
4602- ulonglong lost_connections,
4603- ulonglong access_denied_errors,
4604- ulonglong empty_queries)
4605-{
4606- user_stats->total_connections += total_connections;
4607- user_stats->concurrent_connections += concurrent_connections;
4608- user_stats->connected_time += connected_time;
4609- user_stats->busy_time += busy_time;
4610- user_stats->cpu_time += cpu_time;
4611- user_stats->bytes_received += bytes_received;
4612- user_stats->bytes_sent += bytes_sent;
4613- user_stats->binlog_bytes_written += binlog_bytes_written;
4614- user_stats->rows_fetched += rows_fetched;
4615- user_stats->rows_updated += rows_updated;
4616- user_stats->rows_read += rows_read;
4617- user_stats->select_commands += select_commands;
4618- user_stats->update_commands += update_commands;
4619- user_stats->other_commands += other_commands;
4620- user_stats->commit_trans += commit_trans;
4621- user_stats->rollback_trans += rollback_trans;
4622- user_stats->denied_connections += denied_connections;
4623- user_stats->lost_connections += lost_connections;
4624- user_stats->access_denied_errors += access_denied_errors;
4625- user_stats->empty_queries += empty_queries;
4626-}
4627-
4628-void add_thread_stats(THREAD_STATS *thread_stats,
4629- uint total_connections,
4630- uint concurrent_connections,
4631- time_t connected_time,
4632- double busy_time,
4633- double cpu_time,
4634- ulonglong bytes_received,
4635- ulonglong bytes_sent,
4636- ulonglong binlog_bytes_written,
4637- ha_rows rows_fetched,
4638- ha_rows rows_updated,
4639- ha_rows rows_read,
4640- ulonglong select_commands,
4641- ulonglong update_commands,
4642- ulonglong other_commands,
4643- ulonglong commit_trans,
4644- ulonglong rollback_trans,
4645- ulonglong denied_connections,
4646- ulonglong lost_connections,
4647- ulonglong access_denied_errors,
4648- ulonglong empty_queries)
4649-{
4650- thread_stats->total_connections += total_connections;
4651- thread_stats->concurrent_connections += concurrent_connections;
4652- thread_stats->connected_time += connected_time;
4653- thread_stats->busy_time += busy_time;
4654- thread_stats->cpu_time += cpu_time;
4655- thread_stats->bytes_received += bytes_received;
4656- thread_stats->bytes_sent += bytes_sent;
4657- thread_stats->binlog_bytes_written += binlog_bytes_written;
4658- thread_stats->rows_fetched += rows_fetched;
4659- thread_stats->rows_updated += rows_updated;
4660- thread_stats->rows_read += rows_read;
4661- thread_stats->select_commands += select_commands;
4662- thread_stats->update_commands += update_commands;
4663- thread_stats->other_commands += other_commands;
4664- thread_stats->commit_trans += commit_trans;
4665- thread_stats->rollback_trans += rollback_trans;
4666- thread_stats->denied_connections += denied_connections;
4667- thread_stats->lost_connections += lost_connections;
4668- thread_stats->access_denied_errors += access_denied_errors;
4669- thread_stats->empty_queries += empty_queries;
4670-}
4671-
4672-void init_global_user_stats(void)
4673-{
4674- if (hash_init(&global_user_stats, system_charset_info, max_connections,
4675- 0, 0, (hash_get_key)get_key_user_stats,
4676- (hash_free_key)free_user_stats, 0)) {
4677- sql_print_error("Initializing global_user_stats failed.");
4678- exit(1);
4679- }
4680-}
4681+ init_stats(&user_stats->stats);
4682+}
4683+
4684
4685 void init_global_client_stats(void)
4686 {
4687+ DBUG_ENTER("init_global_client_stats");
4688 if (hash_init(&global_client_stats, system_charset_info, max_connections,
4689 0, 0, (hash_get_key)get_key_user_stats,
4690- (hash_free_key)free_user_stats, 0)) {
4691- sql_print_error("Initializing global_client_stats failed.");
4692- exit(1);
4693- }
4694-}
4695-
4696-void init_global_thread_stats(void)
4697-{
4698- if (hash_init(&global_thread_stats, &my_charset_bin, max_connections,
4699- 0, 0, (hash_get_key)get_key_thread_stats,
4700- (hash_free_key)free_thread_stats, 0)) {
4701- sql_print_error("Initializing global_client_stats failed.");
4702- exit(1);
4703- }
4704-}
4705-
4706-extern "C" uchar *get_key_table_stats(TABLE_STATS *table_stats, size_t *length,
4707- my_bool not_used __attribute__((unused)))
4708-{
4709- *length = strlen(table_stats->table);
4710- return (uchar*)table_stats->table;
4711-}
4712-
4713-extern "C" void free_table_stats(TABLE_STATS* table_stats)
4714-{
4715- my_free((char*)table_stats, MYF(0));
4716-}
4717+ (hash_free_key)free_user_stats, 0))
4718+ {
4719+ sql_print_error("Initializing global_client_stats failed.");
4720+ exit(1);
4721+ }
4722+ DBUG_VOID_RETURN;
4723+}
4724+
4725+
4726+void init_global_index_stats(void)
4727+{
4728+ if (hash_init(&global_index_stats, system_charset_info, max_connections,
4729+ 0, 0, (hash_get_key)get_key_index_stats,
4730+ (hash_free_key)free_index_stats, 0))
4731+ {
4732+ sql_print_error("Initializing global_index_stats failed.");
4733+ exit(1);
4734+ }
4735+}
4736+
4737
4738 void init_global_table_stats(void)
4739 {
4740+ DBUG_ENTER("init_global_table_stats");
4741 if (hash_init(&global_table_stats, system_charset_info, max_connections,
4742 0, 0, (hash_get_key)get_key_table_stats,
4743- (hash_free_key)free_table_stats, 0)) {
4744+ (hash_free_key)free_table_stats, 0))
4745+ {
4746 sql_print_error("Initializing global_table_stats failed.");
4747 exit(1);
4748 }
4749-}
4750-
4751-extern "C" uchar *get_key_index_stats(INDEX_STATS *index_stats, size_t *length,
4752- my_bool not_used __attribute__((unused)))
4753-{
4754- *length = strlen(index_stats->index);
4755- return (uchar*)index_stats->index;
4756-}
4757-
4758-extern "C" void free_index_stats(INDEX_STATS* index_stats)
4759-{
4760- my_free((char*)index_stats, MYF(0));
4761-}
4762-
4763-void init_global_index_stats(void)
4764-{
4765- if (hash_init(&global_index_stats, system_charset_info, max_connections,
4766- 0, 0, (hash_get_key)get_key_index_stats,
4767- (hash_free_key)free_index_stats, 0)) {
4768- sql_print_error("Initializing global_index_stats failed.");
4769- exit(1);
4770- }
4771-}
4772-
4773-void free_global_user_stats(void)
4774-{
4775- hash_free(&global_user_stats);
4776-}
4777-
4778-void free_global_thread_stats(void)
4779-{
4780- hash_free(&global_thread_stats);
4781-}
4782-
4783-void free_global_table_stats(void)
4784-{
4785- hash_free(&global_table_stats);
4786-}
4787-
4788-void free_global_index_stats(void)
4789-{
4790- hash_free(&global_index_stats);
4791-}
4792-
4793-void free_global_client_stats(void)
4794-{
4795- hash_free(&global_client_stats);
4796-}
4797-
4798-// 'mysql_system_user' is used for when the user is not defined for a THD.
4799-static char mysql_system_user[] = "#mysql_system#";
4800-
4801-// Returns 'user' if it's not NULL. Returns 'mysql_system_user' otherwise.
4802-static char* get_valid_user_string(char* user) {
4803+ DBUG_VOID_RETURN;
4804+}
4805+
4806+
4807+void init_global_thread_stats(void)
4808+{
4809+ DBUG_ENTER("init_global_thread_stats");
4810+ if (hash_init(&global_thread_stats, &my_charset_bin, max_connections,
4811+ 0, 0, (hash_get_key)get_key_thread_stats,
4812+ (hash_free_key)free_thread_stats, 0))
4813+ {
4814+ sql_print_error("Initializing global_thread_stats failed.");
4815+ exit(1);
4816+ }
4817+ DBUG_VOID_RETURN;
4818+}
4819+
4820+
4821+void init_global_user_stats(void)
4822+{
4823+ DBUG_ENTER("init_global_user_stats");
4824+ if (hash_init(&global_user_stats, system_charset_info, max_connections,
4825+ 0, 0, (hash_get_key)get_key_user_stats,
4826+ (hash_free_key)free_user_stats, 0))
4827+ {
4828+ sql_print_error("Initializing global_user_stats failed.");
4829+ exit(1);
4830+ }
4831+ DBUG_VOID_RETURN;
4832+}
4833+
4834+
4835+/* 'mysql_system_user' is used for when the user is not defined for a THD. */
4836+static char mysql_system_user[]= "#mysql_system#";
4837+
4838+/**
4839+ Stringify the user name (system user too)
4840+
4841+ @retval user if user is not NULL.
4842+ @retval mysqld_system_user if user is NULL.
4843+*/
4844+static const char* get_valid_user_string(const char* user)
4845+{
4846 return user ? user : mysql_system_user;
4847 }
4848
4849-// Increments the global stats connection count for an entry from
4850-// global_client_stats or global_user_stats. Returns 0 on success
4851-// and 1 on error.
4852-static int increment_count_by_name(const char *name, const char *role_name,
4853- HASH *users_or_clients, THD *thd)
4854+/**
4855+ Increments the global stats connection count for an entry from
4856+ global_client_stats or global_user_stats.
4857+
4858+ @retval 0 on success.
4859+ @retval 1 on error.
4860+*/
4861+static int increment_count_by_name(const char *name,
4862+ HASH *collection,
4863+ THD *thd)
4864 {
4865- USER_STATS* user_stats;
4866+ DBUG_ENTER("increment_count_by_name");
4867+ USER_STATS* stats;
4868
4869- if (!(user_stats = (USER_STATS*)hash_search(users_or_clients, (uchar*) name,
4870- strlen(name))))
4871+ if (!(stats= (USER_STATS*)hash_search(collection,
4872+ (uchar*) name,
4873+ strlen(name))))
4874 {
4875- // First connection for this user or client
4876- if (!(user_stats = ((USER_STATS*)
4877- my_malloc(sizeof(USER_STATS), MYF(MY_WME | MY_ZEROFILL)))))
4878+ /* First connection for this user or client */
4879+ if (!(stats= ((USER_STATS*)my_malloc(sizeof(USER_STATS),
4880+ MYF(MY_WME | MY_ZEROFILL)))))
4881 {
4882- return 1; // Out of memory
4883+ /* Out of memory */
4884+ DBUG_RETURN(1);
4885 }
4886
4887- init_user_stats(user_stats, name, role_name,
4888- 0, 0, // connections
4889- 0, 0, 0, // time
4890- 0, 0, 0, // bytes sent, received and written
4891- 0, 0, 0, // rows fetched, updated and read
4892- 0, 0, 0, // select, update and other commands
4893- 0, 0, // commit and rollback trans
4894- thd->diff_denied_connections,
4895- 0, // lost connections
4896- 0, // access denied errors
4897- 0); // empty queries
4898+ init_user_stats(stats, name);
4899+ stats->stats.denied_connections= thd->diff_stats.denied_connections;
4900
4901- if (my_hash_insert(users_or_clients, (uchar*)user_stats))
4902+ if (my_hash_insert(collection, (uchar*)stats))
4903 {
4904- my_free((char*)user_stats, 0);
4905- return 1; // Out of memory
4906+ my_free((char*)stats, 0);
4907+ /* Out of memory */
4908+ DBUG_RETURN(1);
4909 }
4910 }
4911- user_stats->total_connections++;
4912- return 0;
4913+ stats->stats.total_connections++;
4914+ DBUG_RETURN(0);
4915 }
4916
4917 static int increment_count_by_id(my_thread_id id,
4918- HASH *users_or_clients, THD *thd)
4919+ HASH *collection,
4920+ THD *thd)
4921 {
4922- THREAD_STATS* thread_stats;
4923+ DBUG_ENTER("increment_count_by_id");
4924+ THREAD_STATS* stats;
4925
4926- if (!(thread_stats = (THREAD_STATS*)hash_search(users_or_clients, (uchar*) &id,
4927- sizeof(my_thread_id))))
4928+ if (!(stats= (THREAD_STATS*)hash_search(collection,
4929+ (uchar*) &id,
4930+ sizeof(my_thread_id))))
4931 {
4932- // First connection for this user or client
4933- if (!(thread_stats = ((THREAD_STATS*)
4934- my_malloc(sizeof(THREAD_STATS), MYF(MY_WME | MY_ZEROFILL)))))
4935+ /* First connection for this user or client */
4936+ if (!(stats= ((THREAD_STATS*)my_malloc(sizeof(THREAD_STATS),
4937+ MYF(MY_WME | MY_ZEROFILL)))))
4938 {
4939- return 1; // Out of memory
4940+ /* Out of memory */
4941+ DBUG_RETURN(1);
4942 }
4943
4944- init_thread_stats(thread_stats, id,
4945- 0, 0, // connections
4946- 0, 0, 0, // time
4947- 0, 0, 0, // bytes sent, received and written
4948- 0, 0, 0, // rows fetched, updated and read
4949- 0, 0, 0, // select, update and other commands
4950- 0, 0, // commit and rollback trans
4951- thd->diff_denied_connections,
4952- 0, // lost connections
4953- 0, // access denied errors
4954- 0); // empty queries
4955-
4956- if (my_hash_insert(users_or_clients, (uchar*)thread_stats))
4957+ init_thread_stats(stats, id);
4958+ stats->stats.denied_connections= thd->diff_stats.denied_connections;
4959+ if (my_hash_insert(collection, (uchar*)stats))
4960 {
4961- my_free((char*)thread_stats, 0);
4962- return 1; // Out of memory
4963+ my_free((char*)stats, 0);
4964+ /* Out of memory */
4965+ DBUG_RETURN(1);
4966 }
4967 }
4968- thread_stats->total_connections++;
4969- return 0;
4970+ stats->stats.total_connections++;
4971+ DBUG_RETURN(0);
4972 }
4973
4974-// Increments the global user and client stats connection count. If 'use_lock'
4975-// is true, LOCK_global_user_client_stats will be locked/unlocked. Returns
4976-// 0 on success, 1 on error.
4977-static int increment_connection_count(THD* thd, bool use_lock)
4978+/**
4979+ Increments the global client, thread and user stats connection count.
4980+
4981+ @retval 0 on success.
4982+ @retval 1 on error.
4983+*/
4984+static int increment_connection_count(THD* thd)
4985 {
4986- char* user_string = get_valid_user_string(thd->main_security_ctx.user);
4987- const char* client_string = get_client_host(thd);
4988- int return_value = 0;
4989+ DBUG_ENTER("increment_connection_count");
4990+ const char* user_string= get_valid_user_string(thd->main_security_ctx.user);
4991+ const char* client_string= get_client_host(thd);
4992+ int return_value= 0;
4993
4994 if (!opt_userstat_running)
4995- return return_value;
4996-
4997- if (use_lock) pthread_mutex_lock(&LOCK_global_user_client_stats);
4998-
4999- if (increment_count_by_name(user_string, user_string,
5000- &global_user_stats, thd))
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches