mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
move userstat tables to a plugin
This commit is contained in:
@ -129,6 +129,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
|
|||||||
TABLE_PRIVILEGES TABLE_PRIVILEGES
|
TABLE_PRIVILEGES TABLE_PRIVILEGES
|
||||||
TABLE_STATISTICS TABLE_STATISTICS
|
TABLE_STATISTICS TABLE_STATISTICS
|
||||||
TRIGGERS TRIGGERS
|
TRIGGERS TRIGGERS
|
||||||
|
t1 t1
|
||||||
|
t2 t2
|
||||||
|
t3 t3
|
||||||
|
t4 t4
|
||||||
|
t5 t5
|
||||||
table_stats table_stats
|
table_stats table_stats
|
||||||
tables_priv tables_priv
|
tables_priv tables_priv
|
||||||
time_zone time_zone
|
time_zone time_zone
|
||||||
@ -136,11 +141,6 @@ time_zone_leap_second time_zone_leap_second
|
|||||||
time_zone_name time_zone_name
|
time_zone_name time_zone_name
|
||||||
time_zone_transition time_zone_transition
|
time_zone_transition time_zone_transition
|
||||||
time_zone_transition_type time_zone_transition_type
|
time_zone_transition_type time_zone_transition_type
|
||||||
t1 t1
|
|
||||||
t4 t4
|
|
||||||
t2 t2
|
|
||||||
t3 t3
|
|
||||||
t5 t5
|
|
||||||
select c,table_name from v1
|
select c,table_name from v1
|
||||||
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
||||||
where v1.c like "t%";
|
where v1.c like "t%";
|
||||||
@ -151,6 +151,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
|
|||||||
TABLE_PRIVILEGES TABLE_PRIVILEGES
|
TABLE_PRIVILEGES TABLE_PRIVILEGES
|
||||||
TABLE_STATISTICS TABLE_STATISTICS
|
TABLE_STATISTICS TABLE_STATISTICS
|
||||||
TRIGGERS TRIGGERS
|
TRIGGERS TRIGGERS
|
||||||
|
t1 t1
|
||||||
|
t2 t2
|
||||||
|
t3 t3
|
||||||
|
t4 t4
|
||||||
|
t5 t5
|
||||||
table_stats table_stats
|
table_stats table_stats
|
||||||
tables_priv tables_priv
|
tables_priv tables_priv
|
||||||
time_zone time_zone
|
time_zone time_zone
|
||||||
@ -158,11 +163,6 @@ time_zone_leap_second time_zone_leap_second
|
|||||||
time_zone_name time_zone_name
|
time_zone_name time_zone_name
|
||||||
time_zone_transition time_zone_transition
|
time_zone_transition time_zone_transition
|
||||||
time_zone_transition_type time_zone_transition_type
|
time_zone_transition_type time_zone_transition_type
|
||||||
t1 t1
|
|
||||||
t4 t4
|
|
||||||
t2 t2
|
|
||||||
t3 t3
|
|
||||||
t5 t5
|
|
||||||
select c, v2.table_name from v1
|
select c, v2.table_name from v1
|
||||||
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
||||||
where v1.c like "t%";
|
where v1.c like "t%";
|
||||||
@ -173,6 +173,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
|
|||||||
TABLE_PRIVILEGES TABLE_PRIVILEGES
|
TABLE_PRIVILEGES TABLE_PRIVILEGES
|
||||||
TABLE_STATISTICS TABLE_STATISTICS
|
TABLE_STATISTICS TABLE_STATISTICS
|
||||||
TRIGGERS TRIGGERS
|
TRIGGERS TRIGGERS
|
||||||
|
t1 t1
|
||||||
|
t2 t2
|
||||||
|
t3 t3
|
||||||
|
t4 t4
|
||||||
|
t5 t5
|
||||||
table_stats table_stats
|
table_stats table_stats
|
||||||
tables_priv tables_priv
|
tables_priv tables_priv
|
||||||
time_zone time_zone
|
time_zone time_zone
|
||||||
@ -180,11 +185,6 @@ time_zone_leap_second time_zone_leap_second
|
|||||||
time_zone_name time_zone_name
|
time_zone_name time_zone_name
|
||||||
time_zone_transition time_zone_transition
|
time_zone_transition time_zone_transition
|
||||||
time_zone_transition_type time_zone_transition_type
|
time_zone_transition_type time_zone_transition_type
|
||||||
t1 t1
|
|
||||||
t4 t4
|
|
||||||
t2 t2
|
|
||||||
t3 t3
|
|
||||||
t5 t5
|
|
||||||
select table_name from information_schema.TABLES
|
select table_name from information_schema.TABLES
|
||||||
where table_schema = "mysqltest" and table_name like "t%";
|
where table_schema = "mysqltest" and table_name like "t%";
|
||||||
table_name
|
table_name
|
||||||
|
@ -55,14 +55,17 @@ create view v1 (c) as
|
|||||||
--sorted_result
|
--sorted_result
|
||||||
select * from v1;
|
select * from v1;
|
||||||
|
|
||||||
|
--sorted_result
|
||||||
select c,table_name from v1
|
select c,table_name from v1
|
||||||
inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
||||||
where v1.c like "t%";
|
where v1.c like "t%";
|
||||||
|
|
||||||
|
--sorted_result
|
||||||
select c,table_name from v1
|
select c,table_name from v1
|
||||||
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
||||||
where v1.c like "t%";
|
where v1.c like "t%";
|
||||||
|
|
||||||
|
--sorted_result
|
||||||
select c, v2.table_name from v1
|
select c, v2.table_name from v1
|
||||||
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
||||||
where v1.c like "t%";
|
where v1.c like "t%";
|
||||||
@ -368,17 +371,20 @@ drop view vo;
|
|||||||
select TABLE_NAME,TABLE_TYPE,ENGINE
|
select TABLE_NAME,TABLE_TYPE,ENGINE
|
||||||
from information_schema.tables
|
from information_schema.tables
|
||||||
where table_schema='information_schema' limit 2;
|
where table_schema='information_schema' limit 2;
|
||||||
|
--sorted_result
|
||||||
show tables from information_schema like "T%";
|
show tables from information_schema like "T%";
|
||||||
|
|
||||||
--error ER_DBACCESS_DENIED_ERROR
|
--error ER_DBACCESS_DENIED_ERROR
|
||||||
create database information_schema;
|
create database information_schema;
|
||||||
use information_schema;
|
use information_schema;
|
||||||
|
--sorted_result
|
||||||
show full tables like "T%";
|
show full tables like "T%";
|
||||||
--error ER_DBACCESS_DENIED_ERROR
|
--error ER_DBACCESS_DENIED_ERROR
|
||||||
create table t1(a int);
|
create table t1(a int);
|
||||||
use test;
|
use test;
|
||||||
show tables;
|
show tables;
|
||||||
use information_schema;
|
use information_schema;
|
||||||
|
--sorted_result
|
||||||
show tables like "T%";
|
show tables like "T%";
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -15,6 +15,7 @@ drop function if exists f2;
|
|||||||
--enable_warnings
|
--enable_warnings
|
||||||
|
|
||||||
--replace_result 'Tables_in_INFORMATION_SCHEMA (T%)' 'Tables_in_information_schema (T%)'
|
--replace_result 'Tables_in_INFORMATION_SCHEMA (T%)' 'Tables_in_information_schema (T%)'
|
||||||
|
--sorted_result
|
||||||
show tables from INFORMATION_SCHEMA like 'T%';
|
show tables from INFORMATION_SCHEMA like 'T%';
|
||||||
create database `inf%`;
|
create database `inf%`;
|
||||||
create database mbase;
|
create database mbase;
|
||||||
|
4
plugin/userstat/CMakeLists.txt
Normal file
4
plugin/userstat/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql)
|
||||||
|
|
||||||
|
MYSQL_ADD_PLUGIN(USERSTAT userstat.cc MANDATORY)
|
||||||
|
|
97
plugin/userstat/client_stats.cc
Normal file
97
plugin/userstat/client_stats.cc
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
static ST_FIELD_INFO client_stats_fields[]=
|
||||||
|
{
|
||||||
|
{"CLIENT", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Client", 0},
|
||||||
|
{"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Total_connections", 0},
|
||||||
|
{"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Concurrent_connections", 0},
|
||||||
|
{"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Connected_time", 0},
|
||||||
|
{"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_DOUBLE, 0, 0, "Busy_time", 0},
|
||||||
|
{"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_DOUBLE, 0, 0, "Cpu_time", 0},
|
||||||
|
{"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Bytes_received", 0},
|
||||||
|
{"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Bytes_sent", 0},
|
||||||
|
{"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Binlog_bytes_written", 0},
|
||||||
|
{"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_read", 0},
|
||||||
|
{"ROWS_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_sent", 0},
|
||||||
|
{"ROWS_DELETED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_deleted", 0},
|
||||||
|
{"ROWS_INSERTED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_inserted", 0},
|
||||||
|
{"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_updated", 0},
|
||||||
|
{"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Select_commands", 0},
|
||||||
|
{"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Update_commands", 0},
|
||||||
|
{"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Other_commands", 0},
|
||||||
|
{"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Commit_transactions", 0},
|
||||||
|
{"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rollback_transactions", 0},
|
||||||
|
{"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Denied_connections", 0},
|
||||||
|
{"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Lost_connections", 0},
|
||||||
|
{"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Access_denied", 0},
|
||||||
|
{"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Empty_queries", 0},
|
||||||
|
{"MAX_STATEMENT_TIME_EXCEEDED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Max_statement_time_exceeded",SKIP_OPEN_TABLE},
|
||||||
|
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
|
||||||
|
{
|
||||||
|
mysql_mutex_lock(&LOCK_global_user_client_stats);
|
||||||
|
for (uint i= 0; i < all_user_stats->records; i++)
|
||||||
|
{
|
||||||
|
uint j= 0;
|
||||||
|
USER_STATS *user_stats= (USER_STATS*) my_hash_element(all_user_stats, i);
|
||||||
|
|
||||||
|
table->field[j++]->store(user_stats->user, user_stats->user_name_length,
|
||||||
|
system_charset_info);
|
||||||
|
table->field[j++]->store((longlong)user_stats->total_connections,TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->concurrent_connections, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->connected_time, TRUE);
|
||||||
|
table->field[j++]->store((double)user_stats->busy_time);
|
||||||
|
table->field[j++]->store((double)user_stats->cpu_time);
|
||||||
|
table->field[j++]->store((longlong)user_stats->bytes_received, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->bytes_sent, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->binlog_bytes_written, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->rows_read, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->rows_sent, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->rows_deleted, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->rows_inserted, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->rows_updated, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->select_commands, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->update_commands, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->other_commands, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->commit_trans, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->rollback_trans, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->denied_connections, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->lost_connections, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->access_denied_errors, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->empty_queries, TRUE);
|
||||||
|
table->field[j++]->store((longlong)user_stats->max_statement_time_exceeded, TRUE);
|
||||||
|
if (schema_table_store_record(thd, table))
|
||||||
|
{
|
||||||
|
mysql_mutex_unlock(&LOCK_global_user_client_stats);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mysql_mutex_unlock(&LOCK_global_user_client_stats);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int client_stats_fill(THD* thd, TABLE_LIST* tables, COND* cond)
|
||||||
|
{
|
||||||
|
if (check_global_access(thd, SUPER_ACL | PROCESS_ACL, true))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return send_user_stats(thd, &global_client_stats, tables->table);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int client_stats_reset()
|
||||||
|
{
|
||||||
|
mysql_mutex_lock(&LOCK_global_user_client_stats);
|
||||||
|
free_global_client_stats();
|
||||||
|
init_global_client_stats();
|
||||||
|
mysql_mutex_unlock(&LOCK_global_user_client_stats);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int client_stats_init(void *p)
|
||||||
|
{
|
||||||
|
ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p;
|
||||||
|
schema->fields_info= client_stats_fields;
|
||||||
|
schema->fill_table= client_stats_fill;
|
||||||
|
schema->reset_table= client_stats_reset;
|
||||||
|
return 0;
|
||||||
|
}
|
72
plugin/userstat/index_stats.cc
Normal file
72
plugin/userstat/index_stats.cc
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
static ST_FIELD_INFO index_stats_fields[]=
|
||||||
|
{
|
||||||
|
{"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema",SKIP_OPEN_TABLE},
|
||||||
|
{"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name",SKIP_OPEN_TABLE},
|
||||||
|
{"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name",SKIP_OPEN_TABLE},
|
||||||
|
{"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_read",SKIP_OPEN_TABLE},
|
||||||
|
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0,0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int index_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||||
|
{
|
||||||
|
TABLE *table= tables->table;
|
||||||
|
|
||||||
|
mysql_mutex_lock(&LOCK_global_index_stats);
|
||||||
|
for (uint i= 0; i < global_index_stats.records; i++)
|
||||||
|
{
|
||||||
|
INDEX_STATS *index_stats =
|
||||||
|
(INDEX_STATS*) my_hash_element(&global_index_stats, i);
|
||||||
|
TABLE_LIST tmp_table;
|
||||||
|
char *index_name;
|
||||||
|
size_t schema_name_length, table_name_length, index_name_length;
|
||||||
|
|
||||||
|
bzero((char*) &tmp_table,sizeof(tmp_table));
|
||||||
|
tmp_table.db= index_stats->index;
|
||||||
|
tmp_table.table_name= strend(index_stats->index)+1;
|
||||||
|
tmp_table.grant.privilege= 0;
|
||||||
|
if (check_access(thd, SELECT_ACL, tmp_table.db,
|
||||||
|
&tmp_table.grant.privilege, NULL, 0, 1) ||
|
||||||
|
check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
index_name= strend(tmp_table.table_name)+1;
|
||||||
|
schema_name_length= (tmp_table.table_name - index_stats->index) -1;
|
||||||
|
table_name_length= (index_name - tmp_table.table_name)-1;
|
||||||
|
index_name_length= (index_stats->index_name_length - schema_name_length -
|
||||||
|
table_name_length - 3);
|
||||||
|
|
||||||
|
table->field[0]->store(tmp_table.db, schema_name_length,
|
||||||
|
system_charset_info);
|
||||||
|
table->field[1]->store(tmp_table.table_name, table_name_length,
|
||||||
|
system_charset_info);
|
||||||
|
table->field[2]->store(index_name, index_name_length, system_charset_info);
|
||||||
|
table->field[3]->store((longlong)index_stats->rows_read, TRUE);
|
||||||
|
|
||||||
|
if (schema_table_store_record(thd, table))
|
||||||
|
{
|
||||||
|
mysql_mutex_unlock(&LOCK_global_index_stats);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mysql_mutex_unlock(&LOCK_global_index_stats);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int index_stats_reset()
|
||||||
|
{
|
||||||
|
mysql_mutex_lock(&LOCK_global_index_stats);
|
||||||
|
free_global_index_stats();
|
||||||
|
init_global_index_stats();
|
||||||
|
mysql_mutex_unlock(&LOCK_global_index_stats);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int index_stats_init(void *p)
|
||||||
|
{
|
||||||
|
ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p;
|
||||||
|
schema->fields_info= index_stats_fields;
|
||||||
|
schema->fill_table= index_stats_fill;
|
||||||
|
schema->reset_table= index_stats_reset;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
73
plugin/userstat/table_stats.cc
Normal file
73
plugin/userstat/table_stats.cc
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
static ST_FIELD_INFO table_stats_fields[]=
|
||||||
|
{
|
||||||
|
{"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema",SKIP_OPEN_TABLE},
|
||||||
|
{"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name",SKIP_OPEN_TABLE},
|
||||||
|
{"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_read",SKIP_OPEN_TABLE},
|
||||||
|
{"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_changed",SKIP_OPEN_TABLE},
|
||||||
|
{"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_changed_x_#indexes",SKIP_OPEN_TABLE},
|
||||||
|
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int table_stats_fill(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||||
|
{
|
||||||
|
TABLE *table= tables->table;
|
||||||
|
|
||||||
|
mysql_mutex_lock(&LOCK_global_table_stats);
|
||||||
|
for (uint i= 0; i < global_table_stats.records; i++)
|
||||||
|
{
|
||||||
|
char *end_of_schema;
|
||||||
|
TABLE_STATS *table_stats=
|
||||||
|
(TABLE_STATS*)my_hash_element(&global_table_stats, i);
|
||||||
|
TABLE_LIST tmp_table;
|
||||||
|
size_t schema_length, table_name_length;
|
||||||
|
|
||||||
|
end_of_schema= strend(table_stats->table);
|
||||||
|
schema_length= (size_t) (end_of_schema - table_stats->table);
|
||||||
|
table_name_length= strlen(table_stats->table + schema_length + 1);
|
||||||
|
|
||||||
|
bzero((char*) &tmp_table,sizeof(tmp_table));
|
||||||
|
tmp_table.db= table_stats->table;
|
||||||
|
tmp_table.table_name= end_of_schema+1;
|
||||||
|
tmp_table.grant.privilege= 0;
|
||||||
|
if (check_access(thd, SELECT_ACL, tmp_table.db,
|
||||||
|
&tmp_table.grant.privilege, NULL, 0, 1) ||
|
||||||
|
check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX,
|
||||||
|
1))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
table->field[0]->store(table_stats->table, schema_length,
|
||||||
|
system_charset_info);
|
||||||
|
table->field[1]->store(table_stats->table + schema_length+1,
|
||||||
|
table_name_length, system_charset_info);
|
||||||
|
table->field[2]->store((longlong)table_stats->rows_read, TRUE);
|
||||||
|
table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
|
||||||
|
table->field[4]->store((longlong)table_stats->rows_changed_x_indexes,
|
||||||
|
TRUE);
|
||||||
|
if (schema_table_store_record(thd, table))
|
||||||
|
{
|
||||||
|
mysql_mutex_unlock(&LOCK_global_table_stats);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mysql_mutex_unlock(&LOCK_global_table_stats);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int table_stats_reset()
|
||||||
|
{
|
||||||
|
mysql_mutex_lock(&LOCK_global_table_stats);
|
||||||
|
free_global_table_stats();
|
||||||
|
init_global_table_stats();
|
||||||
|
mysql_mutex_unlock(&LOCK_global_table_stats);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int table_stats_init(void *p)
|
||||||
|
{
|
||||||
|
ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p;
|
||||||
|
schema->fields_info= table_stats_fields;
|
||||||
|
schema->fill_table= table_stats_fill;
|
||||||
|
schema->reset_table= table_stats_reset;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
55
plugin/userstat/user_stats.cc
Normal file
55
plugin/userstat/user_stats.cc
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
static ST_FIELD_INFO user_stats_fields[]=
|
||||||
|
{
|
||||||
|
{"USER", USERNAME_CHAR_LENGTH, MYSQL_TYPE_STRING, 0, 0, "User", 0},
|
||||||
|
{"TOTAL_CONNECTIONS", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections", 0},
|
||||||
|
{"CONCURRENT_CONNECTIONS", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections", 0},
|
||||||
|
{"CONNECTED_TIME", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time", 0},
|
||||||
|
{"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_DOUBLE, 0, 0, "Busy_time", 0},
|
||||||
|
{"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_DOUBLE, 0, 0, "Cpu_time", 0},
|
||||||
|
{"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Bytes_received", 0},
|
||||||
|
{"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Bytes_sent", 0},
|
||||||
|
{"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Binlog_bytes_written", 0},
|
||||||
|
{"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_read", 0},
|
||||||
|
{"ROWS_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_sent", 0},
|
||||||
|
{"ROWS_DELETED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_deleted", 0},
|
||||||
|
{"ROWS_INSERTED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_inserted", 0},
|
||||||
|
{"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_updated", 0},
|
||||||
|
{"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Select_commands", 0},
|
||||||
|
{"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Update_commands", 0},
|
||||||
|
{"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Other_commands", 0},
|
||||||
|
{"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Commit_transactions", 0},
|
||||||
|
{"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rollback_transactions", 0},
|
||||||
|
{"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Denied_connections", 0},
|
||||||
|
{"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Lost_connections", 0},
|
||||||
|
{"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Access_denied", 0},
|
||||||
|
{"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Empty_queries", 0},
|
||||||
|
{"MAX_STATEMENT_TIME_EXCEEDED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Max_statement_time_exceeded",SKIP_OPEN_TABLE},
|
||||||
|
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int user_stats_fill(THD* thd, TABLE_LIST* tables, COND* cond)
|
||||||
|
{
|
||||||
|
if (check_global_access(thd, SUPER_ACL | PROCESS_ACL, true))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return send_user_stats(thd, &global_user_stats, tables->table);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int user_stats_reset()
|
||||||
|
{
|
||||||
|
mysql_mutex_lock(&LOCK_global_user_client_stats);
|
||||||
|
free_global_user_stats();
|
||||||
|
init_global_user_stats();
|
||||||
|
mysql_mutex_unlock(&LOCK_global_user_client_stats);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int user_stats_init(void *p)
|
||||||
|
{
|
||||||
|
ST_SCHEMA_TABLE *schema= (ST_SCHEMA_TABLE *)p;
|
||||||
|
schema->fields_info= user_stats_fields;
|
||||||
|
schema->fill_table= user_stats_fill;
|
||||||
|
schema->reset_table= user_stats_reset;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
81
plugin/userstat/userstat.cc
Normal file
81
plugin/userstat/userstat.cc
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#include <mysql/plugin.h>
|
||||||
|
#include <mysql_version.h>
|
||||||
|
#include "table.h"
|
||||||
|
#include "sql_connect.h"
|
||||||
|
#include "field.h"
|
||||||
|
#include "sql_const.h"
|
||||||
|
#include "sql_acl.h"
|
||||||
|
|
||||||
|
bool schema_table_store_record(THD *thd, TABLE *table);
|
||||||
|
|
||||||
|
#include "client_stats.cc"
|
||||||
|
#include "index_stats.cc"
|
||||||
|
#include "table_stats.cc"
|
||||||
|
#include "user_stats.cc"
|
||||||
|
|
||||||
|
static struct st_mysql_information_schema userstat_info=
|
||||||
|
{ MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION };
|
||||||
|
|
||||||
|
maria_declare_plugin(userstat)
|
||||||
|
{
|
||||||
|
MYSQL_INFORMATION_SCHEMA_PLUGIN,
|
||||||
|
&userstat_info,
|
||||||
|
"CLIENT_STATISTICS",
|
||||||
|
"Percona and Sergei Golubchik",
|
||||||
|
"Client Statistics",
|
||||||
|
PLUGIN_LICENSE_GPL,
|
||||||
|
client_stats_init,
|
||||||
|
0,
|
||||||
|
0x0200,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
"2.0",
|
||||||
|
MariaDB_PLUGIN_MATURITY_GAMMA
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MYSQL_INFORMATION_SCHEMA_PLUGIN,
|
||||||
|
&userstat_info,
|
||||||
|
"INDEX_STATISTICS",
|
||||||
|
"Percona and Sergei Golubchik",
|
||||||
|
"Index Statistics",
|
||||||
|
PLUGIN_LICENSE_GPL,
|
||||||
|
index_stats_init,
|
||||||
|
0,
|
||||||
|
0x0200,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
"2.0",
|
||||||
|
MariaDB_PLUGIN_MATURITY_GAMMA
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MYSQL_INFORMATION_SCHEMA_PLUGIN,
|
||||||
|
&userstat_info,
|
||||||
|
"TABLE_STATISTICS",
|
||||||
|
"Percona and Sergei Golubchik",
|
||||||
|
"Table Statistics",
|
||||||
|
PLUGIN_LICENSE_GPL,
|
||||||
|
table_stats_init,
|
||||||
|
0,
|
||||||
|
0x0200,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
"2.0",
|
||||||
|
MariaDB_PLUGIN_MATURITY_GAMMA
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MYSQL_INFORMATION_SCHEMA_PLUGIN,
|
||||||
|
&userstat_info,
|
||||||
|
"USER_STATISTICS",
|
||||||
|
"Percona and Sergei Golubchik",
|
||||||
|
"User Statistics",
|
||||||
|
PLUGIN_LICENSE_GPL,
|
||||||
|
user_stats_init,
|
||||||
|
0,
|
||||||
|
0x0200,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
"2.0",
|
||||||
|
MariaDB_PLUGIN_MATURITY_GAMMA
|
||||||
|
}
|
||||||
|
maria_declare_plugin_end;
|
||||||
|
|
@ -720,7 +720,6 @@ enum enum_schema_tables
|
|||||||
SCH_ALL_PLUGINS,
|
SCH_ALL_PLUGINS,
|
||||||
SCH_APPLICABLE_ROLES,
|
SCH_APPLICABLE_ROLES,
|
||||||
SCH_CHARSETS,
|
SCH_CHARSETS,
|
||||||
SCH_CLIENT_STATS,
|
|
||||||
SCH_COLLATIONS,
|
SCH_COLLATIONS,
|
||||||
SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
|
SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
|
||||||
SCH_COLUMNS,
|
SCH_COLUMNS,
|
||||||
@ -732,7 +731,6 @@ enum enum_schema_tables
|
|||||||
SCH_FILES,
|
SCH_FILES,
|
||||||
SCH_GLOBAL_STATUS,
|
SCH_GLOBAL_STATUS,
|
||||||
SCH_GLOBAL_VARIABLES,
|
SCH_GLOBAL_VARIABLES,
|
||||||
SCH_INDEX_STATS,
|
|
||||||
SCH_KEY_CACHES,
|
SCH_KEY_CACHES,
|
||||||
SCH_KEY_COLUMN_USAGE,
|
SCH_KEY_COLUMN_USAGE,
|
||||||
SCH_OPEN_TABLES,
|
SCH_OPEN_TABLES,
|
||||||
@ -754,10 +752,8 @@ enum enum_schema_tables
|
|||||||
SCH_TABLE_CONSTRAINTS,
|
SCH_TABLE_CONSTRAINTS,
|
||||||
SCH_TABLE_NAMES,
|
SCH_TABLE_NAMES,
|
||||||
SCH_TABLE_PRIVILEGES,
|
SCH_TABLE_PRIVILEGES,
|
||||||
SCH_TABLE_STATS,
|
|
||||||
SCH_TRIGGERS,
|
SCH_TRIGGERS,
|
||||||
SCH_USER_PRIVILEGES,
|
SCH_USER_PRIVILEGES,
|
||||||
SCH_USER_STATS,
|
|
||||||
SCH_VIEWS
|
SCH_VIEWS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ class THD;
|
|||||||
int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
|
int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
|
||||||
bool schema_table_store_record(THD *thd, TABLE *table);
|
bool schema_table_store_record(THD *thd, TABLE *table);
|
||||||
void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
|
void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
|
||||||
bool check_global_access(THD *thd, ulong want_access, bool no_errors=false);
|
|
||||||
uint strconvert(CHARSET_INFO *from_cs, const char *from, uint from_length,
|
uint strconvert(CHARSET_INFO *from_cs, const char *from, uint from_length,
|
||||||
CHARSET_INFO *to_cs, char *to, uint to_length,
|
CHARSET_INFO *to_cs, char *to, uint to_length,
|
||||||
uint *errors);
|
uint *errors);
|
||||||
|
@ -10206,6 +10206,11 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
bool check_grant(THD *, ulong, TABLE_LIST *, bool, uint, bool)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif /*NO_EMBEDDED_ACCESS_CHECKS */
|
#endif /*NO_EMBEDDED_ACCESS_CHECKS */
|
||||||
|
|
||||||
int fill_schema_enabled_roles(THD *thd, TABLE_LIST *tables, COND *cond)
|
int fill_schema_enabled_roles(THD *thd, TABLE_LIST *tables, COND *cond)
|
||||||
|
@ -235,6 +235,10 @@ bool check_grant_all_columns(THD *thd, ulong want_access,
|
|||||||
bool check_grant_routine(THD *thd, ulong want_access,
|
bool check_grant_routine(THD *thd, ulong want_access,
|
||||||
TABLE_LIST *procs, bool is_proc, bool no_error);
|
TABLE_LIST *procs, bool is_proc, bool no_error);
|
||||||
bool check_grant_db(THD *thd,const char *db);
|
bool check_grant_db(THD *thd,const char *db);
|
||||||
|
bool check_global_access(THD *thd, ulong want_access, bool no_errors= false);
|
||||||
|
bool check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
||||||
|
GRANT_INTERNAL_INFO *grant_internal_info,
|
||||||
|
bool dont_check_global_grants, bool no_errors);
|
||||||
ulong get_table_grant(THD *thd, TABLE_LIST *table);
|
ulong get_table_grant(THD *thd, TABLE_LIST *table);
|
||||||
ulong get_column_grant(THD *thd, GRANT_INFO *grant,
|
ulong get_column_grant(THD *thd, GRANT_INFO *grant,
|
||||||
const char *db_name, const char *table_name,
|
const char *db_name, const char *table_name,
|
||||||
@ -263,10 +267,6 @@ int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
|
|||||||
int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
|
int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond);
|
||||||
int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr);
|
int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr);
|
||||||
int check_password_policy(String *password);
|
int check_password_policy(String *password);
|
||||||
#ifdef NO_EMBEDDED_ACCESS_CHECKS
|
|
||||||
#define check_grant(A,B,C,D,E,F) 0
|
|
||||||
#define check_grant_db(A,B) 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Result of an access check for an internal schema or table.
|
Result of an access check for an internal schema or table.
|
||||||
|
@ -2115,10 +2115,6 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
|
|||||||
thd->profiling.discard_current_query();
|
thd->profiling.discard_current_query();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case SCH_USER_STATS:
|
|
||||||
case SCH_CLIENT_STATS:
|
|
||||||
if (check_global_access(thd, SUPER_ACL | PROCESS_ACL, true))
|
|
||||||
DBUG_RETURN(1);
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -148,15 +148,6 @@ inline bool check_identifier_name(LEX_STRING *str)
|
|||||||
return check_identifier_name(str, NAME_CHAR_LEN, 0, "");
|
return check_identifier_name(str, NAME_CHAR_LEN, 0, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
check_access() is needed for the connect engine.
|
|
||||||
It cannot be inlined - it must be exported.
|
|
||||||
*/
|
|
||||||
bool check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
|
|
||||||
GRANT_INTERNAL_INFO *grant_internal_info,
|
|
||||||
bool dont_check_global_grants, bool no_errors);
|
|
||||||
|
|
||||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||||
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
|
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
|
||||||
bool check_single_table_access(THD *thd, ulong privilege,
|
bool check_single_table_access(THD *thd, ulong privilege,
|
||||||
@ -194,8 +185,4 @@ check_table_access(THD *thd, ulong requirements,TABLE_LIST *tables,
|
|||||||
{ return false; }
|
{ return false; }
|
||||||
#endif /*NO_EMBEDDED_ACCESS_CHECKS*/
|
#endif /*NO_EMBEDDED_ACCESS_CHECKS*/
|
||||||
|
|
||||||
/* These were under the INNODB_COMPATIBILITY_HOOKS */
|
|
||||||
|
|
||||||
bool check_global_access(THD *thd, ulong want_access, bool no_errors= false);
|
|
||||||
|
|
||||||
#endif /* SQL_PARSE_INCLUDED */
|
#endif /* SQL_PARSE_INCLUDED */
|
||||||
|
347
sql/sql_show.cc
347
sql/sql_show.cc
@ -3125,267 +3125,6 @@ end:
|
|||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Write result to network for SHOW USER_STATISTICS
|
|
||||||
|
|
||||||
SYNOPSIS
|
|
||||||
send_user_stats
|
|
||||||
all_user_stats - values to return
|
|
||||||
table - I_S table
|
|
||||||
|
|
||||||
RETURN
|
|
||||||
0 - OK
|
|
||||||
1 - error
|
|
||||||
*/
|
|
||||||
|
|
||||||
int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
|
|
||||||
{
|
|
||||||
DBUG_ENTER("send_user_stats");
|
|
||||||
|
|
||||||
for (uint i= 0; i < all_user_stats->records; i++)
|
|
||||||
{
|
|
||||||
uint j= 0;
|
|
||||||
USER_STATS *user_stats= (USER_STATS*) my_hash_element(all_user_stats, i);
|
|
||||||
|
|
||||||
table->field[j++]->store(user_stats->user, user_stats->user_name_length,
|
|
||||||
system_charset_info);
|
|
||||||
table->field[j++]->store((longlong)user_stats->total_connections,TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->concurrent_connections, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->connected_time, TRUE);
|
|
||||||
table->field[j++]->store((double)user_stats->busy_time);
|
|
||||||
table->field[j++]->store((double)user_stats->cpu_time);
|
|
||||||
table->field[j++]->store((longlong)user_stats->bytes_received, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->bytes_sent, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->binlog_bytes_written, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->rows_read, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->rows_sent, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->rows_deleted, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->rows_inserted, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->rows_updated, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->select_commands, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->update_commands, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->other_commands, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->commit_trans, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->rollback_trans, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->denied_connections, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->lost_connections, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->access_denied_errors, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->empty_queries, TRUE);
|
|
||||||
table->field[j++]->store((longlong)user_stats->max_statement_time_exceeded, TRUE);
|
|
||||||
if (schema_table_store_record(thd, table))
|
|
||||||
{
|
|
||||||
DBUG_PRINT("error", ("store record error"));
|
|
||||||
DBUG_RETURN(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DBUG_RETURN(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Process SHOW USER_STATISTICS
|
|
||||||
|
|
||||||
SYNOPSIS
|
|
||||||
mysqld_show_user_stats
|
|
||||||
thd - current thread
|
|
||||||
wild - limit results to the entry for this user
|
|
||||||
with_roles - when true, display role for mapped users
|
|
||||||
|
|
||||||
RETURN
|
|
||||||
0 - OK
|
|
||||||
1 - error
|
|
||||||
*/
|
|
||||||
|
|
||||||
int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
|
|
||||||
{
|
|
||||||
TABLE *table= tables->table;
|
|
||||||
int result;
|
|
||||||
DBUG_ENTER("fill_schema_user_stats");
|
|
||||||
|
|
||||||
if (check_global_access(thd, SUPER_ACL | PROCESS_ACL, true))
|
|
||||||
DBUG_RETURN(0);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Iterates through all the global stats and sends them to the client.
|
|
||||||
Pattern matching on the client IP is supported.
|
|
||||||
*/
|
|
||||||
|
|
||||||
mysql_mutex_lock(&LOCK_global_user_client_stats);
|
|
||||||
result= send_user_stats(thd, &global_user_stats, table) != 0;
|
|
||||||
mysql_mutex_unlock(&LOCK_global_user_client_stats);
|
|
||||||
|
|
||||||
DBUG_PRINT("exit", ("result: %d", result));
|
|
||||||
DBUG_RETURN(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Process SHOW CLIENT_STATISTICS
|
|
||||||
|
|
||||||
SYNOPSIS
|
|
||||||
mysqld_show_client_stats
|
|
||||||
thd - current thread
|
|
||||||
wild - limit results to the entry for this client
|
|
||||||
|
|
||||||
RETURN
|
|
||||||
0 - OK
|
|
||||||
1 - error
|
|
||||||
*/
|
|
||||||
|
|
||||||
int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
|
|
||||||
{
|
|
||||||
TABLE *table= tables->table;
|
|
||||||
int result;
|
|
||||||
DBUG_ENTER("fill_schema_client_stats");
|
|
||||||
|
|
||||||
if (check_global_access(thd, SUPER_ACL | PROCESS_ACL, true))
|
|
||||||
DBUG_RETURN(0);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Iterates through all the global stats and sends them to the client.
|
|
||||||
Pattern matching on the client IP is supported.
|
|
||||||
*/
|
|
||||||
|
|
||||||
mysql_mutex_lock(&LOCK_global_user_client_stats);
|
|
||||||
result= send_user_stats(thd, &global_client_stats, table) != 0;
|
|
||||||
mysql_mutex_unlock(&LOCK_global_user_client_stats);
|
|
||||||
|
|
||||||
DBUG_PRINT("exit", ("result: %d", result));
|
|
||||||
DBUG_RETURN(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Fill information schema table with table statistics */
|
|
||||||
|
|
||||||
int fill_schema_table_stats(THD *thd, TABLE_LIST *tables, COND *cond)
|
|
||||||
{
|
|
||||||
TABLE *table= tables->table;
|
|
||||||
DBUG_ENTER("fill_schema_table_stats");
|
|
||||||
|
|
||||||
mysql_mutex_lock(&LOCK_global_table_stats);
|
|
||||||
for (uint i= 0; i < global_table_stats.records; i++)
|
|
||||||
{
|
|
||||||
char *end_of_schema;
|
|
||||||
TABLE_STATS *table_stats=
|
|
||||||
(TABLE_STATS*)my_hash_element(&global_table_stats, i);
|
|
||||||
TABLE_LIST tmp_table;
|
|
||||||
size_t schema_length, table_name_length;
|
|
||||||
|
|
||||||
end_of_schema= strend(table_stats->table);
|
|
||||||
schema_length= (size_t) (end_of_schema - table_stats->table);
|
|
||||||
table_name_length= strlen(table_stats->table + schema_length + 1);
|
|
||||||
|
|
||||||
bzero((char*) &tmp_table,sizeof(tmp_table));
|
|
||||||
tmp_table.db= table_stats->table;
|
|
||||||
tmp_table.table_name= end_of_schema+1;
|
|
||||||
tmp_table.grant.privilege= 0;
|
|
||||||
if (check_access(thd, SELECT_ACL, tmp_table.db,
|
|
||||||
&tmp_table.grant.privilege, NULL, 0, 1) ||
|
|
||||||
check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX,
|
|
||||||
1))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
table->field[0]->store(table_stats->table, schema_length,
|
|
||||||
system_charset_info);
|
|
||||||
table->field[1]->store(table_stats->table + schema_length+1,
|
|
||||||
table_name_length, system_charset_info);
|
|
||||||
table->field[2]->store((longlong)table_stats->rows_read, TRUE);
|
|
||||||
table->field[3]->store((longlong)table_stats->rows_changed, TRUE);
|
|
||||||
table->field[4]->store((longlong)table_stats->rows_changed_x_indexes,
|
|
||||||
TRUE);
|
|
||||||
if (schema_table_store_record(thd, table))
|
|
||||||
{
|
|
||||||
mysql_mutex_unlock(&LOCK_global_table_stats);
|
|
||||||
DBUG_RETURN(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mysql_mutex_unlock(&LOCK_global_table_stats);
|
|
||||||
DBUG_RETURN(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Fill information schema table with index statistics */
|
|
||||||
|
|
||||||
int fill_schema_index_stats(THD *thd, TABLE_LIST *tables, COND *cond)
|
|
||||||
{
|
|
||||||
TABLE *table= tables->table;
|
|
||||||
DBUG_ENTER("fill_schema_index_stats");
|
|
||||||
|
|
||||||
mysql_mutex_lock(&LOCK_global_index_stats);
|
|
||||||
for (uint i= 0; i < global_index_stats.records; i++)
|
|
||||||
{
|
|
||||||
INDEX_STATS *index_stats =
|
|
||||||
(INDEX_STATS*) my_hash_element(&global_index_stats, i);
|
|
||||||
TABLE_LIST tmp_table;
|
|
||||||
char *index_name;
|
|
||||||
size_t schema_name_length, table_name_length, index_name_length;
|
|
||||||
|
|
||||||
bzero((char*) &tmp_table,sizeof(tmp_table));
|
|
||||||
tmp_table.db= index_stats->index;
|
|
||||||
tmp_table.table_name= strend(index_stats->index)+1;
|
|
||||||
tmp_table.grant.privilege= 0;
|
|
||||||
if (check_access(thd, SELECT_ACL, tmp_table.db,
|
|
||||||
&tmp_table.grant.privilege, NULL, 0, 1) ||
|
|
||||||
check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
index_name= strend(tmp_table.table_name)+1;
|
|
||||||
schema_name_length= (tmp_table.table_name - index_stats->index) -1;
|
|
||||||
table_name_length= (index_name - tmp_table.table_name)-1;
|
|
||||||
index_name_length= (index_stats->index_name_length - schema_name_length -
|
|
||||||
table_name_length - 3);
|
|
||||||
|
|
||||||
table->field[0]->store(tmp_table.db, schema_name_length,
|
|
||||||
system_charset_info);
|
|
||||||
table->field[1]->store(tmp_table.table_name, table_name_length,
|
|
||||||
system_charset_info);
|
|
||||||
table->field[2]->store(index_name, index_name_length, system_charset_info);
|
|
||||||
table->field[3]->store((longlong)index_stats->rows_read, TRUE);
|
|
||||||
|
|
||||||
if (schema_table_store_record(thd, table))
|
|
||||||
{
|
|
||||||
mysql_mutex_unlock(&LOCK_global_index_stats);
|
|
||||||
DBUG_RETURN(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mysql_mutex_unlock(&LOCK_global_index_stats);
|
|
||||||
DBUG_RETURN(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int reset_schema_user_stats()
|
|
||||||
{
|
|
||||||
mysql_mutex_lock(&LOCK_global_user_client_stats);
|
|
||||||
free_global_user_stats();
|
|
||||||
init_global_user_stats();
|
|
||||||
mysql_mutex_unlock(&LOCK_global_user_client_stats);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int reset_schema_client_stats()
|
|
||||||
{
|
|
||||||
mysql_mutex_lock(&LOCK_global_user_client_stats);
|
|
||||||
free_global_client_stats();
|
|
||||||
init_global_client_stats();
|
|
||||||
mysql_mutex_unlock(&LOCK_global_user_client_stats);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int reset_schema_table_stats()
|
|
||||||
{
|
|
||||||
mysql_mutex_lock(&LOCK_global_table_stats);
|
|
||||||
free_global_table_stats();
|
|
||||||
init_global_table_stats();
|
|
||||||
mysql_mutex_unlock(&LOCK_global_table_stats);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int reset_schema_index_stats()
|
|
||||||
{
|
|
||||||
mysql_mutex_lock(&LOCK_global_index_stats);
|
|
||||||
free_global_index_stats();
|
|
||||||
init_global_index_stats();
|
|
||||||
mysql_mutex_unlock(&LOCK_global_index_stats);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* collect status for all running threads */
|
/* collect status for all running threads */
|
||||||
|
|
||||||
void calc_sum_of_all_status(STATUS_VAR *to)
|
void calc_sum_of_all_status(STATUS_VAR *to)
|
||||||
@ -7312,84 +7051,6 @@ struct schema_table_ref
|
|||||||
ST_SCHEMA_TABLE *schema_table;
|
ST_SCHEMA_TABLE *schema_table;
|
||||||
};
|
};
|
||||||
|
|
||||||
ST_FIELD_INFO user_stats_fields_info[]=
|
|
||||||
{
|
|
||||||
{"USER", USERNAME_CHAR_LENGTH, MYSQL_TYPE_STRING, 0, 0, "User", SKIP_OPEN_TABLE},
|
|
||||||
{"TOTAL_CONNECTIONS", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections",SKIP_OPEN_TABLE},
|
|
||||||
{"CONCURRENT_CONNECTIONS", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections",SKIP_OPEN_TABLE},
|
|
||||||
{"CONNECTED_TIME", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time",SKIP_OPEN_TABLE},
|
|
||||||
{"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_DOUBLE, 0, 0, "Busy_time",SKIP_OPEN_TABLE},
|
|
||||||
{"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_DOUBLE, 0, 0, "Cpu_time",SKIP_OPEN_TABLE},
|
|
||||||
{"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Bytes_received",SKIP_OPEN_TABLE},
|
|
||||||
{"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Bytes_sent",SKIP_OPEN_TABLE},
|
|
||||||
{"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Binlog_bytes_written",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_read",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_sent",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_DELETED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_deleted",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_INSERTED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_inserted",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_updated",SKIP_OPEN_TABLE},
|
|
||||||
{"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Select_commands",SKIP_OPEN_TABLE},
|
|
||||||
{"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Update_commands",SKIP_OPEN_TABLE},
|
|
||||||
{"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Other_commands",SKIP_OPEN_TABLE},
|
|
||||||
{"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Commit_transactions",SKIP_OPEN_TABLE},
|
|
||||||
{"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rollback_transactions",SKIP_OPEN_TABLE},
|
|
||||||
{"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Denied_connections",SKIP_OPEN_TABLE},
|
|
||||||
{"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Lost_connections",SKIP_OPEN_TABLE},
|
|
||||||
{"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Access_denied",SKIP_OPEN_TABLE},
|
|
||||||
{"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Empty_queries",SKIP_OPEN_TABLE},
|
|
||||||
{"MAX_STATEMENT_TIME_EXCEEDED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Max_statement_time_exceeded",SKIP_OPEN_TABLE},
|
|
||||||
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
ST_FIELD_INFO client_stats_fields_info[]=
|
|
||||||
{
|
|
||||||
{"CLIENT", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Client",SKIP_OPEN_TABLE},
|
|
||||||
{"TOTAL_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Total_connections",SKIP_OPEN_TABLE},
|
|
||||||
{"CONCURRENT_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Concurrent_connections",SKIP_OPEN_TABLE},
|
|
||||||
{"CONNECTED_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Connected_time",SKIP_OPEN_TABLE},
|
|
||||||
{"BUSY_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_DOUBLE, 0, 0, "Busy_time",SKIP_OPEN_TABLE},
|
|
||||||
{"CPU_TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_DOUBLE, 0, 0, "Cpu_time",SKIP_OPEN_TABLE},
|
|
||||||
{"BYTES_RECEIVED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Bytes_received",SKIP_OPEN_TABLE},
|
|
||||||
{"BYTES_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Bytes_sent",SKIP_OPEN_TABLE},
|
|
||||||
{"BINLOG_BYTES_WRITTEN", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Binlog_bytes_written",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_read",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_sent",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_DELETED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_deleted",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_INSERTED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_inserted",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_UPDATED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_updated",SKIP_OPEN_TABLE},
|
|
||||||
{"SELECT_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Select_commands",SKIP_OPEN_TABLE},
|
|
||||||
{"UPDATE_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Update_commands",SKIP_OPEN_TABLE},
|
|
||||||
{"OTHER_COMMANDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Other_commands",SKIP_OPEN_TABLE},
|
|
||||||
{"COMMIT_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Commit_transactions",SKIP_OPEN_TABLE},
|
|
||||||
{"ROLLBACK_TRANSACTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rollback_transactions",SKIP_OPEN_TABLE},
|
|
||||||
{"DENIED_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Denied_connections",SKIP_OPEN_TABLE},
|
|
||||||
{"LOST_CONNECTIONS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Lost_connections",SKIP_OPEN_TABLE},
|
|
||||||
{"ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Access_denied",SKIP_OPEN_TABLE},
|
|
||||||
{"EMPTY_QUERIES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Empty_queries",SKIP_OPEN_TABLE},
|
|
||||||
{"MAX_STATEMENT_TIME_EXCEEDED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Max_statement_time_exceeded",SKIP_OPEN_TABLE},
|
|
||||||
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
ST_FIELD_INFO table_stats_fields_info[]=
|
|
||||||
{
|
|
||||||
{"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema",SKIP_OPEN_TABLE},
|
|
||||||
{"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_read",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_CHANGED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_changed",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_CHANGED_X_INDEXES", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_changed_x_#indexes",SKIP_OPEN_TABLE},
|
|
||||||
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
ST_FIELD_INFO index_stats_fields_info[]=
|
|
||||||
{
|
|
||||||
{"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schema",SKIP_OPEN_TABLE},
|
|
||||||
{"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name",SKIP_OPEN_TABLE},
|
|
||||||
{"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name",SKIP_OPEN_TABLE},
|
|
||||||
{"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, "Rows_read",SKIP_OPEN_TABLE},
|
|
||||||
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0,0}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Find schema_tables elment by name
|
Find schema_tables elment by name
|
||||||
|
|
||||||
@ -9062,8 +8723,6 @@ ST_SCHEMA_TABLE schema_tables[]=
|
|||||||
fill_schema_applicable_roles, 0, 0, -1, -1, 0, 0},
|
fill_schema_applicable_roles, 0, 0, -1, -1, 0, 0},
|
||||||
{"CHARACTER_SETS", charsets_fields_info, 0,
|
{"CHARACTER_SETS", charsets_fields_info, 0,
|
||||||
fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0},
|
fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, 0},
|
||||||
{"CLIENT_STATISTICS", client_stats_fields_info, reset_schema_client_stats,
|
|
||||||
fill_schema_client_stats, make_old_format, 0, -1, -1, 0, 0},
|
|
||||||
{"COLLATIONS", collation_fields_info, 0,
|
{"COLLATIONS", collation_fields_info, 0,
|
||||||
fill_schema_collation, make_old_format, 0, -1, -1, 0, 0},
|
fill_schema_collation, make_old_format, 0, -1, -1, 0, 0},
|
||||||
{"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
|
{"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
|
||||||
@ -9092,8 +8751,6 @@ ST_SCHEMA_TABLE schema_tables[]=
|
|||||||
fill_status, make_old_format, 0, 0, -1, 0, 0},
|
fill_status, make_old_format, 0, 0, -1, 0, 0},
|
||||||
{"GLOBAL_VARIABLES", variables_fields_info, 0,
|
{"GLOBAL_VARIABLES", variables_fields_info, 0,
|
||||||
fill_variables, make_old_format, 0, 0, -1, 0, 0},
|
fill_variables, make_old_format, 0, 0, -1, 0, 0},
|
||||||
{"INDEX_STATISTICS", index_stats_fields_info, reset_schema_index_stats,
|
|
||||||
fill_schema_index_stats, make_old_format, 0, -1, -1, 0, 0},
|
|
||||||
{"KEY_CACHES", keycache_fields_info, 0,
|
{"KEY_CACHES", keycache_fields_info, 0,
|
||||||
fill_key_cache_tables, 0, 0, -1,-1, 0, 0},
|
fill_key_cache_tables, 0, 0, -1,-1, 0, 0},
|
||||||
{"KEY_COLUMN_USAGE", key_column_usage_fields_info, 0,
|
{"KEY_COLUMN_USAGE", key_column_usage_fields_info, 0,
|
||||||
@ -9143,15 +8800,11 @@ ST_SCHEMA_TABLE schema_tables[]=
|
|||||||
get_all_tables, make_table_names_old_format, 0, 1, 2, 1, OPTIMIZE_I_S_TABLE},
|
get_all_tables, make_table_names_old_format, 0, 1, 2, 1, OPTIMIZE_I_S_TABLE},
|
||||||
{"TABLE_PRIVILEGES", table_privileges_fields_info, 0,
|
{"TABLE_PRIVILEGES", table_privileges_fields_info, 0,
|
||||||
fill_schema_table_privileges, 0, 0, -1, -1, 0, 0},
|
fill_schema_table_privileges, 0, 0, -1, -1, 0, 0},
|
||||||
{"TABLE_STATISTICS", table_stats_fields_info, reset_schema_table_stats,
|
|
||||||
fill_schema_table_stats, make_old_format, 0, -1, -1, 0, 0},
|
|
||||||
{"TRIGGERS", triggers_fields_info, 0,
|
{"TRIGGERS", triggers_fields_info, 0,
|
||||||
get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0,
|
get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0,
|
||||||
OPEN_TRIGGER_ONLY|OPTIMIZE_I_S_TABLE},
|
OPEN_TRIGGER_ONLY|OPTIMIZE_I_S_TABLE},
|
||||||
{"USER_PRIVILEGES", user_privileges_fields_info, 0,
|
{"USER_PRIVILEGES", user_privileges_fields_info, 0,
|
||||||
fill_schema_user_privileges, 0, 0, -1, -1, 0, 0},
|
fill_schema_user_privileges, 0, 0, -1, -1, 0, 0},
|
||||||
{"USER_STATISTICS", user_stats_fields_info, reset_schema_user_stats,
|
|
||||||
fill_schema_user_stats, make_old_format, 0, -1, -1, 0, 0},
|
|
||||||
{"VIEWS", view_fields_info, 0,
|
{"VIEWS", view_fields_info, 0,
|
||||||
get_all_tables, 0, get_schema_views_record, 1, 2, 0,
|
get_all_tables, 0, get_schema_views_record, 1, 2, 0,
|
||||||
OPEN_VIEW_ONLY|OPTIMIZE_I_S_TABLE},
|
OPEN_VIEW_ONLY|OPTIMIZE_I_S_TABLE},
|
||||||
|
Reference in New Issue
Block a user