summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/information_schema.result30
-rw-r--r--mysql-test/t/information_schema.test6
-rw-r--r--mysql-test/t/information_schema_db.test1
-rw-r--r--plugin/userstat/CMakeLists.txt4
-rw-r--r--plugin/userstat/client_stats.cc97
-rw-r--r--plugin/userstat/index_stats.cc72
-rw-r--r--plugin/userstat/table_stats.cc73
-rw-r--r--plugin/userstat/user_stats.cc55
-rw-r--r--plugin/userstat/userstat.cc81
-rw-r--r--sql/handler.h4
-rw-r--r--sql/innodb_priv.h1
-rw-r--r--sql/sql_acl.cc5
-rw-r--r--sql/sql_acl.h8
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_parse.h13
-rw-r--r--sql/sql_show.cc347
16 files changed, 413 insertions, 388 deletions
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index d150ac036a3..b6d2fb09d6c 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -129,6 +129,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
+t1 t1
+t2 t2
+t3 t3
+t4 t4
+t5 t5
table_stats table_stats
tables_priv tables_priv
time_zone time_zone
@@ -136,11 +141,6 @@ time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_transition time_zone_transition
time_zone_transition_type time_zone_transition_type
-t1 t1
-t4 t4
-t2 t2
-t3 t3
-t5 t5
select c,table_name from v1
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
@@ -151,6 +151,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
+t1 t1
+t2 t2
+t3 t3
+t4 t4
+t5 t5
table_stats table_stats
tables_priv tables_priv
time_zone time_zone
@@ -158,11 +163,6 @@ time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_transition time_zone_transition
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
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
@@ -173,6 +173,11 @@ TABLE_CONSTRAINTS TABLE_CONSTRAINTS
TABLE_PRIVILEGES TABLE_PRIVILEGES
TABLE_STATISTICS TABLE_STATISTICS
TRIGGERS TRIGGERS
+t1 t1
+t2 t2
+t3 t3
+t4 t4
+t5 t5
table_stats table_stats
tables_priv tables_priv
time_zone time_zone
@@ -180,11 +185,6 @@ time_zone_leap_second time_zone_leap_second
time_zone_name time_zone_name
time_zone_transition time_zone_transition
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
where table_schema = "mysqltest" and table_name like "t%";
table_name
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index bc77b2c2a8f..9375dd78adc 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -55,14 +55,17 @@ create view v1 (c) as
--sorted_result
select * from v1;
+--sorted_result
select c,table_name from v1
inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
+--sorted_result
select c,table_name from v1
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
+--sorted_result
select c, v2.table_name from v1
right join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
@@ -368,17 +371,20 @@ drop view vo;
select TABLE_NAME,TABLE_TYPE,ENGINE
from information_schema.tables
where table_schema='information_schema' limit 2;
+--sorted_result
show tables from information_schema like "T%";
--error ER_DBACCESS_DENIED_ERROR
create database information_schema;
use information_schema;
+--sorted_result
show full tables like "T%";
--error ER_DBACCESS_DENIED_ERROR
create table t1(a int);
use test;
show tables;
use information_schema;
+--sorted_result
show tables like "T%";
#
diff --git a/mysql-test/t/information_schema_db.test b/mysql-test/t/information_schema_db.test
index a2a32a4fac5..5b730db47cd 100644
--- a/mysql-test/t/information_schema_db.test
+++ b/mysql-test/t/information_schema_db.test
@@ -15,6 +15,7 @@ drop function if exists f2;
--enable_warnings
--replace_result 'Tables_in_INFORMATION_SCHEMA (T%)' 'Tables_in_information_schema (T%)'
+--sorted_result
show tables from INFORMATION_SCHEMA like 'T%';
create database `inf%`;
create database mbase;
diff --git a/plugin/userstat/CMakeLists.txt b/plugin/userstat/CMakeLists.txt
new file mode 100644
index 00000000000..5daa4f59577
--- /dev/null
+++ b/plugin/userstat/CMakeLists.txt
@@ -0,0 +1,4 @@
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql)
+
+MYSQL_ADD_PLUGIN(USERSTAT userstat.cc MANDATORY)
+
diff --git a/plugin/userstat/client_stats.cc b/plugin/userstat/client_stats.cc
new file mode 100644
index 00000000000..dd79f350c5c
--- /dev/null
+++ b/plugin/userstat/client_stats.cc
@@ -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;
+}
diff --git a/plugin/userstat/index_stats.cc b/plugin/userstat/index_stats.cc
new file mode 100644
index 00000000000..236130d327f
--- /dev/null
+++ b/plugin/userstat/index_stats.cc
@@ -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;
+}
+
diff --git a/plugin/userstat/table_stats.cc b/plugin/userstat/table_stats.cc
new file mode 100644
index 00000000000..7b522a388d7
--- /dev/null
+++ b/plugin/userstat/table_stats.cc
@@ -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;
+}
+
diff --git a/plugin/userstat/user_stats.cc b/plugin/userstat/user_stats.cc
new file mode 100644
index 00000000000..71ba3f0397d
--- /dev/null
+++ b/plugin/userstat/user_stats.cc
@@ -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;
+}
+
diff --git a/plugin/userstat/userstat.cc b/plugin/userstat/userstat.cc
new file mode 100644
index 00000000000..3e5afe3df0c
--- /dev/null
+++ b/plugin/userstat/userstat.cc
@@ -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;
+
diff --git a/sql/handler.h b/sql/handler.h
index 4c7648b390c..69f7481e2c6 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -720,7 +720,6 @@ enum enum_schema_tables
SCH_ALL_PLUGINS,
SCH_APPLICABLE_ROLES,
SCH_CHARSETS,
- SCH_CLIENT_STATS,
SCH_COLLATIONS,
SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
SCH_COLUMNS,
@@ -732,7 +731,6 @@ enum enum_schema_tables
SCH_FILES,
SCH_GLOBAL_STATUS,
SCH_GLOBAL_VARIABLES,
- SCH_INDEX_STATS,
SCH_KEY_CACHES,
SCH_KEY_COLUMN_USAGE,
SCH_OPEN_TABLES,
@@ -754,10 +752,8 @@ enum enum_schema_tables
SCH_TABLE_CONSTRAINTS,
SCH_TABLE_NAMES,
SCH_TABLE_PRIVILEGES,
- SCH_TABLE_STATS,
SCH_TRIGGERS,
SCH_USER_PRIVILEGES,
- SCH_USER_STATS,
SCH_VIEWS
};
diff --git a/sql/innodb_priv.h b/sql/innodb_priv.h
index b9e471b3b13..ec85aa352f8 100644
--- a/sql/innodb_priv.h
+++ b/sql/innodb_priv.h
@@ -25,7 +25,6 @@ class THD;
int get_quote_char_for_identifier(THD *thd, const char *name, uint length);
bool schema_table_store_record(THD *thd, TABLE *table);
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,
CHARSET_INFO *to_cs, char *to, uint to_length,
uint *errors);
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index cc2a2549daf..3d3c0bc835a 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -10206,6 +10206,11 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr)
return 0;
}
+#else
+bool check_grant(THD *, ulong, TABLE_LIST *, bool, uint, bool)
+{
+ return 0;
+}
#endif /*NO_EMBEDDED_ACCESS_CHECKS */
int fill_schema_enabled_roles(THD *thd, TABLE_LIST *tables, COND *cond)
diff --git a/sql/sql_acl.h b/sql/sql_acl.h
index 7833fb8736b..28eb7a7f933 100644
--- a/sql/sql_acl.h
+++ b/sql/sql_acl.h
@@ -235,6 +235,10 @@ bool check_grant_all_columns(THD *thd, ulong want_access,
bool check_grant_routine(THD *thd, ulong want_access,
TABLE_LIST *procs, bool is_proc, bool no_error);
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_column_grant(THD *thd, GRANT_INFO *grant,
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 wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr);
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.
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 452252788a9..d8906b2d578 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2115,10 +2115,6 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
thd->profiling.discard_current_query();
#endif
break;
- case SCH_USER_STATS:
- case SCH_CLIENT_STATS:
- if (check_global_access(thd, SUPER_ACL | PROCESS_ACL, true))
- DBUG_RETURN(1);
default:
break;
}
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index 3bbddc8ba4d..da024a5e746 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -148,15 +148,6 @@ inline bool check_identifier_name(LEX_STRING *str)
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
bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables);
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; }
#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 */
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 07ddb3fbea7..fcca91c456b 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3125,267 +3125,6 @@ end:
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 */
void calc_sum_of_all_status(STATUS_VAR *to)
@@ -7312,84 +7051,6 @@ struct schema_table_ref
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
@@ -9062,8 +8723,6 @@ ST_SCHEMA_TABLE schema_tables[]=
fill_schema_applicable_roles, 0, 0, -1, -1, 0, 0},
{"CHARACTER_SETS", charsets_fields_info, 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,
fill_schema_collation, make_old_format, 0, -1, -1, 0, 0},
{"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},
{"GLOBAL_VARIABLES", variables_fields_info, 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,
fill_key_cache_tables, 0, 0, -1,-1, 0, 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},
{"TABLE_PRIVILEGES", table_privileges_fields_info, 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,
get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0,
OPEN_TRIGGER_ONLY|OPTIMIZE_I_S_TABLE},
{"USER_PRIVILEGES", user_privileges_fields_info, 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,
get_all_tables, 0, get_schema_views_record, 1, 2, 0,
OPEN_VIEW_ONLY|OPTIMIZE_I_S_TABLE},