diff options
259 files changed, 7176 insertions, 6685 deletions
diff --git a/.gitignore b/.gitignore index e283abf39f9..3a3733470fc 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ Makefile TAGS Testing/ VERSION.dep +configure client/async_example client/mysql client/mysql_plugin diff --git a/client/mysqldump.c b/client/mysqldump.c index eba5bd93671..b8d04014552 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -39,7 +39,7 @@ ** 10 Jun 2003: SET NAMES and --no-set-names by Alexander Barkov */ -#define DUMP_VERSION "10.15" +#define DUMP_VERSION "10.16" #include <my_global.h> #include <my_sys.h> @@ -112,7 +112,7 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_include_master_host_port= 0, opt_events= 0, opt_comments_used= 0, opt_galera_sst_mode= 0, - opt_alltspcs=0, opt_notspcs= 0; + opt_alltspcs=0, opt_notspcs= 0, opt_logging; static my_bool insert_pat_inited= 0, debug_info_flag= 0, debug_check_flag= 0; static ulong opt_max_allowed_packet, opt_net_buffer_length; static MYSQL mysql_connection,*mysql=0; @@ -390,6 +390,8 @@ static struct my_option my_long_options[] = {"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.", &log_error_file, &log_error_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"log-queries", 0, "When restoring the dump, the server will, if logging turned on, log the queries to the general and slow query log.", + &opt_logging, &opt_logging, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"master-data", OPT_MASTER_DATA, "This causes the binary log position and filename to be appended to the " "output. If equal to 1, will print it as a CHANGE MASTER command; if equal" @@ -672,6 +674,10 @@ static void write_header(FILE *sql_file, char *db_name) print_comment(sql_file, 0, "-- Server version\t%s\n", mysql_get_server_info(&mysql_connection)); + if (!opt_logging) + fprintf(sql_file, +"\n/*M!100101 SET LOCAL SQL_LOG_OFF=0, LOCAL SLOW_QUERY_LOG=0 */;"); + if (opt_set_charset) fprintf(sql_file, "\n/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;" diff --git a/cmake/configure.pl b/cmake/configure.pl index a71795a3bc8..b528cda70dc 100644 --- a/cmake/configure.pl +++ b/cmake/configure.pl @@ -167,7 +167,7 @@ foreach my $option (@ARGV) } if($option =~ /with-debug/) { - $cmakeargs = $cmakeargs." -DCMAKE_BUILD_TYPE=Debug"; + $cmakeargs = $cmakeargs." -DCMAKE_BUILD_TYPE=Debug -DSECURITY_HARDENED=OFF"; next; } if($option =~ /with-ssl/) diff --git a/configure.cmake b/configure.cmake index 7ec87f6e9a8..4adc977b192 100644 --- a/configure.cmake +++ b/configure.cmake @@ -55,7 +55,7 @@ ENDIF() # Always enable -Wall for gnu C/C++ IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_FLAGS MATCHES ".*-Wall.*") - SET(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS} -Wall -Wno-unused-parameter") + SET(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS} -Wall -Wno-unused-parameter -Wno-init-self") ENDIF() IF(CMAKE_COMPILER_IS_GNUCC AND NOT CMAKE_C_FLAGS MATCHES ".*-Wall.*") SET(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS} -Wall") diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index e91163dde1c..bfd0c3c635a 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -98,6 +98,11 @@ static struct my_option my_long_options[] = {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; +void cleanup_and_exit(int exit_code) +{ + my_end(0); + exit(exit_code); +} static void usage(my_bool version) { @@ -112,7 +117,7 @@ static void usage(my_bool version) my_print_default_files(config_file); my_print_variables(my_long_options); printf("\nExample usage:\n%s --defaults-file=example.cnf client client-server mysql\n", my_progname); - exit(0); + cleanup_and_exit(0); } @@ -125,7 +130,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_defaults_file_used= 1; break; case 'n': - exit(0); + cleanup_and_exit(0); case 'I': case '?': usage(0); @@ -174,7 +179,7 @@ int main(int argc, char **argv) /* Check out the args */ if (get_options(&argc,&argv)) - exit(1); + cleanup_and_exit(1); nargs= argc + 1; if (opt_mysqld) diff --git a/include/my_global.h b/include/my_global.h index e9a472e686e..bec5fb027eb 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -480,16 +480,14 @@ extern "C" int madvise(void *addr, size_t len, int behav); /* Suppress uninitialized variable warning without generating code. - - The _cplusplus is a temporary workaround for C++ code pending a fix - for a g++ bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34772). */ -#if defined(_lint) || defined(FORCE_INIT_OF_VARS) || \ - defined(__cplusplus) || !defined(__GNUC__) -#define UNINIT_VAR(x) x= 0 -#else +#if defined(__GNUC__) /* GCC specific self-initialization which inhibits the warning. */ #define UNINIT_VAR(x) x= x +#elif defined(_lint) || defined(FORCE_INIT_OF_VARS) +#define UNINIT_VAR(x) x= 0 +#else +#define UNINIT_VAR(x) x #endif #if !defined(HAVE_UINT) diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index e303c288552..c4770182598 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -2222,4 +2222,32 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`d3` AS `d3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`i2` = `test`.`t1`.`i1`) and (`test`.`t3`.`i3` = `test`.`t1`.`i1`))) where ((`test`.`t3`.`d3` = 0) or isnull(`test`.`t3`.`d3`)) DROP TABLE t1,t2,t3; +# +# MDEV-6634: Wrong estimates for ref(const) and key IS NULL predicate +# +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, key(b), key(c)); +insert into t2 select +@a:=A.a + 10*B.a+100*C.a, +IF(@a<900, NULL, @a), +IF(@a<500, NULL, @a) +from t1 A, t1 B, t1 C; +delete from t1 where a=0; +# Check that there are different #rows of NULLs for b and c, both !=10: +explain select * from t2 force index (b) where b is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref b b 5 const 780 Using index condition +explain select * from t2 force index (c) where c is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref c c 5 const 393 Using index condition +explain select * from t1 left join t2 on t2.b is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 9 +1 SIMPLE t2 ref b b 5 const 780 Using where +explain select * from t1 left join t2 on t2.c is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 9 +1 SIMPLE t2 ref c c 5 const 393 Using where +drop table t1,t2; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 88f2fd7c630..862fc194a7a 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -2233,6 +2233,34 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`d3` AS `d3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`i2` = `test`.`t1`.`i1`) and (`test`.`t3`.`i3` = `test`.`t1`.`i1`))) where ((`test`.`t3`.`d3` = 0) or isnull(`test`.`t3`.`d3`)) DROP TABLE t1,t2,t3; +# +# MDEV-6634: Wrong estimates for ref(const) and key IS NULL predicate +# +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, key(b), key(c)); +insert into t2 select +@a:=A.a + 10*B.a+100*C.a, +IF(@a<900, NULL, @a), +IF(@a<500, NULL, @a) +from t1 A, t1 B, t1 C; +delete from t1 where a=0; +# Check that there are different #rows of NULLs for b and c, both !=10: +explain select * from t2 force index (b) where b is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref b b 5 const 780 Using index condition +explain select * from t2 force index (c) where c is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref c c 5 const 393 Using index condition +explain select * from t1 left join t2 on t2.b is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 9 +1 SIMPLE t2 ref b b 5 const 780 Using where +explain select * from t1 left join t2 on t2.c is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 9 +1 SIMPLE t2 ref c c 5 const 393 Using where +drop table t1,t2; SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/r/log_state.result b/mysql-test/r/log_state.result index cc6f3709ae4..f157887de4b 100644 --- a/mysql-test/r/log_state.result +++ b/mysql-test/r/log_state.result @@ -42,6 +42,7 @@ select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id # Switch to connection default set global slow_query_log= ON; +set local slow_query_log= ON; # Switch to connection con1 set session long_query_time = @long_query_time; select sleep(@long_query_time + 1); @@ -49,7 +50,13 @@ sleep(@long_query_time + 1) 0 select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id -TIMESTAMP USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 select sleep(@long_query_time + 1) THREAD_ID +set local slow_query_log= ON; +select sleep(@long_query_time + 2); +sleep(@long_query_time + 2) +0 +select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; +start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id +TIMESTAMP USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 select sleep(@long_query_time + 2) THREAD_ID # Switch to connection default show global variables where Variable_name = 'general_log' or Variable_name = 'slow_query_log'; @@ -62,6 +69,7 @@ set global general_log= OFF; set global slow_query_log= ON; set global slow_query_log= OFF; set global slow_query_log= OFF; +set local slow_query_log= ON; set global general_log= ON; truncate table mysql.general_log; create table t1(f1 int); @@ -124,6 +132,9 @@ Variable_name Value general_log OFF show variables like 'slow_query_log'; Variable_name Value +slow_query_log ON +show global variables like 'slow_query_log'; +Variable_name Value slow_query_log OFF set global general_log=ON; set global log_output=default; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 4b0b3faf629..a7ef5d4d92f 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -5290,3 +5290,13 @@ Usage: mysqldump [OPTIONS] database [tables] OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...] OR mysqldump [OPTIONS] --all-databases [OPTIONS] For more options, use mysqldump --help +# +# Test mysqldump with --disable-query-logs +# +create table t1 (a int); +insert into t1 values (1); +drop table t1; +select * from t1; +a +1 +drop table t1; diff --git a/mysql-test/suite/galera/galera_2nodes.cnf b/mysql-test/suite/galera/galera_2nodes.cnf index 5a08125089a..c0d5b3add3f 100644 --- a/mysql-test/suite/galera/galera_2nodes.cnf +++ b/mysql-test/suite/galera/galera_2nodes.cnf @@ -7,6 +7,8 @@ wsrep_provider=@ENV.WSREP_PROVIDER wsrep_cluster_address='gcomm://' wsrep_provider_options='base_port=@mysqld.1.#galera_port' wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' +# enforce read-committed characteristics across the cluster +wsrep_causal_reads=ON [mysqld.2] binlog-format=row @@ -14,6 +16,8 @@ wsrep_provider=@ENV.WSREP_PROVIDER wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' wsrep_provider_options='base_port=@mysqld.2.#galera_port' wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' +# enforce read-committed characteristics across the cluster +wsrep_causal_reads=ON [ENV] NODE_MYPORT_1= @mysqld.1.port diff --git a/mysql-test/suite/innodb/r/innodb_defrag_binlog.result b/mysql-test/suite/innodb/r/innodb_defrag_binlog.result new file mode 100644 index 00000000000..2a1992e449d --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_defrag_binlog.result @@ -0,0 +1,29 @@ +include/master-slave.inc +[connection master] +drop table if exists t1; +create table t1(a int not null primary key auto_increment, b varchar(256), key second(b)) engine=innodb; +insert into t1 values (1, REPEAT("a", 256)); +insert into t1 values (2, REPEAT("a", 256)); +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +drop table t1; +show binlog events in 'master-bin.000001' from 313; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 313 Gtid 1 351 GTID 0-1-1 +master-bin.000001 351 Query 1 465 use `test`; DROP TABLE IF EXISTS `t1` +master-bin.000001 465 Gtid 1 503 GTID 0-1-2 +master-bin.000001 503 Query 1 669 use `test`; create table t1(a int not null primary key auto_increment, b varchar(256), key second(b)) engine=innodb +master-bin.000001 669 Gtid 1 707 BEGIN GTID 0-1-3 +master-bin.000001 707 Table_map 1 751 table_id: 82 (test.t1) +master-bin.000001 751 Write_rows_v1 1 1043 table_id: 82 flags: STMT_END_F +master-bin.000001 1043 Xid 1 1070 COMMIT +master-bin.000001 1070 Gtid 1 1108 BEGIN GTID 0-1-4 +master-bin.000001 1108 Table_map 1 1152 table_id: 82 (test.t1) +master-bin.000001 1152 Write_rows_v1 1 1444 table_id: 82 flags: STMT_END_F +master-bin.000001 1444 Xid 1 1471 COMMIT +master-bin.000001 1471 Gtid 1 1509 GTID 0-1-5 +master-bin.000001 1509 Query 1 1589 use `test`; optimize table t1 +master-bin.000001 1589 Gtid 1 1627 GTID 0-1-6 +master-bin.000001 1627 Query 1 1731 use `test`; DROP TABLE `t1` +include/rpl_end.inc diff --git a/mysql-test/suite/innodb/r/innodb_defrag_concurrent.result b/mysql-test/suite/innodb/r/innodb_defrag_concurrent.result new file mode 100644 index 00000000000..1b1ff3a858f --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_defrag_concurrent.result @@ -0,0 +1,73 @@ +DROP TABLE if exists t1; +select @@global.innodb_stats_persistent; +@@global.innodb_stats_persistent +0 +set global innodb_defragment_stats_accuracy = 80; +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), c INT, KEY second(a, b),KEY third(c)) ENGINE=INNODB; +SET @@global.innodb_defragment_n_pages = 20; +after populate PRIMARY +select count(*) from t1; +count(*) +20000 +after populate second +select count(*) from t1 force index (second); +count(*) +20000 +after populate third +select count(*) from t1 force index (third); +count(*) +20000 +select count(*) from t1; +count(*) +15800 +after delete PRIMAY +select count(*) from t1 force index (second); +count(*) +15800 +after delete second +select count(*) from t1 force index (third); +count(*) +15800 +after delete third +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); +count(stat_value) > 0 +0 +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +count(stat_value) > 0 +1 +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +count(stat_value) > 0 +1 +optimize table t1;; +INSERT INTO t1 VALUES (400000, REPEAT('A', 256),300000);; +INSERT INTO t1 VALUES (500000, REPEAT('A', 256),400000);; +DELETE FROM t1 where a between 1 and 100;; +UPDATE t1 SET c = c + 1 where c between 2000 and 8000;; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +select sleep(5); +sleep(5) +0 +select count(*) from t1; +count(*) +15723 +after optimize PRIMARY +select count(*) from t1 force index (second); +count(*) +15723 +after optimize second +select count(*) from t1 force index (third); +count(*) +15723 +after optimize third +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); +count(stat_value) > 0 +1 +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +count(stat_value) > 0 +1 +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +count(stat_value) > 0 +1 +drop table t1; diff --git a/mysql-test/suite/innodb/r/innodb_defrag_stats.result b/mysql-test/suite/innodb/r/innodb_defrag_stats.result new file mode 100644 index 00000000000..0838a199b3b --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_defrag_stats.result @@ -0,0 +1,94 @@ +DROP TABLE if exists t1; +select @@global.innodb_stats_persistent; +@@global.innodb_stats_persistent +0 +set global innodb_defragment_stats_accuracy = 20; +# Create table. +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB; +# Populate data +INSERT INTO t1 VALUES(1, REPEAT('A', 256)); +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +# Not enough page splits to trigger persistent stats write yet. +select count(*) from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split', 'n_leaf_pages_defrag'); +count(*) +0 +INSERT INTO t1 (b) SELECT b from t1; +# Persistent stats recorded. +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split', 'n_leaf_pages_defrag'); +count(stat_value) > 0 +0 +# Delete some rows. +delete from t1 where a between 100 * 20 and 100 * 20 + 30; +delete from t1 where a between 100 * 19 and 100 * 19 + 30; +delete from t1 where a between 100 * 18 and 100 * 18 + 30; +delete from t1 where a between 100 * 17 and 100 * 17 + 30; +delete from t1 where a between 100 * 16 and 100 * 16 + 30; +delete from t1 where a between 100 * 15 and 100 * 15 + 30; +delete from t1 where a between 100 * 14 and 100 * 14 + 30; +delete from t1 where a between 100 * 13 and 100 * 13 + 30; +delete from t1 where a between 100 * 12 and 100 * 12 + 30; +delete from t1 where a between 100 * 11 and 100 * 11 + 30; +delete from t1 where a between 100 * 10 and 100 * 10 + 30; +delete from t1 where a between 100 * 9 and 100 * 9 + 30; +delete from t1 where a between 100 * 8 and 100 * 8 + 30; +delete from t1 where a between 100 * 7 and 100 * 7 + 30; +delete from t1 where a between 100 * 6 and 100 * 6 + 30; +delete from t1 where a between 100 * 5 and 100 * 5 + 30; +delete from t1 where a between 100 * 4 and 100 * 4 + 30; +delete from t1 where a between 100 * 3 and 100 * 3 + 30; +delete from t1 where a between 100 * 2 and 100 * 2 + 30; +delete from t1 where a between 100 * 1 and 100 * 1 + 30; +# Server Restarted +# Confirm persistent stats still there after restart. +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split', 'n_leaf_pages_defrag'); +count(stat_value) > 0 +0 +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +# n_page_split should be 0 after defragmentation, n_pages_freed should be non-zero. +select stat_value = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split'; +stat_value = 0 +1 +1 +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed', 'n_leaf_pages_defrag'); +count(stat_value) > 0 +1 +set global innodb_defragment_stats_accuracy = 40; +INSERT INTO t1 (b) SELECT b from t1; +# Not enough operation to trigger persistent stats write +select stat_value = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split'; +stat_value = 0 +1 +1 +INSERT INTO t1 (b) SELECT b from t1; +# Persistent stats write triggered +select stat_value > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split'; +stat_value > 0 +0 +0 +# Table rename should cause stats rename. +rename table t1 to t2; +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed', 'n_page_split', 'n_leaf_pages_defrag'); +count(stat_value) > 0 +1 +# Drop index should cause stats drop. +drop index SECOND on t2; +select count(*) from mysql.innodb_index_stats where table_name like '%t2%' and index_name = 'SECOND'; +count(*) +4 +Server Restarted +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed', 'n_page_split', 'n_leaf_pages_defrag'); +count(stat_value) > 0 +1 +# Clean up +DROP TABLE t2; diff --git a/mysql-test/suite/innodb/r/innodb_defrag_stats_many_tables.result b/mysql-test/suite/innodb/r/innodb_defrag_stats_many_tables.result new file mode 100644 index 00000000000..f19e5ddf590 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_defrag_stats_many_tables.result @@ -0,0 +1,36 @@ +DROP TABLE if exists t1; +SET @start_table_definition_cache = @@global.table_definition_cache; +SET @@global.table_definition_cache = 400; +SET @start_innodb_defragment_stats_accuracy = @@global.innodb_defragment_stats_accuracy; +SET @@global.innodb_defragment_stats_accuracy = 10; +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB; +INSERT INTO t1 VALUES(1, REPEAT('A', 256)); +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +select stat_value > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split'; +stat_value > 0 +Create 405 table to overflow the table cache. +Sleep for a while to make sure t1 is evicted. +select sleep(10); +sleep(10) +0 +Reload t1 to get defrag stats from persistent storage +INSERT INTO t1 (b) SELECT b from t1; +make sure the stats thread will wake up and do the write even if there's a race condition between set and reset. +select sleep(12); +sleep(12) +0 +select stat_value > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split'; +stat_value > 0 +SET @@global.innodb_defragment_stats_accuracy = @start_innodb_defragment_stats_accuracy; +SET @@global.table_definition_cache = @start_table_definition_cache; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb_defragment.result b/mysql-test/suite/innodb/r/innodb_defragment.result new file mode 100644 index 00000000000..b8f61b0eba3 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_defragment.result @@ -0,0 +1,81 @@ +DROP TABLE if exists t1; +set global innodb_defragment_stats_accuracy = 80; +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +INSERT INTO t1 VALUES (100000, REPEAT('A', 256)); +INSERT INTO t1 VALUES (200000, REPEAT('A', 256)); +INSERT INTO t1 VALUES (300000, REPEAT('A', 256)); +INSERT INTO t1 VALUES (400000, REPEAT('A', 256)); +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +create procedure defragment() +begin +set @i = 0; +repeat +set @i = @i + 1; +optimize table t1; +select sleep(5); +until @i = 3 end repeat; +end // +select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); +count(stat_value) = 0 +1 +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +count(stat_value) > 0 +1 +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +count(stat_value) > 0 +1 +select count(*) from t1; +count(*) +10004 +select count(*) from t1 force index (second); +count(*) +10004 +call defragment(); +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +select sleep(5); +sleep(5) +0 +select count(*) from t1; +count(*) +7904 +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed', 'n_page_split', 'n_leaf_pages_defrag'); +count(stat_value) > 0 +0 +select count(*) from t1 force index (second); +count(*) +7904 +SET @@global.innodb_defragment_n_pages = 3; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed', 'n_page_split', 'n_leaf_pages_defrag'); +count(stat_value) > 0 +0 +select count(*) from t1; +count(*) +6904 +select count(*) from t1 force index (second); +count(*) +6904 +SET @@global.innodb_defragment_n_pages = 10; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed', 'n_page_split', 'n_leaf_pages_defrag'); +count(stat_value) > 0 +0 +select count(*) from t1; +count(*) +6904 +select count(*) from t1 force index (second); +count(*) +6904 +DROP PROCEDURE defragment; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb_defragment_fill_factor.result b/mysql-test/suite/innodb/r/innodb_defragment_fill_factor.result new file mode 100644 index 00000000000..90dcbc004f7 --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_defragment_fill_factor.result @@ -0,0 +1,59 @@ +DROP TABLE if exists t1; +DROP TABLE if exists t2; +Testing tables with large records +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +select count(*) from t1; +count(*) +790 +select count(*) from t1 force index (second); +count(*) +790 +# A few more insertions on the page should not cause a page split. +insert into t1 values (81, REPEAT('A', 256)); +insert into t1 values (83, REPEAT('A', 256)); +insert into t1 values (87, REPEAT('A', 256)); +insert into t1 values (82, REPEAT('A', 256)); +insert into t1 values (86, REPEAT('A', 256)); +# More insertions will cause page splits +insert into t1 values (88, REPEAT('A', 50)); +Too much space are reserved on primary index. +Too much space are reserved on second index. +DROP TABLE t1; +Testing table with small records +CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARchar(16), KEY SECOND(a,b)) ENGINE=INNODB; +optimize table t2; +Table Op Msg_type Msg_text +test.t2 optimize status OK +select count(*) from t2 force index(second); +count(*) +3701 +The page should have room for about 20 insertions +insert into t2 values(1181, REPEAT('A', 16)); +insert into t2 values(1191, REPEAT('A', 16)); +insert into t2 values(1182, REPEAT('A', 16)); +insert into t2 values(1192, REPEAT('A', 16)); +insert into t2 values(1183, REPEAT('A', 16)); +insert into t2 values(1193, REPEAT('A', 16)); +insert into t2 values(1184, REPEAT('A', 16)); +insert into t2 values(1194, REPEAT('A', 16)); +insert into t2 values(1185, REPEAT('A', 16)); +insert into t2 values(1195, REPEAT('A', 16)); +insert into t2 values(1186, REPEAT('A', 16)); +insert into t2 values(1196, REPEAT('A', 16)); +insert into t2 values(1187, REPEAT('A', 16)); +insert into t2 values(1197, REPEAT('A', 16)); +insert into t2 values(1188, REPEAT('A', 16)); +insert into t2 values(1198, REPEAT('A', 16)); +insert into t2 values(1189, REPEAT('A', 16)); +insert into t2 values(1199, REPEAT('A', 16)); +insert into t2 values(1190, REPEAT('A', 16)); +insert into t2 values(1180, REPEAT('A', 16)); +More insertions will cause page split. +insert into t2 values(1280, REPEAT('A', 16)); +insert into t2 values(1290, REPEAT('A', 16)); +insert into t2 values(1281, REPEAT('A', 16)); +insert into t2 values(1291, REPEAT('A', 16)); +DROP TABLE t2; diff --git a/mysql-test/suite/innodb/t/innodb.opt b/mysql-test/suite/innodb/t/innodb.opt new file mode 100644 index 00000000000..59e43fea231 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb.opt @@ -0,0 +1 @@ +--innodb-defragment=0
\ No newline at end of file diff --git a/mysql-test/suite/innodb/t/innodb_defrag_binlog.opt b/mysql-test/suite/innodb/t/innodb_defrag_binlog.opt new file mode 100644 index 00000000000..8a432b8c76e --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defrag_binlog.opt @@ -0,0 +1,5 @@ +--loose-innodb-buffer-pool-stats +--loose-innodb-buffer-page +--loose-innodb-buffer-page-lru +--binlog-format=row +--innodb-defragment=1
\ No newline at end of file diff --git a/mysql-test/suite/innodb/t/innodb_defrag_binlog.test b/mysql-test/suite/innodb/t/innodb_defrag_binlog.test new file mode 100644 index 00000000000..c0d4b377cb1 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defrag_binlog.test @@ -0,0 +1,19 @@ +--source include/have_innodb.inc +--source include/master-slave.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1(a int not null primary key auto_increment, b varchar(256), key second(b)) engine=innodb; + +insert into t1 values (1, REPEAT("a", 256)); +insert into t1 values (2, REPEAT("a", 256)); +optimize table t1; + +drop table t1; + +--replace_regex /\/\*.*// +show binlog events in 'master-bin.000001' from 313; + +--source include/rpl_end.inc diff --git a/mysql-test/suite/innodb/t/innodb_defrag_concurrent.opt b/mysql-test/suite/innodb/t/innodb_defrag_concurrent.opt new file mode 100644 index 00000000000..6426bac41a0 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defrag_concurrent.opt @@ -0,0 +1,4 @@ +--loose-innodb-buffer-pool-stats +--loose-innodb-buffer-page +--loose-innodb-buffer-page-lru +--innodb-defragment=1
\ No newline at end of file diff --git a/mysql-test/suite/innodb/t/innodb_defrag_concurrent.test b/mysql-test/suite/innodb/t/innodb_defrag_concurrent.test new file mode 100644 index 00000000000..7cf00e1da4c --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defrag_concurrent.test @@ -0,0 +1,180 @@ +--source include/have_innodb.inc + +--disable_warnings +DROP TABLE if exists t1; +--enable_warnings + +--disable_query_log +let $innodb_defragment_n_pages_orig=`select @@innodb_defragment_n_pages`; +let $innodb_defragment_stats_accuracy_orig=`select @@innodb_defragment_stats_accuracy`; +--enable_query_log + +select @@global.innodb_stats_persistent; +set global innodb_defragment_stats_accuracy = 80; + +# Create table. +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), c INT, KEY second(a, b),KEY third(c)) ENGINE=INNODB; + +connect (con1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); +connect (con2,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); +connect (con3,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); +connect (con4,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); + +connection default; + +SET @@global.innodb_defragment_n_pages = 20; + +let $data_size = 20000; +let $delete_size = 2000; + +# Populate table. +let $i = $data_size; +--disable_query_log +while ($i) +{ + eval + INSERT INTO t1 VALUES ($data_size + 1 - $i, REPEAT('A', 256), $i); + dec $i; +} +--enable_query_log + +--echo after populate PRIMARY +select count(*) from t1; + +if (`select count(*) < 30 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number;`) +{ +aelect count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number; +} + +--echo after populate second +select count(*) from t1 force index (second); + +if (`select count(*) < 320 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number; +} + +--ECHO after populate third +select count(*) from t1 force index (third); + +if (`select count(*) < 20 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'third' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'third' order by page_number; +} + +# Delete some data +--disable_query_log +let $size = $delete_size; +while ($size) +{ + let $j = 100 * $size; + eval delete from t1 where a between $j - 20 and $j; + dec $size; +} +--enable_query_log + +select count(*) from t1; + +--echo after delete PRIMAY +if (`select count(*) < 30 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number; +} + +select count(*) from t1 force index (second); + +--echo after delete second +if (`select count(*) < 300 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number; +} + +select count(*) from t1 force index (third); + +--echo after delete third +if (`select count(*) > 20 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'third' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'third' order by page_number; +} + +# Above delete will free some pages and insert causes page split and these could cause defrag +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); + +connection con1; +--send optimize table t1; + +connection default; +--send INSERT INTO t1 VALUES (400000, REPEAT('A', 256),300000); + +connection con2; +--send INSERT INTO t1 VALUES (500000, REPEAT('A', 256),400000); + +connection con3; +--send DELETE FROM t1 where a between 1 and 100; + +connection con4; +--send UPDATE t1 SET c = c + 1 where c between 2000 and 8000; + +connection con1; +--disable_result_log +--reap +--enable_result_log + +connection con2; +--reap + +connection con3; +--reap + +connection con4; +--reap + +connection default; +--reap + +disconnect con1; +disconnect con2; +disconnect con3; +disconnect con4; + +optimize table t1; +select sleep(5); + +select count(*) from t1; + +--echo after optimize PRIMARY +if (`select count(*) > 62 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number; +} + +select count(*) from t1 force index (second); + +--echo after optimize second +if (`select count(*) > 340 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number; +} + +select count(*) from t1 force index (third); + +--echo after optimize third +if (`select count(*) > 25 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'third' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'third' order by page_number; +} + +# Now pages are freed +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); + +drop table t1; + +# reset system +--disable_query_log +EVAL SET GLOBAL innodb_defragment_n_pages = $innodb_defragment_n_pages_orig; +EVAL SET GLOBAL innodb_defragment_stats_accuracy = $innodb_defragment_stats_accuracy_orig; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb_defrag_stats.opt b/mysql-test/suite/innodb/t/innodb_defrag_stats.opt new file mode 100644 index 00000000000..d3525162f03 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defrag_stats.opt @@ -0,0 +1 @@ +--innodb-defragment=1 diff --git a/mysql-test/suite/innodb/t/innodb_defrag_stats.test b/mysql-test/suite/innodb/t/innodb_defrag_stats.test new file mode 100644 index 00000000000..f07544df4f6 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defrag_stats.test @@ -0,0 +1,87 @@ +--source include/have_innodb.inc +--source include/big_test.inc + +--disable_warnings +DROP TABLE if exists t1; +--enable_warnings + +--disable_query_log +let $innodb_defragment_stats_accuracy_orig=`select @@innodb_defragment_stats_accuracy`; +--enable_query_log + +select @@global.innodb_stats_persistent; +set global innodb_defragment_stats_accuracy = 20; + +--echo # Create table. +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB; + +--echo # Populate data +INSERT INTO t1 VALUES(1, REPEAT('A', 256)); +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; + +--echo # Not enough page splits to trigger persistent stats write yet. +select count(*) from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split', 'n_leaf_pages_defrag'); + +INSERT INTO t1 (b) SELECT b from t1; + +--echo # Persistent stats recorded. +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split', 'n_leaf_pages_defrag'); + +--echo # Delete some rows. +let $num_delete = 20; +while ($num_delete) +{ + let $j = 100 * $num_delete; + eval delete from t1 where a between $j and $j + 30; + dec $num_delete; +} + +--source include/restart_mysqld.inc +--echo # Server Restarted + +--echo # Confirm persistent stats still there after restart. +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split', 'n_leaf_pages_defrag'); + +optimize table t1; +--echo # n_page_split should be 0 after defragmentation, n_pages_freed should be non-zero. +select stat_value = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split'; +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed', 'n_leaf_pages_defrag'); + +set global innodb_defragment_stats_accuracy = 40; + +INSERT INTO t1 (b) SELECT b from t1; +--echo # Not enough operation to trigger persistent stats write +select stat_value = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split'; + +INSERT INTO t1 (b) SELECT b from t1; +--echo # Persistent stats write triggered +select stat_value > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split'; + +--echo # Table rename should cause stats rename. +rename table t1 to t2; +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed', 'n_page_split', 'n_leaf_pages_defrag'); + +--echo # Drop index should cause stats drop. +drop index SECOND on t2; +select count(*) from mysql.innodb_index_stats where table_name like '%t2%' and index_name = 'SECOND'; + +--source include/restart_mysqld.inc +--echo Server Restarted + +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed', 'n_page_split', 'n_leaf_pages_defrag'); + +--echo # Clean up +DROP TABLE t2; + +--disable_query_log +EVAL SET GLOBAL innodb_defragment_stats_accuracy = $innodb_defragment_stats_accuracy_orig; +--enable_query_log diff --git a/mysql-test/suite/innodb/t/innodb_defrag_stats_many_tables.opt b/mysql-test/suite/innodb/t/innodb_defrag_stats_many_tables.opt new file mode 100644 index 00000000000..d3525162f03 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defrag_stats_many_tables.opt @@ -0,0 +1 @@ +--innodb-defragment=1 diff --git a/mysql-test/suite/innodb/t/innodb_defrag_stats_many_tables.test b/mysql-test/suite/innodb/t/innodb_defrag_stats_many_tables.test new file mode 100644 index 00000000000..e1a463459be --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defrag_stats_many_tables.test @@ -0,0 +1,71 @@ +--source include/have_innodb.inc +--source include/big_test.inc + +--disable_warnings +DROP TABLE if exists t1; +--enable_warnings + +let $num_tables = 405; + +SET @start_table_definition_cache = @@global.table_definition_cache; +SET @@global.table_definition_cache = 400; + +# set stats accuracy to be pretty high so stats sync is easily triggered. +SET @start_innodb_defragment_stats_accuracy = @@global.innodb_defragment_stats_accuracy; +SET @@global.innodb_defragment_stats_accuracy = 10; + +# Create table. +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB; + +# Populate data +INSERT INTO t1 VALUES(1, REPEAT('A', 256)); +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 (b) SELECT b from t1; + +select stat_value > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split'; + +# Create many tables to over flow the table definition cache + +--echo Create $num_tables table to overflow the table cache. +--disable_query_log +let $count = $num_tables; +while ($count) +{ + EVAL CREATE TABLE t_$count (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT) ENGINE=INNODB; + EVAL INSERT INTO t_$count VALUES (1), (2); + dec $count; +} +--enable_query_log +--echo Sleep for a while to make sure t1 is evicted. +select sleep(10); + +--echo Reload t1 to get defrag stats from persistent storage +INSERT INTO t1 (b) SELECT b from t1; + +--echo make sure the stats thread will wake up and do the write even if there's a race condition between set and reset. +select sleep(12); + +select stat_value > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split'; + + +# Clean up +SET @@global.innodb_defragment_stats_accuracy = @start_innodb_defragment_stats_accuracy; +SET @@global.table_definition_cache = @start_table_definition_cache; +--disable_query_log +let $count = $num_tables; +while ($count) +{ + EVAL DROP TABLE t_$count; + dec $count; +} +--enable_query_log +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb_defragment-master.opt b/mysql-test/suite/innodb/t/innodb_defragment-master.opt new file mode 100644 index 00000000000..6fc7f343b24 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defragment-master.opt @@ -0,0 +1,2 @@ +--innodb_file_per_table +--innodb-defragment=1
\ No newline at end of file diff --git a/mysql-test/suite/innodb/t/innodb_defragment.opt b/mysql-test/suite/innodb/t/innodb_defragment.opt new file mode 100644 index 00000000000..6426bac41a0 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defragment.opt @@ -0,0 +1,4 @@ +--loose-innodb-buffer-pool-stats +--loose-innodb-buffer-page +--loose-innodb-buffer-page-lru +--innodb-defragment=1
\ No newline at end of file diff --git a/mysql-test/suite/innodb/t/innodb_defragment.test b/mysql-test/suite/innodb/t/innodb_defragment.test new file mode 100644 index 00000000000..77fceeaa56b --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defragment.test @@ -0,0 +1,190 @@ +--source include/have_innodb.inc + +--disable_warnings +DROP TABLE if exists t1; +--enable_warnings + +--disable_query_log +let $innodb_defragment_n_pages_orig=`select @@innodb_defragment_n_pages`; +let $innodb_defragment_stats_accuracy_orig=`select @@innodb_defragment_stats_accuracy`; +--enable_query_log + +set global innodb_defragment_stats_accuracy = 80; + +# Create table. +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB; + +## Test-1 defragment an empty table +optimize table t1; + +## Test-2 defragment a single page table +INSERT INTO t1 VALUES (100000, REPEAT('A', 256)); +INSERT INTO t1 VALUES (200000, REPEAT('A', 256)); +INSERT INTO t1 VALUES (300000, REPEAT('A', 256)); +INSERT INTO t1 VALUES (400000, REPEAT('A', 256)); + +optimize table t1; + +## Test-3 defragment (somewhat) in parallel with delete queries +let $data_size = 10000; +let $delete_size = 100; + +delimiter //; +create procedure defragment() +begin + set @i = 0; + repeat + set @i = @i + 1; + optimize table t1; + select sleep(5); + until @i = 3 end repeat; +end // +delimiter ;// + + +# Populate table. +let $i = $data_size; +--disable_query_log +while ($i) +{ + eval + INSERT INTO t1 VALUES ($data_size + 1 - $i, REPEAT('A', 256)); + dec $i; +} +--enable_query_log + +select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); + +select count(*) from t1; + +if (!`select count(*) > 180 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number; +} + +select count(*) from t1 force index (second); + +if (!`select count(*) > 170 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number; +} + + +connect (con1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); + +connection con1; +--send call defragment() + +connection default; + +--disable_query_log +let $size = $delete_size; +while ($size) +{ + let $j = 100 * $size; + eval delete from t1 where a between $j - 20 and $j; + dec $size; +} +--enable_query_log + +connection con1; +--disable_result_log +--reap +--enable_result_log + +connection default; +disconnect con1; + +optimize table t1; +select sleep(5); + +--source include/restart_mysqld.inc +select count(*) from t1; + +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed', 'n_page_split', 'n_leaf_pages_defrag'); + +# After deletion & defragmentation, there are 8000 records left +if (!`select count(*) < 180 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number; +} + +select count(*) from t1 force index (second); + +# secondary index is pretty much the same size as primary index so the number of pages should be similar. +if (!`select count(*) < 180 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number; +} + +## Test-4 defragment with larger n_pages + +# delete some more records +--disable_query_log +let $size = $delete_size; +while ($size) +{ + let $j = 100 * $size; + eval delete from t1 where a between $j - 30 and $j - 20; + dec $size; +} +--enable_query_log + +SET @@global.innodb_defragment_n_pages = 3; + +# This will not reduce number of pages by a lot +optimize table t1; + +--source include/restart_mysqld.inc + +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed', 'n_page_split', 'n_leaf_pages_defrag'); + +select count(*) from t1; + +# We didn't create large wholes with the previous deletion, so if innodb_defragment_n_pages = 3, we won't be able to free up many pages. +if (!`select count(*) > 130 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number; +} + +select count(*) from t1 force index (second); + +# Same holds for secondary index, not many pages are released. +if (!`select count(*) > 100 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number; +} + +SET @@global.innodb_defragment_n_pages = 10; + +optimize table t1; + +--source include/restart_mysqld.inc + +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed', 'n_page_split', 'n_leaf_pages_defrag'); + +select count(*) from t1; + +# This time we used innodb_defragment_n_pages = 10, so we should be able to free up some pages. +if (!`select count(*) < 165 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY' order by page_number; +} + +select count(*) from t1 force index (second); + +if (!`select count(*) < 165 from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number;`) +{ +select count(*) from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second' order by page_number; +} + +DROP PROCEDURE defragment; +DROP TABLE t1; +# reset system +--disable_query_log +EVAL SET GLOBAL innodb_defragment_n_pages = $innodb_defragment_n_pages_orig; +EVAL SET GLOBAL innodb_defragment_stats_accuracy = $innodb_defragment_stats_accuracy_orig; +--enable_query_log + diff --git a/mysql-test/suite/innodb/t/innodb_defragment_fill_factor.opt b/mysql-test/suite/innodb/t/innodb_defragment_fill_factor.opt new file mode 100644 index 00000000000..6426bac41a0 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defragment_fill_factor.opt @@ -0,0 +1,4 @@ +--loose-innodb-buffer-pool-stats +--loose-innodb-buffer-page +--loose-innodb-buffer-page-lru +--innodb-defragment=1
\ No newline at end of file diff --git a/mysql-test/suite/innodb/t/innodb_defragment_fill_factor.test b/mysql-test/suite/innodb/t/innodb_defragment_fill_factor.test new file mode 100644 index 00000000000..b2fdfa4a409 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_defragment_fill_factor.test @@ -0,0 +1,130 @@ +--source include/have_innodb.inc +--disable_warnings +DROP TABLE if exists t1; +DROP TABLE if exists t2; +--enable_warnings +--echo Testing tables with large records +# Create table. +CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB; +# Populate table. +let $i = 1000; +--disable_query_log +while ($i) +{ + eval + INSERT INTO t1 VALUES ($i, REPEAT('A', 256)); + dec $i; +} +--enable_query_log +--disable_query_log +let $size = 10; +while ($size) +{ + let $j = 100 * $size; + eval delete from t1 where a between $j - 20 and $j; + dec $size; +} +--enable_query_log +optimize table t1; +--source include/restart_mysqld.inc +select count(*) from t1; +# After deletion & defragmentation, there are 800 records left. Each page can hold about 57 records. We fill the page 90% full, +# so there should be less than 16 pages total. +--let $primary_before = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY', Value, 1) +select count(*) from t1 force index (second); +# secondary index is slightly bigger than primary index so the number of pages should be similar. +--let $second_before = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second', Value, 1) +--echo # A few more insertions on the page should not cause a page split. +insert into t1 values (81, REPEAT('A', 256)); +insert into t1 values (83, REPEAT('A', 256)); +insert into t1 values (87, REPEAT('A', 256)); +insert into t1 values (82, REPEAT('A', 256)); +insert into t1 values (86, REPEAT('A', 256)); +--let $primary_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY', Value, 1) +--let $second_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second', Value, 1) +if ($primary_before != $primary_after) { + --echo Insertion caused page split on primary, which should be avoided by innodb_defragment_fill_factor. +} +if ($second_before != $second_after) { + --echo Insertion caused page split on second, which should be avoided by innodb_defragment_fill_factor. +} +--echo # More insertions will cause page splits +insert into t1 values (88, REPEAT('A', 50)); +#insert into t1 values (85, REPEAT('A', 256)); +#insert into t1 values (84, REPEAT('A', 256)); +#insert into t1 values (89, REPEAT('A', 256)); +--let $primary_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'PRIMARY', Value, 1) +--let $second_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t1%' and index_name = 'second', Value, 1) +if ($primary_before == $primary_after) { + --echo Too much space are reserved on primary index. +} +if ($second_before == $second_after) { + --echo Too much space are reserved on second index. +} +DROP TABLE t1; +--echo Testing table with small records +CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARchar(16), KEY SECOND(a,b)) ENGINE=INNODB; +# Populate table. +--disable_query_log +INSERT INTO t2 VALUES (1, REPEAT('A', 16)); +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +INSERT INTO t2 (b) SELECT b from t2; +--enable_query_log +--disable_query_log +let $size = 40; +while ($size) +{ + let $j = 100 * $size; + eval delete from t2 where a between $j - 20 and $j; + dec $size; +} +--enable_query_log +optimize table t2; +--source include/restart_mysqld.inc +select count(*) from t2 force index(second); +--let $second_before = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t2%' and index_name = 'second', Value, 1) +--echo The page should have room for about 20 insertions +insert into t2 values(1181, REPEAT('A', 16)); +insert into t2 values(1191, REPEAT('A', 16)); +insert into t2 values(1182, REPEAT('A', 16)); +insert into t2 values(1192, REPEAT('A', 16)); +insert into t2 values(1183, REPEAT('A', 16)); +insert into t2 values(1193, REPEAT('A', 16)); +insert into t2 values(1184, REPEAT('A', 16)); +insert into t2 values(1194, REPEAT('A', 16)); +insert into t2 values(1185, REPEAT('A', 16)); +insert into t2 values(1195, REPEAT('A', 16)); +insert into t2 values(1186, REPEAT('A', 16)); +insert into t2 values(1196, REPEAT('A', 16)); +insert into t2 values(1187, REPEAT('A', 16)); +insert into t2 values(1197, REPEAT('A', 16)); +insert into t2 values(1188, REPEAT('A', 16)); +insert into t2 values(1198, REPEAT('A', 16)); +insert into t2 values(1189, REPEAT('A', 16)); +insert into t2 values(1199, REPEAT('A', 16)); +insert into t2 values(1190, REPEAT('A', 16)); +insert into t2 values(1180, REPEAT('A', 16)); +--let $second_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t2%' and index_name = 'second', Value, 1) +if ($second_before != $second_after) { + --echo Insertion caused page split on second, which should be avoided by innodb_defragment_fill_factor. +} +--echo More insertions will cause page split. +insert into t2 values(1280, REPEAT('A', 16)); +insert into t2 values(1290, REPEAT('A', 16)); +insert into t2 values(1281, REPEAT('A', 16)); +insert into t2 values(1291, REPEAT('A', 16)); +--let $second_after = query_get_value(select count(*) as Value from information_schema.innodb_buffer_page where table_name like '%t2%' and index_name = 'second', Value, 1) +if ($second_before == $second_after) { + --echo Too much space are reserved on second index. +} +DROP TABLE t2; diff --git a/mysql-test/suite/perfschema/include/upgrade_check.inc b/mysql-test/suite/perfschema/include/upgrade_check.inc index 52d4cfd1e63..327d63cc633 100644 --- a/mysql-test/suite/perfschema/include/upgrade_check.inc +++ b/mysql-test/suite/perfschema/include/upgrade_check.inc @@ -3,11 +3,10 @@ # --source include/count_sessions.inc ---error 1 --exec $MYSQL_UPGRADE --skip-verbose --force > $out_file 2> $err_file --source include/wait_until_count_sessions.inc -# Verify that mysql_upgrade complained about the performance_schema +# Verify that mysql_upgrade does not complain about the performance_schema --replace_regex /at line [0-9]+/at line ###/ --cat_file $err_file diff --git a/mysql-test/suite/perfschema/r/pfs_upgrade_event.result b/mysql-test/suite/perfschema/r/pfs_upgrade_event.result index cbd684a6232..6397ef7d90c 100644 --- a/mysql-test/suite/perfschema/r/pfs_upgrade_event.result +++ b/mysql-test/suite/perfschema/r/pfs_upgrade_event.result @@ -3,59 +3,6 @@ drop event if exists test.user_event; create event test.user_event on schedule every 1 day do select "not supposed to be here"; update mysql.event set db='performance_schema' where name='user_event'; -ERROR 1050 (42S01) at line ###: Table 'cond_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'file_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'file_summary_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'file_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_summary_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'host_cache' already exists -ERROR 1050 (42S01) at line ###: Table 'mutex_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'objects_summary_global_by_type' already exists -ERROR 1050 (42S01) at line ###: Table 'performance_timers' already exists -ERROR 1050 (42S01) at line ###: Table 'rwlock_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_actors' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_consumers' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_instruments' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_objects' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_timers' already exists -ERROR 1050 (42S01) at line ###: Table 'table_io_waits_summary_by_index_usage' already exists -ERROR 1050 (42S01) at line ###: Table 'table_io_waits_summary_by_table' already exists -ERROR 1050 (42S01) at line ###: Table 'table_lock_waits_summary_by_table' already exists -ERROR 1050 (42S01) at line ###: Table 'threads' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'hosts' already exists -ERROR 1050 (42S01) at line ###: Table 'users' already exists -ERROR 1050 (42S01) at line ###: Table 'accounts' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_digest' already exists -ERROR 1050 (42S01) at line ###: Table 'session_connect_attrs' already exists -ERROR 1050 (42S01) at line ###: Table 'session_account_connect_attrs' already exists -FATAL ERROR: Upgrade failed select name from mysql.event where db='performance_schema'; name user_event diff --git a/mysql-test/suite/perfschema/r/pfs_upgrade_func.result b/mysql-test/suite/perfschema/r/pfs_upgrade_func.result index 6978e1ed0a8..e03b526b045 100644 --- a/mysql-test/suite/perfschema/r/pfs_upgrade_func.result +++ b/mysql-test/suite/perfschema/r/pfs_upgrade_func.result @@ -3,59 +3,6 @@ drop function if exists test.user_func; create function test.user_func() returns integer return 0; update mysql.proc set db='performance_schema' where name='user_func'; -ERROR 1050 (42S01) at line ###: Table 'cond_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'file_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'file_summary_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'file_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_summary_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'host_cache' already exists -ERROR 1050 (42S01) at line ###: Table 'mutex_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'objects_summary_global_by_type' already exists -ERROR 1050 (42S01) at line ###: Table 'performance_timers' already exists -ERROR 1050 (42S01) at line ###: Table 'rwlock_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_actors' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_consumers' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_instruments' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_objects' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_timers' already exists -ERROR 1050 (42S01) at line ###: Table 'table_io_waits_summary_by_index_usage' already exists -ERROR 1050 (42S01) at line ###: Table 'table_io_waits_summary_by_table' already exists -ERROR 1050 (42S01) at line ###: Table 'table_lock_waits_summary_by_table' already exists -ERROR 1050 (42S01) at line ###: Table 'threads' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'hosts' already exists -ERROR 1050 (42S01) at line ###: Table 'users' already exists -ERROR 1050 (42S01) at line ###: Table 'accounts' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_digest' already exists -ERROR 1050 (42S01) at line ###: Table 'session_connect_attrs' already exists -ERROR 1050 (42S01) at line ###: Table 'session_account_connect_attrs' already exists -FATAL ERROR: Upgrade failed select name from mysql.proc where db='performance_schema'; name user_func diff --git a/mysql-test/suite/perfschema/r/pfs_upgrade_proc.result b/mysql-test/suite/perfschema/r/pfs_upgrade_proc.result index f5a13fb445d..95e0943d326 100644 --- a/mysql-test/suite/perfschema/r/pfs_upgrade_proc.result +++ b/mysql-test/suite/perfschema/r/pfs_upgrade_proc.result @@ -3,59 +3,6 @@ drop procedure if exists test.user_proc; create procedure test.user_proc() select "Not supposed to be here"; update mysql.proc set db='performance_schema' where name='user_proc'; -ERROR 1050 (42S01) at line ###: Table 'cond_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'file_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'file_summary_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'file_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_summary_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'host_cache' already exists -ERROR 1050 (42S01) at line ###: Table 'mutex_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'objects_summary_global_by_type' already exists -ERROR 1050 (42S01) at line ###: Table 'performance_timers' already exists -ERROR 1050 (42S01) at line ###: Table 'rwlock_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_actors' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_consumers' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_instruments' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_objects' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_timers' already exists -ERROR 1050 (42S01) at line ###: Table 'table_io_waits_summary_by_index_usage' already exists -ERROR 1050 (42S01) at line ###: Table 'table_io_waits_summary_by_table' already exists -ERROR 1050 (42S01) at line ###: Table 'table_lock_waits_summary_by_table' already exists -ERROR 1050 (42S01) at line ###: Table 'threads' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'hosts' already exists -ERROR 1050 (42S01) at line ###: Table 'users' already exists -ERROR 1050 (42S01) at line ###: Table 'accounts' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_digest' already exists -ERROR 1050 (42S01) at line ###: Table 'session_connect_attrs' already exists -ERROR 1050 (42S01) at line ###: Table 'session_account_connect_attrs' already exists -FATAL ERROR: Upgrade failed select name from mysql.proc where db='performance_schema'; name user_proc diff --git a/mysql-test/suite/perfschema/r/pfs_upgrade_table.result b/mysql-test/suite/perfschema/r/pfs_upgrade_table.result index bb5ba7060ae..a5f5ad5ae17 100644 --- a/mysql-test/suite/perfschema/r/pfs_upgrade_table.result +++ b/mysql-test/suite/perfschema/r/pfs_upgrade_table.result @@ -5,59 +5,6 @@ use performance_schema; show tables like "user_table"; Tables_in_performance_schema (user_table) user_table -ERROR 1050 (42S01) at line ###: Table 'cond_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'file_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'file_summary_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'file_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_summary_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'host_cache' already exists -ERROR 1050 (42S01) at line ###: Table 'mutex_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'objects_summary_global_by_type' already exists -ERROR 1050 (42S01) at line ###: Table 'performance_timers' already exists -ERROR 1050 (42S01) at line ###: Table 'rwlock_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_actors' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_consumers' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_instruments' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_objects' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_timers' already exists -ERROR 1050 (42S01) at line ###: Table 'table_io_waits_summary_by_index_usage' already exists -ERROR 1050 (42S01) at line ###: Table 'table_io_waits_summary_by_table' already exists -ERROR 1050 (42S01) at line ###: Table 'table_lock_waits_summary_by_table' already exists -ERROR 1050 (42S01) at line ###: Table 'threads' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'hosts' already exists -ERROR 1050 (42S01) at line ###: Table 'users' already exists -ERROR 1050 (42S01) at line ###: Table 'accounts' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_digest' already exists -ERROR 1050 (42S01) at line ###: Table 'session_connect_attrs' already exists -ERROR 1050 (42S01) at line ###: Table 'session_account_connect_attrs' already exists -FATAL ERROR: Upgrade failed show tables like "user_table"; Tables_in_performance_schema (user_table) user_table diff --git a/mysql-test/suite/perfschema/r/pfs_upgrade_view.result b/mysql-test/suite/perfschema/r/pfs_upgrade_view.result index f9541680b6d..3c6df20a62c 100644 --- a/mysql-test/suite/perfschema/r/pfs_upgrade_view.result +++ b/mysql-test/suite/perfschema/r/pfs_upgrade_view.result @@ -5,59 +5,6 @@ use performance_schema; show tables like "user_view"; Tables_in_performance_schema (user_view) user_view -ERROR 1050 (42S01) at line ###: Table 'cond_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_waits_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'file_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'file_summary_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'file_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_summary_by_instance' already exists -ERROR 1050 (42S01) at line ###: Table 'socket_summary_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'host_cache' already exists -ERROR 1050 (42S01) at line ###: Table 'mutex_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'objects_summary_global_by_type' already exists -ERROR 1050 (42S01) at line ###: Table 'performance_timers' already exists -ERROR 1050 (42S01) at line ###: Table 'rwlock_instances' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_actors' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_consumers' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_instruments' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_objects' already exists -ERROR 1050 (42S01) at line ###: Table 'setup_timers' already exists -ERROR 1050 (42S01) at line ###: Table 'table_io_waits_summary_by_index_usage' already exists -ERROR 1050 (42S01) at line ###: Table 'table_io_waits_summary_by_table' already exists -ERROR 1050 (42S01) at line ###: Table 'table_lock_waits_summary_by_table' already exists -ERROR 1050 (42S01) at line ###: Table 'threads' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_stages_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_current' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_history' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_history_long' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_thread_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_host_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_user_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_account_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_global_by_event_name' already exists -ERROR 1050 (42S01) at line ###: Table 'hosts' already exists -ERROR 1050 (42S01) at line ###: Table 'users' already exists -ERROR 1050 (42S01) at line ###: Table 'accounts' already exists -ERROR 1050 (42S01) at line ###: Table 'events_statements_summary_by_digest' already exists -ERROR 1050 (42S01) at line ###: Table 'session_connect_attrs' already exists -ERROR 1050 (42S01) at line ###: Table 'session_account_connect_attrs' already exists -FATAL ERROR: Upgrade failed show tables like "user_view"; Tables_in_performance_schema (user_view) user_view diff --git a/mysql-test/suite/perfschema/r/tampered_perfschema_table1.result b/mysql-test/suite/perfschema/r/tampered_perfschema_table1.result deleted file mode 100644 index e9537e5474c..00000000000 --- a/mysql-test/suite/perfschema/r/tampered_perfschema_table1.result +++ /dev/null @@ -1,6 +0,0 @@ -call mtr.add_suppression( -"Column count of performance_schema.setup_instruments is wrong. " -"Expected 4, found 3. The table is probably corrupted"); -select * from performance_schema.setup_instruments limit 1; -ERROR HY000: Native table 'performance_schema'.'setup_instruments' has the wrong structure -select * from performance_schema.setup_consumers limit 1; diff --git a/mysql-test/suite/perfschema/t/tampered_perfschema_table1-master.opt b/mysql-test/suite/perfschema/t/tampered_perfschema_table1-master.opt deleted file mode 100644 index 5f094e68be7..00000000000 --- a/mysql-test/suite/perfschema/t/tampered_perfschema_table1-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-debug=+d,tampered_perfschema_table1 diff --git a/mysql-test/suite/perfschema/t/tampered_perfschema_table1.test b/mysql-test/suite/perfschema/t/tampered_perfschema_table1.test deleted file mode 100644 index 09e3d3aaa2c..00000000000 --- a/mysql-test/suite/perfschema/t/tampered_perfschema_table1.test +++ /dev/null @@ -1,25 +0,0 @@ -# Tests for PERFORMANCE_SCHEMA - -# This test uses error injection, -# see PFS_engine_table_share::check_all_tables() - -# Verify that the server starts even when a performance schema table -# is corrupted, with an incompatible change. -# Verify that using that table nicely fails. -# Verify that other tables are not affected. - ---source include/have_debug.inc ---source include/not_embedded.inc ---source include/have_perfschema.inc - -call mtr.add_suppression( -"Column count of performance_schema.setup_instruments is wrong. " -"Expected 4, found 3. The table is probably corrupted"); - ---error ER_WRONG_NATIVE_TABLE_STRUCTURE -select * from performance_schema.setup_instruments limit 1; - ---disable_result_log -select * from performance_schema.setup_consumers limit 1; ---enable_result_log - diff --git a/mysql-test/suite/sys_vars/r/innodb_defragment_basic.result b/mysql-test/suite/sys_vars/r/innodb_defragment_basic.result new file mode 100644 index 00000000000..916bb5ca1a9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_defragment_basic.result @@ -0,0 +1,18 @@ +SET @orig = @@global.innodb_defragment; +SELECT @orig; +@orig +0 +SET GLOBAL innodb_defragment = OFF; +SELECT @@global.innodb_defragment; +@@global.innodb_defragment +0 +SET GLOBAL innodb_defragment = ON; +SELECT @@global.innodb_defragment; +@@global.innodb_defragment +1 +SET GLOBAL innodb_defragment = 100; +ERROR 42000: Variable 'innodb_defragment' can't be set to the value of '100' +SELECT @@global.innodb_defragment; +@@global.innodb_defragment +1 +SET GLOBAL innodb_defragment = @orig; diff --git a/mysql-test/suite/sys_vars/r/innodb_defragment_fill_factor_basic.result b/mysql-test/suite/sys_vars/r/innodb_defragment_fill_factor_basic.result new file mode 100644 index 00000000000..93a5af727c3 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_defragment_fill_factor_basic.result @@ -0,0 +1,37 @@ +SET @start_innodb_defragment_fill_factor = @@global.innodb_defragment_fill_factor; +SELECT @start_innodb_defragment_fill_factor; +@start_innodb_defragment_fill_factor +0.9 +SELECT COUNT(@@global.innodb_defragment_fill_factor); +COUNT(@@global.innodb_defragment_fill_factor) +1 +SET @@global.innodb_defragment_fill_factor = 0.77777777777777; +SELECT @@global.innodb_defragment_fill_factor; +@@global.innodb_defragment_fill_factor +0.777778 +SET @@global.innodb_defragment_fill_factor = 1; +SELECT @@global.innodb_defragment_fill_factor; +@@global.innodb_defragment_fill_factor +1.000000 +SET @@global.innodb_defragment_fill_factor = 0.7; +SELECT @@global.innodb_defragment_fill_factor; +@@global.innodb_defragment_fill_factor +0.700000 +SET @@global.innodb_defragment_fill_factor = -1; +Warnings: +Warning 1292 Truncated incorrect innodb_defragment_fill_factor value: '-1' +SELECT @@global.innodb_defragment_fill_factor; +@@global.innodb_defragment_fill_factor +0.700000 +SET @@global.innodb_defragment_fill_factor = 2; +Warnings: +Warning 1292 Truncated incorrect innodb_defragment_fill_factor value: '2' +SELECT @@global.innodb_defragment_fill_factor; +@@global.innodb_defragment_fill_factor +1.000000 +SET @@global.innodb_defragment_fill_factor = "abc"; +ERROR 42000: Incorrect argument type to variable 'innodb_defragment_fill_factor' +SELECT @@global.innodb_defragment_fill_factor; +@@global.innodb_defragment_fill_factor +1.000000 +SET @@global.innodb_defragment_fill_factor = @start_innodb_defragment_fill_factor; diff --git a/mysql-test/suite/sys_vars/r/innodb_defragment_fill_factor_n_recs_basic.result b/mysql-test/suite/sys_vars/r/innodb_defragment_fill_factor_n_recs_basic.result new file mode 100644 index 00000000000..ffbeb39fe33 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_defragment_fill_factor_n_recs_basic.result @@ -0,0 +1,42 @@ +SET @start_innodb_defragment_fill_factor_n_recs = @@global.innodb_defragment_fill_factor_n_recs; +SELECT @start_innodb_defragment_fill_factor_n_recs; +@start_innodb_defragment_fill_factor_n_recs +20 +SELECT COUNT(@@global.innodb_defragment_fill_factor_n_recs); +COUNT(@@global.innodb_defragment_fill_factor_n_recs) +1 +SET @@global.innodb_defragment_fill_factor_n_recs = 50; +SELECT @@global.innodb_defragment_fill_factor_n_recs; +@@global.innodb_defragment_fill_factor_n_recs +50 +SET @@global.innodb_defragment_fill_factor_n_recs = 100; +SELECT @@global.innodb_defragment_fill_factor_n_recs; +@@global.innodb_defragment_fill_factor_n_recs +100 +SET @@global.innodb_defragment_fill_factor_n_recs = 1; +SELECT @@global.innodb_defragment_fill_factor_n_recs; +@@global.innodb_defragment_fill_factor_n_recs +1 +SET @@global.innodb_defragment_fill_factor_n_recs = -1; +Warnings: +Warning 1292 Truncated incorrect innodb_defragment_fill_factor_n_ value: '-1' +SELECT @@global.innodb_defragment_fill_factor_n_recs; +@@global.innodb_defragment_fill_factor_n_recs +1 +SET @@global.innodb_defragment_fill_factor_n_recs = 10000; +Warnings: +Warning 1292 Truncated incorrect innodb_defragment_fill_factor_n_ value: '10000' +SELECT @@global.innodb_defragment_fill_factor_n_recs; +@@global.innodb_defragment_fill_factor_n_recs +100 +SET @@global.innodb_defragment_fill_factor_n_recs = 10.5; +ERROR 42000: Incorrect argument type to variable 'innodb_defragment_fill_factor_n_recs' +SELECT @@global.innodb_defragment_fill_factor_n_recs; +@@global.innodb_defragment_fill_factor_n_recs +100 +SET @@global.innodb_defragment_fill_factor_n_recs = "abc"; +ERROR 42000: Incorrect argument type to variable 'innodb_defragment_fill_factor_n_recs' +SELECT @@global.innodb_defragment_fill_factor_n_recs; +@@global.innodb_defragment_fill_factor_n_recs +100 +SET @@global.innodb_defragment_fill_factor_n_recs = @start_innodb_defragment_fill_factor_n_recs; diff --git a/mysql-test/suite/sys_vars/r/innodb_defragment_frequency_basic.result b/mysql-test/suite/sys_vars/r/innodb_defragment_frequency_basic.result new file mode 100644 index 00000000000..d4314d6506e --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_defragment_frequency_basic.result @@ -0,0 +1,42 @@ +SET @start_innodb_defragment_frequency = @@global.innodb_defragment_frequency; +SELECT @start_innodb_defragment_frequency; +@start_innodb_defragment_frequency +40 +SELECT COUNT(@@global.innodb_defragment_frequency); +COUNT(@@global.innodb_defragment_frequency) +1 +SET @@global.innodb_defragment_frequency = 200; +SELECT @@global.innodb_defragment_frequency; +@@global.innodb_defragment_frequency +200 +SET @@global.innodb_defragment_frequency = 1; +SELECT @@global.innodb_defragment_frequency; +@@global.innodb_defragment_frequency +1 +SET @@global.innodb_defragment_frequency = 1000; +SELECT @@global.innodb_defragment_frequency; +@@global.innodb_defragment_frequency +1000 +SET @@global.innodb_defragment_frequency = -1; +Warnings: +Warning 1292 Truncated incorrect innodb_defragment_frequency value: '-1' +SELECT @@global.innodb_defragment_frequency; +@@global.innodb_defragment_frequency +1 +SET @@global.innodb_defragment_frequency = 10000; +Warnings: +Warning 1292 Truncated incorrect innodb_defragment_frequency value: '10000' +SELECT @@global.innodb_defragment_frequency; +@@global.innodb_defragment_frequency +1000 +SET @@global.innodb_defragment_frequency = 10.5; +ERROR 42000: Incorrect argument type to variable 'innodb_defragment_frequency' +SELECT @@global.innodb_defragment_frequency; +@@global.innodb_defragment_frequency +1000 +SET @@global.innodb_defragment_frequency = "abc"; +ERROR 42000: Incorrect argument type to variable 'innodb_defragment_frequency' +SELECT @@global.innodb_defragment_frequency; +@@global.innodb_defragment_frequency +1000 +SET @@global.innodb_defragment_frequency = @start_innodb_defragment_frequency; diff --git a/mysql-test/suite/sys_vars/r/innodb_defragment_n_pages_basic.result b/mysql-test/suite/sys_vars/r/innodb_defragment_n_pages_basic.result new file mode 100644 index 00000000000..99b68b39ec4 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_defragment_n_pages_basic.result @@ -0,0 +1,28 @@ +SET @start_innodb_defragment_n_pages = @@global.innodb_defragment_n_pages; +SELECT @start_innodb_defragment_n_pages; +@start_innodb_defragment_n_pages +7 +SELECT COUNT(@@global.innodb_defragment_n_pages); +COUNT(@@global.innodb_defragment_n_pages) +1 +SET @@global.innodb_defragment_n_pages = 1; +Warnings: +Warning 1292 Truncated incorrect innodb_defragment_n_pages value: '1' +SELECT @@global.innodb_defragment_n_pages; +@@global.innodb_defragment_n_pages +2 +SET @@global.innodb_defragment_n_pages = 2; +SELECT @@global.innodb_defragment_n_pages; +@@global.innodb_defragment_n_pages +2 +SET @@global.innodb_defragment_n_pages = 32; +SELECT @@global.innodb_defragment_n_pages; +@@global.innodb_defragment_n_pages +32 +SET @@global.innodb_defragment_n_pages = 64; +Warnings: +Warning 1292 Truncated incorrect innodb_defragment_n_pages value: '64' +SELECT @@global.innodb_defragment_n_pages; +@@global.innodb_defragment_n_pages +32 +SET @@global.innodb_defragment_n_pages = @start_innodb_defragment_n_pages; diff --git a/mysql-test/suite/sys_vars/r/innodb_defragment_stats_accuracy_basic.result b/mysql-test/suite/sys_vars/r/innodb_defragment_stats_accuracy_basic.result new file mode 100644 index 00000000000..025dacdb1ec --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_defragment_stats_accuracy_basic.result @@ -0,0 +1,33 @@ +SET @start_innodb_defragment_stats_accuracy = @@global.innodb_defragment_stats_accuracy; +SELECT @start_innodb_defragment_stats_accuracy; +@start_innodb_defragment_stats_accuracy +0 +SELECT COUNT(@@global.innodb_defragment_stats_accuracy); +COUNT(@@global.innodb_defragment_stats_accuracy) +1 +SET @@global.innodb_defragment_stats_accuracy = 1; +SELECT @@global.innodb_defragment_stats_accuracy; +@@global.innodb_defragment_stats_accuracy +1 +SET @@global.innodb_defragment_stats_accuracy = 1000; +SELECT @@global.innodb_defragment_stats_accuracy; +@@global.innodb_defragment_stats_accuracy +1000 +SET @@global.innodb_defragment_stats_accuracy = -1; +Warnings: +Warning 1292 Truncated incorrect innodb_defragment_stats_accuracy value: '-1' +SELECT @@global.innodb_defragment_stats_accuracy; +@@global.innodb_defragment_stats_accuracy +0 +SET @@global.innodb_defragment_stats_accuracy = 1000000000000; +Warnings: +Warning 1292 Truncated incorrect innodb_defragment_stats_accuracy value: '1000000000000' +SELECT @@global.innodb_defragment_stats_accuracy; +@@global.innodb_defragment_stats_accuracy +4294967295 +SET @@global.innodb_defragment_stats_accuracy = "abc"; +ERROR 42000: Incorrect argument type to variable 'innodb_defragment_stats_accuracy' +SELECT @@global.innodb_defragment_stats_accuracy; +@@global.innodb_defragment_stats_accuracy +4294967295 +SET @@global.innodb_defragment_stats_accuracy = @start_innodb_defragment_stats_accuracy; diff --git a/mysql-test/suite/sys_vars/r/slave_run_triggers_for_rbr_basic.result b/mysql-test/suite/sys_vars/r/slave_run_triggers_for_rbr_basic.result new file mode 100644 index 00000000000..02a3cdf27ce --- /dev/null +++ b/mysql-test/suite/sys_vars/r/slave_run_triggers_for_rbr_basic.result @@ -0,0 +1,45 @@ +SET @old_slave_run_triggers_for_rbr= @@global.slave_run_triggers_for_rbr; +SET @@global.slave_run_triggers_for_rbr= NO; +select @@global.slave_run_triggers_for_rbr; +@@global.slave_run_triggers_for_rbr +NO +SET @@global.slave_run_triggers_for_rbr= YES; +select @@global.slave_run_triggers_for_rbr; +@@global.slave_run_triggers_for_rbr +YES +SET @@global.slave_run_triggers_for_rbr= LOGGING; +select @@global.slave_run_triggers_for_rbr; +@@global.slave_run_triggers_for_rbr +LOGGING +SET @@global.slave_run_triggers_for_rbr= default; +select @@global.slave_run_triggers_for_rbr; +@@global.slave_run_triggers_for_rbr +NO +SET @@global.slave_run_triggers_for_rbr= 0; +select @@global.slave_run_triggers_for_rbr; +@@global.slave_run_triggers_for_rbr +NO +SET @@global.slave_run_triggers_for_rbr= 1; +select @@global.slave_run_triggers_for_rbr; +@@global.slave_run_triggers_for_rbr +YES +SET @@global.slave_run_triggers_for_rbr= 2; +select @@global.slave_run_triggers_for_rbr; +@@global.slave_run_triggers_for_rbr +LOGGING +SET @@global.slave_run_triggers_for_rbr= 3; +ERROR 42000: Variable 'slave_run_triggers_for_rbr' can't be set to the value of '3' +select @@global.slave_run_triggers_for_rbr; +@@global.slave_run_triggers_for_rbr +LOGGING +SET @@global.slave_run_triggers_for_rbr= "N"; +ERROR 42000: Variable 'slave_run_triggers_for_rbr' can't be set to the value of 'N' +select @@global.slave_run_triggers_for_rbr; +@@global.slave_run_triggers_for_rbr +LOGGING +SET @@global.slave_run_triggers_for_rbr= -1; +ERROR 42000: Variable 'slave_run_triggers_for_rbr' can't be set to the value of '-1' +select @@global.slave_run_triggers_for_rbr; +@@global.slave_run_triggers_for_rbr +LOGGING +SET @@global.slave_run_triggers_for_rbr= @old_slave_run_triggers_for_rbr; diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_basic.result b/mysql-test/suite/sys_vars/r/slow_query_log_basic.result index bf9a83f0380..049404f5648 100644 --- a/mysql-test/suite/sys_vars/r/slow_query_log_basic.result +++ b/mysql-test/suite/sys_vars/r/slow_query_log_basic.result @@ -42,10 +42,17 @@ ERROR 42000: Variable 'slow_query_log' can't be set to the value of ' ' SET @@global.slow_query_log = ''; ERROR 42000: Variable 'slow_query_log' can't be set to the value of '' '#-------------------FN_DYNVARS_004_04----------------------------#' +SET @@global.slow_query_log = ON; +SET @@session.slow_query_log = ON; +SELECT @@session.slow_query_log; +@@session.slow_query_log +1 SET @@session.slow_query_log = OFF; -ERROR HY000: Variable 'slow_query_log' is a GLOBAL variable and should be set with SET GLOBAL SELECT @@session.slow_query_log; -ERROR HY000: Variable 'slow_query_log' is a GLOBAL variable +@@session.slow_query_log +0 +SET @@global.slow_query_log = OFF; +SET @@session.slow_query_log = ON; '#----------------------FN_DYNVARS_004_05------------------------#' SELECT IF(@@global.slow_query_log, "ON", "OFF") = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES @@ -72,12 +79,11 @@ SELECT @@global.slow_query_log; 0 '#---------------------FN_DYNVARS_004_08----------------------#' SET @@global.slow_query_log = ON; +SET @@local.slow_query_log = OFF; SELECT @@slow_query_log = @@global.slow_query_log; @@slow_query_log = @@global.slow_query_log -1 +0 '#---------------------FN_DYNVARS_004_09----------------------#' -SET slow_query_log = ON; -ERROR HY000: Variable 'slow_query_log' is a GLOBAL variable and should be set with SET GLOBAL SET local.slow_query_log = OFF; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'slow_query_log = OFF' at line 1 SELECT local.slow_query_log; diff --git a/mysql-test/suite/sys_vars/r/slow_query_log_func.result b/mysql-test/suite/sys_vars/r/slow_query_log_func.result index f01b2c4c48b..b431f963239 100644 --- a/mysql-test/suite/sys_vars/r/slow_query_log_func.result +++ b/mysql-test/suite/sys_vars/r/slow_query_log_func.result @@ -2,7 +2,7 @@ SET @global_slow_query_log = @@global.slow_query_log; SET @global_log_output = @@global.log_output; SET @@session.long_query_time=1; SET @@global.log_output = 'TABLE'; -'----When slow_query_log = OFF----' +'----When global.slow_query_log = OFF----' SET @@global.slow_query_log = OFF; TRUNCATE mysql.slow_log; SELECT sleep(2); @@ -11,7 +11,7 @@ sleep(2) SELECT count(*) FROM mysql.slow_log; count(*) 0 -'----When slow_query_log = ON-----' +'----When global.slow_query_log = ON-----' SET @@global.slow_query_log = ON; TRUNCATE mysql.slow_log; SELECT sleep(2); @@ -20,6 +20,16 @@ sleep(2) SELECT count(*) > 0 FROM mysql.slow_log; count(*) > 0 1 +'----When local.slow_query_log = OFF-----' +SET @@local.slow_query_log = OFF; +TRUNCATE mysql.slow_log; +SELECT sleep(2); +sleep(2) +0 +SELECT count(*) FROM mysql.slow_log; +count(*) +0 +SET @@local.slow_query_log = ON; 'Bug#47905 stored procedures not logged correctly to slow query log' TRUNCATE mysql.slow_log; CREATE PROCEDURE p_test() diff --git a/mysql-test/suite/sys_vars/t/innodb_defragment_basic.test b/mysql-test/suite/sys_vars/t/innodb_defragment_basic.test new file mode 100644 index 00000000000..9667f63f687 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_defragment_basic.test @@ -0,0 +1,20 @@ +-- source include/have_innodb.inc + +# Check the default value +SET @orig = @@global.innodb_defragment; +SELECT @orig; + +# Turn off +SET GLOBAL innodb_defragment = OFF; +SELECT @@global.innodb_defragment; + +# Turn on +SET GLOBAL innodb_defragment = ON; +SELECT @@global.innodb_defragment; + +# Wrong value +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_defragment = 100; +SELECT @@global.innodb_defragment; + +SET GLOBAL innodb_defragment = @orig; diff --git a/mysql-test/suite/sys_vars/t/innodb_defragment_fill_factor_basic.test b/mysql-test/suite/sys_vars/t/innodb_defragment_fill_factor_basic.test new file mode 100644 index 00000000000..ae9863e806a --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_defragment_fill_factor_basic.test @@ -0,0 +1,27 @@ +--source include/have_innodb.inc + +SET @start_innodb_defragment_fill_factor = @@global.innodb_defragment_fill_factor; +SELECT @start_innodb_defragment_fill_factor; + +SELECT COUNT(@@global.innodb_defragment_fill_factor); + +SET @@global.innodb_defragment_fill_factor = 0.77777777777777; +SELECT @@global.innodb_defragment_fill_factor; + +SET @@global.innodb_defragment_fill_factor = 1; +SELECT @@global.innodb_defragment_fill_factor; + +SET @@global.innodb_defragment_fill_factor = 0.7; +SELECT @@global.innodb_defragment_fill_factor; + +SET @@global.innodb_defragment_fill_factor = -1; +SELECT @@global.innodb_defragment_fill_factor; + +SET @@global.innodb_defragment_fill_factor = 2; +SELECT @@global.innodb_defragment_fill_factor; + +--Error ER_WRONG_TYPE_FOR_VAR +SET @@global.innodb_defragment_fill_factor = "abc"; +SELECT @@global.innodb_defragment_fill_factor; + +SET @@global.innodb_defragment_fill_factor = @start_innodb_defragment_fill_factor; diff --git a/mysql-test/suite/sys_vars/t/innodb_defragment_fill_factor_n_recs_basic.test b/mysql-test/suite/sys_vars/t/innodb_defragment_fill_factor_n_recs_basic.test new file mode 100644 index 00000000000..366817c4bbc --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_defragment_fill_factor_n_recs_basic.test @@ -0,0 +1,31 @@ +--source include/have_innodb.inc + +SET @start_innodb_defragment_fill_factor_n_recs = @@global.innodb_defragment_fill_factor_n_recs; +SELECT @start_innodb_defragment_fill_factor_n_recs; + +SELECT COUNT(@@global.innodb_defragment_fill_factor_n_recs); + +SET @@global.innodb_defragment_fill_factor_n_recs = 50; +SELECT @@global.innodb_defragment_fill_factor_n_recs; + +SET @@global.innodb_defragment_fill_factor_n_recs = 100; +SELECT @@global.innodb_defragment_fill_factor_n_recs; + +SET @@global.innodb_defragment_fill_factor_n_recs = 1; +SELECT @@global.innodb_defragment_fill_factor_n_recs; + +SET @@global.innodb_defragment_fill_factor_n_recs = -1; +SELECT @@global.innodb_defragment_fill_factor_n_recs; + +SET @@global.innodb_defragment_fill_factor_n_recs = 10000; +SELECT @@global.innodb_defragment_fill_factor_n_recs; + +--Error ER_WRONG_TYPE_FOR_VAR +SET @@global.innodb_defragment_fill_factor_n_recs = 10.5; +SELECT @@global.innodb_defragment_fill_factor_n_recs; + +--Error ER_WRONG_TYPE_FOR_VAR +SET @@global.innodb_defragment_fill_factor_n_recs = "abc"; +SELECT @@global.innodb_defragment_fill_factor_n_recs; + +SET @@global.innodb_defragment_fill_factor_n_recs = @start_innodb_defragment_fill_factor_n_recs; diff --git a/mysql-test/suite/sys_vars/t/innodb_defragment_frequency_basic.test b/mysql-test/suite/sys_vars/t/innodb_defragment_frequency_basic.test new file mode 100644 index 00000000000..3ab45744a9c --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_defragment_frequency_basic.test @@ -0,0 +1,37 @@ +--source include/have_innodb.inc + +SET @start_innodb_defragment_frequency = @@global.innodb_defragment_frequency; +SELECT @start_innodb_defragment_frequency; + +SELECT COUNT(@@global.innodb_defragment_frequency); + +# test valid value +SET @@global.innodb_defragment_frequency = 200; +SELECT @@global.innodb_defragment_frequency; + +# test valid min +SET @@global.innodb_defragment_frequency = 1; +SELECT @@global.innodb_defragment_frequency; + +# test valid max +SET @@global.innodb_defragment_frequency = 1000; +SELECT @@global.innodb_defragment_frequency; + +# test invalid value < min +SET @@global.innodb_defragment_frequency = -1; +SELECT @@global.innodb_defragment_frequency; + +# test invalid value > max +SET @@global.innodb_defragment_frequency = 10000; +SELECT @@global.innodb_defragment_frequency; + +# test wrong type +--Error ER_WRONG_TYPE_FOR_VAR +SET @@global.innodb_defragment_frequency = 10.5; +SELECT @@global.innodb_defragment_frequency; + +--Error ER_WRONG_TYPE_FOR_VAR +SET @@global.innodb_defragment_frequency = "abc"; +SELECT @@global.innodb_defragment_frequency; + +SET @@global.innodb_defragment_frequency = @start_innodb_defragment_frequency; diff --git a/mysql-test/suite/sys_vars/t/innodb_defragment_n_pages_basic.test b/mysql-test/suite/sys_vars/t/innodb_defragment_n_pages_basic.test new file mode 100644 index 00000000000..64aa20a615f --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_defragment_n_pages_basic.test @@ -0,0 +1,22 @@ +--source include/have_innodb.inc + +SET @start_innodb_defragment_n_pages = @@global.innodb_defragment_n_pages; +SELECT @start_innodb_defragment_n_pages; + +SELECT COUNT(@@global.innodb_defragment_n_pages); + +SET @@global.innodb_defragment_n_pages = 1; +SELECT @@global.innodb_defragment_n_pages; + +SET @@global.innodb_defragment_n_pages = 2; +SELECT @@global.innodb_defragment_n_pages; + +SET @@global.innodb_defragment_n_pages = 32; +SELECT @@global.innodb_defragment_n_pages; + +SET @@global.innodb_defragment_n_pages = 64; +SELECT @@global.innodb_defragment_n_pages; + +SET @@global.innodb_defragment_n_pages = @start_innodb_defragment_n_pages; + + diff --git a/mysql-test/suite/sys_vars/t/innodb_defragment_stats_accuracy_basic.test b/mysql-test/suite/sys_vars/t/innodb_defragment_stats_accuracy_basic.test new file mode 100644 index 00000000000..062753f27ea --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_defragment_stats_accuracy_basic.test @@ -0,0 +1,24 @@ +--source include/have_innodb.inc + +SET @start_innodb_defragment_stats_accuracy = @@global.innodb_defragment_stats_accuracy; +SELECT @start_innodb_defragment_stats_accuracy; + +SELECT COUNT(@@global.innodb_defragment_stats_accuracy); + +SET @@global.innodb_defragment_stats_accuracy = 1; +SELECT @@global.innodb_defragment_stats_accuracy; + +SET @@global.innodb_defragment_stats_accuracy = 1000; +SELECT @@global.innodb_defragment_stats_accuracy; + +SET @@global.innodb_defragment_stats_accuracy = -1; +SELECT @@global.innodb_defragment_stats_accuracy; + +SET @@global.innodb_defragment_stats_accuracy = 1000000000000; +SELECT @@global.innodb_defragment_stats_accuracy; + +--Error ER_WRONG_TYPE_FOR_VAR +SET @@global.innodb_defragment_stats_accuracy = "abc"; +SELECT @@global.innodb_defragment_stats_accuracy; + +SET @@global.innodb_defragment_stats_accuracy = @start_innodb_defragment_stats_accuracy; diff --git a/mysql-test/suite/sys_vars/t/slave_run_triggers_for_rbr_basic.test b/mysql-test/suite/sys_vars/t/slave_run_triggers_for_rbr_basic.test new file mode 100644 index 00000000000..ac5296677b9 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/slave_run_triggers_for_rbr_basic.test @@ -0,0 +1,30 @@ + +-- source include/have_rbr_triggers.inc + +SET @old_slave_run_triggers_for_rbr= @@global.slave_run_triggers_for_rbr; +SET @@global.slave_run_triggers_for_rbr= NO; +select @@global.slave_run_triggers_for_rbr; +SET @@global.slave_run_triggers_for_rbr= YES; +select @@global.slave_run_triggers_for_rbr; +SET @@global.slave_run_triggers_for_rbr= LOGGING; +select @@global.slave_run_triggers_for_rbr; +SET @@global.slave_run_triggers_for_rbr= default; +select @@global.slave_run_triggers_for_rbr; +SET @@global.slave_run_triggers_for_rbr= 0; +select @@global.slave_run_triggers_for_rbr; +SET @@global.slave_run_triggers_for_rbr= 1; +select @@global.slave_run_triggers_for_rbr; +SET @@global.slave_run_triggers_for_rbr= 2; +select @@global.slave_run_triggers_for_rbr; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.slave_run_triggers_for_rbr= 3; +select @@global.slave_run_triggers_for_rbr; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.slave_run_triggers_for_rbr= "N"; +select @@global.slave_run_triggers_for_rbr; +--error ER_WRONG_VALUE_FOR_VAR +SET @@global.slave_run_triggers_for_rbr= -1; +select @@global.slave_run_triggers_for_rbr; + + +SET @@global.slave_run_triggers_for_rbr= @old_slave_run_triggers_for_rbr; diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_basic.test b/mysql-test/suite/sys_vars/t/slow_query_log_basic.test index fef37b5ff4a..b429f9f5cea 100644 --- a/mysql-test/suite/sys_vars/t/slow_query_log_basic.test +++ b/mysql-test/suite/sys_vars/t/slow_query_log_basic.test @@ -90,14 +90,16 @@ SET @@global.slow_query_log = ''; --echo '#-------------------FN_DYNVARS_004_04----------------------------#' ################################################################## -# Test if accessing session slow_query_log gives error # +# Test that accessing session slow_query_log dows not give # ################################################################## ---Error ER_GLOBAL_VARIABLE +SET @@global.slow_query_log = ON; +SET @@session.slow_query_log = ON; +SELECT @@session.slow_query_log; SET @@session.slow_query_log = OFF; ---Error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.slow_query_log; - +SET @@global.slow_query_log = OFF; +SET @@session.slow_query_log = ON; --echo '#----------------------FN_DYNVARS_004_05------------------------#' ############################################################################## @@ -132,18 +134,17 @@ SELECT @@global.slow_query_log; --echo '#---------------------FN_DYNVARS_004_08----------------------#' ############################################################################## # Check if accessing variable with SESSION,LOCAL and without SCOPE points # -# to same session variable # +# to same session variable (doesn't) # ############################################################################## SET @@global.slow_query_log = ON; +SET @@local.slow_query_log = OFF; SELECT @@slow_query_log = @@global.slow_query_log; --echo '#---------------------FN_DYNVARS_004_09----------------------#' ###################################################################### # Check if slow_query_log can be accessed with and without @@ sign # ###################################################################### ---Error ER_GLOBAL_VARIABLE -SET slow_query_log = ON; --Error ER_PARSE_ERROR SET local.slow_query_log = OFF; --Error ER_UNKNOWN_TABLE diff --git a/mysql-test/suite/sys_vars/t/slow_query_log_func.test b/mysql-test/suite/sys_vars/t/slow_query_log_func.test index dd202ec20ff..2f1d7449976 100644 --- a/mysql-test/suite/sys_vars/t/slow_query_log_func.test +++ b/mysql-test/suite/sys_vars/t/slow_query_log_func.test @@ -10,7 +10,7 @@ SET @@session.long_query_time=1; SET @@global.log_output = 'TABLE'; #========================================= ---echo '----When slow_query_log = OFF----' +--echo '----When global.slow_query_log = OFF----' #========================================= SET @@global.slow_query_log = OFF; @@ -21,7 +21,7 @@ SELECT sleep(2); SELECT count(*) FROM mysql.slow_log; #========================================= ---echo '----When slow_query_log = ON-----' +--echo '----When global.slow_query_log = ON-----' #========================================= SET @@global.slow_query_log = ON; @@ -31,6 +31,17 @@ SELECT sleep(2); SELECT count(*) > 0 FROM mysql.slow_log; +#========================================= +--echo '----When local.slow_query_log = OFF-----' +#========================================= + +SET @@local.slow_query_log = OFF; +TRUNCATE mysql.slow_log; +# The sleep is the slow query +SELECT sleep(2); + +SELECT count(*) FROM mysql.slow_log; +SET @@local.slow_query_log = ON; #========================================================================== --echo 'Bug#47905 stored procedures not logged correctly to slow query log' diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 7a70c413e8d..8f4554e69b4 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1777,4 +1777,28 @@ SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3 DROP TABLE t1,t2,t3; +--echo # +--echo # MDEV-6634: Wrong estimates for ref(const) and key IS NULL predicate +--echo # +create table t1(a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, c int, key(b), key(c)); + +insert into t2 select + @a:=A.a + 10*B.a+100*C.a, + IF(@a<900, NULL, @a), + IF(@a<500, NULL, @a) +from t1 A, t1 B, t1 C; + +delete from t1 where a=0; + +--echo # Check that there are different #rows of NULLs for b and c, both !=10: +explain select * from t2 force index (b) where b is null; +explain select * from t2 force index (c) where c is null; + +explain select * from t1 left join t2 on t2.b is null; +explain select * from t1 left join t2 on t2.c is null; + +drop table t1,t2; + SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/t/lock_sync-master.opt b/mysql-test/t/lock_sync-master.opt index 96f0ce3f36c..a6700b8d18e 100644 --- a/mysql-test/t/lock_sync-master.opt +++ b/mysql-test/t/lock_sync-master.opt @@ -1 +1,2 @@ --default-storage-engine=MyISAM +--innodb-defragment=0 diff --git a/mysql-test/t/log_state.test b/mysql-test/t/log_state.test index 3231769a4bf..12c7a7fd92b 100644 --- a/mysql-test/t/log_state.test +++ b/mysql-test/t/log_state.test @@ -52,12 +52,18 @@ select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; connection default; set global slow_query_log= ON; +set local slow_query_log= ON; --echo # Switch to connection con1 connection con1; set session long_query_time = @long_query_time; select sleep(@long_query_time + 1); --replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME 12 THREAD_ID select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; +set local slow_query_log= ON; +select sleep(@long_query_time + 2); +--replace_column 1 TIMESTAMP 2 USER_HOST 3 QUERY_TIME 12 THREAD_ID +select * from mysql.slow_log where sql_text NOT LIKE '%slow_log%'; + --echo # Switch to connection default connection default; show global variables @@ -69,6 +75,7 @@ set global general_log= OFF; set global slow_query_log= ON; set global slow_query_log= OFF; set global slow_query_log= OFF; +set local slow_query_log= ON; set global general_log= ON; truncate table mysql.general_log; @@ -127,6 +134,7 @@ set global general_log_file= default; set global slow_query_log_file= default; show variables like 'general_log'; show variables like 'slow_query_log'; +show global variables like 'slow_query_log'; set global general_log=ON; set global log_output=default; show variables like 'log_output'; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 9d6789541c0..8461ebff412 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -2473,3 +2473,18 @@ drop table t1, t2; --exec $MYSQL_DUMP --user=foo 2>&1 > $MYSQLTEST_VARDIR/tmp/bug6056.out --exec $MYSQL_DUMP --help > $MYSQLTEST_VARDIR/tmp/bug6056.out +--echo # +--echo # Test mysqldump with --disable-query-logs +--echo # + +create table t1 (a int); +insert into t1 values (1); + +--exec $MYSQL_DUMP --hex-blob --character-sets-dir=$MYSQL_SHAREDIR/charsets --tab=$MYSQLTEST_VARDIR/tmp/ test t1 +--exec $MYSQL_DUMP --disable-log-queries --skip-comments test t1 >$MYSQLTEST_VARDIR/tmp/mysqldump-test.out +drop table t1; + +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqldump-test.out +select * from t1; +drop table t1; +--remove_file $MYSQLTEST_VARDIR/tmp/mysqldump-test.out diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 663686ac1c8..3a0f34ae44d 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -234,8 +234,8 @@ set -e if test -f ./client/.libs/mysql then echo "" - echo "The MySQL clients are compiled dynamicly, which is not allowed for" - echo "a MySQL binary tar file. Please configure with" + echo "The MariaDB clients are compiled dynamically, which is not allowed for" + echo "a MariaDB binary tar file. Please configure with" echo "--with-client-ldflags=-all-static and try again" exit 1; fi diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index beff6e5eb5f..938fbbfbeea 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -15,7 +15,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # This script reports various configuration settings that may be needed -# when using the MySQL client library. +# when using the MariaDB client library. which () { @@ -39,7 +39,7 @@ which () # # If we can find the given directory relatively to where mysql_config is # we should use this instead of the incompiled one. -# This is to ensure that this script also works with the binary MySQL +# This is to ensure that this script also works with the binary MariaDB # version fix_path () diff --git a/scripts/mysql_convert_table_format.sh b/scripts/mysql_convert_table_format.sh index 5f3e093d2b9..d8258726347 100644 --- a/scripts/mysql_convert_table_format.sh +++ b/scripts/mysql_convert_table_format.sh @@ -125,7 +125,7 @@ sub usage print <<EOF; -Conversion of a MySQL tables to other storage engines +Conversion of a MariaDB tables to other storage engines Usage: $0 database [table[ table ...]] If no tables has been specifed, all tables in the database will be converted. diff --git a/scripts/mysql_find_rows.sh b/scripts/mysql_find_rows.sh index 48c4915ae00..8a163e0edf1 100644 --- a/scripts/mysql_find_rows.sh +++ b/scripts/mysql_find_rows.sh @@ -131,7 +131,7 @@ $0 Ver $version Prints all SQL queries that matches a regexp or contains a 'use database' or 'set ..' command to stdout. A SQL query may contain -newlines. This is useful to find things in a MySQL update log. +newlines. This is useful to find things in a MariaDB update log. $0 takes the following options: diff --git a/scripts/mysql_fix_extensions.sh b/scripts/mysql_fix_extensions.sh index 2a50bfe22bb..79a9461fbb4 100644 --- a/scripts/mysql_fix_extensions.sh +++ b/scripts/mysql_fix_extensions.sh @@ -18,10 +18,10 @@ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301, USA -# This is a utility for MySQL. It is not needed by any standard part -# of MySQL. +# This is a utility for MariaDB. It is not needed by any standard part +# of MariaDB. -# Usage: mysql_fix_extentions datadir +# Usage: mysql_fix_extensions datadir # does not work with RAID, with InnoDB or BDB tables # makes .frm lowercase and .MYI/MYD/ISM/ISD uppercase # useful when datafiles are copied from windows diff --git a/scripts/mysql_performance_tables.sql b/scripts/mysql_performance_tables.sql index d4955782e4d..306160355de 100644 --- a/scripts/mysql_performance_tables.sql +++ b/scripts/mysql_performance_tables.sql @@ -53,1427 +53,3 @@ SET @str = IF(@broken_pfs = 0, @cmd, 'SET @dummy = 0'); PREPARE stmt FROM @str; EXECUTE stmt; DROP PREPARE stmt; - --- --- From this point, only create the performance schema tables --- if the server is built with performance schema --- - -set @have_pfs= (select count(engine) from information_schema.engines where engine='PERFORMANCE_SCHEMA' and support != 'NO'); - --- --- TABLE COND_INSTANCES --- - -SET @cmd="CREATE TABLE performance_schema.cond_instances(" - "NAME VARCHAR(128) not null," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_WAITS_CURRENT --- - -SET @cmd="CREATE TABLE performance_schema.events_waits_current(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_ID BIGINT unsigned not null," - "END_EVENT_ID BIGINT unsigned," - "EVENT_NAME VARCHAR(128) not null," - "SOURCE VARCHAR(64)," - "TIMER_START BIGINT unsigned," - "TIMER_END BIGINT unsigned," - "TIMER_WAIT BIGINT unsigned," - "SPINS INTEGER unsigned," - "OBJECT_SCHEMA VARCHAR(64)," - "OBJECT_NAME VARCHAR(512)," - "INDEX_NAME VARCHAR(64)," - "OBJECT_TYPE VARCHAR(64)," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," - "NESTING_EVENT_ID BIGINT unsigned," - "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')," - "OPERATION VARCHAR(32) not null," - "NUMBER_OF_BYTES BIGINT," - "FLAGS INTEGER unsigned" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_WAITS_HISTORY --- - -SET @cmd="CREATE TABLE performance_schema.events_waits_history(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_ID BIGINT unsigned not null," - "END_EVENT_ID BIGINT unsigned," - "EVENT_NAME VARCHAR(128) not null," - "SOURCE VARCHAR(64)," - "TIMER_START BIGINT unsigned," - "TIMER_END BIGINT unsigned," - "TIMER_WAIT BIGINT unsigned," - "SPINS INTEGER unsigned," - "OBJECT_SCHEMA VARCHAR(64)," - "OBJECT_NAME VARCHAR(512)," - "INDEX_NAME VARCHAR(64)," - "OBJECT_TYPE VARCHAR(64)," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," - "NESTING_EVENT_ID BIGINT unsigned," - "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')," - "OPERATION VARCHAR(32) not null," - "NUMBER_OF_BYTES BIGINT," - "FLAGS INTEGER unsigned" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_WAITS_HISTORY_LONG --- - -SET @cmd="CREATE TABLE performance_schema.events_waits_history_long(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_ID BIGINT unsigned not null," - "END_EVENT_ID BIGINT unsigned," - "EVENT_NAME VARCHAR(128) not null," - "SOURCE VARCHAR(64)," - "TIMER_START BIGINT unsigned," - "TIMER_END BIGINT unsigned," - "TIMER_WAIT BIGINT unsigned," - "SPINS INTEGER unsigned," - "OBJECT_SCHEMA VARCHAR(64)," - "OBJECT_NAME VARCHAR(512)," - "INDEX_NAME VARCHAR(64)," - "OBJECT_TYPE VARCHAR(64)," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," - "NESTING_EVENT_ID BIGINT unsigned," - "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')," - "OPERATION VARCHAR(32) not null," - "NUMBER_OF_BYTES BIGINT," - "FLAGS INTEGER unsigned" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_WAITS_SUMMARY_BY_INSTANCE --- - -SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_instance(" - "EVENT_NAME VARCHAR(128) not null," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_WAITS_SUMMARY_BY_HOST_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_host_by_event_name(" - "HOST CHAR(60) collate utf8_bin default null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_WAITS_SUMMARY_BY_USER_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_user_by_event_name(" - "USER CHAR(16) collate utf8_bin default null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_WAITS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_account_by_event_name(" - "USER CHAR(16) collate utf8_bin default null," - "HOST CHAR(60) collate utf8_bin default null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_waits_summary_by_thread_by_event_name(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_waits_summary_global_by_event_name(" - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE FILE_INSTANCES --- - -SET @cmd="CREATE TABLE performance_schema.file_instances(" - "FILE_NAME VARCHAR(512) not null," - "EVENT_NAME VARCHAR(128) not null," - "OPEN_COUNT INTEGER unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE FILE_SUMMARY_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.file_summary_by_event_name(" - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "COUNT_READ BIGINT unsigned not null," - "SUM_TIMER_READ BIGINT unsigned not null," - "MIN_TIMER_READ BIGINT unsigned not null," - "AVG_TIMER_READ BIGINT unsigned not null," - "MAX_TIMER_READ BIGINT unsigned not null," - "SUM_NUMBER_OF_BYTES_READ BIGINT not null," - "COUNT_WRITE BIGINT unsigned not null," - "SUM_TIMER_WRITE BIGINT unsigned not null," - "MIN_TIMER_WRITE BIGINT unsigned not null," - "AVG_TIMER_WRITE BIGINT unsigned not null," - "MAX_TIMER_WRITE BIGINT unsigned not null," - "SUM_NUMBER_OF_BYTES_WRITE BIGINT not null," - "COUNT_MISC BIGINT unsigned not null," - "SUM_TIMER_MISC BIGINT unsigned not null," - "MIN_TIMER_MISC BIGINT unsigned not null," - "AVG_TIMER_MISC BIGINT unsigned not null," - "MAX_TIMER_MISC BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE FILE_SUMMARY_BY_INSTANCE --- - -SET @cmd="CREATE TABLE performance_schema.file_summary_by_instance(" - "FILE_NAME VARCHAR(512) not null," - "EVENT_NAME VARCHAR(128) not null," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "COUNT_READ BIGINT unsigned not null," - "SUM_TIMER_READ BIGINT unsigned not null," - "MIN_TIMER_READ BIGINT unsigned not null," - "AVG_TIMER_READ BIGINT unsigned not null," - "MAX_TIMER_READ BIGINT unsigned not null," - "SUM_NUMBER_OF_BYTES_READ BIGINT not null," - "COUNT_WRITE BIGINT unsigned not null," - "SUM_TIMER_WRITE BIGINT unsigned not null," - "MIN_TIMER_WRITE BIGINT unsigned not null," - "AVG_TIMER_WRITE BIGINT unsigned not null," - "MAX_TIMER_WRITE BIGINT unsigned not null," - "SUM_NUMBER_OF_BYTES_WRITE BIGINT not null," - "COUNT_MISC BIGINT unsigned not null," - "SUM_TIMER_MISC BIGINT unsigned not null," - "MIN_TIMER_MISC BIGINT unsigned not null," - "AVG_TIMER_MISC BIGINT unsigned not null," - "MAX_TIMER_MISC BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - - --- --- TABLE SOCKET_INSTANCES --- - -SET @cmd="CREATE TABLE performance_schema.socket_instances(" - "EVENT_NAME VARCHAR(128) not null," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," - "THREAD_ID BIGINT unsigned," - "SOCKET_ID INTEGER not null," - "IP VARCHAR(64) not null," - "PORT INTEGER not null," - "STATE ENUM('IDLE','ACTIVE') not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE SOCKET_SUMMARY_BY_INSTANCE --- - -SET @cmd="CREATE TABLE performance_schema.socket_summary_by_instance(" - "EVENT_NAME VARCHAR(128) not null," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "COUNT_READ BIGINT unsigned not null," - "SUM_TIMER_READ BIGINT unsigned not null," - "MIN_TIMER_READ BIGINT unsigned not null," - "AVG_TIMER_READ BIGINT unsigned not null," - "MAX_TIMER_READ BIGINT unsigned not null," - "SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null," - "COUNT_WRITE BIGINT unsigned not null," - "SUM_TIMER_WRITE BIGINT unsigned not null," - "MIN_TIMER_WRITE BIGINT unsigned not null," - "AVG_TIMER_WRITE BIGINT unsigned not null," - "MAX_TIMER_WRITE BIGINT unsigned not null," - "SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null," - "COUNT_MISC BIGINT unsigned not null," - "SUM_TIMER_MISC BIGINT unsigned not null," - "MIN_TIMER_MISC BIGINT unsigned not null," - "AVG_TIMER_MISC BIGINT unsigned not null," - "MAX_TIMER_MISC BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE SOCKET_SUMMARY_BY_INSTANCE --- - -SET @cmd="CREATE TABLE performance_schema.socket_summary_by_event_name(" - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "COUNT_READ BIGINT unsigned not null," - "SUM_TIMER_READ BIGINT unsigned not null," - "MIN_TIMER_READ BIGINT unsigned not null," - "AVG_TIMER_READ BIGINT unsigned not null," - "MAX_TIMER_READ BIGINT unsigned not null," - "SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null," - "COUNT_WRITE BIGINT unsigned not null," - "SUM_TIMER_WRITE BIGINT unsigned not null," - "MIN_TIMER_WRITE BIGINT unsigned not null," - "AVG_TIMER_WRITE BIGINT unsigned not null," - "MAX_TIMER_WRITE BIGINT unsigned not null," - "SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null," - "COUNT_MISC BIGINT unsigned not null," - "SUM_TIMER_MISC BIGINT unsigned not null," - "MIN_TIMER_MISC BIGINT unsigned not null," - "AVG_TIMER_MISC BIGINT unsigned not null," - "MAX_TIMER_MISC BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE HOST_CACHE --- - -SET @cmd="CREATE TABLE performance_schema.host_cache(" - "IP VARCHAR(64) not null," - "HOST VARCHAR(255) collate utf8_bin," - "HOST_VALIDATED ENUM ('YES', 'NO') not null," - "SUM_CONNECT_ERRORS BIGINT not null," - "COUNT_HOST_BLOCKED_ERRORS BIGINT not null," - "COUNT_NAMEINFO_TRANSIENT_ERRORS BIGINT not null," - "COUNT_NAMEINFO_PERMANENT_ERRORS BIGINT not null," - "COUNT_FORMAT_ERRORS BIGINT not null," - "COUNT_ADDRINFO_TRANSIENT_ERRORS BIGINT not null," - "COUNT_ADDRINFO_PERMANENT_ERRORS BIGINT not null," - "COUNT_FCRDNS_ERRORS BIGINT not null," - "COUNT_HOST_ACL_ERRORS BIGINT not null," - "COUNT_NO_AUTH_PLUGIN_ERRORS BIGINT not null," - "COUNT_AUTH_PLUGIN_ERRORS BIGINT not null," - "COUNT_HANDSHAKE_ERRORS BIGINT not null," - "COUNT_PROXY_USER_ERRORS BIGINT not null," - "COUNT_PROXY_USER_ACL_ERRORS BIGINT not null," - "COUNT_AUTHENTICATION_ERRORS BIGINT not null," - "COUNT_SSL_ERRORS BIGINT not null," - "COUNT_MAX_USER_CONNECTIONS_ERRORS BIGINT not null," - "COUNT_MAX_USER_CONNECTIONS_PER_HOUR_ERRORS BIGINT not null," - "COUNT_DEFAULT_DATABASE_ERRORS BIGINT not null," - "COUNT_INIT_CONNECT_ERRORS BIGINT not null," - "COUNT_LOCAL_ERRORS BIGINT not null," - "COUNT_UNKNOWN_ERRORS BIGINT not null," - "FIRST_SEEN TIMESTAMP(0) NOT NULL default 0," - "LAST_SEEN TIMESTAMP(0) NOT NULL default 0," - "FIRST_ERROR_SEEN TIMESTAMP(0) null default 0," - "LAST_ERROR_SEEN TIMESTAMP(0) null default 0" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE MUTEX_INSTANCES --- - -SET @cmd="CREATE TABLE performance_schema.mutex_instances(" - "NAME VARCHAR(128) not null," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," - "LOCKED_BY_THREAD_ID BIGINT unsigned" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE OBJECTS_SUMMARY_GLOBAL_BY_TYPE --- - -SET @cmd="CREATE TABLE performance_schema.objects_summary_global_by_type(" - "OBJECT_TYPE VARCHAR(64)," - "OBJECT_SCHEMA VARCHAR(64)," - "OBJECT_NAME VARCHAR(64)," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE PERFORMANCE_TIMERS --- - -SET @cmd="CREATE TABLE performance_schema.performance_timers(" - "TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null," - "TIMER_FREQUENCY BIGINT," - "TIMER_RESOLUTION BIGINT," - "TIMER_OVERHEAD BIGINT" - ") ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE RWLOCK_INSTANCES --- - -SET @cmd="CREATE TABLE performance_schema.rwlock_instances(" - "NAME VARCHAR(128) not null," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," - "WRITE_LOCKED_BY_THREAD_ID BIGINT unsigned," - "READ_LOCKED_BY_COUNT INTEGER unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE SETUP_ACTORS --- - -SET @cmd="CREATE TABLE performance_schema.setup_actors(" - "HOST CHAR(60) collate utf8_bin default '%' not null," - "USER CHAR(16) collate utf8_bin default '%' not null," - "ROLE CHAR(16) collate utf8_bin default '%' not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE SETUP_CONSUMERS --- - -SET @cmd="CREATE TABLE performance_schema.setup_consumers(" - "NAME VARCHAR(64) not null," - "ENABLED ENUM ('YES', 'NO') not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE SETUP_INSTRUMENTS --- - -SET @cmd="CREATE TABLE performance_schema.setup_instruments(" - "NAME VARCHAR(128) not null," - "ENABLED ENUM ('YES', 'NO') not null," - "TIMED ENUM ('YES', 'NO') not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE SETUP_OBJECTS --- - -SET @cmd="CREATE TABLE performance_schema.setup_objects(" - "OBJECT_TYPE ENUM ('TABLE') not null default 'TABLE'," - "OBJECT_SCHEMA VARCHAR(64) default '%'," - "OBJECT_NAME VARCHAR(64) not null default '%'," - "ENABLED ENUM ('YES', 'NO') not null default 'YES'," - "TIMED ENUM ('YES', 'NO') not null default 'YES'" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE SETUP_TIMERS --- - -SET @cmd="CREATE TABLE performance_schema.setup_timers(" - "NAME VARCHAR(64) not null," - "TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE --- - -SET @cmd="CREATE TABLE performance_schema.table_io_waits_summary_by_index_usage(" - "OBJECT_TYPE VARCHAR(64)," - "OBJECT_SCHEMA VARCHAR(64)," - "OBJECT_NAME VARCHAR(64)," - "INDEX_NAME VARCHAR(64)," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "COUNT_READ BIGINT unsigned not null," - "SUM_TIMER_READ BIGINT unsigned not null," - "MIN_TIMER_READ BIGINT unsigned not null," - "AVG_TIMER_READ BIGINT unsigned not null," - "MAX_TIMER_READ BIGINT unsigned not null," - "COUNT_WRITE BIGINT unsigned not null," - "SUM_TIMER_WRITE BIGINT unsigned not null," - "MIN_TIMER_WRITE BIGINT unsigned not null," - "AVG_TIMER_WRITE BIGINT unsigned not null," - "MAX_TIMER_WRITE BIGINT unsigned not null," - "COUNT_FETCH BIGINT unsigned not null," - "SUM_TIMER_FETCH BIGINT unsigned not null," - "MIN_TIMER_FETCH BIGINT unsigned not null," - "AVG_TIMER_FETCH BIGINT unsigned not null," - "MAX_TIMER_FETCH BIGINT unsigned not null," - "COUNT_INSERT BIGINT unsigned not null," - "SUM_TIMER_INSERT BIGINT unsigned not null," - "MIN_TIMER_INSERT BIGINT unsigned not null," - "AVG_TIMER_INSERT BIGINT unsigned not null," - "MAX_TIMER_INSERT BIGINT unsigned not null," - "COUNT_UPDATE BIGINT unsigned not null," - "SUM_TIMER_UPDATE BIGINT unsigned not null," - "MIN_TIMER_UPDATE BIGINT unsigned not null," - "AVG_TIMER_UPDATE BIGINT unsigned not null," - "MAX_TIMER_UPDATE BIGINT unsigned not null," - "COUNT_DELETE BIGINT unsigned not null," - "SUM_TIMER_DELETE BIGINT unsigned not null," - "MIN_TIMER_DELETE BIGINT unsigned not null," - "AVG_TIMER_DELETE BIGINT unsigned not null," - "MAX_TIMER_DELETE BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE TABLE_IO_WAITS_SUMMARY_BY_TABLE --- - -SET @cmd="CREATE TABLE performance_schema.table_io_waits_summary_by_table(" - "OBJECT_TYPE VARCHAR(64)," - "OBJECT_SCHEMA VARCHAR(64)," - "OBJECT_NAME VARCHAR(64)," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "COUNT_READ BIGINT unsigned not null," - "SUM_TIMER_READ BIGINT unsigned not null," - "MIN_TIMER_READ BIGINT unsigned not null," - "AVG_TIMER_READ BIGINT unsigned not null," - "MAX_TIMER_READ BIGINT unsigned not null," - "COUNT_WRITE BIGINT unsigned not null," - "SUM_TIMER_WRITE BIGINT unsigned not null," - "MIN_TIMER_WRITE BIGINT unsigned not null," - "AVG_TIMER_WRITE BIGINT unsigned not null," - "MAX_TIMER_WRITE BIGINT unsigned not null," - "COUNT_FETCH BIGINT unsigned not null," - "SUM_TIMER_FETCH BIGINT unsigned not null," - "MIN_TIMER_FETCH BIGINT unsigned not null," - "AVG_TIMER_FETCH BIGINT unsigned not null," - "MAX_TIMER_FETCH BIGINT unsigned not null," - "COUNT_INSERT BIGINT unsigned not null," - "SUM_TIMER_INSERT BIGINT unsigned not null," - "MIN_TIMER_INSERT BIGINT unsigned not null," - "AVG_TIMER_INSERT BIGINT unsigned not null," - "MAX_TIMER_INSERT BIGINT unsigned not null," - "COUNT_UPDATE BIGINT unsigned not null," - "SUM_TIMER_UPDATE BIGINT unsigned not null," - "MIN_TIMER_UPDATE BIGINT unsigned not null," - "AVG_TIMER_UPDATE BIGINT unsigned not null," - "MAX_TIMER_UPDATE BIGINT unsigned not null," - "COUNT_DELETE BIGINT unsigned not null," - "SUM_TIMER_DELETE BIGINT unsigned not null," - "MIN_TIMER_DELETE BIGINT unsigned not null," - "AVG_TIMER_DELETE BIGINT unsigned not null," - "MAX_TIMER_DELETE BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE TABLE_LOCK_WAITS_SUMMARY_BY_TABLE --- - -SET @cmd="CREATE TABLE performance_schema.table_lock_waits_summary_by_table(" - "OBJECT_TYPE VARCHAR(64)," - "OBJECT_SCHEMA VARCHAR(64)," - "OBJECT_NAME VARCHAR(64)," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "COUNT_READ BIGINT unsigned not null," - "SUM_TIMER_READ BIGINT unsigned not null," - "MIN_TIMER_READ BIGINT unsigned not null," - "AVG_TIMER_READ BIGINT unsigned not null," - "MAX_TIMER_READ BIGINT unsigned not null," - "COUNT_WRITE BIGINT unsigned not null," - "SUM_TIMER_WRITE BIGINT unsigned not null," - "MIN_TIMER_WRITE BIGINT unsigned not null," - "AVG_TIMER_WRITE BIGINT unsigned not null," - "MAX_TIMER_WRITE BIGINT unsigned not null," - "COUNT_READ_NORMAL BIGINT unsigned not null," - "SUM_TIMER_READ_NORMAL BIGINT unsigned not null," - "MIN_TIMER_READ_NORMAL BIGINT unsigned not null," - "AVG_TIMER_READ_NORMAL BIGINT unsigned not null," - "MAX_TIMER_READ_NORMAL BIGINT unsigned not null," - "COUNT_READ_WITH_SHARED_LOCKS BIGINT unsigned not null," - "SUM_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null," - "MIN_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null," - "AVG_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null," - "MAX_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null," - "COUNT_READ_HIGH_PRIORITY BIGINT unsigned not null," - "SUM_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null," - "MIN_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null," - "AVG_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null," - "MAX_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null," - "COUNT_READ_NO_INSERT BIGINT unsigned not null," - "SUM_TIMER_READ_NO_INSERT BIGINT unsigned not null," - "MIN_TIMER_READ_NO_INSERT BIGINT unsigned not null," - "AVG_TIMER_READ_NO_INSERT BIGINT unsigned not null," - "MAX_TIMER_READ_NO_INSERT BIGINT unsigned not null," - "COUNT_READ_EXTERNAL BIGINT unsigned not null," - "SUM_TIMER_READ_EXTERNAL BIGINT unsigned not null," - "MIN_TIMER_READ_EXTERNAL BIGINT unsigned not null," - "AVG_TIMER_READ_EXTERNAL BIGINT unsigned not null," - "MAX_TIMER_READ_EXTERNAL BIGINT unsigned not null," - "COUNT_WRITE_ALLOW_WRITE BIGINT unsigned not null," - "SUM_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null," - "MIN_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null," - "AVG_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null," - "MAX_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null," - "COUNT_WRITE_CONCURRENT_INSERT BIGINT unsigned not null," - "SUM_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null," - "MIN_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null," - "AVG_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null," - "MAX_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null," - "COUNT_WRITE_DELAYED BIGINT unsigned not null," - "SUM_TIMER_WRITE_DELAYED BIGINT unsigned not null," - "MIN_TIMER_WRITE_DELAYED BIGINT unsigned not null," - "AVG_TIMER_WRITE_DELAYED BIGINT unsigned not null," - "MAX_TIMER_WRITE_DELAYED BIGINT unsigned not null," - "COUNT_WRITE_LOW_PRIORITY BIGINT unsigned not null," - "SUM_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null," - "MIN_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null," - "AVG_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null," - "MAX_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null," - "COUNT_WRITE_NORMAL BIGINT unsigned not null," - "SUM_TIMER_WRITE_NORMAL BIGINT unsigned not null," - "MIN_TIMER_WRITE_NORMAL BIGINT unsigned not null," - "AVG_TIMER_WRITE_NORMAL BIGINT unsigned not null," - "MAX_TIMER_WRITE_NORMAL BIGINT unsigned not null," - "COUNT_WRITE_EXTERNAL BIGINT unsigned not null," - "SUM_TIMER_WRITE_EXTERNAL BIGINT unsigned not null," - "MIN_TIMER_WRITE_EXTERNAL BIGINT unsigned not null," - "AVG_TIMER_WRITE_EXTERNAL BIGINT unsigned not null," - "MAX_TIMER_WRITE_EXTERNAL BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE THREADS --- - -SET @cmd="CREATE TABLE performance_schema.threads(" - "THREAD_ID BIGINT unsigned not null," - "NAME VARCHAR(128) not null," - "TYPE VARCHAR(10) not null," - "PROCESSLIST_ID BIGINT unsigned," - "PROCESSLIST_USER VARCHAR(16)," - "PROCESSLIST_HOST VARCHAR(60)," - "PROCESSLIST_DB VARCHAR(64)," - "PROCESSLIST_COMMAND VARCHAR(16)," - "PROCESSLIST_TIME BIGINT," - "PROCESSLIST_STATE VARCHAR(64)," - "PROCESSLIST_INFO LONGTEXT," - "PARENT_THREAD_ID BIGINT unsigned," - "ROLE VARCHAR(64)," - "INSTRUMENTED ENUM ('YES', 'NO') not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STAGES_CURRENT --- - -SET @cmd="CREATE TABLE performance_schema.events_stages_current(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_ID BIGINT unsigned not null," - "END_EVENT_ID BIGINT unsigned," - "EVENT_NAME VARCHAR(128) not null," - "SOURCE VARCHAR(64)," - "TIMER_START BIGINT unsigned," - "TIMER_END BIGINT unsigned," - "TIMER_WAIT BIGINT unsigned," - "NESTING_EVENT_ID BIGINT unsigned," - "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STAGES_HISTORY --- - -SET @cmd="CREATE TABLE performance_schema.events_stages_history(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_ID BIGINT unsigned not null," - "END_EVENT_ID BIGINT unsigned," - "EVENT_NAME VARCHAR(128) not null," - "SOURCE VARCHAR(64)," - "TIMER_START BIGINT unsigned," - "TIMER_END BIGINT unsigned," - "TIMER_WAIT BIGINT unsigned," - "NESTING_EVENT_ID BIGINT unsigned," - "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STAGES_HISTORY_LONG --- - -SET @cmd="CREATE TABLE performance_schema.events_stages_history_long(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_ID BIGINT unsigned not null," - "END_EVENT_ID BIGINT unsigned," - "EVENT_NAME VARCHAR(128) not null," - "SOURCE VARCHAR(64)," - "TIMER_START BIGINT unsigned," - "TIMER_END BIGINT unsigned," - "TIMER_WAIT BIGINT unsigned," - "NESTING_EVENT_ID BIGINT unsigned," - "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STAGES_SUMMARY_BY_THREAD_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_thread_by_event_name(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STAGES_SUMMARY_BY_HOST_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_host_by_event_name(" - "HOST CHAR(60) collate utf8_bin default null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STAGES_SUMMARY_BY_USER_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_user_by_event_name(" - "USER CHAR(16) collate utf8_bin default null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STAGES_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_stages_summary_by_account_by_event_name(" - "USER CHAR(16) collate utf8_bin default null," - "HOST CHAR(60) collate utf8_bin default null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STAGES_SUMMARY_GLOBAL_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_stages_summary_global_by_event_name(" - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STATEMENTS_CURRENT --- - -SET @cmd="CREATE TABLE performance_schema.events_statements_current(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_ID BIGINT unsigned not null," - "END_EVENT_ID BIGINT unsigned," - "EVENT_NAME VARCHAR(128) not null," - "SOURCE VARCHAR(64)," - "TIMER_START BIGINT unsigned," - "TIMER_END BIGINT unsigned," - "TIMER_WAIT BIGINT unsigned," - "LOCK_TIME bigint unsigned not null," - "SQL_TEXT LONGTEXT," - "DIGEST VARCHAR(32)," - "DIGEST_TEXT LONGTEXT," - "CURRENT_SCHEMA VARCHAR(64)," - "OBJECT_TYPE VARCHAR(64)," - "OBJECT_SCHEMA VARCHAR(64)," - "OBJECT_NAME VARCHAR(64)," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned," - "MYSQL_ERRNO INTEGER," - "RETURNED_SQLSTATE VARCHAR(5)," - "MESSAGE_TEXT VARCHAR(128)," - "ERRORS BIGINT unsigned not null," - "WARNINGS BIGINT unsigned not null," - "ROWS_AFFECTED BIGINT unsigned not null," - "ROWS_SENT BIGINT unsigned not null," - "ROWS_EXAMINED BIGINT unsigned not null," - "CREATED_TMP_DISK_TABLES BIGINT unsigned not null," - "CREATED_TMP_TABLES BIGINT unsigned not null," - "SELECT_FULL_JOIN BIGINT unsigned not null," - "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," - "SELECT_RANGE BIGINT unsigned not null," - "SELECT_RANGE_CHECK BIGINT unsigned not null," - "SELECT_SCAN BIGINT unsigned not null," - "SORT_MERGE_PASSES BIGINT unsigned not null," - "SORT_RANGE BIGINT unsigned not null," - "SORT_ROWS BIGINT unsigned not null," - "SORT_SCAN BIGINT unsigned not null," - "NO_INDEX_USED BIGINT unsigned not null," - "NO_GOOD_INDEX_USED BIGINT unsigned not null," - "NESTING_EVENT_ID BIGINT unsigned," - "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STATEMENTS_HISTORY --- - -SET @cmd="CREATE TABLE performance_schema.events_statements_history(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_ID BIGINT unsigned not null," - "END_EVENT_ID BIGINT unsigned," - "EVENT_NAME VARCHAR(128) not null," - "SOURCE VARCHAR(64)," - "TIMER_START BIGINT unsigned," - "TIMER_END BIGINT unsigned," - "TIMER_WAIT BIGINT unsigned," - "LOCK_TIME bigint unsigned not null," - "SQL_TEXT LONGTEXT," - "DIGEST VARCHAR(32)," - "DIGEST_TEXT LONGTEXT," - "CURRENT_SCHEMA VARCHAR(64)," - "OBJECT_TYPE VARCHAR(64)," - "OBJECT_SCHEMA VARCHAR(64)," - "OBJECT_NAME VARCHAR(64)," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned," - "MYSQL_ERRNO INTEGER," - "RETURNED_SQLSTATE VARCHAR(5)," - "MESSAGE_TEXT VARCHAR(128)," - "ERRORS BIGINT unsigned not null," - "WARNINGS BIGINT unsigned not null," - "ROWS_AFFECTED BIGINT unsigned not null," - "ROWS_SENT BIGINT unsigned not null," - "ROWS_EXAMINED BIGINT unsigned not null," - "CREATED_TMP_DISK_TABLES BIGINT unsigned not null," - "CREATED_TMP_TABLES BIGINT unsigned not null," - "SELECT_FULL_JOIN BIGINT unsigned not null," - "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," - "SELECT_RANGE BIGINT unsigned not null," - "SELECT_RANGE_CHECK BIGINT unsigned not null," - "SELECT_SCAN BIGINT unsigned not null," - "SORT_MERGE_PASSES BIGINT unsigned not null," - "SORT_RANGE BIGINT unsigned not null," - "SORT_ROWS BIGINT unsigned not null," - "SORT_SCAN BIGINT unsigned not null," - "NO_INDEX_USED BIGINT unsigned not null," - "NO_GOOD_INDEX_USED BIGINT unsigned not null," - "NESTING_EVENT_ID BIGINT unsigned," - "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STATEMENTS_HISTORY_LONG --- - -SET @cmd="CREATE TABLE performance_schema.events_statements_history_long(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_ID BIGINT unsigned not null," - "END_EVENT_ID BIGINT unsigned," - "EVENT_NAME VARCHAR(128) not null," - "SOURCE VARCHAR(64)," - "TIMER_START BIGINT unsigned," - "TIMER_END BIGINT unsigned," - "TIMER_WAIT BIGINT unsigned," - "LOCK_TIME bigint unsigned not null," - "SQL_TEXT LONGTEXT," - "DIGEST VARCHAR(32)," - "DIGEST_TEXT LONGTEXT," - "CURRENT_SCHEMA VARCHAR(64)," - "OBJECT_TYPE VARCHAR(64)," - "OBJECT_SCHEMA VARCHAR(64)," - "OBJECT_NAME VARCHAR(64)," - "OBJECT_INSTANCE_BEGIN BIGINT unsigned," - "MYSQL_ERRNO INTEGER," - "RETURNED_SQLSTATE VARCHAR(5)," - "MESSAGE_TEXT VARCHAR(128)," - "ERRORS BIGINT unsigned not null," - "WARNINGS BIGINT unsigned not null," - "ROWS_AFFECTED BIGINT unsigned not null," - "ROWS_SENT BIGINT unsigned not null," - "ROWS_EXAMINED BIGINT unsigned not null," - "CREATED_TMP_DISK_TABLES BIGINT unsigned not null," - "CREATED_TMP_TABLES BIGINT unsigned not null," - "SELECT_FULL_JOIN BIGINT unsigned not null," - "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," - "SELECT_RANGE BIGINT unsigned not null," - "SELECT_RANGE_CHECK BIGINT unsigned not null," - "SELECT_SCAN BIGINT unsigned not null," - "SORT_MERGE_PASSES BIGINT unsigned not null," - "SORT_RANGE BIGINT unsigned not null," - "SORT_ROWS BIGINT unsigned not null," - "SORT_SCAN BIGINT unsigned not null," - "NO_INDEX_USED BIGINT unsigned not null," - "NO_GOOD_INDEX_USED BIGINT unsigned not null," - "NESTING_EVENT_ID BIGINT unsigned," - "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STATEMENTS_SUMMARY_BY_THREAD_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_thread_by_event_name(" - "THREAD_ID BIGINT unsigned not null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "SUM_LOCK_TIME BIGINT unsigned not null," - "SUM_ERRORS BIGINT unsigned not null," - "SUM_WARNINGS BIGINT unsigned not null," - "SUM_ROWS_AFFECTED BIGINT unsigned not null," - "SUM_ROWS_SENT BIGINT unsigned not null," - "SUM_ROWS_EXAMINED BIGINT unsigned not null," - "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," - "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," - "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," - "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," - "SUM_SELECT_RANGE BIGINT unsigned not null," - "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," - "SUM_SELECT_SCAN BIGINT unsigned not null," - "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," - "SUM_SORT_RANGE BIGINT unsigned not null," - "SUM_SORT_ROWS BIGINT unsigned not null," - "SUM_SORT_SCAN BIGINT unsigned not null," - "SUM_NO_INDEX_USED BIGINT unsigned not null," - "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STATEMENTS_SUMMARY_BY_HOST_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_host_by_event_name(" - "HOST CHAR(60) collate utf8_bin default null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "SUM_LOCK_TIME BIGINT unsigned not null," - "SUM_ERRORS BIGINT unsigned not null," - "SUM_WARNINGS BIGINT unsigned not null," - "SUM_ROWS_AFFECTED BIGINT unsigned not null," - "SUM_ROWS_SENT BIGINT unsigned not null," - "SUM_ROWS_EXAMINED BIGINT unsigned not null," - "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," - "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," - "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," - "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," - "SUM_SELECT_RANGE BIGINT unsigned not null," - "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," - "SUM_SELECT_SCAN BIGINT unsigned not null," - "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," - "SUM_SORT_RANGE BIGINT unsigned not null," - "SUM_SORT_ROWS BIGINT unsigned not null," - "SUM_SORT_SCAN BIGINT unsigned not null," - "SUM_NO_INDEX_USED BIGINT unsigned not null," - "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STATEMENTS_SUMMARY_BY_USER_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_user_by_event_name(" - "USER CHAR(16) collate utf8_bin default null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "SUM_LOCK_TIME BIGINT unsigned not null," - "SUM_ERRORS BIGINT unsigned not null," - "SUM_WARNINGS BIGINT unsigned not null," - "SUM_ROWS_AFFECTED BIGINT unsigned not null," - "SUM_ROWS_SENT BIGINT unsigned not null," - "SUM_ROWS_EXAMINED BIGINT unsigned not null," - "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," - "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," - "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," - "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," - "SUM_SELECT_RANGE BIGINT unsigned not null," - "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," - "SUM_SELECT_SCAN BIGINT unsigned not null," - "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," - "SUM_SORT_RANGE BIGINT unsigned not null," - "SUM_SORT_ROWS BIGINT unsigned not null," - "SUM_SORT_SCAN BIGINT unsigned not null," - "SUM_NO_INDEX_USED BIGINT unsigned not null," - "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STATEMENTS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_account_by_event_name(" - "USER CHAR(16) collate utf8_bin default null," - "HOST CHAR(60) collate utf8_bin default null," - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "SUM_LOCK_TIME BIGINT unsigned not null," - "SUM_ERRORS BIGINT unsigned not null," - "SUM_WARNINGS BIGINT unsigned not null," - "SUM_ROWS_AFFECTED BIGINT unsigned not null," - "SUM_ROWS_SENT BIGINT unsigned not null," - "SUM_ROWS_EXAMINED BIGINT unsigned not null," - "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," - "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," - "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," - "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," - "SUM_SELECT_RANGE BIGINT unsigned not null," - "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," - "SUM_SELECT_SCAN BIGINT unsigned not null," - "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," - "SUM_SORT_RANGE BIGINT unsigned not null," - "SUM_SORT_ROWS BIGINT unsigned not null," - "SUM_SORT_SCAN BIGINT unsigned not null," - "SUM_NO_INDEX_USED BIGINT unsigned not null," - "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STATEMENTS_SUMMARY_GLOBAL_BY_EVENT_NAME --- - -SET @cmd="CREATE TABLE performance_schema.events_statements_summary_global_by_event_name(" - "EVENT_NAME VARCHAR(128) not null," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "SUM_LOCK_TIME BIGINT unsigned not null," - "SUM_ERRORS BIGINT unsigned not null," - "SUM_WARNINGS BIGINT unsigned not null," - "SUM_ROWS_AFFECTED BIGINT unsigned not null," - "SUM_ROWS_SENT BIGINT unsigned not null," - "SUM_ROWS_EXAMINED BIGINT unsigned not null," - "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," - "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," - "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," - "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," - "SUM_SELECT_RANGE BIGINT unsigned not null," - "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," - "SUM_SELECT_SCAN BIGINT unsigned not null," - "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," - "SUM_SORT_RANGE BIGINT unsigned not null," - "SUM_SORT_ROWS BIGINT unsigned not null," - "SUM_SORT_SCAN BIGINT unsigned not null," - "SUM_NO_INDEX_USED BIGINT unsigned not null," - "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE HOSTS --- - -SET @cmd="CREATE TABLE performance_schema.hosts(" - "HOST CHAR(60) collate utf8_bin default null," - "CURRENT_CONNECTIONS bigint not null," - "TOTAL_CONNECTIONS bigint not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE USERS --- - -SET @cmd="CREATE TABLE performance_schema.users(" - "USER CHAR(16) collate utf8_bin default null," - "CURRENT_CONNECTIONS bigint not null," - "TOTAL_CONNECTIONS bigint not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE ACCOUNTS --- - -SET @cmd="CREATE TABLE performance_schema.accounts(" - "USER CHAR(16) collate utf8_bin default null," - "HOST CHAR(60) collate utf8_bin default null," - "CURRENT_CONNECTIONS bigint not null," - "TOTAL_CONNECTIONS bigint not null" - ")ENGINE=PERFORMANCE_SCHEMA;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE EVENTS_STATEMENTS_SUMMARY_BY_DIGEST --- - -SET @cmd="CREATE TABLE performance_schema.events_statements_summary_by_digest(" - "SCHEMA_NAME VARCHAR(64)," - "DIGEST VARCHAR(32)," - "DIGEST_TEXT LONGTEXT," - "COUNT_STAR BIGINT unsigned not null," - "SUM_TIMER_WAIT BIGINT unsigned not null," - "MIN_TIMER_WAIT BIGINT unsigned not null," - "AVG_TIMER_WAIT BIGINT unsigned not null," - "MAX_TIMER_WAIT BIGINT unsigned not null," - "SUM_LOCK_TIME BIGINT unsigned not null," - "SUM_ERRORS BIGINT unsigned not null," - "SUM_WARNINGS BIGINT unsigned not null," - "SUM_ROWS_AFFECTED BIGINT unsigned not null," - "SUM_ROWS_SENT BIGINT unsigned not null," - "SUM_ROWS_EXAMINED BIGINT unsigned not null," - "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," - "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," - "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," - "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," - "SUM_SELECT_RANGE BIGINT unsigned not null," - "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," - "SUM_SELECT_SCAN BIGINT unsigned not null," - "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," - "SUM_SORT_RANGE BIGINT unsigned not null," - "SUM_SORT_ROWS BIGINT unsigned not null," - "SUM_SORT_SCAN BIGINT unsigned not null," - "SUM_NO_INDEX_USED BIGINT unsigned not null," - "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null," - "FIRST_SEEN TIMESTAMP(0) NOT NULL default 0," - "LAST_SEEN TIMESTAMP(0) NOT NULL default 0" - ")ENGINE=PERFORMANCE_SCHEMA;"; - - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE SESSION_CONNECT_ATTRS --- - -SET @cmd="CREATE TABLE performance_schema.session_connect_attrs(" - "PROCESSLIST_ID INT NOT NULL," - "ATTR_NAME VARCHAR(32) NOT NULL," - "ATTR_VALUE VARCHAR(1024)," - "ORDINAL_POSITION INT" - ")ENGINE=PERFORMANCE_SCHEMA CHARACTER SET utf8 COLLATE utf8_bin;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; - --- --- TABLE SESSION_ACCOUNT_CONNECT_ATTRS --- - -SET @cmd="CREATE TABLE performance_schema.session_account_connect_attrs " - " LIKE performance_schema.session_connect_attrs;"; - -SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0'); -PREPARE stmt FROM @str; -EXECUTE stmt; -DROP PREPARE stmt; diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh index f23011a5ae6..50d7b116507 100644 --- a/scripts/mysql_setpermission.sh +++ b/scripts/mysql_setpermission.sh @@ -78,7 +78,7 @@ else if ($opt_password eq '') { system "stty -echo"; - print "Password for user $opt_user to connect to MySQL: "; + print "Password for user $opt_user to connect to MariaDB: "; $opt_password = <STDIN>; chomp($opt_password); system "stty echo"; @@ -86,7 +86,7 @@ if ($opt_password eq '') } -# make the connection to MySQL +# make the connection to MariaDB $dbh= DBI->connect("DBI:mysql:mysql:host=$sqlhost:port=$opt_port:mysql_socket=$opt_socket",$opt_user,$opt_password, {PrintError => 0}) || die("Can't make a connection to the mysql server.\n The error: $DBI::errstr"); @@ -106,7 +106,7 @@ sub q1 { # first question ... while (! $end) { print "#"x70; print "\n"; - print "## Welcome to the permission setter $version for MySQL.\n"; + print "## Welcome to the permission setter $version for MariaDB.\n"; print "## made by Luuk de Boer\n"; print "#"x70; print "\n"; @@ -634,17 +634,17 @@ sub usage { print <<EOL; ---------------------------------------------------------------------- - The permission setter for MySQL. + The permission setter for MariaDB. version: $version made by: Luuk de Boer <luuk\@wxs.nl> ---------------------------------------------------------------------- The permission setter is a little program which can help you add users -or databases or change passwords in MySQL. Keep in mind that we don't -check permissions which already been set in MySQL. So if you can't -connect to MySQL using the permission you just added, take a look at -the permissions which have already been set in MySQL. +or databases or change passwords in MariaDB. Keep in mind that we don't +check permissions which already been set in MariaDB. So if you can't +connect to MariaDB using the permission you just added, take a look at +the permissions which have already been set in MariaDB. The permission setter first reads your .my.cnf file in your Home directory if it exists. @@ -653,7 +653,7 @@ Options for the permission setter: --help : print this help message and exit. -The options shown below are used for making the connection to the MySQL +The options shown below are used for making the connection to the MariaDB server. Keep in mind that the permissions for the user specified via these options must be sufficient to add users / create databases / set passwords. diff --git a/scripts/mysql_zap.sh b/scripts/mysql_zap.sh index a9c3e7a7f5a..98c3603df15 100644 --- a/scripts/mysql_zap.sh +++ b/scripts/mysql_zap.sh @@ -15,8 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# This is a utility for MySQL. It is not needed by any standard part -# of MySQL. +# This is a utility for MariaDB. It is not needed by any standard part +# of MariaDB. # Usage: mysql_zap [-signal] [-f] [-t] pattern diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index 1d01c84735a..f422b6a7dc8 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -34,7 +34,7 @@ BEGIN { $script_log = $ENV{'HOME'}."/$script.log"; # **************************** - # information on MySQL + # information on MariaDB $MYSQL = '@bindir@/mysql'; # path to mysql executable $SERVER = '3.21'; $MYSQL_OPT = ' --batch --unbuffered'; @@ -97,8 +97,8 @@ Usage: $script [host [user [db]]] OPTIONS -U, --superuser=# connect as superuser -P, --spassword=# password for superuser - -H, --rhost=# remote MySQL-server to connect to - --old_server connect to old MySQL-server (before v3.21) which + -H, --rhost=# remote MariaDB-server to connect to + --old_server connect to old MariaDB-server (before v3.21) which does not yet know how to handle full where clauses. -b, --brief single-line tabular report diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 93ab717c8ae..4dd5eae003d 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -103,7 +103,7 @@ sub main print "WARNING: my_print_defaults command not found.\n"; print "Please make sure you have this command available and\n"; print "in your path. The command is available from the latest\n"; - print "MySQL distribution.\n"; + print "MariaDB distribution.\n"; $my_print_defaults_exists= 0; } @@ -154,7 +154,7 @@ sub main if (!defined(my_which(my_print_defaults))) { print "ABORT: Can't find command 'my_print_defaults'.\n"; - print "This command is available from the latest MySQL\n"; + print "This command is available from the latest MariaDB\n"; print "distribution. Please make sure you have the command\n"; print "in your PATH.\n"; exit(1); @@ -269,17 +269,17 @@ sub init_log } #### -#### Report living and not running MySQL servers +#### Report living and not running MariaDB servers #### sub report_mysqlds { my (@groups, $com, $i, @options, $pec); - print "Reporting MySQL servers\n"; + print "Reporting MariaDB servers\n"; if (!$opt_no_log) { - w2log("\nReporting MySQL servers","$opt_log",0,0); + w2log("\nReporting MariaDB servers","$opt_log",0,0); } @groups = &find_groups($groupids); for ($i = 0; defined($groups[$i]); $i++) @@ -290,19 +290,19 @@ sub report_mysqlds $pec = $? >> 8; if ($pec) { - print "MySQL server from group: $groups[$i] is not running\n"; + print "MariaDB server from group: $groups[$i] is not running\n"; if (!$opt_no_log) { - w2log("MySQL server from group: $groups[$i] is not running", + w2log("MariaDB server from group: $groups[$i] is not running", "$opt_log", 0, 0); } } else { - print "MySQL server from group: $groups[$i] is running\n"; + print "MariaDB server from group: $groups[$i] is running\n"; if (!$opt_no_log) { - w2log("MySQL server from group: $groups[$i] is running", + w2log("MariaDB server from group: $groups[$i] is running", "$opt_log", 0, 0); } } @@ -327,11 +327,11 @@ sub start_mysqlds() if (!$opt_no_log) { - w2log("\nStarting MySQL servers\n","$opt_log",0,0); + w2log("\nStarting MariaDB servers\n","$opt_log",0,0); } else { - print "\nStarting MySQL servers\n"; + print "\nStarting MariaDB servers\n"; } @groups = &find_groups($groupids); for ($i = 0; defined($groups[$i]); $i++) @@ -402,7 +402,7 @@ sub start_mysqlds() } if (!$i && !$opt_no_log) { - w2log("No MySQL servers to be started (check your GNRs)", + w2log("No MariaDB servers to be started (check your GNRs)", "$opt_log", 0, 0); } } @@ -417,11 +417,11 @@ sub stop_mysqlds() if (!$opt_no_log) { - w2log("\nStopping MySQL servers\n","$opt_log",0,0); + w2log("\nStopping MariaDB servers\n","$opt_log",0,0); } else { - print "\nStopping MySQL servers\n"; + print "\nStopping MariaDB servers\n"; } @groups = &find_groups($groupids); for ($i = 0; defined($groups[$i]); $i++) @@ -434,7 +434,7 @@ sub stop_mysqlds() } if (!$i && !$opt_no_log) { - w2log("No MySQL servers to be stopped (check your GNRs)", + w2log("No MariaDB servers to be stopped (check your GNRs)", "$opt_log", 0, 0); } } @@ -642,23 +642,23 @@ sub example # # 1.COMMON USER # -# Make sure that the MySQL user, who is stopping the mysqld services, has -# the same password to all MySQL servers being accessed by $my_progname. +# Make sure that the MariaDB user, who is stopping the mysqld services, has +# the same password to all MariaDB servers being accessed by $my_progname. # This user needs to have the 'Shutdown_priv' -privilege, but for security # reasons should have no other privileges. It is advised that you create a -# common 'multi_admin' user for all MySQL servers being controlled by +# common 'multi_admin' user for all MariaDB servers being controlled by # $my_progname. Here is an example how to do it: # # GRANT SHUTDOWN ON *.* TO multi_admin\@localhost IDENTIFIED BY 'password' # -# You will need to apply the above to all MySQL servers that are being +# You will need to apply the above to all MariaDB servers that are being # controlled by $my_progname. 'multi_admin' will shutdown the servers # using 'mysqladmin' -binary, when '$my_progname stop' is being called. # # 2.PID-FILE # # If you are using mysqld_safe to start mysqld, make sure that every -# MySQL server has a separate pid-file. In order to use mysqld_safe +# MariaDB server has a separate pid-file. In order to use mysqld_safe # via $my_progname, you need to use two options: # # mysqld=/path/to/mysqld_safe @@ -671,7 +671,7 @@ sub example # # 3.DATA DIRECTORY # -# It is NOT advised to run many MySQL servers within the same data directory. +# It is NOT advised to run many MariaDB servers within the same data directory. # You can do so, but please make sure to understand and deal with the # underlying caveats. In short they are: # - Speed penalty @@ -692,7 +692,7 @@ sub example # intentionally left out. You may have 'gaps' in the config file. This # gives you more flexibility. # -# 6.MySQL Server User +# 6.MariaDB Server User # # You can pass the user=... option inside [mysqld#] groups. This # can be very handy in some cases, but then you need to run $my_progname @@ -700,7 +700,7 @@ sub example # # 7.A Start-up Manage Script for $my_progname # -# In the recent MySQL distributions you can find a file called +# In the recent MariaDB distributions you can find a file called # mysqld_multi.server.sh. It is a wrapper for $my_progname. This can # be used to start and stop multiple servers during boot and shutdown. # @@ -713,7 +713,7 @@ sub example # or /root/.my.cnf and add the [mysqld_multi] and [mysqld#] groups. # # The script can be found from support-files/mysqld_multi.server.sh -# in MySQL distribution. (Verify the script before using) +# in MariaDB distribution. (Verify the script before using) # [mysqld_multi] @@ -832,7 +832,7 @@ Using: @{[join ' ', @defaults_options]} file is turned on. --password=... Password for mysqladmin user. --silent Disable warnings. ---tcp-ip Connect to the MySQL server(s) via the TCP/IP port instead +--tcp-ip Connect to the MariaDB server(s) via the TCP/IP port instead of the UNIX socket. This affects stopping and reporting. If a socket file is missing, the server may still be running, but can be accessed only via the TCP/IP port. diff --git a/scripts/mytop.sh b/scripts/mytop.sh index 480805e90b1..fe7765988fb 100644 --- a/scripts/mytop.sh +++ b/scripts/mytop.sh @@ -6,7 +6,7 @@ =head1 NAME -mytop - display MySQL server performance info like `top' +mytop - display MariaDB server performance info like `top' =cut @@ -257,7 +257,7 @@ my $dbh = DBI->connect($dsn, $config{user}, $config{pass}, if (not ref $dbh) { my $Error = <<EODIE -Cannot connect to MySQL server. Please check the: +Cannot connect to MariaDB server. Please check the: * database you specified "$config{db}" (default is "test") * username you specified "$config{user}" (default is "root") @@ -1905,12 +1905,11 @@ pick up Term::ReadKey here: http://search.cpan.org/search?dist=TermReadKey -And you obviously need access to a MySQL server (version 3.22.x or -3.23.x) with the necessary security to run the I<SHOW PROCESSLIST> and -I<SHOW STATUS> commands. +And you obviously need access to a MariaDB server with the necessary +security to run the I<SHOW PROCESSLIST> and I<SHOW STATUS> commands. If you are a Windows user, using ActiveState's Perl, you can use PPM -(the Perl Package Manager) to install the MySQL and Term::ReadKey +(the Perl Package Manager) to install the MariaDB/MySQL and Term::ReadKey modules. =head2 Optional Color Support @@ -1962,24 +1961,24 @@ B<mytop> was inspired by the system monitoring tool B<top>. I routinely use B<top> on Linux, FreeBSD, and Solaris. You are likely to notice features from each of them here. -B<mytop> will connect to a MySQL server and periodically run the +B<mytop> will connect to a MariaDB server and periodically run the I<SHOW PROCESSLIST> and I<SHOW STATUS> commands and attempt to summarize the information from them in a useful format. =head2 The Display The B<mytop> display screen is really broken into two parts. The top 4 -lines (header) contain summary information about your MySQL +lines (header) contain summary information about your MariaDB server. For example, you might see something like: -MySQL on localhost (4.0.13-log) up 1+11:13:00 [23:29:11] +MariaDB on localhost (10.0.13-log) up 1+11:13:00 [23:29:11] Queries: 19.3M qps: 160 Slow: 1.0 Se/In/Up/De(%): 00/80/03/17 qps now: 219 Slow qps: 0.0 Threads: 1 ( 1/ 16) 00/74/00/25 Key Efficiency: 99.3% Bps in/out: 30.5k/162.8 Now in/out: 32.7k/ 3.3k The first line identifies the hostname of the server (localhost) and -the version of MySQL it is running. The right had side shows the -uptime of the MySQL server process in days+hours:minutes:seconds +the version of MariaDB it is running. The right had side shows the +uptime of the MariaDB server process in days+hours:minutes:seconds format (much like FreeBSD's top) as well as the current time. The second line displays the total number of queries the server has @@ -1993,7 +1992,7 @@ on the previous line). And the fourth line displays key buffer efficiency (how often keys are read from the buffer rather than disk) and the number of bytes that -MySQL has sent and received, both over all and in the last cycle. +MariaDB has sent and received, both over all and in the last cycle. You can toggle the header by hitting B<h> when running B<mytop>. @@ -2039,21 +2038,21 @@ have two dashes `--'. Short arguments only have one '-'. =item B<-u> or B<-user> username -Username to use when logging in to the MySQL server. Default: ``root''. +Username to use when logging in to the MariaDB server. Default: ``root''. =item B<-p> or B<-pass> or B<-password> password -Password to use when logging in to the MySQL server. Default: none. +Password to use when logging in to the MariaDB server. Default: none. =item B<-h> or B<--host> hostname[:port] -Hostname of the MySQL server. The hostname may be followed by an +Hostname of the MariaDB server. The hostname may be followed by an option port number. Note that the port is specified separate from the host when using a config file. Default: ``localhost''. =item B<--port> or B<-P> port -If you're running MySQL on a non-standard port, use this to specify +If you're running MariaDB on a non-standard port, use this to specify the port number. Default: 3306. =item B<-s> or B<--delay> seconds @@ -2071,15 +2070,15 @@ In batch mode, mytop runs only once, does not clear the screen, and places no limit on the number of lines it will print. This is suitable for running periodically (perhaps from cron) to capture the information into a file for later viewing. You might use batch mode in -a CGI script to occasionally display your MySQL server status on the +a CGI script to occasionally display your MariaDB server status on the web. Default: unset. =item B<-S> or B<--socket> /path/to/socket -If you're running B<mytop> on the same host as MySQL, you may wish to -have it use the MySQL socket directly rather than a standard TCP/IP +If you're running B<mytop> on the same host as MariaDB, you may wish to +have it use the MariaDB socket directly rather than a standard TCP/IP connection. If you do,just specify one. Note that specifying a socket will make B<mytop> ignore any host @@ -2125,7 +2124,7 @@ Default: noprompt. =item B<--resolve> -If you have skip-resolve set on MySQL (to keep it from doing a reverse +If you have skip-resolve set on MariaDB (to keep it from doing a reverse DNS lookup on each inbound connection), mytop can replace IP addresses with hostnames but toggling this option. diff --git a/sql/events.cc b/sql/events.cc index 725a7613e69..999df79a4c0 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -270,6 +270,7 @@ common_1_lev_code: static int create_query_string(THD *thd, String *buf) { + buf->length(0); /* Append the "CREATE" part of the query */ if (buf->append(STRING_WITH_LEN("CREATE "))) return 1; @@ -380,7 +381,8 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, { /* Binlog the create event. */ DBUG_ASSERT(thd->query() && thd->query_length()); - String log_query; + char buffer[1024]; + String log_query(buffer, sizeof(buffer), &my_charset_bin); if (create_query_string(thd, &log_query)) { sql_print_error("Event Error: An error occurred while creating query " diff --git a/sql/handler.cc b/sql/handler.cc index 63ddb9c6d6e..253883cc114 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1453,11 +1453,9 @@ int ha_commit_trans(THD *thd, bool all) goto err; } #endif /* WITH_WSREP */ - my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); - } - if (err) + my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); goto err; - + } need_prepare_ordered|= (ht->prepare_ordered != NULL); need_commit_ordered|= (ht->commit_ordered != NULL); } diff --git a/sql/log.cc b/sql/log.cc index 371f9c06cce..4f80b38e497 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -518,7 +518,7 @@ bool LOGGER::is_log_table_enabled(uint log_table_type) { switch (log_table_type) { case QUERY_LOG_SLOW: - return (table_log_handler != NULL) && opt_slow_log; + return (table_log_handler != NULL) && global_system_variables.sql_log_slow; case QUERY_LOG_GENERAL: return (table_log_handler != NULL) && opt_log ; default: @@ -1048,7 +1048,7 @@ bool Log_to_file_event_handler::init() { if (!is_initialized) { - if (opt_slow_log) + if (global_system_variables.sql_log_slow) mysql_slow_log.open_slow_log(opt_slow_logname); if (opt_log) @@ -1072,7 +1072,7 @@ void Log_to_file_event_handler::flush() /* reopen log files */ if (opt_log) mysql_log.reopen_file(); - if (opt_slow_log) + if (global_system_variables.sql_log_slow) mysql_slow_log.reopen_file(); } @@ -1200,7 +1200,7 @@ bool LOGGER::flush_slow_log() logger.lock_exclusive(); /* Reopen slow log file */ - if (opt_slow_log) + if (global_system_variables.sql_log_slow) file_log_handler->get_mysql_slow_log()->reopen_file(); /* End of log flush */ @@ -1270,11 +1270,11 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length, if (*slow_log_handler_list) { /* do not log slow queries from replication threads */ - if (thd->slave_thread && !opt_log_slow_slave_statements) + if (!thd->variables.sql_log_slow) return 0; lock_shared(); - if (!opt_slow_log) + if (!global_system_variables.sql_log_slow) { unlock(); return 0; @@ -1448,7 +1448,7 @@ bool LOGGER::activate_log_handler(THD* thd, uint log_type) lock_exclusive(); switch (log_type) { case QUERY_LOG_SLOW: - if (!opt_slow_log) + if (!global_system_variables.sql_log_slow) { file_log= file_log_handler->get_mysql_slow_log(); @@ -1462,7 +1462,7 @@ bool LOGGER::activate_log_handler(THD* thd, uint log_type) else { init_slow_log(log_output_options); - opt_slow_log= TRUE; + global_system_variables.sql_log_slow= TRUE; } } break; @@ -1501,7 +1501,7 @@ void LOGGER::deactivate_log_handler(THD *thd, uint log_type) switch (log_type) { case QUERY_LOG_SLOW: - tmp_opt= &opt_slow_log; + tmp_opt= &global_system_variables.sql_log_slow; file_log= file_log_handler->get_mysql_slow_log(); break; case QUERY_LOG_GENERAL: diff --git a/sql/log_event.cc b/sql/log_event.cc index 8e5f7a1f23e..c19faf21647 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -4289,6 +4289,7 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, THD_STAGE_INFO(thd, stage_init); MYSQL_SET_STATEMENT_TEXT(thd->m_statement_psi, thd->query(), thd->query_length()); + thd->enable_slow_log= thd->variables.sql_log_slow; mysql_parse(thd, thd->query(), thd->query_length(), &parser_state); /* Finalize server status flags after executing a statement. */ thd->update_server_status(); @@ -4296,18 +4297,6 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, } thd->variables.option_bits&= ~OPTION_MASTER_SQL_ERROR; - - /* - Resetting the enable_slow_log thd variable. - - We need to reset it back to the opt_log_slow_slave_statements - value after the statement execution (and slow logging - is done). It might have changed if the statement was an - admin statement (in which case, down in mysql_parse execution - thd->enable_slow_log is set to the value of - opt_log_slow_admin_statements). - */ - thd->enable_slow_log= opt_log_slow_slave_statements; } else { diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 97e9cff3b79..b077563918f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -380,7 +380,7 @@ static DYNAMIC_ARRAY all_options; /* Global variables */ bool opt_bin_log, opt_bin_log_used=0, opt_ignore_builtin_innodb= 0; -my_bool opt_log, opt_slow_log, debug_assert_if_crashed_table= 0, opt_help= 0; +my_bool opt_log, debug_assert_if_crashed_table= 0, opt_help= 0; static my_bool opt_abort; ulonglong log_output_options; my_bool opt_userstat_running; @@ -3495,7 +3495,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) sql_print_information("Got signal %d to shutdown mysqld",sig); #endif /* switch to the old log message processing */ - logger.set_handlers(LOG_FILE, opt_slow_log ? LOG_FILE:LOG_NONE, + logger.set_handlers(LOG_FILE, global_system_variables.sql_log_slow ? LOG_FILE:LOG_NONE, opt_log ? LOG_FILE:LOG_NONE); DBUG_PRINT("info",("Got signal: %d abort_loop: %d",sig,abort_loop)); if (!abort_loop) @@ -3533,13 +3533,15 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) if (log_output_options & LOG_NONE) { logger.set_handlers(LOG_FILE, - opt_slow_log ? LOG_TABLE : LOG_NONE, + global_system_variables.sql_log_slow ? + LOG_TABLE : LOG_NONE, opt_log ? LOG_TABLE : LOG_NONE); } else { logger.set_handlers(LOG_FILE, - opt_slow_log ? log_output_options : LOG_NONE, + global_system_variables.sql_log_slow ? + log_output_options : LOG_NONE, opt_log ? log_output_options : LOG_NONE); } break; @@ -4446,7 +4448,8 @@ static int init_common_variables() "--log option, log tables are used. " "To enable logging to files use the --log-output option."); - if (opt_slow_log && opt_slow_logname && *opt_slow_logname && + if (global_system_variables.sql_log_slow && opt_slow_logname && + *opt_slow_logname && !(log_output_options & (LOG_FILE | LOG_NONE))) sql_print_warning("Although a path was specified for the " "--log-slow-queries option, log tables are used. " @@ -5166,7 +5169,9 @@ a file name for --log-bin-index option", opt_binlog_index_name); /* purecov: end */ } - logger.set_handlers(LOG_FILE, opt_slow_log ? log_output_options:LOG_NONE, + logger.set_handlers(LOG_FILE, + global_system_variables.sql_log_slow ? + log_output_options:LOG_NONE, opt_log ? log_output_options:LOG_NONE); } @@ -5752,14 +5757,6 @@ int mysqld_main(int argc, char **argv) #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE initialize_performance_schema_acl(opt_bootstrap); - /* - Do not check the structure of the performance schema tables - during bootstrap: - - the tables are not supposed to exist yet, bootstrap will create them - - a check would print spurious error messages - */ - if (! opt_bootstrap) - check_performance_schema(); #endif initialize_information_schema_acl(); @@ -8478,7 +8475,7 @@ static int mysql_init_variables(void) /* We can only test for sub paths if my_symlink.c is using realpath */ myisam_test_invalid_symlink= test_if_data_home_dir; #endif - opt_log= opt_slow_log= 0; + opt_log= 0; opt_bin_log= opt_bin_log_used= 0; opt_disable_networking= opt_skip_show_db=0; opt_skip_name_resolve= 0; @@ -9185,7 +9182,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr) if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes || opt_log_slow_slave_statements) && - !opt_slow_log) + !global_system_variables.sql_log_slow) sql_print_warning("options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set"); if (global_system_variables.net_buffer_length > global_system_variables.max_allowed_packet) @@ -9403,7 +9400,7 @@ void set_server_version(void) if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug")) end= strmov(end, "-debug"); #endif - if (opt_log || opt_slow_log || opt_bin_log) + if (opt_log || global_system_variables.sql_log_slow || opt_bin_log) strmov(end, "-log"); // This may slow down system } diff --git a/sql/mysqld.h b/sql/mysqld.h index 8a6794cc30c..39b77b441bb 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -81,7 +81,7 @@ extern CHARSET_INFO *character_set_filesystem; extern MY_BITMAP temp_pool; extern bool opt_large_files, server_id_supplied; extern bool opt_update_log, opt_bin_log, opt_error_log; -extern my_bool opt_log, opt_slow_log, opt_bootstrap; +extern my_bool opt_log, opt_bootstrap; extern my_bool opt_backup_history_log; extern my_bool opt_backup_progress_log; extern ulonglong log_output_options; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index fc2aa75e604..2616e044025 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8132,8 +8132,15 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field, param->thd->mem_root= param->old_root; if (!value) // IS NULL or IS NOT NULL { - if (field->table->maybe_null) // Can't use a key on this - goto end; + /* + No check for field->table->maybe_null. It's perfecly fine to use range + access for cases like + + SELECT * FROM t1 LEFT JOIN t2 ON t2.key IS [NOT] NULL + + ON expression is evaluated before considering NULL-complemented rows, so + IS [NOT] NULL has regular semantics. + */ if (!maybe_null) // Not null field { if (type == Item_func::ISNULL_FUNC) diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index e72d3470a7f..90ee2360eb7 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -235,7 +235,7 @@ handle_rpl_parallel_thread(void *arg) thd->security_ctx->skip_grants(); thd->variables.max_allowed_packet= slave_max_allowed_packet; thd->slave_thread= 1; - thd->enable_slow_log= opt_log_slow_slave_statements; + thd->variables.sql_log_slow= opt_log_slow_slave_statements; thd->variables.log_slow_filter= global_system_variables.log_slow_filter; set_slave_thread_options(thd); thd->client_capabilities = CLIENT_LOCAL_FILES; diff --git a/sql/slave.cc b/sql/slave.cc index 746b1d48458..44107c02724 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2923,7 +2923,7 @@ static int init_slave_thread(THD* thd, Master_info *mi, thd->security_ctx->skip_grants(); thd->slave_thread= 1; thd->connection_name= mi->connection_name; - thd->enable_slow_log= opt_log_slow_slave_statements; + thd->variables.sql_log_slow= opt_log_slow_slave_statements; thd->variables.log_slow_filter= global_system_variables.log_slow_filter; set_slave_thread_options(thd); thd->client_capabilities = CLIENT_LOCAL_FILES; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 443da8557ad..8bceffca0bd 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1386,8 +1386,8 @@ void THD::init(void) mysql_mutex_lock(&LOCK_global_system_variables); plugin_thdvar_init(this); /* - variables= global_system_variables above has reset - variables.pseudo_thread_id to 0. We need to correct it here to + plugin_thd_var_init() sets variables= global_system_variables, which + has reset variables.pseudo_thread_id to 0. We need to correct it here to avoid temporary tables replication failure. */ variables.pseudo_thread_id= thread_id; @@ -1435,6 +1435,14 @@ void THD::init(void) wsrep_TOI_pre_query = NULL; wsrep_TOI_pre_query_len = 0; + + /* + @@wsrep_causal_reads is now being handled via wsrep_sync_wait, update it + appropriately. + */ + if (variables.wsrep_causal_reads) + variables.wsrep_sync_wait|= WSREP_SYNC_WAIT_BEFORE_READ; + #endif if (variables.sql_log_bin) variables.option_bits|= OPTION_BIN_LOG; diff --git a/sql/sql_class.h b/sql/sql_class.h index d3b305d34f4..3424a3380f0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -568,9 +568,6 @@ typedef struct system_variables ulong log_slow_rate_limit; ulong binlog_format; ///< binlog format for this thd (see enum_binlog_format) ulong progress_report_time; - my_bool binlog_annotate_row_events; - my_bool binlog_direct_non_trans_update; - my_bool sql_log_bin; ulong completion_type; ulong query_cache_type; ulong tx_isolation; @@ -609,6 +606,10 @@ typedef struct system_variables my_bool old_passwords; my_bool big_tables; my_bool query_cache_strip_comments; + my_bool sql_log_slow; + my_bool sql_log_bin; + my_bool binlog_annotate_row_events; + my_bool binlog_direct_non_trans_update; plugin_ref table_plugin; plugin_ref tmp_table_plugin; diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 9df4fd965a5..53ac095d1d0 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -1006,8 +1006,10 @@ int Explain_insert::print_explain(Explain_query *query, void delete_explain_query(LEX *lex) { + DBUG_ENTER("delete_explain_query"); delete lex->explain; lex->explain= NULL; + DBUG_VOID_RETURN; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 066acfb015a..741ba08386d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1285,7 +1285,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, Commands which always take a long time are logged into the slow log only if opt_log_slow_admin_statements is set. */ - thd->enable_slow_log= TRUE; + thd->enable_slow_log= thd->variables.sql_log_slow; thd->query_plan_flags= QPLAN_INIT; thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */ @@ -1685,7 +1685,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, status_var_increment(thd->status_var.com_other); - thd->enable_slow_log= opt_log_slow_admin_statements; + thd->enable_slow_log&= opt_log_slow_admin_statements; thd->query_plan_flags|= QPLAN_ADMIN; if (check_global_access(thd, REPL_SLAVE_ACL)) break; @@ -1977,7 +1977,6 @@ void log_slow_statement(THD *thd) { DBUG_ENTER("log_slow_statement"); - /* The following should never be true with our current code base, but better to keep this here so we don't accidently try to log a @@ -1988,12 +1987,10 @@ void log_slow_statement(THD *thd) /* Follow the slow log filter configuration. */ - if (!thd->enable_slow_log || + if (!thd->enable_slow_log || !global_system_variables.sql_log_slow || (thd->variables.log_slow_filter && !(thd->variables.log_slow_filter & thd->query_plan_flags))) - { goto end; - } if (((thd->server_status & SERVER_QUERY_WAS_SLOW) || ((thd->server_status & @@ -3327,7 +3324,7 @@ end_with_restore_list: and thus classify as slow administrative statements just like ALTER TABLE. */ - thd->enable_slow_log= opt_log_slow_admin_statements; + thd->enable_slow_log&= opt_log_slow_admin_statements; thd->query_plan_flags|= QPLAN_ADMIN; bzero((char*) &create_info, sizeof(create_info)); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index d9365e14494..e0d1cec6a0a 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -161,6 +161,20 @@ public: uint param_count; uint last_errno; uint flags; + /* + The value of thd->select_number at the end of the PREPARE phase. + + The issue is: each statement execution opens VIEWs, which may cause + select_lex objects to be created, and select_number values to be assigned. + + On the other hand, PREPARE assigns select_number values for triggers and + subqueries. + + In order for select_number values from EXECUTE not to conflict with + select_number values from PREPARE, we keep the number and set it at each + execution. + */ + uint select_number_after_prepare; char last_error[MYSQL_ERRMSG_SIZE]; #ifndef EMBEDDED_LIBRARY bool (*set_params)(Prepared_statement *st, uchar *data, uchar *data_end, @@ -3206,7 +3220,7 @@ void Prepared_statement::setup_set_params() because we want to look it up in the query cache) or not. */ if ((mysql_bin_log.is_open() && is_update_query(lex->sql_command)) || - opt_log || opt_slow_log || + opt_log || thd->variables.sql_log_slow || query_cache_is_cacheable_query(lex)) { set_params_from_vars= insert_params_from_vars_with_log; @@ -3456,6 +3470,8 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) trans_rollback_implicit(thd); thd->mdl_context.release_transactional_locks(); } + + select_number_after_prepare= thd->select_number; lex_end(lex); cleanup_stmt(); @@ -3582,7 +3598,8 @@ Prepared_statement::execute_loop(String *expanded_query, Reprepare_observer reprepare_observer; bool error; int reprepare_attempt= 0; - + + thd->select_number= select_number_after_prepare; /* Check if we got an error when sending long data */ if (state == Query_arena::STMT_ERROR) { diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index f1f9ba9452f..797c9779994 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -130,7 +130,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, result= 1; } - if ((options & REFRESH_SLOW_LOG) && opt_slow_log) + if ((options & REFRESH_SLOW_LOG) && global_system_variables.sql_log_slow) logger.flush_slow_log(); if ((options & REFRESH_GENERAL_LOG) && opt_log) diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index c76ee5e6358..0c68409dd25 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3863,7 +3863,7 @@ static void reopen_slow_log(char* name) static bool fix_slow_log_file(sys_var *self, THD *thd, enum_var_type type) { return fix_log(&opt_slow_logname, opt_log_basename, "-slow.log", - opt_slow_log, reopen_slow_log); + global_system_variables.sql_log_slow, reopen_slow_log); } static Sys_var_charptr Sys_slow_log_path( "slow_query_log_file", "Log slow queries to given log file. " @@ -3914,6 +3914,7 @@ static Sys_var_have Sys_have_symlink( READ_ONLY GLOBAL_VAR(have_symlink), NO_CMD_LINE); static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type); + static Sys_var_mybool Sys_general_log( "general_log", "Log connections and queries to a table or log file. " "Defaults logging to a file 'hostname'.log or a table mysql.general_log" @@ -3927,9 +3928,9 @@ static Sys_var_mybool Sys_slow_query_log( "Log slow queries to a table or log file. Defaults logging to a file " "'hostname'-slow.log or a table mysql.slow_log if --log-output=TABLE is " "used. Must be enabled to activate other slow log options", - GLOBAL_VAR(opt_slow_log), CMD_LINE(OPT_ARG), - DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), - ON_UPDATE(fix_log_state)); + SESSION_VAR(sql_log_slow), CMD_LINE(OPT_ARG), + DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG, + ON_CHECK(0), ON_UPDATE(fix_log_state)); static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type) { @@ -3937,6 +3938,9 @@ static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type) my_bool *UNINIT_VAR(newvalptr), newval, UNINIT_VAR(oldval); uint UNINIT_VAR(log_type); + if (type != OPT_GLOBAL) + return 0; + if (self == &Sys_general_log) { newvalptr= &opt_log; @@ -3945,7 +3949,7 @@ static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type) } else if (self == &Sys_slow_query_log) { - newvalptr= &opt_slow_log; + newvalptr= &global_system_variables.sql_log_slow; oldval= logger.get_slow_log_file_handler()->is_open(); log_type= QUERY_LOG_SLOW; } diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 12d43bba5bc..79fe57dffc5 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -306,6 +306,7 @@ SET(INNOBASE_SOURCES btr/btr0cur.cc btr/btr0pcur.cc btr/btr0sea.cc + btr/btr0defragment.cc buf/buf0buddy.cc buf/buf0buf.cc buf/buf0dblwr.cc @@ -416,7 +417,8 @@ SET(INNOBASE_SOURCES ut/ut0rnd.cc ut/ut0ut.cc ut/ut0vec.cc - ut/ut0wqueue.cc) + ut/ut0wqueue.cc + ut/ut0timer.cc) IF(WITH_WSREP) SET(INNOBASE_SOURCES ${INNOBASE_SOURCES} wsrep/md5.cc) diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 104c2f00ef6..4f9ccbe061a 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -38,6 +38,7 @@ Created 6/2/1994 Heikki Tuuri #include "btr0cur.h" #include "btr0sea.h" #include "btr0pcur.h" +#include "btr0defragment.h" #include "rem0cmp.h" #include "lock0lock.h" #include "ibuf0ibuf.h" @@ -1193,6 +1194,32 @@ btr_get_size( mtr_t* mtr) /*!< in/out: mini-transaction where index is s-latched */ { + ulint used; + if (flag == BTR_N_LEAF_PAGES) { + btr_get_size_and_reserved(index, flag, &used, mtr); + return used; + } else if (flag == BTR_TOTAL_SIZE) { + return btr_get_size_and_reserved(index, flag, &used, mtr); + } else { + ut_error; + } + return (ULINT_UNDEFINED); +} + +/**************************************************************//** +Gets the number of reserved and used pages in a B-tree. +@return number of pages reserved, or ULINT_UNDEFINED if the index +is unavailable */ +UNIV_INTERN +ulint +btr_get_size_and_reserved( +/*======================*/ + dict_index_t* index, /*!< in: index */ + ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */ + ulint* used, /*!< out: number of pages used (<= reserved) */ + mtr_t* mtr) /*!< in/out: mini-transaction where index + is s-latched */ +{ fseg_header_t* seg_header; page_t* root; ulint n; @@ -1201,6 +1228,8 @@ btr_get_size( ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), MTR_MEMO_S_LOCK)); + ut_a(flag == BTR_N_LEAF_PAGES || flag == BTR_TOTAL_SIZE); + if (index->page == FIL_NULL || dict_index_is_online_ddl(index) || *index->name == TEMP_INDEX_PREFIX) { return(ULINT_UNDEFINED); @@ -1208,21 +1237,16 @@ btr_get_size( root = btr_root_get(index, mtr); - if (flag == BTR_N_LEAF_PAGES) { - seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; + seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; - fseg_n_reserved_pages(seg_header, &n, mtr); + n = fseg_n_reserved_pages(seg_header, used, mtr); - } else if (flag == BTR_TOTAL_SIZE) { + if (flag == BTR_TOTAL_SIZE) { seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_TOP; - n = fseg_n_reserved_pages(seg_header, &dummy, mtr); - - seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; - n += fseg_n_reserved_pages(seg_header, &dummy, mtr); - } else { - ut_error; + *used += dummy; + } return(n); @@ -1971,7 +1995,7 @@ IBUF_BITMAP_FREE is unaffected by reorganization. @retval true if the operation was successful @retval false if it is a compressed page, and recompression failed */ -static __attribute__((nonnull)) +UNIV_INTERN bool btr_page_reorganize_block( /*======================*/ @@ -2923,6 +2947,12 @@ func_start: new_page_zip = buf_block_get_page_zip(new_block); btr_page_create(new_block, new_page_zip, cursor->index, btr_page_get_level(page, mtr), mtr); + /* Only record the leaf level page splits. */ + if (btr_page_get_level(page, mtr) == 0) { + cursor->index->stat_defrag_n_page_split ++; + cursor->index->stat_defrag_modified_counter ++; + btr_defragment_save_defrag_stats_if_needed(cursor->index); + } /* 3. Calculate the first record on the upper half-page, and the first record (move_limit) on original page which ends up on the @@ -3181,31 +3211,9 @@ func_exit: return(rec); } -#ifdef UNIV_SYNC_DEBUG -/*************************************************************//** -Removes a page from the level list of pages. -@param space in: space where removed -@param zip_size in: compressed page size in bytes, or 0 for uncompressed -@param page in/out: page to remove -@param index in: index tree -@param mtr in/out: mini-transaction */ -# define btr_level_list_remove(space,zip_size,page,index,mtr) \ - btr_level_list_remove_func(space,zip_size,page,index,mtr) -#else /* UNIV_SYNC_DEBUG */ -/*************************************************************//** -Removes a page from the level list of pages. -@param space in: space where removed -@param zip_size in: compressed page size in bytes, or 0 for uncompressed -@param page in/out: page to remove -@param index in: index tree -@param mtr in/out: mini-transaction */ -# define btr_level_list_remove(space,zip_size,page,index,mtr) \ - btr_level_list_remove_func(space,zip_size,page,mtr) -#endif /* UNIV_SYNC_DEBUG */ - /*************************************************************//** Removes a page from the level list of pages. */ -static __attribute__((nonnull)) +UNIV_INTERN void btr_level_list_remove_func( /*=======================*/ @@ -3377,7 +3385,7 @@ btr_node_ptr_delete( If page is the only on its level, this function moves its records to the father page, thus reducing the tree height. @return father block */ -static +UNIV_INTERN buf_block_t* btr_lift_page_up( /*=============*/ diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc new file mode 100644 index 00000000000..dfb2cd8dffd --- /dev/null +++ b/storage/innobase/btr/btr0defragment.cc @@ -0,0 +1,818 @@ +/***************************************************************************** + +Copyright (C) 2013, 2014 Facebook, Inc. All Rights Reserved. +Copyright (C) 2014, SkySQL Ab. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + +*****************************************************************************/ +/**************************************************//** +@file btr/btr0defragment.cc +Index defragmentation. + +Created 05/29/2014 Rongrong Zhong +Modified 16/07/2014 Sunguck Lee +Modified 30/07/2014 Jan Lindström jan.lindstrom@skysql.com +*******************************************************/ + +#include "btr0defragment.h" +#ifndef UNIV_HOTBACKUP +#include "btr0cur.h" +#include "btr0sea.h" +#include "btr0pcur.h" +#include "dict0stats.h" +#include "dict0stats_bg.h" +#include "ibuf0ibuf.h" +#include "lock0lock.h" +#include "srv0start.h" +#include "ut0timer.h" + +#include <list> + +/**************************************************//** +Custom nullptr implementation for under g++ 4.6 +*******************************************************/ +// #pragma once +/* +namespace std +{ + // based on SC22/WG21/N2431 = J16/07-0301 + struct nullptr_t + { + template<typename any> operator any * () const + { + return 0; + } + template<class any, typename T> operator T any:: * () const + { + return 0; + } + +#ifdef _MSC_VER + struct pad {}; + pad __[sizeof(void*)/sizeof(pad)]; +#else + char __[sizeof(void*)]; +#endif +private: + // nullptr_t();// {} + // nullptr_t(const nullptr_t&); + // void operator = (const nullptr_t&); + void operator &() const; + template<typename any> void operator +(any) const + { + // I Love MSVC 2005! + } + template<typename any> void operator -(any) const + { + // I Love MSVC 2005! + } + }; +static const nullptr_t __nullptr = {}; +} + +#ifndef nullptr +#define nullptr std::__nullptr +#endif +*/ + +/**************************************************//** +End of Custom nullptr implementation for under g++ 4.6 +*******************************************************/ + +/* When there's no work, either because defragment is disabled, or because no +query is submitted, thread checks state every BTR_DEFRAGMENT_SLEEP_IN_USECS.*/ +#define BTR_DEFRAGMENT_SLEEP_IN_USECS 1000000 +/* Reduce the target page size by this amount when compression failure happens +during defragmentaiton. 512 is chosen because it's a power of 2 and it is about +3% of the page size. When there are compression failures in defragmentation, +our goal is to get a decent defrag ratio with as few compression failure as +possible. From experimentation it seems that reduce the target size by 512 every +time will make sure the page is compressible within a couple of iterations. */ +#define BTR_DEFRAGMENT_PAGE_REDUCTION_STEP_SIZE 512 + +/* Work queue for defragmentation. */ +typedef std::list<btr_defragment_item_t*> btr_defragment_wq_t; +static btr_defragment_wq_t btr_defragment_wq; + +/* Mutex protecting the defragmentation work queue.*/ +ib_mutex_t btr_defragment_mutex; +#ifdef UNIV_PFS_MUTEX +UNIV_INTERN mysql_pfs_key_t btr_defragment_mutex_key; +#endif /* UNIV_PFS_MUTEX */ + +/* Number of compression failures caused by defragmentation since server +start. */ +ulint btr_defragment_compression_failures = 0; +/* Number of btr_defragment_n_pages calls that altered page but didn't +manage to release any page. */ +ulint btr_defragment_failures = 0; +/* Total number of btr_defragment_n_pages calls that altered page. +The difference between btr_defragment_count and btr_defragment_failures shows +the amount of effort wasted. */ +ulint btr_defragment_count = 0; + +/******************************************************************//** +Constructor for btr_defragment_item_t. */ +btr_defragment_item_t::btr_defragment_item_t( + btr_pcur_t* pcur, + os_event_t event) +{ + this->pcur = pcur; + this->event = event; + this->removed = false; + this->last_processed = 0; +} + +/******************************************************************//** +Destructor for btr_defragment_item_t. */ +btr_defragment_item_t::~btr_defragment_item_t() { + if (this->pcur) { + btr_pcur_free_for_mysql(this->pcur); + } + if (this->event) { + os_event_set(this->event); + } +} + +/******************************************************************//** +Initialize defragmentation. */ +void +btr_defragment_init() +{ + srv_defragment_interval = ut_microseconds_to_timer( + 1000000.0 / srv_defragment_frequency); + mutex_create(btr_defragment_mutex_key, &btr_defragment_mutex, + SYNC_ANY_LATCH); + os_thread_create(btr_defragment_thread, NULL, NULL); +} + +/******************************************************************//** +Shutdown defragmentation. Release all resources. */ +void +btr_defragment_shutdown() +{ + mutex_enter(&btr_defragment_mutex); + list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + while(iter != btr_defragment_wq.end()) { + btr_defragment_item_t* item = *iter; + iter = btr_defragment_wq.erase(iter); + delete item; + } + mutex_exit(&btr_defragment_mutex); + mutex_free(&btr_defragment_mutex); +} + + +/******************************************************************//** +Functions used by the query threads: btr_defragment_xxx_index +Query threads find/add/remove index. */ +/******************************************************************//** +Check whether the given index is in btr_defragment_wq. We use index->id +to identify indices. */ +bool +btr_defragment_find_index( + dict_index_t* index) /*!< Index to find. */ +{ + mutex_enter(&btr_defragment_mutex); + for (list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + iter != btr_defragment_wq.end(); + ++iter) { + btr_defragment_item_t* item = *iter; + btr_pcur_t* pcur = item->pcur; + btr_cur_t* cursor = btr_pcur_get_btr_cur(pcur); + dict_index_t* idx = btr_cur_get_index(cursor); + if (index->id == idx->id) { + mutex_exit(&btr_defragment_mutex); + return true; + } + } + mutex_exit(&btr_defragment_mutex); + return false; +} + +/******************************************************************//** +Query thread uses this function to add an index to btr_defragment_wq. +Return a pointer to os_event for the query thread to wait on if this is a +synchronized defragmentation. */ +os_event_t +btr_defragment_add_index( + dict_index_t* index, /*!< index to be added */ + bool async) /*!< whether this is an async defragmentation */ +{ + mtr_t mtr; + ulint space = dict_index_get_space(index); + ulint zip_size = dict_table_zip_size(index->table); + ulint page_no = dict_index_get_page(index); + mtr_start(&mtr); + // Load index rood page. + page_t* page = btr_page_get(space, zip_size, page_no, + RW_NO_LATCH, index, &mtr); + if (btr_page_get_level(page, &mtr) == 0) { + // Index root is a leaf page, no need to defragment. + mtr_commit(&mtr); + return NULL; + } + btr_pcur_t* pcur = btr_pcur_create_for_mysql(); + os_event_t event = NULL; + if (!async) { + event = os_event_create(); + } + btr_pcur_open_at_index_side(true, index, BTR_SEARCH_LEAF, pcur, + true, 0, &mtr); + btr_pcur_move_to_next(pcur, &mtr); + btr_pcur_store_position(pcur, &mtr); + mtr_commit(&mtr); + dict_stats_empty_defrag_summary(index); + btr_defragment_item_t* item = new btr_defragment_item_t(pcur, event); + mutex_enter(&btr_defragment_mutex); + btr_defragment_wq.push_back(item); + mutex_exit(&btr_defragment_mutex); + return event; +} + +/******************************************************************//** +When table is dropped, this function is called to mark a table as removed in +btr_efragment_wq. The difference between this function and the remove_index +function is this will not NULL the event. */ +void +btr_defragment_remove_table( + dict_table_t* table) /*!< Index to be removed. */ +{ + mutex_enter(&btr_defragment_mutex); + for (list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + iter != btr_defragment_wq.end(); + ++iter) { + btr_defragment_item_t* item = *iter; + btr_pcur_t* pcur = item->pcur; + btr_cur_t* cursor = btr_pcur_get_btr_cur(pcur); + dict_index_t* idx = btr_cur_get_index(cursor); + if (table->id == idx->table->id) { + item->removed = true; + } + } + mutex_exit(&btr_defragment_mutex); +} + +/******************************************************************//** +Query thread uses this function to mark an index as removed in +btr_efragment_wq. */ +void +btr_defragment_remove_index( + dict_index_t* index) /*!< Index to be removed. */ +{ + mutex_enter(&btr_defragment_mutex); + for (list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + iter != btr_defragment_wq.end(); + ++iter) { + btr_defragment_item_t* item = *iter; + btr_pcur_t* pcur = item->pcur; + btr_cur_t* cursor = btr_pcur_get_btr_cur(pcur); + dict_index_t* idx = btr_cur_get_index(cursor); + if (index->id == idx->id) { + item->removed = true; + item->event = NULL; + break; + } + } + mutex_exit(&btr_defragment_mutex); +} + +/******************************************************************//** +Functions used by defragmentation thread: btr_defragment_xxx_item. +Defragmentation thread operates on the work *item*. It gets/removes +item from the work queue. */ +/******************************************************************//** +Defragment thread uses this to remove an item from btr_defragment_wq. +When an item is removed from the work queue, all resources associated with it +are free as well. */ +void +btr_defragment_remove_item( + btr_defragment_item_t* item) /*!< Item to be removed. */ +{ + mutex_enter(&btr_defragment_mutex); + for (list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + iter != btr_defragment_wq.end(); + ++iter) { + if (item == *iter) { + btr_defragment_wq.erase(iter); + delete item; + break; + } + } + mutex_exit(&btr_defragment_mutex); +} + +/******************************************************************//** +Defragment thread uses this to get an item from btr_defragment_wq to work on. +The item is not removed from the work queue so query threads can still access +this item. We keep it this way so query threads can find and kill a +defragmentation even if that index is being worked on. Be aware that while you +work on this item you have no lock protection on it whatsoever. This is OK as +long as the query threads and defragment thread won't modify the same fields +without lock protection. +*/ +btr_defragment_item_t* +btr_defragment_get_item() +{ + if (btr_defragment_wq.empty()) { + return NULL; + //return nullptr; + } + mutex_enter(&btr_defragment_mutex); + list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + if (iter == btr_defragment_wq.end()) { + iter = btr_defragment_wq.begin(); + } + btr_defragment_item_t* item = *iter; + iter++; + mutex_exit(&btr_defragment_mutex); + return item; +} + +/*********************************************************************//** +Check whether we should save defragmentation statistics to persistent storage. +Currently we save the stats to persistent storage every 100 updates. */ +UNIV_INTERN +void +btr_defragment_save_defrag_stats_if_needed( + dict_index_t* index) /*!< in: index */ +{ + if (srv_defragment_stats_accuracy != 0 // stats tracking disabled + && dict_index_get_space(index) != 0 // do not track system tables + && index->stat_defrag_modified_counter + >= srv_defragment_stats_accuracy) { + dict_stats_defrag_pool_add(index); + index->stat_defrag_modified_counter = 0; + } +} + +/*********************************************************************//** +Main defragment functionalities used by defragment thread.*/ +/*************************************************************//** +Calculate number of records from beginning of block that can +fit into size_limit +@return number of records */ +UNIV_INTERN +ulint +btr_defragment_calc_n_recs_for_size( + buf_block_t* block, /*!< in: B-tree page */ + dict_index_t* index, /*!< in: index of the page */ + ulint size_limit, /*!< in: size limit to fit records in */ + ulint* n_recs_size) /*!< out: actual size of the records that fit + in size_limit. */ +{ + page_t* page = buf_block_get_frame(block); + ulint n_recs = 0; + ulint offsets_[REC_OFFS_NORMAL_SIZE]; + ulint* offsets = offsets_; + rec_offs_init(offsets_); + mem_heap_t* heap = NULL; + ulint size = 0; + page_cur_t cur; + + page_cur_set_before_first(block, &cur); + page_cur_move_to_next(&cur); + while (page_cur_get_rec(&cur) != page_get_supremum_rec(page)) { + rec_t* cur_rec = page_cur_get_rec(&cur); + offsets = rec_get_offsets(cur_rec, index, offsets, + ULINT_UNDEFINED, &heap); + ulint rec_size = rec_offs_size(offsets); + size += rec_size; + if (size > size_limit) { + size = size - rec_size; + break; + } + n_recs ++; + page_cur_move_to_next(&cur); + } + *n_recs_size = size; + return n_recs; +} + +/*************************************************************//** +Merge as many records from the from_block to the to_block. Delete +the from_block if all records are successfully merged to to_block. +@return the to_block to target for next merge operation. */ +UNIV_INTERN +buf_block_t* +btr_defragment_merge_pages( + dict_index_t* index, /*!< in: index tree */ + buf_block_t* from_block, /*!< in: origin of merge */ + buf_block_t* to_block, /*!< in: destination of merge */ + ulint zip_size, /*!< in: zip size of the block */ + ulint reserved_space, /*!< in: space reserved for future + insert to avoid immediate page split */ + ulint* max_data_size, /*!< in/out: max data size to + fit in a single compressed page. */ + mem_heap_t* heap, /*!< in/out: pointer to memory heap */ + mtr_t* mtr) /*!< in/out: mini-transaction */ +{ + page_t* from_page = buf_block_get_frame(from_block); + page_t* to_page = buf_block_get_frame(to_block); + ulint space = dict_index_get_space(index); + ulint level = btr_page_get_level(from_page, mtr); + ulint n_recs = page_get_n_recs(from_page); + ulint new_data_size = page_get_data_size(to_page); + ulint max_ins_size = + page_get_max_insert_size(to_page, n_recs); + ulint max_ins_size_reorg = + page_get_max_insert_size_after_reorganize( + to_page, n_recs); + ulint max_ins_size_to_use = max_ins_size_reorg > reserved_space + ? max_ins_size_reorg - reserved_space : 0; + ulint move_size = 0; + ulint n_recs_to_move = 0; + rec_t* rec = NULL; + ulint target_n_recs = 0; + rec_t* orig_pred; + + // Estimate how many records can be moved from the from_page to + // the to_page. + if (zip_size) { + ulint page_diff = UNIV_PAGE_SIZE - *max_data_size; + max_ins_size_to_use = (max_ins_size_to_use > page_diff) + ? max_ins_size_to_use - page_diff : 0; + } + n_recs_to_move = btr_defragment_calc_n_recs_for_size( + from_block, index, max_ins_size_to_use, &move_size); + + // If max_ins_size >= move_size, we can move the records without + // reorganizing the page, otherwise we need to reorganize the page + // first to release more space. + if (move_size > max_ins_size) { + if (!btr_page_reorganize_block(false, page_zip_level, + to_block, index, + mtr)) { + if (!dict_index_is_clust(index) + && page_is_leaf(to_page)) { + ibuf_reset_free_bits(to_block); + } + // If reorganization fails, that means page is + // not compressable. There's no point to try + // merging into this page. Continue to the + // next page. + return from_block; + } + ut_ad(page_validate(to_page, index)); + max_ins_size = page_get_max_insert_size(to_page, n_recs); + ut_a(max_ins_size >= move_size); + } + + // Move records to pack to_page more full. + orig_pred = NULL; + target_n_recs = n_recs_to_move; + while (n_recs_to_move > 0) { + rec = page_rec_get_nth(from_page, + n_recs_to_move + 1); + orig_pred = page_copy_rec_list_start( + to_block, from_block, rec, index, mtr); + if (orig_pred) + break; + // If we reach here, that means compression failed after packing + // n_recs_to_move number of records to to_page. We try to reduce + // the targeted data size on the to_page by + // BTR_DEFRAGMENT_PAGE_REDUCTION_STEP_SIZE and try again. + os_atomic_increment_ulint( + &btr_defragment_compression_failures, 1); + max_ins_size_to_use = + move_size > BTR_DEFRAGMENT_PAGE_REDUCTION_STEP_SIZE + ? move_size - BTR_DEFRAGMENT_PAGE_REDUCTION_STEP_SIZE + : 0; + if (max_ins_size_to_use == 0) { + n_recs_to_move = 0; + move_size = 0; + break; + } + n_recs_to_move = btr_defragment_calc_n_recs_for_size( + from_block, index, max_ins_size_to_use, &move_size); + } + // If less than target_n_recs are moved, it means there are + // compression failures during page_copy_rec_list_start. Adjust + // the max_data_size estimation to reduce compression failures + // in the following runs. + if (target_n_recs > n_recs_to_move + && *max_data_size > new_data_size + move_size) { + *max_data_size = new_data_size + move_size; + } + // Set ibuf free bits if necessary. + if (!dict_index_is_clust(index) + && page_is_leaf(to_page)) { + if (zip_size) { + ibuf_reset_free_bits(to_block); + } else { + ibuf_update_free_bits_if_full( + to_block, + UNIV_PAGE_SIZE, + ULINT_UNDEFINED); + } + } + if (n_recs_to_move == n_recs) { + /* The whole page is merged with the previous page, + free it. */ + lock_update_merge_left(to_block, orig_pred, + from_block); + btr_search_drop_page_hash_index(from_block); + btr_level_list_remove(space, zip_size, from_page, + index, mtr); + btr_node_ptr_delete(index, from_block, mtr); + btr_blob_dbg_remove(from_page, index, + "btr_defragment_n_pages"); + btr_page_free(index, from_block, mtr); + } else { + // There are still records left on the page, so + // increment n_defragmented. Node pointer will be changed + // so remove the old node pointer. + if (n_recs_to_move > 0) { + // Part of the page is merged to left, remove + // the merged records, update record locks and + // node pointer. + dtuple_t* node_ptr; + page_delete_rec_list_start(rec, from_block, + index, mtr); + lock_update_split_and_merge(to_block, + orig_pred, + from_block); + btr_node_ptr_delete(index, from_block, mtr); + rec = page_rec_get_next( + page_get_infimum_rec(from_page)); + node_ptr = dict_index_build_node_ptr( + index, rec, page_get_page_no(from_page), + heap, level + 1); + btr_insert_on_non_leaf_level(0, index, level+1, + node_ptr, mtr); + } + to_block = from_block; + } + return to_block; +} + +/*************************************************************//** +Tries to merge N consecutive pages, starting from the page pointed by the +cursor. Skip space 0. Only consider leaf pages. +This function first loads all N pages into memory, then for each of +the pages other than the first page, it tries to move as many records +as possible to the left sibling to keep the left sibling full. During +the process, if any page becomes empty, that page will be removed from +the level list. Record locks, hash, and node pointers are updated after +page reorganization. +@return pointer to the last block processed, or NULL if reaching end of index */ +UNIV_INTERN +buf_block_t* +btr_defragment_n_pages( + buf_block_t* block, /*!< in: starting block for defragmentation */ + dict_index_t* index, /*!< in: index tree */ + uint n_pages,/*!< in: number of pages to defragment */ + mtr_t* mtr) /*!< in/out: mini-transaction */ +{ + ulint space; + ulint zip_size; + /* We will need to load the n+1 block because if the last page is freed + and we need to modify the prev_page_no of that block. */ + buf_block_t* blocks[BTR_DEFRAGMENT_MAX_N_PAGES + 1]; + page_t* first_page; + buf_block_t* current_block; + ulint total_data_size = 0; + ulint total_n_recs = 0; + ulint data_size_per_rec; + ulint optimal_page_size; + ulint reserved_space; + ulint level; + ulint max_data_size = 0; + uint n_defragmented = 0; + uint n_new_slots; + mem_heap_t* heap; + ibool end_of_index = FALSE; + + /* It doesn't make sense to call this function with n_pages = 1. */ + ut_ad(n_pages > 1); + + ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), + MTR_MEMO_X_LOCK)); + space = dict_index_get_space(index); + if (space == 0) { + /* Ignore space 0. */ + return NULL; + } + + if (n_pages > BTR_DEFRAGMENT_MAX_N_PAGES) { + n_pages = BTR_DEFRAGMENT_MAX_N_PAGES; + } + + zip_size = dict_table_zip_size(index->table); + first_page = buf_block_get_frame(block); + level = btr_page_get_level(first_page, mtr); + + if (level != 0) { + return NULL; + } + + /* 1. Load the pages and calculate the total data size. */ + blocks[0] = block; + for (uint i = 1; i <= n_pages; i++) { + page_t* page = buf_block_get_frame(blocks[i-1]); + ulint page_no = btr_page_get_next(page, mtr); + total_data_size += page_get_data_size(page); + total_n_recs += page_get_n_recs(page); + if (page_no == FIL_NULL) { + n_pages = i; + end_of_index = TRUE; + break; + } + blocks[i] = btr_block_get(space, zip_size, page_no, + RW_X_LATCH, index, mtr); + } + + if (n_pages == 1) { + if (btr_page_get_prev(first_page, mtr) == FIL_NULL) { + /* last page in the index */ + if (dict_index_get_page(index) + == page_get_page_no(first_page)) + return NULL; + /* given page is the last page. + Lift the records to father. */ + btr_lift_page_up(index, block, mtr); + } + return NULL; + } + + /* 2. Calculate how many pages data can fit in. If not compressable, + return early. */ + ut_a(total_n_recs != 0); + data_size_per_rec = total_data_size / total_n_recs; + // For uncompressed pages, the optimal data size if the free space of a + // empty page. + optimal_page_size = page_get_free_space_of_empty( + page_is_comp(first_page)); + // For compressed pages, we take compression failures into account. + if (zip_size) { + ulint size = 0; + int i = 0; + // We estimate the optimal data size of the index use samples of + // data size. These samples are taken when pages failed to + // compress due to insertion on the page. We use the average + // of all samples we have as the estimation. Different pages of + // the same index vary in compressibility. Average gives a good + // enough estimation. + for (;i < STAT_DEFRAG_DATA_SIZE_N_SAMPLE; i++) { + if (index->stat_defrag_data_size_sample[i] == 0) { + break; + } + size += index->stat_defrag_data_size_sample[i]; + } + if (i != 0) { + size = size / i; + optimal_page_size = min(optimal_page_size, size); + } + max_data_size = optimal_page_size; + } + + reserved_space = min((ulint)(optimal_page_size + * (1 - srv_defragment_fill_factor)), + (data_size_per_rec + * srv_defragment_fill_factor_n_recs)); + optimal_page_size -= reserved_space; + n_new_slots = (total_data_size + optimal_page_size - 1) + / optimal_page_size; + if (n_new_slots >= n_pages) { + /* Can't defragment. */ + if (end_of_index) + return NULL; + return blocks[n_pages-1]; + } + + /* 3. Defragment pages. */ + heap = mem_heap_create(256); + // First defragmented page will be the first page. + current_block = blocks[0]; + // Start from the second page. + for (uint i = 1; i < n_pages; i ++) { + buf_block_t* new_block = btr_defragment_merge_pages( + index, blocks[i], current_block, zip_size, + reserved_space, &max_data_size, heap, mtr); + if (new_block != current_block) { + n_defragmented ++; + current_block = new_block; + } + } + mem_heap_free(heap); + n_defragmented ++; + os_atomic_increment_ulint( + &btr_defragment_count, 1); + if (n_pages == n_defragmented) { + os_atomic_increment_ulint( + &btr_defragment_failures, 1); + } else { + index->stat_defrag_n_pages_freed += (n_pages - n_defragmented); + } + if (end_of_index) + return NULL; + return current_block; +} + +/******************************************************************//** +Thread that merges consecutive b-tree pages into fewer pages to defragment +the index. */ +extern "C" UNIV_INTERN +os_thread_ret_t +DECLARE_THREAD(btr_defragment_thread)( +/*==========================================*/ + void* arg) /*!< in: work queue */ +{ + btr_pcur_t* pcur; + btr_cur_t* cursor; + dict_index_t* index; + mtr_t mtr; + buf_block_t* first_block; + buf_block_t* last_block; + + while (srv_shutdown_state == SRV_SHUTDOWN_NONE) { + /* If defragmentation is disabled, sleep before + checking whether it's enabled. */ + if (!srv_defragment) { + os_thread_sleep(BTR_DEFRAGMENT_SLEEP_IN_USECS); + continue; + } + /* The following call won't remove the item from work queue. + We only get a pointer to it to work on. This will make sure + when user issue a kill command, all indices are in the work + queue to be searched. This also means that the user thread + cannot directly remove the item from queue (since we might be + using it). So user thread only marks index as removed. */ + btr_defragment_item_t* item = btr_defragment_get_item(); + /* If work queue is empty, sleep and check later. */ + if (!item) { + os_thread_sleep(BTR_DEFRAGMENT_SLEEP_IN_USECS); + continue; + } + /* If an index is marked as removed, we remove it from the work + queue. No other thread could be using this item at this point so + it's safe to remove now. */ + if (item->removed) { + btr_defragment_remove_item(item); + continue; + } + + pcur = item->pcur; + ulonglong now = ut_timer_now(); + ulonglong elapsed = now - item->last_processed; + + if (elapsed < srv_defragment_interval) { + /* If we see an index again before the interval + determined by the configured frequency is reached, + we just sleep until the interval pass. Since + defragmentation of all indices queue up on a single + thread, it's likely other indices that follow this one + don't need to sleep again. */ + os_thread_sleep(((ulint)ut_timer_to_microseconds( + srv_defragment_interval - elapsed))); + } + + now = ut_timer_now(); + mtr_start(&mtr); + btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, &mtr); + cursor = btr_pcur_get_btr_cur(pcur); + index = btr_cur_get_index(cursor); + first_block = btr_cur_get_block(cursor); + last_block = btr_defragment_n_pages(first_block, index, + srv_defragment_n_pages, + &mtr); + if (last_block) { + /* If we haven't reached the end of the index, + place the cursor on the last record of last page, + store the cursor position, and put back in queue. */ + page_t* last_page = buf_block_get_frame(last_block); + rec_t* rec = page_rec_get_prev( + page_get_supremum_rec(last_page)); + ut_a(page_rec_is_user_rec(rec)); + page_cur_position(rec, last_block, + btr_cur_get_page_cur(cursor)); + btr_pcur_store_position(pcur, &mtr); + mtr_commit(&mtr); + /* Update the last_processed time of this index. */ + item->last_processed = now; + } else { + mtr_commit(&mtr); + /* Reaching the end of the index. */ + dict_stats_empty_defrag_stats(index); + dict_stats_save_defrag_stats(index); + dict_stats_save_defrag_summary(index); + btr_defragment_remove_item(item); + } + } + btr_defragment_shutdown(); + os_thread_exit(NULL); + OS_THREAD_DUMMY_RETURN; +} + +#endif /* !UNIV_HOTBACKUP */ diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 72a0f39e19e..ad5c9d42e81 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -408,7 +408,7 @@ dict_table_try_drop_aborted( if (table == NULL) { table = dict_table_open_on_id_low( - table_id, DICT_ERR_IGNORE_NONE); + table_id, DICT_ERR_IGNORE_NONE, FALSE); } else { ut_ad(table->id == table_id); } @@ -795,7 +795,8 @@ dict_table_open_on_id( table_id, table_op == DICT_TABLE_OP_LOAD_TABLESPACE ? DICT_ERR_IGNORE_RECOVER_LOCK - : DICT_ERR_IGNORE_NONE); + : DICT_ERR_IGNORE_NONE, + table_op == DICT_TABLE_OP_OPEN_ONLY_IF_CACHED); if (table != NULL) { @@ -1313,7 +1314,7 @@ dict_table_move_from_non_lru_to_lru( /**********************************************************************//** Looks for an index with the given id given a table instance. @return index or NULL */ -static +UNIV_INTERN dict_index_t* dict_table_find_index_on_id( /*========================*/ @@ -2408,6 +2409,13 @@ undo_size_ok: new_index->stat_index_size = 1; new_index->stat_n_leaf_pages = 1; + new_index->stat_defrag_n_pages_freed = 0; + new_index->stat_defrag_n_page_split = 0; + + new_index->stat_defrag_sample_next_slot = 0; + memset(&new_index->stat_defrag_data_size_sample, + 0x0, sizeof(ulint) * STAT_DEFRAG_DATA_SIZE_N_SAMPLE); + /* Add the new index as the last index for the table */ UT_LIST_ADD_LAST(indexes, table->indexes, new_index); diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 928bdb3f2ef..bec0079942b 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -492,6 +492,9 @@ dict_stats_table_clone_create( heap, idx->n_uniq * sizeof(idx->stat_n_non_null_key_vals[0])); ut_d(idx->magic_n = DICT_INDEX_MAGIC_N); + + idx->stat_defrag_n_page_split = 0; + idx->stat_defrag_n_pages_freed = 0; } ut_d(t->magic_n = DICT_TABLE_MAGIC_N); @@ -520,7 +523,9 @@ static void dict_stats_empty_index( /*===================*/ - dict_index_t* index) /*!< in/out: index */ + dict_index_t* index, /*!< in/out: index */ + bool empty_defrag_stats) + /*!< in: whether to empty defrag stats */ { ut_ad(!(index->type & DICT_FTS)); ut_ad(!dict_index_is_univ(index)); @@ -535,6 +540,34 @@ dict_stats_empty_index( index->stat_index_size = 1; index->stat_n_leaf_pages = 1; + + if (empty_defrag_stats) { + dict_stats_empty_defrag_stats(index); + dict_stats_empty_defrag_summary(index); + } +} + +/**********************************************************************//** +Clear defragmentation summary. */ +UNIV_INTERN +void +dict_stats_empty_defrag_summary( +/*==================*/ + dict_index_t* index) /*!< in: index to clear defragmentation stats */ +{ + index->stat_defrag_n_pages_freed = 0; +} + +/**********************************************************************//** +Clear defragmentation related index stats. */ +UNIV_INTERN +void +dict_stats_empty_defrag_stats( +/*==================*/ + dict_index_t* index) /*!< in: index to clear defragmentation stats */ +{ + index->stat_defrag_modified_counter = 0; + index->stat_defrag_n_page_split = 0; } /*********************************************************************//** @@ -544,7 +577,9 @@ static void dict_stats_empty_table( /*===================*/ - dict_table_t* table) /*!< in/out: table */ + dict_table_t* table, /*!< in/out: table */ + bool empty_defrag_stats) + /*!< in: whether to empty defrag stats */ { /* Zero the stats members */ @@ -569,7 +604,7 @@ dict_stats_empty_table( ut_ad(!dict_index_is_univ(index)); - dict_stats_empty_index(index); + dict_stats_empty_index(index, empty_defrag_stats); } table->stat_initialized = TRUE; @@ -704,7 +739,7 @@ dict_stats_copy( } if (!INDEX_EQ(src_idx, dst_idx)) { - dict_stats_empty_index(dst_idx); + dict_stats_empty_index(dst_idx, true); continue; } @@ -715,7 +750,7 @@ dict_stats_copy( /* Since src is smaller some elements in dst will remain untouched by the following memmove(), thus we init all of them here. */ - dict_stats_empty_index(dst_idx); + dict_stats_empty_index(dst_idx, true); } else { n_copy_el = dst_idx->n_uniq; } @@ -735,6 +770,13 @@ dict_stats_copy( dst_idx->stat_index_size = src_idx->stat_index_size; dst_idx->stat_n_leaf_pages = src_idx->stat_n_leaf_pages; + + dst_idx->stat_defrag_modified_counter = + src_idx->stat_defrag_modified_counter; + dst_idx->stat_defrag_n_pages_freed = + src_idx->stat_defrag_n_pages_freed; + dst_idx->stat_defrag_n_page_split = + src_idx->stat_defrag_n_page_split; } dst->stat_initialized = TRUE; @@ -758,6 +800,9 @@ dict_index_t::stat_n_sample_sizes[] dict_index_t::stat_n_non_null_key_vals[] dict_index_t::stat_index_size dict_index_t::stat_n_leaf_pages +dict_index_t::stat_defrag_modified_counter +dict_index_t::stat_defrag_n_pages_freed +dict_index_t::stat_defrag_n_page_split The returned object should be freed with dict_stats_snapshot_free() when no longer needed. @return incomplete table object */ @@ -807,7 +852,9 @@ dict_stats_snapshot_free( Calculates new estimates for index statistics. This function is relatively quick and is used to calculate transient statistics that are not saved on disk. This was the only way to calculate statistics -before the Persistent Statistics feature was introduced. */ +before the Persistent Statistics feature was introduced. +This function doesn't update the defragmentation related stats. +Only persistent statistics supports defragmentation stats. */ static void dict_stats_update_transient_for_index( @@ -823,10 +870,10 @@ dict_stats_update_transient_for_index( Initialize some bogus index cardinality statistics, so that the data can be queried in various means, also via secondary indexes. */ - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG } else if (ibuf_debug && !dict_index_is_clust(index)) { - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ } else { mtr_t mtr; @@ -847,7 +894,7 @@ dict_stats_update_transient_for_index( switch (size) { case ULINT_UNDEFINED: - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); return; case 0: /* The root node of the tree is a leaf */ @@ -882,7 +929,7 @@ dict_stats_update_transient( if (dict_table_is_discarded(table)) { /* Nothing to do. */ - dict_stats_empty_table(table); + dict_stats_empty_table(table, false); return; } else if (index == NULL) { /* Table definition is corrupt */ @@ -892,7 +939,7 @@ dict_stats_update_transient( fprintf(stderr, " InnoDB: table %s has no indexes. " "Cannot calculate statistics.\n", ut_format_name(table->name, TRUE, buf, sizeof(buf))); - dict_stats_empty_table(table); + dict_stats_empty_table(table, false); return; } @@ -904,7 +951,7 @@ dict_stats_update_transient( continue; } - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); if (dict_stats_should_ignore_index(index)) { continue; @@ -1794,7 +1841,7 @@ dict_stats_analyze_index( DEBUG_PRINTF(" %s(index=%s)\n", __func__, index->name); - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); mtr_start(&mtr); @@ -2059,7 +2106,7 @@ dict_stats_update_persistent( /* Table definition is corrupt */ dict_table_stats_unlock(table, RW_X_LATCH); - dict_stats_empty_table(table); + dict_stats_empty_table(table, true); return(DB_CORRUPTION); } @@ -2088,7 +2135,7 @@ dict_stats_update_persistent( continue; } - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); if (dict_stats_should_ignore_index(index)) { continue; @@ -2657,6 +2704,16 @@ dict_stats_fetch_index_stats_step( == 0) { index->stat_n_leaf_pages = (ulint) stat_value; arg->stats_were_modified = true; + } else if (stat_name_len == 12 /* strlen("n_page_split") */ + && strncasecmp("n_page_split", stat_name, stat_name_len) + == 0) { + index->stat_defrag_n_page_split = (ulint) stat_value; + arg->stats_were_modified = true; + } else if (stat_name_len == 13 /* strlen("n_pages_freed") */ + && strncasecmp("n_pages_freed", stat_name, stat_name_len) + == 0) { + index->stat_defrag_n_pages_freed = (ulint) stat_value; + arg->stats_were_modified = true; } else if (stat_name_len > PFX_LEN /* e.g. stat_name=="n_diff_pfx01" */ && strncasecmp(PFX, stat_name, PFX_LEN) == 0) { @@ -2776,7 +2833,7 @@ dict_stats_fetch_from_ps( the persistent storage contains incomplete stats (e.g. missing stats for some index) then we would end up with (partially) uninitialized stats. */ - dict_stats_empty_table(table); + dict_stats_empty_table(table, true); trx = trx_allocate_for_background(); @@ -2878,6 +2935,22 @@ dict_stats_fetch_from_ps( } /*********************************************************************//** +Clear defragmentation stats modified counter for all indices in table. */ +static +void +dict_stats_empty_defrag_modified_counter( + dict_table_t* table) /*!< in: table */ +{ + dict_index_t* index; + ut_a(table); + for (index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + index->stat_defrag_modified_counter = 0; + } +} + +/*********************************************************************//** Fetches or calculates new estimates for index statistics. */ UNIV_INTERN void @@ -2949,13 +3022,13 @@ dict_stats_update( "because the .ibd file is missing. For help, please " "refer to " REFMAN "innodb-troubleshooting.html\n", ut_format_name(table->name, TRUE, buf, sizeof(buf))); - dict_stats_empty_table(table); + dict_stats_empty_table(table, true); return(DB_TABLESPACE_DELETED); } else if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { /* If we have set a high innodb_force_recovery level, do not calculate statistics, as a badly corrupted index can cause a crash in it. */ - dict_stats_empty_table(table); + dict_stats_empty_table(table, false); return(DB_SUCCESS); } @@ -3014,7 +3087,7 @@ dict_stats_update( case DICT_STATS_EMPTY_TABLE: - dict_stats_empty_table(table); + dict_stats_empty_table(table, true); /* If table is using persistent stats, then save the stats on disk */ @@ -3073,6 +3146,7 @@ dict_stats_update( t->stats_last_recalc = table->stats_last_recalc; t->stat_modified_counter = 0; + dict_stats_empty_defrag_modified_counter(t); switch (err) { case DB_SUCCESS: @@ -3083,7 +3157,7 @@ dict_stats_update( copying because dict_stats_table_clone_create() does skip corrupted indexes so our dummy object 't' may have less indexes than the real object 'table'. */ - dict_stats_empty_table(table); + dict_stats_empty_table(table, true); dict_stats_copy(table, t); @@ -3650,6 +3724,117 @@ dict_stats_rename_table( return(ret); } +/*********************************************************************//** +Save defragmentation result. +@return DB_SUCCESS or error code */ +UNIV_INTERN +dberr_t +dict_stats_save_defrag_summary( + dict_index_t* index) /*!< in: index */ +{ + dberr_t ret; + lint now = (lint) ut_time(); + if (dict_index_is_univ(index)) { + return DB_SUCCESS; + } + rw_lock_x_lock(&dict_operation_lock); + mutex_enter(&dict_sys->mutex); + ret = dict_stats_save_index_stat(index, now, "n_pages_freed", + index->stat_defrag_n_pages_freed, + NULL, + "Number of pages freed during" + " last defragmentation run.", + NULL); + + mutex_exit(&dict_sys->mutex); + rw_lock_x_unlock(&dict_operation_lock); + return (ret); +} + +/*********************************************************************//** +Save defragmentation stats for a given index. +@return DB_SUCCESS or error code */ +UNIV_INTERN +dberr_t +dict_stats_save_defrag_stats( + dict_index_t* index) /*!< in: index */ +{ + dberr_t ret; + + if (index->table->ibd_file_missing) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Cannot save defragment stats because " + ".ibd file is missing.\n"); + return (DB_TABLESPACE_DELETED); + } + if (dict_index_is_corrupted(index)) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Cannot save defragment stats because " + "index is corrupted.\n"); + return(DB_CORRUPTION); + } + + if (dict_index_is_univ(index)) { + return DB_SUCCESS; + } + + lint now = (lint) ut_time(); + mtr_t mtr; + ulint n_leaf_pages; + ulint n_leaf_reserved; + mtr_start(&mtr); + mtr_s_lock(dict_index_get_lock(index), &mtr); + n_leaf_reserved = btr_get_size_and_reserved(index, BTR_N_LEAF_PAGES, + &n_leaf_pages, &mtr); + mtr_commit(&mtr); + + if (n_leaf_reserved == ULINT_UNDEFINED) { + // The index name is different during fast index creation, + // so the stats won't be associated with the right index + // for later use. We just return without saving. + return DB_SUCCESS; + } + + rw_lock_x_lock(&dict_operation_lock); + + mutex_enter(&dict_sys->mutex); + ret = dict_stats_save_index_stat(index, now, "n_page_split", + index->stat_defrag_n_page_split, + NULL, + "Number of new page splits on leaves" + " since last defragmentation.", + NULL); + if (ret != DB_SUCCESS) { + goto end; + } + + ret = dict_stats_save_index_stat( + index, now, "n_leaf_pages_defrag", + n_leaf_pages, + NULL, + "Number of leaf pages when this stat is saved to disk", + NULL); + if (ret != DB_SUCCESS) { + goto end; + } + + ret = dict_stats_save_index_stat( + index, now, "n_leaf_pages_reserved", + n_leaf_reserved, + NULL, + "Number of pages reserved for this index leaves when this stat " + "is saved to disk", + NULL); + +end: + mutex_exit(&dict_sys->mutex); + rw_lock_x_unlock(&dict_operation_lock); + + return (ret); +} + /* tests @{ */ #ifdef UNIV_COMPILE_TEST_FUNCS diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index ecd723ca39a..0089f9897ae 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -25,6 +25,7 @@ Created Apr 25, 2012 Vasil Dimov #include "row0mysql.h" #include "srv0start.h" +#include "dict0dict.h" #include "dict0stats.h" #include "dict0stats_bg.h" @@ -44,8 +45,10 @@ UNIV_INTERN os_event_t dict_stats_event = NULL; /** This mutex protects the "recalc_pool" variable. */ static ib_mutex_t recalc_pool_mutex; +static ib_mutex_t defrag_pool_mutex; #ifdef HAVE_PSI_INTERFACE static mysql_pfs_key_t recalc_pool_mutex_key; +static mysql_pfs_key_t defrag_pool_mutex_key; #endif /* HAVE_PSI_INTERFACE */ /** The number of tables that can be added to "recalc_pool" before @@ -59,16 +62,26 @@ static recalc_pool_t recalc_pool; typedef recalc_pool_t::iterator recalc_pool_iterator_t; +/** Indices whose defrag stats need to be saved to persistent storage.*/ +struct defrag_pool_item_t { + table_id_t table_id; + index_id_t index_id; +}; +typedef std::vector<defrag_pool_item_t> defrag_pool_t; +static defrag_pool_t defrag_pool; +typedef defrag_pool_t::iterator defrag_pool_iterator_t; + /*****************************************************************//** Initialize the recalc pool, called once during thread initialization. */ static void -dict_stats_recalc_pool_init() +dict_stats_pool_init() /*=========================*/ { ut_ad(!srv_read_only_mode); recalc_pool.reserve(RECALC_POOL_INITIAL_SLOTS); + defrag_pool.reserve(RECALC_POOL_INITIAL_SLOTS); } /*****************************************************************//** @@ -76,12 +89,13 @@ Free the resources occupied by the recalc pool, called once during thread de-initialization. */ static void -dict_stats_recalc_pool_deinit() -/*===========================*/ +dict_stats_pool_deinit() +/*====================*/ { ut_ad(!srv_read_only_mode); recalc_pool.clear(); + defrag_pool.clear(); /* recalc_pool may still have its buffer allocated. It will free it when its destructor is called. @@ -90,8 +104,12 @@ dict_stats_recalc_pool_deinit() memory. To avoid that, we force recalc_pool to surrender its buffer to empty_pool object, which will free it when leaving this function: */ - recalc_pool_t empty_pool; - recalc_pool.swap(empty_pool); + recalc_pool_t recalc_empty_pool; + defrag_pool_t defrag_empty_pool; + memset(&recalc_empty_pool, 0, sizeof(recalc_pool_t)); + memset(&defrag_empty_pool, 0, sizeof(defrag_pool_t)); + recalc_pool.swap(recalc_empty_pool); + defrag_pool.swap(defrag_empty_pool); } /*****************************************************************//** @@ -188,6 +206,111 @@ dict_stats_recalc_pool_del( } /*****************************************************************//** +Add an index in a table to the defrag pool, which is processed by the +background stats gathering thread. Only the table id and index id are +added to the list, so the table can be closed after being enqueued and +it will be opened when needed. If the table or index does not exist later +(has been DROPped), then it will be removed from the pool and skipped. */ +UNIV_INTERN +void +dict_stats_defrag_pool_add( +/*=======================*/ + const dict_index_t* index) /*!< in: table to add */ +{ + defrag_pool_item_t item; + + ut_ad(!srv_read_only_mode); + + mutex_enter(&defrag_pool_mutex); + + /* quit if already in the list */ + for (defrag_pool_iterator_t iter = defrag_pool.begin(); + iter != defrag_pool.end(); + ++iter) { + if ((*iter).table_id == index->table->id + && (*iter).index_id == index->id) { + mutex_exit(&defrag_pool_mutex); + return; + } + } + + item.table_id = index->table->id; + item.index_id = index->id; + defrag_pool.push_back(item); + + mutex_exit(&defrag_pool_mutex); + + os_event_set(dict_stats_event); +} + +/*****************************************************************//** +Get an index from the auto defrag pool. The returned index id is removed +from the pool. +@return true if the pool was non-empty and "id" was set, false otherwise */ +static +bool +dict_stats_defrag_pool_get( +/*=======================*/ + table_id_t* table_id, /*!< out: table id, or unmodified if + list is empty */ + index_id_t* index_id) /*!< out: index id, or unmodified if + list is empty */ +{ + ut_ad(!srv_read_only_mode); + + mutex_enter(&defrag_pool_mutex); + + if (defrag_pool.empty()) { + mutex_exit(&defrag_pool_mutex); + return(false); + } + + defrag_pool_item_t& item = defrag_pool.back(); + *table_id = item.table_id; + *index_id = item.index_id; + + defrag_pool.pop_back(); + + mutex_exit(&defrag_pool_mutex); + + return(true); +} + +/*****************************************************************//** +Delete a given index from the auto defrag pool. */ +UNIV_INTERN +void +dict_stats_defrag_pool_del( +/*=======================*/ + const dict_table_t* table, /*!<in: if given, remove + all entries for the table */ + const dict_index_t* index) /*!< in: if given, remove this index */ +{ + ut_a((table && !index) || (!table && index)); + ut_ad(!srv_read_only_mode); + ut_ad(mutex_own(&dict_sys->mutex)); + + mutex_enter(&defrag_pool_mutex); + + defrag_pool_iterator_t iter = defrag_pool.begin(); + while (iter != defrag_pool.end()) { + if ((table && (*iter).table_id == table->id) + || (index + && (*iter).table_id == index->table->id + && (*iter).index_id == index->id)) { + /* erase() invalidates the iterator */ + iter = defrag_pool.erase(iter); + if (index) + break; + } else { + iter++; + } + } + + mutex_exit(&defrag_pool_mutex); +} + +/*****************************************************************//** Wait until background stats thread has stopped using the specified table. The caller must have locked the data dictionary using row_mysql_lock_data_dictionary() and this function may unlock it temporarily @@ -237,7 +360,10 @@ dict_stats_thread_init() mutex_create(recalc_pool_mutex_key, &recalc_pool_mutex, SYNC_STATS_AUTO_RECALC); - dict_stats_recalc_pool_init(); + /* We choose SYNC_STATS_DEFRAG to be below SYNC_FSP_PAGE. */ + mutex_create(defrag_pool_mutex_key, &defrag_pool_mutex, + SYNC_STATS_DEFRAG); + dict_stats_pool_init(); } /*****************************************************************//** @@ -251,11 +377,14 @@ dict_stats_thread_deinit() ut_a(!srv_read_only_mode); ut_ad(!srv_dict_stats_thread_active); - dict_stats_recalc_pool_deinit(); + dict_stats_pool_deinit(); mutex_free(&recalc_pool_mutex); memset(&recalc_pool_mutex, 0x0, sizeof(recalc_pool_mutex)); + mutex_free(&defrag_pool_mutex); + memset(&defrag_pool_mutex, 0x0, sizeof(defrag_pool_mutex)); + os_event_free(dict_stats_event); dict_stats_event = NULL; } @@ -333,6 +462,63 @@ dict_stats_process_entry_from_recalc_pool() } /*****************************************************************//** +Get the first index that has been added for updating persistent defrag +stats and eventually save its stats. */ +static +void +dict_stats_process_entry_from_defrag_pool() +/*=======================================*/ +{ + table_id_t table_id; + index_id_t index_id; + + ut_ad(!srv_read_only_mode); + + /* pop the first index from the auto defrag pool */ + if (!dict_stats_defrag_pool_get(&table_id, &index_id)) { + /* no index in defrag pool */ + return; + } + + dict_table_t* table; + + mutex_enter(&dict_sys->mutex); + + /* If the table is no longer cached, we've already lost the in + memory stats so there's nothing really to write to disk. */ + table = dict_table_open_on_id(table_id, TRUE, + DICT_TABLE_OP_OPEN_ONLY_IF_CACHED); + + if (table == NULL) { + mutex_exit(&dict_sys->mutex); + return; + } + + /* Check whether table is corrupted */ + if (table->corrupted) { + dict_table_close(table, TRUE, FALSE); + mutex_exit(&dict_sys->mutex); + return; + } + mutex_exit(&dict_sys->mutex); + + dict_index_t* index = dict_table_find_index_on_id(table, index_id); + + if (index == NULL) { + return; + } + + /* Check whether index is corrupted */ + if (dict_index_is_corrupted(index)) { + dict_table_close(table, FALSE, FALSE); + return; + } + + dict_stats_save_defrag_stats(index); + dict_table_close(table, FALSE, FALSE); +} + +/*****************************************************************//** This is the thread for background stats gathering. It pops tables, from the auto recalc list and proceeds them, eventually recalculating their statistics. @@ -364,6 +550,9 @@ DECLARE_THREAD(dict_stats_thread)( dict_stats_process_entry_from_recalc_pool(); + while (defrag_pool.size()) + dict_stats_process_entry_from_defrag_pool(); + os_event_reset(dict_stats_event); } diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index b2a58c3bfdc..be6a1ce30ef 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -6700,7 +6700,7 @@ fil_space_name( /*******************************************************************//** Return page type name */ -char* +const char* fil_get_page_type_name( /*===================*/ ulint page_type) /*!< in: FIL_PAGE_TYPE */ diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index f324631dff1..65d5317a1b1 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -346,17 +346,20 @@ fil_compress_page( len, reinterpret_cast<uint8_t*>(out_buf + header_len), &out_pos, - (size_t)&write_size); + (size_t)write_size); - if (err != LZMA_OK || write_size > UNIV_PAGE_SIZE-header_len) { + if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) { fprintf(stderr, "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", - space_id, fil_space_name(space), len, err, write_size); + space_id, fil_space_name(space), len, err, out_pos); srv_stats.pages_page_compression_error.inc(); *out_len = len; return (buf); } + + write_size = out_pos; + break; } #endif /* HAVE_LZMA */ diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 970127a7420..5e20cbcfc61 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -57,6 +57,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "buf0flu.h" #include "buf0dblwr.h" #include "btr0sea.h" +#include "btr0defragment.h" #include "os0file.h" #include "os0thread.h" #include "srv0start.h" @@ -65,7 +66,6 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0trx.h" #include "trx0sys.h" -#include "mtr0mtr.h" #include "rem0types.h" #include "row0ins.h" #include "row0mysql.h" @@ -86,6 +86,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0stats_bg.h" #include "ha_prototypes.h" #include "ut0mem.h" +#include "ut0timer.h" #include "ibuf0ibuf.h" #include "dict0dict.h" #include "srv0mon.h" @@ -792,6 +793,14 @@ static SHOW_VAR innodb_status_variables[]= { {"have_bzip2", (char*) &innodb_have_bzip2, SHOW_BOOL}, + /* Defragmentation */ + {"defragment_compression_failures", + (char*) &export_vars.innodb_defragment_compression_failures, SHOW_LONG}, + {"defragment_failures", + (char*) &export_vars.innodb_defragment_failures, SHOW_LONG}, + {"defragment_count", + (char*) &export_vars.innodb_defragment_count, SHOW_LONG}, + {NullS, NullS, SHOW_LONG} }; @@ -2411,7 +2420,8 @@ ha_innobase::ha_innobase( (srv_force_primary_key ? HA_REQUIRE_PRIMARY_KEY : 0 ) | HA_CAN_FULLTEXT_EXT | HA_CAN_EXPORT), start_of_scan(0), - num_write_row(0) + num_write_row(0), + ha_partition_stats(NULL) {} /*********************************************************************//** @@ -11786,6 +11796,71 @@ ha_innobase::delete_table( DBUG_RETURN(convert_error_code_to_mysql(err, 0, NULL)); } +/*****************************************************************//** +Defragment table. +@return error number */ +UNIV_INTERN +int +ha_innobase::defragment_table( +/*==========================*/ + const char* name, /*!< in: table name */ + const char* index_name, /*!< in: index name */ + bool async) /*!< in: whether to wait until finish */ +{ + char norm_name[FN_REFLEN]; + dict_table_t* table; + dict_index_t* index; + ibool one_index = (index_name != 0); + int ret = 0; + if (!srv_defragment) { + return ER_FEATURE_DISABLED; + } + normalize_table_name(norm_name, name); + table = dict_table_open_on_name(norm_name, FALSE, + FALSE, DICT_ERR_IGNORE_NONE); + for (index = dict_table_get_first_index(table); index; + index = dict_table_get_next_index(index)) { + if (one_index && strcasecmp(index_name, index->name) != 0) + continue; + if (btr_defragment_find_index(index)) { + // We borrow this error code. When the same index is + // already in the defragmentation queue, issue another + // defragmentation only introduces overhead. We return + // an error here to let the user know this is not + // necessary. Note that this will fail a query that's + // trying to defragment a full table if one of the + // indicies in that table is already in defragmentation. + // We choose this behavior so user is aware of this + // rather than silently defragment other indicies of + // that table. + ret = ER_SP_ALREADY_EXISTS; + break; + } + os_event_t event = btr_defragment_add_index(index, async); + if (!async && event) { + while(os_event_wait_time(event, 1000000)) { + if (thd_killed(current_thd)) { + btr_defragment_remove_index(index); + ret = ER_QUERY_INTERRUPTED; + break; + } + } + os_event_free(event); + } + if (ret) { + break; + } + if (one_index) { + one_index = FALSE; + break; + } + } + dict_table_close(table, FALSE, FALSE); + if (ret == 0 && one_index) { + ret = ER_NO_SUCH_INDEX; + } + return ret; +} /*****************************************************************//** Removes all tables in the named database inside InnoDB. */ @@ -12924,6 +12999,27 @@ ha_innobase::optimize( This works OK otherwise, but MySQL locks the entire table during calls to OPTIMIZE, which is undesirable. */ + if (srv_defragment) { + int err; + + err = defragment_table(prebuilt->table->name, NULL, false); + + if (err == 0) { + return (HA_ADMIN_OK); + } else { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + err, + "InnoDB: Cannot defragment table %s: returned error code %d\n", + prebuilt->table->name, err); + + if(err == ER_SP_ALREADY_EXISTS) { + return (HA_ADMIN_OK); + } else { + return (HA_ADMIN_TRY_ALTER); + } + } + } + if (innodb_optimize_fulltext_only) { if (prebuilt->table->fts && prebuilt->table->fts->cache && !dict_table_is_discarded(prebuilt->table)) { @@ -15638,6 +15734,13 @@ innodb_max_dirty_pages_pct_lwm_update( srv_max_dirty_pages_pct_lwm = in_val; } +UNIV_INTERN +void +ha_innobase::set_partition_owner_stats(ha_statistics *stats) +{ + ha_partition_stats= stats; +} + /************************************************************//** Validate the file format name and return its corresponding id. @return valid file format id */ @@ -16891,6 +16994,23 @@ innodb_reset_all_monitor_update( TRUE); } +static +void +innodb_defragment_frequency_update( +/*===============================*/ + THD* thd, /*!< in: thread handle */ + struct st_mysql_sys_var* var, /*!< in: pointer to + system variable */ + void* var_ptr,/*!< out: where the + formal string goes */ + const void* save) /*!< in: immediate result + from check function */ +{ + srv_defragment_frequency = (*static_cast<const uint*>(save)); + srv_defragment_interval = ut_microseconds_to_timer( + 1000000.0 / srv_defragment_frequency); +} + /****************************************************************//** Parse and enable InnoDB monitor counters during server startup. User can list the monitor counters/groups to be enable by specifying @@ -18048,6 +18168,60 @@ static MYSQL_SYSVAR_BOOL(buffer_pool_load_at_startup, srv_buffer_pool_load_at_st "Load the buffer pool from a file named @@innodb_buffer_pool_filename", NULL, NULL, FALSE); +static MYSQL_SYSVAR_BOOL(defragment, srv_defragment, + PLUGIN_VAR_RQCMDARG, + "Enable/disable InnoDB defragmentation (default FALSE). When set to FALSE, all existing " + "defragmentation will be paused. And new defragmentation command will fail." + "Paused defragmentation commands will resume when this variable is set to " + "true again.", + NULL, NULL, FALSE); + +static MYSQL_SYSVAR_UINT(defragment_n_pages, srv_defragment_n_pages, + PLUGIN_VAR_RQCMDARG, + "Number of pages considered at once when merging multiple pages to " + "defragment", + NULL, NULL, 7, 2, 32, 0); + +static MYSQL_SYSVAR_UINT(defragment_stats_accuracy, + srv_defragment_stats_accuracy, + PLUGIN_VAR_RQCMDARG, + "How many defragment stats changes there are before the stats " + "are written to persistent storage. Set to 0 meaning disable " + "defragment stats tracking.", + NULL, NULL, 0, 0, ~0U, 0); + +static MYSQL_SYSVAR_UINT(defragment_fill_factor_n_recs, + srv_defragment_fill_factor_n_recs, + PLUGIN_VAR_RQCMDARG, + "How many records of space defragmentation should leave on the page. " + "This variable, together with innodb_defragment_fill_factor, is introduced " + "so defragmentation won't pack the page too full and cause page split on " + "the next insert on every page. The variable indicating more defragmentation" + " gain is the one effective.", + NULL, NULL, 20, 1, 100, 0); + +static MYSQL_SYSVAR_DOUBLE(defragment_fill_factor, srv_defragment_fill_factor, + PLUGIN_VAR_RQCMDARG, + "A number between [0.7, 1] that tells defragmentation how full it should " + "fill a page. Default is 0.9. Number below 0.7 won't make much sense." + "This variable, together with innodb_defragment_fill_factor_n_recs, is " + "introduced so defragmentation won't pack the page too full and cause " + "page split on the next insert on every page. The variable indicating more " + "defragmentation gain is the one effective.", + NULL, NULL, 0.9, 0.7, 1, 0); + +static MYSQL_SYSVAR_UINT(defragment_frequency, srv_defragment_frequency, + PLUGIN_VAR_RQCMDARG, + "Do not defragment a single index more than this number of time per second." + "This controls the number of time defragmentation thread can request X_LOCK " + "on an index. Defragmentation thread will check whether " + "1/defragment_frequency (s) has passed since it worked on this index last " + "time, and put the index back to the queue if not enough time has passed. " + "The actual frequency can only be lower than this given number.", + NULL, innodb_defragment_frequency_update, + SRV_DEFRAGMENT_FREQUENCY_DEFAULT, 1, 1000, 0); + + static MYSQL_SYSVAR_ULONG(lru_scan_depth, srv_LRU_scan_depth, PLUGIN_VAR_RQCMDARG, "How deep to scan LRU to keep it clean", @@ -18567,6 +18741,12 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(buffer_pool_load_now), MYSQL_SYSVAR(buffer_pool_load_abort), MYSQL_SYSVAR(buffer_pool_load_at_startup), + MYSQL_SYSVAR(defragment), + MYSQL_SYSVAR(defragment_n_pages), + MYSQL_SYSVAR(defragment_stats_accuracy), + MYSQL_SYSVAR(defragment_fill_factor), + MYSQL_SYSVAR(defragment_fill_factor_n_recs), + MYSQL_SYSVAR(defragment_frequency), MYSQL_SYSVAR(lru_scan_depth), MYSQL_SYSVAR(flush_neighbors), MYSQL_SYSVAR(checksum_algorithm), diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 1fa9fe139fb..9c190bb90cb 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -105,6 +105,8 @@ class ha_innobase: public handler or undefined */ uint num_write_row; /*!< number of write_row() calls */ + ha_statistics* ha_partition_stats; /*!< stats of the partition owner + handler (if there is one) */ uint store_key_val_for_row(uint keynr, char* buff, uint buff_len, const uchar* record); inline void update_thd(THD* thd); @@ -210,6 +212,8 @@ class ha_innobase: public handler int truncate(); int delete_table(const char *name); int rename_table(const char* from, const char* to); + int defragment_table(const char* name, const char* index_name, + bool async); int check(THD* thd, HA_CHECK_OPT* check_opt); char* update_table_comment(const char* comment); char* get_foreign_key_create_info(); @@ -313,6 +317,7 @@ class ha_innobase: public handler Alter_inplace_info* ha_alter_info, bool commit); /** @} */ + void set_partition_owner_stats(ha_statistics *stats); bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); private: diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index 305acf7e322..b6f8a685ae9 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -2,6 +2,7 @@ Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2014, SkySQL Ab. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -671,6 +672,21 @@ btr_get_size( is s-latched */ __attribute__((nonnull, warn_unused_result)); /**************************************************************//** +Gets the number of reserved and used pages in a B-tree. +@return number of pages reserved, or ULINT_UNDEFINED if the index +is unavailable */ +UNIV_INTERN +ulint +btr_get_size_and_reserved( +/*======================*/ + dict_index_t* index, /*!< in: index */ + ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */ + ulint* used, /*!< out: number of pages used (<= reserved) */ + mtr_t* mtr) /*!< in/out: mini-transaction where index + is s-latched */ + __attribute__((nonnull)); + +/**************************************************************//** Allocates a new file page to be used in an index tree. NOTE: we assume that the caller has made the reservation for free extents! @retval NULL if no page could be allocated @@ -717,6 +733,33 @@ btr_page_free_low( ulint level, /*!< in: page level */ mtr_t* mtr) /*!< in: mtr */ __attribute__((nonnull)); +/*************************************************************//** +Reorganizes an index page. + +IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE +if this is a compressed leaf page in a secondary index. This has to +be done either within the same mini-transaction, or by invoking +ibuf_reset_free_bits() before mtr_commit(). On uncompressed pages, +IBUF_BITMAP_FREE is unaffected by reorganization. + +@retval true if the operation was successful +@retval false if it is a compressed page, and recompression failed */ +UNIV_INTERN +bool +btr_page_reorganize_block( +/*======================*/ + bool recovery,/*!< in: true if called in recovery: + locks should not be updated, i.e., + there cannot exist locks on the + page, and a hash index should not be + dropped: it cannot exist */ + ulint z_level,/*!< in: compression level to be used + if dealing with compressed page */ + buf_block_t* block, /*!< in/out: B-tree page */ + dict_index_t* index, /*!< in: the index tree of the page */ + mtr_t* mtr) /*!< in/out: mini-transaction */ + __attribute__((nonnull)); + #ifdef UNIV_BTR_PRINT /*************************************************************//** Prints size info of a B-tree. */ @@ -762,6 +805,60 @@ btr_validate_index( const trx_t* trx) /*!< in: transaction or 0 */ __attribute__((nonnull(1), warn_unused_result)); +#ifdef UNIV_SYNC_DEBUG +/*************************************************************//** +Removes a page from the level list of pages. +@param space in: space where removed +@param zip_size in: compressed page size in bytes, or 0 for uncompressed +@param page in/out: page to remove +@param index in: index tree +@param mtr in/out: mini-transaction */ +# define btr_level_list_remove(space,zip_size,page,index,mtr) \ + btr_level_list_remove_func(space,zip_size,page,index,mtr) +#else /* UNIV_SYNC_DEBUG */ +/*************************************************************//** +Removes a page from the level list of pages. +@param space in: space where removed +@param zip_size in: compressed page size in bytes, or 0 for uncompressed +@param page in/out: page to remove +@param index in: index tree +@param mtr in/out: mini-transaction */ +# define btr_level_list_remove(space,zip_size,page,index,mtr) \ + btr_level_list_remove_func(space,zip_size,page,mtr) +#endif /* UNIV_SYNC_DEBUG */ + +/*************************************************************//** +Removes a page from the level list of pages. */ +UNIV_INTERN +void +btr_level_list_remove_func( +/*=======================*/ + ulint space, /*!< in: space where removed */ + ulint zip_size,/*!< in: compressed page size in bytes + or 0 for uncompressed pages */ + page_t* page, /*!< in/out: page to remove */ +#ifdef UNIV_SYNC_DEBUG + const dict_index_t* index, /*!< in: index tree */ +#endif /* UNIV_SYNC_DEBUG */ + mtr_t* mtr) /*!< in/out: mini-transaction */ + __attribute__((nonnull)); + +/*************************************************************//** +If page is the only on its level, this function moves its records to the +father page, thus reducing the tree height. +@return father block */ +UNIV_INTERN +buf_block_t* +btr_lift_page_up( +/*=============*/ + dict_index_t* index, /*!< in: index tree */ + buf_block_t* block, /*!< in: page which is the only on its level; + must not be empty: use + btr_discard_only_page_on_level if the last + record from the page should be removed */ + mtr_t* mtr) /*!< in: mtr */ + __attribute__((nonnull)); + #define BTR_N_LEAF_PAGES 1 #define BTR_TOTAL_SIZE 2 #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/innobase/include/btr0btr.ic b/storage/innobase/include/btr0btr.ic index 00f50b5dcaf..40b468b200a 100644 --- a/storage/innobase/include/btr0btr.ic +++ b/storage/innobase/include/btr0btr.ic @@ -163,9 +163,10 @@ btr_page_get_next( /*!< in: mini-transaction handle */ { ut_ad(page && mtr); +#ifndef UNIV_INNOCHECKSUM ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX) || mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_S_FIX)); - +#endif /* UNIV_INNOCHECKSUM */ return(mach_read_from_4(page + FIL_PAGE_NEXT)); } diff --git a/storage/innobase/include/btr0defragment.h b/storage/innobase/include/btr0defragment.h new file mode 100644 index 00000000000..8fef3c6519a --- /dev/null +++ b/storage/innobase/include/btr0defragment.h @@ -0,0 +1,101 @@ +/***************************************************************************** + +Copyright (C) 2013, 2014 Facebook, Inc. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +#ifndef btr0defragment_h +#define btr0defragment_h + +#include "univ.i" + +#ifndef UNIV_HOTBACKUP + +#include "btr0pcur.h" + +/* Max number of pages to consider at once during defragmentation. */ +#define BTR_DEFRAGMENT_MAX_N_PAGES 32 + +/** stats in btr_defragment */ +extern ulint btr_defragment_compression_failures; +extern ulint btr_defragment_failures; +extern ulint btr_defragment_count; + +/** Item in the work queue for btr_degrament_thread. */ +struct btr_defragment_item_t +{ + btr_pcur_t* pcur; /* persistent cursor where + btr_defragment_n_pages should start */ + os_event_t event; /* if not null, signal after work + is done */ + bool removed; /* Mark an item as removed */ + ulonglong last_processed; /* timestamp of last time this index + is processed by defragment thread */ + + btr_defragment_item_t(btr_pcur_t* pcur, os_event_t event); + ~btr_defragment_item_t(); +}; + +/******************************************************************//** +Initialize defragmentation. */ +void +btr_defragment_init(void); +/******************************************************************//** +Shutdown defragmentation. */ +void +btr_defragment_shutdown(); +/******************************************************************//** +Check whether the given index is in btr_defragment_wq. */ +bool +btr_defragment_find_index( + dict_index_t* index); /*!< Index to find. */ +/******************************************************************//** +Add an index to btr_defragment_wq. Return a pointer to os_event if this +is a synchronized defragmentation. */ +os_event_t +btr_defragment_add_index( + dict_index_t* index, /*!< index to be added */ + bool async); /*!< whether this is an async defragmentation */ +/******************************************************************//** +When table is dropped, this function is called to mark a table as removed in +btr_efragment_wq. The difference between this function and the remove_index +function is this will not NULL the event. */ +void +btr_defragment_remove_table( + dict_table_t* table); /*!< Index to be removed. */ +/******************************************************************//** +Mark an index as removed from btr_defragment_wq. */ +void +btr_defragment_remove_index( + dict_index_t* index); /*!< Index to be removed. */ +/*********************************************************************//** +Check whether we should save defragmentation statistics to persistent storage.*/ +UNIV_INTERN +void +btr_defragment_save_defrag_stats_if_needed( + dict_index_t* index); /*!< in: index */ +/******************************************************************//** +Thread that merges consecutive b-tree pages into fewer pages to defragment +the index. */ +extern "C" UNIV_INTERN +os_thread_ret_t +DECLARE_THREAD(btr_defragment_thread)( +/*==========================================*/ + void* arg); /*!< in: a dummy parameter required by + os_thread_create */ + + +#endif /* !UNIV_HOTBACKUP */ +#endif diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 2a96f5299bb..7d14df09cb2 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -120,7 +120,9 @@ enum dict_table_op_t { DICT_TABLE_OP_DROP_ORPHAN, /** Silently load the tablespace if it does not exist, and do not load the definitions of incomplete indexes. */ - DICT_TABLE_OP_LOAD_TABLESPACE + DICT_TABLE_OP_LOAD_TABLESPACE, + /** Open the table only if it's in table cache. */ + DICT_TABLE_OP_OPEN_ONLY_IF_CACHED }; /**********************************************************************//** @@ -1496,6 +1498,16 @@ dict_table_get_index_on_name( const char* name) /*!< in: name of the index to find */ __attribute__((nonnull, warn_unused_result)); /**********************************************************************//** +Looks for an index with the given id given a table instance. +@return index or NULL */ +UNIV_INTERN +dict_index_t* +dict_table_find_index_on_id( +/*========================*/ + const dict_table_t* table, /*!< in: table instance */ + index_id_t id) /*!< in: index id */ + __attribute__((nonnull, warn_unused_result)); +/**********************************************************************//** In case there is more than one index with the same name return the index with the min(id). @return index, NULL if does not exist */ diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index 497a3bd86e6..84d5c57f720 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -647,7 +647,7 @@ dict_tf_is_valid( if (atomic_writes) { - if(atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if(atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n" @@ -689,7 +689,7 @@ dict_sys_tables_type_validate( ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(type); ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(type); - ut_a(atomic_writes >= 0 && atomic_writes <= ATOMIC_WRITES_OFF); + ut_a(atomic_writes <= ATOMIC_WRITES_OFF); /* The low order bit of SYS_TABLES.TYPE is always set to 1. If the format is UNIV_FORMAT_B or higher, this field is the same @@ -768,7 +768,7 @@ dict_sys_tables_type_validate( } /* Validate that the atomic writes number is within allowed range. */ - if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if (atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, atomic_writes %lu\n", type, atomic_writes); return(ULINT_UNDEFINED); diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index b5e62e53a72..46f8690fd5f 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -591,6 +591,10 @@ struct zip_pad_info_t { rounds */ }; +/** Number of samples of data size kept when page compression fails for +a certain index.*/ +#define STAT_DEFRAG_DATA_SIZE_N_SAMPLE 10 + /** Data structure for an index. Most fields will be initialized to 0, NULL or FALSE in dict_mem_index_create(). */ struct dict_index_t{ @@ -679,6 +683,23 @@ struct dict_index_t{ /*!< approximate number of leaf pages in the index tree */ /* @} */ + /** Statistics for defragmentation, these numbers are estimations and + could be very inaccurate at certain times, e.g. right after restart, + during defragmentation, etc. */ + /* @{ */ + ulint stat_defrag_modified_counter; + ulint stat_defrag_n_pages_freed; + /* number of pages freed by defragmentation. */ + ulint stat_defrag_n_page_split; + /* number of page splits since last full index + defragmentation. */ + ulint stat_defrag_data_size_sample[STAT_DEFRAG_DATA_SIZE_N_SAMPLE]; + /* data size when compression failure happened + the most recent 10 times. */ + ulint stat_defrag_sample_next_slot; + /* in which slot the next sample should be + saved. */ + /* @} */ rw_lock_t lock; /*!< read-write lock protecting the upper levels of the index tree */ trx_id_t trx_id; /*!< id of the transaction that created this diff --git a/storage/innobase/include/dict0pagecompress.ic b/storage/innobase/include/dict0pagecompress.ic index ea3c7546850..811976434a8 100644 --- a/storage/innobase/include/dict0pagecompress.ic +++ b/storage/innobase/include/dict0pagecompress.ic @@ -122,7 +122,7 @@ dict_tf_get_page_compression_level( { ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags); - ut_ad(page_compression_level >= 0 && page_compression_level <= 9); + ut_ad(page_compression_level <= 9); return(page_compression_level); } diff --git a/storage/innobase/include/dict0priv.h b/storage/innobase/include/dict0priv.h index 9a3c8e22992..e034662aba0 100644 --- a/storage/innobase/include/dict0priv.h +++ b/storage/innobase/include/dict0priv.h @@ -53,8 +53,9 @@ dict_table_t* dict_table_open_on_id_low( /*=====================*/ table_id_t table_id, /*!< in: table id */ - dict_err_ignore_t ignore_err); /*!< in: errors to ignore + dict_err_ignore_t ignore_err, /*!< in: errors to ignore when loading the table */ + ibool open_only_if_in_cache); #ifndef UNIV_NONINL #include "dict0priv.ic" diff --git a/storage/innobase/include/dict0priv.ic b/storage/innobase/include/dict0priv.ic index 30ba8fb60aa..983218af78a 100644 --- a/storage/innobase/include/dict0priv.ic +++ b/storage/innobase/include/dict0priv.ic @@ -74,8 +74,9 @@ dict_table_t* dict_table_open_on_id_low( /*======================*/ table_id_t table_id, /*!< in: table id */ - dict_err_ignore_t ignore_err) /*!< in: errors to ignore + dict_err_ignore_t ignore_err, /*!< in: errors to ignore when loading the table */ + ibool open_only_if_in_cache) { dict_table_t* table; ulint fold; @@ -88,7 +89,7 @@ dict_table_open_on_id_low( HASH_SEARCH(id_hash, dict_sys->table_id_hash, fold, dict_table_t*, table, ut_ad(table->cached), table->id == table_id); - if (table == NULL) { + if (table == NULL && !open_only_if_in_cache) { table = dict_load_table_on_id(table_id, ignore_err); } diff --git a/storage/innobase/include/dict0stats.h b/storage/innobase/include/dict0stats.h index 186f90e3694..abf56b2f0c7 100644 --- a/storage/innobase/include/dict0stats.h +++ b/storage/innobase/include/dict0stats.h @@ -195,6 +195,39 @@ dict_stats_rename_table( is returned */ size_t errstr_sz); /*!< in: errstr size */ +/*********************************************************************//** +Save defragmentation result. +@return DB_SUCCESS or error code */ +UNIV_INTERN +dberr_t +dict_stats_save_defrag_summary( + dict_index_t* index); /*!< in: index */ + +/*********************************************************************//** +Save defragmentation stats for a given index. +@return DB_SUCCESS or error code */ +UNIV_INTERN +dberr_t +dict_stats_save_defrag_stats( + dict_index_t* index); /*!< in: index */ + +/**********************************************************************//** +Clear defragmentation summary. */ +UNIV_INTERN +void +dict_stats_empty_defrag_summary( +/*==================*/ + dict_index_t* index); /*!< in: index to clear defragmentation stats */ + +/**********************************************************************//** +Clear defragmentation related index stats. */ +UNIV_INTERN +void +dict_stats_empty_defrag_stats( +/*==================*/ + dict_index_t* index); /*!< in: index to clear defragmentation stats */ + + #ifndef UNIV_NONINL #include "dict0stats.ic" #endif diff --git a/storage/innobase/include/dict0stats_bg.h b/storage/innobase/include/dict0stats_bg.h index e866ab419fe..32fac3015e8 100644 --- a/storage/innobase/include/dict0stats_bg.h +++ b/storage/innobase/include/dict0stats_bg.h @@ -56,6 +56,28 @@ dict_stats_recalc_pool_del( /*=======================*/ const dict_table_t* table); /*!< in: table to remove */ +/*****************************************************************//** +Add an index in a table to the defrag pool, which is processed by the +background stats gathering thread. Only the table id and index id are +added to the list, so the table can be closed after being enqueued and +it will be opened when needed. If the table or index does not exist later +(has been DROPped), then it will be removed from the pool and skipped. */ +UNIV_INTERN +void +dict_stats_defrag_pool_add( +/*=======================*/ + const dict_index_t* index); /*!< in: table to add */ + +/*****************************************************************//** +Delete a given index from the auto defrag pool. */ +UNIV_INTERN +void +dict_stats_defrag_pool_del( +/*=======================*/ + const dict_table_t* table, /*!<in: if given, remove + all entries for the table */ + const dict_index_t* index); /*!< in: index to remove */ + /** Yield the data dictionary latch when waiting for the background thread to stop accessing a table. @param trx transaction holding the data dictionary locks */ diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 1e5a2ed1caa..bb4cfe8fe92 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1076,7 +1076,7 @@ fil_space_name( /*******************************************************************//** Return page type name */ -char* +const char* fil_get_page_type_name( /*===================*/ ulint page_type); /*!< in: FIL_PAGE_TYPE */ diff --git a/storage/innobase/include/fsp0fsp.ic b/storage/innobase/include/fsp0fsp.ic index fb253370b6e..3a3eb21a61a 100644 --- a/storage/innobase/include/fsp0fsp.ic +++ b/storage/innobase/include/fsp0fsp.ic @@ -131,7 +131,7 @@ fsp_flags_is_valid( } } - if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if (atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted atomic_writes %lu\n", flags, atomic_writes); return (false); diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index 385853bdb68..b62453de15f 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -181,6 +181,16 @@ lock_update_merge_left( const buf_block_t* right_block); /*!< in: merged index page which will be discarded */ /*************************************************************//** +Updates the lock table when a page is splited and merged to +two pages. */ +UNIV_INTERN +void +lock_update_split_and_merge( + const buf_block_t* left_block, /*!< in: left page to which merged */ + const rec_t* orig_pred, /*!< in: original predecessor of + supremum on the left page before merge*/ + const buf_block_t* right_block);/*!< in: right page from which merged */ +/*************************************************************//** Resets the original locks on heir and replaces them with gap type locks inherited from rec. */ UNIV_INTERN diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index a1da2ee03b1..a4aa3eb4bf3 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -339,6 +339,15 @@ extern my_bool srv_random_read_ahead; extern ulong srv_read_ahead_threshold; extern ulint srv_n_read_io_threads; extern ulint srv_n_write_io_threads; +/* Defragmentation, Origianlly facebook default value is 100, but it's too high */ +#define SRV_DEFRAGMENT_FREQUENCY_DEFAULT 40 +extern my_bool srv_defragment; +extern uint srv_defragment_n_pages; +extern uint srv_defragment_stats_accuracy; +extern uint srv_defragment_fill_factor_n_recs; +extern double srv_defragment_fill_factor; +extern uint srv_defragment_frequency; +extern ulonglong srv_defragment_interval; /* Number of IO operations per second the server can do */ extern ulong srv_io_capacity; @@ -892,7 +901,12 @@ struct export_var_t{ ulint innodb_rows_deleted; /*!< srv_n_rows_deleted */ ulint innodb_num_open_files; /*!< fil_n_file_opened */ ulint innodb_truncated_status_writes; /*!< srv_truncated_status_writes */ - ulint innodb_available_undo_logs; /*!< srv_available_undo_logs */ + ulint innodb_available_undo_logs; /*!< srv_available_undo_logs + */ + ulint innodb_defragment_compression_failures; + ulint innodb_defragment_failures; + ulint innodb_defragment_count; + #ifdef UNIV_DEBUG ulint innodb_purge_trx_id_age; /*!< rw_max_trx_id - purged trx_id */ ulint innodb_purge_view_trx_id_age; /*!< rw_max_trx_id diff --git a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h index 7b00e16476b..f26e66f1a87 100644 --- a/storage/innobase/include/sync0sync.h +++ b/storage/innobase/include/sync0sync.h @@ -687,6 +687,7 @@ or row lock! */ #define SYNC_EXTERN_STORAGE 500 #define SYNC_FSP 400 #define SYNC_FSP_PAGE 395 +#define SYNC_STATS_DEFRAG 390 /*------------------------------------- Change buffer headers */ #define SYNC_IBUF_MUTEX 370 /* ibuf_mutex */ /*------------------------------------- Change buffer tree */ diff --git a/storage/innobase/include/ut0timer.h b/storage/innobase/include/ut0timer.h new file mode 100644 index 00000000000..f361ae79bf5 --- /dev/null +++ b/storage/innobase/include/ut0timer.h @@ -0,0 +1,104 @@ +/***************************************************************************** + +Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. +Copyright (c) 2014, SkySQL Ab. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +/********************************************************************//** +@file include/ut0timer.h +Timer rountines + +Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com +modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 +*************************************************************************/ +#ifndef ut0timer_h +#define ut0timer_h + +#include "univ.i" +#include "data0type.h" +#include <my_rdtsc.h> + +/* Current timer stats */ +extern struct my_timer_unit_info ut_timer; + +/**************************************************************//** +Function pointer to point selected timer function. +@return timer current value */ +extern ulonglong (*ut_timer_now)(void); + +/**************************************************************//** +Sets up the data required for use of my_timer_* functions. +Selects the best timer by high frequency, and tight resolution. +Points my_timer_now() to the selected timer function. +Initializes my_timer struct to contain the info for selected timer.*/ +UNIV_INTERN +void ut_init_timer(void); + +/**************************************************************//** +Return time passed since time then, automatically adjusted +for the estimated timer overhead. +@return time passed since "then" */ +UNIV_INLINE +ulonglong +ut_timer_since( +/*===========*/ + ulonglong then); /*!< in: time where to calculate */ +/**************************************************************//** +Get time passed since "then", and update then to now +@return time passed sinche "then" */ +UNIV_INLINE +ulonglong +ut_timer_since_and_update( +/*======================*/ + ulonglong *then); /*!< in: time where to calculate */ +/**************************************************************//** +Convert native timer units in a ulonglong into seconds in a double +@return time in a seconds */ +UNIV_INLINE +double +ut_timer_to_seconds( +/*=================*/ + ulonglong when); /*!< in: time where to calculate */ +/**************************************************************//** +Convert native timer units in a ulonglong into milliseconds in a double +@return time in milliseconds */ +UNIV_INLINE +double +ut_timer_to_milliseconds( +/*=====================*/ + ulonglong when); /*!< in: time where to calculate */ +/**************************************************************//** +Convert native timer units in a ulonglong into microseconds in a double +@return time in microseconds */ +UNIV_INLINE +double +ut_timer_to_microseconds( +/*=====================*/ + ulonglong when); /*!< in: time where to calculate */ +/**************************************************************//** +Convert microseconds in a double to native timer units in a ulonglong +@return time in microseconds */ +UNIV_INLINE +ulonglong +ut_microseconds_to_timer( +/*=====================*/ + ulonglong when); /*!< in: time where to calculate */ + +#ifndef UNIV_NONINL +#include "ut0timer.ic" +#endif + +#endif diff --git a/storage/innobase/include/ut0timer.ic b/storage/innobase/include/ut0timer.ic new file mode 100644 index 00000000000..027e89c6279 --- /dev/null +++ b/storage/innobase/include/ut0timer.ic @@ -0,0 +1,113 @@ +/***************************************************************************** + +Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. +Copyright (c) 2014, SkySQL Ab. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +/********************************************************************//** +@file include/ut0timer.ic +Timer rountines + +Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com +modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 +*************************************************************************/ + +/**************************************************************//** +Return time passed since time then, automatically adjusted +for the estimated timer overhead. +@return time passed since "then" */ +UNIV_INLINE +ulonglong +ut_timer_since( +/*===========*/ + ulonglong then) /*!< in: time where to calculate */ +{ + return (ut_timer_now() - then) - ut_timer.overhead; +} + +/**************************************************************//** +Get time passed since "then", and update then to now +@return time passed sinche "then" */ +UNIV_INLINE +ulonglong +ut_timer_since_and_update( +/*======================*/ + ulonglong *then) /*!< in: time where to calculate */ +{ + ulonglong now = ut_timer_now(); + ulonglong ret = (now - (*then)) - ut_timer.overhead; + *then = now; + return ret; +} + +/**************************************************************//** +Convert native timer units in a ulonglong into seconds in a double +@return time in a seconds */ +UNIV_INLINE +double +ut_timer_to_seconds( +/*=================*/ + ulonglong when) /*!< in: time where to calculate */ +{ + double ret = (double)(when); + ret /= (double)(ut_timer.frequency); + return ret; +} + +/**************************************************************//** +Convert native timer units in a ulonglong into milliseconds in a double +@return time in milliseconds */ +UNIV_INLINE +double +ut_timer_to_milliseconds( +/*=====================*/ + ulonglong when) /*!< in: time where to calculate */ +{ + double ret = (double)(when); + ret *= 1000.0; + ret /= (double)(ut_timer.frequency); + return ret; +} + +/**************************************************************//** +Convert native timer units in a ulonglong into microseconds in a double +@return time in microseconds */ +UNIV_INLINE +double +ut_timer_to_microseconds( +/*=====================*/ + ulonglong when) /*!< in: time where to calculate */ +{ + double ret = (double)(when); + ret *= 1000000.0; + ret /= (double)(ut_timer.frequency); + return ret; +} + +/**************************************************************//** +Convert microseconds in a double to native timer units in a ulonglong +@return time in microseconds */ +UNIV_INLINE +ulonglong +ut_microseconds_to_timer( +/*=====================*/ + ulonglong when) /*!< in: time where to calculate */ +{ + double ret = when; + ret *= (double)(ut_timer.frequency); + ret /= 1000000.0; + return (ulonglong)ret; +} diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index ce107dda077..fbac412c4e8 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -3566,6 +3566,47 @@ lock_update_merge_left( } /*************************************************************//** +Updates the lock table when a page is split and merged to +two pages. */ +UNIV_INTERN +void +lock_update_split_and_merge( + const buf_block_t* left_block, /*!< in: left page to which merged */ + const rec_t* orig_pred, /*!< in: original predecessor of + supremum on the left page before merge*/ + const buf_block_t* right_block) /*!< in: right page from which merged */ +{ + const rec_t* left_next_rec; + + ut_a(left_block && right_block); + ut_a(orig_pred); + + lock_mutex_enter(); + + left_next_rec = page_rec_get_next_const(orig_pred); + + /* Inherit the locks on the supremum of the left page to the + first record which was moved from the right page */ + lock_rec_inherit_to_gap( + left_block, left_block, + page_rec_get_heap_no(left_next_rec), + PAGE_HEAP_NO_SUPREMUM); + + /* Reset the locks on the supremum of the left page, + releasing waiting transactions */ + lock_rec_reset_and_release_wait(left_block, + PAGE_HEAP_NO_SUPREMUM); + + /* Inherit the locks to the supremum of the left page from the + successor of the infimum on the right page */ + lock_rec_inherit_to_gap(left_block, right_block, + PAGE_HEAP_NO_SUPREMUM, + lock_get_min_heap_no(right_block)); + + lock_mutex_exit(); +} + +/*************************************************************//** Resets the original locks on heir and replaces them with gap type locks inherited from rec. */ UNIV_INTERN diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index fd9e60d123b..971ff14e45c 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -809,15 +809,18 @@ os_file_handle_error_cond_exit( to the log. */ if (should_exit || !on_error_silent) { + fprintf(stderr, + " InnoDB: Operation %s to file %s and at line %ld\n", + operation, file, line); + } + + if (should_exit || !on_error_silent) { ib_logf(IB_LOG_LEVEL_ERROR, "File %s: '%s' returned OS " "error " ULINTPF ".%s", name ? name : "(unknown)", operation, err, should_exit ? " Cannot continue operation" : ""); } - fprintf(stderr, - " InnoDB: at file %s and at line %ld\n", file, line); - if (should_exit) { exit(1); } diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index f5f7e1299ce..97405261392 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -1349,6 +1349,21 @@ page_cur_insert_rec_zip( return(insert_rec); } + /* Page compress failed. If this happened on a + leaf page, put the data size into the sample + buffer. */ + if (page_is_leaf(page)) { + ulint occupied = page_get_data_size(page) + + page_dir_calc_reserved_space( + page_get_n_recs(page)); + index->stat_defrag_data_size_sample[ + index->stat_defrag_sample_next_slot] = + occupied; + index->stat_defrag_sample_next_slot = + (index->stat_defrag_sample_next_slot + + 1) % STAT_DEFRAG_DATA_SIZE_N_SAMPLE; + } + ut_ad(cursor->rec == (pos > 1 ? page_rec_get_nth( diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index ab97b5a9f28..d9e0dc709be 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -2100,6 +2100,7 @@ row_merge( /* Copy the last blocks, if there are any. */ while (foffs0 < ihalf) { + if (UNIV_UNLIKELY(trx_is_interrupted(trx))) { return(DB_INTERRUPTED); } @@ -2116,6 +2117,7 @@ row_merge( ut_ad(foffs0 == ihalf); while (foffs1 < file->offset) { + if (trx_is_interrupted(trx)) { return(DB_INTERRUPTED); } @@ -2175,6 +2177,7 @@ row_merge_sort( { const ulint half = file->offset / 2; ulint num_runs; + ulint cur_run = 0; ulint* run_offset; dberr_t error = DB_SUCCESS; DBUG_ENTER("row_merge_sort"); @@ -2198,8 +2201,16 @@ row_merge_sort( of file marker). Thus, it must be at least one block. */ ut_ad(file->offset > 0); + thd_progress_init(trx->mysql_thd, num_runs); + /* Merge the runs until we have one big run */ do { + cur_run++; + + /* Report progress of merge sort to MySQL for + show processlist progress field */ + thd_progress_report(trx->mysql_thd, cur_run, num_runs); + error = row_merge(trx, dup, file, block, tmpfd, &num_runs, run_offset); @@ -2212,6 +2223,8 @@ row_merge_sort( mem_free(run_offset); + thd_progress_end(trx->mysql_thd); + DBUG_RETURN(error); } diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 93d13ea49ee..8def475e1f9 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -54,6 +54,7 @@ Created 9/17/2000 Heikki Tuuri #include "rem0cmp.h" #include "log0log.h" #include "btr0sea.h" +#include "btr0defragment.h" #include "fil0fil.h" #include "ibuf0ibuf.h" #include "fts0fts.h" @@ -3843,6 +3844,8 @@ row_drop_table_for_mysql( if (!dict_table_is_temporary(table)) { dict_stats_recalc_pool_del(table); + dict_stats_defrag_pool_del(table, NULL); + btr_defragment_remove_table(table); /* Remove stats for this table and all of its indexes from the persistent storage if it exists and if there are stats for this @@ -5128,18 +5131,6 @@ end: trx->error_state = DB_SUCCESS; trx_rollback_to_savepoint(trx, NULL); trx->error_state = DB_SUCCESS; - } else { - if (old_is_tmp && !new_is_tmp) { - /* After ALTER TABLE the table statistics - needs to be rebuilt. Even if we close - table below there could be other - transactions using this table (e.g. - SELECT * FROM INFORMATION_SCHEMA.`TABLE_CONSTRAINTS`), - thus we can't remove table from dictionary cache - here. Therefore, we initialize the - transient statistics here. */ - dict_stats_update_transient(table); - } } } diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index ba742c7238c..f76056dc71c 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -68,6 +68,7 @@ Created 10/8/1995 Heikki Tuuri #include "os0sync.h" /* for HAVE_ATOMIC_BUILTINS */ #include "srv0mon.h" #include "ut0crc32.h" +#include "btr0defragment.h" #include "mysql/plugin.h" #include "mysql/service_thd_wait.h" @@ -404,6 +405,15 @@ UNIV_INTERN ib_uint64_t srv_page_compressed_trim_op = 0; UNIV_INTERN ib_uint64_t srv_page_compressed_trim_op_saved = 0; UNIV_INTERN ib_uint64_t srv_index_page_decompressed = 0; +/* Defragmentation */ +UNIV_INTERN my_bool srv_defragment = FALSE; +UNIV_INTERN uint srv_defragment_n_pages = 7; +UNIV_INTERN uint srv_defragment_stats_accuracy = 0; +UNIV_INTERN uint srv_defragment_fill_factor_n_recs = 20; +UNIV_INTERN double srv_defragment_fill_factor = 0.9; +UNIV_INTERN uint srv_defragment_frequency = + SRV_DEFRAGMENT_FREQUENCY_DEFAULT; +UNIV_INTERN ulonglong srv_defragment_interval = 0; /* Set the following to 0 if you want InnoDB to write messages on stderr on startup/shutdown. */ @@ -1508,6 +1518,11 @@ srv_export_innodb_status(void) export_vars.innodb_page_compressed_trim_op_saved = srv_stats.page_compressed_trim_op_saved; export_vars.innodb_pages_page_decompressed = srv_stats.pages_page_decompressed; + export_vars.innodb_defragment_compression_failures = + btr_defragment_compression_failures; + export_vars.innodb_defragment_failures = btr_defragment_failures; + export_vars.innodb_defragment_count = btr_defragment_count; + #ifdef UNIV_DEBUG rw_lock_s_lock(&purge_sys->latch); trx_id_t done_trx_no = purge_sys->done.trx_no; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index ece16c6bd70..6a02b08c3b7 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -43,6 +43,7 @@ Created 2/16/1996 Heikki Tuuri #include "pars0pars.h" #include "row0ftsort.h" #include "ut0mem.h" +#include "ut0timer.h" #include "mem0mem.h" #include "data0data.h" #include "data0type.h" @@ -67,6 +68,8 @@ Created 2/16/1996 Heikki Tuuri #include "ibuf0ibuf.h" #include "srv0start.h" #include "srv0srv.h" +#include "btr0defragment.h" + #ifndef UNIV_HOTBACKUP # include "trx0rseg.h" # include "os0proc.h" @@ -1531,6 +1534,9 @@ innobase_start_or_create_for_mysql(void) char* logfile0 = NULL; size_t dirnamelen; + /* This should be initialized early */ + ut_init_timer(); + if (srv_force_recovery > SRV_FORCE_NO_TRX_UNDO) { srv_read_only_mode = true; } @@ -2877,6 +2883,9 @@ files_checked: fts_optimize_init(); } + /* Initialize online defragmentation. */ + btr_defragment_init(); + srv_was_started = TRUE; return(DB_SUCCESS); diff --git a/storage/innobase/sync/sync0sync.cc b/storage/innobase/sync/sync0sync.cc index 5ef8a02fb3f..3532f513646 100644 --- a/storage/innobase/sync/sync0sync.cc +++ b/storage/innobase/sync/sync0sync.cc @@ -1164,6 +1164,7 @@ sync_thread_add_level( case SYNC_IBUF_MUTEX: case SYNC_INDEX_ONLINE_LOG: case SYNC_STATS_AUTO_RECALC: + case SYNC_STATS_DEFRAG: if (!sync_thread_levels_g(array, level, TRUE)) { fprintf(stderr, "InnoDB: sync_thread_levels_g(array, %lu)" diff --git a/storage/innobase/ut/ut0timer.cc b/storage/innobase/ut/ut0timer.cc new file mode 100644 index 00000000000..85292cce28c --- /dev/null +++ b/storage/innobase/ut/ut0timer.cc @@ -0,0 +1,92 @@ +/***************************************************************************** + +Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. +Copyright (c) 2014, SkySQL Ab. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +/********************************************************************//** +@file ut/ut0timer.cc +Timer rountines + +Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com +modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 +*************************************************************************/ + +#include "data0type.h" +#include <my_rdtsc.h> +#include <ut0timer.h> + +/**************************************************************//** +Initial timer definition +@return 0 */ +static +ulonglong +ut_timer_none(void) +/*===============*/ +{ + return 0; +} + +/**************************************************************//** +Function pointer to point selected timer function. +@return timer current value */ +ulonglong (*ut_timer_now)(void) = &ut_timer_none; + +struct my_timer_unit_info ut_timer; + +/**************************************************************//** +Sets up the data required for use of my_timer_* functions. +Selects the best timer by high frequency, and tight resolution. +Points my_timer_now() to the selected timer function. +Initializes my_timer struct to contain the info for selected timer.*/ +UNIV_INTERN +void +ut_init_timer(void) +/*===============*/ +{ + MY_TIMER_INFO all_timer_info; + my_timer_init(&all_timer_info); + + if (all_timer_info.cycles.frequency > 1000000 && + all_timer_info.cycles.resolution == 1) { + ut_timer = all_timer_info.cycles; + ut_timer_now = &my_timer_cycles; + } else if (all_timer_info.nanoseconds.frequency > 1000000 && + all_timer_info.nanoseconds.resolution == 1) { + ut_timer = all_timer_info.nanoseconds; + ut_timer_now = &my_timer_nanoseconds; + } else if (all_timer_info.microseconds.frequency >= 1000000 && + all_timer_info.microseconds.resolution == 1) { + ut_timer = all_timer_info.microseconds; + ut_timer_now = &my_timer_microseconds; + + } else if (all_timer_info.milliseconds.frequency >= 1000 && + all_timer_info.milliseconds.resolution == 1) { + ut_timer = all_timer_info.milliseconds; + ut_timer_now = &my_timer_milliseconds; + } else if (all_timer_info.ticks.frequency >= 1000 && + /* Will probably be false */ + all_timer_info.ticks.resolution == 1) { + ut_timer = all_timer_info.ticks; + ut_timer_now = &my_timer_ticks; + } else { + /* None are acceptable, so leave it as "None", and fill in struct */ + ut_timer.frequency = 1; /* Avoid div-by-zero */ + ut_timer.overhead = 0; /* Since it doesn't do anything */ + ut_timer.resolution = 10; /* Another sign it's bad */ + ut_timer.routine = 0; /* None */ + } +} diff --git a/storage/perfschema/CMakeLists.txt b/storage/perfschema/CMakeLists.txt index aaa1142a180..870702afb48 100644 --- a/storage/perfschema/CMakeLists.txt +++ b/storage/perfschema/CMakeLists.txt @@ -135,7 +135,6 @@ pfs.cc pfs_account.cc pfs_atomic.cc pfs_autosize.cc -pfs_check.cc pfs_column_values.cc pfs_con_slice.cc pfs_defaults.cc diff --git a/storage/perfschema/ha_perfschema.cc b/storage/perfschema/ha_perfschema.cc index 58db8dc0031..8d41ff1711d 100644 --- a/storage/perfschema/ha_perfschema.cc +++ b/storage/perfschema/ha_perfschema.cc @@ -71,6 +71,23 @@ find_table_share(const char *db, const char *name) DBUG_RETURN(result); } +static int pfs_discover_table(handlerton *hton, THD *thd, TABLE_SHARE *share) +{ + const PFS_engine_table_share *pfs_share; + + if ((pfs_share= find_table_share(share->db.str, share->table_name.str))) + return share->init_from_sql_statement_string(thd, false, + pfs_share->sql.str, + pfs_share->sql.length); + return HA_ERR_NO_SUCH_TABLE; +} + +static int pfs_discover_table_existence(handlerton *hton, const char *db, + const char *table_name) +{ + return MY_TEST(find_table_share(db, table_name)); +} + static int pfs_init_func(void *p) { DBUG_ENTER("pfs_init_func"); @@ -99,6 +116,9 @@ static int pfs_init_func(void *p) the performance schema. See Bug#43039. */ pfs_hton->db_type= DB_TYPE_PERFORMANCE_SCHEMA; + pfs_hton->discover_table= pfs_discover_table; + pfs_hton->discover_table_existence= pfs_discover_table_existence; + pfs_hton->discover_table_names= pfs_discover_table_names; PFS_engine_table_share::init_all_locks(); @@ -438,25 +458,10 @@ int ha_perfschema::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { DBUG_ENTER("ha_perfschema::create"); - DBUG_ASSERT(table_arg); - DBUG_ASSERT(table_arg->s); - if (find_table_share(table_arg->s->db.str, - table_arg->s->table_name.str)) - { - /* - Attempting to create a known performance schema table. - Allowing the create, to create .FRM files, - for the initial database install, and mysql_upgrade. - This should fail once .FRM are removed. - */ - DBUG_RETURN(0); - } /* This is not a general purpose engine. Failure to CREATE TABLE is the expected result. */ - DBUG_PRINT("error", ("unknown table: %s.%s", table_arg->s->db.str, - table_arg->s->table_name.str)); DBUG_RETURN(HA_ERR_WRONG_COMMAND); } diff --git a/storage/perfschema/pfs_check.cc b/storage/perfschema/pfs_check.cc deleted file mode 100644 index c8800e7ec96..00000000000 --- a/storage/perfschema/pfs_check.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ - -/** - @file storage/perfschema/pfs_check.cc - Check the performance schema table structure. - The code in this file is implemented in pfs_check.cc - instead of pfs_server.cc, to separate dependencies to server - structures (THD, ...) in a dedicated file. - This code organization helps a lot maintenance of the unit tests. -*/ - -#include "my_global.h" -#include "pfs_server.h" -#include "pfs_engine_table.h" - -/* -*/ - -/** - Check that the performance schema tables - have the expected structure. - Discrepancies are written in the server log, - but are not considered fatal, so this function does not - return an error code: - - some differences are compatible, and should not cause a failure - - some differences are not compatible, but then the DBA needs an operational - server to be able to DROP+CREATE the tables with the proper structure, - as part of the initial server installation or during an upgrade. - In case of discrepancies, later attempt to perform DML against - the performance schema will be rejected with an error. -*/ -void check_performance_schema() -{ - DBUG_ENTER("check_performance_schema"); - - THD *thd= new THD(); - if (thd == NULL) - DBUG_VOID_RETURN; - - thd->thread_stack= (char*) &thd; - thd->store_globals(); - - PFS_engine_table_share::check_all_tables(thd); - - thd->reset_globals(); - delete thd; - DBUG_VOID_RETURN; -} - diff --git a/storage/perfschema/pfs_engine_table.cc b/storage/perfschema/pfs_engine_table.cc index 958a2bdd7bd..c132f82f681 100644 --- a/storage/perfschema/pfs_engine_table.cc +++ b/storage/perfschema/pfs_engine_table.cc @@ -151,91 +151,6 @@ static PFS_engine_table_share *all_shares[]= NULL }; -/** - Check all the tables structure. - @param thd current thread -*/ -void PFS_engine_table_share::check_all_tables(THD *thd) -{ - PFS_engine_table_share **current; - - DBUG_EXECUTE_IF("tampered_perfschema_table1", - { - /* Hack SETUP_INSTRUMENT, incompatible change. */ - all_shares[20]->m_field_def->count++; - }); - - for (current= &all_shares[0]; (*current) != NULL; current++) - (*current)->check_one_table(thd); -} - -/** Error reporting for schema integrity checks. */ -class PFS_check_intact : public Table_check_intact -{ -protected: - virtual void report_error(uint code, const char *fmt, ...); - -public: - PFS_check_intact() - {} - - ~PFS_check_intact() - {} -}; - -void PFS_check_intact::report_error(uint code, const char *fmt, ...) -{ - va_list args; - char buff[MYSQL_ERRMSG_SIZE]; - - va_start(args, fmt); - my_vsnprintf(buff, sizeof(buff), fmt, args); - va_end(args); - - /* - This is an install/upgrade issue: - - do not report it in the user connection, there is none in main(), - - report it in the server error log. - */ - sql_print_error("%s", buff); -} - -/** - Check integrity of the actual table schema. - The actual table schema (.frm) is compared to the expected schema. - @param thd current thread -*/ -void PFS_engine_table_share::check_one_table(THD *thd) -{ - TABLE_LIST tables; - - tables.init_one_table(PERFORMANCE_SCHEMA_str.str, - PERFORMANCE_SCHEMA_str.length, - m_name.str, m_name.length, - m_name.str, TL_READ); - - /* Work around until Bug#32115 is backported. */ - LEX dummy_lex; - LEX *old_lex= thd->lex; - thd->lex= &dummy_lex; - lex_start(thd); - - if (! open_and_lock_tables(thd, &tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) - { - PFS_check_intact checker; - - if (!checker.check(tables.table, m_field_def)) - m_checked= true; - close_thread_tables(thd); - } - else - sql_print_error(ER(ER_WRONG_NATIVE_TABLE_STRUCTURE), - PERFORMANCE_SCHEMA_str.str, m_name.str); - - lex_end(&dummy_lex); - thd->lex= old_lex; -} - /** Initialize all the table share locks. */ void PFS_engine_table_share::init_all_locks(void) { @@ -268,15 +183,6 @@ int PFS_engine_table_share::write_row(TABLE *table, unsigned char *buf, { my_bitmap_map *org_bitmap; - /* - Make sure the table structure is as expected before mapping - hard wired columns in m_write_row. - */ - if (! m_checked) - { - return HA_ERR_TABLE_NEEDS_UPGRADE; - } - if (m_write_row == NULL) { return HA_ERR_WRONG_COMMAND; @@ -347,15 +253,6 @@ int PFS_engine_table::read_row(TABLE *table, Field *f; Field **fields_reset; - /* - Make sure the table structure is as expected before mapping - hard wired columns in read_row_values. - */ - if (! m_share_ptr->m_checked) - { - return HA_ERR_TABLE_NEEDS_UPGRADE; - } - /* We must read all columns in case a table is opened for update */ bool read_all= !bitmap_is_clear_all(table->write_set); @@ -392,15 +289,6 @@ int PFS_engine_table::update_row(TABLE *table, { my_bitmap_map *org_bitmap; - /* - Make sure the table structure is as expected before mapping - hard wired columns in update_row_values. - */ - if (! m_share_ptr->m_checked) - { - return HA_ERR_TABLE_NEEDS_UPGRADE; - } - /* We internally read from Fields to support the write interface */ org_bitmap= dbug_tmp_use_all_columns(table, table->read_set); int result= update_row_values(table, old_buf, new_buf, fields); @@ -415,15 +303,6 @@ int PFS_engine_table::delete_row(TABLE *table, { my_bitmap_map *org_bitmap; - /* - Make sure the table structure is as expected before mapping - hard wired columns in delete_row_values. - */ - if (! m_share_ptr->m_checked) - { - return HA_ERR_TABLE_NEEDS_UPGRADE; - } - /* We internally read from Fields to support the delete interface */ org_bitmap= dbug_tmp_use_all_columns(table, table->read_set); int result= delete_row_values(table, buf, fields); @@ -1440,5 +1319,18 @@ end: DBUG_RETURN(false); } +int pfs_discover_table_names(handlerton *hton __attribute__((unused)), + LEX_STRING *db, + MY_DIR *dir __attribute__((unused)), + handlerton::discovered_list *result) +{ + if (compare_table_names(db->str, PERFORMANCE_SCHEMA_str.str)) + return 0; + for (size_t i= 0; i < array_elements(all_shares) - 1; i++) + result->add_table(all_shares[i]->m_name.str, + all_shares[i]->m_name.length); + return 0; +} + /** @} */ diff --git a/storage/perfschema/pfs_engine_table.h b/storage/perfschema/pfs_engine_table.h index 981d72ee19e..2bbf8891420 100644 --- a/storage/perfschema/pfs_engine_table.h +++ b/storage/perfschema/pfs_engine_table.h @@ -212,8 +212,6 @@ typedef ha_rows (*pfs_get_row_count_t)(void); */ struct PFS_engine_table_share { - static void check_all_tables(THD *thd); - void check_one_table(THD *thd); static void init_all_locks(void); static void delete_all_locks(void); /** Get the row count. */ @@ -244,10 +242,8 @@ struct PFS_engine_table_share uint m_ref_length; /** The lock, stored on behalf of the SQL layer. */ THR_LOCK *m_thr_lock_ptr; - /** Table fields definition. */ - TABLE_FIELD_DEF *m_field_def; - /** Schema integrity flag. */ - bool m_checked; + /** Table definition. */ + LEX_STRING sql; }; /** @@ -461,5 +457,9 @@ struct PFS_triple_index bool pfs_show_status(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat); +int pfs_discover_table_names(handlerton *hton, LEX_STRING *db, + MY_DIR *dir, + handlerton::discovered_list *result); + /** @} */ #endif diff --git a/storage/perfschema/pfs_server.h b/storage/perfschema/pfs_server.h index 606a814c168..83e0d3ba9fa 100644 --- a/storage/perfschema/pfs_server.h +++ b/storage/perfschema/pfs_server.h @@ -231,8 +231,6 @@ void pfs_automated_sizing(PFS_global_param *param); */ void initialize_performance_schema_acl(bool bootstrap); -void check_performance_schema(); - /** Initialize the dynamic array holding individual instrument settings collected from the server configuration options. diff --git a/storage/perfschema/table_accounts.cc b/storage/perfschema/table_accounts.cc index eb14a0fe481..be18e0b7ce8 100644 --- a/storage/perfschema/table_accounts.cc +++ b/storage/perfschema/table_accounts.cc @@ -23,34 +23,6 @@ THR_LOCK table_accounts::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("USER") }, - { C_STRING_WITH_LEN("char(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("HOST") }, - { C_STRING_WITH_LEN("char(60)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("CURRENT_CONNECTIONS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TOTAL_CONNECTIONS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_accounts::m_field_def= -{ 4, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_accounts::m_share= { @@ -63,8 +35,11 @@ table_accounts::m_share= 1000, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE accounts(" + "USER CHAR(16) collate utf8_bin default null," + "HOST CHAR(60) collate utf8_bin default null," + "CURRENT_CONNECTIONS bigint not null," + "TOTAL_CONNECTIONS bigint not null)") } }; PFS_engine_table* table_accounts::create() diff --git a/storage/perfschema/table_accounts.h b/storage/perfschema/table_accounts.h index 232cb9d9b36..4c1932641d2 100644 --- a/storage/perfschema/table_accounts.h +++ b/storage/perfschema/table_accounts.h @@ -67,8 +67,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_accounts m_row; diff --git a/storage/perfschema/table_esgs_by_account_by_event_name.cc b/storage/perfschema/table_esgs_by_account_by_event_name.cc index 4f0fc6858f9..a565cbb49bd 100644 --- a/storage/perfschema/table_esgs_by_account_by_event_name.cc +++ b/storage/perfschema/table_esgs_by_account_by_event_name.cc @@ -29,54 +29,6 @@ THR_LOCK table_esgs_by_account_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("USER") }, - { C_STRING_WITH_LEN("char(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("HOST") }, - { C_STRING_WITH_LEN("char(60)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esgs_by_account_by_event_name::m_field_def= -{ 8, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esgs_by_account_by_event_name::m_share= { @@ -89,8 +41,15 @@ table_esgs_by_account_by_event_name::m_share= 1000, /* records */ sizeof(pos_esgs_by_account_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_stages_summary_by_account_by_event_name(" + "USER CHAR(16) collate utf8_bin default null," + "HOST CHAR(60) collate utf8_bin default null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esgs_by_account_by_event_name.h b/storage/perfschema/table_esgs_by_account_by_event_name.h index 2cd51783db1..531c4874557 100644 --- a/storage/perfschema/table_esgs_by_account_by_event_name.h +++ b/storage/perfschema/table_esgs_by_account_by_event_name.h @@ -108,8 +108,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esgs_by_account_by_event_name m_row; diff --git a/storage/perfschema/table_esgs_by_host_by_event_name.cc b/storage/perfschema/table_esgs_by_host_by_event_name.cc index 904f0e21b3c..76e60b32a80 100644 --- a/storage/perfschema/table_esgs_by_host_by_event_name.cc +++ b/storage/perfschema/table_esgs_by_host_by_event_name.cc @@ -30,49 +30,6 @@ THR_LOCK table_esgs_by_host_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("HOST") }, - { C_STRING_WITH_LEN("char(60)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esgs_by_host_by_event_name::m_field_def= -{ 7, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esgs_by_host_by_event_name::m_share= { @@ -85,8 +42,14 @@ table_esgs_by_host_by_event_name::m_share= 1000, /* records */ sizeof(pos_esgs_by_host_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_stages_summary_by_host_by_event_name(" + "HOST CHAR(60) collate utf8_bin default null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esgs_by_host_by_event_name.h b/storage/perfschema/table_esgs_by_host_by_event_name.h index a8404e11e93..59a16c24828 100644 --- a/storage/perfschema/table_esgs_by_host_by_event_name.h +++ b/storage/perfschema/table_esgs_by_host_by_event_name.h @@ -108,8 +108,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esgs_by_host_by_event_name m_row; diff --git a/storage/perfschema/table_esgs_by_thread_by_event_name.cc b/storage/perfschema/table_esgs_by_thread_by_event_name.cc index 8a4d67695fa..4fde6013ade 100644 --- a/storage/perfschema/table_esgs_by_thread_by_event_name.cc +++ b/storage/perfschema/table_esgs_by_thread_by_event_name.cc @@ -29,49 +29,6 @@ THR_LOCK table_esgs_by_thread_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esgs_by_thread_by_event_name::m_field_def= -{ 7, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esgs_by_thread_by_event_name::m_share= { @@ -84,8 +41,14 @@ table_esgs_by_thread_by_event_name::m_share= 1000, /* records */ sizeof(pos_esgs_by_thread_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_stages_summary_by_thread_by_event_name(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esgs_by_thread_by_event_name.h b/storage/perfschema/table_esgs_by_thread_by_event_name.h index 5295a9eacdf..38c6d667d28 100644 --- a/storage/perfschema/table_esgs_by_thread_by_event_name.h +++ b/storage/perfschema/table_esgs_by_thread_by_event_name.h @@ -112,8 +112,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esgs_by_thread_by_event_name m_row; diff --git a/storage/perfschema/table_esgs_by_user_by_event_name.cc b/storage/perfschema/table_esgs_by_user_by_event_name.cc index 736559dd5e2..cdb7ed651a8 100644 --- a/storage/perfschema/table_esgs_by_user_by_event_name.cc +++ b/storage/perfschema/table_esgs_by_user_by_event_name.cc @@ -30,49 +30,6 @@ THR_LOCK table_esgs_by_user_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("USER") }, - { C_STRING_WITH_LEN("char(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esgs_by_user_by_event_name::m_field_def= -{ 7, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esgs_by_user_by_event_name::m_share= { @@ -85,8 +42,14 @@ table_esgs_by_user_by_event_name::m_share= 1000, /* records */ sizeof(pos_esgs_by_user_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_stages_summary_by_user_by_event_name(" + "USER CHAR(16) collate utf8_bin default null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esgs_by_user_by_event_name.h b/storage/perfschema/table_esgs_by_user_by_event_name.h index 9fc66033caa..3e1a03bd7f1 100644 --- a/storage/perfschema/table_esgs_by_user_by_event_name.h +++ b/storage/perfschema/table_esgs_by_user_by_event_name.h @@ -113,8 +113,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esgs_by_user_by_event_name m_row; diff --git a/storage/perfschema/table_esgs_global_by_event_name.cc b/storage/perfschema/table_esgs_global_by_event_name.cc index 1dea1f8aceb..0d59940f4ea 100644 --- a/storage/perfschema/table_esgs_global_by_event_name.cc +++ b/storage/perfschema/table_esgs_global_by_event_name.cc @@ -31,44 +31,6 @@ THR_LOCK table_esgs_global_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esgs_global_by_event_name::m_field_def= -{ 6, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esgs_global_by_event_name::m_share= { @@ -81,8 +43,13 @@ table_esgs_global_by_event_name::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_stages_summary_global_by_event_name(" + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esgs_global_by_event_name.h b/storage/perfschema/table_esgs_global_by_event_name.h index a9c1456e9b1..e6e23bf4515 100644 --- a/storage/perfschema/table_esgs_global_by_event_name.h +++ b/storage/perfschema/table_esgs_global_by_event_name.h @@ -76,8 +76,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esgs_global_by_event_name m_row; diff --git a/storage/perfschema/table_esms_by_account_by_event_name.cc b/storage/perfschema/table_esms_by_account_by_event_name.cc index 436056ef30b..b08c68a7000 100644 --- a/storage/perfschema/table_esms_by_account_by_event_name.cc +++ b/storage/perfschema/table_esms_by_account_by_event_name.cc @@ -29,149 +29,6 @@ THR_LOCK table_esms_by_account_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("USER") }, - { C_STRING_WITH_LEN("char(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("HOST") }, - { C_STRING_WITH_LEN("char(60)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_LOCK_TIME") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_WARNINGS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_AFFECTED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_SENT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_EXAMINED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_DISK_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_RANGE_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE_CHECK") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_MERGE_PASSES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_ROWS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_GOOD_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esms_by_account_by_event_name::m_field_def= -{ 27, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esms_by_account_by_event_name::m_share= { @@ -184,8 +41,34 @@ table_esms_by_account_by_event_name::m_share= 1000, /* records */ sizeof(pos_esms_by_account_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_statements_summary_by_account_by_event_name(" + "USER CHAR(16) collate utf8_bin default null," + "HOST CHAR(60) collate utf8_bin default null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "SUM_LOCK_TIME BIGINT unsigned not null," + "SUM_ERRORS BIGINT unsigned not null," + "SUM_WARNINGS BIGINT unsigned not null," + "SUM_ROWS_AFFECTED BIGINT unsigned not null," + "SUM_ROWS_SENT BIGINT unsigned not null," + "SUM_ROWS_EXAMINED BIGINT unsigned not null," + "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," + "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," + "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," + "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," + "SUM_SELECT_RANGE BIGINT unsigned not null," + "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," + "SUM_SELECT_SCAN BIGINT unsigned not null," + "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," + "SUM_SORT_RANGE BIGINT unsigned not null," + "SUM_SORT_ROWS BIGINT unsigned not null," + "SUM_SORT_SCAN BIGINT unsigned not null," + "SUM_NO_INDEX_USED BIGINT unsigned not null," + "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esms_by_account_by_event_name.h b/storage/perfschema/table_esms_by_account_by_event_name.h index 23168d03cd3..4e3097ef363 100644 --- a/storage/perfschema/table_esms_by_account_by_event_name.h +++ b/storage/perfschema/table_esms_by_account_by_event_name.h @@ -108,8 +108,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esms_by_account_by_event_name m_row; diff --git a/storage/perfschema/table_esms_by_digest.cc b/storage/perfschema/table_esms_by_digest.cc index 80fa4077281..88860a77c5d 100644 --- a/storage/perfschema/table_esms_by_digest.cc +++ b/storage/perfschema/table_esms_by_digest.cc @@ -33,159 +33,6 @@ THR_LOCK table_esms_by_digest::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("SCHEMA_NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("DIGEST") }, - { C_STRING_WITH_LEN("varchar(32)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("DIGEST_TEXT") }, - { C_STRING_WITH_LEN("longtext") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_LOCK_TIME") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_WARNINGS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_AFFECTED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_SENT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_EXAMINED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_DISK_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_RANGE_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE_CHECK") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_MERGE_PASSES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_ROWS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_GOOD_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("FIRST_SEEN") }, - { C_STRING_WITH_LEN("timestamp") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("LAST_SEEN") }, - { C_STRING_WITH_LEN("timestamp") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esms_by_digest::m_field_def= -{ 29, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esms_by_digest::m_share= { @@ -198,8 +45,36 @@ table_esms_by_digest::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_statements_summary_by_digest(" + "SCHEMA_NAME VARCHAR(64)," + "DIGEST VARCHAR(32)," + "DIGEST_TEXT LONGTEXT," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "SUM_LOCK_TIME BIGINT unsigned not null," + "SUM_ERRORS BIGINT unsigned not null," + "SUM_WARNINGS BIGINT unsigned not null," + "SUM_ROWS_AFFECTED BIGINT unsigned not null," + "SUM_ROWS_SENT BIGINT unsigned not null," + "SUM_ROWS_EXAMINED BIGINT unsigned not null," + "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," + "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," + "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," + "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," + "SUM_SELECT_RANGE BIGINT unsigned not null," + "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," + "SUM_SELECT_SCAN BIGINT unsigned not null," + "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," + "SUM_SORT_RANGE BIGINT unsigned not null," + "SUM_SORT_ROWS BIGINT unsigned not null," + "SUM_SORT_SCAN BIGINT unsigned not null," + "SUM_NO_INDEX_USED BIGINT unsigned not null," + "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null," + "FIRST_SEEN TIMESTAMP(0) NOT NULL default 0," + "LAST_SEEN TIMESTAMP(0) NOT NULL default 0)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esms_by_digest.h b/storage/perfschema/table_esms_by_digest.h index 5df8ec69633..196a89fcd09 100644 --- a/storage/perfschema/table_esms_by_digest.h +++ b/storage/perfschema/table_esms_by_digest.h @@ -78,8 +78,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esms_by_digest m_row; diff --git a/storage/perfschema/table_esms_by_host_by_event_name.cc b/storage/perfschema/table_esms_by_host_by_event_name.cc index 2cbe70d5ae4..78381cc8a4f 100644 --- a/storage/perfschema/table_esms_by_host_by_event_name.cc +++ b/storage/perfschema/table_esms_by_host_by_event_name.cc @@ -30,144 +30,6 @@ THR_LOCK table_esms_by_host_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("HOST") }, - { C_STRING_WITH_LEN("char(60)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_LOCK_TIME") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_WARNINGS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_AFFECTED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_SENT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_EXAMINED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_DISK_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_RANGE_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE_CHECK") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_MERGE_PASSES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_ROWS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_GOOD_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esms_by_host_by_event_name::m_field_def= -{ 26, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esms_by_host_by_event_name::m_share= { @@ -180,8 +42,33 @@ table_esms_by_host_by_event_name::m_share= 1000, /* records */ sizeof(pos_esms_by_host_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_statements_summary_by_host_by_event_name(" + "HOST CHAR(60) collate utf8_bin default null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "SUM_LOCK_TIME BIGINT unsigned not null," + "SUM_ERRORS BIGINT unsigned not null," + "SUM_WARNINGS BIGINT unsigned not null," + "SUM_ROWS_AFFECTED BIGINT unsigned not null," + "SUM_ROWS_SENT BIGINT unsigned not null," + "SUM_ROWS_EXAMINED BIGINT unsigned not null," + "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," + "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," + "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," + "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," + "SUM_SELECT_RANGE BIGINT unsigned not null," + "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," + "SUM_SELECT_SCAN BIGINT unsigned not null," + "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," + "SUM_SORT_RANGE BIGINT unsigned not null," + "SUM_SORT_ROWS BIGINT unsigned not null," + "SUM_SORT_SCAN BIGINT unsigned not null," + "SUM_NO_INDEX_USED BIGINT unsigned not null," + "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esms_by_host_by_event_name.h b/storage/perfschema/table_esms_by_host_by_event_name.h index c28f17a4473..e1a6535d77f 100644 --- a/storage/perfschema/table_esms_by_host_by_event_name.h +++ b/storage/perfschema/table_esms_by_host_by_event_name.h @@ -108,8 +108,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esms_by_host_by_event_name m_row; diff --git a/storage/perfschema/table_esms_by_thread_by_event_name.cc b/storage/perfschema/table_esms_by_thread_by_event_name.cc index 9ab2a814443..56a081218c0 100644 --- a/storage/perfschema/table_esms_by_thread_by_event_name.cc +++ b/storage/perfschema/table_esms_by_thread_by_event_name.cc @@ -29,144 +29,6 @@ THR_LOCK table_esms_by_thread_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_LOCK_TIME") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_WARNINGS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_AFFECTED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_SENT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_EXAMINED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_DISK_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_RANGE_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE_CHECK") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_MERGE_PASSES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_ROWS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_GOOD_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esms_by_thread_by_event_name::m_field_def= -{ 26, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esms_by_thread_by_event_name::m_share= { @@ -179,8 +41,33 @@ table_esms_by_thread_by_event_name::m_share= 1000, /* records */ sizeof(pos_esms_by_thread_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_statements_summary_by_thread_by_event_name(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "SUM_LOCK_TIME BIGINT unsigned not null," + "SUM_ERRORS BIGINT unsigned not null," + "SUM_WARNINGS BIGINT unsigned not null," + "SUM_ROWS_AFFECTED BIGINT unsigned not null," + "SUM_ROWS_SENT BIGINT unsigned not null," + "SUM_ROWS_EXAMINED BIGINT unsigned not null," + "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," + "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," + "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," + "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," + "SUM_SELECT_RANGE BIGINT unsigned not null," + "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," + "SUM_SELECT_SCAN BIGINT unsigned not null," + "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," + "SUM_SORT_RANGE BIGINT unsigned not null," + "SUM_SORT_ROWS BIGINT unsigned not null," + "SUM_SORT_SCAN BIGINT unsigned not null," + "SUM_NO_INDEX_USED BIGINT unsigned not null," + "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esms_by_thread_by_event_name.h b/storage/perfschema/table_esms_by_thread_by_event_name.h index 9fb9f7c58dc..32554c3a2f8 100644 --- a/storage/perfschema/table_esms_by_thread_by_event_name.h +++ b/storage/perfschema/table_esms_by_thread_by_event_name.h @@ -112,8 +112,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esms_by_thread_by_event_name m_row; diff --git a/storage/perfschema/table_esms_by_user_by_event_name.cc b/storage/perfschema/table_esms_by_user_by_event_name.cc index 6b55fb82814..7e0fce7cafc 100644 --- a/storage/perfschema/table_esms_by_user_by_event_name.cc +++ b/storage/perfschema/table_esms_by_user_by_event_name.cc @@ -30,144 +30,6 @@ THR_LOCK table_esms_by_user_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("USER") }, - { C_STRING_WITH_LEN("char(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_LOCK_TIME") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_WARNINGS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_AFFECTED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_SENT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_EXAMINED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_DISK_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_RANGE_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE_CHECK") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_MERGE_PASSES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_ROWS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_GOOD_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esms_by_user_by_event_name::m_field_def= -{ 26, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esms_by_user_by_event_name::m_share= { @@ -180,8 +42,33 @@ table_esms_by_user_by_event_name::m_share= 1000, /* records */ sizeof(pos_esms_by_user_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_statements_summary_by_user_by_event_name(" + "USER CHAR(16) collate utf8_bin default null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "SUM_LOCK_TIME BIGINT unsigned not null," + "SUM_ERRORS BIGINT unsigned not null," + "SUM_WARNINGS BIGINT unsigned not null," + "SUM_ROWS_AFFECTED BIGINT unsigned not null," + "SUM_ROWS_SENT BIGINT unsigned not null," + "SUM_ROWS_EXAMINED BIGINT unsigned not null," + "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," + "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," + "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," + "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," + "SUM_SELECT_RANGE BIGINT unsigned not null," + "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," + "SUM_SELECT_SCAN BIGINT unsigned not null," + "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," + "SUM_SORT_RANGE BIGINT unsigned not null," + "SUM_SORT_ROWS BIGINT unsigned not null," + "SUM_SORT_SCAN BIGINT unsigned not null," + "SUM_NO_INDEX_USED BIGINT unsigned not null," + "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esms_by_user_by_event_name.h b/storage/perfschema/table_esms_by_user_by_event_name.h index 6dc481d3273..beba70459d7 100644 --- a/storage/perfschema/table_esms_by_user_by_event_name.h +++ b/storage/perfschema/table_esms_by_user_by_event_name.h @@ -108,8 +108,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esms_by_user_by_event_name m_row; diff --git a/storage/perfschema/table_esms_global_by_event_name.cc b/storage/perfschema/table_esms_global_by_event_name.cc index e1b65559642..1e9f8f99159 100644 --- a/storage/perfschema/table_esms_global_by_event_name.cc +++ b/storage/perfschema/table_esms_global_by_event_name.cc @@ -31,139 +31,6 @@ THR_LOCK table_esms_global_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_LOCK_TIME") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_WARNINGS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_AFFECTED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_SENT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_ROWS_EXAMINED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_DISK_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CREATED_TMP_TABLES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_FULL_RANGE_JOIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_RANGE_CHECK") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SELECT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_MERGE_PASSES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_RANGE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_ROWS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_SORT_SCAN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NO_GOOD_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_esms_global_by_event_name::m_field_def= -{ 25, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_esms_global_by_event_name::m_share= { @@ -176,8 +43,32 @@ table_esms_global_by_event_name::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_statements_summary_global_by_event_name(" + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "SUM_LOCK_TIME BIGINT unsigned not null," + "SUM_ERRORS BIGINT unsigned not null," + "SUM_WARNINGS BIGINT unsigned not null," + "SUM_ROWS_AFFECTED BIGINT unsigned not null," + "SUM_ROWS_SENT BIGINT unsigned not null," + "SUM_ROWS_EXAMINED BIGINT unsigned not null," + "SUM_CREATED_TMP_DISK_TABLES BIGINT unsigned not null," + "SUM_CREATED_TMP_TABLES BIGINT unsigned not null," + "SUM_SELECT_FULL_JOIN BIGINT unsigned not null," + "SUM_SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," + "SUM_SELECT_RANGE BIGINT unsigned not null," + "SUM_SELECT_RANGE_CHECK BIGINT unsigned not null," + "SUM_SELECT_SCAN BIGINT unsigned not null," + "SUM_SORT_MERGE_PASSES BIGINT unsigned not null," + "SUM_SORT_RANGE BIGINT unsigned not null," + "SUM_SORT_ROWS BIGINT unsigned not null," + "SUM_SORT_SCAN BIGINT unsigned not null," + "SUM_NO_INDEX_USED BIGINT unsigned not null," + "SUM_NO_GOOD_INDEX_USED BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_esms_global_by_event_name.h b/storage/perfschema/table_esms_global_by_event_name.h index ed07e2b9062..14435fb6087 100644 --- a/storage/perfschema/table_esms_global_by_event_name.h +++ b/storage/perfschema/table_esms_global_by_event_name.h @@ -76,8 +76,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_esms_global_by_event_name m_row; diff --git a/storage/perfschema/table_events_stages.cc b/storage/perfschema/table_events_stages.cc index 08a977987dd..f98ff60d569 100644 --- a/storage/perfschema/table_events_stages.cc +++ b/storage/perfschema/table_events_stages.cc @@ -28,64 +28,6 @@ THR_LOCK table_events_stages_current::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("END_EVENT_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SOURCE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_START") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_END") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("NESTING_EVENT_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("NESTING_EVENT_TYPE") }, - { C_STRING_WITH_LEN("enum(\'STATEMENT\',\'STAGE\',\'WAIT\'") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_events_stages_current::m_field_def= -{10 , field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_events_stages_current::m_share= { @@ -98,8 +40,17 @@ table_events_stages_current::m_share= 1000, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_stages_current(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_ID BIGINT unsigned not null," + "END_EVENT_ID BIGINT unsigned," + "EVENT_NAME VARCHAR(128) not null," + "SOURCE VARCHAR(64)," + "TIMER_START BIGINT unsigned," + "TIMER_END BIGINT unsigned," + "TIMER_WAIT BIGINT unsigned," + "NESTING_EVENT_ID BIGINT unsigned," + "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT'))") } }; THR_LOCK table_events_stages_history::m_table_lock; @@ -116,8 +67,17 @@ table_events_stages_history::m_share= 1000, /* records */ sizeof(pos_events_stages_history), /* ref length */ &m_table_lock, - &table_events_stages_current::m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_stages_history(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_ID BIGINT unsigned not null," + "END_EVENT_ID BIGINT unsigned," + "EVENT_NAME VARCHAR(128) not null," + "SOURCE VARCHAR(64)," + "TIMER_START BIGINT unsigned," + "TIMER_END BIGINT unsigned," + "TIMER_WAIT BIGINT unsigned," + "NESTING_EVENT_ID BIGINT unsigned," + "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT'))") } }; THR_LOCK table_events_stages_history_long::m_table_lock; @@ -134,8 +94,17 @@ table_events_stages_history_long::m_share= 10000, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &table_events_stages_current::m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_stages_history_long(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_ID BIGINT unsigned not null," + "END_EVENT_ID BIGINT unsigned," + "EVENT_NAME VARCHAR(128) not null," + "SOURCE VARCHAR(64)," + "TIMER_START BIGINT unsigned," + "TIMER_END BIGINT unsigned," + "TIMER_WAIT BIGINT unsigned," + "NESTING_EVENT_ID BIGINT unsigned," + "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT'))") } }; table_events_stages_common::table_events_stages_common diff --git a/storage/perfschema/table_events_stages.h b/storage/perfschema/table_events_stages.h index 09c555c80fd..2568a090aa3 100644 --- a/storage/perfschema/table_events_stages.h +++ b/storage/perfschema/table_events_stages.h @@ -133,12 +133,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** - Fields definition. - Also used by table_events_stages_history - and table_events_stages_history_long. - */ - static TABLE_FIELD_DEF m_field_def; /** Current position. */ PFS_simple_index m_pos; diff --git a/storage/perfschema/table_events_statements.cc b/storage/perfschema/table_events_statements.cc index 96a79eecd00..c6d0bc2e24e 100644 --- a/storage/perfschema/table_events_statements.cc +++ b/storage/perfschema/table_events_statements.cc @@ -31,214 +31,6 @@ THR_LOCK table_events_statements_current::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("END_EVENT_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SOURCE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_START") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_END") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("LOCK_TIME") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SQL_TEXT") }, - { C_STRING_WITH_LEN("longtext") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("DIGEST") }, - { C_STRING_WITH_LEN("varchar(32)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("DIGEST_TEXT") }, - { C_STRING_WITH_LEN("longtext") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("CURRENT_SCHEMA") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_TYPE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_SCHEMA") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_INSTANCE_BEGIN") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MYSQL_ERRNO") }, - { C_STRING_WITH_LEN("int(11)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("RETURNED_SQLSTATE") }, - { C_STRING_WITH_LEN("varchar(5)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MESSAGE_TEXT") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ERRORS") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("WARNINGS") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ROWS_AFFECTED") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ROWS_SENT") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ROWS_EXAMINED") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("CREATED_TMP_DISK_TABLES") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("CREATED_TMP_TABLES") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SELECT_FULL_JOIN") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SELECT_FULL_RANGE_JOIN") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SELECT_RANGE") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SELECT_RANGE_CHECK") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SELECT_SCAN") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SORT_MERGE_PASSES") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SORT_RANGE") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SORT_ROWS") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SORT_SCAN") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("NO_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("NO_GOOD_INDEX_USED") }, - { C_STRING_WITH_LEN("bigint") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("NESTING_EVENT_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("NESTING_EVENT_TYPE") }, - { C_STRING_WITH_LEN("enum(\'STATEMENT\',\'STAGE\',\'WAIT\'") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_events_statements_current::m_field_def= -{40 , field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_events_statements_current::m_share= { @@ -251,8 +43,47 @@ table_events_statements_current::m_share= 1000, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_statements_current(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_ID BIGINT unsigned not null," + "END_EVENT_ID BIGINT unsigned," + "EVENT_NAME VARCHAR(128) not null," + "SOURCE VARCHAR(64)," + "TIMER_START BIGINT unsigned," + "TIMER_END BIGINT unsigned," + "TIMER_WAIT BIGINT unsigned," + "LOCK_TIME bigint unsigned not null," + "SQL_TEXT LONGTEXT," + "DIGEST VARCHAR(32)," + "DIGEST_TEXT LONGTEXT," + "CURRENT_SCHEMA VARCHAR(64)," + "OBJECT_TYPE VARCHAR(64)," + "OBJECT_SCHEMA VARCHAR(64)," + "OBJECT_NAME VARCHAR(64)," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned," + "MYSQL_ERRNO INTEGER," + "RETURNED_SQLSTATE VARCHAR(5)," + "MESSAGE_TEXT VARCHAR(128)," + "ERRORS BIGINT unsigned not null," + "WARNINGS BIGINT unsigned not null," + "ROWS_AFFECTED BIGINT unsigned not null," + "ROWS_SENT BIGINT unsigned not null," + "ROWS_EXAMINED BIGINT unsigned not null," + "CREATED_TMP_DISK_TABLES BIGINT unsigned not null," + "CREATED_TMP_TABLES BIGINT unsigned not null," + "SELECT_FULL_JOIN BIGINT unsigned not null," + "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," + "SELECT_RANGE BIGINT unsigned not null," + "SELECT_RANGE_CHECK BIGINT unsigned not null," + "SELECT_SCAN BIGINT unsigned not null," + "SORT_MERGE_PASSES BIGINT unsigned not null," + "SORT_RANGE BIGINT unsigned not null," + "SORT_ROWS BIGINT unsigned not null," + "SORT_SCAN BIGINT unsigned not null," + "NO_INDEX_USED BIGINT unsigned not null," + "NO_GOOD_INDEX_USED BIGINT unsigned not null," + "NESTING_EVENT_ID BIGINT unsigned," + "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT'))") } }; THR_LOCK table_events_statements_history::m_table_lock; @@ -269,8 +100,47 @@ table_events_statements_history::m_share= 1000, /* records */ sizeof(pos_events_statements_history), /* ref length */ &m_table_lock, - &table_events_statements_current::m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_statements_history(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_ID BIGINT unsigned not null," + "END_EVENT_ID BIGINT unsigned," + "EVENT_NAME VARCHAR(128) not null," + "SOURCE VARCHAR(64)," + "TIMER_START BIGINT unsigned," + "TIMER_END BIGINT unsigned," + "TIMER_WAIT BIGINT unsigned," + "LOCK_TIME bigint unsigned not null," + "SQL_TEXT LONGTEXT," + "DIGEST VARCHAR(32)," + "DIGEST_TEXT LONGTEXT," + "CURRENT_SCHEMA VARCHAR(64)," + "OBJECT_TYPE VARCHAR(64)," + "OBJECT_SCHEMA VARCHAR(64)," + "OBJECT_NAME VARCHAR(64)," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned," + "MYSQL_ERRNO INTEGER," + "RETURNED_SQLSTATE VARCHAR(5)," + "MESSAGE_TEXT VARCHAR(128)," + "ERRORS BIGINT unsigned not null," + "WARNINGS BIGINT unsigned not null," + "ROWS_AFFECTED BIGINT unsigned not null," + "ROWS_SENT BIGINT unsigned not null," + "ROWS_EXAMINED BIGINT unsigned not null," + "CREATED_TMP_DISK_TABLES BIGINT unsigned not null," + "CREATED_TMP_TABLES BIGINT unsigned not null," + "SELECT_FULL_JOIN BIGINT unsigned not null," + "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," + "SELECT_RANGE BIGINT unsigned not null," + "SELECT_RANGE_CHECK BIGINT unsigned not null," + "SELECT_SCAN BIGINT unsigned not null," + "SORT_MERGE_PASSES BIGINT unsigned not null," + "SORT_RANGE BIGINT unsigned not null," + "SORT_ROWS BIGINT unsigned not null," + "SORT_SCAN BIGINT unsigned not null," + "NO_INDEX_USED BIGINT unsigned not null," + "NO_GOOD_INDEX_USED BIGINT unsigned not null," + "NESTING_EVENT_ID BIGINT unsigned," + "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT'))") } }; THR_LOCK table_events_statements_history_long::m_table_lock; @@ -287,8 +157,47 @@ table_events_statements_history_long::m_share= 10000, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &table_events_statements_current::m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_statements_history_long(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_ID BIGINT unsigned not null," + "END_EVENT_ID BIGINT unsigned," + "EVENT_NAME VARCHAR(128) not null," + "SOURCE VARCHAR(64)," + "TIMER_START BIGINT unsigned," + "TIMER_END BIGINT unsigned," + "TIMER_WAIT BIGINT unsigned," + "LOCK_TIME bigint unsigned not null," + "SQL_TEXT LONGTEXT," + "DIGEST VARCHAR(32)," + "DIGEST_TEXT LONGTEXT," + "CURRENT_SCHEMA VARCHAR(64)," + "OBJECT_TYPE VARCHAR(64)," + "OBJECT_SCHEMA VARCHAR(64)," + "OBJECT_NAME VARCHAR(64)," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned," + "MYSQL_ERRNO INTEGER," + "RETURNED_SQLSTATE VARCHAR(5)," + "MESSAGE_TEXT VARCHAR(128)," + "ERRORS BIGINT unsigned not null," + "WARNINGS BIGINT unsigned not null," + "ROWS_AFFECTED BIGINT unsigned not null," + "ROWS_SENT BIGINT unsigned not null," + "ROWS_EXAMINED BIGINT unsigned not null," + "CREATED_TMP_DISK_TABLES BIGINT unsigned not null," + "CREATED_TMP_TABLES BIGINT unsigned not null," + "SELECT_FULL_JOIN BIGINT unsigned not null," + "SELECT_FULL_RANGE_JOIN BIGINT unsigned not null," + "SELECT_RANGE BIGINT unsigned not null," + "SELECT_RANGE_CHECK BIGINT unsigned not null," + "SELECT_SCAN BIGINT unsigned not null," + "SORT_MERGE_PASSES BIGINT unsigned not null," + "SORT_RANGE BIGINT unsigned not null," + "SORT_ROWS BIGINT unsigned not null," + "SORT_SCAN BIGINT unsigned not null," + "NO_INDEX_USED BIGINT unsigned not null," + "NO_GOOD_INDEX_USED BIGINT unsigned not null," + "NESTING_EVENT_ID BIGINT unsigned," + "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT'))") } }; table_events_statements_common::table_events_statements_common diff --git a/storage/perfschema/table_events_statements.h b/storage/perfschema/table_events_statements.h index e33c6b505bd..e80a67c1b71 100644 --- a/storage/perfschema/table_events_statements.h +++ b/storage/perfschema/table_events_statements.h @@ -212,12 +212,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** - Fields definition. - Also used by table_events_statements_history - and table_events_statements_history_long. - */ - static TABLE_FIELD_DEF m_field_def; void make_row(PFS_thread* pfs_thread, PFS_events_statements *statement); diff --git a/storage/perfschema/table_events_waits.cc b/storage/perfschema/table_events_waits.cc index 35b90816713..8e2d0064538 100644 --- a/storage/perfschema/table_events_waits.cc +++ b/storage/perfschema/table_events_waits.cc @@ -30,109 +30,6 @@ THR_LOCK table_events_waits_current::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("END_EVENT_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SOURCE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_START") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_END") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SPINS") }, - { C_STRING_WITH_LEN("int(10)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_SCHEMA") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_NAME") }, - { C_STRING_WITH_LEN("varchar(512)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("INDEX_NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_TYPE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_INSTANCE_BEGIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("NESTING_EVENT_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("NESTING_EVENT_TYPE") }, - { C_STRING_WITH_LEN("enum(\'STATEMENT\',\'STAGE\',\'WAIT\'") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OPERATION") }, - { C_STRING_WITH_LEN("varchar(32)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("NUMBER_OF_BYTES") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("FLAGS") }, - { C_STRING_WITH_LEN("int(10)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_events_waits_current::m_field_def= -{ 19, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_events_waits_current::m_share= { @@ -145,8 +42,26 @@ table_events_waits_current::m_share= 1000, /* records */ sizeof(pos_events_waits_current), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_waits_current(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_ID BIGINT unsigned not null," + "END_EVENT_ID BIGINT unsigned," + "EVENT_NAME VARCHAR(128) not null," + "SOURCE VARCHAR(64)," + "TIMER_START BIGINT unsigned," + "TIMER_END BIGINT unsigned," + "TIMER_WAIT BIGINT unsigned," + "SPINS INTEGER unsigned," + "OBJECT_SCHEMA VARCHAR(64)," + "OBJECT_NAME VARCHAR(512)," + "INDEX_NAME VARCHAR(64)," + "OBJECT_TYPE VARCHAR(64)," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," + "NESTING_EVENT_ID BIGINT unsigned," + "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')," + "OPERATION VARCHAR(32) not null," + "NUMBER_OF_BYTES BIGINT," + "FLAGS INTEGER unsigned)") } }; THR_LOCK table_events_waits_history::m_table_lock; @@ -163,8 +78,26 @@ table_events_waits_history::m_share= 1000, /* records */ sizeof(pos_events_waits_history), /* ref length */ &m_table_lock, - &table_events_waits_current::m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_waits_history(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_ID BIGINT unsigned not null," + "END_EVENT_ID BIGINT unsigned," + "EVENT_NAME VARCHAR(128) not null," + "SOURCE VARCHAR(64)," + "TIMER_START BIGINT unsigned," + "TIMER_END BIGINT unsigned," + "TIMER_WAIT BIGINT unsigned," + "SPINS INTEGER unsigned," + "OBJECT_SCHEMA VARCHAR(64)," + "OBJECT_NAME VARCHAR(512)," + "INDEX_NAME VARCHAR(64)," + "OBJECT_TYPE VARCHAR(64)," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," + "NESTING_EVENT_ID BIGINT unsigned," + "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')," + "OPERATION VARCHAR(32) not null," + "NUMBER_OF_BYTES BIGINT," + "FLAGS INTEGER unsigned)") } }; THR_LOCK table_events_waits_history_long::m_table_lock; @@ -181,8 +114,26 @@ table_events_waits_history_long::m_share= 10000, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &table_events_waits_current::m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_waits_history_long(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_ID BIGINT unsigned not null," + "END_EVENT_ID BIGINT unsigned," + "EVENT_NAME VARCHAR(128) not null," + "SOURCE VARCHAR(64)," + "TIMER_START BIGINT unsigned," + "TIMER_END BIGINT unsigned," + "TIMER_WAIT BIGINT unsigned," + "SPINS INTEGER unsigned," + "OBJECT_SCHEMA VARCHAR(64)," + "OBJECT_NAME VARCHAR(512)," + "INDEX_NAME VARCHAR(64)," + "OBJECT_TYPE VARCHAR(64)," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," + "NESTING_EVENT_ID BIGINT unsigned," + "NESTING_EVENT_TYPE ENUM('STATEMENT', 'STAGE', 'WAIT')," + "OPERATION VARCHAR(32) not null," + "NUMBER_OF_BYTES BIGINT," + "FLAGS INTEGER unsigned)") } }; table_events_waits_common::table_events_waits_common diff --git a/storage/perfschema/table_events_waits.h b/storage/perfschema/table_events_waits.h index 065bf95e5a6..60657278191 100644 --- a/storage/perfschema/table_events_waits.h +++ b/storage/perfschema/table_events_waits.h @@ -182,12 +182,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** - Fields definition. - Also used by table_events_waits_history - and table_events_waits_history_long. - */ - static TABLE_FIELD_DEF m_field_def; /** Current position. */ pos_events_waits_current m_pos; diff --git a/storage/perfschema/table_events_waits_summary.cc b/storage/perfschema/table_events_waits_summary.cc index a7130c14a29..516b271669d 100644 --- a/storage/perfschema/table_events_waits_summary.cc +++ b/storage/perfschema/table_events_waits_summary.cc @@ -28,49 +28,6 @@ THR_LOCK table_events_waits_summary_by_instance::m_table_lock; -static const TABLE_FIELD_TYPE ews_by_instance_field_types[]= -{ - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_INSTANCE_BEGIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_events_waits_summary_by_instance::m_field_def= -{ 7, ews_by_instance_field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_events_waits_summary_by_instance::m_share= { @@ -83,8 +40,14 @@ table_events_waits_summary_by_instance::m_share= 1000, /* records */ sizeof(pos_all_instr), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_waits_summary_by_instance(" + "EVENT_NAME VARCHAR(128) not null," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* table_events_waits_summary_by_instance::create(void) diff --git a/storage/perfschema/table_events_waits_summary.h b/storage/perfschema/table_events_waits_summary.h index 7463ace3eb6..9d3a28816e3 100644 --- a/storage/perfschema/table_events_waits_summary.h +++ b/storage/perfschema/table_events_waits_summary.h @@ -79,8 +79,6 @@ public: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_events_waits_summary_by_instance m_row; diff --git a/storage/perfschema/table_ews_by_account_by_event_name.cc b/storage/perfschema/table_ews_by_account_by_event_name.cc index 251fbc74536..7f79feca9d3 100644 --- a/storage/perfschema/table_ews_by_account_by_event_name.cc +++ b/storage/perfschema/table_ews_by_account_by_event_name.cc @@ -29,54 +29,6 @@ THR_LOCK table_ews_by_account_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("USER") }, - { C_STRING_WITH_LEN("char(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("HOST") }, - { C_STRING_WITH_LEN("char(60)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_ews_by_account_by_event_name::m_field_def= -{ 8, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_ews_by_account_by_event_name::m_share= { @@ -89,8 +41,15 @@ table_ews_by_account_by_event_name::m_share= 1000, /* records */ sizeof(pos_ews_by_account_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_waits_summary_by_account_by_event_name(" + "USER CHAR(16) collate utf8_bin default null," + "HOST CHAR(60) collate utf8_bin default null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_ews_by_account_by_event_name.h b/storage/perfschema/table_ews_by_account_by_event_name.h index 8ccfee599eb..40283c30ccb 100644 --- a/storage/perfschema/table_ews_by_account_by_event_name.h +++ b/storage/perfschema/table_ews_by_account_by_event_name.h @@ -119,8 +119,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_ews_by_account_by_event_name m_row; diff --git a/storage/perfschema/table_ews_by_host_by_event_name.cc b/storage/perfschema/table_ews_by_host_by_event_name.cc index 38f94ebc11b..61ac7848cf4 100644 --- a/storage/perfschema/table_ews_by_host_by_event_name.cc +++ b/storage/perfschema/table_ews_by_host_by_event_name.cc @@ -30,49 +30,6 @@ THR_LOCK table_ews_by_host_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("HOST") }, - { C_STRING_WITH_LEN("char(60)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_ews_by_host_by_event_name::m_field_def= -{ 7, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_ews_by_host_by_event_name::m_share= { @@ -85,8 +42,14 @@ table_ews_by_host_by_event_name::m_share= 1000, /* records */ sizeof(pos_ews_by_host_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_waits_summary_by_host_by_event_name(" + "HOST CHAR(60) collate utf8_bin default null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_ews_by_host_by_event_name.h b/storage/perfschema/table_ews_by_host_by_event_name.h index 124b121e8d2..c93afafd0ef 100644 --- a/storage/perfschema/table_ews_by_host_by_event_name.h +++ b/storage/perfschema/table_ews_by_host_by_event_name.h @@ -119,8 +119,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_ews_by_host_by_event_name m_row; diff --git a/storage/perfschema/table_ews_by_thread_by_event_name.cc b/storage/perfschema/table_ews_by_thread_by_event_name.cc index 3f21b0625d3..833cdb3df7e 100644 --- a/storage/perfschema/table_ews_by_thread_by_event_name.cc +++ b/storage/perfschema/table_ews_by_thread_by_event_name.cc @@ -29,49 +29,6 @@ THR_LOCK table_ews_by_thread_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_ews_by_thread_by_event_name::m_field_def= -{ 7, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_ews_by_thread_by_event_name::m_share= { @@ -84,8 +41,14 @@ table_ews_by_thread_by_event_name::m_share= 1000, /* records */ sizeof(pos_ews_by_thread_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_waits_summary_by_thread_by_event_name(" + "THREAD_ID BIGINT unsigned not null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_ews_by_thread_by_event_name.h b/storage/perfschema/table_ews_by_thread_by_event_name.h index 989356be646..c584b507d46 100644 --- a/storage/perfschema/table_ews_by_thread_by_event_name.h +++ b/storage/perfschema/table_ews_by_thread_by_event_name.h @@ -118,8 +118,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_ews_by_thread_by_event_name m_row; diff --git a/storage/perfschema/table_ews_by_user_by_event_name.cc b/storage/perfschema/table_ews_by_user_by_event_name.cc index b8365064a26..82d4768293e 100644 --- a/storage/perfschema/table_ews_by_user_by_event_name.cc +++ b/storage/perfschema/table_ews_by_user_by_event_name.cc @@ -30,49 +30,6 @@ THR_LOCK table_ews_by_user_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("USER") }, - { C_STRING_WITH_LEN("char(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_ews_by_user_by_event_name::m_field_def= -{ 7, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_ews_by_user_by_event_name::m_share= { @@ -85,8 +42,14 @@ table_ews_by_user_by_event_name::m_share= 1000, /* records */ sizeof(pos_ews_by_user_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_waits_summary_by_user_by_event_name(" + "USER CHAR(16) collate utf8_bin default null," + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_ews_by_user_by_event_name.h b/storage/perfschema/table_ews_by_user_by_event_name.h index 123ee2349ae..4fe4613206f 100644 --- a/storage/perfschema/table_ews_by_user_by_event_name.h +++ b/storage/perfschema/table_ews_by_user_by_event_name.h @@ -119,8 +119,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_ews_by_user_by_event_name m_row; diff --git a/storage/perfschema/table_ews_global_by_event_name.cc b/storage/perfschema/table_ews_global_by_event_name.cc index bc5c3780ecf..ebd855f9109 100644 --- a/storage/perfschema/table_ews_global_by_event_name.cc +++ b/storage/perfschema/table_ews_global_by_event_name.cc @@ -31,44 +31,6 @@ THR_LOCK table_ews_global_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_ews_global_by_event_name::m_field_def= -{ 6, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_ews_global_by_event_name::m_share= { @@ -81,8 +43,13 @@ table_ews_global_by_event_name::m_share= 1000, /* records */ sizeof(pos_ews_global_by_event_name), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE events_waits_summary_global_by_event_name(" + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_ews_global_by_event_name.h b/storage/perfschema/table_ews_global_by_event_name.h index a118e536b6a..538f1f1fb8a 100644 --- a/storage/perfschema/table_ews_global_by_event_name.h +++ b/storage/perfschema/table_ews_global_by_event_name.h @@ -111,8 +111,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_ews_global_by_event_name m_row; diff --git a/storage/perfschema/table_file_instances.cc b/storage/perfschema/table_file_instances.cc index 5b13210c004..4b5ecf3cb39 100644 --- a/storage/perfschema/table_file_instances.cc +++ b/storage/perfschema/table_file_instances.cc @@ -28,29 +28,6 @@ THR_LOCK table_file_instances::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("FILE_NAME") }, - { C_STRING_WITH_LEN("varchar(512)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OPEN_COUNT") }, - { C_STRING_WITH_LEN("int(10)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_file_instances::m_field_def= -{ 3, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_file_instances::m_share= { @@ -63,8 +40,10 @@ table_file_instances::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE file_instances(" + "FILE_NAME VARCHAR(512) not null," + "EVENT_NAME VARCHAR(128) not null," + "OPEN_COUNT INTEGER unsigned not null)") } }; PFS_engine_table* table_file_instances::create(void) diff --git a/storage/perfschema/table_file_instances.h b/storage/perfschema/table_file_instances.h index f7ec16715f3..988c03bcb5f 100644 --- a/storage/perfschema/table_file_instances.h +++ b/storage/perfschema/table_file_instances.h @@ -73,8 +73,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_file_instances m_row; diff --git a/storage/perfschema/table_file_summary.cc b/storage/perfschema/table_file_summary.cc deleted file mode 100644 index 104fa0fbd36..00000000000 --- a/storage/perfschema/table_file_summary.cc +++ /dev/null @@ -1,372 +0,0 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ - -/** - @file storage/perfschema/table_file_summary.cc - Table FILE_SUMMARY_BY_xxx (implementation). -*/ - -#include "my_global.h" -#include "my_pthread.h" -#include "pfs_instr_class.h" -#include "pfs_column_types.h" -#include "pfs_column_values.h" -#include "table_file_summary.h" -#include "pfs_global.h" - -THR_LOCK table_file_summary_by_event_name::m_table_lock; - -static const TABLE_FIELD_TYPE fs_by_event_name_field_types[]= -{ - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_file_summary_by_event_name::m_field_def= -{ 5, fs_by_event_name_field_types, 0, (uint*) 0 }; - -PFS_engine_table_share -table_file_summary_by_event_name::m_share= -{ - { C_STRING_WITH_LEN("file_summary_by_event_name") }, - &pfs_truncatable_acl, - &table_file_summary_by_event_name::create, - NULL, /* write_row */ - table_file_summary_by_event_name::delete_all_rows, - 1000, /* records */ - sizeof(PFS_simple_index), - &m_table_lock, - &m_field_def, - false /* checked */ -}; - -PFS_engine_table* table_file_summary_by_event_name::create(void) -{ - return new table_file_summary_by_event_name(); -} - -int table_file_summary_by_event_name::delete_all_rows(void) -{ - reset_file_class_io(); - return 0; -} - -table_file_summary_by_event_name::table_file_summary_by_event_name() - : PFS_engine_table(&m_share, &m_pos), - m_pos(1), m_next_pos(1) -{} - -void table_file_summary_by_event_name::reset_position(void) -{ - m_pos.m_index= 1; - m_next_pos.m_index= 1; -} - -int table_file_summary_by_event_name::rnd_next(void) -{ - PFS_file_class *file_class; - - m_pos.set_at(&m_next_pos); - - file_class= find_file_class(m_pos.m_index); - if (file_class) - { - make_row(file_class); - m_next_pos.set_after(&m_pos); - return 0; - } - - return HA_ERR_END_OF_FILE; -} - -int table_file_summary_by_event_name::rnd_pos(const void *pos) -{ - PFS_file_class *file_class; - - set_position(pos); - - file_class= find_file_class(m_pos.m_index); - if (file_class) - { - make_row(file_class); - return 0; - } - - return HA_ERR_RECORD_DELETED; -} - -/** - Build a row. - @param klass the file class the cursor is reading -*/ -void table_file_summary_by_event_name::make_row(PFS_file_class *klass) -{ - m_row.m_name= &klass->m_name[0]; - m_row.m_name_length= klass->m_name_length; - m_row.m_file_stat= klass->m_file_stat; -} - -int table_file_summary_by_event_name::read_row_values(TABLE *table, - unsigned char *, - Field **fields, - bool read_all) -{ - Field *f; - - /* Set the null bits */ - DBUG_ASSERT(table->s->null_bytes == 0); - - /* The row always exists for classes */ - - for (; (f= *fields) ; fields++) - { - if (read_all || bitmap_is_set(table->read_set, f->field_index)) - { - switch(f->field_index) - { - case 0: /* NAME */ - set_field_varchar_utf8(f, m_row.m_name, m_row.m_name_length); - break; - case 1: /* COUNT_READ */ - set_field_ulonglong(f, m_row.m_file_stat.m_count_read); - break; - case 2: /* COUNT_WRITE */ - set_field_ulonglong(f, m_row.m_file_stat.m_count_write); - break; - case 3: /* READ_BYTES */ - set_field_ulonglong(f, m_row.m_file_stat.m_read_bytes); - break; - case 4: /* WRITE_BYTES */ - set_field_ulonglong(f, m_row.m_file_stat.m_write_bytes); - break; - default: - DBUG_ASSERT(false); - } - } - } - - return 0; -} - -THR_LOCK table_file_summary_by_instance::m_table_lock; - -static const TABLE_FIELD_TYPE fs_by_instance_field_types[]= -{ - { - { C_STRING_WITH_LEN("FILE_NAME") }, - { C_STRING_WITH_LEN("varchar(512)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_file_summary_by_instance::m_field_def= -{ 6, fs_by_instance_field_types, 0, (uint*) 0 }; - -PFS_engine_table_share -table_file_summary_by_instance::m_share= -{ - { C_STRING_WITH_LEN("file_summary_by_instance") }, - &pfs_truncatable_acl, - &table_file_summary_by_instance::create, - NULL, /* write_row */ - table_file_summary_by_instance::delete_all_rows, - 1000, /* records */ - sizeof(PFS_simple_index), - &m_table_lock, - &m_field_def, - false /* checked */ -}; - -PFS_engine_table* table_file_summary_by_instance::create(void) -{ - return new table_file_summary_by_instance(); -} - -int table_file_summary_by_instance::delete_all_rows(void) -{ - reset_file_instance_io(); - return 0; -} - -table_file_summary_by_instance::table_file_summary_by_instance() - : PFS_engine_table(&m_share, &m_pos), - m_row_exists(false), m_pos(0), m_next_pos(0) -{} - -void table_file_summary_by_instance::reset_position(void) -{ - m_pos.m_index= 0; - m_next_pos.m_index= 0; -} - -int table_file_summary_by_instance::rnd_next(void) -{ - PFS_file *pfs; - - for (m_pos.set_at(&m_next_pos); - m_pos.m_index < file_max; - m_pos.next()) - { - pfs= &file_array[m_pos.m_index]; - if (pfs->m_lock.is_populated()) - { - make_row(pfs); - m_next_pos.set_after(&m_pos); - return 0; - } - } - - return HA_ERR_END_OF_FILE; -} - -int table_file_summary_by_instance::rnd_pos(const void *pos) -{ - PFS_file *pfs; - - set_position(pos); - DBUG_ASSERT(m_pos.m_index < file_max); - pfs= &file_array[m_pos.m_index]; - - if (! pfs->m_lock.is_populated()) - return HA_ERR_RECORD_DELETED; - - make_row(pfs); - return 0; -} - -/** - Build a row. - @param pfs the file the cursor is reading -*/ -void table_file_summary_by_instance::make_row(PFS_file *pfs) -{ - pfs_lock lock; - PFS_file_class *safe_class; - - m_row_exists= false; - - /* Protect this reader against a file delete */ - pfs->m_lock.begin_optimistic_lock(&lock); - - safe_class= sanitize_file_class(pfs->m_class); - if (unlikely(safe_class == NULL)) - return; - - m_row.m_filename= pfs->m_filename; - m_row.m_filename_length= pfs->m_filename_length; - m_row.m_name= safe_class->m_name; - m_row.m_name_length= safe_class->m_name_length; - m_row.m_file_stat= pfs->m_file_stat; - - if (pfs->m_lock.end_optimistic_lock(&lock)) - m_row_exists= true; -} - -int table_file_summary_by_instance::read_row_values(TABLE *table, - unsigned char *, - Field **fields, - bool read_all) -{ - Field *f; - - if (unlikely(! m_row_exists)) - return HA_ERR_RECORD_DELETED; - - /* Set the null bits */ - DBUG_ASSERT(table->s->null_bytes == 0); - - for (; (f= *fields) ; fields++) - { - if (read_all || bitmap_is_set(table->read_set, f->field_index)) - { - switch(f->field_index) - { - case 0: /* FILENAME */ - set_field_varchar_utf8(f, m_row.m_filename, m_row.m_filename_length); - break; - case 1: /* NAME */ - set_field_varchar_utf8(f, m_row.m_name, m_row.m_name_length); - break; - case 2: /* COUNT_READ */ - set_field_ulonglong(f, m_row.m_file_stat.m_count_read); - break; - case 3: /* COUNT_WRITE */ - set_field_ulonglong(f, m_row.m_file_stat.m_count_write); - break; - case 4: /* READ_BYTES */ - set_field_ulonglong(f, m_row.m_file_stat.m_read_bytes); - break; - case 5: /* WRITE_BYTES */ - set_field_ulonglong(f, m_row.m_file_stat.m_write_bytes); - break; - default: - DBUG_ASSERT(false); - } - } - } - - return 0; -} - diff --git a/storage/perfschema/table_file_summary.h b/storage/perfschema/table_file_summary.h deleted file mode 100644 index 92837189f1f..00000000000 --- a/storage/perfschema/table_file_summary.h +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ - -#ifndef TABLE_FILE_SUMMARY_H -#define TABLE_FILE_SUMMARY_H - -/** - @file storage/perfschema/table_file_summary.h - Table FILE_SUMMARY_BY_xxx (declarations). -*/ - -#include "pfs_column_types.h" -#include "pfs_engine_table.h" -#include "pfs_instr_class.h" -#include "pfs_instr.h" - -/** - @addtogroup Performance_schema_tables - @{ -*/ - -/** A row of PERFORMANCE_SCHEMA.FILE_SUMMARY_BY_EVENT_NAME. */ -struct row_file_summary_by_event_name -{ - /** Column EVENT_NAME. */ - const char *m_name; - /** Length in bytes of @c m_name. */ - uint m_name_length; - /** - Columns COUNT_READ, COUNT_WRITE, - SUM_NUMBER_OF_BYTES_READ, SUM_NUMBER_OF_BYTES_WRITE. - */ - PFS_file_stat m_file_stat; -}; - -/** Table PERFORMANCE_SCHEMA.FILE_SUMMARY_BY_EVENT_NAME. */ -class table_file_summary_by_event_name : public PFS_engine_table -{ -public: - /** Table share */ - static PFS_engine_table_share m_share; - static PFS_engine_table* create(); - static int delete_all_rows(); - - virtual int rnd_next(); - virtual int rnd_pos(const void *pos); - virtual void reset_position(void); - -protected: - void make_row(PFS_file_class *klass); - - virtual int read_row_values(TABLE *table, - unsigned char *buf, - Field **fields, - bool read_all); - - table_file_summary_by_event_name(); - -public: - ~table_file_summary_by_event_name() - {} - -private: - /** Table share lock. */ - static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; - - /** Current row. */ - row_file_summary_by_event_name m_row; - /** Current position. */ - PFS_simple_index m_pos; - /** Next position. */ - PFS_simple_index m_next_pos; -}; - -/** A row of PERFORMANCE_SCHEMA.FILE_SUMMARY_BY_INSTANCE. */ -struct row_file_summary_by_instance -{ - /** Column FILE_NAME. */ - const char *m_filename; - /** Length in bytes of @c m_filename. */ - uint m_filename_length; - /** Column EVENT_NAME. */ - const char *m_name; - /** Length in bytes of @c m_name. */ - uint m_name_length; - /** - Columns COUNT_READ, COUNT_WRITE, - SUM_NUMBER_OF_BYTES_READ, SUM_NUMBER_OF_BYTES_WRITE. - */ - PFS_file_stat m_file_stat; -}; - -/** Table PERFORMANCE_SCHEMA.FILE_UMMARY_BY_INSTANCE. */ -class table_file_summary_by_instance : public PFS_engine_table -{ -public: - /** Table share */ - static PFS_engine_table_share m_share; - static PFS_engine_table* create(); - static int delete_all_rows(); - - virtual int rnd_next(); - virtual int rnd_pos(const void *pos); - virtual void reset_position(void); - -protected: - void make_row(PFS_file *pfs); - - virtual int read_row_values(TABLE *table, - unsigned char *buf, - Field **fields, - bool read_all); - - table_file_summary_by_instance(); - -public: - ~table_file_summary_by_instance() - {} - -private: - /** Table share lock. */ - static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; - - /** Current row. */ - row_file_summary_by_instance m_row; - /** True is the current row exists. */ - bool m_row_exists; - /** Current position. */ - PFS_simple_index m_pos; - /** Next position. */ - PFS_simple_index m_next_pos; -}; - -/** @} */ -#endif diff --git a/storage/perfschema/table_file_summary_by_event_name.cc b/storage/perfschema/table_file_summary_by_event_name.cc index 33bee172806..2e46c7c13ec 100644 --- a/storage/perfschema/table_file_summary_by_event_name.cc +++ b/storage/perfschema/table_file_summary_by_event_name.cc @@ -29,135 +29,6 @@ THR_LOCK table_file_summary_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Read */ - { - { C_STRING_WITH_LEN("COUNT_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Write */ - { - { C_STRING_WITH_LEN("COUNT_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Misc */ - { - { C_STRING_WITH_LEN("COUNT_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_file_summary_by_event_name::m_field_def= -{ 23, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_file_summary_by_event_name::m_share= { @@ -170,8 +41,30 @@ table_file_summary_by_event_name::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE file_summary_by_event_name(" + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "COUNT_READ BIGINT unsigned not null," + "SUM_TIMER_READ BIGINT unsigned not null," + "MIN_TIMER_READ BIGINT unsigned not null," + "AVG_TIMER_READ BIGINT unsigned not null," + "MAX_TIMER_READ BIGINT unsigned not null," + "SUM_NUMBER_OF_BYTES_READ BIGINT not null," + "COUNT_WRITE BIGINT unsigned not null," + "SUM_TIMER_WRITE BIGINT unsigned not null," + "MIN_TIMER_WRITE BIGINT unsigned not null," + "AVG_TIMER_WRITE BIGINT unsigned not null," + "MAX_TIMER_WRITE BIGINT unsigned not null," + "SUM_NUMBER_OF_BYTES_WRITE BIGINT not null," + "COUNT_MISC BIGINT unsigned not null," + "SUM_TIMER_MISC BIGINT unsigned not null," + "MIN_TIMER_MISC BIGINT unsigned not null," + "AVG_TIMER_MISC BIGINT unsigned not null," + "MAX_TIMER_MISC BIGINT unsigned not null)") } }; PFS_engine_table* table_file_summary_by_event_name::create(void) diff --git a/storage/perfschema/table_file_summary_by_event_name.h b/storage/perfschema/table_file_summary_by_event_name.h index 8a51dffad65..2c6f3b26950 100644 --- a/storage/perfschema/table_file_summary_by_event_name.h +++ b/storage/perfschema/table_file_summary_by_event_name.h @@ -74,8 +74,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_file_summary_by_event_name m_row; diff --git a/storage/perfschema/table_file_summary_by_instance.cc b/storage/perfschema/table_file_summary_by_instance.cc index c0bf1c29307..c69aa641a3c 100644 --- a/storage/perfschema/table_file_summary_by_instance.cc +++ b/storage/perfschema/table_file_summary_by_instance.cc @@ -28,145 +28,6 @@ THR_LOCK table_file_summary_by_instance::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("FILE_NAME") }, - { C_STRING_WITH_LEN("varchar(512)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_INSTANCE_BEGIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Read */ - { - { C_STRING_WITH_LEN("COUNT_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Write */ - { - { C_STRING_WITH_LEN("COUNT_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Misc */ - { - { C_STRING_WITH_LEN("COUNT_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_file_summary_by_instance::m_field_def= -{ 25, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_file_summary_by_instance::m_share= { @@ -179,8 +40,32 @@ table_file_summary_by_instance::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE file_summary_by_instance(" + "FILE_NAME VARCHAR(512) not null," + "EVENT_NAME VARCHAR(128) not null," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "COUNT_READ BIGINT unsigned not null," + "SUM_TIMER_READ BIGINT unsigned not null," + "MIN_TIMER_READ BIGINT unsigned not null," + "AVG_TIMER_READ BIGINT unsigned not null," + "MAX_TIMER_READ BIGINT unsigned not null," + "SUM_NUMBER_OF_BYTES_READ BIGINT not null," + "COUNT_WRITE BIGINT unsigned not null," + "SUM_TIMER_WRITE BIGINT unsigned not null," + "MIN_TIMER_WRITE BIGINT unsigned not null," + "AVG_TIMER_WRITE BIGINT unsigned not null," + "MAX_TIMER_WRITE BIGINT unsigned not null," + "SUM_NUMBER_OF_BYTES_WRITE BIGINT not null," + "COUNT_MISC BIGINT unsigned not null," + "SUM_TIMER_MISC BIGINT unsigned not null," + "MIN_TIMER_MISC BIGINT unsigned not null," + "AVG_TIMER_MISC BIGINT unsigned not null," + "MAX_TIMER_MISC BIGINT unsigned not null)") } }; PFS_engine_table* table_file_summary_by_instance::create(void) diff --git a/storage/perfschema/table_file_summary_by_instance.h b/storage/perfschema/table_file_summary_by_instance.h index d9f406966db..4bc1f9a76da 100644 --- a/storage/perfschema/table_file_summary_by_instance.h +++ b/storage/perfschema/table_file_summary_by_instance.h @@ -82,8 +82,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_file_summary_by_instance m_row; diff --git a/storage/perfschema/table_host_cache.cc b/storage/perfschema/table_host_cache.cc index 70efcd46bbf..df13207e578 100644 --- a/storage/perfschema/table_host_cache.cc +++ b/storage/perfschema/table_host_cache.cc @@ -25,159 +25,6 @@ THR_LOCK table_host_cache::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("IP") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("HOST") }, - { C_STRING_WITH_LEN("varchar(255)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("HOST_VALIDATED") }, - { C_STRING_WITH_LEN("enum(\'YES\',\'NO\')") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_CONNECT_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_HOST_BLOCKED_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_NAMEINFO_TRANSIENT_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_NAMEINFO_PERMANENT_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_FORMAT_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_ADDRINFO_TRANSIENT_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_ADDRINFO_PERMANENT_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_FCRDNS_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_HOST_ACL_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_NO_AUTH_PLUGIN_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_AUTH_PLUGIN_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_HANDSHAKE_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_PROXY_USER_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_PROXY_USER_ACL_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_AUTHENTICATION_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_SSL_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_MAX_USER_CONNECTIONS_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_MAX_USER_CONNECTIONS_PER_HOUR_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_DEFAULT_DATABASE_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_INIT_CONNECT_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_LOCAL_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_UNKNOWN_ERRORS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("FIRST_SEEN") }, - { C_STRING_WITH_LEN("timestamp") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("LAST_SEEN") }, - { C_STRING_WITH_LEN("timestamp") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("FIRST_ERROR_SEEN") }, - { C_STRING_WITH_LEN("timestamp") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("LAST_ERROR_SEEN") }, - { C_STRING_WITH_LEN("timestamp") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_host_cache::m_field_def= -{ 29, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_host_cache::m_share= { @@ -190,8 +37,36 @@ table_host_cache::m_share= 1000, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE host_cache(" + "IP VARCHAR(64) not null," + "HOST VARCHAR(255) collate utf8_bin," + "HOST_VALIDATED ENUM ('YES', 'NO') not null," + "SUM_CONNECT_ERRORS BIGINT not null," + "COUNT_HOST_BLOCKED_ERRORS BIGINT not null," + "COUNT_NAMEINFO_TRANSIENT_ERRORS BIGINT not null," + "COUNT_NAMEINFO_PERMANENT_ERRORS BIGINT not null," + "COUNT_FORMAT_ERRORS BIGINT not null," + "COUNT_ADDRINFO_TRANSIENT_ERRORS BIGINT not null," + "COUNT_ADDRINFO_PERMANENT_ERRORS BIGINT not null," + "COUNT_FCRDNS_ERRORS BIGINT not null," + "COUNT_HOST_ACL_ERRORS BIGINT not null," + "COUNT_NO_AUTH_PLUGIN_ERRORS BIGINT not null," + "COUNT_AUTH_PLUGIN_ERRORS BIGINT not null," + "COUNT_HANDSHAKE_ERRORS BIGINT not null," + "COUNT_PROXY_USER_ERRORS BIGINT not null," + "COUNT_PROXY_USER_ACL_ERRORS BIGINT not null," + "COUNT_AUTHENTICATION_ERRORS BIGINT not null," + "COUNT_SSL_ERRORS BIGINT not null," + "COUNT_MAX_USER_CONNECTIONS_ERRORS BIGINT not null," + "COUNT_MAX_USER_CONNECTIONS_PER_HOUR_ERRORS BIGINT not null," + "COUNT_DEFAULT_DATABASE_ERRORS BIGINT not null," + "COUNT_INIT_CONNECT_ERRORS BIGINT not null," + "COUNT_LOCAL_ERRORS BIGINT not null," + "COUNT_UNKNOWN_ERRORS BIGINT not null," + "FIRST_SEEN TIMESTAMP(0) NOT NULL default 0," + "LAST_SEEN TIMESTAMP(0) NOT NULL default 0," + "FIRST_ERROR_SEEN TIMESTAMP(0) null default 0," + "LAST_ERROR_SEEN TIMESTAMP(0) null default 0)") } }; PFS_engine_table* table_host_cache::create(void) diff --git a/storage/perfschema/table_host_cache.h b/storage/perfschema/table_host_cache.h index 74795707ac1..6a100cc4f55 100644 --- a/storage/perfschema/table_host_cache.h +++ b/storage/perfschema/table_host_cache.h @@ -127,8 +127,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; row_host_cache *m_all_rows; uint m_row_count; diff --git a/storage/perfschema/table_hosts.cc b/storage/perfschema/table_hosts.cc index c91193ea83e..8ddc34f5728 100644 --- a/storage/perfschema/table_hosts.cc +++ b/storage/perfschema/table_hosts.cc @@ -24,29 +24,6 @@ THR_LOCK table_hosts::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("HOST") }, - { C_STRING_WITH_LEN("char(60)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("CURRENT_CONNECTIONS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TOTAL_CONNECTIONS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_hosts::m_field_def= -{ 3, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_hosts::m_share= { @@ -59,8 +36,10 @@ table_hosts::m_share= 1000, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE hosts(" + "HOST CHAR(60) collate utf8_bin default null," + "CURRENT_CONNECTIONS bigint not null," + "TOTAL_CONNECTIONS bigint not null)") } }; PFS_engine_table* table_hosts::create() diff --git a/storage/perfschema/table_hosts.h b/storage/perfschema/table_hosts.h index 6fdbf1bb0d9..9f44dd3381b 100644 --- a/storage/perfschema/table_hosts.h +++ b/storage/perfschema/table_hosts.h @@ -67,8 +67,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_hosts m_row; diff --git a/storage/perfschema/table_os_global_by_type.cc b/storage/perfschema/table_os_global_by_type.cc index f6c9a85a95d..2f7bf5ec5e1 100644 --- a/storage/perfschema/table_os_global_by_type.cc +++ b/storage/perfschema/table_os_global_by_type.cc @@ -28,54 +28,6 @@ THR_LOCK table_os_global_by_type::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("OBJECT_TYPE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_SCHEMA") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_os_global_by_type::m_field_def= -{ 8, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_os_global_by_type::m_share= { @@ -88,8 +40,15 @@ table_os_global_by_type::m_share= 1000, /* records */ sizeof(pos_os_global_by_type), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE objects_summary_global_by_type(" + "OBJECT_TYPE VARCHAR(64)," + "OBJECT_SCHEMA VARCHAR(64)," + "OBJECT_NAME VARCHAR(64)," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_os_global_by_type.h b/storage/perfschema/table_os_global_by_type.h index 888e3760488..7968b85aec4 100644 --- a/storage/perfschema/table_os_global_by_type.h +++ b/storage/perfschema/table_os_global_by_type.h @@ -112,8 +112,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_os_global_by_type m_row; diff --git a/storage/perfschema/table_performance_timers.cc b/storage/perfschema/table_performance_timers.cc index 473ea8b82cf..780d507a64b 100644 --- a/storage/perfschema/table_performance_timers.cc +++ b/storage/perfschema/table_performance_timers.cc @@ -26,35 +26,6 @@ THR_LOCK table_performance_timers::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("TIMER_NAME") }, - { C_STRING_WITH_LEN("enum(\'CYCLE\',\'NANOSECOND\',\'MICROSECOND\'," - "\'MILLISECOND\',\'TICK\')") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_FREQUENCY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_RESOLUTION") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_OVERHEAD") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_performance_timers::m_field_def= -{ 4, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_performance_timers::m_share= { @@ -67,8 +38,11 @@ table_performance_timers::m_share= COUNT_TIMER_NAME, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE performance_timers(" + "TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null," + "TIMER_FREQUENCY BIGINT," + "TIMER_RESOLUTION BIGINT," + "TIMER_OVERHEAD BIGINT)") } }; PFS_engine_table* table_performance_timers::create(void) diff --git a/storage/perfschema/table_performance_timers.h b/storage/perfschema/table_performance_timers.h index dbd47665ff6..79e9f54636d 100644 --- a/storage/perfschema/table_performance_timers.h +++ b/storage/perfschema/table_performance_timers.h @@ -70,8 +70,6 @@ public: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_performance_timers *m_row; diff --git a/storage/perfschema/table_session_account_connect_attrs.cc b/storage/perfschema/table_session_account_connect_attrs.cc index 4a3fcc22341..2aed519a903 100644 --- a/storage/perfschema/table_session_account_connect_attrs.cc +++ b/storage/perfschema/table_session_account_connect_attrs.cc @@ -29,8 +29,12 @@ table_session_account_connect_attrs::m_share= 1000, /* records */ sizeof(pos_connect_attr_by_thread_by_attr), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE session_account_connect_attrs(" + "PROCESSLIST_ID INT NOT NULL," + "ATTR_NAME VARCHAR(32) NOT NULL," + "ATTR_VALUE VARCHAR(1024)," + "ORDINAL_POSITION INT" + ") CHARACTER SET utf8 COLLATE utf8_bin") } }; PFS_engine_table* table_session_account_connect_attrs::create() diff --git a/storage/perfschema/table_session_connect.cc b/storage/perfschema/table_session_connect.cc index df3337b284c..a5c557baeb2 100644 --- a/storage/perfschema/table_session_connect.cc +++ b/storage/perfschema/table_session_connect.cc @@ -15,33 +15,6 @@ #include "table_session_connect.h" -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("PROCESSLIST_ID") }, - { C_STRING_WITH_LEN("int(11)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ATTR_NAME") }, - { C_STRING_WITH_LEN("varchar(32)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ATTR_VALUE") }, - { C_STRING_WITH_LEN("varchar(1024)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ORDINAL_POSITION") }, - { C_STRING_WITH_LEN("int(11)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF table_session_connect::m_field_def= -{ 4, field_types, 0, (uint*) 0 }; - table_session_connect::table_session_connect(const PFS_engine_table_share *share) : cursor_by_thread_connect_attr(share) { diff --git a/storage/perfschema/table_session_connect.h b/storage/perfschema/table_session_connect.h index e6faa283e42..7e06f8a3d24 100644 --- a/storage/perfschema/table_session_connect.h +++ b/storage/perfschema/table_session_connect.h @@ -66,8 +66,6 @@ protected: virtual int read_row_values(TABLE *table, unsigned char *buf, Field **fields, bool read_all); protected: - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_session_connect_attrs m_row; /** Safe copy of @c PFS_thread::m_session_connect_attrs. */ diff --git a/storage/perfschema/table_session_connect_attrs.cc b/storage/perfschema/table_session_connect_attrs.cc index 9e1804b7294..840167a40e9 100644 --- a/storage/perfschema/table_session_connect_attrs.cc +++ b/storage/perfschema/table_session_connect_attrs.cc @@ -29,8 +29,12 @@ table_session_connect_attrs::m_share= 1000, /* records */ sizeof(pos_connect_attr_by_thread_by_attr), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE session_connect_attrs(" + "PROCESSLIST_ID INT NOT NULL," + "ATTR_NAME VARCHAR(32) NOT NULL," + "ATTR_VALUE VARCHAR(1024)," + "ORDINAL_POSITION INT" + ") CHARACTER SET utf8 COLLATE utf8_bin") } }; PFS_engine_table* table_session_connect_attrs::create() diff --git a/storage/perfschema/table_setup_actors.cc b/storage/perfschema/table_setup_actors.cc index a73ec452980..c82d67fba2d 100644 --- a/storage/perfschema/table_setup_actors.cc +++ b/storage/perfschema/table_setup_actors.cc @@ -29,29 +29,6 @@ THR_LOCK table_setup_actors::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("HOST") }, - { C_STRING_WITH_LEN("char(60)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("USER") }, - { C_STRING_WITH_LEN("char(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ROLE") }, - { C_STRING_WITH_LEN("char(16)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_setup_actors::m_field_def= -{ 3, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_setup_actors::m_share= { @@ -64,8 +41,10 @@ table_setup_actors::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE setup_actors(" + "HOST CHAR(60) collate utf8_bin default '%' not null," + "USER CHAR(16) collate utf8_bin default '%' not null," + "ROLE CHAR(16) collate utf8_bin default '%' not null)") } }; PFS_engine_table* table_setup_actors::create() diff --git a/storage/perfschema/table_setup_actors.h b/storage/perfschema/table_setup_actors.h index be3ab1bdf0d..2a9395dfac7 100644 --- a/storage/perfschema/table_setup_actors.h +++ b/storage/perfschema/table_setup_actors.h @@ -89,8 +89,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_setup_actors m_row; diff --git a/storage/perfschema/table_setup_consumers.cc b/storage/perfschema/table_setup_consumers.cc index 563307f97ad..c09853ffeca 100644 --- a/storage/perfschema/table_setup_consumers.cc +++ b/storage/perfschema/table_setup_consumers.cc @@ -92,24 +92,6 @@ static row_setup_consumers all_setup_consumers_data[COUNT_SETUP_CONSUMERS]= THR_LOCK table_setup_consumers::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ENABLED") }, - { C_STRING_WITH_LEN("enum(\'YES\',\'NO\')") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_setup_consumers::m_field_def= -{ 2, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_setup_consumers::m_share= { @@ -122,8 +104,9 @@ table_setup_consumers::m_share= COUNT_SETUP_CONSUMERS, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE setup_consumers(" + "NAME VARCHAR(64) not null," + "ENABLED ENUM ('YES', 'NO') not null)") } }; PFS_engine_table* table_setup_consumers::create(void) diff --git a/storage/perfschema/table_setup_consumers.h b/storage/perfschema/table_setup_consumers.h index bc7e9d553bb..e59033c0ad1 100644 --- a/storage/perfschema/table_setup_consumers.h +++ b/storage/perfschema/table_setup_consumers.h @@ -72,8 +72,6 @@ public: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_setup_consumers *m_row; diff --git a/storage/perfschema/table_setup_instruments.cc b/storage/perfschema/table_setup_instruments.cc index 060857c3a38..d911128ce94 100644 --- a/storage/perfschema/table_setup_instruments.cc +++ b/storage/perfschema/table_setup_instruments.cc @@ -30,29 +30,6 @@ THR_LOCK table_setup_instruments::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ENABLED") }, - { C_STRING_WITH_LEN("enum(\'YES\',\'NO\')") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMED") }, - { C_STRING_WITH_LEN("enum(\'YES\',\'NO\')") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_setup_instruments::m_field_def= -{ 3, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_setup_instruments::m_share= { @@ -65,8 +42,10 @@ table_setup_instruments::m_share= 1000, /* records */ sizeof(pos_setup_instruments), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE setup_instruments(" + "NAME VARCHAR(128) not null," + "ENABLED ENUM ('YES', 'NO') not null," + "TIMED ENUM ('YES', 'NO') not null)") } }; PFS_engine_table* table_setup_instruments::create(void) diff --git a/storage/perfschema/table_setup_instruments.h b/storage/perfschema/table_setup_instruments.h index cb4c6a06de1..2e70a528bbd 100644 --- a/storage/perfschema/table_setup_instruments.h +++ b/storage/perfschema/table_setup_instruments.h @@ -106,8 +106,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_setup_instruments m_row; diff --git a/storage/perfschema/table_setup_objects.cc b/storage/perfschema/table_setup_objects.cc index 4753285d277..5321271a62d 100644 --- a/storage/perfschema/table_setup_objects.cc +++ b/storage/perfschema/table_setup_objects.cc @@ -30,39 +30,6 @@ THR_LOCK table_setup_objects::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("OBJECT_TYPE") }, - { C_STRING_WITH_LEN("enum(\'TABLE\')") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_SCHEMA") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ENABLED") }, - { C_STRING_WITH_LEN("enum(\'YES\',\'NO\')") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMED") }, - { C_STRING_WITH_LEN("enum(\'YES\',\'NO\')") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_setup_objects::m_field_def= -{ 5, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_setup_objects::m_share= { @@ -75,8 +42,12 @@ table_setup_objects::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE setup_objects(" + "OBJECT_TYPE ENUM ('TABLE') not null default 'TABLE'," + "OBJECT_SCHEMA VARCHAR(64) default '%'," + "OBJECT_NAME VARCHAR(64) not null default '%'," + "ENABLED ENUM ('YES', 'NO') not null default 'YES'," + "TIMED ENUM ('YES', 'NO') not null default 'YES')") } }; int update_derived_flags() diff --git a/storage/perfschema/table_setup_objects.h b/storage/perfschema/table_setup_objects.h index 4b31fa6a8a6..55423ffd90f 100644 --- a/storage/perfschema/table_setup_objects.h +++ b/storage/perfschema/table_setup_objects.h @@ -92,8 +92,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_setup_objects m_row; diff --git a/storage/perfschema/table_setup_timers.cc b/storage/perfschema/table_setup_timers.cc index 1176f1f34b1..911fa121e06 100644 --- a/storage/perfschema/table_setup_timers.cc +++ b/storage/perfschema/table_setup_timers.cc @@ -48,25 +48,6 @@ static row_setup_timers all_setup_timers_data[COUNT_SETUP_TIMERS]= THR_LOCK table_setup_timers::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TIMER_NAME") }, - { C_STRING_WITH_LEN("enum(\'CYCLE\',\'NANOSECOND\',\'MICROSECOND\'," - "\'MILLISECOND\',\'TICK\')") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_setup_timers::m_field_def= -{ 2, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_setup_timers::m_share= { @@ -79,8 +60,9 @@ table_setup_timers::m_share= COUNT_SETUP_TIMERS, sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE setup_timers(" + "NAME VARCHAR(64) not null," + "TIMER_NAME ENUM ('CYCLE', 'NANOSECOND', 'MICROSECOND', 'MILLISECOND', 'TICK') not null)") } }; PFS_engine_table* table_setup_timers::create(void) diff --git a/storage/perfschema/table_setup_timers.h b/storage/perfschema/table_setup_timers.h index a81e6fefaaf..46af68bb9e3 100644 --- a/storage/perfschema/table_setup_timers.h +++ b/storage/perfschema/table_setup_timers.h @@ -70,8 +70,6 @@ public: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_setup_timers *m_row; diff --git a/storage/perfschema/table_socket_instances.cc b/storage/perfschema/table_socket_instances.cc index 6dfea0bf8be..e47a97c90b0 100644 --- a/storage/perfschema/table_socket_instances.cc +++ b/storage/perfschema/table_socket_instances.cc @@ -28,49 +28,6 @@ THR_LOCK table_socket_instances::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_INSTANCE_BEGIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SOCKET_ID") }, - { C_STRING_WITH_LEN("int(11)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("IP") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("PORT") }, - { C_STRING_WITH_LEN("int(11)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("STATE") }, - { C_STRING_WITH_LEN("enum('IDLE','ACTIVE')") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_socket_instances::m_field_def= -{ 7, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_socket_instances::m_share= { @@ -83,8 +40,14 @@ table_socket_instances::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE socket_instances(" + "EVENT_NAME VARCHAR(128) not null," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," + "THREAD_ID BIGINT unsigned," + "SOCKET_ID INTEGER not null," + "IP VARCHAR(64) not null," + "PORT INTEGER not null," + "STATE ENUM('IDLE','ACTIVE') not null)") } }; PFS_engine_table* table_socket_instances::create(void) diff --git a/storage/perfschema/table_socket_instances.h b/storage/perfschema/table_socket_instances.h index 080f11c1ba8..76ed8c47559 100644 --- a/storage/perfschema/table_socket_instances.h +++ b/storage/perfschema/table_socket_instances.h @@ -85,8 +85,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_socket_instances m_row; diff --git a/storage/perfschema/table_socket_summary_by_event_name.cc b/storage/perfschema/table_socket_summary_by_event_name.cc index 07bc9c9389a..512fe8e41d3 100644 --- a/storage/perfschema/table_socket_summary_by_event_name.cc +++ b/storage/perfschema/table_socket_summary_by_event_name.cc @@ -29,135 +29,6 @@ THR_LOCK table_socket_summary_by_event_name::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Read */ - { - { C_STRING_WITH_LEN("COUNT_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Write */ - { - { C_STRING_WITH_LEN("COUNT_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Misc */ - { - { C_STRING_WITH_LEN("COUNT_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_socket_summary_by_event_name::m_field_def= -{ 23, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_socket_summary_by_event_name::m_share= { @@ -170,8 +41,30 @@ table_socket_summary_by_event_name::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE socket_summary_by_event_name(" + "EVENT_NAME VARCHAR(128) not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "COUNT_READ BIGINT unsigned not null," + "SUM_TIMER_READ BIGINT unsigned not null," + "MIN_TIMER_READ BIGINT unsigned not null," + "AVG_TIMER_READ BIGINT unsigned not null," + "MAX_TIMER_READ BIGINT unsigned not null," + "SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null," + "COUNT_WRITE BIGINT unsigned not null," + "SUM_TIMER_WRITE BIGINT unsigned not null," + "MIN_TIMER_WRITE BIGINT unsigned not null," + "AVG_TIMER_WRITE BIGINT unsigned not null," + "MAX_TIMER_WRITE BIGINT unsigned not null," + "SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null," + "COUNT_MISC BIGINT unsigned not null," + "SUM_TIMER_MISC BIGINT unsigned not null," + "MIN_TIMER_MISC BIGINT unsigned not null," + "AVG_TIMER_MISC BIGINT unsigned not null," + "MAX_TIMER_MISC BIGINT unsigned not null)") } }; PFS_engine_table* table_socket_summary_by_event_name::create(void) diff --git a/storage/perfschema/table_socket_summary_by_event_name.h b/storage/perfschema/table_socket_summary_by_event_name.h index b34bed41f83..72a1e54fa99 100644 --- a/storage/perfschema/table_socket_summary_by_event_name.h +++ b/storage/perfschema/table_socket_summary_by_event_name.h @@ -75,8 +75,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_socket_summary_by_event_name m_row; diff --git a/storage/perfschema/table_socket_summary_by_instance.cc b/storage/perfschema/table_socket_summary_by_instance.cc index 3d092b9b1d0..4ab600d8c4e 100644 --- a/storage/perfschema/table_socket_summary_by_instance.cc +++ b/storage/perfschema/table_socket_summary_by_instance.cc @@ -28,140 +28,6 @@ THR_LOCK table_socket_summary_by_instance::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("EVENT_NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_INSTANCE_BEGIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Read */ - { - { C_STRING_WITH_LEN("COUNT_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Write */ - { - { C_STRING_WITH_LEN("COUNT_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_NUMBER_OF_BYTES_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - - /** Misc */ - { - { C_STRING_WITH_LEN("COUNT_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_MISC") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_socket_summary_by_instance::m_field_def= -{ 24, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_socket_summary_by_instance::m_share= { @@ -174,8 +40,31 @@ table_socket_summary_by_instance::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE socket_summary_by_instance(" + "EVENT_NAME VARCHAR(128) not null," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "COUNT_READ BIGINT unsigned not null," + "SUM_TIMER_READ BIGINT unsigned not null," + "MIN_TIMER_READ BIGINT unsigned not null," + "AVG_TIMER_READ BIGINT unsigned not null," + "MAX_TIMER_READ BIGINT unsigned not null," + "SUM_NUMBER_OF_BYTES_READ BIGINT unsigned not null," + "COUNT_WRITE BIGINT unsigned not null," + "SUM_TIMER_WRITE BIGINT unsigned not null," + "MIN_TIMER_WRITE BIGINT unsigned not null," + "AVG_TIMER_WRITE BIGINT unsigned not null," + "MAX_TIMER_WRITE BIGINT unsigned not null," + "SUM_NUMBER_OF_BYTES_WRITE BIGINT unsigned not null," + "COUNT_MISC BIGINT unsigned not null," + "SUM_TIMER_MISC BIGINT unsigned not null," + "MIN_TIMER_MISC BIGINT unsigned not null," + "AVG_TIMER_MISC BIGINT unsigned not null," + "MAX_TIMER_MISC BIGINT unsigned not null)") } }; PFS_engine_table* table_socket_summary_by_instance::create(void) diff --git a/storage/perfschema/table_socket_summary_by_instance.h b/storage/perfschema/table_socket_summary_by_instance.h index f4c8ea41d8c..949e99bfef9 100644 --- a/storage/perfschema/table_socket_summary_by_instance.h +++ b/storage/perfschema/table_socket_summary_by_instance.h @@ -78,8 +78,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_socket_summary_by_instance m_row; diff --git a/storage/perfschema/table_sync_instances.cc b/storage/perfschema/table_sync_instances.cc index 9b53eb3ce57..4bf5ae66938 100644 --- a/storage/perfschema/table_sync_instances.cc +++ b/storage/perfschema/table_sync_instances.cc @@ -29,29 +29,6 @@ THR_LOCK table_mutex_instances::m_table_lock; -static const TABLE_FIELD_TYPE mutex_field_types[]= -{ - { - { C_STRING_WITH_LEN("NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_INSTANCE_BEGIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("LOCKED_BY_THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_mutex_instances::m_field_def= -{ 3, mutex_field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_mutex_instances::m_share= { @@ -64,8 +41,10 @@ table_mutex_instances::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE mutex_instances(" + "NAME VARCHAR(128) not null," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," + "LOCKED_BY_THREAD_ID BIGINT unsigned)") } }; PFS_engine_table* table_mutex_instances::create(void) @@ -193,34 +172,6 @@ int table_mutex_instances::read_row_values(TABLE *table, THR_LOCK table_rwlock_instances::m_table_lock; -static const TABLE_FIELD_TYPE rwlock_field_types[]= -{ - { - { C_STRING_WITH_LEN("NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_INSTANCE_BEGIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("WRITE_LOCKED_BY_THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("READ_LOCKED_BY_COUNT") }, - { C_STRING_WITH_LEN("int(10)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_rwlock_instances::m_field_def= -{ 4, rwlock_field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_rwlock_instances::m_share= { @@ -233,8 +184,11 @@ table_rwlock_instances::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE rwlock_instances(" + "NAME VARCHAR(128) not null," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null," + "WRITE_LOCKED_BY_THREAD_ID BIGINT unsigned," + "READ_LOCKED_BY_COUNT INTEGER unsigned not null)") } }; PFS_engine_table* table_rwlock_instances::create(void) @@ -369,24 +323,6 @@ int table_rwlock_instances::read_row_values(TABLE *table, THR_LOCK table_cond_instances::m_table_lock; -static const TABLE_FIELD_TYPE cond_field_types[]= -{ - { - { C_STRING_WITH_LEN("NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_INSTANCE_BEGIN") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_cond_instances::m_field_def= -{ 2, cond_field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_cond_instances::m_share= { @@ -399,8 +335,9 @@ table_cond_instances::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE cond_instances(" + "NAME VARCHAR(128) not null," + "OBJECT_INSTANCE_BEGIN BIGINT unsigned not null)") } }; PFS_engine_table* table_cond_instances::create(void) diff --git a/storage/perfschema/table_sync_instances.h b/storage/perfschema/table_sync_instances.h index ff7b2765a11..da459268599 100644 --- a/storage/perfschema/table_sync_instances.h +++ b/storage/perfschema/table_sync_instances.h @@ -77,8 +77,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_mutex_instances m_row; @@ -136,8 +134,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_rwlock_instances m_row; @@ -189,8 +185,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_cond_instances m_row; diff --git a/storage/perfschema/table_threads.cc b/storage/perfschema/table_threads.cc index 1fd2486589c..5c78b567b8c 100644 --- a/storage/perfschema/table_threads.cc +++ b/storage/perfschema/table_threads.cc @@ -22,84 +22,6 @@ THR_LOCK table_threads::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("NAME") }, - { C_STRING_WITH_LEN("varchar(128)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TYPE") }, - { C_STRING_WITH_LEN("varchar(10)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("PROCESSLIST_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("PROCESSLIST_USER") }, - { C_STRING_WITH_LEN("varchar(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("PROCESSLIST_HOST") }, - { C_STRING_WITH_LEN("varchar(60)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("PROCESSLIST_DB") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("PROCESSLIST_COMMAND") }, - { C_STRING_WITH_LEN("varchar(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("PROCESSLIST_TIME") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("PROCESSLIST_STATE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("PROCESSLIST_INFO") }, - { C_STRING_WITH_LEN("longtext") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("PARENT_THREAD_ID") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("ROLE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("INSTRUMENTED") }, - { C_STRING_WITH_LEN("enum(\'YES\',\'NO\')") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_threads::m_field_def= -{ 14, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_threads::m_share= { @@ -112,8 +34,21 @@ table_threads::m_share= 1000, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE threads(" + "THREAD_ID BIGINT unsigned not null," + "NAME VARCHAR(128) not null," + "TYPE VARCHAR(10) not null," + "PROCESSLIST_ID BIGINT unsigned," + "PROCESSLIST_USER VARCHAR(16)," + "PROCESSLIST_HOST VARCHAR(60)," + "PROCESSLIST_DB VARCHAR(64)," + "PROCESSLIST_COMMAND VARCHAR(16)," + "PROCESSLIST_TIME BIGINT," + "PROCESSLIST_STATE VARCHAR(64)," + "PROCESSLIST_INFO LONGTEXT," + "PARENT_THREAD_ID BIGINT unsigned," + "ROLE VARCHAR(64)," + "INSTRUMENTED ENUM ('YES', 'NO') not null)") } }; PFS_engine_table* table_threads::create() diff --git a/storage/perfschema/table_threads.h b/storage/perfschema/table_threads.h index bce45c0cbce..10afbe14e74 100644 --- a/storage/perfschema/table_threads.h +++ b/storage/perfschema/table_threads.h @@ -102,8 +102,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_threads m_row; diff --git a/storage/perfschema/table_tiws_by_index_usage.cc b/storage/perfschema/table_tiws_by_index_usage.cc index 5f6d0cd2b5a..382b2f86b97 100644 --- a/storage/perfschema/table_tiws_by_index_usage.cc +++ b/storage/perfschema/table_tiws_by_index_usage.cc @@ -29,209 +29,6 @@ THR_LOCK table_tiws_by_index_usage::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("OBJECT_TYPE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_SCHEMA") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("INDEX_NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_FETCH") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_FETCH") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_FETCH") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_FETCH") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_FETCH") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_UPDATE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_UPDATE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_UPDATE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_UPDATE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_UPDATE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_DELETE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_DELETE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_DELETE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_DELETE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_DELETE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_tiws_by_index_usage::m_field_def= -{ 39, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_tiws_by_index_usage::m_share= { @@ -244,8 +41,46 @@ table_tiws_by_index_usage::m_share= 1000, /* records */ sizeof(pos_tiws_by_index_usage), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE table_io_waits_summary_by_index_usage(" + "OBJECT_TYPE VARCHAR(64)," + "OBJECT_SCHEMA VARCHAR(64)," + "OBJECT_NAME VARCHAR(64)," + "INDEX_NAME VARCHAR(64)," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "COUNT_READ BIGINT unsigned not null," + "SUM_TIMER_READ BIGINT unsigned not null," + "MIN_TIMER_READ BIGINT unsigned not null," + "AVG_TIMER_READ BIGINT unsigned not null," + "MAX_TIMER_READ BIGINT unsigned not null," + "COUNT_WRITE BIGINT unsigned not null," + "SUM_TIMER_WRITE BIGINT unsigned not null," + "MIN_TIMER_WRITE BIGINT unsigned not null," + "AVG_TIMER_WRITE BIGINT unsigned not null," + "MAX_TIMER_WRITE BIGINT unsigned not null," + "COUNT_FETCH BIGINT unsigned not null," + "SUM_TIMER_FETCH BIGINT unsigned not null," + "MIN_TIMER_FETCH BIGINT unsigned not null," + "AVG_TIMER_FETCH BIGINT unsigned not null," + "MAX_TIMER_FETCH BIGINT unsigned not null," + "COUNT_INSERT BIGINT unsigned not null," + "SUM_TIMER_INSERT BIGINT unsigned not null," + "MIN_TIMER_INSERT BIGINT unsigned not null," + "AVG_TIMER_INSERT BIGINT unsigned not null," + "MAX_TIMER_INSERT BIGINT unsigned not null," + "COUNT_UPDATE BIGINT unsigned not null," + "SUM_TIMER_UPDATE BIGINT unsigned not null," + "MIN_TIMER_UPDATE BIGINT unsigned not null," + "AVG_TIMER_UPDATE BIGINT unsigned not null," + "MAX_TIMER_UPDATE BIGINT unsigned not null," + "COUNT_DELETE BIGINT unsigned not null," + "SUM_TIMER_DELETE BIGINT unsigned not null," + "MIN_TIMER_DELETE BIGINT unsigned not null," + "AVG_TIMER_DELETE BIGINT unsigned not null," + "MAX_TIMER_DELETE BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_tiws_by_index_usage.h b/storage/perfschema/table_tiws_by_index_usage.h index b5f589d0cea..1528de2fe15 100644 --- a/storage/perfschema/table_tiws_by_index_usage.h +++ b/storage/perfschema/table_tiws_by_index_usage.h @@ -106,8 +106,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_tiws_by_index_usage m_row; diff --git a/storage/perfschema/table_tiws_by_table.cc b/storage/perfschema/table_tiws_by_table.cc index 7eeebccb8a9..ab1e9b115d6 100644 --- a/storage/perfschema/table_tiws_by_table.cc +++ b/storage/perfschema/table_tiws_by_table.cc @@ -29,204 +29,6 @@ THR_LOCK table_tiws_by_table::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("OBJECT_TYPE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_SCHEMA") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_FETCH") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_FETCH") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_FETCH") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_FETCH") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_FETCH") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_UPDATE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_UPDATE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_UPDATE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_UPDATE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_UPDATE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_DELETE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_DELETE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_DELETE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_DELETE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_DELETE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_tiws_by_table::m_field_def= -{ 38, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_tiws_by_table::m_share= { @@ -239,8 +41,45 @@ table_tiws_by_table::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE table_io_waits_summary_by_table(" + "OBJECT_TYPE VARCHAR(64)," + "OBJECT_SCHEMA VARCHAR(64)," + "OBJECT_NAME VARCHAR(64)," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "COUNT_READ BIGINT unsigned not null," + "SUM_TIMER_READ BIGINT unsigned not null," + "MIN_TIMER_READ BIGINT unsigned not null," + "AVG_TIMER_READ BIGINT unsigned not null," + "MAX_TIMER_READ BIGINT unsigned not null," + "COUNT_WRITE BIGINT unsigned not null," + "SUM_TIMER_WRITE BIGINT unsigned not null," + "MIN_TIMER_WRITE BIGINT unsigned not null," + "AVG_TIMER_WRITE BIGINT unsigned not null," + "MAX_TIMER_WRITE BIGINT unsigned not null," + "COUNT_FETCH BIGINT unsigned not null," + "SUM_TIMER_FETCH BIGINT unsigned not null," + "MIN_TIMER_FETCH BIGINT unsigned not null," + "AVG_TIMER_FETCH BIGINT unsigned not null," + "MAX_TIMER_FETCH BIGINT unsigned not null," + "COUNT_INSERT BIGINT unsigned not null," + "SUM_TIMER_INSERT BIGINT unsigned not null," + "MIN_TIMER_INSERT BIGINT unsigned not null," + "AVG_TIMER_INSERT BIGINT unsigned not null," + "MAX_TIMER_INSERT BIGINT unsigned not null," + "COUNT_UPDATE BIGINT unsigned not null," + "SUM_TIMER_UPDATE BIGINT unsigned not null," + "MIN_TIMER_UPDATE BIGINT unsigned not null," + "AVG_TIMER_UPDATE BIGINT unsigned not null," + "MAX_TIMER_UPDATE BIGINT unsigned not null," + "COUNT_DELETE BIGINT unsigned not null," + "SUM_TIMER_DELETE BIGINT unsigned not null," + "MIN_TIMER_DELETE BIGINT unsigned not null," + "AVG_TIMER_DELETE BIGINT unsigned not null," + "MAX_TIMER_DELETE BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_tiws_by_table.h b/storage/perfschema/table_tiws_by_table.h index ea52b5297d7..d11043188eb 100644 --- a/storage/perfschema/table_tiws_by_table.h +++ b/storage/perfschema/table_tiws_by_table.h @@ -76,8 +76,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_tiws_by_table m_row; diff --git a/storage/perfschema/table_tlws_by_table.cc b/storage/perfschema/table_tlws_by_table.cc index 6537e709549..bae120248ad 100644 --- a/storage/perfschema/table_tlws_by_table.cc +++ b/storage/perfschema/table_tlws_by_table.cc @@ -29,379 +29,6 @@ THR_LOCK table_tlws_by_table::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("OBJECT_TYPE") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_SCHEMA") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("OBJECT_NAME") }, - { C_STRING_WITH_LEN("varchar(64)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_STAR") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WAIT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_READ_NORMAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ_NORMAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ_NORMAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ_NORMAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ_NORMAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_READ_WITH_SHARED_LOCKS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ_WITH_SHARED_LOCKS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ_WITH_SHARED_LOCKS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ_WITH_SHARED_LOCKS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ_WITH_SHARED_LOCKS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_READ_HIGH_PRIORITY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ_HIGH_PRIORITY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ_HIGH_PRIORITY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ_HIGH_PRIORITY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ_HIGH_PRIORITY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_READ_NO_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ_NO_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ_NO_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ_NO_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ_NO_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_READ_EXTERNAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_READ_EXTERNAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_READ_EXTERNAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_READ_EXTERNAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_READ_EXTERNAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE_ALLOW_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE_ALLOW_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE_ALLOW_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE_ALLOW_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE_ALLOW_WRITE") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE_CONCURRENT_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE_CONCURRENT_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE_CONCURRENT_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE_CONCURRENT_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE_CONCURRENT_INSERT") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE_DELAYED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE_DELAYED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE_DELAYED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE_DELAYED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE_DELAYED") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE_LOW_PRIORITY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE_LOW_PRIORITY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE_LOW_PRIORITY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE_LOW_PRIORITY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE_LOW_PRIORITY") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE_NORMAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE_NORMAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE_NORMAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE_NORMAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE_NORMAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("COUNT_WRITE_EXTERNAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("SUM_TIMER_WRITE_EXTERNAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MIN_TIMER_WRITE_EXTERNAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("AVG_TIMER_WRITE_EXTERNAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("MAX_TIMER_WRITE_EXTERNAL") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_tlws_by_table::m_field_def= -{ 73, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_tlws_by_table::m_share= { @@ -414,8 +41,80 @@ table_tlws_by_table::m_share= 1000, /* records */ sizeof(PFS_simple_index), &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE table_lock_waits_summary_by_table(" + "OBJECT_TYPE VARCHAR(64)," + "OBJECT_SCHEMA VARCHAR(64)," + "OBJECT_NAME VARCHAR(64)," + "COUNT_STAR BIGINT unsigned not null," + "SUM_TIMER_WAIT BIGINT unsigned not null," + "MIN_TIMER_WAIT BIGINT unsigned not null," + "AVG_TIMER_WAIT BIGINT unsigned not null," + "MAX_TIMER_WAIT BIGINT unsigned not null," + "COUNT_READ BIGINT unsigned not null," + "SUM_TIMER_READ BIGINT unsigned not null," + "MIN_TIMER_READ BIGINT unsigned not null," + "AVG_TIMER_READ BIGINT unsigned not null," + "MAX_TIMER_READ BIGINT unsigned not null," + "COUNT_WRITE BIGINT unsigned not null," + "SUM_TIMER_WRITE BIGINT unsigned not null," + "MIN_TIMER_WRITE BIGINT unsigned not null," + "AVG_TIMER_WRITE BIGINT unsigned not null," + "MAX_TIMER_WRITE BIGINT unsigned not null," + "COUNT_READ_NORMAL BIGINT unsigned not null," + "SUM_TIMER_READ_NORMAL BIGINT unsigned not null," + "MIN_TIMER_READ_NORMAL BIGINT unsigned not null," + "AVG_TIMER_READ_NORMAL BIGINT unsigned not null," + "MAX_TIMER_READ_NORMAL BIGINT unsigned not null," + "COUNT_READ_WITH_SHARED_LOCKS BIGINT unsigned not null," + "SUM_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null," + "MIN_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null," + "AVG_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null," + "MAX_TIMER_READ_WITH_SHARED_LOCKS BIGINT unsigned not null," + "COUNT_READ_HIGH_PRIORITY BIGINT unsigned not null," + "SUM_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null," + "MIN_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null," + "AVG_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null," + "MAX_TIMER_READ_HIGH_PRIORITY BIGINT unsigned not null," + "COUNT_READ_NO_INSERT BIGINT unsigned not null," + "SUM_TIMER_READ_NO_INSERT BIGINT unsigned not null," + "MIN_TIMER_READ_NO_INSERT BIGINT unsigned not null," + "AVG_TIMER_READ_NO_INSERT BIGINT unsigned not null," + "MAX_TIMER_READ_NO_INSERT BIGINT unsigned not null," + "COUNT_READ_EXTERNAL BIGINT unsigned not null," + "SUM_TIMER_READ_EXTERNAL BIGINT unsigned not null," + "MIN_TIMER_READ_EXTERNAL BIGINT unsigned not null," + "AVG_TIMER_READ_EXTERNAL BIGINT unsigned not null," + "MAX_TIMER_READ_EXTERNAL BIGINT unsigned not null," + "COUNT_WRITE_ALLOW_WRITE BIGINT unsigned not null," + "SUM_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null," + "MIN_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null," + "AVG_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null," + "MAX_TIMER_WRITE_ALLOW_WRITE BIGINT unsigned not null," + "COUNT_WRITE_CONCURRENT_INSERT BIGINT unsigned not null," + "SUM_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null," + "MIN_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null," + "AVG_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null," + "MAX_TIMER_WRITE_CONCURRENT_INSERT BIGINT unsigned not null," + "COUNT_WRITE_DELAYED BIGINT unsigned not null," + "SUM_TIMER_WRITE_DELAYED BIGINT unsigned not null," + "MIN_TIMER_WRITE_DELAYED BIGINT unsigned not null," + "AVG_TIMER_WRITE_DELAYED BIGINT unsigned not null," + "MAX_TIMER_WRITE_DELAYED BIGINT unsigned not null," + "COUNT_WRITE_LOW_PRIORITY BIGINT unsigned not null," + "SUM_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null," + "MIN_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null," + "AVG_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null," + "MAX_TIMER_WRITE_LOW_PRIORITY BIGINT unsigned not null," + "COUNT_WRITE_NORMAL BIGINT unsigned not null," + "SUM_TIMER_WRITE_NORMAL BIGINT unsigned not null," + "MIN_TIMER_WRITE_NORMAL BIGINT unsigned not null," + "AVG_TIMER_WRITE_NORMAL BIGINT unsigned not null," + "MAX_TIMER_WRITE_NORMAL BIGINT unsigned not null," + "COUNT_WRITE_EXTERNAL BIGINT unsigned not null," + "SUM_TIMER_WRITE_EXTERNAL BIGINT unsigned not null," + "MIN_TIMER_WRITE_EXTERNAL BIGINT unsigned not null," + "AVG_TIMER_WRITE_EXTERNAL BIGINT unsigned not null," + "MAX_TIMER_WRITE_EXTERNAL BIGINT unsigned not null)") } }; PFS_engine_table* diff --git a/storage/perfschema/table_tlws_by_table.h b/storage/perfschema/table_tlws_by_table.h index fc396447bcf..f5bf6a99f46 100644 --- a/storage/perfschema/table_tlws_by_table.h +++ b/storage/perfschema/table_tlws_by_table.h @@ -76,8 +76,6 @@ protected: private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_tlws_by_table m_row; diff --git a/storage/perfschema/table_users.cc b/storage/perfschema/table_users.cc index 1f6b861342d..134ebb08d26 100644 --- a/storage/perfschema/table_users.cc +++ b/storage/perfschema/table_users.cc @@ -24,29 +24,6 @@ THR_LOCK table_users::m_table_lock; -static const TABLE_FIELD_TYPE field_types[]= -{ - { - { C_STRING_WITH_LEN("USER") }, - { C_STRING_WITH_LEN("char(16)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("CURRENT_CONNECTIONS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - }, - { - { C_STRING_WITH_LEN("TOTAL_CONNECTIONS") }, - { C_STRING_WITH_LEN("bigint(20)") }, - { NULL, 0} - } -}; - -TABLE_FIELD_DEF -table_users::m_field_def= -{ 3, field_types, 0, (uint*) 0 }; - PFS_engine_table_share table_users::m_share= { @@ -59,8 +36,10 @@ table_users::m_share= 1000, /* records */ sizeof(PFS_simple_index), /* ref length */ &m_table_lock, - &m_field_def, - false /* checked */ + { C_STRING_WITH_LEN("CREATE TABLE users(" + "USER CHAR(16) collate utf8_bin default null," + "CURRENT_CONNECTIONS bigint not null," + "TOTAL_CONNECTIONS bigint not null)") } }; PFS_engine_table* table_users::create() diff --git a/storage/perfschema/table_users.h b/storage/perfschema/table_users.h index 94ea44832d1..5d673cbda9c 100644 --- a/storage/perfschema/table_users.h +++ b/storage/perfschema/table_users.h @@ -67,8 +67,6 @@ private: /** Table share lock. */ static THR_LOCK m_table_lock; - /** Fields definition. */ - static TABLE_FIELD_DEF m_field_def; /** Current row. */ row_users m_row; diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index 6d9bd1a500a..c29888b8b15 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -313,6 +313,7 @@ SET(INNOBASE_SOURCES btr/btr0cur.cc btr/btr0pcur.cc btr/btr0sea.cc + btr/btr0defragment.cc buf/buf0buddy.cc buf/buf0buf.cc buf/buf0dblwr.cc @@ -426,7 +427,8 @@ SET(INNOBASE_SOURCES ut/ut0rnd.cc ut/ut0ut.cc ut/ut0vec.cc - ut/ut0wqueue.cc) + ut/ut0wqueue.cc + ut/ut0timer.cc) IF(WITH_WSREP) SET(INNOBASE_SOURCES ${INNOBASE_SOURCES} wsrep/md5.cc) diff --git a/storage/xtradb/btr/btr0btr.cc b/storage/xtradb/btr/btr0btr.cc index cce91bdab6e..926c3be0fb5 100644 --- a/storage/xtradb/btr/btr0btr.cc +++ b/storage/xtradb/btr/btr0btr.cc @@ -38,6 +38,7 @@ Created 6/2/1994 Heikki Tuuri #include "btr0cur.h" #include "btr0sea.h" #include "btr0pcur.h" +#include "btr0defragment.h" #include "rem0cmp.h" #include "lock0lock.h" #include "ibuf0ibuf.h" @@ -1213,6 +1214,32 @@ btr_get_size( mtr_t* mtr) /*!< in/out: mini-transaction where index is s-latched */ { + ulint used; + if (flag == BTR_N_LEAF_PAGES) { + btr_get_size_and_reserved(index, flag, &used, mtr); + return used; + } else if (flag == BTR_TOTAL_SIZE) { + return btr_get_size_and_reserved(index, flag, &used, mtr); + } else { + ut_error; + } + return (ULINT_UNDEFINED); +} + +/**************************************************************//** +Gets the number of reserved and used pages in a B-tree. +@return number of pages reserved, or ULINT_UNDEFINED if the index +is unavailable */ +UNIV_INTERN +ulint +btr_get_size_and_reserved( +/*======================*/ + dict_index_t* index, /*!< in: index */ + ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */ + ulint* used, /*!< out: number of pages used (<= reserved) */ + mtr_t* mtr) /*!< in/out: mini-transaction where index + is s-latched */ +{ fseg_header_t* seg_header; page_t* root; ulint n; @@ -1221,6 +1248,8 @@ btr_get_size( ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), MTR_MEMO_S_LOCK)); + ut_a(flag == BTR_N_LEAF_PAGES || flag == BTR_TOTAL_SIZE); + if (index->page == FIL_NULL || dict_index_is_online_ddl(index) || *index->name == TEMP_INDEX_PREFIX) { return(ULINT_UNDEFINED); @@ -1228,27 +1257,16 @@ btr_get_size( root = btr_root_get(index, mtr); - SRV_CORRUPT_TABLE_CHECK(root, - { - mtr_commit(mtr); - return(0); - }); + seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; - if (flag == BTR_N_LEAF_PAGES) { - seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; - - fseg_n_reserved_pages(seg_header, &n, mtr); + n = fseg_n_reserved_pages(seg_header, used, mtr); - } else if (flag == BTR_TOTAL_SIZE) { + if (flag == BTR_TOTAL_SIZE) { seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_TOP; - n = fseg_n_reserved_pages(seg_header, &dummy, mtr); - - seg_header = root + PAGE_HEADER + PAGE_BTR_SEG_LEAF; - n += fseg_n_reserved_pages(seg_header, &dummy, mtr); - } else { - ut_error; + *used += dummy; + } return(n); @@ -2013,7 +2031,7 @@ IBUF_BITMAP_FREE is unaffected by reorganization. @retval true if the operation was successful @retval false if it is a compressed page, and recompression failed */ -static __attribute__((nonnull)) +UNIV_INTERN bool btr_page_reorganize_block( /*======================*/ @@ -2965,6 +2983,12 @@ func_start: new_page_zip = buf_block_get_page_zip(new_block); btr_page_create(new_block, new_page_zip, cursor->index, btr_page_get_level(page, mtr), mtr); + /* Only record the leaf level page splits. */ + if (btr_page_get_level(page, mtr) == 0) { + cursor->index->stat_defrag_n_page_split ++; + cursor->index->stat_defrag_modified_counter ++; + btr_defragment_save_defrag_stats_if_needed(cursor->index); + } /* 3. Calculate the first record on the upper half-page, and the first record (move_limit) on original page which ends up on the @@ -3223,31 +3247,9 @@ func_exit: return(rec); } -#ifdef UNIV_SYNC_DEBUG -/*************************************************************//** -Removes a page from the level list of pages. -@param space in: space where removed -@param zip_size in: compressed page size in bytes, or 0 for uncompressed -@param page in/out: page to remove -@param index in: index tree -@param mtr in/out: mini-transaction */ -# define btr_level_list_remove(space,zip_size,page,index,mtr) \ - btr_level_list_remove_func(space,zip_size,page,index,mtr) -#else /* UNIV_SYNC_DEBUG */ -/*************************************************************//** -Removes a page from the level list of pages. -@param space in: space where removed -@param zip_size in: compressed page size in bytes, or 0 for uncompressed -@param page in/out: page to remove -@param index in: index tree -@param mtr in/out: mini-transaction */ -# define btr_level_list_remove(space,zip_size,page,index,mtr) \ - btr_level_list_remove_func(space,zip_size,page,mtr) -#endif /* UNIV_SYNC_DEBUG */ - /*************************************************************//** Removes a page from the level list of pages. */ -static __attribute__((nonnull)) +UNIV_INTERN void btr_level_list_remove_func( /*=======================*/ @@ -3419,7 +3421,7 @@ btr_node_ptr_delete( If page is the only on its level, this function moves its records to the father page, thus reducing the tree height. @return father block */ -static +UNIV_INTERN buf_block_t* btr_lift_page_up( /*=============*/ diff --git a/storage/xtradb/btr/btr0defragment.cc b/storage/xtradb/btr/btr0defragment.cc new file mode 100644 index 00000000000..b4edda13b45 --- /dev/null +++ b/storage/xtradb/btr/btr0defragment.cc @@ -0,0 +1,818 @@ +/***************************************************************************** + +Copyright (C) 2012, 2014 Facebook, Inc. All Rights Reserved. +Copyright (C) 2014, SkySQL Ab. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + +*****************************************************************************/ +/**************************************************//** +@file btr/btr0defragment.cc +Index defragmentation. + +Created 05/29/2014 Rongrong Zhong +Modified 16/07/2014 Sunguck Lee +Modified 30/07/2014 Jan Lindström jan.lindstrom@skysql.com +*******************************************************/ + +#include "btr0defragment.h" +#ifndef UNIV_HOTBACKUP +#include "btr0cur.h" +#include "btr0sea.h" +#include "btr0pcur.h" +#include "dict0stats.h" +#include "dict0stats_bg.h" +#include "ibuf0ibuf.h" +#include "lock0lock.h" +#include "srv0start.h" +#include "srv0srv.h" +#include "ut0timer.h" + +#include <list> + +/**************************************************//** +Custom nullptr implementation for under g++ 4.6 +*******************************************************/ +/* +// #pragma once +namespace std +{ + // based on SC22/WG21/N2431 = J16/07-0301 + struct nullptr_t + { + template<typename any> operator any * () const + { + return 0; + } + template<class any, typename T> operator T any:: * () const + { + return 0; + } + +#ifdef _MSC_VER + struct pad {}; + pad __[sizeof(void*)/sizeof(pad)]; +#else + char __[sizeof(void*)]; +#endif +private: + // nullptr_t();// {} + // nullptr_t(const nullptr_t&); + // void operator = (const nullptr_t&); + void operator &() const; + template<typename any> void operator +(any) const + { + // I Love MSVC 2005! + } + template<typename any> void operator -(any) const + { + // I Love MSVC 2005! + } + }; +static const nullptr_t __nullptr = {}; +} + +#ifndef nullptr +#define nullptr std::__nullptr +#endif +*/ +/**************************************************//** +End of Custom nullptr implementation for under g++ 4.6 +*******************************************************/ + +/* When there's no work, either because defragment is disabled, or because no +query is submitted, thread checks state every BTR_DEFRAGMENT_SLEEP_IN_USECS.*/ +#define BTR_DEFRAGMENT_SLEEP_IN_USECS 1000000 +/* Reduce the target page size by this amount when compression failure happens +during defragmentaiton. 512 is chosen because it's a power of 2 and it is about +3% of the page size. When there are compression failures in defragmentation, +our goal is to get a decent defrag ratio with as few compression failure as +possible. From experimentation it seems that reduce the target size by 512 every +time will make sure the page is compressible within a couple of iterations. */ +#define BTR_DEFRAGMENT_PAGE_REDUCTION_STEP_SIZE 512 + +/* Work queue for defragmentation. */ +typedef std::list<btr_defragment_item_t*> btr_defragment_wq_t; +static btr_defragment_wq_t btr_defragment_wq; + +/* Mutex protecting the defragmentation work queue.*/ +ib_mutex_t btr_defragment_mutex; +#ifdef UNIV_PFS_MUTEX +UNIV_INTERN mysql_pfs_key_t btr_defragment_mutex_key; +#endif /* UNIV_PFS_MUTEX */ + +/* Number of compression failures caused by defragmentation since server +start. */ +ulint btr_defragment_compression_failures = 0; +/* Number of btr_defragment_n_pages calls that altered page but didn't +manage to release any page. */ +ulint btr_defragment_failures = 0; +/* Total number of btr_defragment_n_pages calls that altered page. +The difference between btr_defragment_count and btr_defragment_failures shows +the amount of effort wasted. */ +ulint btr_defragment_count = 0; + +/******************************************************************//** +Constructor for btr_defragment_item_t. */ +btr_defragment_item_t::btr_defragment_item_t( + btr_pcur_t* pcur, + os_event_t event) +{ + this->pcur = pcur; + this->event = event; + this->removed = false; + this->last_processed = 0; +} + +/******************************************************************//** +Destructor for btr_defragment_item_t. */ +btr_defragment_item_t::~btr_defragment_item_t() { + if (this->pcur) { + btr_pcur_free_for_mysql(this->pcur); + } + if (this->event) { + os_event_set(this->event); + } +} + +/******************************************************************//** +Initialize defragmentation. */ +void +btr_defragment_init() +{ + srv_defragment_interval = ut_microseconds_to_timer( + 1000000.0 / srv_defragment_frequency); + mutex_create(btr_defragment_mutex_key, &btr_defragment_mutex, + SYNC_ANY_LATCH); + os_thread_create(btr_defragment_thread, NULL, NULL); +} + +/******************************************************************//** +Shutdown defragmentation. Release all resources. */ +void +btr_defragment_shutdown() +{ + mutex_enter(&btr_defragment_mutex); + list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + while(iter != btr_defragment_wq.end()) { + btr_defragment_item_t* item = *iter; + iter = btr_defragment_wq.erase(iter); + delete item; + } + mutex_exit(&btr_defragment_mutex); + mutex_free(&btr_defragment_mutex); +} + + +/******************************************************************//** +Functions used by the query threads: btr_defragment_xxx_index +Query threads find/add/remove index. */ +/******************************************************************//** +Check whether the given index is in btr_defragment_wq. We use index->id +to identify indices. */ +bool +btr_defragment_find_index( + dict_index_t* index) /*!< Index to find. */ +{ + mutex_enter(&btr_defragment_mutex); + for (list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + iter != btr_defragment_wq.end(); + ++iter) { + btr_defragment_item_t* item = *iter; + btr_pcur_t* pcur = item->pcur; + btr_cur_t* cursor = btr_pcur_get_btr_cur(pcur); + dict_index_t* idx = btr_cur_get_index(cursor); + if (index->id == idx->id) { + mutex_exit(&btr_defragment_mutex); + return true; + } + } + mutex_exit(&btr_defragment_mutex); + return false; +} + +/******************************************************************//** +Query thread uses this function to add an index to btr_defragment_wq. +Return a pointer to os_event for the query thread to wait on if this is a +synchronized defragmentation. */ +os_event_t +btr_defragment_add_index( + dict_index_t* index, /*!< index to be added */ + bool async) /*!< whether this is an async defragmentation */ +{ + mtr_t mtr; + ulint space = dict_index_get_space(index); + ulint zip_size = dict_table_zip_size(index->table); + ulint page_no = dict_index_get_page(index); + mtr_start(&mtr); + // Load index rood page. + page_t* page = btr_page_get(space, zip_size, page_no, + RW_NO_LATCH, index, &mtr); + if (btr_page_get_level(page, &mtr) == 0) { + // Index root is a leaf page, no need to defragment. + mtr_commit(&mtr); + return NULL; + } + btr_pcur_t* pcur = btr_pcur_create_for_mysql(); + os_event_t event = NULL; + if (!async) { + event = os_event_create(); + } + btr_pcur_open_at_index_side(true, index, BTR_SEARCH_LEAF, pcur, + true, 0, &mtr); + btr_pcur_move_to_next(pcur, &mtr); + btr_pcur_store_position(pcur, &mtr); + mtr_commit(&mtr); + dict_stats_empty_defrag_summary(index); + btr_defragment_item_t* item = new btr_defragment_item_t(pcur, event); + mutex_enter(&btr_defragment_mutex); + btr_defragment_wq.push_back(item); + mutex_exit(&btr_defragment_mutex); + return event; +} + +/******************************************************************//** +When table is dropped, this function is called to mark a table as removed in +btr_efragment_wq. The difference between this function and the remove_index +function is this will not NULL the event. */ +void +btr_defragment_remove_table( + dict_table_t* table) /*!< Index to be removed. */ +{ + mutex_enter(&btr_defragment_mutex); + for (list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + iter != btr_defragment_wq.end(); + ++iter) { + btr_defragment_item_t* item = *iter; + btr_pcur_t* pcur = item->pcur; + btr_cur_t* cursor = btr_pcur_get_btr_cur(pcur); + dict_index_t* idx = btr_cur_get_index(cursor); + if (table->id == idx->table->id) { + item->removed = true; + } + } + mutex_exit(&btr_defragment_mutex); +} + +/******************************************************************//** +Query thread uses this function to mark an index as removed in +btr_efragment_wq. */ +void +btr_defragment_remove_index( + dict_index_t* index) /*!< Index to be removed. */ +{ + mutex_enter(&btr_defragment_mutex); + for (list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + iter != btr_defragment_wq.end(); + ++iter) { + btr_defragment_item_t* item = *iter; + btr_pcur_t* pcur = item->pcur; + btr_cur_t* cursor = btr_pcur_get_btr_cur(pcur); + dict_index_t* idx = btr_cur_get_index(cursor); + if (index->id == idx->id) { + item->removed = true; + item->event = NULL; + break; + } + } + mutex_exit(&btr_defragment_mutex); +} + +/******************************************************************//** +Functions used by defragmentation thread: btr_defragment_xxx_item. +Defragmentation thread operates on the work *item*. It gets/removes +item from the work queue. */ +/******************************************************************//** +Defragment thread uses this to remove an item from btr_defragment_wq. +When an item is removed from the work queue, all resources associated with it +are free as well. */ +void +btr_defragment_remove_item( + btr_defragment_item_t* item) /*!< Item to be removed. */ +{ + mutex_enter(&btr_defragment_mutex); + for (list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + iter != btr_defragment_wq.end(); + ++iter) { + if (item == *iter) { + btr_defragment_wq.erase(iter); + delete item; + break; + } + } + mutex_exit(&btr_defragment_mutex); +} + +/******************************************************************//** +Defragment thread uses this to get an item from btr_defragment_wq to work on. +The item is not removed from the work queue so query threads can still access +this item. We keep it this way so query threads can find and kill a +defragmentation even if that index is being worked on. Be aware that while you +work on this item you have no lock protection on it whatsoever. This is OK as +long as the query threads and defragment thread won't modify the same fields +without lock protection. +*/ +btr_defragment_item_t* +btr_defragment_get_item() +{ + if (btr_defragment_wq.empty()) { + return NULL; + //return nullptr; + } + mutex_enter(&btr_defragment_mutex); + list< btr_defragment_item_t* >::iterator iter = btr_defragment_wq.begin(); + if (iter == btr_defragment_wq.end()) { + iter = btr_defragment_wq.begin(); + } + btr_defragment_item_t* item = *iter; + iter++; + mutex_exit(&btr_defragment_mutex); + return item; +} + +/*********************************************************************//** +Check whether we should save defragmentation statistics to persistent storage. +Currently we save the stats to persistent storage every 100 updates. */ +UNIV_INTERN +void +btr_defragment_save_defrag_stats_if_needed( + dict_index_t* index) /*!< in: index */ +{ + if (srv_defragment_stats_accuracy != 0 // stats tracking disabled + && dict_index_get_space(index) != 0 // do not track system tables + && index->stat_defrag_modified_counter + >= srv_defragment_stats_accuracy) { + dict_stats_defrag_pool_add(index); + index->stat_defrag_modified_counter = 0; + } +} + +/*********************************************************************//** +Main defragment functionalities used by defragment thread.*/ +/*************************************************************//** +Calculate number of records from beginning of block that can +fit into size_limit +@return number of records */ +UNIV_INTERN +ulint +btr_defragment_calc_n_recs_for_size( + buf_block_t* block, /*!< in: B-tree page */ + dict_index_t* index, /*!< in: index of the page */ + ulint size_limit, /*!< in: size limit to fit records in */ + ulint* n_recs_size) /*!< out: actual size of the records that fit + in size_limit. */ +{ + page_t* page = buf_block_get_frame(block); + ulint n_recs = 0; + ulint offsets_[REC_OFFS_NORMAL_SIZE]; + ulint* offsets = offsets_; + rec_offs_init(offsets_); + mem_heap_t* heap = NULL; + ulint size = 0; + page_cur_t cur; + + page_cur_set_before_first(block, &cur); + page_cur_move_to_next(&cur); + while (page_cur_get_rec(&cur) != page_get_supremum_rec(page)) { + rec_t* cur_rec = page_cur_get_rec(&cur); + offsets = rec_get_offsets(cur_rec, index, offsets, + ULINT_UNDEFINED, &heap); + ulint rec_size = rec_offs_size(offsets); + size += rec_size; + if (size > size_limit) { + size = size - rec_size; + break; + } + n_recs ++; + page_cur_move_to_next(&cur); + } + *n_recs_size = size; + return n_recs; +} + +/*************************************************************//** +Merge as many records from the from_block to the to_block. Delete +the from_block if all records are successfully merged to to_block. +@return the to_block to target for next merge operation. */ +UNIV_INTERN +buf_block_t* +btr_defragment_merge_pages( + dict_index_t* index, /*!< in: index tree */ + buf_block_t* from_block, /*!< in: origin of merge */ + buf_block_t* to_block, /*!< in: destination of merge */ + ulint zip_size, /*!< in: zip size of the block */ + ulint reserved_space, /*!< in: space reserved for future + insert to avoid immediate page split */ + ulint* max_data_size, /*!< in/out: max data size to + fit in a single compressed page. */ + mem_heap_t* heap, /*!< in/out: pointer to memory heap */ + mtr_t* mtr) /*!< in/out: mini-transaction */ +{ + page_t* from_page = buf_block_get_frame(from_block); + page_t* to_page = buf_block_get_frame(to_block); + ulint space = dict_index_get_space(index); + ulint level = btr_page_get_level(from_page, mtr); + ulint n_recs = page_get_n_recs(from_page); + ulint new_data_size = page_get_data_size(to_page); + ulint max_ins_size = + page_get_max_insert_size(to_page, n_recs); + ulint max_ins_size_reorg = + page_get_max_insert_size_after_reorganize( + to_page, n_recs); + ulint max_ins_size_to_use = max_ins_size_reorg > reserved_space + ? max_ins_size_reorg - reserved_space : 0; + ulint move_size = 0; + ulint n_recs_to_move = 0; + rec_t* rec = NULL; + ulint target_n_recs = 0; + rec_t* orig_pred; + + // Estimate how many records can be moved from the from_page to + // the to_page. + if (zip_size) { + ulint page_diff = UNIV_PAGE_SIZE - *max_data_size; + max_ins_size_to_use = (max_ins_size_to_use > page_diff) + ? max_ins_size_to_use - page_diff : 0; + } + n_recs_to_move = btr_defragment_calc_n_recs_for_size( + from_block, index, max_ins_size_to_use, &move_size); + + // If max_ins_size >= move_size, we can move the records without + // reorganizing the page, otherwise we need to reorganize the page + // first to release more space. + if (move_size > max_ins_size) { + if (!btr_page_reorganize_block(false, page_zip_level, + to_block, index, + mtr)) { + if (!dict_index_is_clust(index) + && page_is_leaf(to_page)) { + ibuf_reset_free_bits(to_block); + } + // If reorganization fails, that means page is + // not compressable. There's no point to try + // merging into this page. Continue to the + // next page. + return from_block; + } + ut_ad(page_validate(to_page, index)); + max_ins_size = page_get_max_insert_size(to_page, n_recs); + ut_a(max_ins_size >= move_size); + } + + // Move records to pack to_page more full. + orig_pred = NULL; + target_n_recs = n_recs_to_move; + while (n_recs_to_move > 0) { + rec = page_rec_get_nth(from_page, + n_recs_to_move + 1); + orig_pred = page_copy_rec_list_start( + to_block, from_block, rec, index, mtr); + if (orig_pred) + break; + // If we reach here, that means compression failed after packing + // n_recs_to_move number of records to to_page. We try to reduce + // the targeted data size on the to_page by + // BTR_DEFRAGMENT_PAGE_REDUCTION_STEP_SIZE and try again. + os_atomic_increment_ulint( + &btr_defragment_compression_failures, 1); + max_ins_size_to_use = + move_size > BTR_DEFRAGMENT_PAGE_REDUCTION_STEP_SIZE + ? move_size - BTR_DEFRAGMENT_PAGE_REDUCTION_STEP_SIZE + : 0; + if (max_ins_size_to_use == 0) { + n_recs_to_move = 0; + move_size = 0; + break; + } + n_recs_to_move = btr_defragment_calc_n_recs_for_size( + from_block, index, max_ins_size_to_use, &move_size); + } + // If less than target_n_recs are moved, it means there are + // compression failures during page_copy_rec_list_start. Adjust + // the max_data_size estimation to reduce compression failures + // in the following runs. + if (target_n_recs > n_recs_to_move + && *max_data_size > new_data_size + move_size) { + *max_data_size = new_data_size + move_size; + } + // Set ibuf free bits if necessary. + if (!dict_index_is_clust(index) + && page_is_leaf(to_page)) { + if (zip_size) { + ibuf_reset_free_bits(to_block); + } else { + ibuf_update_free_bits_if_full( + to_block, + UNIV_PAGE_SIZE, + ULINT_UNDEFINED); + } + } + if (n_recs_to_move == n_recs) { + /* The whole page is merged with the previous page, + free it. */ + lock_update_merge_left(to_block, orig_pred, + from_block); + btr_search_drop_page_hash_index(from_block); + btr_level_list_remove(space, zip_size, from_page, + index, mtr); + btr_node_ptr_delete(index, from_block, mtr); + btr_blob_dbg_remove(from_page, index, + "btr_defragment_n_pages"); + btr_page_free(index, from_block, mtr); + } else { + // There are still records left on the page, so + // increment n_defragmented. Node pointer will be changed + // so remove the old node pointer. + if (n_recs_to_move > 0) { + // Part of the page is merged to left, remove + // the merged records, update record locks and + // node pointer. + dtuple_t* node_ptr; + page_delete_rec_list_start(rec, from_block, + index, mtr); + lock_update_split_and_merge(to_block, + orig_pred, + from_block); + btr_node_ptr_delete(index, from_block, mtr); + rec = page_rec_get_next( + page_get_infimum_rec(from_page)); + node_ptr = dict_index_build_node_ptr( + index, rec, page_get_page_no(from_page), + heap, level + 1); + btr_insert_on_non_leaf_level(0, index, level+1, + node_ptr, mtr); + } + to_block = from_block; + } + return to_block; +} + +/*************************************************************//** +Tries to merge N consecutive pages, starting from the page pointed by the +cursor. Skip space 0. Only consider leaf pages. +This function first loads all N pages into memory, then for each of +the pages other than the first page, it tries to move as many records +as possible to the left sibling to keep the left sibling full. During +the process, if any page becomes empty, that page will be removed from +the level list. Record locks, hash, and node pointers are updated after +page reorganization. +@return pointer to the last block processed, or NULL if reaching end of index */ +UNIV_INTERN +buf_block_t* +btr_defragment_n_pages( + buf_block_t* block, /*!< in: starting block for defragmentation */ + dict_index_t* index, /*!< in: index tree */ + uint n_pages,/*!< in: number of pages to defragment */ + mtr_t* mtr) /*!< in/out: mini-transaction */ +{ + ulint space; + ulint zip_size; + /* We will need to load the n+1 block because if the last page is freed + and we need to modify the prev_page_no of that block. */ + buf_block_t* blocks[BTR_DEFRAGMENT_MAX_N_PAGES + 1]; + page_t* first_page; + buf_block_t* current_block; + ulint total_data_size = 0; + ulint total_n_recs = 0; + ulint data_size_per_rec; + ulint optimal_page_size; + ulint reserved_space; + ulint level; + ulint max_data_size = 0; + uint n_defragmented = 0; + uint n_new_slots; + mem_heap_t* heap; + ibool end_of_index = FALSE; + + /* It doesn't make sense to call this function with n_pages = 1. */ + ut_ad(n_pages > 1); + + ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), + MTR_MEMO_X_LOCK)); + space = dict_index_get_space(index); + if (space == 0) { + /* Ignore space 0. */ + return NULL; + } + + if (n_pages > BTR_DEFRAGMENT_MAX_N_PAGES) { + n_pages = BTR_DEFRAGMENT_MAX_N_PAGES; + } + + zip_size = dict_table_zip_size(index->table); + first_page = buf_block_get_frame(block); + level = btr_page_get_level(first_page, mtr); + + if (level != 0) { + return NULL; + } + + /* 1. Load the pages and calculate the total data size. */ + blocks[0] = block; + for (uint i = 1; i <= n_pages; i++) { + page_t* page = buf_block_get_frame(blocks[i-1]); + ulint page_no = btr_page_get_next(page, mtr); + total_data_size += page_get_data_size(page); + total_n_recs += page_get_n_recs(page); + if (page_no == FIL_NULL) { + n_pages = i; + end_of_index = TRUE; + break; + } + blocks[i] = btr_block_get(space, zip_size, page_no, + RW_X_LATCH, index, mtr); + } + + if (n_pages == 1) { + if (btr_page_get_prev(first_page, mtr) == FIL_NULL) { + /* last page in the index */ + if (dict_index_get_page(index) + == page_get_page_no(first_page)) + return NULL; + /* given page is the last page. + Lift the records to father. */ + btr_lift_page_up(index, block, mtr); + } + return NULL; + } + + /* 2. Calculate how many pages data can fit in. If not compressable, + return early. */ + ut_a(total_n_recs != 0); + data_size_per_rec = total_data_size / total_n_recs; + // For uncompressed pages, the optimal data size if the free space of a + // empty page. + optimal_page_size = page_get_free_space_of_empty( + page_is_comp(first_page)); + // For compressed pages, we take compression failures into account. + if (zip_size) { + ulint size = 0; + int i = 0; + // We estimate the optimal data size of the index use samples of + // data size. These samples are taken when pages failed to + // compress due to insertion on the page. We use the average + // of all samples we have as the estimation. Different pages of + // the same index vary in compressibility. Average gives a good + // enough estimation. + for (;i < STAT_DEFRAG_DATA_SIZE_N_SAMPLE; i++) { + if (index->stat_defrag_data_size_sample[i] == 0) { + break; + } + size += index->stat_defrag_data_size_sample[i]; + } + if (i != 0) { + size = size / i; + optimal_page_size = min(optimal_page_size, size); + } + max_data_size = optimal_page_size; + } + + reserved_space = min((ulint)(optimal_page_size + * (1 - srv_defragment_fill_factor)), + (data_size_per_rec + * srv_defragment_fill_factor_n_recs)); + optimal_page_size -= reserved_space; + n_new_slots = (total_data_size + optimal_page_size - 1) + / optimal_page_size; + if (n_new_slots >= n_pages) { + /* Can't defragment. */ + if (end_of_index) + return NULL; + return blocks[n_pages-1]; + } + + /* 3. Defragment pages. */ + heap = mem_heap_create(256); + // First defragmented page will be the first page. + current_block = blocks[0]; + // Start from the second page. + for (uint i = 1; i < n_pages; i ++) { + buf_block_t* new_block = btr_defragment_merge_pages( + index, blocks[i], current_block, zip_size, + reserved_space, &max_data_size, heap, mtr); + if (new_block != current_block) { + n_defragmented ++; + current_block = new_block; + } + } + mem_heap_free(heap); + n_defragmented ++; + os_atomic_increment_ulint( + &btr_defragment_count, 1); + if (n_pages == n_defragmented) { + os_atomic_increment_ulint( + &btr_defragment_failures, 1); + } else { + index->stat_defrag_n_pages_freed += (n_pages - n_defragmented); + } + if (end_of_index) + return NULL; + return current_block; +} + +/******************************************************************//** +Thread that merges consecutive b-tree pages into fewer pages to defragment +the index. */ +extern "C" UNIV_INTERN +os_thread_ret_t +DECLARE_THREAD(btr_defragment_thread)( +/*==========================================*/ + void* arg) /*!< in: work queue */ +{ + btr_pcur_t* pcur; + btr_cur_t* cursor; + dict_index_t* index; + mtr_t mtr; + buf_block_t* first_block; + buf_block_t* last_block; + + while (srv_shutdown_state == SRV_SHUTDOWN_NONE) { + /* If defragmentation is disabled, sleep before + checking whether it's enabled. */ + if (!srv_defragment) { + os_thread_sleep(BTR_DEFRAGMENT_SLEEP_IN_USECS); + continue; + } + /* The following call won't remove the item from work queue. + We only get a pointer to it to work on. This will make sure + when user issue a kill command, all indices are in the work + queue to be searched. This also means that the user thread + cannot directly remove the item from queue (since we might be + using it). So user thread only marks index as removed. */ + btr_defragment_item_t* item = btr_defragment_get_item(); + /* If work queue is empty, sleep and check later. */ + if (!item) { + os_thread_sleep(BTR_DEFRAGMENT_SLEEP_IN_USECS); + continue; + } + /* If an index is marked as removed, we remove it from the work + queue. No other thread could be using this item at this point so + it's safe to remove now. */ + if (item->removed) { + btr_defragment_remove_item(item); + continue; + } + + pcur = item->pcur; + ulonglong now = ut_timer_now(); + ulonglong elapsed = now - item->last_processed; + + if (elapsed < srv_defragment_interval) { + /* If we see an index again before the interval + determined by the configured frequency is reached, + we just sleep until the interval pass. Since + defragmentation of all indices queue up on a single + thread, it's likely other indices that follow this one + don't need to sleep again. */ + os_thread_sleep(((ulint)ut_timer_to_microseconds( + srv_defragment_interval - elapsed))); + } + + now = ut_timer_now(); + mtr_start(&mtr); + btr_pcur_restore_position(BTR_MODIFY_TREE, pcur, &mtr); + cursor = btr_pcur_get_btr_cur(pcur); + index = btr_cur_get_index(cursor); + first_block = btr_cur_get_block(cursor); + last_block = btr_defragment_n_pages(first_block, index, + srv_defragment_n_pages, + &mtr); + if (last_block) { + /* If we haven't reached the end of the index, + place the cursor on the last record of last page, + store the cursor position, and put back in queue. */ + page_t* last_page = buf_block_get_frame(last_block); + rec_t* rec = page_rec_get_prev( + page_get_supremum_rec(last_page)); + ut_a(page_rec_is_user_rec(rec)); + page_cur_position(rec, last_block, + btr_cur_get_page_cur(cursor)); + btr_pcur_store_position(pcur, &mtr); + mtr_commit(&mtr); + /* Update the last_processed time of this index. */ + item->last_processed = now; + } else { + mtr_commit(&mtr); + /* Reaching the end of the index. */ + dict_stats_empty_defrag_stats(index); + dict_stats_save_defrag_stats(index); + dict_stats_save_defrag_summary(index); + btr_defragment_remove_item(item); + } + } + btr_defragment_shutdown(); + os_thread_exit(NULL); + OS_THREAD_DUMMY_RETURN; +} + +#endif /* !UNIV_HOTBACKUP */ diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc index c340590b4bb..931f14af312 100644 --- a/storage/xtradb/dict/dict0dict.cc +++ b/storage/xtradb/dict/dict0dict.cc @@ -408,7 +408,7 @@ dict_table_try_drop_aborted( if (table == NULL) { table = dict_table_open_on_id_low( - table_id, DICT_ERR_IGNORE_NONE); + table_id, DICT_ERR_IGNORE_NONE, FALSE); } else { ut_ad(table->id == table_id); } @@ -795,7 +795,8 @@ dict_table_open_on_id( table_id, table_op == DICT_TABLE_OP_LOAD_TABLESPACE ? DICT_ERR_IGNORE_RECOVER_LOCK - : DICT_ERR_IGNORE_NONE); + : DICT_ERR_IGNORE_NONE, + table_op == DICT_TABLE_OP_OPEN_ONLY_IF_CACHED); if (table != NULL) { @@ -1313,7 +1314,7 @@ dict_table_move_from_non_lru_to_lru( /**********************************************************************//** Looks for an index with the given id given a table instance. @return index or NULL */ -static +UNIV_INTERN dict_index_t* dict_table_find_index_on_id( /*========================*/ @@ -2408,6 +2409,13 @@ undo_size_ok: new_index->stat_index_size = 1; new_index->stat_n_leaf_pages = 1; + new_index->stat_defrag_n_pages_freed = 0; + new_index->stat_defrag_n_page_split = 0; + + new_index->stat_defrag_sample_next_slot = 0; + memset(&new_index->stat_defrag_data_size_sample, + 0x0, sizeof(ulint) * STAT_DEFRAG_DATA_SIZE_N_SAMPLE); + /* Add the new index as the last index for the table */ UT_LIST_ADD_LAST(indexes, table->indexes, new_index); diff --git a/storage/xtradb/dict/dict0stats.cc b/storage/xtradb/dict/dict0stats.cc index 928bdb3f2ef..bec0079942b 100644 --- a/storage/xtradb/dict/dict0stats.cc +++ b/storage/xtradb/dict/dict0stats.cc @@ -492,6 +492,9 @@ dict_stats_table_clone_create( heap, idx->n_uniq * sizeof(idx->stat_n_non_null_key_vals[0])); ut_d(idx->magic_n = DICT_INDEX_MAGIC_N); + + idx->stat_defrag_n_page_split = 0; + idx->stat_defrag_n_pages_freed = 0; } ut_d(t->magic_n = DICT_TABLE_MAGIC_N); @@ -520,7 +523,9 @@ static void dict_stats_empty_index( /*===================*/ - dict_index_t* index) /*!< in/out: index */ + dict_index_t* index, /*!< in/out: index */ + bool empty_defrag_stats) + /*!< in: whether to empty defrag stats */ { ut_ad(!(index->type & DICT_FTS)); ut_ad(!dict_index_is_univ(index)); @@ -535,6 +540,34 @@ dict_stats_empty_index( index->stat_index_size = 1; index->stat_n_leaf_pages = 1; + + if (empty_defrag_stats) { + dict_stats_empty_defrag_stats(index); + dict_stats_empty_defrag_summary(index); + } +} + +/**********************************************************************//** +Clear defragmentation summary. */ +UNIV_INTERN +void +dict_stats_empty_defrag_summary( +/*==================*/ + dict_index_t* index) /*!< in: index to clear defragmentation stats */ +{ + index->stat_defrag_n_pages_freed = 0; +} + +/**********************************************************************//** +Clear defragmentation related index stats. */ +UNIV_INTERN +void +dict_stats_empty_defrag_stats( +/*==================*/ + dict_index_t* index) /*!< in: index to clear defragmentation stats */ +{ + index->stat_defrag_modified_counter = 0; + index->stat_defrag_n_page_split = 0; } /*********************************************************************//** @@ -544,7 +577,9 @@ static void dict_stats_empty_table( /*===================*/ - dict_table_t* table) /*!< in/out: table */ + dict_table_t* table, /*!< in/out: table */ + bool empty_defrag_stats) + /*!< in: whether to empty defrag stats */ { /* Zero the stats members */ @@ -569,7 +604,7 @@ dict_stats_empty_table( ut_ad(!dict_index_is_univ(index)); - dict_stats_empty_index(index); + dict_stats_empty_index(index, empty_defrag_stats); } table->stat_initialized = TRUE; @@ -704,7 +739,7 @@ dict_stats_copy( } if (!INDEX_EQ(src_idx, dst_idx)) { - dict_stats_empty_index(dst_idx); + dict_stats_empty_index(dst_idx, true); continue; } @@ -715,7 +750,7 @@ dict_stats_copy( /* Since src is smaller some elements in dst will remain untouched by the following memmove(), thus we init all of them here. */ - dict_stats_empty_index(dst_idx); + dict_stats_empty_index(dst_idx, true); } else { n_copy_el = dst_idx->n_uniq; } @@ -735,6 +770,13 @@ dict_stats_copy( dst_idx->stat_index_size = src_idx->stat_index_size; dst_idx->stat_n_leaf_pages = src_idx->stat_n_leaf_pages; + + dst_idx->stat_defrag_modified_counter = + src_idx->stat_defrag_modified_counter; + dst_idx->stat_defrag_n_pages_freed = + src_idx->stat_defrag_n_pages_freed; + dst_idx->stat_defrag_n_page_split = + src_idx->stat_defrag_n_page_split; } dst->stat_initialized = TRUE; @@ -758,6 +800,9 @@ dict_index_t::stat_n_sample_sizes[] dict_index_t::stat_n_non_null_key_vals[] dict_index_t::stat_index_size dict_index_t::stat_n_leaf_pages +dict_index_t::stat_defrag_modified_counter +dict_index_t::stat_defrag_n_pages_freed +dict_index_t::stat_defrag_n_page_split The returned object should be freed with dict_stats_snapshot_free() when no longer needed. @return incomplete table object */ @@ -807,7 +852,9 @@ dict_stats_snapshot_free( Calculates new estimates for index statistics. This function is relatively quick and is used to calculate transient statistics that are not saved on disk. This was the only way to calculate statistics -before the Persistent Statistics feature was introduced. */ +before the Persistent Statistics feature was introduced. +This function doesn't update the defragmentation related stats. +Only persistent statistics supports defragmentation stats. */ static void dict_stats_update_transient_for_index( @@ -823,10 +870,10 @@ dict_stats_update_transient_for_index( Initialize some bogus index cardinality statistics, so that the data can be queried in various means, also via secondary indexes. */ - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG } else if (ibuf_debug && !dict_index_is_clust(index)) { - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ } else { mtr_t mtr; @@ -847,7 +894,7 @@ dict_stats_update_transient_for_index( switch (size) { case ULINT_UNDEFINED: - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); return; case 0: /* The root node of the tree is a leaf */ @@ -882,7 +929,7 @@ dict_stats_update_transient( if (dict_table_is_discarded(table)) { /* Nothing to do. */ - dict_stats_empty_table(table); + dict_stats_empty_table(table, false); return; } else if (index == NULL) { /* Table definition is corrupt */ @@ -892,7 +939,7 @@ dict_stats_update_transient( fprintf(stderr, " InnoDB: table %s has no indexes. " "Cannot calculate statistics.\n", ut_format_name(table->name, TRUE, buf, sizeof(buf))); - dict_stats_empty_table(table); + dict_stats_empty_table(table, false); return; } @@ -904,7 +951,7 @@ dict_stats_update_transient( continue; } - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); if (dict_stats_should_ignore_index(index)) { continue; @@ -1794,7 +1841,7 @@ dict_stats_analyze_index( DEBUG_PRINTF(" %s(index=%s)\n", __func__, index->name); - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); mtr_start(&mtr); @@ -2059,7 +2106,7 @@ dict_stats_update_persistent( /* Table definition is corrupt */ dict_table_stats_unlock(table, RW_X_LATCH); - dict_stats_empty_table(table); + dict_stats_empty_table(table, true); return(DB_CORRUPTION); } @@ -2088,7 +2135,7 @@ dict_stats_update_persistent( continue; } - dict_stats_empty_index(index); + dict_stats_empty_index(index, false); if (dict_stats_should_ignore_index(index)) { continue; @@ -2657,6 +2704,16 @@ dict_stats_fetch_index_stats_step( == 0) { index->stat_n_leaf_pages = (ulint) stat_value; arg->stats_were_modified = true; + } else if (stat_name_len == 12 /* strlen("n_page_split") */ + && strncasecmp("n_page_split", stat_name, stat_name_len) + == 0) { + index->stat_defrag_n_page_split = (ulint) stat_value; + arg->stats_were_modified = true; + } else if (stat_name_len == 13 /* strlen("n_pages_freed") */ + && strncasecmp("n_pages_freed", stat_name, stat_name_len) + == 0) { + index->stat_defrag_n_pages_freed = (ulint) stat_value; + arg->stats_were_modified = true; } else if (stat_name_len > PFX_LEN /* e.g. stat_name=="n_diff_pfx01" */ && strncasecmp(PFX, stat_name, PFX_LEN) == 0) { @@ -2776,7 +2833,7 @@ dict_stats_fetch_from_ps( the persistent storage contains incomplete stats (e.g. missing stats for some index) then we would end up with (partially) uninitialized stats. */ - dict_stats_empty_table(table); + dict_stats_empty_table(table, true); trx = trx_allocate_for_background(); @@ -2878,6 +2935,22 @@ dict_stats_fetch_from_ps( } /*********************************************************************//** +Clear defragmentation stats modified counter for all indices in table. */ +static +void +dict_stats_empty_defrag_modified_counter( + dict_table_t* table) /*!< in: table */ +{ + dict_index_t* index; + ut_a(table); + for (index = dict_table_get_first_index(table); + index != NULL; + index = dict_table_get_next_index(index)) { + index->stat_defrag_modified_counter = 0; + } +} + +/*********************************************************************//** Fetches or calculates new estimates for index statistics. */ UNIV_INTERN void @@ -2949,13 +3022,13 @@ dict_stats_update( "because the .ibd file is missing. For help, please " "refer to " REFMAN "innodb-troubleshooting.html\n", ut_format_name(table->name, TRUE, buf, sizeof(buf))); - dict_stats_empty_table(table); + dict_stats_empty_table(table, true); return(DB_TABLESPACE_DELETED); } else if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) { /* If we have set a high innodb_force_recovery level, do not calculate statistics, as a badly corrupted index can cause a crash in it. */ - dict_stats_empty_table(table); + dict_stats_empty_table(table, false); return(DB_SUCCESS); } @@ -3014,7 +3087,7 @@ dict_stats_update( case DICT_STATS_EMPTY_TABLE: - dict_stats_empty_table(table); + dict_stats_empty_table(table, true); /* If table is using persistent stats, then save the stats on disk */ @@ -3073,6 +3146,7 @@ dict_stats_update( t->stats_last_recalc = table->stats_last_recalc; t->stat_modified_counter = 0; + dict_stats_empty_defrag_modified_counter(t); switch (err) { case DB_SUCCESS: @@ -3083,7 +3157,7 @@ dict_stats_update( copying because dict_stats_table_clone_create() does skip corrupted indexes so our dummy object 't' may have less indexes than the real object 'table'. */ - dict_stats_empty_table(table); + dict_stats_empty_table(table, true); dict_stats_copy(table, t); @@ -3650,6 +3724,117 @@ dict_stats_rename_table( return(ret); } +/*********************************************************************//** +Save defragmentation result. +@return DB_SUCCESS or error code */ +UNIV_INTERN +dberr_t +dict_stats_save_defrag_summary( + dict_index_t* index) /*!< in: index */ +{ + dberr_t ret; + lint now = (lint) ut_time(); + if (dict_index_is_univ(index)) { + return DB_SUCCESS; + } + rw_lock_x_lock(&dict_operation_lock); + mutex_enter(&dict_sys->mutex); + ret = dict_stats_save_index_stat(index, now, "n_pages_freed", + index->stat_defrag_n_pages_freed, + NULL, + "Number of pages freed during" + " last defragmentation run.", + NULL); + + mutex_exit(&dict_sys->mutex); + rw_lock_x_unlock(&dict_operation_lock); + return (ret); +} + +/*********************************************************************//** +Save defragmentation stats for a given index. +@return DB_SUCCESS or error code */ +UNIV_INTERN +dberr_t +dict_stats_save_defrag_stats( + dict_index_t* index) /*!< in: index */ +{ + dberr_t ret; + + if (index->table->ibd_file_missing) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Cannot save defragment stats because " + ".ibd file is missing.\n"); + return (DB_TABLESPACE_DELETED); + } + if (dict_index_is_corrupted(index)) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Cannot save defragment stats because " + "index is corrupted.\n"); + return(DB_CORRUPTION); + } + + if (dict_index_is_univ(index)) { + return DB_SUCCESS; + } + + lint now = (lint) ut_time(); + mtr_t mtr; + ulint n_leaf_pages; + ulint n_leaf_reserved; + mtr_start(&mtr); + mtr_s_lock(dict_index_get_lock(index), &mtr); + n_leaf_reserved = btr_get_size_and_reserved(index, BTR_N_LEAF_PAGES, + &n_leaf_pages, &mtr); + mtr_commit(&mtr); + + if (n_leaf_reserved == ULINT_UNDEFINED) { + // The index name is different during fast index creation, + // so the stats won't be associated with the right index + // for later use. We just return without saving. + return DB_SUCCESS; + } + + rw_lock_x_lock(&dict_operation_lock); + + mutex_enter(&dict_sys->mutex); + ret = dict_stats_save_index_stat(index, now, "n_page_split", + index->stat_defrag_n_page_split, + NULL, + "Number of new page splits on leaves" + " since last defragmentation.", + NULL); + if (ret != DB_SUCCESS) { + goto end; + } + + ret = dict_stats_save_index_stat( + index, now, "n_leaf_pages_defrag", + n_leaf_pages, + NULL, + "Number of leaf pages when this stat is saved to disk", + NULL); + if (ret != DB_SUCCESS) { + goto end; + } + + ret = dict_stats_save_index_stat( + index, now, "n_leaf_pages_reserved", + n_leaf_reserved, + NULL, + "Number of pages reserved for this index leaves when this stat " + "is saved to disk", + NULL); + +end: + mutex_exit(&dict_sys->mutex); + rw_lock_x_unlock(&dict_operation_lock); + + return (ret); +} + /* tests @{ */ #ifdef UNIV_COMPILE_TEST_FUNCS diff --git a/storage/xtradb/dict/dict0stats_bg.cc b/storage/xtradb/dict/dict0stats_bg.cc index 9e1f75a13a9..2cf8aff1e30 100644 --- a/storage/xtradb/dict/dict0stats_bg.cc +++ b/storage/xtradb/dict/dict0stats_bg.cc @@ -25,6 +25,7 @@ Created Apr 25, 2012 Vasil Dimov #include "row0mysql.h" #include "srv0start.h" +#include "dict0dict.h" #include "dict0stats.h" #include "dict0stats_bg.h" @@ -44,8 +45,10 @@ UNIV_INTERN os_event_t dict_stats_event = NULL; /** This mutex protects the "recalc_pool" variable. */ static ib_mutex_t recalc_pool_mutex; +static ib_mutex_t defrag_pool_mutex; #ifdef HAVE_PSI_INTERFACE static mysql_pfs_key_t recalc_pool_mutex_key; +static mysql_pfs_key_t defrag_pool_mutex_key; #endif /* HAVE_PSI_INTERFACE */ /** The number of tables that can be added to "recalc_pool" before @@ -59,16 +62,26 @@ static recalc_pool_t recalc_pool; typedef recalc_pool_t::iterator recalc_pool_iterator_t; +/** Indices whose defrag stats need to be saved to persistent storage.*/ +struct defrag_pool_item_t { + table_id_t table_id; + index_id_t index_id; +}; +typedef std::vector<defrag_pool_item_t> defrag_pool_t; +static defrag_pool_t defrag_pool; +typedef defrag_pool_t::iterator defrag_pool_iterator_t; + /*****************************************************************//** Initialize the recalc pool, called once during thread initialization. */ static void -dict_stats_recalc_pool_init() +dict_stats_pool_init() /*=========================*/ { ut_ad(!srv_read_only_mode); recalc_pool.reserve(RECALC_POOL_INITIAL_SLOTS); + defrag_pool.reserve(RECALC_POOL_INITIAL_SLOTS); } /*****************************************************************//** @@ -76,12 +89,13 @@ Free the resources occupied by the recalc pool, called once during thread de-initialization. */ static void -dict_stats_recalc_pool_deinit() +dict_stats_pool_deinit() /*===========================*/ { ut_ad(!srv_read_only_mode); recalc_pool.clear(); + defrag_pool.clear(); } /*****************************************************************//** @@ -178,6 +192,111 @@ dict_stats_recalc_pool_del( } /*****************************************************************//** +Add an index in a table to the defrag pool, which is processed by the +background stats gathering thread. Only the table id and index id are +added to the list, so the table can be closed after being enqueued and +it will be opened when needed. If the table or index does not exist later +(has been DROPped), then it will be removed from the pool and skipped. */ +UNIV_INTERN +void +dict_stats_defrag_pool_add( +/*=======================*/ + const dict_index_t* index) /*!< in: table to add */ +{ + defrag_pool_item_t item; + + ut_ad(!srv_read_only_mode); + + mutex_enter(&defrag_pool_mutex); + + /* quit if already in the list */ + for (defrag_pool_iterator_t iter = defrag_pool.begin(); + iter != defrag_pool.end(); + ++iter) { + if ((*iter).table_id == index->table->id + && (*iter).index_id == index->id) { + mutex_exit(&defrag_pool_mutex); + return; + } + } + + item.table_id = index->table->id; + item.index_id = index->id; + defrag_pool.push_back(item); + + mutex_exit(&defrag_pool_mutex); + + os_event_set(dict_stats_event); +} + +/*****************************************************************//** +Get an index from the auto defrag pool. The returned index id is removed +from the pool. +@return true if the pool was non-empty and "id" was set, false otherwise */ +static +bool +dict_stats_defrag_pool_get( +/*=======================*/ + table_id_t* table_id, /*!< out: table id, or unmodified if + list is empty */ + index_id_t* index_id) /*!< out: index id, or unmodified if + list is empty */ +{ + ut_ad(!srv_read_only_mode); + + mutex_enter(&defrag_pool_mutex); + + if (defrag_pool.empty()) { + mutex_exit(&defrag_pool_mutex); + return(false); + } + + defrag_pool_item_t& item = defrag_pool.back(); + *table_id = item.table_id; + *index_id = item.index_id; + + defrag_pool.pop_back(); + + mutex_exit(&defrag_pool_mutex); + + return(true); +} + +/*****************************************************************//** +Delete a given index from the auto defrag pool. */ +UNIV_INTERN +void +dict_stats_defrag_pool_del( +/*=======================*/ + const dict_table_t* table, /*!<in: if given, remove + all entries for the table */ + const dict_index_t* index) /*!< in: if given, remove this index */ +{ + ut_a((table && !index) || (!table && index)); + ut_ad(!srv_read_only_mode); + ut_ad(mutex_own(&dict_sys->mutex)); + + mutex_enter(&defrag_pool_mutex); + + defrag_pool_iterator_t iter = defrag_pool.begin(); + while (iter != defrag_pool.end()) { + if ((table && (*iter).table_id == table->id) + || (index + && (*iter).table_id == index->table->id + && (*iter).index_id == index->id)) { + /* erase() invalidates the iterator */ + iter = defrag_pool.erase(iter); + if (index) + break; + } else { + iter++; + } + } + + mutex_exit(&defrag_pool_mutex); +} + +/*****************************************************************//** Wait until background stats thread has stopped using the specified table. The caller must have locked the data dictionary using row_mysql_lock_data_dictionary() and this function may unlock it temporarily @@ -227,7 +346,10 @@ dict_stats_thread_init() mutex_create(recalc_pool_mutex_key, &recalc_pool_mutex, SYNC_STATS_AUTO_RECALC); - dict_stats_recalc_pool_init(); + /* We choose SYNC_STATS_DEFRAG to be below SYNC_FSP_PAGE. */ + mutex_create(defrag_pool_mutex_key, &defrag_pool_mutex, + SYNC_STATS_DEFRAG); + dict_stats_pool_init(); } /*****************************************************************//** @@ -241,11 +363,14 @@ dict_stats_thread_deinit() ut_a(!srv_read_only_mode); ut_ad(!srv_dict_stats_thread_active); - dict_stats_recalc_pool_deinit(); + dict_stats_pool_deinit(); mutex_free(&recalc_pool_mutex); memset(&recalc_pool_mutex, 0x0, sizeof(recalc_pool_mutex)); + mutex_free(&defrag_pool_mutex); + memset(&defrag_pool_mutex, 0x0, sizeof(defrag_pool_mutex)); + os_event_free(dict_stats_event); dict_stats_event = NULL; } @@ -323,6 +448,63 @@ dict_stats_process_entry_from_recalc_pool() } /*****************************************************************//** +Get the first index that has been added for updating persistent defrag +stats and eventually save its stats. */ +static +void +dict_stats_process_entry_from_defrag_pool() +/*=======================================*/ +{ + table_id_t table_id; + index_id_t index_id; + + ut_ad(!srv_read_only_mode); + + /* pop the first index from the auto defrag pool */ + if (!dict_stats_defrag_pool_get(&table_id, &index_id)) { + /* no index in defrag pool */ + return; + } + + dict_table_t* table; + + mutex_enter(&dict_sys->mutex); + + /* If the table is no longer cached, we've already lost the in + memory stats so there's nothing really to write to disk. */ + table = dict_table_open_on_id(table_id, TRUE, + DICT_TABLE_OP_OPEN_ONLY_IF_CACHED); + + if (table == NULL) { + mutex_exit(&dict_sys->mutex); + return; + } + + /* Check whether table is corrupted */ + if (table->corrupted) { + dict_table_close(table, TRUE, FALSE); + mutex_exit(&dict_sys->mutex); + return; + } + mutex_exit(&dict_sys->mutex); + + dict_index_t* index = dict_table_find_index_on_id(table, index_id); + + if (index == NULL) { + return; + } + + /* Check whether index is corrupted */ + if (dict_index_is_corrupted(index)) { + dict_table_close(table, FALSE, FALSE); + return; + } + + dict_stats_save_defrag_stats(index); + dict_table_close(table, FALSE, FALSE); +} + +/*****************************************************************//** This is the thread for background stats gathering. It pops tables, from the auto recalc list and proceeds them, eventually recalculating their statistics. @@ -354,6 +536,9 @@ DECLARE_THREAD(dict_stats_thread)( dict_stats_process_entry_from_recalc_pool(); + while (defrag_pool.size()) + dict_stats_process_entry_from_defrag_pool(); + os_event_reset(dict_stats_event); } diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index 343cc0f47c4..d9398e3ceb5 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -6826,43 +6826,43 @@ fil_space_name( /*******************************************************************//** Return page type name */ -char* +const char* fil_get_page_type_name( /*===================*/ ulint page_type) /*!< in: FIL_PAGE_TYPE */ { switch(page_type) { case FIL_PAGE_PAGE_COMPRESSED: - return (char *)"PAGE_COMPRESSED"; + return "PAGE_COMPRESSED"; case FIL_PAGE_INDEX: - return (char *)"INDEX"; + return "INDEX"; case FIL_PAGE_UNDO_LOG: - return (char *)"UNDO LOG"; + return "UNDO LOG"; case FIL_PAGE_INODE: - return (char *)"INODE"; + return "INODE"; case FIL_PAGE_IBUF_FREE_LIST: - return (char *)"IBUF_FREE_LIST"; + return "IBUF_FREE_LIST"; case FIL_PAGE_TYPE_ALLOCATED: - return (char *)"ALLOCATED"; + return "ALLOCATED"; case FIL_PAGE_IBUF_BITMAP: - return (char *)"IBUF_BITMAP"; + return "IBUF_BITMAP"; case FIL_PAGE_TYPE_SYS: - return (char *)"SYS"; + return "SYS"; case FIL_PAGE_TYPE_TRX_SYS: - return (char *)"TRX_SYS"; + return "TRX_SYS"; case FIL_PAGE_TYPE_FSP_HDR: - return (char *)"FSP_HDR"; + return "FSP_HDR"; case FIL_PAGE_TYPE_XDES: - return (char *)"XDES"; + return "XDES"; case FIL_PAGE_TYPE_BLOB: - return (char *)"BLOB"; + return "BLOB"; case FIL_PAGE_TYPE_ZBLOB: - return (char *)"ZBLOB"; + return "ZBLOB"; case FIL_PAGE_TYPE_ZBLOB2: - return (char *)"ZBLOB2"; + return "ZBLOB2"; case FIL_PAGE_TYPE_COMPRESSED: - return (char *)"ORACLE PAGE COMPRESSED"; + return "ORACLE PAGE COMPRESSED"; default: - return (char *)"PAGE TYPE CORRUPTED"; + return "PAGE TYPE CORRUPTED"; } } diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc index ec19a4ef4b7..59d45d5af62 100644 --- a/storage/xtradb/fil/fil0pagecompress.cc +++ b/storage/xtradb/fil/fil0pagecompress.cc @@ -345,16 +345,19 @@ fil_compress_page( len, reinterpret_cast<uint8_t*>(out_buf + header_len), &out_pos, - (size_t)&write_size); + (size_t)write_size); - if (err != LZMA_OK || write_size > UNIV_PAGE_SIZE-header_len) { + if (err != LZMA_OK || out_pos > UNIV_PAGE_SIZE-header_len) { fprintf(stderr, "InnoDB: Warning: Compression failed for space %lu name %s len %lu err %d write_size %lu\n", - space_id, fil_space_name(space), len, err, write_size); + space_id, fil_space_name(space), len, err, out_pos); srv_stats.pages_page_compression_error.inc(); *out_len = len; return (buf); } + + write_size = out_pos; + break; } #endif /* HAVE_LZMA */ diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 4c4bccd15e1..2a551be0284 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -58,6 +58,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "buf0flu.h" #include "buf0dblwr.h" #include "btr0sea.h" +#include "btr0defragment.h" #include "os0file.h" #include "os0thread.h" #include "srv0start.h" @@ -66,7 +67,6 @@ this program; if not, write to the Free Software Foundation, Inc., #include "trx0trx.h" #include "trx0sys.h" -#include "mtr0mtr.h" #include "rem0types.h" #include "row0ins.h" #include "row0mysql.h" @@ -88,6 +88,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "dict0stats_bg.h" #include "ha_prototypes.h" #include "ut0mem.h" +#include "ut0timer.h" #include "ibuf0ibuf.h" #include "dict0dict.h" #include "srv0mon.h" @@ -984,6 +985,14 @@ static SHOW_VAR innodb_status_variables[]= { {"have_bzip2", (char*) &innodb_have_bzip2, SHOW_BOOL}, + /* Defragment */ + {"defragment_compression_failures", + (char*) &export_vars.innodb_defragment_compression_failures, SHOW_LONG}, + {"defragment_failures", + (char*) &export_vars.innodb_defragment_failures, SHOW_LONG}, + {"defragment_count", + (char*) &export_vars.innodb_defragment_count, SHOW_LONG}, + {NullS, NullS, SHOW_LONG} }; @@ -2759,7 +2768,8 @@ ha_innobase::ha_innobase( (srv_force_primary_key ? HA_REQUIRE_PRIMARY_KEY : 0 ) | HA_CAN_FULLTEXT_EXT | HA_CAN_EXPORT), start_of_scan(0), - num_write_row(0) + num_write_row(0), + ha_partition_stats(NULL) {} /*********************************************************************//** @@ -12326,6 +12336,72 @@ ha_innobase::delete_table( } /*****************************************************************//** +Defragment table. +@return error number */ +UNIV_INTERN +int +ha_innobase::defragment_table( +/*==========================*/ + const char* name, /*!< in: table name */ + const char* index_name, /*!< in: index name */ + bool async) /*!< in: whether to wait until finish */ +{ + char norm_name[FN_REFLEN]; + dict_table_t* table; + dict_index_t* index; + ibool one_index = (index_name != 0); + int ret = 0; + if (!srv_defragment) { + return ER_FEATURE_DISABLED; + } + normalize_table_name(norm_name, name); + table = dict_table_open_on_name(norm_name, FALSE, + FALSE, DICT_ERR_IGNORE_NONE); + for (index = dict_table_get_first_index(table); index; + index = dict_table_get_next_index(index)) { + if (one_index && strcasecmp(index_name, index->name) != 0) + continue; + if (btr_defragment_find_index(index)) { + // We borrow this error code. When the same index is + // already in the defragmentation queue, issue another + // defragmentation only introduces overhead. We return + // an error here to let the user know this is not + // necessary. Note that this will fail a query that's + // trying to defragment a full table if one of the + // indicies in that table is already in defragmentation. + // We choose this behavior so user is aware of this + // rather than silently defragment other indicies of + // that table. + ret = ER_SP_ALREADY_EXISTS; + break; + } + os_event_t event = btr_defragment_add_index(index, async); + if (!async && event) { + while(os_event_wait_time(event, 1000000)) { + if (thd_killed(current_thd)) { + btr_defragment_remove_index(index); + ret = ER_QUERY_INTERRUPTED; + break; + } + } + os_event_free(event); + } + if (ret) { + break; + } + if (one_index) { + one_index = FALSE; + break; + } + } + dict_table_close(table, FALSE, FALSE); + if (ret == 0 && one_index) { + ret = ER_NO_SUCH_INDEX; + } + return ret; +} + +/*****************************************************************//** Removes all tables in the named database inside InnoDB. */ static void @@ -13492,6 +13568,27 @@ ha_innobase::optimize( This works OK otherwise, but MySQL locks the entire table during calls to OPTIMIZE, which is undesirable. */ + if (srv_defragment) { + int err; + + err = defragment_table(prebuilt->table->name, NULL, false); + + if (err == 0) { + return (HA_ADMIN_OK); + } else { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + err, + "InnoDB: Cannot defragment table %s: returned error code %d\n", + prebuilt->table->name, err); + + if(err == ER_SP_ALREADY_EXISTS) { + return (HA_ADMIN_OK); + } else { + return (HA_ADMIN_TRY_ALTER); + } + } + } + if (innodb_optimize_fulltext_only) { if (prebuilt->table->fts && prebuilt->table->fts->cache && !dict_table_is_discarded(prebuilt->table)) { @@ -16303,6 +16400,13 @@ innodb_max_dirty_pages_pct_lwm_update( srv_max_dirty_pages_pct_lwm = in_val; } +UNIV_INTERN +void +ha_innobase::set_partition_owner_stats(ha_statistics *stats) +{ + ha_partition_stats= stats; +} + /************************************************************//** Validate the file format name and return its corresponding id. @return valid file format id */ @@ -17561,6 +17665,23 @@ innodb_reset_all_monitor_update( TRUE); } +static +void +innodb_defragment_frequency_update( +/*===============================*/ + THD* thd, /*!< in: thread handle */ + struct st_mysql_sys_var* var, /*!< in: pointer to + system variable */ + void* var_ptr,/*!< out: where the + formal string goes */ + const void* save) /*!< in: immediate result + from check function */ +{ + srv_defragment_frequency = (*static_cast<const uint*>(save)); + srv_defragment_interval = ut_microseconds_to_timer( + 1000000.0 / srv_defragment_frequency); +} + /****************************************************************//** Parse and enable InnoDB monitor counters during server startup. User can list the monitor counters/groups to be enable by specifying @@ -19145,6 +19266,60 @@ static MYSQL_SYSVAR_BOOL(buffer_pool_load_at_startup, srv_buffer_pool_load_at_st "Load the buffer pool from a file named @@innodb_buffer_pool_filename", NULL, NULL, FALSE); +static MYSQL_SYSVAR_BOOL(defragment, srv_defragment, + PLUGIN_VAR_RQCMDARG, + "Enable/disable InnoDB defragmentation (default FALSE). When set to FALSE, all existing " + "defragmentation will be paused. And new defragmentation command will fail." + "Paused defragmentation commands will resume when this variable is set to " + "true again.", + NULL, NULL, FALSE); + +static MYSQL_SYSVAR_UINT(defragment_n_pages, srv_defragment_n_pages, + PLUGIN_VAR_RQCMDARG, + "Number of pages considered at once when merging multiple pages to " + "defragment", + NULL, NULL, 7, 2, 32, 0); + +static MYSQL_SYSVAR_UINT(defragment_stats_accuracy, + srv_defragment_stats_accuracy, + PLUGIN_VAR_RQCMDARG, + "How many defragment stats changes there are before the stats " + "are written to persistent storage. Set to 0 meaning disable " + "defragment stats tracking.", + NULL, NULL, 0, 0, ~0U, 0); + +static MYSQL_SYSVAR_UINT(defragment_fill_factor_n_recs, + srv_defragment_fill_factor_n_recs, + PLUGIN_VAR_RQCMDARG, + "How many records of space defragmentation should leave on the page. " + "This variable, together with innodb_defragment_fill_factor, is introduced " + "so defragmentation won't pack the page too full and cause page split on " + "the next insert on every page. The variable indicating more defragmentation" + " gain is the one effective.", + NULL, NULL, 20, 1, 100, 0); + +static MYSQL_SYSVAR_DOUBLE(defragment_fill_factor, srv_defragment_fill_factor, + PLUGIN_VAR_RQCMDARG, + "A number between [0.7, 1] that tells defragmentation how full it should " + "fill a page. Default is 0.9. Number below 0.7 won't make much sense." + "This variable, together with innodb_defragment_fill_factor_n_recs, is " + "introduced so defragmentation won't pack the page too full and cause " + "page split on the next insert on every page. The variable indicating more " + "defragmentation gain is the one effective.", + NULL, NULL, 0.9, 0.7, 1, 0); + +static MYSQL_SYSVAR_UINT(defragment_frequency, srv_defragment_frequency, + PLUGIN_VAR_RQCMDARG, + "Do not defragment a single index more than this number of time per second." + "This controls the number of time defragmentation thread can request X_LOCK " + "on an index. Defragmentation thread will check whether " + "1/defragment_frequency (s) has passed since it worked on this index last " + "time, and put the index back to the queue if not enough time has passed. " + "The actual frequency can only be lower than this given number.", + NULL, innodb_defragment_frequency_update, + SRV_DEFRAGMENT_FREQUENCY_DEFAULT, 1, 1000, 0); + + static MYSQL_SYSVAR_ULONG(lru_scan_depth, srv_LRU_scan_depth, PLUGIN_VAR_RQCMDARG, "How deep to scan LRU to keep it clean", @@ -19735,6 +19910,12 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(buffer_pool_load_now), MYSQL_SYSVAR(buffer_pool_load_abort), MYSQL_SYSVAR(buffer_pool_load_at_startup), + MYSQL_SYSVAR(defragment), + MYSQL_SYSVAR(defragment_n_pages), + MYSQL_SYSVAR(defragment_stats_accuracy), + MYSQL_SYSVAR(defragment_fill_factor), + MYSQL_SYSVAR(defragment_fill_factor_n_recs), + MYSQL_SYSVAR(defragment_frequency), MYSQL_SYSVAR(lru_scan_depth), MYSQL_SYSVAR(flush_neighbors), MYSQL_SYSVAR(checksum_algorithm), diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index ff4ab88335a..d6a1b738fe7 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2012, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, SkySQL Ab. All Rights Reserved. +Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -105,6 +105,8 @@ class ha_innobase: public handler or undefined */ uint num_write_row; /*!< number of write_row() calls */ + ha_statistics* ha_partition_stats; /*!< stats of the partition owner + handler (if there is one) */ uint store_key_val_for_row(uint keynr, char* buff, uint buff_len, const uchar* record); inline void update_thd(THD* thd); @@ -211,6 +213,8 @@ class ha_innobase: public handler int truncate(); int delete_table(const char *name); int rename_table(const char* from, const char* to); + int defragment_table(const char* name, const char* index_name, + bool async); int check(THD* thd, HA_CHECK_OPT* check_opt); char* update_table_comment(const char* comment); char* get_foreign_key_create_info(); @@ -314,6 +318,7 @@ class ha_innobase: public handler Alter_inplace_info* ha_alter_info, bool commit); /** @} */ + void set_partition_owner_stats(ha_statistics *stats); bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); bool check_if_supported_virtual_columns(void) { return TRUE; } diff --git a/storage/xtradb/include/btr0btr.h b/storage/xtradb/include/btr0btr.h index a3f7cee2733..001e1af7d2d 100644 --- a/storage/xtradb/include/btr0btr.h +++ b/storage/xtradb/include/btr0btr.h @@ -2,6 +2,7 @@ Copyright (c) 1994, 2013, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2014, SkySQL Ab. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -674,6 +675,21 @@ btr_get_size( is s-latched */ __attribute__((nonnull, warn_unused_result)); /**************************************************************//** +Gets the number of reserved and used pages in a B-tree. +@return number of pages reserved, or ULINT_UNDEFINED if the index +is unavailable */ +UNIV_INTERN +ulint +btr_get_size_and_reserved( +/*======================*/ + dict_index_t* index, /*!< in: index */ + ulint flag, /*!< in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE */ + ulint* used, /*!< out: number of pages used (<= reserved) */ + mtr_t* mtr) /*!< in/out: mini-transaction where index + is s-latched */ + __attribute__((nonnull)); + +/**************************************************************//** Allocates a new file page to be used in an index tree. NOTE: we assume that the caller has made the reservation for free extents! @retval NULL if no page could be allocated @@ -720,6 +736,33 @@ btr_page_free_low( ulint level, /*!< in: page level */ mtr_t* mtr) /*!< in: mtr */ __attribute__((nonnull)); +/*************************************************************//** +Reorganizes an index page. + +IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE +if this is a compressed leaf page in a secondary index. This has to +be done either within the same mini-transaction, or by invoking +ibuf_reset_free_bits() before mtr_commit(). On uncompressed pages, +IBUF_BITMAP_FREE is unaffected by reorganization. + +@retval true if the operation was successful +@retval false if it is a compressed page, and recompression failed */ +UNIV_INTERN +bool +btr_page_reorganize_block( +/*======================*/ + bool recovery,/*!< in: true if called in recovery: + locks should not be updated, i.e., + there cannot exist locks on the + page, and a hash index should not be + dropped: it cannot exist */ + ulint z_level,/*!< in: compression level to be used + if dealing with compressed page */ + buf_block_t* block, /*!< in/out: B-tree page */ + dict_index_t* index, /*!< in: the index tree of the page */ + mtr_t* mtr) /*!< in/out: mini-transaction */ + __attribute__((nonnull)); + #ifdef UNIV_BTR_PRINT /*************************************************************//** Prints size info of a B-tree. */ @@ -765,6 +808,60 @@ btr_validate_index( const trx_t* trx) /*!< in: transaction or 0 */ __attribute__((nonnull(1), warn_unused_result)); +#ifdef UNIV_SYNC_DEBUG +/*************************************************************//** +Removes a page from the level list of pages. +@param space in: space where removed +@param zip_size in: compressed page size in bytes, or 0 for uncompressed +@param page in/out: page to remove +@param index in: index tree +@param mtr in/out: mini-transaction */ +# define btr_level_list_remove(space,zip_size,page,index,mtr) \ + btr_level_list_remove_func(space,zip_size,page,index,mtr) +#else /* UNIV_SYNC_DEBUG */ +/*************************************************************//** +Removes a page from the level list of pages. +@param space in: space where removed +@param zip_size in: compressed page size in bytes, or 0 for uncompressed +@param page in/out: page to remove +@param index in: index tree +@param mtr in/out: mini-transaction */ +# define btr_level_list_remove(space,zip_size,page,index,mtr) \ + btr_level_list_remove_func(space,zip_size,page,mtr) +#endif /* UNIV_SYNC_DEBUG */ + +/*************************************************************//** +Removes a page from the level list of pages. */ +UNIV_INTERN +void +btr_level_list_remove_func( +/*=======================*/ + ulint space, /*!< in: space where removed */ + ulint zip_size,/*!< in: compressed page size in bytes + or 0 for uncompressed pages */ + page_t* page, /*!< in/out: page to remove */ +#ifdef UNIV_SYNC_DEBUG + const dict_index_t* index, /*!< in: index tree */ +#endif /* UNIV_SYNC_DEBUG */ + mtr_t* mtr) /*!< in/out: mini-transaction */ + __attribute__((nonnull)); + +/*************************************************************//** +If page is the only on its level, this function moves its records to the +father page, thus reducing the tree height. +@return father block */ +UNIV_INTERN +buf_block_t* +btr_lift_page_up( +/*=============*/ + dict_index_t* index, /*!< in: index tree */ + buf_block_t* block, /*!< in: page which is the only on its level; + must not be empty: use + btr_discard_only_page_on_level if the last + record from the page should be removed */ + mtr_t* mtr) /*!< in: mtr */ + __attribute__((nonnull)); + #define BTR_N_LEAF_PAGES 1 #define BTR_TOTAL_SIZE 2 #endif /* !UNIV_HOTBACKUP */ diff --git a/storage/xtradb/include/btr0btr.ic b/storage/xtradb/include/btr0btr.ic index 9cc611ee450..40b468b200a 100644 --- a/storage/xtradb/include/btr0btr.ic +++ b/storage/xtradb/include/btr0btr.ic @@ -28,7 +28,7 @@ Created 6/2/1994 Heikki Tuuri #include "mtr0mtr.h" #include "mtr0log.h" #include "page0zip.h" -#include "srv0srv.h" + #define BTR_MAX_NODE_LEVEL 50 /*!< Maximum B-tree page level (not really a hard limit). Used in debug assertions @@ -59,9 +59,7 @@ btr_block_get_func( block = buf_page_get_gen(space, zip_size, page_no, mode, NULL, BUF_GET, file, line, mtr); - SRV_CORRUPT_TABLE_CHECK(block, ; /* do nothing */); - - if (block && mode != RW_NO_LATCH) { + if (mode != RW_NO_LATCH) { buf_block_dbg_add_level( block, index != NULL && dict_index_is_ibuf(index) @@ -165,9 +163,10 @@ btr_page_get_next( /*!< in: mini-transaction handle */ { ut_ad(page && mtr); +#ifndef UNIV_INNOCHECKSUM ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX) || mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_S_FIX)); - +#endif /* UNIV_INNOCHECKSUM */ return(mach_read_from_4(page + FIL_PAGE_NEXT)); } diff --git a/storage/xtradb/include/btr0defragment.h b/storage/xtradb/include/btr0defragment.h new file mode 100644 index 00000000000..99beb0a24ba --- /dev/null +++ b/storage/xtradb/include/btr0defragment.h @@ -0,0 +1,100 @@ +/***************************************************************************** + +Copyright (C) 2013, 2014 Facebook, Inc. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +#ifndef btr0defragment_h +#define btr0defragment_h + +#include "univ.i" + +#ifndef UNIV_HOTBACKUP + +#include "btr0pcur.h" + +/* Max number of pages to consider at once during defragmentation. */ +#define BTR_DEFRAGMENT_MAX_N_PAGES 32 + +/** stats in btr_defragment */ +extern ulint btr_defragment_compression_failures; +extern ulint btr_defragment_failures; +extern ulint btr_defragment_count; + +/** Item in the work queue for btr_degrament_thread. */ +struct btr_defragment_item_t +{ + btr_pcur_t* pcur; /* persistent cursor where + btr_defragment_n_pages should start */ + os_event_t event; /* if not null, signal after work + is done */ + bool removed; /* Mark an item as removed */ + ulonglong last_processed; /* timestamp of last time this index + is processed by defragment thread */ + + btr_defragment_item_t(btr_pcur_t* pcur, os_event_t event); + ~btr_defragment_item_t(); +}; + +/******************************************************************//** +Initialize defragmentation. */ +void +btr_defragment_init(void); +/******************************************************************//** +Shutdown defragmentation. */ +void +btr_defragment_shutdown(); +/******************************************************************//** +Check whether the given index is in btr_defragment_wq. */ +bool +btr_defragment_find_index( + dict_index_t* index); /*!< Index to find. */ +/******************************************************************//** +Add an index to btr_defragment_wq. Return a pointer to os_event if this +is a synchronized defragmentation. */ +os_event_t +btr_defragment_add_index( + dict_index_t* index, /*!< index to be added */ + bool async); /*!< whether this is an async defragmentation */ +/******************************************************************//** +When table is dropped, this function is called to mark a table as removed in +btr_efragment_wq. The difference between this function and the remove_index +function is this will not NULL the event. */ +void +btr_defragment_remove_table( + dict_table_t* table); /*!< Index to be removed. */ +/******************************************************************//** +Mark an index as removed from btr_defragment_wq. */ +void +btr_defragment_remove_index( + dict_index_t* index); /*!< Index to be removed. */ +/*********************************************************************//** +Check whether we should save defragmentation statistics to persistent storage.*/ +UNIV_INTERN +void +btr_defragment_save_defrag_stats_if_needed( + dict_index_t* index); /*!< in: index */ +/******************************************************************//** +Thread that merges consecutive b-tree pages into fewer pages to defragment +the index. */ +extern "C" UNIV_INTERN +os_thread_ret_t +DECLARE_THREAD(btr_defragment_thread)( +/*==========================================*/ + void* arg); /*!< in: a dummy parameter required by + os_thread_create */ + +#endif /* !UNIV_HOTBACKUP */ +#endif diff --git a/storage/xtradb/include/dict0dict.h b/storage/xtradb/include/dict0dict.h index 47790a158da..52ac5eee86b 100644 --- a/storage/xtradb/include/dict0dict.h +++ b/storage/xtradb/include/dict0dict.h @@ -120,7 +120,9 @@ enum dict_table_op_t { DICT_TABLE_OP_DROP_ORPHAN, /** Silently load the tablespace if it does not exist, and do not load the definitions of incomplete indexes. */ - DICT_TABLE_OP_LOAD_TABLESPACE + DICT_TABLE_OP_LOAD_TABLESPACE, + /** Open the table only if it's in table cache. */ + DICT_TABLE_OP_OPEN_ONLY_IF_CACHED }; /**********************************************************************//** @@ -1495,6 +1497,16 @@ dict_table_get_index_on_name( const char* name) /*!< in: name of the index to find */ __attribute__((nonnull, warn_unused_result)); /**********************************************************************//** +Looks for an index with the given id given a table instance. +@return index or NULL */ +UNIV_INTERN +dict_index_t* +dict_table_find_index_on_id( +/*========================*/ + const dict_table_t* table, /*!< in: table instance */ + index_id_t id) /*!< in: index id */ + __attribute__((nonnull, warn_unused_result)); +/**********************************************************************//** In case there is more than one index with the same name return the index with the min(id). @return index, NULL if does not exist */ diff --git a/storage/xtradb/include/dict0dict.ic b/storage/xtradb/include/dict0dict.ic index 435b244ec3d..2b698dd7218 100644 --- a/storage/xtradb/include/dict0dict.ic +++ b/storage/xtradb/include/dict0dict.ic @@ -651,7 +651,7 @@ dict_tf_is_valid( if (atomic_writes) { - if(atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if(atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: table flags are %ld in the data dictionary and are corrupted\n" @@ -693,7 +693,7 @@ dict_sys_tables_type_validate( ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(type); ulint atomic_writes = DICT_TF_GET_ATOMIC_WRITES(type); - ut_a(atomic_writes >= 0 && atomic_writes <= ATOMIC_WRITES_OFF); + ut_a(atomic_writes <= ATOMIC_WRITES_OFF); /* The low order bit of SYS_TABLES.TYPE is always set to 1. If the format is UNIV_FORMAT_B or higher, this field is the same @@ -772,7 +772,7 @@ dict_sys_tables_type_validate( } /* Validate that the atomic writes number is within allowed range. */ - if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if (atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: SYS_TABLES::TYPE=%lu, atomic_writes %lu\n", type, atomic_writes); return(ULINT_UNDEFINED); diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h index 93fe2efa830..8de9206cb81 100644 --- a/storage/xtradb/include/dict0mem.h +++ b/storage/xtradb/include/dict0mem.h @@ -600,6 +600,10 @@ struct zip_pad_info_t { rounds */ }; +/** Number of samples of data size kept when page compression fails for +a certain index.*/ +#define STAT_DEFRAG_DATA_SIZE_N_SAMPLE 10 + /** Data structure for an index. Most fields will be initialized to 0, NULL or FALSE in dict_mem_index_create(). */ struct dict_index_t{ @@ -692,6 +696,23 @@ struct dict_index_t{ /*!< approximate number of leaf pages in the index tree */ /* @} */ + /** Statistics for defragmentation, these numbers are estimations and + could be very inaccurate at certain times, e.g. right after restart, + during defragmentation, etc. */ + /* @{ */ + ulint stat_defrag_modified_counter; + ulint stat_defrag_n_pages_freed; + /* number of pages freed by defragmentation. */ + ulint stat_defrag_n_page_split; + /* number of page splits since last full index + defragmentation. */ + ulint stat_defrag_data_size_sample[STAT_DEFRAG_DATA_SIZE_N_SAMPLE]; + /* data size when compression failure happened + the most recent 10 times. */ + ulint stat_defrag_sample_next_slot; + /* in which slot the next sample should be + saved. */ + /* @} */ prio_rw_lock_t lock; /*!< read-write lock protecting the upper levels of the index tree */ trx_id_t trx_id; /*!< id of the transaction that created this diff --git a/storage/xtradb/include/dict0pagecompress.ic b/storage/xtradb/include/dict0pagecompress.ic index ea3c7546850..811976434a8 100644 --- a/storage/xtradb/include/dict0pagecompress.ic +++ b/storage/xtradb/include/dict0pagecompress.ic @@ -122,7 +122,7 @@ dict_tf_get_page_compression_level( { ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags); - ut_ad(page_compression_level >= 0 && page_compression_level <= 9); + ut_ad(page_compression_level <= 9); return(page_compression_level); } diff --git a/storage/xtradb/include/dict0priv.h b/storage/xtradb/include/dict0priv.h index 9a3c8e22992..e034662aba0 100644 --- a/storage/xtradb/include/dict0priv.h +++ b/storage/xtradb/include/dict0priv.h @@ -53,8 +53,9 @@ dict_table_t* dict_table_open_on_id_low( /*=====================*/ table_id_t table_id, /*!< in: table id */ - dict_err_ignore_t ignore_err); /*!< in: errors to ignore + dict_err_ignore_t ignore_err, /*!< in: errors to ignore when loading the table */ + ibool open_only_if_in_cache); #ifndef UNIV_NONINL #include "dict0priv.ic" diff --git a/storage/xtradb/include/dict0priv.ic b/storage/xtradb/include/dict0priv.ic index 30ba8fb60aa..983218af78a 100644 --- a/storage/xtradb/include/dict0priv.ic +++ b/storage/xtradb/include/dict0priv.ic @@ -74,8 +74,9 @@ dict_table_t* dict_table_open_on_id_low( /*======================*/ table_id_t table_id, /*!< in: table id */ - dict_err_ignore_t ignore_err) /*!< in: errors to ignore + dict_err_ignore_t ignore_err, /*!< in: errors to ignore when loading the table */ + ibool open_only_if_in_cache) { dict_table_t* table; ulint fold; @@ -88,7 +89,7 @@ dict_table_open_on_id_low( HASH_SEARCH(id_hash, dict_sys->table_id_hash, fold, dict_table_t*, table, ut_ad(table->cached), table->id == table_id); - if (table == NULL) { + if (table == NULL && !open_only_if_in_cache) { table = dict_load_table_on_id(table_id, ignore_err); } diff --git a/storage/xtradb/include/dict0stats.h b/storage/xtradb/include/dict0stats.h index 186f90e3694..abf56b2f0c7 100644 --- a/storage/xtradb/include/dict0stats.h +++ b/storage/xtradb/include/dict0stats.h @@ -195,6 +195,39 @@ dict_stats_rename_table( is returned */ size_t errstr_sz); /*!< in: errstr size */ +/*********************************************************************//** +Save defragmentation result. +@return DB_SUCCESS or error code */ +UNIV_INTERN +dberr_t +dict_stats_save_defrag_summary( + dict_index_t* index); /*!< in: index */ + +/*********************************************************************//** +Save defragmentation stats for a given index. +@return DB_SUCCESS or error code */ +UNIV_INTERN +dberr_t +dict_stats_save_defrag_stats( + dict_index_t* index); /*!< in: index */ + +/**********************************************************************//** +Clear defragmentation summary. */ +UNIV_INTERN +void +dict_stats_empty_defrag_summary( +/*==================*/ + dict_index_t* index); /*!< in: index to clear defragmentation stats */ + +/**********************************************************************//** +Clear defragmentation related index stats. */ +UNIV_INTERN +void +dict_stats_empty_defrag_stats( +/*==================*/ + dict_index_t* index); /*!< in: index to clear defragmentation stats */ + + #ifndef UNIV_NONINL #include "dict0stats.ic" #endif diff --git a/storage/xtradb/include/dict0stats_bg.h b/storage/xtradb/include/dict0stats_bg.h index e866ab419fe..32fac3015e8 100644 --- a/storage/xtradb/include/dict0stats_bg.h +++ b/storage/xtradb/include/dict0stats_bg.h @@ -56,6 +56,28 @@ dict_stats_recalc_pool_del( /*=======================*/ const dict_table_t* table); /*!< in: table to remove */ +/*****************************************************************//** +Add an index in a table to the defrag pool, which is processed by the +background stats gathering thread. Only the table id and index id are +added to the list, so the table can be closed after being enqueued and +it will be opened when needed. If the table or index does not exist later +(has been DROPped), then it will be removed from the pool and skipped. */ +UNIV_INTERN +void +dict_stats_defrag_pool_add( +/*=======================*/ + const dict_index_t* index); /*!< in: table to add */ + +/*****************************************************************//** +Delete a given index from the auto defrag pool. */ +UNIV_INTERN +void +dict_stats_defrag_pool_del( +/*=======================*/ + const dict_table_t* table, /*!<in: if given, remove + all entries for the table */ + const dict_index_t* index); /*!< in: index to remove */ + /** Yield the data dictionary latch when waiting for the background thread to stop accessing a table. @param trx transaction holding the data dictionary locks */ diff --git a/storage/xtradb/include/fil0fil.h b/storage/xtradb/include/fil0fil.h index a73faa89655..3960eef5d7e 100644 --- a/storage/xtradb/include/fil0fil.h +++ b/storage/xtradb/include/fil0fil.h @@ -1119,7 +1119,7 @@ os_file_handle_error_no_exit( /*******************************************************************//** Return page type name */ -char* +const char* fil_get_page_type_name( /*===================*/ ulint page_type); /*!< in: FIL_PAGE_TYPE */ diff --git a/storage/xtradb/include/fsp0fsp.ic b/storage/xtradb/include/fsp0fsp.ic index 3563f5ef372..ddcb87b0e57 100644 --- a/storage/xtradb/include/fsp0fsp.ic +++ b/storage/xtradb/include/fsp0fsp.ic @@ -135,7 +135,7 @@ fsp_flags_is_valid( } } - if (atomic_writes < 0 || atomic_writes > ATOMIC_WRITES_OFF) { + if (atomic_writes > ATOMIC_WRITES_OFF) { fprintf(stderr, "InnoDB: Error: Tablespace flags %lu corrupted atomic_writes %lu\n", flags, atomic_writes); return (false); diff --git a/storage/xtradb/include/lock0lock.h b/storage/xtradb/include/lock0lock.h index 633e4f6626b..8d5515b5eb5 100644 --- a/storage/xtradb/include/lock0lock.h +++ b/storage/xtradb/include/lock0lock.h @@ -183,6 +183,16 @@ lock_update_merge_left( const buf_block_t* right_block); /*!< in: merged index page which will be discarded */ /*************************************************************//** +Updates the lock table when a page is splited and merged to +two pages. */ +UNIV_INTERN +void +lock_update_split_and_merge( + const buf_block_t* left_block, /*!< in: left page to which merged */ + const rec_t* orig_pred, /*!< in: original predecessor of + supremum on the left page before merge*/ + const buf_block_t* right_block);/*!< in: right page from which merged */ +/*************************************************************//** Resets the original locks on heir and replaces them with gap type locks inherited from rec. */ UNIV_INTERN diff --git a/storage/xtradb/include/srv0srv.h b/storage/xtradb/include/srv0srv.h index a54198f4e00..48cad8c36c0 100644 --- a/storage/xtradb/include/srv0srv.h +++ b/storage/xtradb/include/srv0srv.h @@ -401,6 +401,15 @@ extern my_bool srv_random_read_ahead; extern ulong srv_read_ahead_threshold; extern ulint srv_n_read_io_threads; extern ulint srv_n_write_io_threads; +/* Defragmentation, Origianlly facebook default value is 100, but it's too high */ +#define SRV_DEFRAGMENT_FREQUENCY_DEFAULT 40 +extern my_bool srv_defragment; +extern uint srv_defragment_n_pages; +extern uint srv_defragment_stats_accuracy; +extern uint srv_defragment_fill_factor_n_recs; +extern double srv_defragment_fill_factor; +extern uint srv_defragment_frequency; +extern ulonglong srv_defragment_interval; /* Number of IO operations per second the server can do */ extern ulong srv_io_capacity; @@ -1103,6 +1112,9 @@ struct export_var_t{ ib_int64_t innodb_x_lock_os_waits; ib_int64_t innodb_x_lock_spin_rounds; ib_int64_t innodb_x_lock_spin_waits; + ulint innodb_defragment_compression_failures; + ulint innodb_defragment_failures; + ulint innodb_defragment_count; #ifdef UNIV_DEBUG ulint innodb_purge_trx_id_age; /*!< rw_max_trx_id - purged trx_id */ ulint innodb_purge_view_trx_id_age; /*!< rw_max_trx_id diff --git a/storage/xtradb/include/sync0sync.h b/storage/xtradb/include/sync0sync.h index 788f765f919..72cfbf61dd8 100644 --- a/storage/xtradb/include/sync0sync.h +++ b/storage/xtradb/include/sync0sync.h @@ -864,6 +864,7 @@ or row lock! */ #define SYNC_EXTERN_STORAGE 500 #define SYNC_FSP 400 #define SYNC_FSP_PAGE 395 +#define SYNC_STATS_DEFRAG 390 /*------------------------------------- Change buffer headers */ #define SYNC_IBUF_MUTEX 370 /* ibuf_mutex */ /*------------------------------------- Change buffer tree */ diff --git a/storage/xtradb/include/ut0timer.h b/storage/xtradb/include/ut0timer.h new file mode 100644 index 00000000000..f361ae79bf5 --- /dev/null +++ b/storage/xtradb/include/ut0timer.h @@ -0,0 +1,104 @@ +/***************************************************************************** + +Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. +Copyright (c) 2014, SkySQL Ab. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +/********************************************************************//** +@file include/ut0timer.h +Timer rountines + +Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com +modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 +*************************************************************************/ +#ifndef ut0timer_h +#define ut0timer_h + +#include "univ.i" +#include "data0type.h" +#include <my_rdtsc.h> + +/* Current timer stats */ +extern struct my_timer_unit_info ut_timer; + +/**************************************************************//** +Function pointer to point selected timer function. +@return timer current value */ +extern ulonglong (*ut_timer_now)(void); + +/**************************************************************//** +Sets up the data required for use of my_timer_* functions. +Selects the best timer by high frequency, and tight resolution. +Points my_timer_now() to the selected timer function. +Initializes my_timer struct to contain the info for selected timer.*/ +UNIV_INTERN +void ut_init_timer(void); + +/**************************************************************//** +Return time passed since time then, automatically adjusted +for the estimated timer overhead. +@return time passed since "then" */ +UNIV_INLINE +ulonglong +ut_timer_since( +/*===========*/ + ulonglong then); /*!< in: time where to calculate */ +/**************************************************************//** +Get time passed since "then", and update then to now +@return time passed sinche "then" */ +UNIV_INLINE +ulonglong +ut_timer_since_and_update( +/*======================*/ + ulonglong *then); /*!< in: time where to calculate */ +/**************************************************************//** +Convert native timer units in a ulonglong into seconds in a double +@return time in a seconds */ +UNIV_INLINE +double +ut_timer_to_seconds( +/*=================*/ + ulonglong when); /*!< in: time where to calculate */ +/**************************************************************//** +Convert native timer units in a ulonglong into milliseconds in a double +@return time in milliseconds */ +UNIV_INLINE +double +ut_timer_to_milliseconds( +/*=====================*/ + ulonglong when); /*!< in: time where to calculate */ +/**************************************************************//** +Convert native timer units in a ulonglong into microseconds in a double +@return time in microseconds */ +UNIV_INLINE +double +ut_timer_to_microseconds( +/*=====================*/ + ulonglong when); /*!< in: time where to calculate */ +/**************************************************************//** +Convert microseconds in a double to native timer units in a ulonglong +@return time in microseconds */ +UNIV_INLINE +ulonglong +ut_microseconds_to_timer( +/*=====================*/ + ulonglong when); /*!< in: time where to calculate */ + +#ifndef UNIV_NONINL +#include "ut0timer.ic" +#endif + +#endif diff --git a/storage/xtradb/include/ut0timer.ic b/storage/xtradb/include/ut0timer.ic new file mode 100644 index 00000000000..62e17a10fb1 --- /dev/null +++ b/storage/xtradb/include/ut0timer.ic @@ -0,0 +1,113 @@ +/***************************************************************************** + +Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. +Copyright (c) 2014, SkySQL Ab. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +/********************************************************************//** +@file include/ut0timer.ic +Timer rountines + +Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com +modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 +*************************************************************************/ + +/**************************************************************//** +Return time passed since time then, automatically adjusted +for the estimated timer overhead. +@return time passed since "then" */ +UNIV_INLINE +ulonglong +ut_timer_since( +/*===========*/ + ulonglong then) /*!< in: time where to calculate */ +{ + return (ut_timer_now() - then) - ut_timer.overhead; +} + +/**************************************************************//** +Get time passed since "then", and update then to now +@return time passed sinche "then" */ +UNIV_INLINE +ulonglong +ut_timer_since_and_update( +/*======================*/ + ulonglong *then) /*!< in: time where to calculate */ +{ + ulonglong now = ut_timer_now(); + ulonglong ret = (now - (*then)) - ut_timer.overhead; + *then = now; + return ret; +} + +/**************************************************************//** +Convert native timer units in a ulonglong into seconds in a double +@return time in a seconds */ +UNIV_INLINE +double +ut_timer_to_seconds( +/*=================*/ + ulonglong when) /*!< in: time where to calculate */ +{ + double ret = (double)(when); + ret /= (double)(ut_timer.frequency); + return ret; +} + +/**************************************************************//** +Convert native timer units in a ulonglong into milliseconds in a double +@return time in milliseconds */ +UNIV_INLINE +double +ut_timer_to_milliseconds( +/*=====================*/ + ulonglong when) /*!< in: time where to calculate */ +{ + double ret = (double)(when); + ret *= 1000.0; + ret /= (double)(ut_timer.frequency); + return ret; +} + +/**************************************************************//** +Convert native timer units in a ulonglong into microseconds in a double +@return time in microseconds */ +UNIV_INLINE +double +ut_timer_to_microseconds( +/*=====================*/ + ulonglong when) /*!< in: time where to calculate */ +{ + double ret = (double)(when); + ret *= 1000000.0; + ret /= (double)(ut_timer.frequency); + return ret; +} + +/**************************************************************//** +Convert microseconds in a double to native timer units in a ulonglong +@return time in microseconds */ +UNIV_INLINE +ulonglong +ut_microseconds_to_timer( +/*=====================*/ + ulonglong when) /*!< in: time where to calculate */ +{ + double ret = when; + ret *= (double)(ut_timer.frequency); + ret /= 1000000.0; + return (ulonglong)ret; +} diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc index 8f7724daad9..532bd6232b7 100644 --- a/storage/xtradb/lock/lock0lock.cc +++ b/storage/xtradb/lock/lock0lock.cc @@ -3592,6 +3592,47 @@ lock_update_merge_left( } /*************************************************************//** +Updates the lock table when a page is split and merged to +two pages. */ +UNIV_INTERN +void +lock_update_split_and_merge( + const buf_block_t* left_block, /*!< in: left page to which merged */ + const rec_t* orig_pred, /*!< in: original predecessor of + supremum on the left page before merge*/ + const buf_block_t* right_block) /*!< in: right page from which merged */ +{ + const rec_t* left_next_rec; + + ut_a(left_block && right_block); + ut_a(orig_pred); + + lock_mutex_enter(); + + left_next_rec = page_rec_get_next_const(orig_pred); + + /* Inherit the locks on the supremum of the left page to the + first record which was moved from the right page */ + lock_rec_inherit_to_gap( + left_block, left_block, + page_rec_get_heap_no(left_next_rec), + PAGE_HEAP_NO_SUPREMUM); + + /* Reset the locks on the supremum of the left page, + releasing waiting transactions */ + lock_rec_reset_and_release_wait(left_block, + PAGE_HEAP_NO_SUPREMUM); + + /* Inherit the locks to the supremum of the left page from the + successor of the infimum on the right page */ + lock_rec_inherit_to_gap(left_block, right_block, + PAGE_HEAP_NO_SUPREMUM, + lock_get_min_heap_no(right_block)); + + lock_mutex_exit(); +} + +/*************************************************************//** Resets the original locks on heir and replaces them with gap type locks inherited from rec. */ UNIV_INTERN diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc index edcb6662fe9..bec3d1b0080 100644 --- a/storage/xtradb/os/os0file.cc +++ b/storage/xtradb/os/os0file.cc @@ -877,8 +877,11 @@ os_file_handle_error_cond_exit( is better to ignore on_error_silent and print an error message to the log. */ - fprintf(stderr, - " InnoDB: at file %s and at line %ld\n", file, line); + if (should_exit || !on_error_silent) { + fprintf(stderr, + " InnoDB: Operation %s to file %s and at line %ld\n", + operation, file, line); + } if (should_exit || !on_error_silent) { ib_logf(IB_LOG_LEVEL_ERROR, "File %s: '%s' returned OS " diff --git a/storage/xtradb/page/page0cur.cc b/storage/xtradb/page/page0cur.cc index f5f7e1299ce..97405261392 100644 --- a/storage/xtradb/page/page0cur.cc +++ b/storage/xtradb/page/page0cur.cc @@ -1349,6 +1349,21 @@ page_cur_insert_rec_zip( return(insert_rec); } + /* Page compress failed. If this happened on a + leaf page, put the data size into the sample + buffer. */ + if (page_is_leaf(page)) { + ulint occupied = page_get_data_size(page) + + page_dir_calc_reserved_space( + page_get_n_recs(page)); + index->stat_defrag_data_size_sample[ + index->stat_defrag_sample_next_slot] = + occupied; + index->stat_defrag_sample_next_slot = + (index->stat_defrag_sample_next_slot + + 1) % STAT_DEFRAG_DATA_SIZE_N_SAMPLE; + } + ut_ad(cursor->rec == (pos > 1 ? page_rec_get_nth( diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index 0b2e966efe0..4428de30473 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -2106,6 +2106,7 @@ row_merge( /* Copy the last blocks, if there are any. */ while (foffs0 < ihalf) { + if (UNIV_UNLIKELY(trx_is_interrupted(trx))) { return(DB_INTERRUPTED); } @@ -2122,6 +2123,7 @@ row_merge( ut_ad(foffs0 == ihalf); while (foffs1 < file->offset) { + if (trx_is_interrupted(trx)) { return(DB_INTERRUPTED); } @@ -2181,6 +2183,7 @@ row_merge_sort( { const ulint half = file->offset / 2; ulint num_runs; + ulint cur_run = 0; ulint* run_offset; dberr_t error = DB_SUCCESS; DBUG_ENTER("row_merge_sort"); @@ -2204,8 +2207,16 @@ row_merge_sort( of file marker). Thus, it must be at least one block. */ ut_ad(file->offset > 0); + thd_progress_init(trx->mysql_thd, num_runs); + /* Merge the runs until we have one big run */ do { + cur_run++; + + /* Report progress of merge sort to MySQL for + show processlist progress field */ + thd_progress_report(trx->mysql_thd, cur_run, num_runs); + error = row_merge(trx, dup, file, block, tmpfd, &num_runs, run_offset); @@ -2218,6 +2229,8 @@ row_merge_sort( mem_free(run_offset); + thd_progress_end(trx->mysql_thd); + DBUG_RETURN(error); } diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index c65c39b7971..86de2eeb14c 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -53,6 +53,7 @@ Created 9/17/2000 Heikki Tuuri #include "rem0cmp.h" #include "log0log.h" #include "btr0sea.h" +#include "btr0defragment.h" #include "fil0fil.h" #include "ibuf0ibuf.h" #include "fts0fts.h" @@ -3857,6 +3858,8 @@ row_drop_table_for_mysql( if (!dict_table_is_temporary(table)) { dict_stats_recalc_pool_del(table); + dict_stats_defrag_pool_del(table, NULL); + btr_defragment_remove_table(table); /* Remove stats for this table and all of its indexes from the persistent storage if it exists and if there are stats for this diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc index d421980d41a..896bb8a3b77 100644 --- a/storage/xtradb/srv/srv0srv.cc +++ b/storage/xtradb/srv/srv0srv.cc @@ -70,10 +70,11 @@ Created 10/8/1995 Heikki Tuuri #include "srv0mon.h" #include "ut0crc32.h" #include "os0file.h" - +#include "btr0defragment.h" #include "mysql/plugin.h" #include "mysql/service_thd_wait.h" #include "fil0pagecompress.h" +#include <my_rdtsc.h> /* prototypes of new functions added to ha_innodb.cc for kill_idle_transaction */ ibool innobase_thd_is_idle(const void* thd); @@ -292,6 +293,16 @@ UNIV_INTERN ulint srv_buf_pool_curr_size = 0; UNIV_INTERN ulint srv_mem_pool_size = ULINT_MAX; UNIV_INTERN ulint srv_lock_table_size = ULINT_MAX; +/* Defragmentation */ +UNIV_INTERN my_bool srv_defragment = FALSE; +UNIV_INTERN uint srv_defragment_n_pages = 7; +UNIV_INTERN uint srv_defragment_stats_accuracy = 0; +UNIV_INTERN uint srv_defragment_fill_factor_n_recs = 20; +UNIV_INTERN double srv_defragment_fill_factor = 0.9; +UNIV_INTERN uint srv_defragment_frequency = + SRV_DEFRAGMENT_FREQUENCY_DEFAULT; +UNIV_INTERN ulonglong srv_defragment_interval = 0; + /** Query thread preflush algorithm */ UNIV_INTERN ulong srv_foreground_preflush = SRV_FOREGROUND_PREFLUSH_EXP_BACKOFF; @@ -1896,6 +1907,11 @@ srv_export_innodb_status(void) export_vars.innodb_page_compressed_trim_op_saved = srv_stats.page_compressed_trim_op_saved; export_vars.innodb_pages_page_decompressed = srv_stats.pages_page_decompressed; + export_vars.innodb_defragment_compression_failures = + btr_defragment_compression_failures; + export_vars.innodb_defragment_failures = btr_defragment_failures; + export_vars.innodb_defragment_count = btr_defragment_count; + #ifdef UNIV_DEBUG rw_lock_s_lock(&purge_sys->latch); trx_id_t done_trx_no = purge_sys->done.trx_no; diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index 3aedede7c97..cb7aa9bc3c7 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -69,6 +69,8 @@ Created 2/16/1996 Heikki Tuuri #include "srv0start.h" #include "srv0srv.h" #include "buf0flu.h" +#include "btr0defragment.h" +#include "ut0timer.h" #ifndef UNIV_HOTBACKUP # include "trx0rseg.h" @@ -1575,6 +1577,9 @@ innobase_start_or_create_for_mysql(void) char* logfile0 = NULL; size_t dirnamelen; + /* This should be initialized early */ + ut_init_timer(); + if (srv_force_recovery > SRV_FORCE_NO_TRX_UNDO) { srv_read_only_mode = true; } @@ -2960,6 +2965,9 @@ files_checked: fts_optimize_init(); } + /* Initialize online defragmentation. */ + btr_defragment_init(); + srv_was_started = TRUE; return(DB_SUCCESS); diff --git a/storage/xtradb/sync/sync0sync.cc b/storage/xtradb/sync/sync0sync.cc index e698b7dcf10..1c5b144eb24 100644 --- a/storage/xtradb/sync/sync0sync.cc +++ b/storage/xtradb/sync/sync0sync.cc @@ -1272,6 +1272,7 @@ sync_thread_add_level( case SYNC_IBUF_MUTEX: case SYNC_INDEX_ONLINE_LOG: case SYNC_STATS_AUTO_RECALC: + case SYNC_STATS_DEFRAG: if (!sync_thread_levels_g(array, level, TRUE)) { fprintf(stderr, "InnoDB: sync_thread_levels_g(array, %lu)" diff --git a/storage/xtradb/ut/ut0timer.cc b/storage/xtradb/ut/ut0timer.cc new file mode 100644 index 00000000000..85292cce28c --- /dev/null +++ b/storage/xtradb/ut/ut0timer.cc @@ -0,0 +1,92 @@ +/***************************************************************************** + +Copyright (c) 2013, 2014, Facebook, Inc. All Rights Reserved. +Copyright (c) 2014, SkySQL Ab. All Rights Reserved. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +/********************************************************************//** +@file ut/ut0timer.cc +Timer rountines + +Created 30/07/2014 Jan Lindström jan.lindstrom@skysql.com +modified from https://github.com/facebook/mysql-5.6/commit/c75a413edeb96eb99bf11d7269bdfea06f96d6b6 +*************************************************************************/ + +#include "data0type.h" +#include <my_rdtsc.h> +#include <ut0timer.h> + +/**************************************************************//** +Initial timer definition +@return 0 */ +static +ulonglong +ut_timer_none(void) +/*===============*/ +{ + return 0; +} + +/**************************************************************//** +Function pointer to point selected timer function. +@return timer current value */ +ulonglong (*ut_timer_now)(void) = &ut_timer_none; + +struct my_timer_unit_info ut_timer; + +/**************************************************************//** +Sets up the data required for use of my_timer_* functions. +Selects the best timer by high frequency, and tight resolution. +Points my_timer_now() to the selected timer function. +Initializes my_timer struct to contain the info for selected timer.*/ +UNIV_INTERN +void +ut_init_timer(void) +/*===============*/ +{ + MY_TIMER_INFO all_timer_info; + my_timer_init(&all_timer_info); + + if (all_timer_info.cycles.frequency > 1000000 && + all_timer_info.cycles.resolution == 1) { + ut_timer = all_timer_info.cycles; + ut_timer_now = &my_timer_cycles; + } else if (all_timer_info.nanoseconds.frequency > 1000000 && + all_timer_info.nanoseconds.resolution == 1) { + ut_timer = all_timer_info.nanoseconds; + ut_timer_now = &my_timer_nanoseconds; + } else if (all_timer_info.microseconds.frequency >= 1000000 && + all_timer_info.microseconds.resolution == 1) { + ut_timer = all_timer_info.microseconds; + ut_timer_now = &my_timer_microseconds; + + } else if (all_timer_info.milliseconds.frequency >= 1000 && + all_timer_info.milliseconds.resolution == 1) { + ut_timer = all_timer_info.milliseconds; + ut_timer_now = &my_timer_milliseconds; + } else if (all_timer_info.ticks.frequency >= 1000 && + /* Will probably be false */ + all_timer_info.ticks.resolution == 1) { + ut_timer = all_timer_info.ticks; + ut_timer_now = &my_timer_ticks; + } else { + /* None are acceptable, so leave it as "None", and fill in struct */ + ut_timer.frequency = 1; /* Avoid div-by-zero */ + ut_timer.overhead = 0; /* Since it doesn't do anything */ + ut_timer.resolution = 10; /* Another sign it's bad */ + ut_timer.routine = 0; /* None */ + } +} |