1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
select variable_value from information_schema.global_status where variable_name="handler_read_key" into @global_read_key;
Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
show columns from information_schema.client_statistics;
Field Type Null Key Default Extra
CLIENT varchar(64) NO
TOTAL_CONNECTIONS bigint(21) NO 0
CONCURRENT_CONNECTIONS bigint(21) NO 0
CONNECTED_TIME bigint(21) NO 0
BUSY_TIME double NO 0
CPU_TIME double NO 0
BYTES_RECEIVED bigint(21) NO 0
BYTES_SENT bigint(21) NO 0
BINLOG_BYTES_WRITTEN bigint(21) NO 0
ROWS_READ bigint(21) NO 0
ROWS_SENT bigint(21) NO 0
ROWS_DELETED bigint(21) NO 0
ROWS_INSERTED bigint(21) NO 0
ROWS_UPDATED bigint(21) NO 0
SELECT_COMMANDS bigint(21) NO 0
UPDATE_COMMANDS bigint(21) NO 0
OTHER_COMMANDS bigint(21) NO 0
COMMIT_TRANSACTIONS bigint(21) NO 0
ROLLBACK_TRANSACTIONS bigint(21) NO 0
DENIED_CONNECTIONS bigint(21) NO 0
LOST_CONNECTIONS bigint(21) NO 0
ACCESS_DENIED bigint(21) NO 0
EMPTY_QUERIES bigint(21) NO 0
TOTAL_SSL_CONNECTIONS bigint(21) unsigned NO 0
MAX_STATEMENT_TIME_EXCEEDED bigint(21) NO 0
show columns from information_schema.user_statistics;
Field Type Null Key Default Extra
USER varchar(128) NO
TOTAL_CONNECTIONS int(11) NO 0
CONCURRENT_CONNECTIONS int(11) NO 0
CONNECTED_TIME int(11) NO 0
BUSY_TIME double NO 0
CPU_TIME double NO 0
BYTES_RECEIVED bigint(21) NO 0
BYTES_SENT bigint(21) NO 0
BINLOG_BYTES_WRITTEN bigint(21) NO 0
ROWS_READ bigint(21) NO 0
ROWS_SENT bigint(21) NO 0
ROWS_DELETED bigint(21) NO 0
ROWS_INSERTED bigint(21) NO 0
ROWS_UPDATED bigint(21) NO 0
SELECT_COMMANDS bigint(21) NO 0
UPDATE_COMMANDS bigint(21) NO 0
OTHER_COMMANDS bigint(21) NO 0
COMMIT_TRANSACTIONS bigint(21) NO 0
ROLLBACK_TRANSACTIONS bigint(21) NO 0
DENIED_CONNECTIONS bigint(21) NO 0
LOST_CONNECTIONS bigint(21) NO 0
ACCESS_DENIED bigint(21) NO 0
EMPTY_QUERIES bigint(21) NO 0
TOTAL_SSL_CONNECTIONS bigint(21) unsigned NO 0
MAX_STATEMENT_TIME_EXCEEDED bigint(21) NO 0
show columns from information_schema.index_statistics;
Field Type Null Key Default Extra
TABLE_SCHEMA varchar(192) NO
TABLE_NAME varchar(192) NO
INDEX_NAME varchar(192) NO
ROWS_READ bigint(21) NO 0
show columns from information_schema.table_statistics;
Field Type Null Key Default Extra
TABLE_SCHEMA varchar(192) NO
TABLE_NAME varchar(192) NO
ROWS_READ bigint(21) NO 0
ROWS_CHANGED bigint(21) NO 0
ROWS_CHANGED_X_INDEXES bigint(21) NO 0
set @save_general_log=@@global.general_log;
set @@global.general_log=0;
set @@global.userstat=1;
flush status;
create table t1 (a int, primary key (a), b int default 0) engine=innodb;
insert into t1 (a) values (1),(2),(3),(4);
update t1 set b=1;
update t1 set b=5 where a=2;
delete from t1 where a=3;
/* Empty query */
select * from t1 where a=999;
a b
drop table t1;
connect ssl_con,localhost,root,,,,,SSL;
SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher';
have_ssl
1
connection default;
create table t1 (a int, primary key (a), b int default 0) engine=innodb;
begin;
insert into t1 values(1,1);
commit;
begin;
insert into t1 values(2,2);
commit;
begin;
insert into t1 values(3,3);
rollback;
drop table t1;
select sleep(1);
sleep(1)
0
show status like "rows%";
Variable_name Value
Rows_read 6
Rows_sent 1
Rows_tmp_read 0
show status like "ha%";
Variable_name Value
Handler_commit 19
Handler_delete 1
Handler_discover 0
Handler_external_lock 0
Handler_icp_attempts 0
Handler_icp_match 0
Handler_mrr_init 0
Handler_mrr_key_refills 0
Handler_mrr_rowid_refills 0
Handler_prepare 18
Handler_read_first 0
Handler_read_key 17
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 5
Handler_rollback 2
Handler_savepoint 0
Handler_savepoint_rollback 0
Handler_tmp_delete 0
Handler_tmp_update 0
Handler_tmp_write 0
Handler_update 5
Handler_write 7
select variable_value - @global_read_key as "handler_read_key" from information_schema.global_status where variable_name="handler_read_key";
handler_read_key
17
disconnect ssl_con;
set @@global.userstat=0;
select * from information_schema.index_statistics;
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
select * from information_schema.table_statistics;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
show index_statistics;
Table_schema Table_name Index_name Rows_read
select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;;
TOTAL_CONNECTIONS 2
TOTAL_SSL_CONNECTIONS 1
CONCURRENT_CONNECTIONS 0
ROWS_READ 6
ROWS_SENT 3
ROWS_DELETED 1
ROWS_INSERTED 7
ROWS_UPDATED 5
SELECT_COMMANDS 4
UPDATE_COMMANDS 11
COMMIT_TRANSACTIONS 19
ROLLBACK_TRANSACTIONS 2
DENIED_CONNECTIONS 0
LOST_CONNECTIONS 0
ACCESS_DENIED 0
EMPTY_QUERIES 1
select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics;;
TOTAL_CONNECTIONS 2
TOTAL_SSL_CONNECTIONS 1
CONCURRENT_CONNECTIONS 0
ROWS_READ 6
ROWS_SENT 3
ROWS_DELETED 1
ROWS_INSERTED 7
ROWS_UPDATED 5
SELECT_COMMANDS 4
UPDATE_COMMANDS 11
COMMIT_TRANSACTIONS 19
ROLLBACK_TRANSACTIONS 2
DENIED_CONNECTIONS 0
LOST_CONNECTIONS 0
ACCESS_DENIED 0
EMPTY_QUERIES 1
select OTHER_COMMANDS IN (7,8) from information_schema.client_statistics;
OTHER_COMMANDS IN (7,8)
1
select OTHER_COMMANDS IN (7,8) from information_schema.user_statistics;
OTHER_COMMANDS IN (7,8)
1
flush table_statistics;
flush index_statistics;
select * from information_schema.index_statistics;
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
select * from information_schema.table_statistics;
TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES
show status like "%generic%";
Variable_name Value
Com_show_generic 2
select connected_time <> 0, busy_time <> 0, bytes_received <> 0,
bytes_sent <> 0, binlog_bytes_written <> 0
from information_schema.user_statistics;
connected_time <> 0 busy_time <> 0 bytes_received <> 0 bytes_sent <> 0 binlog_bytes_written <> 0
1 1 1 1 1
select connected_time <> 0, busy_time <> 0, bytes_received <> 0,
bytes_sent <> 0, binlog_bytes_written <> 0
from information_schema.client_statistics;
connected_time <> 0 busy_time <> 0 bytes_received <> 0 bytes_sent <> 0 binlog_bytes_written <> 0
1 1 1 1 1
create table t1 (a int) engine=innodb;
select @@in_transaction;
@@in_transaction
0
begin;
select @@in_transaction;
@@in_transaction
1
insert into t1 values (1);
select @@in_transaction;
@@in_transaction
1
commit;
select @@in_transaction;
@@in_transaction
0
set @@autocommit=0;
select @@in_transaction;
@@in_transaction
0
insert into t1 values (2);
select @@in_transaction;
@@in_transaction
1
set @@autocommit=1;
select @@in_transaction;
@@in_transaction
0
drop table t1;
set @@global.general_log=@save_general_log;
#
# MDEV-25242 Server crashes in check_grant upon invoking function with userstat enabled
#
create function f() returns int return (select 1 from performance_schema.threads);
set global userstat= 1;
select f() from information_schema.table_statistics;
ERROR 21000: Subquery returns more than 1 row
select f() from information_schema.index_statistics;
ERROR 21000: Subquery returns more than 1 row
set global userstat= 0;
drop function f;
#
# End of 10.2 tests
#
|