diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index e0d8dad060f..e5a8255c428 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -149,7 +149,7 @@ fi # Override -DFORCE_INIT_OF_VARS from debug_cflags. It enables the macro # LINT_INIT(), which is only useful for silencing spurious warnings # of static analysis tools. We want LINT_INIT() to be a no-op in Valgrind. -valgrind_flags="-UFORCE_INIT_OF_VARS -DHAVE_purify " +valgrind_flags="-UFORCE_INIT_OF_VARS -DHAVE_purify -DHAVE_valgrind " valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max" valgrind_configs="--with-valgrind" # diff --git a/BUILD/compile-innodb b/BUILD/compile-innodb index 82601f03ae9..988c862465d 100755 --- a/BUILD/compile-innodb +++ b/BUILD/compile-innodb @@ -1,24 +1,25 @@ -#! /bin/sh +#!/bin/sh +# +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. # -# Copyright (c) 2006, 2009, Innobase Oy. 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., 59 Temple # Place, Suite 330, Boston, MA 02111-1307 USA # -path=`dirname $0` -. "$path/SETUP.sh" +# we assume this script is in storage/innobase/ -extra_flags="$pentium_cflags $fast_cflags -g" -extra_configs="$pentium_configs $static_link --with-plugins=innobase" +MYSQL_ROOT="$(dirname ${0})/../.." -. "$path/FINISH.sh" +cd ${MYSQL_ROOT} + +cmake -DWITH_INNOBASE_STORAGE_ENGINE:BOOL=ON +make -j$(nproc) diff --git a/BUILD/compile-innodb-debug b/BUILD/compile-innodb-debug deleted file mode 100755 index efb4abf88d5..00000000000 --- a/BUILD/compile-innodb-debug +++ /dev/null @@ -1,24 +0,0 @@ -#! /bin/sh -# -# Copyright (c) 2005, 2009, Innobase Oy. 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., 59 Temple -# Place, Suite 330, Boston, MA 02111-1307 USA -# - -path=`dirname $0` -. "$path/SETUP.sh" $@ --with-debug=full - -extra_flags="$pentium_cflags $debug_cflags" -extra_configs="$pentium_configs $debug_configs --with-plugins=innobase" - -. "$path/FINISH.sh" diff --git a/include/my_valgrind.h b/include/my_valgrind.h index c0a6cef4b59..87e6c3192dc 100644 --- a/include/my_valgrind.h +++ b/include/my_valgrind.h @@ -22,7 +22,7 @@ #define IF_VALGRIND(A,B) B #endif -#if defined(HAVE_valgrind) && defined(HAVE_VALGRIND_MEMCHECK_H) +#if defined(HAVE_VALGRIND) && defined(HAVE_VALGRIND_MEMCHECK_H) # include # define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len) # define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len) diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index d83c91c5ec3..69d6a3fc615 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -44,7 +44,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql-common/client_plugin.c ../sql/password.c ../sql/discover.cc ../sql/derror.cc ../sql/field.cc ../sql/field_conv.cc - ../sql/filesort.cc ../sql/gstream.cc + ../sql/filesort.cc ../sql/gstream.cc ../sql/slave.cc ../sql/handler.cc ../sql/hash_filo.cc ../sql/hostname.cc ../sql/init.cc ../sql/item_buff.cc ../sql/item_cmpfunc.cc ../sql/item.cc ../sql/item_create.cc ../sql/item_func.cc diff --git a/mysql-test/include/have_innodb.opt b/mysql-test/include/have_innodb.opt index 5d9121b3dc3..4fb96229a7b 100644 --- a/mysql-test/include/have_innodb.opt +++ b/mysql-test/include/have_innodb.opt @@ -1,2 +1,2 @@ --loose-innodb ---plugin-load=$HA_INNODB_SO +--plugin-load=$HA_XTRADB_SO diff --git a/mysql-test/include/have_xtradb.inc b/mysql-test/include/have_xtradb.inc index 5832267375c..cf92b0317df 100644 --- a/mysql-test/include/have_xtradb.inc +++ b/mysql-test/include/have_xtradb.inc @@ -1,3 +1,4 @@ +--source include/have_innodb.inc if (!`SELECT count(*) FROM information_schema.plugins WHERE plugin_name = 'innodb' AND plugin_status = 'active' AND plugin_description LIKE '%xtradb%'`){ diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index c5995987914..4614535c188 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -1120,6 +1120,11 @@ INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1); INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1; # should be range access + +# +# InnoDB uses "where", while xtradb "index condition" +# +--replace_regex /where/index condition/ EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; # should produce '8 7 6 5 4' for a diff --git a/mysql-test/include/mysqld--help.inc b/mysql-test/include/mysqld--help.inc index a39615d6011..91fe9bf00e3 100644 --- a/mysql-test/include/mysqld--help.inc +++ b/mysql-test/include/mysqld--help.inc @@ -22,7 +22,7 @@ perl; # Plugins which may or may not be there: @plugins=qw/innodb ndb archive blackhole federated partition ndbcluster debug temp-pool ssl des-key-file - thread-concurrency super-large-pages mutex-deadlock-detector null-audit maria aria pbxt oqgraph sphinx/; + xtradb thread-concurrency super-large-pages mutex-deadlock-detector null-audit maria aria pbxt oqgraph sphinx/; # And substitute the content some environment variables with their # names: @@ -39,7 +39,7 @@ perl; next if /Value \(after reading options\)/; # skip table header next if /^($re1) /; next if /^($re2)-/; - $skip=0 if /^ -/; + $skip=0 if /^ -/ or /^$/; $skip=1 if / --($re2)\b/; y!\\!/!; s/[ ]+/ /; # squeeze spaces to remove table formatting diff --git a/mysql-test/include/percona_query_cache_with_comments.inc b/mysql-test/include/percona_query_cache_with_comments.inc deleted file mode 100644 index bed87bd4c22..00000000000 --- a/mysql-test/include/percona_query_cache_with_comments.inc +++ /dev/null @@ -1,95 +0,0 @@ ---source include/percona_query_cache_with_comments_clear.inc -let $query=/* with comment first */select * from t1; -eval $query; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=# with comment first -select * from t1; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=-- with comment first -select * from t1; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=/* with comment first and "quote" */select * from t1; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=# with comment first and "quote" -select * from t1; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=-- with comment first and "quote" -select * from t1; ---source include/percona_query_cache_with_comments_eval.inc - -let $query= - /* with comment and whitespaces first */select * from t1; ---source include/percona_query_cache_with_comments_eval.inc - -let $query= - # with comment and whitespaces first -select * from t1; ---source include/percona_query_cache_with_comments_eval.inc - -let $query= - -- with comment and whitespaces first -select * from t1; ---source include/percona_query_cache_with_comments_eval.inc - -let $internal=* internal comment *; - -let $query=select * /$internal/ from t1; ---source include/percona_query_cache_with_comments_eval.inc -let $query=select */$internal/ from t1; ---source include/percona_query_cache_with_comments_eval.inc -let $query=select */$internal/from t1; ---source include/percona_query_cache_with_comments_eval.inc - -let $internal=* internal comment with "quote" *; - -let $query=select * /$internal/ from t1; ---source include/percona_query_cache_with_comments_eval.inc -let $query=select */$internal/ from t1; ---source include/percona_query_cache_with_comments_eval.inc -let $query=select */$internal/from t1; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select * from t1 -; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select * from t1 ; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select * from t1 ; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select * from t1 -/* comment in the end */; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select * from t1 -/* *\/ */; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select * from t1 -/* comment in the end */ -; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select * from t1 #comment in the end; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select * from t1 #comment in the end -; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select * from t1 -- comment in the end; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select * from t1 -- comment in the end -; ---source include/percona_query_cache_with_comments_eval.inc - -let $query=select ' \' ' from t1; ---source include/percona_query_cache_with_comments_eval.inc diff --git a/mysql-test/include/percona_query_response_time_sleep.inc b/mysql-test/include/percona_query_response_time_sleep.inc deleted file mode 100644 index 40688b173b0..00000000000 --- a/mysql-test/include/percona_query_response_time_sleep.inc +++ /dev/null @@ -1,19 +0,0 @@ -SELECT SLEEP(0.31); -SELECT SLEEP(0.32); -SELECT SLEEP(0.33); -SELECT SLEEP(0.34); -SELECT SLEEP(0.35); -SELECT SLEEP(0.36); -SELECT SLEEP(0.37); -SELECT SLEEP(0.38); -SELECT SLEEP(0.39); -SELECT SLEEP(0.40); -SELECT SLEEP(1.1); -SELECT SLEEP(1.2); -SELECT SLEEP(1.3); -SELECT SLEEP(1.5); -SELECT SLEEP(1.4); -SELECT SLEEP(0.5); -SELECT SLEEP(2.1); -SELECT SLEEP(2.3); -SELECT SLEEP(2.5); diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index c9bac8be27f..2eedac79d25 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -862,7 +862,7 @@ x_double_precision NULL NULL drop table t1; grant select on test.* to mysqltest_4@localhost; SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS -where COLUMN_NAME='TABLE_NAME'; +where COLUMN_NAME='TABLE_NAME' and table_name not like 'innodb%'; TABLE_NAME COLUMN_NAME PRIVILEGES COLUMNS TABLE_NAME select COLUMN_PRIVILEGES TABLE_NAME select @@ -1250,12 +1250,12 @@ f1() DROP FUNCTION f1; DROP PROCEDURE p1; DROP USER mysql_bug20230@localhost; -SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test'); +SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test') and table_name not like 'xtradb%'; MAX(table_name) VIEWS SELECT table_name from information_schema.tables WHERE table_name=(SELECT MAX(table_name) -FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test')); +FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test') and table_name not like 'xtradb%'); table_name VIEWS DROP TABLE IF EXISTS bug23037; diff --git a/mysql-test/r/information_schema_all_engines.result b/mysql-test/r/information_schema_all_engines.result index 7a2c548a329..013d480c8e1 100644 --- a/mysql-test/r/information_schema_all_engines.result +++ b/mysql-test/r/information_schema_all_engines.result @@ -15,6 +15,7 @@ GLOBAL_VARIABLES INDEX_STATISTICS KEY_CACHES KEY_COLUMN_USAGE +PARAMETERS PARTITIONS PLUGINS PROCESSLIST @@ -27,6 +28,7 @@ SESSION_STATUS SESSION_VARIABLES STATISTICS TABLES +TABLESPACES TABLE_CONSTRAINTS TABLE_PRIVILEGES TABLE_STATISTICS @@ -34,25 +36,29 @@ TRIGGERS USER_PRIVILEGES USER_STATISTICS VIEWS -INNODB_BUFFER_POOL_PAGES -PBXT_STATISTICS -INNODB_CMP -INNODB_RSEG -XTRADB_ENHANCEMENTS -INNODB_BUFFER_POOL_PAGES_INDEX -XTRADB_ADMIN_COMMAND -INNODB_TRX -INNODB_SYS_TABLES -INNODB_LOCK_WAITS -INNODB_SYS_STATS -INNODB_LOCKS -INNODB_CMPMEM -INNODB_TABLE_STATS -INNODB_SYS_INDEXES -INNODB_CMP_RESET -INNODB_BUFFER_POOL_PAGES_BLOB INNODB_CMPMEM_RESET +PBXT_STATISTICS +INNODB_CMPMEM +INNODB_RSEG +INNODB_SYS_TABLESTATS +INNODB_LOCK_WAITS INNODB_INDEX_STATS +INNODB_CMP +INNODB_SYS_FOREIGN_COLS +INNODB_CMP_RESET +INNODB_BUFFER_POOL_PAGES +INNODB_TRX +INNODB_BUFFER_POOL_PAGES_INDEX +INNODB_LOCKS +INNODB_BUFFER_POOL_PAGES_BLOB +INNODB_SYS_TABLES +INNODB_SYS_FIELDS +INNODB_SYS_COLUMNS +INNODB_TABLE_STATS +INNODB_SYS_STATS +INNODB_SYS_FOREIGN +INNODB_SYS_INDEXES +XTRADB_ADMIN_COMMAND SELECT t.table_name, c1.column_name FROM information_schema.tables t INNER JOIN @@ -82,6 +88,7 @@ GLOBAL_VARIABLES VARIABLE_NAME INDEX_STATISTICS TABLE_SCHEMA KEY_CACHES KEY_CACHE_NAME KEY_COLUMN_USAGE CONSTRAINT_SCHEMA +PARAMETERS SPECIFIC_SCHEMA PARTITIONS TABLE_SCHEMA PLUGINS PLUGIN_NAME PROCESSLIST ID @@ -94,6 +101,7 @@ SESSION_STATUS VARIABLE_NAME SESSION_VARIABLES VARIABLE_NAME STATISTICS TABLE_SCHEMA TABLES TABLE_SCHEMA +TABLESPACES TABLESPACE_NAME TABLE_CONSTRAINTS CONSTRAINT_SCHEMA TABLE_PRIVILEGES TABLE_SCHEMA TABLE_STATISTICS TABLE_SCHEMA @@ -101,25 +109,29 @@ TRIGGERS TRIGGER_SCHEMA USER_PRIVILEGES GRANTEE USER_STATISTICS USER VIEWS TABLE_SCHEMA -INNODB_BUFFER_POOL_PAGES page_type -PBXT_STATISTICS ID -INNODB_CMP page_size -INNODB_RSEG rseg_id -XTRADB_ENHANCEMENTS name -INNODB_BUFFER_POOL_PAGES_INDEX index_id -XTRADB_ADMIN_COMMAND result_message -INNODB_TRX trx_id -INNODB_SYS_TABLES SCHEMA -INNODB_LOCK_WAITS requesting_trx_id -INNODB_SYS_STATS INDEX_ID -INNODB_LOCKS lock_id -INNODB_CMPMEM page_size -INNODB_TABLE_STATS table_schema -INNODB_SYS_INDEXES TABLE_ID -INNODB_CMP_RESET page_size -INNODB_BUFFER_POOL_PAGES_BLOB space_id INNODB_CMPMEM_RESET page_size +PBXT_STATISTICS ID +INNODB_CMPMEM page_size +INNODB_RSEG rseg_id +INNODB_SYS_TABLESTATS SCHEMA +INNODB_LOCK_WAITS requesting_trx_id INNODB_INDEX_STATS table_schema +INNODB_CMP page_size +INNODB_SYS_FOREIGN_COLS ID +INNODB_CMP_RESET page_size +INNODB_BUFFER_POOL_PAGES page_type +INNODB_TRX trx_id +INNODB_BUFFER_POOL_PAGES_INDEX index_id +INNODB_LOCKS lock_id +INNODB_BUFFER_POOL_PAGES_BLOB space_id +INNODB_SYS_TABLES SCHEMA +INNODB_SYS_FIELDS INDEX_ID +INNODB_SYS_COLUMNS TABLE_ID +INNODB_TABLE_STATS table_schema +INNODB_SYS_STATS INDEX_ID +INNODB_SYS_FOREIGN ID +INNODB_SYS_INDEXES INDEX_ID +XTRADB_ADMIN_COMMAND result_message SELECT t.table_name, c1.column_name FROM information_schema.tables t INNER JOIN @@ -149,6 +161,7 @@ GLOBAL_VARIABLES VARIABLE_NAME INDEX_STATISTICS TABLE_SCHEMA KEY_CACHES KEY_CACHE_NAME KEY_COLUMN_USAGE CONSTRAINT_SCHEMA +PARAMETERS SPECIFIC_SCHEMA PARTITIONS TABLE_SCHEMA PLUGINS PLUGIN_NAME PROCESSLIST ID @@ -161,6 +174,7 @@ SESSION_STATUS VARIABLE_NAME SESSION_VARIABLES VARIABLE_NAME STATISTICS TABLE_SCHEMA TABLES TABLE_SCHEMA +TABLESPACES TABLESPACE_NAME TABLE_CONSTRAINTS CONSTRAINT_SCHEMA TABLE_PRIVILEGES TABLE_SCHEMA TABLE_STATISTICS TABLE_SCHEMA @@ -168,25 +182,29 @@ TRIGGERS TRIGGER_SCHEMA USER_PRIVILEGES GRANTEE USER_STATISTICS USER VIEWS TABLE_SCHEMA -INNODB_BUFFER_POOL_PAGES page_type -PBXT_STATISTICS ID -INNODB_CMP page_size -INNODB_RSEG rseg_id -XTRADB_ENHANCEMENTS name -INNODB_BUFFER_POOL_PAGES_INDEX index_id -XTRADB_ADMIN_COMMAND result_message -INNODB_TRX trx_id -INNODB_SYS_TABLES SCHEMA -INNODB_LOCK_WAITS requesting_trx_id -INNODB_SYS_STATS INDEX_ID -INNODB_LOCKS lock_id -INNODB_CMPMEM page_size -INNODB_TABLE_STATS table_schema -INNODB_SYS_INDEXES TABLE_ID -INNODB_CMP_RESET page_size -INNODB_BUFFER_POOL_PAGES_BLOB space_id INNODB_CMPMEM_RESET page_size +PBXT_STATISTICS ID +INNODB_CMPMEM page_size +INNODB_RSEG rseg_id +INNODB_SYS_TABLESTATS SCHEMA +INNODB_LOCK_WAITS requesting_trx_id INNODB_INDEX_STATS table_schema +INNODB_CMP page_size +INNODB_SYS_FOREIGN_COLS ID +INNODB_CMP_RESET page_size +INNODB_BUFFER_POOL_PAGES page_type +INNODB_TRX trx_id +INNODB_BUFFER_POOL_PAGES_INDEX index_id +INNODB_LOCKS lock_id +INNODB_BUFFER_POOL_PAGES_BLOB space_id +INNODB_SYS_TABLES SCHEMA +INNODB_SYS_FIELDS INDEX_ID +INNODB_SYS_COLUMNS TABLE_ID +INNODB_TABLE_STATS table_schema +INNODB_SYS_STATS INDEX_ID +INNODB_SYS_FOREIGN ID +INNODB_SYS_INDEXES INDEX_ID +XTRADB_ADMIN_COMMAND result_message select 1 as f1 from information_schema.tables where "CHARACTER_SETS"= (select cast(table_name as char) from information_schema.tables order by table_name limit 1) limit 1; @@ -231,13 +249,19 @@ INNODB_INDEX_STATS information_schema.INNODB_INDEX_STATS 1 INNODB_LOCKS information_schema.INNODB_LOCKS 1 INNODB_LOCK_WAITS information_schema.INNODB_LOCK_WAITS 1 INNODB_RSEG information_schema.INNODB_RSEG 1 +INNODB_SYS_COLUMNS information_schema.INNODB_SYS_COLUMNS 1 +INNODB_SYS_FIELDS information_schema.INNODB_SYS_FIELDS 1 +INNODB_SYS_FOREIGN information_schema.INNODB_SYS_FOREIGN 1 +INNODB_SYS_FOREIGN_COLS information_schema.INNODB_SYS_FOREIGN_COLS 1 INNODB_SYS_INDEXES information_schema.INNODB_SYS_INDEXES 1 INNODB_SYS_STATS information_schema.INNODB_SYS_STATS 1 INNODB_SYS_TABLES information_schema.INNODB_SYS_TABLES 1 +INNODB_SYS_TABLESTATS information_schema.INNODB_SYS_TABLESTATS 1 INNODB_TABLE_STATS information_schema.INNODB_TABLE_STATS 1 INNODB_TRX information_schema.INNODB_TRX 1 KEY_CACHES information_schema.KEY_CACHES 1 KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1 +PARAMETERS information_schema.PARAMETERS 1 PARTITIONS information_schema.PARTITIONS 1 PBXT_STATISTICS information_schema.PBXT_STATISTICS 1 PLUGINS information_schema.PLUGINS 1 @@ -251,6 +275,7 @@ SESSION_STATUS information_schema.SESSION_STATUS 1 SESSION_VARIABLES information_schema.SESSION_VARIABLES 1 STATISTICS information_schema.STATISTICS 1 TABLES information_schema.TABLES 1 +TABLESPACES information_schema.TABLESPACES 1 TABLE_CONSTRAINTS information_schema.TABLE_CONSTRAINTS 1 TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1 TABLE_STATISTICS information_schema.TABLE_STATISTICS 1 @@ -258,7 +283,6 @@ TRIGGERS information_schema.TRIGGERS 1 USER_PRIVILEGES information_schema.USER_PRIVILEGES 1 USER_STATISTICS information_schema.USER_STATISTICS 1 VIEWS information_schema.VIEWS 1 -XTRADB_ENHANCEMENTS information_schema.XTRADB_ENHANCEMENTS 1 Database: information_schema +---------------------------------------+ | Tables | @@ -277,6 +301,7 @@ Database: information_schema | INDEX_STATISTICS | | KEY_CACHES | | KEY_COLUMN_USAGE | +| PARAMETERS | | PARTITIONS | | PLUGINS | | PROCESSLIST | @@ -289,6 +314,7 @@ Database: information_schema | SESSION_VARIABLES | | STATISTICS | | TABLES | +| TABLESPACES | | TABLE_CONSTRAINTS | | TABLE_PRIVILEGES | | TABLE_STATISTICS | @@ -296,25 +322,29 @@ Database: information_schema | USER_PRIVILEGES | | USER_STATISTICS | | VIEWS | -| INNODB_BUFFER_POOL_PAGES | -| PBXT_STATISTICS | -| INNODB_CMP | -| INNODB_RSEG | -| XTRADB_ENHANCEMENTS | -| INNODB_BUFFER_POOL_PAGES_INDEX | -| XTRADB_ADMIN_COMMAND | -| INNODB_TRX | -| INNODB_SYS_TABLES | -| INNODB_LOCK_WAITS | -| INNODB_SYS_STATS | -| INNODB_LOCKS | -| INNODB_CMPMEM | -| INNODB_TABLE_STATS | -| INNODB_SYS_INDEXES | -| INNODB_CMP_RESET | -| INNODB_BUFFER_POOL_PAGES_BLOB | | INNODB_CMPMEM_RESET | +| PBXT_STATISTICS | +| INNODB_CMPMEM | +| INNODB_RSEG | +| INNODB_SYS_TABLESTATS | +| INNODB_LOCK_WAITS | | INNODB_INDEX_STATS | +| INNODB_CMP | +| INNODB_SYS_FOREIGN_COLS | +| INNODB_CMP_RESET | +| INNODB_BUFFER_POOL_PAGES | +| INNODB_TRX | +| INNODB_BUFFER_POOL_PAGES_INDEX | +| INNODB_LOCKS | +| INNODB_BUFFER_POOL_PAGES_BLOB | +| INNODB_SYS_TABLES | +| INNODB_SYS_FIELDS | +| INNODB_SYS_COLUMNS | +| INNODB_TABLE_STATS | +| INNODB_SYS_STATS | +| INNODB_SYS_FOREIGN | +| INNODB_SYS_INDEXES | +| XTRADB_ADMIN_COMMAND | +---------------------------------------+ Database: INFORMATION_SCHEMA +---------------------------------------+ @@ -334,6 +364,7 @@ Database: INFORMATION_SCHEMA | INDEX_STATISTICS | | KEY_CACHES | | KEY_COLUMN_USAGE | +| PARAMETERS | | PARTITIONS | | PLUGINS | | PROCESSLIST | @@ -346,6 +377,7 @@ Database: INFORMATION_SCHEMA | SESSION_VARIABLES | | STATISTICS | | TABLES | +| TABLESPACES | | TABLE_CONSTRAINTS | | TABLE_PRIVILEGES | | TABLE_STATISTICS | @@ -353,25 +385,29 @@ Database: INFORMATION_SCHEMA | USER_PRIVILEGES | | USER_STATISTICS | | VIEWS | -| INNODB_BUFFER_POOL_PAGES | -| PBXT_STATISTICS | -| INNODB_CMP | -| INNODB_RSEG | -| XTRADB_ENHANCEMENTS | -| INNODB_BUFFER_POOL_PAGES_INDEX | -| XTRADB_ADMIN_COMMAND | -| INNODB_TRX | -| INNODB_SYS_TABLES | -| INNODB_LOCK_WAITS | -| INNODB_SYS_STATS | -| INNODB_LOCKS | -| INNODB_CMPMEM | -| INNODB_TABLE_STATS | -| INNODB_SYS_INDEXES | -| INNODB_CMP_RESET | -| INNODB_BUFFER_POOL_PAGES_BLOB | | INNODB_CMPMEM_RESET | +| PBXT_STATISTICS | +| INNODB_CMPMEM | +| INNODB_RSEG | +| INNODB_SYS_TABLESTATS | +| INNODB_LOCK_WAITS | | INNODB_INDEX_STATS | +| INNODB_CMP | +| INNODB_SYS_FOREIGN_COLS | +| INNODB_CMP_RESET | +| INNODB_BUFFER_POOL_PAGES | +| INNODB_TRX | +| INNODB_BUFFER_POOL_PAGES_INDEX | +| INNODB_LOCKS | +| INNODB_BUFFER_POOL_PAGES_BLOB | +| INNODB_SYS_TABLES | +| INNODB_SYS_FIELDS | +| INNODB_SYS_COLUMNS | +| INNODB_TABLE_STATS | +| INNODB_SYS_STATS | +| INNODB_SYS_FOREIGN | +| INNODB_SYS_INDEXES | +| XTRADB_ADMIN_COMMAND | +---------------------------------------+ Wildcard: inf_rmation_schema +--------------------+ @@ -381,5 +417,5 @@ Wildcard: inf_rmation_schema +--------------------+ SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA; table_schema count(*) -information_schema 52 -mysql 22 +information_schema 58 +mysql 23 diff --git a/mysql-test/r/innodb-analyze.result b/mysql-test/r/innodb-analyze.result deleted file mode 100644 index 2aee004a2d6..00000000000 --- a/mysql-test/r/innodb-analyze.result +++ /dev/null @@ -1,2 +0,0 @@ -Variable_name Value -innodb_stats_sample_pages 1 diff --git a/mysql-test/r/innodb-consistent.result b/mysql-test/r/innodb-consistent.result deleted file mode 100644 index 9115791b99c..00000000000 --- a/mysql-test/r/innodb-consistent.result +++ /dev/null @@ -1,35 +0,0 @@ -drop table if exists t1; -set session transaction isolation level read committed; -create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; -create table t2 like t1; -insert into t2 values (1),(2),(3),(4),(5),(6),(7); -set autocommit=0; -begin; -replace into t1 select * from t2; -set session transaction isolation level read committed; -set autocommit=0; -delete from t2 where a=5; -commit; -delete from t2; -commit; -commit; -begin; -insert into t1 select * from t2; -set session transaction isolation level read committed; -set autocommit=0; -delete from t2 where a=5; -commit; -delete from t2; -commit; -commit; -select * from t1; -a -1 -2 -3 -4 -5 -6 -7 -drop table t1; -drop table t2; diff --git a/mysql-test/r/innodb-index_ucs2.result b/mysql-test/r/innodb-index_ucs2.result deleted file mode 100644 index c8a1e8c7da1..00000000000 --- a/mysql-test/r/innodb-index_ucs2.result +++ /dev/null @@ -1,116 +0,0 @@ -create table t1(a int not null, b int, c char(10), d varchar(20), primary key (a)) engine = innodb default charset=ucs2; -insert into t1 values (1,1,'ab','ab'),(2,2,'ac','ac'),(3,2,'ad','ad'),(4,4,'afe','afe'); -commit; -alter table t1 add unique index (b); -ERROR 23000: Duplicate entry '2' for key 'b' -insert into t1 values(8,9,'fff','fff'); -select * from t1; -a b c d -1 1 ab ab -2 2 ac ac -3 2 ad ad -4 4 afe afe -8 9 fff fff -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL, - `b` int(11) DEFAULT NULL, - `c` char(10) DEFAULT NULL, - `d` varchar(20) DEFAULT NULL, - PRIMARY KEY (`a`) -) ENGINE=InnoDB DEFAULT CHARSET=ucs2 -alter table t1 add index (b); -insert into t1 values(10,10,'kkk','iii'); -select * from t1; -a b c d -1 1 ab ab -2 2 ac ac -3 2 ad ad -4 4 afe afe -8 9 fff fff -10 10 kkk iii -select * from t1 force index(b) order by b; -a b c d -1 1 ab ab -2 2 ac ac -3 2 ad ad -4 4 afe afe -8 9 fff fff -10 10 kkk iii -explain select * from t1 force index(b) order by b; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL b 5 NULL 6 -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL, - `b` int(11) DEFAULT NULL, - `c` char(10) DEFAULT NULL, - `d` varchar(20) DEFAULT NULL, - PRIMARY KEY (`a`), - KEY `b` (`b`) -) ENGINE=InnoDB DEFAULT CHARSET=ucs2 -alter table t1 add unique index (c), add index (d); -insert into t1 values(11,11,'aaa','mmm'); -select * from t1; -a b c d -1 1 ab ab -2 2 ac ac -3 2 ad ad -4 4 afe afe -8 9 fff fff -10 10 kkk iii -11 11 aaa mmm -select * from t1 force index(b) order by b; -a b c d -1 1 ab ab -2 2 ac ac -3 2 ad ad -4 4 afe afe -8 9 fff fff -10 10 kkk iii -11 11 aaa mmm -select * from t1 force index(c) order by c; -a b c d -11 11 aaa mmm -1 1 ab ab -2 2 ac ac -3 2 ad ad -4 4 afe afe -8 9 fff fff -10 10 kkk iii -select * from t1 force index(d) order by d; -a b c d -1 1 ab ab -2 2 ac ac -3 2 ad ad -4 4 afe afe -8 9 fff fff -10 10 kkk iii -11 11 aaa mmm -explain select * from t1 force index(b) order by b; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL b 5 NULL 7 -explain select * from t1 force index(c) order by c; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL c 21 NULL 7 -explain select * from t1 force index(d) order by d; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL d 43 NULL 7 -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL, - `b` int(11) DEFAULT NULL, - `c` char(10) DEFAULT NULL, - `d` varchar(20) DEFAULT NULL, - PRIMARY KEY (`a`), - UNIQUE KEY `c` (`c`), - KEY `b` (`b`), - KEY `d` (`d`) -) ENGINE=InnoDB DEFAULT CHARSET=ucs2 -check table t1; -Table Op Msg_type Msg_text -test.t1 check status OK -drop table t1; diff --git a/mysql-test/r/innodb-replace.result b/mysql-test/r/innodb-replace.result deleted file mode 100644 index c926bb89a2e..00000000000 --- a/mysql-test/r/innodb-replace.result +++ /dev/null @@ -1,13 +0,0 @@ -drop table if exists t1; -create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; -select * from t1; -c1 c2 stamp -replace delayed into t1 (c1, c2) values ( "text1","11"); -ERROR HY000: DELAYED option not supported for table 't1' -select * from t1; -c1 c2 stamp -replace delayed into t1 (c1, c2) values ( "text1","12"); -ERROR HY000: DELAYED option not supported for table 't1' -select * from t1; -c1 c2 stamp -drop table t1; diff --git a/mysql-test/r/innodb-timeout.result b/mysql-test/r/innodb-timeout.result deleted file mode 100644 index 2d34cdb1cda..00000000000 --- a/mysql-test/r/innodb-timeout.result +++ /dev/null @@ -1,46 +0,0 @@ -set global innodb_lock_wait_timeout=42; -select @@innodb_lock_wait_timeout; -@@innodb_lock_wait_timeout -42 -set innodb_lock_wait_timeout=1; -select @@innodb_lock_wait_timeout; -@@innodb_lock_wait_timeout -1 -select @@innodb_lock_wait_timeout; -@@innodb_lock_wait_timeout -42 -set global innodb_lock_wait_timeout=347; -select @@innodb_lock_wait_timeout; -@@innodb_lock_wait_timeout -42 -set innodb_lock_wait_timeout=1; -select @@innodb_lock_wait_timeout; -@@innodb_lock_wait_timeout -1 -select @@innodb_lock_wait_timeout; -@@innodb_lock_wait_timeout -347 -create table t1(a int primary key)engine=innodb; -begin; -insert into t1 values(1),(2),(3); -set innodb_lock_wait_timeout=5; -select * from t1 for update; -commit; -a -1 -2 -3 -begin; -insert into t1 values(4); -set innodb_lock_wait_timeout=2; -set @a= current_timestamp(); -select * from t1 for update; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -set @b= current_timestamp(); -set @c= timestampdiff(SECOND, @a, @b); -select if(@c >= 1 and @c <= 10, 'OK', concat("NOT OK, time passed=", @c)); -if(@c >= 1 and @c <= 10, 'OK', concat("NOT OK, time passed=", @c)) -OK -commit; -drop table t1; -set global innodb_lock_wait_timeout=50; diff --git a/mysql-test/r/innodb_bug34053.result b/mysql-test/r/innodb_bug34053.result deleted file mode 100644 index 195775f74c8..00000000000 --- a/mysql-test/r/innodb_bug34053.result +++ /dev/null @@ -1 +0,0 @@ -SET storage_engine=InnoDB; diff --git a/mysql-test/r/innodb_bug34300.result b/mysql-test/r/innodb_bug34300.result deleted file mode 100644 index ae9fee81ad7..00000000000 --- a/mysql-test/r/innodb_bug34300.result +++ /dev/null @@ -1,4 +0,0 @@ -f4 f8 -xxx zzz -f4 f8 -xxx zzz diff --git a/mysql-test/r/innodb_bug35220.result b/mysql-test/r/innodb_bug35220.result deleted file mode 100644 index 195775f74c8..00000000000 --- a/mysql-test/r/innodb_bug35220.result +++ /dev/null @@ -1 +0,0 @@ -SET storage_engine=InnoDB; diff --git a/mysql-test/r/innodb_bug36169.result b/mysql-test/r/innodb_bug36169.result deleted file mode 100644 index aa80e4d7aa4..00000000000 --- a/mysql-test/r/innodb_bug36169.result +++ /dev/null @@ -1,2 +0,0 @@ -SET GLOBAL innodb_file_format='Barracuda'; -SET GLOBAL innodb_file_per_table=ON; diff --git a/mysql-test/r/innodb_bug40360.result b/mysql-test/r/innodb_bug40360.result deleted file mode 100644 index ef4cf463903..00000000000 --- a/mysql-test/r/innodb_bug40360.result +++ /dev/null @@ -1,4 +0,0 @@ -SET TX_ISOLATION='READ-COMMITTED'; -CREATE TABLE bug40360 (a INT) engine=innodb; -INSERT INTO bug40360 VALUES (1); -DROP TABLE bug40360; diff --git a/mysql-test/r/innodb_bug41904.result b/mysql-test/r/innodb_bug41904.result deleted file mode 100644 index 6070d32d181..00000000000 --- a/mysql-test/r/innodb_bug41904.result +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE bug41904 (id INT PRIMARY KEY, uniquecol CHAR(15)) ENGINE=InnoDB; -INSERT INTO bug41904 VALUES (1,NULL), (2,NULL); -CREATE UNIQUE INDEX ui ON bug41904 (uniquecol); -DROP TABLE bug41904; diff --git a/mysql-test/r/innodb_bug44571.result b/mysql-test/r/innodb_bug44571.result deleted file mode 100644 index 955b55ac673..00000000000 --- a/mysql-test/r/innodb_bug44571.result +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE bug44571 (foo INT) ENGINE=InnoDB; -ALTER TABLE bug44571 CHANGE foo bar INT; -ALTER TABLE bug44571 ADD INDEX bug44571b (foo); -ERROR 42000: Key column 'foo' doesn't exist in table -ALTER TABLE bug44571 ADD INDEX bug44571b (bar); -CREATE INDEX bug44571c ON bug44571 (bar); -DROP TABLE bug44571; diff --git a/mysql-test/r/innodb_bug46676.result b/mysql-test/r/innodb_bug46676.result deleted file mode 100644 index 996799ce931..00000000000 --- a/mysql-test/r/innodb_bug46676.result +++ /dev/null @@ -1,9 +0,0 @@ -SET foreign_key_checks=0; -CREATE TABLE t1 (id int, foreign key (id) references t2(id)) ENGINE=INNODB; -CREATE TABLE t2 (id int, foreign key (id) references t1(id)) ENGINE=INNODB; -SET foreign_key_checks=1; -SELECT COUNT(*) FROM information_schema.key_column_usage WHERE REFERENCED_TABLE_NAME in ('t1', 't2'); -COUNT(*) -2 -SET foreign_key_checks=0; -DROP TABLE t1, t2; diff --git a/mysql-test/r/innodb_information_schema.result b/mysql-test/r/innodb_information_schema.result deleted file mode 100644 index 396cae579ce..00000000000 --- a/mysql-test/r/innodb_information_schema.result +++ /dev/null @@ -1,23 +0,0 @@ -lock_mode lock_type lock_table lock_index lock_rec lock_data -X RECORD `test`.```t'\"_str` `PRIMARY` 2 '1', 'abc', '''abc', 'abc''', 'a''bc', 'a''bc''', '''abc''''' -X RECORD `test`.```t'\"_str` `PRIMARY` 2 '1', 'abc', '''abc', 'abc''', 'a''bc', 'a''bc''', '''abc''''' -X RECORD `test`.```t'\"_str` `PRIMARY` 3 '2', 'abc', '"abc', 'abc"', 'a"bc', 'a"bc"', '"abc""' -X RECORD `test`.```t'\"_str` `PRIMARY` 3 '2', 'abc', '"abc', 'abc"', 'a"bc', 'a"bc"', '"abc""' -X RECORD `test`.```t'\"_str` `PRIMARY` 4 '3', 'abc', '\\abc', 'abc\\', 'a\\bc', 'a\\bc\\', '\\abc\\\\' -X RECORD `test`.```t'\"_str` `PRIMARY` 4 '3', 'abc', '\\abc', 'abc\\', 'a\\bc', 'a\\bc\\', '\\abc\\\\' -X RECORD `test`.```t'\"_str` `PRIMARY` 5 '4', 'abc', '\0abc', 'abc\0', 'a\0bc', 'a\0bc\0', 'a\0bc\0\0' -X RECORD `test`.```t'\"_str` `PRIMARY` 5 '4', 'abc', '\0abc', 'abc\0', 'a\0bc', 'a\0bc\0', 'a\0bc\0\0' -X RECORD `test`.`t_min` `PRIMARY` 2 -128, 0, -32768, 0, -8388608, 0, -2147483648, 0, -9223372036854775808, 0 -X RECORD `test`.`t_min` `PRIMARY` 2 -128, 0, -32768, 0, -8388608, 0, -2147483648, 0, -9223372036854775808, 0 -X RECORD `test`.`t_max` `PRIMARY` 2 127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615 -X RECORD `test`.`t_max` `PRIMARY` 2 127, 255, 32767, 65535, 8388607, 16777215, 2147483647, 4294967295, 9223372036854775807, 18446744073709551615 -X RECORD `test`.```t'\"_str` `PRIMARY` 1 supremum pseudo-record -X RECORD `test`.```t'\"_str` `PRIMARY` 1 supremum pseudo-record -lock_table COUNT(*) -`test`.`t_max` 2 -`test`.`t_min` 2 -`test`.```t'\"_str` 10 -lock_table COUNT(*) -"test"."t_max" 2 -"test"."t_min" 2 -"test"."`t'\""_str" 10 diff --git a/mysql-test/r/innodb_trx_weight.result b/mysql-test/r/innodb_trx_weight.result deleted file mode 100644 index 195775f74c8..00000000000 --- a/mysql-test/r/innodb_trx_weight.result +++ /dev/null @@ -1 +0,0 @@ -SET storage_engine=InnoDB; diff --git a/mysql-test/suite/innodb/r/innodb_mysql.result b/mysql-test/suite/innodb/r/innodb_mysql.result index 5b1c0a8b611..deb84a87e93 100644 --- a/mysql-test/suite/innodb/r/innodb_mysql.result +++ b/mysql-test/suite/innodb/r/innodb_mysql.result @@ -1375,7 +1375,7 @@ INSERT INTO t1 (a,b,c) VALUES (1,1,1), (2,1,1), (3,1,1), (4,1,1); INSERT INTO t1 (a,b,c) SELECT a+4,b,c FROM t1; EXPLAIN SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range t1_b t1_b 5 NULL 8 Using where +1 SIMPLE t1 range t1_b t1_b 5 NULL 8 Using index condition SELECT a, b, c FROM t1 WHERE b = 1 ORDER BY a DESC LIMIT 5; a b c 8 1 1 diff --git a/mysql-test/suite/pbxt/r/mysqlshow.result b/mysql-test/suite/pbxt/r/mysqlshow.result index 4898da69b98..96e45e84b77 100644 --- a/mysql-test/suite/pbxt/r/mysqlshow.result +++ b/mysql-test/suite/pbxt/r/mysqlshow.result @@ -114,7 +114,29 @@ Database: information_schema | USER_PRIVILEGES | | USER_STATISTICS | | VIEWS | +| INNODB_CMPMEM_RESET | | PBXT_STATISTICS | +| INNODB_CMPMEM | +| INNODB_RSEG | +| INNODB_SYS_TABLESTATS | +| INNODB_LOCK_WAITS | +| INNODB_INDEX_STATS | +| INNODB_CMP | +| INNODB_SYS_FOREIGN_COLS | +| INNODB_CMP_RESET | +| INNODB_BUFFER_POOL_PAGES | +| INNODB_TRX | +| INNODB_BUFFER_POOL_PAGES_INDEX | +| INNODB_LOCKS | +| INNODB_BUFFER_POOL_PAGES_BLOB | +| INNODB_SYS_TABLES | +| INNODB_SYS_FIELDS | +| INNODB_SYS_COLUMNS | +| INNODB_TABLE_STATS | +| INNODB_SYS_STATS | +| INNODB_SYS_FOREIGN | +| INNODB_SYS_INDEXES | +| XTRADB_ADMIN_COMMAND | +---------------------------------------+ Database: INFORMATION_SCHEMA +---------------------------------------+ @@ -155,7 +177,29 @@ Database: INFORMATION_SCHEMA | USER_PRIVILEGES | | USER_STATISTICS | | VIEWS | +| INNODB_CMPMEM_RESET | | PBXT_STATISTICS | +| INNODB_CMPMEM | +| INNODB_RSEG | +| INNODB_SYS_TABLESTATS | +| INNODB_LOCK_WAITS | +| INNODB_INDEX_STATS | +| INNODB_CMP | +| INNODB_SYS_FOREIGN_COLS | +| INNODB_CMP_RESET | +| INNODB_BUFFER_POOL_PAGES | +| INNODB_TRX | +| INNODB_BUFFER_POOL_PAGES_INDEX | +| INNODB_LOCKS | +| INNODB_BUFFER_POOL_PAGES_BLOB | +| INNODB_SYS_TABLES | +| INNODB_SYS_FIELDS | +| INNODB_SYS_COLUMNS | +| INNODB_TABLE_STATS | +| INNODB_SYS_STATS | +| INNODB_SYS_FOREIGN | +| INNODB_SYS_INDEXES | +| XTRADB_ADMIN_COMMAND | +---------------------------------------+ Wildcard: inf_rmation_schema +--------------------+ diff --git a/mysql-test/suite/pbxt/t/mysqlshow.test b/mysql-test/suite/pbxt/t/mysqlshow.test index d8f5c20afcd..41505cc0b10 100644 --- a/mysql-test/suite/pbxt/t/mysqlshow.test +++ b/mysql-test/suite/pbxt/t/mysqlshow.test @@ -1,5 +1,6 @@ # Can't run test of external client with embedded server -- source include/not_embedded.inc +-- source include/have_innodb.inc --disable_warnings DROP TABLE IF EXISTS t1,t2,test1,test2; diff --git a/mysql-test/suite/percona/disabled.def b/mysql-test/suite/percona/disabled.def index a99b952a5eb..c20f5f3860d 100644 --- a/mysql-test/suite/percona/disabled.def +++ b/mysql-test/suite/percona/disabled.def @@ -16,7 +16,23 @@ percona_status_wait_query_cache_mutex: Feature not merged into MariaDB percona_slave_innodb_stats: Feature not merged into MariaDB percona_query_response_time-replication: Feature not merged into MariaDB percona_server_variables: Feature not merged into MariaDB - percona_slow_query_log-log_slow_verbosity: InnoDB filtering information not fully merged into MariaDB - percona_innodb_buffer_pool_shm: Requires big shmmax not default on many systems +percona_log_warnings_suppress: Feature not merged into MariaDB +percona_slow_extended-log_slow_sp_statements-cl: Feature not merged into MariaDB +percona_slow_extended-log_slow_verbosity-cl: Feature not merged into MariaDB +slow_query_log_use_global_control: Feature not merged into MariaDB +percona_slow_extended-use_global_control: Feature not merged into MariaDB +percona_slow_query_log-log_slow_verbosity: Feature not merged into MariaDB +percona_slow_extended-log_slow_verbosity: Feature not merged into MariaDB +percona_slow_extended-microseconds_in_slow_extended: Feature not merged into MariaDB +percona_slow_extended-use_global_long_query_time: Feature not merged into MariaDB +percona_slow_extended-slow_query_log_timestamp_always-cl: Feature not merged into MariaDB +percona_slow_extended-slow_query_log_microseconds_timestamp-cl: Feature not merged into MariaDB +percona_bug643149: Feature not merged into MariaDB +percona_processlist_row_stats: Feature not merged into MariaDB +percona_server_variables_debug: Feature not merged into MariaDB +percona_slow_extended-slave_statements: Feature not merged into MariaDB +percona_show_slave_status_nolock: Feature not merged into MariaDB +percona_slow_extended-slave_innodb_stats: Feature not merged into MariaDB +percona_slow_extended-slave_statements-and-use_global_long_query_time: Feature not merged into MariaDB diff --git a/mysql-test/suite/percona/grep.inc b/mysql-test/suite/percona/grep.inc new file mode 100644 index 00000000000..c9c823fa695 --- /dev/null +++ b/mysql-test/suite/percona/grep.inc @@ -0,0 +1,16 @@ +perl; + + $file = $ENV{'grep_file'}; + $pattern = $ENV{'grep_pattern'}; + + open(FILE, "$file") + or die("Cannot open file $file: $!\n"); + + $lines = 0; + while() { + $lines++ if (/$pattern/); + } + print "$lines\n"; + + close(FILE); +EOF diff --git a/mysql-test/suite/percona/have_response_time_distribution.inc b/mysql-test/suite/percona/have_response_time_distribution.inc new file mode 100644 index 00000000000..45650133b31 --- /dev/null +++ b/mysql-test/suite/percona/have_response_time_distribution.inc @@ -0,0 +1,4 @@ +if (`SELECT @@have_response_time_distribution != 'YES'`) +{ + --skip No response time distribution +} diff --git a/mysql-test/suite/percona/percona_bug643149.result b/mysql-test/suite/percona/percona_bug643149.result new file mode 100644 index 00000000000..1a447a194e7 --- /dev/null +++ b/mysql-test/suite/percona/percona_bug643149.result @@ -0,0 +1,21 @@ +SET @old_slow_query_log_file=@@global.slow_query_log_file; +SET GLOBAL slow_query_log=on; +SET LOCAL log_slow_verbosity='profiling'; +SET LOCAL long_query_time=0; +SET GLOBAL slow_query_log_file='MYSQLTEST_VARDIR/percona_bug643149_slow.log';; +SELECT 1; +1 +1 +# User@Host: root[root] @ localhost [] +# Thread_id: X Schema: test Last_errno: X Killed: X +# Query_time: X.X Lock_time: X.X Rows_sent: X Rows_examined: X Rows_affected: X Rows_read: X +# Bytes_sent: X Tmp_tables: X Tmp_disk_tables: X Tmp_table_sizes: X +# Profile_starting: X.X Profile_starting_cpu: X.X Profile_Opening_tables: X.X Profile_Opening_tables_cpu: X.X Profile_query_end: X.X Profile_query_end_cpu: X.X Profile_closing_tables: X.X Profile_closing_tables_cpu: X.X Profile_freeing_items: X.X Profile_freeing_items_cpu: X.X Profile_logging_slow_query: X.X Profile_logging_slow_query_cpu: X.X +# Profile_total: X.X Profile_total_cpu: X.X +# User@Host: root[root] @ localhost [] +# Thread_id: X Schema: test Last_errno: X Killed: X +# Query_time: X.X Lock_time: X.X Rows_sent: X Rows_examined: X Rows_affected: X Rows_read: X +# Bytes_sent: X Tmp_tables: X Tmp_disk_tables: X Tmp_table_sizes: X +# Profile_starting: X.X Profile_starting_cpu: X.X Profile_checking_permissions: X.X Profile_checking_permissions_cpu: X.X Profile_Opening_tables: X.X Profile_Opening_tables_cpu: X.X Profile_init: X.X Profile_init_cpu: X.X Profile_optimizing: X.X Profile_optimizing_cpu: X.X Profile_executing: X.X Profile_executing_cpu: X.X Profile_end: X.X Profile_end_cpu: X.X Profile_query_end: X.X Profile_query_end_cpu: X.X Profile_closing_tables: X.X Profile_closing_tables_cpu: X.X Profile_freeing_items: X.X Profile_freeing_items_cpu: X.X Profile_logging_slow_query: X.X Profile_logging_slow_query_cpu: X.X +# Profile_total: X.X Profile_total_cpu: X.X +SET GLOBAL slow_query_log_file=@old_slow_query_log_file; diff --git a/mysql-test/suite/percona/percona_bug643149.test b/mysql-test/suite/percona/percona_bug643149.test new file mode 100644 index 00000000000..fa31b169a19 --- /dev/null +++ b/mysql-test/suite/percona/percona_bug643149.test @@ -0,0 +1,49 @@ +# +# This test suffers from server +# Bug#38124 "general_log_file" variable silently unset when using expression +# In short: +# SET GLOBAL general_log_file = @ +# SET GLOBAL slow_query_log = @ +# cause that the value of these server system variables is set to default +# instead of the assigned values. There comes no error message or warning. +# If this bug is fixed please +# 1. try this test with "let $fixed_bug38124 = 0;" +# 2. remove all workarounds if 1. was successful. +--source include/have_profiling.inc +let $fixed_bug38124 = 0; + +SET @old_slow_query_log_file=@@global.slow_query_log_file; +SET GLOBAL slow_query_log=on; +SET LOCAL log_slow_verbosity='profiling'; +SET LOCAL long_query_time=0; + +let slogfile=$MYSQLTEST_VARDIR/percona_bug643149_slow.log; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SET GLOBAL slow_query_log_file='$slogfile'; + +SELECT 1; + +perl; + $slogfile= $ENV{'slogfile'}; + + open(FILE, "$slogfile") or + die("Unable to read slow query log file $slogfile: $!\n"); + while() { + next if (!/^#/); + next if (/^# Time:/); + s/[0-9]+/X/g; + print; + } + + close(FILE); +EOF + +SET GLOBAL slow_query_log_file=@old_slow_query_log_file; + +if(!$fixed_bug38124) +{ + --disable_query_log + let $my_var = `SELECT @old_slow_query_log_file`; + eval SET @@global.slow_query_log_file = '$my_var'; + --enable_query_log +} diff --git a/mysql-test/suite/percona/percona_innodb_buffer_pool_shm.result b/mysql-test/suite/percona/percona_innodb_buffer_pool_shm.result index 08ece8fb9a9..e5373606099 100644 --- a/mysql-test/suite/percona/percona_innodb_buffer_pool_shm.result +++ b/mysql-test/suite/percona/percona_innodb_buffer_pool_shm.result @@ -1,6 +1,4 @@ show variables like 'innodb_buffer_pool_shm%'; Variable_name Value -innodb_buffer_pool_shm_key 123456 -show variables like 'innodb_buffer_pool_shm%'; -Variable_name Value +innodb_buffer_pool_shm_checksum ON innodb_buffer_pool_shm_key 123456 diff --git a/mysql-test/suite/percona/percona_innodb_buffer_pool_shm.test b/mysql-test/suite/percona/percona_innodb_buffer_pool_shm.test index 7b81bb8d54b..7b26c217893 100644 --- a/mysql-test/suite/percona/percona_innodb_buffer_pool_shm.test +++ b/mysql-test/suite/percona/percona_innodb_buffer_pool_shm.test @@ -1,18 +1,2 @@ ---source include/have_innodb.inc +--source include/have_xtradb.inc show variables like 'innodb_buffer_pool_shm%'; - -#clean shutdown (restart_mysqld.inc is not clean if over 10 sec...) ---write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -wait -EOF -shutdown_server 120; ---append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect -restart -EOF ---enable_reconnect ---source include/wait_until_connected_again.inc ---disable_reconnect - -show variables like 'innodb_buffer_pool_shm%'; ---sleep 1 ---system ipcrm -M 123456 diff --git a/mysql-test/suite/percona/percona_innodb_deadlock_count.result b/mysql-test/suite/percona/percona_innodb_deadlock_count.result index 4ad6fd433fe..00902e87feb 100644 --- a/mysql-test/suite/percona/percona_innodb_deadlock_count.result +++ b/mysql-test/suite/percona/percona_innodb_deadlock_count.result @@ -11,18 +11,18 @@ insert into t values(1,2); # Switch to connection con1 BEGIN; SELECT b FROM t WHERE a=1 FOR UPDATE; -b -2 # Switch to connection con2 BEGIN; SELECT b FROM t WHERE a=2 FOR UPDATE; -b -1 # Switch to connection con1 SELECT b FROM t WHERE a=2 FOR UPDATE; # Switch to connection con2 SELECT b FROM t WHERE a=1 FOR UPDATE; +# Switch to connection con1 +ROLLBACK; +# Switch to connection con2 +ROLLBACK; # Switch to connection con3 -1 +Deadlocks: 1 # Drop test table drop table t; diff --git a/mysql-test/suite/percona/percona_innodb_deadlock_count.test b/mysql-test/suite/percona/percona_innodb_deadlock_count.test index 7a7f0e5ddb7..f953b9d7822 100644 --- a/mysql-test/suite/percona/percona_innodb_deadlock_count.test +++ b/mysql-test/suite/percona/percona_innodb_deadlock_count.test @@ -9,7 +9,6 @@ connect (con3,localhost,root,,); --disable_warnings drop table if exists t; --enable_warnings -disable_abort_on_error; --echo # Create test table create table t(a INT PRIMARY KEY, b INT) engine=InnoDB; @@ -20,12 +19,12 @@ insert into t values(1,2); #--echo # Save current deadlock count let $current = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_deadlocks'`; +--disable_result_log + --echo # Switch to connection con1 connection con1; BEGIN; SELECT b FROM t WHERE a=1 FOR UPDATE; -#show engine innodb status; - --echo # Switch to connection con2 connection con2; BEGIN; SELECT b FROM t WHERE a=2 FOR UPDATE; @@ -38,12 +37,25 @@ SEND SELECT b FROM t WHERE a=2 FOR UPDATE; connection con2; SEND SELECT b FROM t WHERE a=1 FOR UPDATE; -SLEEP 0.2; +--echo # Switch to connection con1 +connection con1; +--error 0, ER_LOCK_DEADLOCK +reap; +ROLLBACK; + +--echo # Switch to connection con2 +connection con2; +--error 0, ER_LOCK_DEADLOCK +reap; +ROLLBACK; + --echo # Switch to connection con3 connection con3; let $result = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_deadlocks'`; +--enable_result_log + let $diff = `SELECT $result - $current`; -echo $diff; +echo Deadlocks: $diff; --echo # Drop test table drop table t; diff --git a/mysql-test/suite/percona/percona_log_connection_error-master.opt b/mysql-test/suite/percona/percona_log_connection_error-master.opt index 32a891789f3..4658d62af60 100644 --- a/mysql-test/suite/percona/percona_log_connection_error-master.opt +++ b/mysql-test/suite/percona/percona_log_connection_error-master.opt @@ -1 +1 @@ ---log-error \ No newline at end of file +--log-error diff --git a/mysql-test/suite/percona/percona_log_connection_error.test b/mysql-test/suite/percona/percona_log_connection_error.test index 57cd652bd24..677da047354 100644 --- a/mysql-test/suite/percona/percona_log_connection_error.test +++ b/mysql-test/suite/percona/percona_log_connection_error.test @@ -48,5 +48,7 @@ if(!`select LENGTH('$log_error_')`) # Assign env variable LOG_ERROR let LOG_ERROR=$log_error_; -let cmd=cat $log_error | grep "Too many connections" | wc -l; +--let grep_file = $log_error +--let grep_pattern = Too many connections +--source grep.inc exec $cmd; diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test b/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test deleted file mode 100644 index 8d4bb1e091c..00000000000 --- a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.test +++ /dev/null @@ -1,141 +0,0 @@ --- source include/not_windows.inc - --- echo # Activate master-slave replication --- source include/master-slave.inc - -connection master; --- echo # Make table t for test --- disable_warnings -DROP TABLE IF EXISTS t; --- enable_warnings -CREATE TABLE t(id INT); - - --- echo # Start slave replication --- disable_warnings -connection slave; -START SLAVE; --- source include/wait_for_slave_to_start.inc --- enable_warnings - -#-- echo # Make insert(1) on master -connection master; -INSERT INTO t VALUES (1); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync(1) slave thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; - --- echo # Read and change log_slow_slave_statements to ON on slave -show variables like 'log_slow_slave_statements'; -set global log_slow_slave_statements=ON; -show variables like 'log_slow_slave_statements'; - -#-- echo # Make insert(2) on master -connection master; -INSERT INTO t VALUES (2); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync slave(2) thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; --- echo # Restart slave -STOP SLAVE; --- source include/wait_for_slave_to_stop.inc -START SLAVE; --- source include/wait_for_slave_to_start.inc - -#-- echo # Make insert(3) on master -connection master; -INSERT INTO t VALUES (3); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync(3) slave thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; -show variables like 'long_query_time'; -show global variables like 'long_query_time'; -show global variables like 'use_global_long_query_time'; -set global long_query_time=0; -show variables like 'long_query_time'; -show global variables like 'long_query_time'; -show global variables like 'use_global_long_query_time'; - -#-- echo # Make insert(4) on master -connection master; -INSERT INTO t VALUES (4); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync slave(4) thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; -show variables like 'long_query_time'; -show global variables like 'long_query_time'; -show global variables like 'use_global_long_query_time'; -set global use_global_long_query_time=1; -show variables like 'long_query_time'; -show global variables like 'long_query_time'; -show global variables like 'use_global_long_query_time'; - -#-- echo # Make insert(5) on master -connection master; -let $MASTER_DATADIR= `select @@datadir`; -INSERT INTO t VALUES (5); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync slave(5) thread -connection slave; -let $SLAVE_DATADIR= `select @@datadir`; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; -show variables like 'long_query_time'; -show global variables like 'long_query_time'; -show global variables like 'use_global_long_query_time'; -set global long_query_time=1; -set global use_global_long_query_time=0; - --- echo # Analyse master slow_query_log -let $i=5; -let $k=1; -let $cmd=cat ./$MASTER_DATADIR/percona_log_slow_slave_statements-master.log | grep; -while($i) -{ - let $current_cmd = $cmd "INSERT INTO t VALUES ($k)" | wc -l; - exec $current_cmd; - dec $i; - inc $k; -} - --- echo # Analyse slave slow_query_log -let $i=5; -let $k=1; -let $cmd=cat $SLAVE_DATADIR/percona_log_slow_slave_statements-slave.log | grep; -while($i) -{ - let $current_cmd = $cmd "INSERT INTO t VALUES ($k)" | wc -l; - exec $current_cmd; - dec $i; - inc $k; -} -set global log_slow_slave_statements=OFF; - -connection master; -DROP TABLE t; - --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync slave(6) thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements.result b/mysql-test/suite/percona/percona_log_slow_slave_statements.result deleted file mode 100644 index e3bf3e92c94..00000000000 --- a/mysql-test/suite/percona/percona_log_slow_slave_statements.result +++ /dev/null @@ -1,86 +0,0 @@ -# Activate master-slave replication -stop slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -reset master; -reset slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -start slave; -# Make table t for test -DROP TABLE IF EXISTS t; -CREATE TABLE t(id INT); -# Start slave replication -START SLAVE; -INSERT INTO t VALUES (1); -# Read information about master binlog -# Sync(1) slave thread -# Read and change log_slow_slave_statements to ON on slave -show variables like 'log_slow_slave_statements'; -Variable_name Value -log_slow_slave_statements OFF -set global log_slow_slave_statements=ON; -show variables like 'log_slow_slave_statements'; -Variable_name Value -log_slow_slave_statements ON -INSERT INTO t VALUES (2); -# Read information about master binlog -# Sync slave(2) thread -# Restart slave -STOP SLAVE; -START SLAVE; -INSERT INTO t VALUES (3); -# Read information about master binlog -# Sync(3) slave thread -# Read and change log_slow_slave_statements to OFF on slave -show variables like 'log_slow_slave_statements'; -Variable_name Value -log_slow_slave_statements ON -set global log_slow_slave_statements=OFF; -show variables like 'log_slow_slave_statements'; -Variable_name Value -log_slow_slave_statements OFF -INSERT INTO t VALUES (4); -# Read information about master binlog -# Sync slave(4) thread -# Restart slave -STOP SLAVE; -START SLAVE; -INSERT INTO t VALUES (5); -# Read information about master binlog -# Sync slave(5) thread -# Read and change log_slow_slave_statements to ON on slave -show variables like 'log_slow_slave_statements'; -Variable_name Value -log_slow_slave_statements OFF -set global log_slow_slave_statements=ON; -show variables like 'log_slow_slave_statements'; -Variable_name Value -log_slow_slave_statements ON -INSERT INTO t VALUES (6); -# Read information about master binlog -# Sync slave(6) thread -# Restart slave -STOP SLAVE; -START SLAVE; -INSERT INTO t VALUES (7); -# Read information about master binlog -# Sync slave(7) thread -# Analyse master slow_query_log -1 -1 -1 -1 -1 -1 -1 -# Analyse slave slow_query_log -0 -0 -1 -0 -0 -0 -1 -set global log_slow_slave_statements=OFF; -DROP TABLE t; -# Read information about master binlog -# Sync slave(8) thread diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements.test b/mysql-test/suite/percona/percona_log_slow_slave_statements.test deleted file mode 100644 index 8c9c594e41c..00000000000 --- a/mysql-test/suite/percona/percona_log_slow_slave_statements.test +++ /dev/null @@ -1,162 +0,0 @@ --- source include/not_windows.inc - --- echo # Activate master-slave replication --- source include/master-slave.inc - -connection master; --- echo # Make table t for test --- disable_warnings -DROP TABLE IF EXISTS t; --- enable_warnings -CREATE TABLE t(id INT); - - --- echo # Start slave replication --- disable_warnings -connection slave; -START SLAVE; --- source include/wait_for_slave_to_start.inc --- enable_warnings - -#-- echo # Make insert(1) on master -connection master; -INSERT INTO t VALUES (1); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync(1) slave thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; - --- echo # Read and change log_slow_slave_statements to ON on slave -show variables like 'log_slow_slave_statements'; -set global log_slow_slave_statements=ON; -show variables like 'log_slow_slave_statements'; - -#-- echo # Make insert(2) on master -connection master; -INSERT INTO t VALUES (2); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync slave(2) thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; --- echo # Restart slave -STOP SLAVE; --- source include/wait_for_slave_to_stop.inc -START SLAVE; --- source include/wait_for_slave_to_start.inc - -#-- echo # Make insert(3) on master -connection master; -INSERT INTO t VALUES (3); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync(3) slave thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; --- echo # Read and change log_slow_slave_statements to OFF on slave -show variables like 'log_slow_slave_statements'; -set global log_slow_slave_statements=OFF; -show variables like 'log_slow_slave_statements'; - -#-- echo # Make insert(4) on master -connection master; -INSERT INTO t VALUES (4); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync slave(4) thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; --- echo # Restart slave -STOP SLAVE; --- source include/wait_for_slave_to_stop.inc -START SLAVE; --- source include/wait_for_slave_to_start.inc - -#-- echo # Make insert(5) on master -connection master; -INSERT INTO t VALUES (5); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync slave(5) thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; --- echo # Read and change log_slow_slave_statements to ON on slave -show variables like 'log_slow_slave_statements'; -set global log_slow_slave_statements=ON; -show variables like 'log_slow_slave_statements'; - -#-- echo # Make insert(6) on master -connection master; -INSERT INTO t VALUES (6); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync slave(6) thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; --- echo # Restart slave -STOP SLAVE; --- source include/wait_for_slave_to_stop.inc -START SLAVE; --- source include/wait_for_slave_to_start.inc - -#-- echo # Make insert(7) on master -connection master; -let $MASTER_DATADIR= `select @@datadir`; -INSERT INTO t VALUES (7); --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync slave(7) thread -connection slave; -let $SLAVE_DATADIR= `select @@datadir`; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; - --- echo # Analyse master slow_query_log -let $i=7; -let $k=1; -let $cmd=cat $MASTER_DATADIR/percona_log_slow_slave_statements-master.log | grep -c; -while($i) -{ - let $current_cmd = $cmd "INSERT INTO t VALUES ($k)"; - exec $current_cmd; - dec $i; - inc $k; -} - --- echo # Analyse slave slow_query_log -let $i=7; -let $k=1; -let $cmd=cat $SLAVE_DATADIR/percona_log_slow_slave_statements-slave.log | grep -c; -while($i) -{ - let $current_cmd = $cmd "INSERT INTO t VALUES ($k)"; - exec $current_cmd; - dec $i; - inc $k; -} -set global log_slow_slave_statements=OFF; - -connection master; -DROP TABLE t; - --- echo # Read information about master binlog -let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1); -let $binlog_position = query_get_value(SHOW MASTER STATUS,Position,1); - --- echo # Sync slave(8) thread -connection slave; -let $sync_result = `SELECT MASTER_POS_WAIT('$binlog_file',$binlog_position)`; diff --git a/mysql-test/suite/percona/percona_suppress_log_warning_1592-master.opt b/mysql-test/suite/percona/percona_log_warnings_suppress-master.opt similarity index 100% rename from mysql-test/suite/percona/percona_suppress_log_warning_1592-master.opt rename to mysql-test/suite/percona/percona_log_warnings_suppress-master.opt diff --git a/mysql-test/suite/percona/percona_log_warnings_suppress.result b/mysql-test/suite/percona/percona_log_warnings_suppress.result new file mode 100644 index 00000000000..1ee6c46738a --- /dev/null +++ b/mysql-test/suite/percona/percona_log_warnings_suppress.result @@ -0,0 +1,31 @@ +SET @old_log_warnings = @@log_warnings; +SET @old_log_warnings_suppress = @@log_warnings_suppress; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(20)); +SET GLOBAL log_warnings_suppress=''; +SET GLOBAL LOG_WARNINGS=0; +SHOW GLOBAL VARIABLES LIKE 'log_warnings_suppress'; +Variable_name Value +log_warnings_suppress +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +SET GLOBAL LOG_WARNINGS=1; +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +SET GLOBAL log_warnings_suppress='1592'; +SET GLOBAL LOG_WARNINGS=0; +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +SET GLOBAL LOG_WARNINGS=1; +INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +DROP TABLE t1; +SET GLOBAL log_warnings = @old_log_warnings; +SET GLOBAL log_warnings_suppress = @old_log_warnings_suppress; +# Count the number of times the "Unsafe" message was printed +# to the error log. +Occurrences: 1 diff --git a/mysql-test/suite/percona/percona_suppress_log_warning_1592.test b/mysql-test/suite/percona/percona_log_warnings_suppress.test similarity index 76% rename from mysql-test/suite/percona/percona_suppress_log_warning_1592.test rename to mysql-test/suite/percona/percona_log_warnings_suppress.test index 97fe40469fc..82221013f0b 100644 --- a/mysql-test/suite/percona/percona_suppress_log_warning_1592.test +++ b/mysql-test/suite/percona/percona_log_warnings_suppress.test @@ -2,26 +2,27 @@ -- source include/have_binlog_format_statement.inc SET @old_log_warnings = @@log_warnings; -SET @old_suppress_log_warning_1592 = @@suppress_log_warning_1592; +SET @old_log_warnings_suppress = @@log_warnings_suppress; --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(20)); -SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 0; -SET GLOBAL LOG_WARNINGS = 0; +SET GLOBAL log_warnings_suppress=''; +SET GLOBAL LOG_WARNINGS=0; +SHOW GLOBAL VARIABLES LIKE 'log_warnings_suppress'; INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); -SET GLOBAL LOG_WARNINGS = 1; +SET GLOBAL LOG_WARNINGS=1; INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); -SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 1; -SET GLOBAL LOG_WARNINGS = 0; +SET GLOBAL log_warnings_suppress='1592'; +SET GLOBAL LOG_WARNINGS=0; INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); -SET GLOBAL LOG_WARNINGS = 1; +SET GLOBAL LOG_WARNINGS=1; INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); DROP TABLE t1; SET GLOBAL log_warnings = @old_log_warnings; -SET GLOBAL suppress_log_warning_1592 = @old_suppress_log_warning_1592; +SET GLOBAL log_warnings_suppress = @old_log_warnings_suppress; let $log_error_= `SELECT @@GLOBAL.log_error`; if(!`select LENGTH('$log_error_')`) diff --git a/mysql-test/suite/percona/percona_processlist_row_stats.result b/mysql-test/suite/percona/percona_processlist_row_stats.result new file mode 100644 index 00000000000..e9b07b2eaea --- /dev/null +++ b/mysql-test/suite/percona/percona_processlist_row_stats.result @@ -0,0 +1,74 @@ +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES(10); +INSERT INTO t2 VALUES(10); +INSERT INTO t2 VALUES(20); +INSERT INTO t2 VALUES(10); +INSERT INTO t2 VALUES(20); +Issuing operation that should not return any rows and stopping the thread #1 +SET DEBUG_SYNC= 'locked_table_name SIGNAL thread1_ready WAIT_FOR threads_dumped'; +CREATE TABLE t1 (a INT); +SET DEBUG_SYNC= 'now WAIT_FOR thread1_ready'; +Thread #1 stopped +Issuing row-returning query and stopping the thread #2 at the end of query +SET DEBUG_SYNC= 'execute_command_after_close_tables SIGNAL thread2_ready WAIT_FOR threads_dumped'; +SELECT a FROM t2 WHERE a > 15; +SET DEBUG_SYNC= 'now WAIT_FOR thread2_ready'; +Thread #2 stopped +Look at thread states +SHOW PROCESSLIST; +Id User Host db Command Time State Info Rows_sent Rows_examined Rows_read +### root ### test Query ### ### SHOW PROCESSLIST 0 0 2 +### root ### test Query ### ### CREATE TABLE t1 (a INT) 0 0 1 +### root ### test Query ### ### SELECT a FROM t2 WHERE a > 15 2 5 6 +SELECT id, info, rows_sent, rows_examined, rows_read FROM information_schema.processlist +ORDER BY id; +id info rows_sent rows_examined rows_read +### SELECT id, info, rows_sent, rows_examined, rows_read FROM information_schema.processlist +ORDER BY id 0 0 1 +### CREATE TABLE t1 (a INT) 0 0 1 +### SELECT a FROM t2 WHERE a > 15 2 5 6 +Let threads #1 and #2 finish their job +SET DEBUG_SYNC= 'now SIGNAL threads_dumped'; +a +20 +20 +Issuing row-returning query and stopping the thread #2 in the middle of query +SET DEBUG_SYNC= 'sent_row SIGNAL thread2_ready WAIT_FOR threads_dumped'; +SELECT a FROM t2 WHERE a > 15; +SET DEBUG_SYNC= 'now WAIT_FOR thread2_ready'; +Thread #2 stopped, look at its state +SHOW PROCESSLIST; +Id User Host db Command Time State Info Rows_sent Rows_examined Rows_read +### root ### test Query ### ### SHOW PROCESSLIST 0 0 4 +### root ### test Sleep ### ### NULL 0 0 1 +### root ### test Query ### ### SELECT a FROM t2 WHERE a > 15 1 0 3 +SELECT id,rows_sent,rows_examined,rows_read FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY Id; +id rows_sent rows_examined rows_read +### 0 0 1 +### 0 0 1 +### 1 0 3 +SET DEBUG_SYNC= 'now SIGNAL threads_dumped'; +Let thread #2 finish its job +a +20 +20 +Issuing an UPDATE and stopping thread #2 +SET DEBUG_SYNC= 'execute_command_after_close_tables SIGNAL thread2_ready WAIT_FOR threads_dumped'; +UPDATE t2 SET a = 15 WHERE a = 10; +SET DEBUG_SYNC= 'now WAIT_FOR thread2_ready'; +Thread #2 stopped, look at its state +SHOW PROCESSLIST; +Id User Host db Command Time State Info Rows_sent Rows_examined Rows_read +### root ### test Query ### ### SHOW PROCESSLIST 0 0 4 +### root ### test Sleep ### ### NULL 0 0 1 +### root ### test Query ### ### UPDATE t2 SET a = 15 WHERE a = 10 0 5 6 +SELECT id,rows_sent,rows_examined,rows_read FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY Id; +id rows_sent rows_examined rows_read +### 0 0 1 +### 0 0 1 +### 0 5 6 +SET DEBUG_SYNC= 'now SIGNAL threads_dumped'; +Let thread #2 finish its job +DROP TABLES t1, t2; diff --git a/mysql-test/suite/percona/percona_processlist_row_stats.test b/mysql-test/suite/percona/percona_processlist_row_stats.test new file mode 100644 index 00000000000..230a9f4c311 --- /dev/null +++ b/mysql-test/suite/percona/percona_processlist_row_stats.test @@ -0,0 +1,92 @@ +# Testing of INFORMATION_SCHEMA.PROCESSLIST fields ROWS_SENT, ROWS_EXAMINED, ROWS_READ +--source include/have_debug_sync.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t2; +--enable_warnings + +CREATE TABLE t2 (a INT); +INSERT INTO t2 VALUES(10); +INSERT INTO t2 VALUES(10); +INSERT INTO t2 VALUES(20); +INSERT INTO t2 VALUES(10); +INSERT INTO t2 VALUES(20); + +connect (conn1, localhost, root, ,); +connect (conn2, localhost, root, ,); + +--connection conn1 +echo Issuing operation that should not return any rows and stopping the thread #1; +SET DEBUG_SYNC= 'locked_table_name SIGNAL thread1_ready WAIT_FOR threads_dumped'; +send CREATE TABLE t1 (a INT); + +--connection default +SET DEBUG_SYNC= 'now WAIT_FOR thread1_ready'; +--echo Thread #1 stopped + +--connection conn2 +echo Issuing row-returning query and stopping the thread #2 at the end of query; +SET DEBUG_SYNC= 'execute_command_after_close_tables SIGNAL thread2_ready WAIT_FOR threads_dumped'; +send SELECT a FROM t2 WHERE a > 15; + +--connection default +SET DEBUG_SYNC= 'now WAIT_FOR thread2_ready'; +--echo Thread #2 stopped +--echo Look at thread states + +--replace_column 1 ### 3 ### 6 ### 7 ### +SHOW PROCESSLIST; +# The running threads are different between SHOW above and SELECT below. Thus select info too to +# show the difference. Results are in the same order as in SHOW. +--replace_column 1 ### +SELECT id, info, rows_sent, rows_examined, rows_read FROM information_schema.processlist +ORDER BY id; + +echo Let threads #1 and #2 finish their job; +SET DEBUG_SYNC= 'now SIGNAL threads_dumped'; + +--connection conn1 +reap; + +--connection conn2 +reap; +echo Issuing row-returning query and stopping the thread #2 in the middle of query; +SET DEBUG_SYNC= 'sent_row SIGNAL thread2_ready WAIT_FOR threads_dumped'; +send SELECT a FROM t2 WHERE a > 15; + +--connection default +SET DEBUG_SYNC= 'now WAIT_FOR thread2_ready'; +echo Thread #2 stopped, look at its state; + +--replace_column 1 ### 3 ### 6 ### 7 ### +SHOW PROCESSLIST; +--replace_column 1 ### +SELECT id,rows_sent,rows_examined,rows_read FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY Id; +SET DEBUG_SYNC= 'now SIGNAL threads_dumped'; +echo Let thread #2 finish its job; + +--connection conn2 +reap; +echo Issuing an UPDATE and stopping thread #2; +SET DEBUG_SYNC= 'execute_command_after_close_tables SIGNAL thread2_ready WAIT_FOR threads_dumped'; +send UPDATE t2 SET a = 15 WHERE a = 10; + +--connection default +SET DEBUG_SYNC= 'now WAIT_FOR thread2_ready'; +echo Thread #2 stopped, look at its state; + +--replace_column 1 ### 3 ### 6 ### 7 ### +SHOW PROCESSLIST; +--replace_column 1 ### +SELECT id,rows_sent,rows_examined,rows_read FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY Id; +SET DEBUG_SYNC= 'now SIGNAL threads_dumped'; +echo Let thread #2 finish its job; + +--connection conn2 +reap; + +--connection default +disconnect conn1; +disconnect conn2; +DROP TABLES t1, t2; diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments.inc b/mysql-test/suite/percona/percona_query_cache_with_comments.inc new file mode 100644 index 00000000000..d55e52d5b64 --- /dev/null +++ b/mysql-test/suite/percona/percona_query_cache_with_comments.inc @@ -0,0 +1,95 @@ +--source percona_query_cache_with_comments_clear.inc +let $query=/* with comment first */select * from t1; +eval $query; +--source percona_query_cache_with_comments_eval.inc + +let $query=# with comment first +select * from t1; +--source percona_query_cache_with_comments_eval.inc + +let $query=-- with comment first +select * from t1; +--source percona_query_cache_with_comments_eval.inc + +let $query=/* with comment first and "quote" */select * from t1; +--source percona_query_cache_with_comments_eval.inc + +let $query=# with comment first and "quote" +select * from t1; +--source percona_query_cache_with_comments_eval.inc + +let $query=-- with comment first and "quote" +select * from t1; +--source percona_query_cache_with_comments_eval.inc + +let $query= + /* with comment and whitespaces first */select * from t1; +--source percona_query_cache_with_comments_eval.inc + +let $query= + # with comment and whitespaces first +select * from t1; +--source percona_query_cache_with_comments_eval.inc + +let $query= + -- with comment and whitespaces first +select * from t1; +--source percona_query_cache_with_comments_eval.inc + +let $internal=* internal comment *; + +let $query=select * /$internal/ from t1; +--source percona_query_cache_with_comments_eval.inc +let $query=select */$internal/ from t1; +--source percona_query_cache_with_comments_eval.inc +let $query=select */$internal/from t1; +--source percona_query_cache_with_comments_eval.inc + +let $internal=* internal comment with "quote" *; + +let $query=select * /$internal/ from t1; +--source percona_query_cache_with_comments_eval.inc +let $query=select */$internal/ from t1; +--source percona_query_cache_with_comments_eval.inc +let $query=select */$internal/from t1; +--source percona_query_cache_with_comments_eval.inc + +let $query=select * from t1 +; +--source percona_query_cache_with_comments_eval.inc + +let $query=select * from t1 ; +--source percona_query_cache_with_comments_eval.inc + +let $query=select * from t1 ; +--source percona_query_cache_with_comments_eval.inc + +let $query=select * from t1 +/* comment in the end */; +--source percona_query_cache_with_comments_eval.inc + +let $query=select * from t1 +/* *\/ */; +--source percona_query_cache_with_comments_eval.inc + +let $query=select * from t1 +/* comment in the end */ +; +--source percona_query_cache_with_comments_eval.inc + +let $query=select * from t1 #comment in the end; +--source percona_query_cache_with_comments_eval.inc + +let $query=select * from t1 #comment in the end +; +--source percona_query_cache_with_comments_eval.inc + +let $query=select * from t1 -- comment in the end; +--source percona_query_cache_with_comments_eval.inc + +let $query=select * from t1 -- comment in the end +; +--source percona_query_cache_with_comments_eval.inc + +let $query=select ' \' ' from t1; +--source percona_query_cache_with_comments_eval.inc diff --git a/mysql-test/suite/percona/percona_query_cache_with_comments.test b/mysql-test/suite/percona/percona_query_cache_with_comments.test index 0190f54d104..0b93441f364 100644 --- a/mysql-test/suite/percona/percona_query_cache_with_comments.test +++ b/mysql-test/suite/percona/percona_query_cache_with_comments.test @@ -1,3 +1,4 @@ +--disable_ps_protocol set global query_cache_strip_comments=ON; -- source include/percona_query_cache_with_comments_begin.inc -- source include/percona_query_cache_with_comments.inc diff --git a/mysql-test/include/percona_query_cache_with_comments_begin.inc b/mysql-test/suite/percona/percona_query_cache_with_comments_begin.inc similarity index 77% rename from mysql-test/include/percona_query_cache_with_comments_begin.inc rename to mysql-test/suite/percona/percona_query_cache_with_comments_begin.inc index 38bfce20263..6bfd2bfbc83 100644 --- a/mysql-test/include/percona_query_cache_with_comments_begin.inc +++ b/mysql-test/suite/percona/percona_query_cache_with_comments_begin.inc @@ -9,4 +9,4 @@ drop table if exists t1; create table t1 (a int not null); insert into t1 values (1),(2),(3); ---source include/percona_query_cache_with_comments_clear.inc +--source percona_query_cache_with_comments_clear.inc diff --git a/mysql-test/include/percona_query_cache_with_comments_clear.inc b/mysql-test/suite/percona/percona_query_cache_with_comments_clear.inc similarity index 100% rename from mysql-test/include/percona_query_cache_with_comments_clear.inc rename to mysql-test/suite/percona/percona_query_cache_with_comments_clear.inc diff --git a/mysql-test/include/percona_query_cache_with_comments_end.inc b/mysql-test/suite/percona/percona_query_cache_with_comments_end.inc similarity index 100% rename from mysql-test/include/percona_query_cache_with_comments_end.inc rename to mysql-test/suite/percona/percona_query_cache_with_comments_end.inc diff --git a/mysql-test/include/percona_query_cache_with_comments_eval.inc b/mysql-test/suite/percona/percona_query_cache_with_comments_eval.inc similarity index 56% rename from mysql-test/include/percona_query_cache_with_comments_eval.inc rename to mysql-test/suite/percona/percona_query_cache_with_comments_eval.inc index a409786d554..f0c200245e0 100644 --- a/mysql-test/include/percona_query_cache_with_comments_eval.inc +++ b/mysql-test/suite/percona/percona_query_cache_with_comments_eval.inc @@ -1,7 +1,7 @@ echo -----------------------------------------------------; echo $query; echo -----------------------------------------------------; ---source include/percona_query_cache_with_comments_show.inc +--source percona_query_cache_with_comments_show.inc eval $query; eval $query; ---source include/percona_query_cache_with_comments_show.inc +--source percona_query_cache_with_comments_show.inc diff --git a/mysql-test/include/percona_query_cache_with_comments_show.inc b/mysql-test/suite/percona/percona_query_cache_with_comments_show.inc similarity index 100% rename from mysql-test/include/percona_query_cache_with_comments_show.inc rename to mysql-test/suite/percona/percona_query_cache_with_comments_show.inc diff --git a/mysql-test/suite/percona/percona_query_response_time-replication.result b/mysql-test/suite/percona/percona_query_response_time-replication.result index df5c73812df..fd06d07b4d8 100644 --- a/mysql-test/suite/percona/percona_query_response_time-replication.result +++ b/mysql-test/suite/percona/percona_query_response_time-replication.result @@ -1,9 +1,5 @@ -stop slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -reset master; -reset slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -start slave; +include/master-slave.inc +[connection master] DROP TABLE IF EXISTS t; CREATE TABLE t(id INT); SELECT * from t; @@ -21,12 +17,16 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 10 FLUSH QUERY_RESPONSE_TIME; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=ON; -INSERT INTO t VALUES(0); +SET GLOBAL QUERY_RESPONSE_TIME_STATS=ON; +INSERT INTO t SELECT SLEEP(0.4); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) 0 -INSERT INTO t VALUES(1); +INSERT INTO t SELECT SLEEP(0.4); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) 0 @@ -41,11 +41,15 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 2 FLUSH QUERY_RESPONSE_TIME; -INSERT INTO t VALUES(0); +INSERT INTO t SELECT SLEEP(0.4); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) 0 -INSERT INTO t VALUES(1); +INSERT INTO t SELECT SLEEP(0.4); +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) 0 @@ -57,4 +61,6 @@ SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) 3 DROP TABLE IF EXISTS t; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=OFF; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=OFF; +STOP SLAVE; +include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/percona/percona_query_response_time-replication.test b/mysql-test/suite/percona/percona_query_response_time-replication.test index 4f674c2fd19..199ecce0977 100644 --- a/mysql-test/suite/percona/percona_query_response_time-replication.test +++ b/mysql-test/suite/percona/percona_query_response_time-replication.test @@ -1,4 +1,10 @@ +--source include/have_response_time_distribution.inc --source include/master-slave.inc +--source include/have_binlog_format_statement.inc +--source include/have_debug.inc +--disable_query_log +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement:"); +--enable_query_log connection master; -- disable_warnings @@ -16,12 +22,12 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=ON; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=ON; connection master; -INSERT INTO t VALUES(0); +INSERT INTO t SELECT SLEEP(0.4); SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; -INSERT INTO t VALUES(1); +INSERT INTO t SELECT SLEEP(0.4); SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; sync_slave_with_master; @@ -34,9 +40,9 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; connection master; -INSERT INTO t VALUES(0); +INSERT INTO t SELECT SLEEP(0.4); SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; -INSERT INTO t VALUES(1); +INSERT INTO t SELECT SLEEP(0.4); SELECT SUM(INFORMATION_SCHEMA.QUERY_RESPONSE_TIME.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; sync_slave_with_master; @@ -49,4 +55,7 @@ DROP TABLE IF EXISTS t; sync_slave_with_master; connection slave; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=OFF; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=OFF; + +STOP SLAVE; +-- source include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/percona/percona_query_response_time-stored.result b/mysql-test/suite/percona/percona_query_response_time-stored.result index df51f2bfd58..0168c4630be 100644 --- a/mysql-test/suite/percona/percona_query_response_time-stored.result +++ b/mysql-test/suite/percona/percona_query_response_time-stored.result @@ -1,15 +1,9 @@ +SET GLOBAL debug="d,query_exec_time_debug"; CREATE FUNCTION test_f() RETURNS CHAR(30) DETERMINISTIC BEGIN -DECLARE first VARCHAR(5); -DECLARE second VARCHAR(5); -DECLARE result VARCHAR(20); -SELECT SLEEP(1.11) INTO first; -SET first= 'Hello'; -SET second=', '; -SET result= CONCAT(first,second); -SET result= CONCAT(result,'world!'); -RETURN result; +SET SESSION debug="+d,query_exec_time_1.1"; +RETURN 'Hello, world!'; END/ SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1; Warnings: @@ -78,7 +72,7 @@ time 4194304.00000 8388608.00000 TOO LONG -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; SELECT test_f(); test_f() Hello, world! @@ -91,7 +85,7 @@ Hello, world! SELECT test_f(); test_f() Hello, world! -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SELECT d.count, (SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, (SELECT SUM((b.total * 1000000) DIV 1000000) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as query_total, @@ -99,8 +93,7 @@ SELECT d.count, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as d WHERE d.count > 0; count query_count query_total not_zero_region_count region_count -1 5 4 2 44 -4 5 4 2 44 +4 4 4 1 44 SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; region_count 44 @@ -158,11 +151,11 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 10 FLUSH QUERY_RESPONSE_TIME; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; SELECT test_f(); test_f() Hello, world! -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SELECT d.count, (SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, (SELECT SUM((b.total * 1000000) DIV 1000000) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as query_total, @@ -170,8 +163,7 @@ SELECT d.count, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as d WHERE d.count > 0; count query_count query_total not_zero_region_count region_count -1 2 1 2 14 -1 2 1 2 14 +1 1 1 1 14 SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; region_count 14 @@ -199,11 +191,11 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 7 FLUSH QUERY_RESPONSE_TIME; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; SELECT test_f(); test_f() Hello, world! -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SELECT d.count, (SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, (SELECT SUM((b.total * 1000000) DIV 1000000) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as query_total, @@ -211,8 +203,7 @@ SELECT d.count, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as d WHERE d.count > 0; count query_count query_total not_zero_region_count region_count -1 2 1 2 17 -1 2 1 2 17 +1 1 1 1 17 SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; region_count 17 @@ -243,11 +234,11 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 156 FLUSH QUERY_RESPONSE_TIME; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; SELECT test_f(); test_f() Hello, world! -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SELECT d.count, (SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, (SELECT SUM((b.total * 1000000) DIV 1000000) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as query_total, @@ -255,8 +246,7 @@ SELECT d.count, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as d WHERE d.count > 0; count query_count query_total not_zero_region_count region_count -1 2 1 2 7 -1 2 1 2 7 +1 1 1 1 7 SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; region_count 7 @@ -277,11 +267,11 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 1000 FLUSH QUERY_RESPONSE_TIME; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; SELECT test_f(); test_f() Hello, world! -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SELECT d.count, (SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, (SELECT SUM((b.total * 1000000) DIV 1000000) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as query_total, @@ -289,8 +279,7 @@ SELECT d.count, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as d WHERE d.count > 0; count query_count query_total not_zero_region_count region_count -1 2 1 2 6 -1 2 1 2 6 +1 1 1 1 6 SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; region_count 6 @@ -311,6 +300,7 @@ Warning 1292 Truncated incorrect query_response_time_range_base value: '1001' SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 1000 -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE =10; DROP FUNCTION test_f; +SET GLOBAL debug=default; diff --git a/mysql-test/suite/percona/percona_query_response_time-stored.test b/mysql-test/suite/percona/percona_query_response_time-stored.test index f761dd7d01c..e80fc3dd3c0 100644 --- a/mysql-test/suite/percona/percona_query_response_time-stored.test +++ b/mysql-test/suite/percona/percona_query_response_time-stored.test @@ -1,18 +1,14 @@ -source include/have_innodb.inc; +--source include/have_response_time_distribution.inc +--source include/have_debug.inc + +SET GLOBAL debug="d,query_exec_time_debug"; delimiter /; CREATE FUNCTION test_f() RETURNS CHAR(30) DETERMINISTIC BEGIN - DECLARE first VARCHAR(5); - DECLARE second VARCHAR(5); - DECLARE result VARCHAR(20); - SELECT SLEEP(1.11) INTO first; - SET first= 'Hello'; - SET second=', '; - SET result= CONCAT(first,second); - SET result= CONCAT(result,'world!'); - RETURN result; + SET SESSION debug="+d,query_exec_time_1.1"; + RETURN 'Hello, world!'; END/ delimiter ;/ @@ -24,12 +20,12 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; source include/percona_query_response_time_show.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; SELECT test_f(); SELECT test_f(); SELECT test_f(); SELECT test_f(); -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; source include/percona_query_response_time_show.inc; @@ -38,9 +34,9 @@ SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; SELECT test_f(); -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; source include/percona_query_response_time_show.inc; @@ -49,9 +45,9 @@ SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 7; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; SELECT test_f(); -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; source include/percona_query_response_time_show.inc; @@ -60,9 +56,9 @@ SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 156; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; SELECT test_f(); -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; source include/percona_query_response_time_show.inc; @@ -71,9 +67,9 @@ SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1000; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; SELECT test_f(); -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; source include/percona_query_response_time_show.inc; @@ -81,7 +77,9 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1001; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE =10; -DROP FUNCTION test_f; \ No newline at end of file +DROP FUNCTION test_f; + +SET GLOBAL debug=default; diff --git a/mysql-test/suite/percona/percona_query_response_time.result b/mysql-test/suite/percona/percona_query_response_time.result index 54657b6ca06..2243c155e39 100644 --- a/mysql-test/suite/percona/percona_query_response_time.result +++ b/mysql-test/suite/percona/percona_query_response_time.result @@ -1,3 +1,4 @@ +SET GLOBAL debug="d,query_exec_time_debug"; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1; Warnings: Warning 1292 Truncated incorrect query_response_time_range_base value: '1' @@ -65,65 +66,27 @@ time 4194304.00000 8388608.00000 TOO LONG -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; -SELECT SLEEP(0.31); -SLEEP(0.31) -0 -SELECT SLEEP(0.32); -SLEEP(0.32) -0 -SELECT SLEEP(0.33); -SLEEP(0.33) -0 -SELECT SLEEP(0.34); -SLEEP(0.34) -0 -SELECT SLEEP(0.35); -SLEEP(0.35) -0 -SELECT SLEEP(0.36); -SLEEP(0.36) -0 -SELECT SLEEP(0.37); -SLEEP(0.37) -0 -SELECT SLEEP(0.38); -SLEEP(0.38) -0 -SELECT SLEEP(0.39); -SLEEP(0.39) -0 -SELECT SLEEP(0.40); -SLEEP(0.40) -0 -SELECT SLEEP(1.1); -SLEEP(1.1) -0 -SELECT SLEEP(1.2); -SLEEP(1.2) -0 -SELECT SLEEP(1.3); -SLEEP(1.3) -0 -SELECT SLEEP(1.5); -SLEEP(1.5) -0 -SELECT SLEEP(1.4); -SLEEP(1.4) -0 -SELECT SLEEP(0.5); -SLEEP(0.5) -0 -SELECT SLEEP(2.1); -SLEEP(2.1) -0 -SELECT SLEEP(2.3); -SLEEP(2.3) -0 -SELECT SLEEP(2.5); -SLEEP(2.5) -0 -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; +SET SESSION debug="+d,query_exec_time_0.31"; +SET SESSION debug="+d,query_exec_time_0.32"; +SET SESSION debug="+d,query_exec_time_0.33"; +SET SESSION debug="+d,query_exec_time_0.34"; +SET SESSION debug="+d,query_exec_time_0.35"; +SET SESSION debug="+d,query_exec_time_0.36"; +SET SESSION debug="+d,query_exec_time_0.37"; +SET SESSION debug="+d,query_exec_time_0.38"; +SET SESSION debug="+d,query_exec_time_0.39"; +SET SESSION debug="+d,query_exec_time_0.4"; +SET SESSION debug="+d,query_exec_time_1.1"; +SET SESSION debug="+d,query_exec_time_1.2"; +SET SESSION debug="+d,query_exec_time_1.3"; +SET SESSION debug="+d,query_exec_time_1.5"; +SET SESSION debug="+d,query_exec_time_1.4"; +SET SESSION debug="+d,query_exec_time_0.5"; +SET SESSION debug="+d,query_exec_time_2.1"; +SET SESSION debug="+d,query_exec_time_2.3"; +SET SESSION debug="+d,query_exec_time_2.5"; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SELECT d.count, (SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, (SELECT SUM((b.total * 1000000) DIV 1000000) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as query_total, @@ -131,11 +94,10 @@ SELECT d.count, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as d WHERE d.count > 0; count query_count query_total not_zero_region_count region_count -1 20 15 5 44 -10 20 15 5 44 -1 20 15 5 44 -5 20 15 5 44 -3 20 15 5 44 +10 19 15 4 44 +1 19 15 4 44 +5 19 15 4 44 +3 19 15 4 44 SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; region_count 44 @@ -193,65 +155,27 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 10 FLUSH QUERY_RESPONSE_TIME; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; -SELECT SLEEP(0.31); -SLEEP(0.31) -0 -SELECT SLEEP(0.32); -SLEEP(0.32) -0 -SELECT SLEEP(0.33); -SLEEP(0.33) -0 -SELECT SLEEP(0.34); -SLEEP(0.34) -0 -SELECT SLEEP(0.35); -SLEEP(0.35) -0 -SELECT SLEEP(0.36); -SLEEP(0.36) -0 -SELECT SLEEP(0.37); -SLEEP(0.37) -0 -SELECT SLEEP(0.38); -SLEEP(0.38) -0 -SELECT SLEEP(0.39); -SLEEP(0.39) -0 -SELECT SLEEP(0.40); -SLEEP(0.40) -0 -SELECT SLEEP(1.1); -SLEEP(1.1) -0 -SELECT SLEEP(1.2); -SLEEP(1.2) -0 -SELECT SLEEP(1.3); -SLEEP(1.3) -0 -SELECT SLEEP(1.5); -SLEEP(1.5) -0 -SELECT SLEEP(1.4); -SLEEP(1.4) -0 -SELECT SLEEP(0.5); -SLEEP(0.5) -0 -SELECT SLEEP(2.1); -SLEEP(2.1) -0 -SELECT SLEEP(2.3); -SLEEP(2.3) -0 -SELECT SLEEP(2.5); -SLEEP(2.5) -0 -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; +SET SESSION debug="+d,query_exec_time_0.31"; +SET SESSION debug="+d,query_exec_time_0.32"; +SET SESSION debug="+d,query_exec_time_0.33"; +SET SESSION debug="+d,query_exec_time_0.34"; +SET SESSION debug="+d,query_exec_time_0.35"; +SET SESSION debug="+d,query_exec_time_0.36"; +SET SESSION debug="+d,query_exec_time_0.37"; +SET SESSION debug="+d,query_exec_time_0.38"; +SET SESSION debug="+d,query_exec_time_0.39"; +SET SESSION debug="+d,query_exec_time_0.4"; +SET SESSION debug="+d,query_exec_time_1.1"; +SET SESSION debug="+d,query_exec_time_1.2"; +SET SESSION debug="+d,query_exec_time_1.3"; +SET SESSION debug="+d,query_exec_time_1.5"; +SET SESSION debug="+d,query_exec_time_1.4"; +SET SESSION debug="+d,query_exec_time_0.5"; +SET SESSION debug="+d,query_exec_time_2.1"; +SET SESSION debug="+d,query_exec_time_2.3"; +SET SESSION debug="+d,query_exec_time_2.5"; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SELECT d.count, (SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, (SELECT SUM((b.total * 1000000) DIV 1000000) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as query_total, @@ -259,9 +183,8 @@ SELECT d.count, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as d WHERE d.count > 0; count query_count query_total not_zero_region_count region_count -1 20 17 3 14 -11 20 17 3 14 -8 20 17 3 14 +11 19 17 2 14 +8 19 17 2 14 SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; region_count 14 @@ -289,65 +212,27 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 7 FLUSH QUERY_RESPONSE_TIME; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; -SELECT SLEEP(0.31); -SLEEP(0.31) -0 -SELECT SLEEP(0.32); -SLEEP(0.32) -0 -SELECT SLEEP(0.33); -SLEEP(0.33) -0 -SELECT SLEEP(0.34); -SLEEP(0.34) -0 -SELECT SLEEP(0.35); -SLEEP(0.35) -0 -SELECT SLEEP(0.36); -SLEEP(0.36) -0 -SELECT SLEEP(0.37); -SLEEP(0.37) -0 -SELECT SLEEP(0.38); -SLEEP(0.38) -0 -SELECT SLEEP(0.39); -SLEEP(0.39) -0 -SELECT SLEEP(0.40); -SLEEP(0.40) -0 -SELECT SLEEP(1.1); -SLEEP(1.1) -0 -SELECT SLEEP(1.2); -SLEEP(1.2) -0 -SELECT SLEEP(1.3); -SLEEP(1.3) -0 -SELECT SLEEP(1.5); -SLEEP(1.5) -0 -SELECT SLEEP(1.4); -SLEEP(1.4) -0 -SELECT SLEEP(0.5); -SLEEP(0.5) -0 -SELECT SLEEP(2.1); -SLEEP(2.1) -0 -SELECT SLEEP(2.3); -SLEEP(2.3) -0 -SELECT SLEEP(2.5); -SLEEP(2.5) -0 -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; +SET SESSION debug="+d,query_exec_time_0.31"; +SET SESSION debug="+d,query_exec_time_0.32"; +SET SESSION debug="+d,query_exec_time_0.33"; +SET SESSION debug="+d,query_exec_time_0.34"; +SET SESSION debug="+d,query_exec_time_0.35"; +SET SESSION debug="+d,query_exec_time_0.36"; +SET SESSION debug="+d,query_exec_time_0.37"; +SET SESSION debug="+d,query_exec_time_0.38"; +SET SESSION debug="+d,query_exec_time_0.39"; +SET SESSION debug="+d,query_exec_time_0.4"; +SET SESSION debug="+d,query_exec_time_1.1"; +SET SESSION debug="+d,query_exec_time_1.2"; +SET SESSION debug="+d,query_exec_time_1.3"; +SET SESSION debug="+d,query_exec_time_1.5"; +SET SESSION debug="+d,query_exec_time_1.4"; +SET SESSION debug="+d,query_exec_time_0.5"; +SET SESSION debug="+d,query_exec_time_2.1"; +SET SESSION debug="+d,query_exec_time_2.3"; +SET SESSION debug="+d,query_exec_time_2.5"; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SELECT d.count, (SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, (SELECT SUM((b.total * 1000000) DIV 1000000) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as query_total, @@ -355,9 +240,8 @@ SELECT d.count, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as d WHERE d.count > 0; count query_count query_total not_zero_region_count region_count -1 20 17 3 17 -11 20 17 3 17 -8 20 17 3 17 +11 19 17 2 17 +8 19 17 2 17 SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; region_count 17 @@ -388,65 +272,27 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 156 FLUSH QUERY_RESPONSE_TIME; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; -SELECT SLEEP(0.31); -SLEEP(0.31) -0 -SELECT SLEEP(0.32); -SLEEP(0.32) -0 -SELECT SLEEP(0.33); -SLEEP(0.33) -0 -SELECT SLEEP(0.34); -SLEEP(0.34) -0 -SELECT SLEEP(0.35); -SLEEP(0.35) -0 -SELECT SLEEP(0.36); -SLEEP(0.36) -0 -SELECT SLEEP(0.37); -SLEEP(0.37) -0 -SELECT SLEEP(0.38); -SLEEP(0.38) -0 -SELECT SLEEP(0.39); -SLEEP(0.39) -0 -SELECT SLEEP(0.40); -SLEEP(0.40) -0 -SELECT SLEEP(1.1); -SLEEP(1.1) -0 -SELECT SLEEP(1.2); -SLEEP(1.2) -0 -SELECT SLEEP(1.3); -SLEEP(1.3) -0 -SELECT SLEEP(1.5); -SLEEP(1.5) -0 -SELECT SLEEP(1.4); -SLEEP(1.4) -0 -SELECT SLEEP(0.5); -SLEEP(0.5) -0 -SELECT SLEEP(2.1); -SLEEP(2.1) -0 -SELECT SLEEP(2.3); -SLEEP(2.3) -0 -SELECT SLEEP(2.5); -SLEEP(2.5) -0 -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; +SET SESSION debug="+d,query_exec_time_0.31"; +SET SESSION debug="+d,query_exec_time_0.32"; +SET SESSION debug="+d,query_exec_time_0.33"; +SET SESSION debug="+d,query_exec_time_0.34"; +SET SESSION debug="+d,query_exec_time_0.35"; +SET SESSION debug="+d,query_exec_time_0.36"; +SET SESSION debug="+d,query_exec_time_0.37"; +SET SESSION debug="+d,query_exec_time_0.38"; +SET SESSION debug="+d,query_exec_time_0.39"; +SET SESSION debug="+d,query_exec_time_0.4"; +SET SESSION debug="+d,query_exec_time_1.1"; +SET SESSION debug="+d,query_exec_time_1.2"; +SET SESSION debug="+d,query_exec_time_1.3"; +SET SESSION debug="+d,query_exec_time_1.5"; +SET SESSION debug="+d,query_exec_time_1.4"; +SET SESSION debug="+d,query_exec_time_0.5"; +SET SESSION debug="+d,query_exec_time_2.1"; +SET SESSION debug="+d,query_exec_time_2.3"; +SET SESSION debug="+d,query_exec_time_2.5"; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SELECT d.count, (SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, (SELECT SUM((b.total * 1000000) DIV 1000000) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as query_total, @@ -454,9 +300,8 @@ SELECT d.count, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as d WHERE d.count > 0; count query_count query_total not_zero_region_count region_count -1 20 17 3 7 -11 20 17 3 7 -8 20 17 3 7 +11 19 17 2 7 +8 19 17 2 7 SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; region_count 7 @@ -477,65 +322,27 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 1000 FLUSH QUERY_RESPONSE_TIME; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; -SELECT SLEEP(0.31); -SLEEP(0.31) -0 -SELECT SLEEP(0.32); -SLEEP(0.32) -0 -SELECT SLEEP(0.33); -SLEEP(0.33) -0 -SELECT SLEEP(0.34); -SLEEP(0.34) -0 -SELECT SLEEP(0.35); -SLEEP(0.35) -0 -SELECT SLEEP(0.36); -SLEEP(0.36) -0 -SELECT SLEEP(0.37); -SLEEP(0.37) -0 -SELECT SLEEP(0.38); -SLEEP(0.38) -0 -SELECT SLEEP(0.39); -SLEEP(0.39) -0 -SELECT SLEEP(0.40); -SLEEP(0.40) -0 -SELECT SLEEP(1.1); -SLEEP(1.1) -0 -SELECT SLEEP(1.2); -SLEEP(1.2) -0 -SELECT SLEEP(1.3); -SLEEP(1.3) -0 -SELECT SLEEP(1.5); -SLEEP(1.5) -0 -SELECT SLEEP(1.4); -SLEEP(1.4) -0 -SELECT SLEEP(0.5); -SLEEP(0.5) -0 -SELECT SLEEP(2.1); -SLEEP(2.1) -0 -SELECT SLEEP(2.3); -SLEEP(2.3) -0 -SELECT SLEEP(2.5); -SLEEP(2.5) -0 -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; +SET SESSION debug="+d,query_exec_time_0.31"; +SET SESSION debug="+d,query_exec_time_0.32"; +SET SESSION debug="+d,query_exec_time_0.33"; +SET SESSION debug="+d,query_exec_time_0.34"; +SET SESSION debug="+d,query_exec_time_0.35"; +SET SESSION debug="+d,query_exec_time_0.36"; +SET SESSION debug="+d,query_exec_time_0.37"; +SET SESSION debug="+d,query_exec_time_0.38"; +SET SESSION debug="+d,query_exec_time_0.39"; +SET SESSION debug="+d,query_exec_time_0.4"; +SET SESSION debug="+d,query_exec_time_1.1"; +SET SESSION debug="+d,query_exec_time_1.2"; +SET SESSION debug="+d,query_exec_time_1.3"; +SET SESSION debug="+d,query_exec_time_1.5"; +SET SESSION debug="+d,query_exec_time_1.4"; +SET SESSION debug="+d,query_exec_time_0.5"; +SET SESSION debug="+d,query_exec_time_2.1"; +SET SESSION debug="+d,query_exec_time_2.3"; +SET SESSION debug="+d,query_exec_time_2.5"; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SELECT d.count, (SELECT SUM(a.count) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as a WHERE a.count != 0) as query_count, (SELECT SUM((b.total * 1000000) DIV 1000000) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as b WHERE b.count != 0) as query_total, @@ -543,9 +350,8 @@ SELECT d.count, (SELECT COUNT(*) FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME as d WHERE d.count > 0; count query_count query_total not_zero_region_count region_count -1 20 17 3 6 -11 20 17 3 6 -8 20 17 3 6 +11 19 17 2 6 +8 19 17 2 6 SELECT COUNT(*) as region_count FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME; region_count 6 @@ -566,5 +372,6 @@ Warning 1292 Truncated incorrect query_response_time_range_base value: '1001' SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; Variable_name Value query_response_time_range_base 1000 -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE =10; +SET GLOBAL debug=default; diff --git a/mysql-test/suite/percona/percona_query_response_time.test b/mysql-test/suite/percona/percona_query_response_time.test index a58cafc8d01..f2df156b13d 100644 --- a/mysql-test/suite/percona/percona_query_response_time.test +++ b/mysql-test/suite/percona/percona_query_response_time.test @@ -1,4 +1,8 @@ -source include/have_innodb.inc; +--source include/have_response_time_distribution.inc +--source include/have_debug.inc + +SET GLOBAL debug="d,query_exec_time_debug"; + SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 2; @@ -7,9 +11,9 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; source include/percona_query_response_time_show.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; source include/percona_query_response_time_sleep.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; source include/percona_query_response_time_show.inc; @@ -18,9 +22,9 @@ SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 10; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; source include/percona_query_response_time_sleep.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; source include/percona_query_response_time_show.inc; @@ -29,9 +33,9 @@ SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 7; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; source include/percona_query_response_time_sleep.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; source include/percona_query_response_time_show.inc; @@ -40,9 +44,9 @@ SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 156; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; source include/percona_query_response_time_sleep.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; source include/percona_query_response_time_show.inc; @@ -51,9 +55,9 @@ SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1000; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; source include/percona_query_response_time_flush.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=1; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1; source include/percona_query_response_time_sleep.inc; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; source include/percona_query_response_time_show.inc; @@ -61,5 +65,7 @@ SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE = 1001; SHOW GLOBAL VARIABLES where Variable_name like 'QUERY_RESPONSE_TIME_RANGE_BASE'; -SET GLOBAL ENABLE_QUERY_RESPONSE_TIME_STATS=0; +SET GLOBAL QUERY_RESPONSE_TIME_STATS=0; SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE =10; + +SET GLOBAL debug=default; diff --git a/mysql-test/include/percona_query_response_time_flush.inc b/mysql-test/suite/percona/percona_query_response_time_flush.inc similarity index 100% rename from mysql-test/include/percona_query_response_time_flush.inc rename to mysql-test/suite/percona/percona_query_response_time_flush.inc diff --git a/mysql-test/include/percona_query_response_time_show.inc b/mysql-test/suite/percona/percona_query_response_time_show.inc similarity index 100% rename from mysql-test/include/percona_query_response_time_show.inc rename to mysql-test/suite/percona/percona_query_response_time_show.inc diff --git a/mysql-test/suite/percona/percona_query_response_time_sleep.inc b/mysql-test/suite/percona/percona_query_response_time_sleep.inc new file mode 100644 index 00000000000..d889fd9f98d --- /dev/null +++ b/mysql-test/suite/percona/percona_query_response_time_sleep.inc @@ -0,0 +1,19 @@ +SET SESSION debug="+d,query_exec_time_0.31"; +SET SESSION debug="+d,query_exec_time_0.32"; +SET SESSION debug="+d,query_exec_time_0.33"; +SET SESSION debug="+d,query_exec_time_0.34"; +SET SESSION debug="+d,query_exec_time_0.35"; +SET SESSION debug="+d,query_exec_time_0.36"; +SET SESSION debug="+d,query_exec_time_0.37"; +SET SESSION debug="+d,query_exec_time_0.38"; +SET SESSION debug="+d,query_exec_time_0.39"; +SET SESSION debug="+d,query_exec_time_0.4"; +SET SESSION debug="+d,query_exec_time_1.1"; +SET SESSION debug="+d,query_exec_time_1.2"; +SET SESSION debug="+d,query_exec_time_1.3"; +SET SESSION debug="+d,query_exec_time_1.5"; +SET SESSION debug="+d,query_exec_time_1.4"; +SET SESSION debug="+d,query_exec_time_0.5"; +SET SESSION debug="+d,query_exec_time_2.1"; +SET SESSION debug="+d,query_exec_time_2.3"; +SET SESSION debug="+d,query_exec_time_2.5"; diff --git a/mysql-test/suite/percona/percona_server_variables.inc b/mysql-test/suite/percona/percona_server_variables.inc new file mode 100644 index 00000000000..60c8e0ba759 --- /dev/null +++ b/mysql-test/suite/percona/percona_server_variables.inc @@ -0,0 +1,3 @@ +--source have_response_time_distribution.inc +--source include/have_xtradb.inc +SELECT Variable_name FROM INFORMATION_SCHEMA.SESSION_VARIABLES ORDER BY 1; diff --git a/mysql-test/suite/percona/percona_server_variables.result b/mysql-test/suite/percona/percona_server_variables.result deleted file mode 100644 index cb2af0d3d0e..00000000000 --- a/mysql-test/suite/percona/percona_server_variables.result +++ /dev/null @@ -1,342 +0,0 @@ -show variables; -Variable_name Value -auto_increment_increment Value -auto_increment_offset Value -autocommit Value -automatic_sp_privileges Value -back_log Value -basedir Value -big_tables Value -binlog_cache_size Value -binlog_direct_non_transactional_updates Value -binlog_format Value -bulk_insert_buffer_size Value -character_set_client Value -character_set_connection Value -character_set_database Value -character_set_filesystem Value -character_set_results Value -character_set_server Value -character_set_system Value -character_sets_dir Value -collation_connection Value -collation_database Value -collation_server Value -completion_type Value -concurrent_insert Value -connect_timeout Value -datadir Value -date_format Value -datetime_format Value -debug Value -debug_sync Value -default_week_format Value -delay_key_write Value -delayed_insert_limit Value -delayed_insert_timeout Value -delayed_queue_size Value -div_precision_increment Value -enable_query_response_time_stats Value -engine_condition_pushdown Value -error_count Value -event_scheduler Value -expire_logs_days Value -fast_index_creation Value -flush Value -flush_time Value -foreign_key_checks Value -ft_boolean_syntax Value -ft_max_word_len Value -ft_min_word_len Value -ft_query_expansion_limit Value -ft_stopword_file Value -general_log Value -general_log_file Value -group_concat_max_len Value -have_community_features Value -have_compress Value -have_crypt Value -have_csv Value -have_dynamic_loading Value -have_geometry Value -have_innodb Value -have_ndbcluster Value -have_openssl Value -have_partitioning Value -have_query_cache Value -have_rtree_keys Value -have_ssl Value -have_symlink Value -hostname Value -identity Value -ignore_builtin_innodb Value -init_connect Value -init_file Value -init_slave Value -innodb_adaptive_checkpoint Value -innodb_adaptive_flushing Value -innodb_adaptive_hash_index Value -innodb_additional_mem_pool_size Value -innodb_auto_lru_dump Value -innodb_autoextend_increment Value -innodb_autoinc_lock_mode Value -innodb_buffer_pool_shm_checksum Value -innodb_buffer_pool_shm_key Value -innodb_buffer_pool_size Value -innodb_change_buffering Value -innodb_checkpoint_age_target Value -innodb_checksums Value -innodb_commit_concurrency Value -innodb_concurrency_tickets Value -innodb_data_file_path Value -innodb_data_home_dir Value -innodb_dict_size_limit Value -innodb_doublewrite Value -innodb_doublewrite_file Value -innodb_enable_unsafe_group_commit Value -innodb_expand_import Value -innodb_extra_rsegments Value -innodb_extra_undoslots Value -innodb_fast_checksum Value -innodb_fast_recovery Value -innodb_fast_shutdown Value -innodb_file_format Value -innodb_file_format_check Value -innodb_file_per_table Value -innodb_flush_log_at_trx_commit Value -innodb_flush_log_at_trx_commit_session Value -innodb_flush_method Value -innodb_flush_neighbor_pages Value -innodb_force_recovery Value -innodb_ibuf_accel_rate Value -innodb_ibuf_active_contract Value -innodb_ibuf_max_size Value -innodb_io_capacity Value -innodb_lock_wait_timeout Value -innodb_locks_unsafe_for_binlog Value -innodb_log_buffer_size Value -innodb_log_file_size Value -innodb_log_files_in_group Value -innodb_log_group_home_dir Value -innodb_max_dirty_pages_pct Value -innodb_max_purge_lag Value -innodb_mirrored_log_groups Value -innodb_old_blocks_pct Value -innodb_old_blocks_time Value -innodb_open_files Value -innodb_overwrite_relay_log_info Value -innodb_page_size Value -innodb_pass_corrupt_table Value -innodb_read_ahead Value -innodb_read_ahead_threshold Value -innodb_read_io_threads Value -innodb_recovery_stats Value -innodb_replication_delay Value -innodb_rollback_on_timeout Value -innodb_show_locks_held Value -innodb_show_verbose_locks Value -innodb_spin_wait_delay Value -innodb_stats_auto_update Value -innodb_stats_method Value -innodb_stats_on_metadata Value -innodb_stats_sample_pages Value -innodb_stats_update_need_lock Value -innodb_strict_mode Value -innodb_support_xa Value -innodb_sync_spin_loops Value -innodb_table_locks Value -innodb_thread_concurrency Value -innodb_thread_concurrency_timer_based Value -innodb_thread_sleep_delay Value -innodb_use_purge_thread Value -innodb_use_sys_malloc Value -innodb_use_sys_stats_table Value -innodb_version Value -innodb_write_io_threads Value -insert_id Value -interactive_timeout Value -join_buffer_size Value -keep_files_on_create Value -key_buffer_size Value -key_cache_age_threshold Value -key_cache_block_size Value -key_cache_division_limit Value -language Value -large_files_support Value -large_page_size Value -large_pages Value -last_insert_id Value -lc_time_names Value -license Value -local_infile Value -locked_in_memory Value -log Value -log_bin Value -log_bin_trust_function_creators Value -log_bin_trust_routine_creators Value -log_error Value -log_output Value -log_queries_not_using_indexes Value -log_slave_updates Value -log_slow_filter Value -log_slow_queries Value -log_slow_rate_limit Value -log_slow_slave_statements Value -log_slow_sp_statements Value -log_slow_timestamp_every Value -log_slow_verbosity Value -log_warnings Value -long_query_time Value -low_priority_updates Value -lower_case_file_system Value -lower_case_table_names Value -max_allowed_packet Value -max_binlog_cache_size Value -max_binlog_size Value -max_connect_errors Value -max_connections Value -max_delayed_threads Value -max_error_count Value -max_heap_table_size Value -max_insert_delayed_threads Value -max_join_size Value -max_length_for_sort_data Value -max_prepared_stmt_count Value -max_relay_log_size Value -max_seeks_for_key Value -max_sort_length Value -max_sp_recursion_depth Value -max_tmp_tables Value -max_user_connections Value -max_write_lock_count Value -min_examined_row_limit Value -multi_range_count Value -myisam_data_pointer_size Value -myisam_max_sort_file_size Value -myisam_mmap_size Value -myisam_recover_options Value -myisam_repair_threads Value -myisam_sort_buffer_size Value -myisam_stats_method Value -myisam_use_mmap Value -net_buffer_length Value -net_read_timeout Value -net_retry_count Value -net_write_timeout Value -new Value -old Value -old_alter_table Value -old_passwords Value -open_files_limit Value -optimizer_fix Value -optimizer_prune_level Value -optimizer_search_depth Value -optimizer_switch Value -pid_file Value -plugin_dir Value -port Value -preload_buffer_size Value -profiling Value -profiling_history_size Value -profiling_server Value -profiling_use_getrusage Value -protocol_version Value -pseudo_thread_id Value -query_alloc_block_size Value -query_cache_limit Value -query_cache_min_res_unit Value -query_cache_size Value -query_cache_strip_comments Value -query_cache_type Value -query_cache_wlock_invalidate Value -query_prealloc_size Value -query_response_time_range_base Value -rand_seed1 Value -rand_seed2 Value -range_alloc_block_size Value -read_buffer_size Value -read_only Value -read_rnd_buffer_size Value -relay_log Value -relay_log_index Value -relay_log_info_file Value -relay_log_purge Value -relay_log_space_limit Value -report_host Value -report_password Value -report_port Value -report_user Value -rpl_recovery_rank Value -secure_auth Value -secure_file_priv Value -server_id Value -skip_external_locking Value -skip_name_resolve Value -skip_networking Value -skip_show_database Value -slave_compressed_protocol Value -slave_exec_mode Value -slave_load_tmpdir Value -slave_net_timeout Value -slave_skip_errors Value -slave_transaction_retries Value -slow_launch_time Value -slow_query_log Value -slow_query_log_file Value -slow_query_log_microseconds_timestamp Value -socket Value -sort_buffer_size Value -sql_auto_is_null Value -sql_big_selects Value -sql_big_tables Value -sql_buffer_result Value -sql_log_bin Value -sql_log_off Value -sql_log_update Value -sql_low_priority_updates Value -sql_max_join_size Value -sql_mode Value -sql_notes Value -sql_quote_show_create Value -sql_safe_updates Value -sql_select_limit Value -sql_slave_skip_counter Value -sql_warnings Value -ssl_ca Value -ssl_capath Value -ssl_cert Value -ssl_cipher Value -ssl_key Value -storage_engine Value -suppress_log_warning_1592 Value -sync_binlog Value -sync_frm Value -system_time_zone Value -table_definition_cache Value -table_lock_wait_timeout Value -table_open_cache Value -table_type Value -thread_cache_size Value -thread_handling Value -thread_stack Value -thread_statistics Value -time_format Value -time_zone Value -timed_mutexes Value -timestamp Value -tmp_table_size Value -tmpdir Value -transaction_alloc_block_size Value -transaction_prealloc_size Value -tx_isolation Value -unique_checks Value -updatable_views_with_limit Value -use_global_log_slow_control Value -use_global_long_query_time Value -userstat_running Value -version Value -version_comment Value -version_compile_machine Value -version_compile_os Value -wait_timeout Value -warning_count Value diff --git a/mysql-test/suite/percona/percona_server_variables.test b/mysql-test/suite/percona/percona_server_variables.test deleted file mode 100644 index 232cbb15e25..00000000000 --- a/mysql-test/suite/percona/percona_server_variables.test +++ /dev/null @@ -1,7 +0,0 @@ ---source include/have_innodb.inc ---source include/have_debug.inc - -#check the list of variable names ---replace_column 2 Value -show variables; - diff --git a/mysql-test/suite/percona/percona_server_variables_debug.result b/mysql-test/suite/percona/percona_server_variables_debug.result new file mode 100644 index 00000000000..1ffaa6a7704 --- /dev/null +++ b/mysql-test/suite/percona/percona_server_variables_debug.result @@ -0,0 +1,371 @@ +SELECT Variable_name FROM INFORMATION_SCHEMA.SESSION_VARIABLES ORDER BY 1; +Variable_name +AUTOCOMMIT +AUTOMATIC_SP_PRIVILEGES +AUTO_INCREMENT_INCREMENT +AUTO_INCREMENT_OFFSET +BACK_LOG +BASEDIR +BIG_TABLES +BINLOG_CACHE_SIZE +BINLOG_DIRECT_NON_TRANSACTIONAL_UPDATES +BINLOG_FORMAT +BINLOG_STMT_CACHE_SIZE +BULK_INSERT_BUFFER_SIZE +CHARACTER_SETS_DIR +CHARACTER_SET_CLIENT +CHARACTER_SET_CONNECTION +CHARACTER_SET_DATABASE +CHARACTER_SET_FILESYSTEM +CHARACTER_SET_RESULTS +CHARACTER_SET_SERVER +CHARACTER_SET_SYSTEM +COLLATION_CONNECTION +COLLATION_DATABASE +COLLATION_SERVER +COMPLETION_TYPE +CONCURRENT_INSERT +CONNECT_TIMEOUT +DATADIR +DATETIME_FORMAT +DATE_FORMAT +DEBUG +DEBUG_SYNC +DEFAULT_STORAGE_ENGINE +DEFAULT_WEEK_FORMAT +DELAYED_INSERT_LIMIT +DELAYED_INSERT_TIMEOUT +DELAYED_QUEUE_SIZE +DELAY_KEY_WRITE +DIV_PRECISION_INCREMENT +ENGINE_CONDITION_PUSHDOWN +ERROR_COUNT +EVENT_SCHEDULER +EXPIRE_LOGS_DAYS +EXTERNAL_USER +FAST_INDEX_CREATION +FLUSH +FLUSH_TIME +FOREIGN_KEY_CHECKS +FT_BOOLEAN_SYNTAX +FT_MAX_WORD_LEN +FT_MIN_WORD_LEN +FT_QUERY_EXPANSION_LIMIT +FT_STOPWORD_FILE +GENERAL_LOG +GENERAL_LOG_FILE +GROUP_CONCAT_MAX_LEN +HAVE_COMPRESS +HAVE_CRYPT +HAVE_CSV +HAVE_DYNAMIC_LOADING +HAVE_GEOMETRY +HAVE_INNODB +HAVE_NDBCLUSTER +HAVE_OPENSSL +HAVE_PARTITIONING +HAVE_PROFILING +HAVE_QUERY_CACHE +HAVE_RESPONSE_TIME_DISTRIBUTION +HAVE_RTREE_KEYS +HAVE_SSL +HAVE_SYMLINK +HOSTNAME +IDENTITY +IGNORE_BUILTIN_INNODB +INIT_CONNECT +INIT_FILE +INIT_SLAVE +INNODB_ADAPTIVE_FLUSHING +INNODB_ADAPTIVE_FLUSHING_METHOD +INNODB_ADAPTIVE_HASH_INDEX +INNODB_ADAPTIVE_HASH_INDEX_PARTITIONS +INNODB_ADDITIONAL_MEM_POOL_SIZE +INNODB_AUTOEXTEND_INCREMENT +INNODB_AUTOINC_LOCK_MODE +INNODB_BUFFER_POOL_INSTANCES +INNODB_BUFFER_POOL_RESTORE_AT_STARTUP +INNODB_BUFFER_POOL_SHM_CHECKSUM +INNODB_BUFFER_POOL_SHM_KEY +INNODB_BUFFER_POOL_SIZE +INNODB_CHANGE_BUFFERING +INNODB_CHANGE_BUFFERING_DEBUG +INNODB_CHECKPOINT_AGE_TARGET +INNODB_CHECKSUMS +INNODB_COMMIT_CONCURRENCY +INNODB_CONCURRENCY_TICKETS +INNODB_CORRUPT_TABLE_ACTION +INNODB_DATA_FILE_PATH +INNODB_DATA_HOME_DIR +INNODB_DICT_SIZE_LIMIT +INNODB_DOUBLEWRITE +INNODB_DOUBLEWRITE_FILE +INNODB_FAST_CHECKSUM +INNODB_FAST_SHUTDOWN +INNODB_FILE_FORMAT +INNODB_FILE_FORMAT_CHECK +INNODB_FILE_FORMAT_MAX +INNODB_FILE_PER_TABLE +INNODB_FLUSH_LOG_AT_TRX_COMMIT +INNODB_FLUSH_METHOD +INNODB_FLUSH_NEIGHBOR_PAGES +INNODB_FORCE_RECOVERY +INNODB_IBUF_ACCEL_RATE +INNODB_IBUF_ACTIVE_CONTRACT +INNODB_IBUF_MAX_SIZE +INNODB_IMPORT_TABLE_FROM_XTRABACKUP +INNODB_IO_CAPACITY +INNODB_LAZY_DROP_TABLE +INNODB_LOCKS_UNSAFE_FOR_BINLOG +INNODB_LOCK_WAIT_TIMEOUT +INNODB_LOG_BLOCK_SIZE +INNODB_LOG_BUFFER_SIZE +INNODB_LOG_FILES_IN_GROUP +INNODB_LOG_FILE_SIZE +INNODB_LOG_GROUP_HOME_DIR +INNODB_MAX_DIRTY_PAGES_PCT +INNODB_MAX_PURGE_LAG +INNODB_MIRRORED_LOG_GROUPS +INNODB_OLD_BLOCKS_PCT +INNODB_OLD_BLOCKS_TIME +INNODB_OPEN_FILES +INNODB_PAGE_SIZE +INNODB_PURGE_BATCH_SIZE +INNODB_PURGE_THREADS +INNODB_READ_AHEAD +INNODB_READ_AHEAD_THRESHOLD +INNODB_READ_IO_THREADS +INNODB_RECOVERY_STATS +INNODB_RECOVERY_UPDATE_RELAY_LOG +INNODB_REPLICATION_DELAY +INNODB_ROLLBACK_ON_TIMEOUT +INNODB_ROLLBACK_SEGMENTS +INNODB_SHOW_LOCKS_HELD +INNODB_SHOW_VERBOSE_LOCKS +INNODB_SPIN_WAIT_DELAY +INNODB_STATS_AUTO_UPDATE +INNODB_STATS_METHOD +INNODB_STATS_ON_METADATA +INNODB_STATS_SAMPLE_PAGES +INNODB_STATS_UPDATE_NEED_LOCK +INNODB_STRICT_MODE +INNODB_SUPPORT_XA +INNODB_SYNC_SPIN_LOOPS +INNODB_TABLE_LOCKS +INNODB_THREAD_CONCURRENCY +INNODB_THREAD_CONCURRENCY_TIMER_BASED +INNODB_THREAD_SLEEP_DELAY +INNODB_USE_GLOBAL_FLUSH_LOG_AT_TRX_COMMIT +INNODB_USE_NATIVE_AIO +INNODB_USE_SYS_MALLOC +INNODB_USE_SYS_STATS_TABLE +INNODB_VERSION +INNODB_WRITE_IO_THREADS +INSERT_ID +INTERACTIVE_TIMEOUT +JOIN_BUFFER_SIZE +KEEP_FILES_ON_CREATE +KEY_BUFFER_SIZE +KEY_CACHE_AGE_THRESHOLD +KEY_CACHE_BLOCK_SIZE +KEY_CACHE_DIVISION_LIMIT +LARGE_FILES_SUPPORT +LARGE_PAGES +LARGE_PAGE_SIZE +LAST_INSERT_ID +LC_MESSAGES +LC_MESSAGES_DIR +LC_TIME_NAMES +LICENSE +LOCAL_INFILE +LOCKED_IN_MEMORY +LOCK_WAIT_TIMEOUT +LOG +LOG_BIN +LOG_BIN_TRUST_FUNCTION_CREATORS +LOG_ERROR +LOG_OUTPUT +LOG_QUERIES_NOT_USING_INDEXES +LOG_SLAVE_UPDATES +LOG_SLOW_FILTER +LOG_SLOW_QUERIES +LOG_SLOW_RATE_LIMIT +LOG_SLOW_SLAVE_STATEMENTS +LOG_SLOW_SP_STATEMENTS +LOG_SLOW_VERBOSITY +LOG_WARNINGS +LOG_WARNINGS_SUPPRESS +LONG_QUERY_TIME +LOWER_CASE_FILE_SYSTEM +LOWER_CASE_TABLE_NAMES +LOW_PRIORITY_UPDATES +MAX_ALLOWED_PACKET +MAX_BINLOG_CACHE_SIZE +MAX_BINLOG_SIZE +MAX_BINLOG_STMT_CACHE_SIZE +MAX_CONNECTIONS +MAX_CONNECT_ERRORS +MAX_DELAYED_THREADS +MAX_ERROR_COUNT +MAX_HEAP_TABLE_SIZE +MAX_INSERT_DELAYED_THREADS +MAX_JOIN_SIZE +MAX_LENGTH_FOR_SORT_DATA +MAX_LONG_DATA_SIZE +MAX_PREPARED_STMT_COUNT +MAX_RELAY_LOG_SIZE +MAX_SEEKS_FOR_KEY +MAX_SORT_LENGTH +MAX_SP_RECURSION_DEPTH +MAX_TMP_TABLES +MAX_USER_CONNECTIONS +MAX_WRITE_LOCK_COUNT +MIN_EXAMINED_ROW_LIMIT +MULTI_RANGE_COUNT +MYISAM_DATA_POINTER_SIZE +MYISAM_MAX_SORT_FILE_SIZE +MYISAM_MMAP_SIZE +MYISAM_RECOVER_OPTIONS +MYISAM_REPAIR_THREADS +MYISAM_SORT_BUFFER_SIZE +MYISAM_STATS_METHOD +MYISAM_USE_MMAP +NET_BUFFER_LENGTH +NET_READ_TIMEOUT +NET_RETRY_COUNT +NET_WRITE_TIMEOUT +NEW +OLD +OLD_ALTER_TABLE +OLD_PASSWORDS +OPEN_FILES_LIMIT +OPTIMIZER_FIX +OPTIMIZER_PRUNE_LEVEL +OPTIMIZER_SEARCH_DEPTH +OPTIMIZER_SWITCH +PERFORMANCE_SCHEMA +PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_LONG_SIZE +PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_SIZE +PERFORMANCE_SCHEMA_MAX_COND_CLASSES +PERFORMANCE_SCHEMA_MAX_COND_INSTANCES +PERFORMANCE_SCHEMA_MAX_FILE_CLASSES +PERFORMANCE_SCHEMA_MAX_FILE_HANDLES +PERFORMANCE_SCHEMA_MAX_FILE_INSTANCES +PERFORMANCE_SCHEMA_MAX_MUTEX_CLASSES +PERFORMANCE_SCHEMA_MAX_MUTEX_INSTANCES +PERFORMANCE_SCHEMA_MAX_RWLOCK_CLASSES +PERFORMANCE_SCHEMA_MAX_RWLOCK_INSTANCES +PERFORMANCE_SCHEMA_MAX_TABLE_HANDLES +PERFORMANCE_SCHEMA_MAX_TABLE_INSTANCES +PERFORMANCE_SCHEMA_MAX_THREAD_CLASSES +PERFORMANCE_SCHEMA_MAX_THREAD_INSTANCES +PID_FILE +PLUGIN_DIR +PORT +PRELOAD_BUFFER_SIZE +PROFILING +PROFILING_HISTORY_SIZE +PROTOCOL_VERSION +PROXY_USER +PSEUDO_THREAD_ID +QUERY_ALLOC_BLOCK_SIZE +QUERY_CACHE_LIMIT +QUERY_CACHE_MIN_RES_UNIT +QUERY_CACHE_SIZE +QUERY_CACHE_STRIP_COMMENTS +QUERY_CACHE_TYPE +QUERY_CACHE_WLOCK_INVALIDATE +QUERY_PREALLOC_SIZE +QUERY_RESPONSE_TIME_RANGE_BASE +QUERY_RESPONSE_TIME_STATS +RAND_SEED1 +RAND_SEED2 +RANGE_ALLOC_BLOCK_SIZE +READ_BUFFER_SIZE +READ_ONLY +READ_RND_BUFFER_SIZE +RELAY_LOG +RELAY_LOG_INDEX +RELAY_LOG_INFO_FILE +RELAY_LOG_PURGE +RELAY_LOG_RECOVERY +RELAY_LOG_SPACE_LIMIT +REPORT_HOST +REPORT_PASSWORD +REPORT_PORT +REPORT_USER +RPL_RECOVERY_RANK +SECURE_AUTH +SECURE_FILE_PRIV +SERVER_ID +SKIP_EXTERNAL_LOCKING +SKIP_NAME_RESOLVE +SKIP_NETWORKING +SKIP_SHOW_DATABASE +SLAVE_COMPRESSED_PROTOCOL +SLAVE_EXEC_MODE +SLAVE_LOAD_TMPDIR +SLAVE_NET_TIMEOUT +SLAVE_SKIP_ERRORS +SLAVE_TRANSACTION_RETRIES +SLAVE_TYPE_CONVERSIONS +SLOW_LAUNCH_TIME +SLOW_QUERY_LOG +SLOW_QUERY_LOG_FILE +SLOW_QUERY_LOG_TIMESTAMP_ALWAYS +SLOW_QUERY_LOG_TIMESTAMP_PRECISION +SLOW_QUERY_LOG_USE_GLOBAL_CONTROL +SOCKET +SORT_BUFFER_SIZE +SQL_AUTO_IS_NULL +SQL_BIG_SELECTS +SQL_BIG_TABLES +SQL_BUFFER_RESULT +SQL_LOG_BIN +SQL_LOG_OFF +SQL_LOW_PRIORITY_UPDATES +SQL_MAX_JOIN_SIZE +SQL_MODE +SQL_NOTES +SQL_QUOTE_SHOW_CREATE +SQL_SAFE_UPDATES +SQL_SELECT_LIMIT +SQL_SLAVE_SKIP_COUNTER +SQL_WARNINGS +SSL_CA +SSL_CAPATH +SSL_CERT +SSL_CIPHER +SSL_KEY +STORAGE_ENGINE +SYNC_BINLOG +SYNC_FRM +SYNC_MASTER_INFO +SYNC_RELAY_LOG +SYNC_RELAY_LOG_INFO +SYSTEM_TIME_ZONE +TABLE_DEFINITION_CACHE +TABLE_OPEN_CACHE +THREAD_CACHE_SIZE +THREAD_CONCURRENCY +THREAD_HANDLING +THREAD_STACK +THREAD_STATISTICS +TIMED_MUTEXES +TIMESTAMP +TIME_FORMAT +TIME_ZONE +TMPDIR +TMP_TABLE_SIZE +TRANSACTION_ALLOC_BLOCK_SIZE +TRANSACTION_PREALLOC_SIZE +TX_ISOLATION +UNIQUE_CHECKS +UPDATABLE_VIEWS_WITH_LIMIT +USERSTAT +VERSION +VERSION_COMMENT +VERSION_COMPILE_MACHINE +VERSION_COMPILE_OS +WAIT_TIMEOUT +WARNING_COUNT diff --git a/mysql-test/suite/percona/percona_server_variables_debug.test b/mysql-test/suite/percona/percona_server_variables_debug.test new file mode 100644 index 00000000000..971f6bae689 --- /dev/null +++ b/mysql-test/suite/percona/percona_server_variables_debug.test @@ -0,0 +1,2 @@ +--source include/have_debug.inc +--source percona_server_variables.inc diff --git a/mysql-test/suite/percona/percona_server_variables_release.result b/mysql-test/suite/percona/percona_server_variables_release.result new file mode 100644 index 00000000000..cabd69b19a6 --- /dev/null +++ b/mysql-test/suite/percona/percona_server_variables_release.result @@ -0,0 +1,368 @@ +SELECT Variable_name FROM INFORMATION_SCHEMA.SESSION_VARIABLES ORDER BY 1; +Variable_name +AUTOCOMMIT +AUTOMATIC_SP_PRIVILEGES +AUTO_INCREMENT_INCREMENT +AUTO_INCREMENT_OFFSET +BACK_LOG +BASEDIR +BIG_TABLES +BINLOG_CACHE_SIZE +BINLOG_DIRECT_NON_TRANSACTIONAL_UPDATES +BINLOG_FORMAT +BINLOG_STMT_CACHE_SIZE +BULK_INSERT_BUFFER_SIZE +CHARACTER_SETS_DIR +CHARACTER_SET_CLIENT +CHARACTER_SET_CONNECTION +CHARACTER_SET_DATABASE +CHARACTER_SET_FILESYSTEM +CHARACTER_SET_RESULTS +CHARACTER_SET_SERVER +CHARACTER_SET_SYSTEM +COLLATION_CONNECTION +COLLATION_DATABASE +COLLATION_SERVER +COMPLETION_TYPE +CONCURRENT_INSERT +CONNECT_TIMEOUT +DATADIR +DATETIME_FORMAT +DATE_FORMAT +DEFAULT_STORAGE_ENGINE +DEFAULT_WEEK_FORMAT +DELAYED_INSERT_LIMIT +DELAYED_INSERT_TIMEOUT +DELAYED_QUEUE_SIZE +DELAY_KEY_WRITE +DIV_PRECISION_INCREMENT +ENGINE_CONDITION_PUSHDOWN +ERROR_COUNT +EVENT_SCHEDULER +EXPIRE_LOGS_DAYS +EXTERNAL_USER +FAST_INDEX_CREATION +FLUSH +FLUSH_TIME +FOREIGN_KEY_CHECKS +FT_BOOLEAN_SYNTAX +FT_MAX_WORD_LEN +FT_MIN_WORD_LEN +FT_QUERY_EXPANSION_LIMIT +FT_STOPWORD_FILE +GENERAL_LOG +GENERAL_LOG_FILE +GROUP_CONCAT_MAX_LEN +HAVE_COMPRESS +HAVE_CRYPT +HAVE_CSV +HAVE_DYNAMIC_LOADING +HAVE_GEOMETRY +HAVE_INNODB +HAVE_NDBCLUSTER +HAVE_OPENSSL +HAVE_PARTITIONING +HAVE_PROFILING +HAVE_QUERY_CACHE +HAVE_RESPONSE_TIME_DISTRIBUTION +HAVE_RTREE_KEYS +HAVE_SSL +HAVE_SYMLINK +HOSTNAME +IDENTITY +IGNORE_BUILTIN_INNODB +INIT_CONNECT +INIT_FILE +INIT_SLAVE +INNODB_ADAPTIVE_FLUSHING +INNODB_ADAPTIVE_FLUSHING_METHOD +INNODB_ADAPTIVE_HASH_INDEX +INNODB_ADAPTIVE_HASH_INDEX_PARTITIONS +INNODB_ADDITIONAL_MEM_POOL_SIZE +INNODB_AUTOEXTEND_INCREMENT +INNODB_AUTOINC_LOCK_MODE +INNODB_BUFFER_POOL_INSTANCES +INNODB_BUFFER_POOL_RESTORE_AT_STARTUP +INNODB_BUFFER_POOL_SHM_CHECKSUM +INNODB_BUFFER_POOL_SHM_KEY +INNODB_BUFFER_POOL_SIZE +INNODB_CHANGE_BUFFERING +INNODB_CHECKPOINT_AGE_TARGET +INNODB_CHECKSUMS +INNODB_COMMIT_CONCURRENCY +INNODB_CONCURRENCY_TICKETS +INNODB_CORRUPT_TABLE_ACTION +INNODB_DATA_FILE_PATH +INNODB_DATA_HOME_DIR +INNODB_DICT_SIZE_LIMIT +INNODB_DOUBLEWRITE +INNODB_DOUBLEWRITE_FILE +INNODB_FAST_CHECKSUM +INNODB_FAST_SHUTDOWN +INNODB_FILE_FORMAT +INNODB_FILE_FORMAT_CHECK +INNODB_FILE_FORMAT_MAX +INNODB_FILE_PER_TABLE +INNODB_FLUSH_LOG_AT_TRX_COMMIT +INNODB_FLUSH_METHOD +INNODB_FLUSH_NEIGHBOR_PAGES +INNODB_FORCE_RECOVERY +INNODB_IBUF_ACCEL_RATE +INNODB_IBUF_ACTIVE_CONTRACT +INNODB_IBUF_MAX_SIZE +INNODB_IMPORT_TABLE_FROM_XTRABACKUP +INNODB_IO_CAPACITY +INNODB_LAZY_DROP_TABLE +INNODB_LOCKS_UNSAFE_FOR_BINLOG +INNODB_LOCK_WAIT_TIMEOUT +INNODB_LOG_BLOCK_SIZE +INNODB_LOG_BUFFER_SIZE +INNODB_LOG_FILES_IN_GROUP +INNODB_LOG_FILE_SIZE +INNODB_LOG_GROUP_HOME_DIR +INNODB_MAX_DIRTY_PAGES_PCT +INNODB_MAX_PURGE_LAG +INNODB_MIRRORED_LOG_GROUPS +INNODB_OLD_BLOCKS_PCT +INNODB_OLD_BLOCKS_TIME +INNODB_OPEN_FILES +INNODB_PAGE_SIZE +INNODB_PURGE_BATCH_SIZE +INNODB_PURGE_THREADS +INNODB_READ_AHEAD +INNODB_READ_AHEAD_THRESHOLD +INNODB_READ_IO_THREADS +INNODB_RECOVERY_STATS +INNODB_RECOVERY_UPDATE_RELAY_LOG +INNODB_REPLICATION_DELAY +INNODB_ROLLBACK_ON_TIMEOUT +INNODB_ROLLBACK_SEGMENTS +INNODB_SHOW_LOCKS_HELD +INNODB_SHOW_VERBOSE_LOCKS +INNODB_SPIN_WAIT_DELAY +INNODB_STATS_AUTO_UPDATE +INNODB_STATS_METHOD +INNODB_STATS_ON_METADATA +INNODB_STATS_SAMPLE_PAGES +INNODB_STATS_UPDATE_NEED_LOCK +INNODB_STRICT_MODE +INNODB_SUPPORT_XA +INNODB_SYNC_SPIN_LOOPS +INNODB_TABLE_LOCKS +INNODB_THREAD_CONCURRENCY +INNODB_THREAD_CONCURRENCY_TIMER_BASED +INNODB_THREAD_SLEEP_DELAY +INNODB_USE_GLOBAL_FLUSH_LOG_AT_TRX_COMMIT +INNODB_USE_NATIVE_AIO +INNODB_USE_SYS_MALLOC +INNODB_USE_SYS_STATS_TABLE +INNODB_VERSION +INNODB_WRITE_IO_THREADS +INSERT_ID +INTERACTIVE_TIMEOUT +JOIN_BUFFER_SIZE +KEEP_FILES_ON_CREATE +KEY_BUFFER_SIZE +KEY_CACHE_AGE_THRESHOLD +KEY_CACHE_BLOCK_SIZE +KEY_CACHE_DIVISION_LIMIT +LARGE_FILES_SUPPORT +LARGE_PAGES +LARGE_PAGE_SIZE +LAST_INSERT_ID +LC_MESSAGES +LC_MESSAGES_DIR +LC_TIME_NAMES +LICENSE +LOCAL_INFILE +LOCKED_IN_MEMORY +LOCK_WAIT_TIMEOUT +LOG +LOG_BIN +LOG_BIN_TRUST_FUNCTION_CREATORS +LOG_ERROR +LOG_OUTPUT +LOG_QUERIES_NOT_USING_INDEXES +LOG_SLAVE_UPDATES +LOG_SLOW_FILTER +LOG_SLOW_QUERIES +LOG_SLOW_RATE_LIMIT +LOG_SLOW_SLAVE_STATEMENTS +LOG_SLOW_SP_STATEMENTS +LOG_SLOW_VERBOSITY +LOG_WARNINGS +LOG_WARNINGS_SUPPRESS +LONG_QUERY_TIME +LOWER_CASE_FILE_SYSTEM +LOWER_CASE_TABLE_NAMES +LOW_PRIORITY_UPDATES +MAX_ALLOWED_PACKET +MAX_BINLOG_CACHE_SIZE +MAX_BINLOG_SIZE +MAX_BINLOG_STMT_CACHE_SIZE +MAX_CONNECTIONS +MAX_CONNECT_ERRORS +MAX_DELAYED_THREADS +MAX_ERROR_COUNT +MAX_HEAP_TABLE_SIZE +MAX_INSERT_DELAYED_THREADS +MAX_JOIN_SIZE +MAX_LENGTH_FOR_SORT_DATA +MAX_LONG_DATA_SIZE +MAX_PREPARED_STMT_COUNT +MAX_RELAY_LOG_SIZE +MAX_SEEKS_FOR_KEY +MAX_SORT_LENGTH +MAX_SP_RECURSION_DEPTH +MAX_TMP_TABLES +MAX_USER_CONNECTIONS +MAX_WRITE_LOCK_COUNT +MIN_EXAMINED_ROW_LIMIT +MULTI_RANGE_COUNT +MYISAM_DATA_POINTER_SIZE +MYISAM_MAX_SORT_FILE_SIZE +MYISAM_MMAP_SIZE +MYISAM_RECOVER_OPTIONS +MYISAM_REPAIR_THREADS +MYISAM_SORT_BUFFER_SIZE +MYISAM_STATS_METHOD +MYISAM_USE_MMAP +NET_BUFFER_LENGTH +NET_READ_TIMEOUT +NET_RETRY_COUNT +NET_WRITE_TIMEOUT +NEW +OLD +OLD_ALTER_TABLE +OLD_PASSWORDS +OPEN_FILES_LIMIT +OPTIMIZER_FIX +OPTIMIZER_PRUNE_LEVEL +OPTIMIZER_SEARCH_DEPTH +OPTIMIZER_SWITCH +PERFORMANCE_SCHEMA +PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_LONG_SIZE +PERFORMANCE_SCHEMA_EVENTS_WAITS_HISTORY_SIZE +PERFORMANCE_SCHEMA_MAX_COND_CLASSES +PERFORMANCE_SCHEMA_MAX_COND_INSTANCES +PERFORMANCE_SCHEMA_MAX_FILE_CLASSES +PERFORMANCE_SCHEMA_MAX_FILE_HANDLES +PERFORMANCE_SCHEMA_MAX_FILE_INSTANCES +PERFORMANCE_SCHEMA_MAX_MUTEX_CLASSES +PERFORMANCE_SCHEMA_MAX_MUTEX_INSTANCES +PERFORMANCE_SCHEMA_MAX_RWLOCK_CLASSES +PERFORMANCE_SCHEMA_MAX_RWLOCK_INSTANCES +PERFORMANCE_SCHEMA_MAX_TABLE_HANDLES +PERFORMANCE_SCHEMA_MAX_TABLE_INSTANCES +PERFORMANCE_SCHEMA_MAX_THREAD_CLASSES +PERFORMANCE_SCHEMA_MAX_THREAD_INSTANCES +PID_FILE +PLUGIN_DIR +PORT +PRELOAD_BUFFER_SIZE +PROFILING +PROFILING_HISTORY_SIZE +PROTOCOL_VERSION +PROXY_USER +PSEUDO_THREAD_ID +QUERY_ALLOC_BLOCK_SIZE +QUERY_CACHE_LIMIT +QUERY_CACHE_MIN_RES_UNIT +QUERY_CACHE_SIZE +QUERY_CACHE_STRIP_COMMENTS +QUERY_CACHE_TYPE +QUERY_CACHE_WLOCK_INVALIDATE +QUERY_PREALLOC_SIZE +QUERY_RESPONSE_TIME_RANGE_BASE +QUERY_RESPONSE_TIME_STATS +RAND_SEED1 +RAND_SEED2 +RANGE_ALLOC_BLOCK_SIZE +READ_BUFFER_SIZE +READ_ONLY +READ_RND_BUFFER_SIZE +RELAY_LOG +RELAY_LOG_INDEX +RELAY_LOG_INFO_FILE +RELAY_LOG_PURGE +RELAY_LOG_RECOVERY +RELAY_LOG_SPACE_LIMIT +REPORT_HOST +REPORT_PASSWORD +REPORT_PORT +REPORT_USER +RPL_RECOVERY_RANK +SECURE_AUTH +SECURE_FILE_PRIV +SERVER_ID +SKIP_EXTERNAL_LOCKING +SKIP_NAME_RESOLVE +SKIP_NETWORKING +SKIP_SHOW_DATABASE +SLAVE_COMPRESSED_PROTOCOL +SLAVE_EXEC_MODE +SLAVE_LOAD_TMPDIR +SLAVE_NET_TIMEOUT +SLAVE_SKIP_ERRORS +SLAVE_TRANSACTION_RETRIES +SLAVE_TYPE_CONVERSIONS +SLOW_LAUNCH_TIME +SLOW_QUERY_LOG +SLOW_QUERY_LOG_FILE +SLOW_QUERY_LOG_TIMESTAMP_ALWAYS +SLOW_QUERY_LOG_TIMESTAMP_PRECISION +SLOW_QUERY_LOG_USE_GLOBAL_CONTROL +SOCKET +SORT_BUFFER_SIZE +SQL_AUTO_IS_NULL +SQL_BIG_SELECTS +SQL_BIG_TABLES +SQL_BUFFER_RESULT +SQL_LOG_BIN +SQL_LOG_OFF +SQL_LOW_PRIORITY_UPDATES +SQL_MAX_JOIN_SIZE +SQL_MODE +SQL_NOTES +SQL_QUOTE_SHOW_CREATE +SQL_SAFE_UPDATES +SQL_SELECT_LIMIT +SQL_SLAVE_SKIP_COUNTER +SQL_WARNINGS +SSL_CA +SSL_CAPATH +SSL_CERT +SSL_CIPHER +SSL_KEY +STORAGE_ENGINE +SYNC_BINLOG +SYNC_FRM +SYNC_MASTER_INFO +SYNC_RELAY_LOG +SYNC_RELAY_LOG_INFO +SYSTEM_TIME_ZONE +TABLE_DEFINITION_CACHE +TABLE_OPEN_CACHE +THREAD_CACHE_SIZE +THREAD_CONCURRENCY +THREAD_HANDLING +THREAD_STACK +THREAD_STATISTICS +TIMED_MUTEXES +TIMESTAMP +TIME_FORMAT +TIME_ZONE +TMPDIR +TMP_TABLE_SIZE +TRANSACTION_ALLOC_BLOCK_SIZE +TRANSACTION_PREALLOC_SIZE +TX_ISOLATION +UNIQUE_CHECKS +UPDATABLE_VIEWS_WITH_LIMIT +USERSTAT +VERSION +VERSION_COMMENT +VERSION_COMPILE_MACHINE +VERSION_COMPILE_OS +WAIT_TIMEOUT +WARNING_COUNT diff --git a/mysql-test/suite/percona/percona_server_variables_release.test b/mysql-test/suite/percona/percona_server_variables_release.test new file mode 100644 index 00000000000..f61446aeb02 --- /dev/null +++ b/mysql-test/suite/percona/percona_server_variables_release.test @@ -0,0 +1,2 @@ +--source include/have_nodebug.inc +--source include/percona_server_variables.inc diff --git a/mysql-test/suite/percona/percona_show_slave_status_nolock.result b/mysql-test/suite/percona/percona_show_slave_status_nolock.result new file mode 100644 index 00000000000..1d6114a001e --- /dev/null +++ b/mysql-test/suite/percona/percona_show_slave_status_nolock.result @@ -0,0 +1,21 @@ +include/master-slave.inc +[connection master] +DROP TABLE IF EXISTS t; +CREATE TABLE t(id INT); +INSERT INTO t SELECT SLEEP(10); +STOP SLAVE; +Warnings: +Note 1592 Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. +master count(*) +master 1 +slave count(*) +slave 0 +SHOW SLAVE STATUS NOLOCK; +include/wait_for_slave_to_stop.inc +START SLAVE; +include/wait_for_slave_to_start.inc +slave count(*) +slave 1 +DROP TABLE t; +STOP SLAVE; +include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/percona/percona_show_slave_status_nolock.test b/mysql-test/suite/percona/percona_show_slave_status_nolock.test new file mode 100644 index 00000000000..dcb2eb26a3e --- /dev/null +++ b/mysql-test/suite/percona/percona_show_slave_status_nolock.test @@ -0,0 +1,53 @@ +--source include/master-slave.inc +--source include/have_binlog_format_statement.inc +--disable_query_log +call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement:"); +call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group"); +--enable_query_log +connection master; + --disable_warnings + DROP TABLE IF EXISTS t; + --enable_warnings + CREATE TABLE t(id INT); + sync_slave_with_master; + +connection master; + send INSERT INTO t SELECT SLEEP(10); + +connection slave; + sleep 15; + send STOP SLAVE; + +connection master; + reap; + + --disable_query_log + select "master",count(*) from t; + --enable_query_log + +connection slave1; + --disable_query_log + select "slave",count(*) from t; + --enable_query_log + + --disable_result_log + SHOW SLAVE STATUS NOLOCK; + --enable_result_log + +connection slave; + reap; + + --source include/wait_for_slave_to_stop.inc + START SLAVE; + --source include/wait_for_slave_to_start.inc + + --disable_query_log + select "slave",count(*) from t; + --enable_query_log + +connection master; + DROP TABLE t; +sync_slave_with_master; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc + diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter-master.opt b/mysql-test/suite/percona/percona_slow_extended-log_slow_filter-master.opt similarity index 60% rename from mysql-test/suite/percona/percona_slow_query_log-log_slow_filter-master.opt rename to mysql-test/suite/percona/percona_slow_extended-log_slow_filter-master.opt index cb93f7abf05..865dc70ba38 100644 --- a/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter-master.opt +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_filter-master.opt @@ -1 +1 @@ ---slow-query-log-file=percona_slow_query_log-log_slow_filter.log --long-query-time=1 \ No newline at end of file +--slow-query-log-file=percona_slow_query_log-log_slow_filter.log --long-query-time=1 --slow_query_log=OFF diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.result b/mysql-test/suite/percona/percona_slow_extended-log_slow_filter.result similarity index 84% rename from mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.result rename to mysql-test/suite/percona/percona_slow_extended-log_slow_filter.result index 9c8f69745a7..2f22ef5457b 100644 --- a/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.result +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_filter.result @@ -1,4 +1,3 @@ -SET GLOBAL SLOW_QUERY_LOG=OFF; drop table if exists t; # Create test table create table t(id INT PRIMARY KEY) engine=InnoDB; @@ -20,6 +19,7 @@ sleep(2) SELECT sleep(2); sleep(2) 0 +SET GLOBAL SLOW_QUERY_LOG=OFF; drop table if exists t; -cat MYSQLD_DATADIR/percona_slow_query_log-log_slow_filter.log | grep -c Query_time +FLUSH LOGS; 2 diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test b/mysql-test/suite/percona/percona_slow_extended-log_slow_filter.test similarity index 64% rename from mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test rename to mysql-test/suite/percona/percona_slow_extended-log_slow_filter.test index 44646de530a..292c1651e34 100644 --- a/mysql-test/suite/percona/percona_slow_query_log-log_slow_filter.test +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_filter.test @@ -1,8 +1,4 @@ --- source include/not_windows.inc - -source include/have_innodb.inc; - -SET GLOBAL SLOW_QUERY_LOG=OFF; +source include/have_xtradb.inc; --disable_warnings drop table if exists t; @@ -24,12 +20,13 @@ set log_slow_filter=full_join; SELECT sleep(2) union select t2.id from t as t1,t as t2; SELECT sleep(2); +SET GLOBAL SLOW_QUERY_LOG=OFF; + --disable_warnings drop table if exists t; --enable_warnings -let $MYSQLD_DATADIR= `select @@datadir`; -let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-log_slow_filter.log | grep -c Query_time; ---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR -exec echo '$cmd'; -exec $cmd; +FLUSH LOGS; +--let grep_file = $MYSQLTEST_VARDIR/mysqld.1/data/percona_slow_query_log-log_slow_filter.log +--let grep_pattern = Query_time +--source grep.inc diff --git a/mysql-test/suite/percona/percona_slow_extended-log_slow_sp_statements-cl-master.opt b/mysql-test/suite/percona/percona_slow_extended-log_slow_sp_statements-cl-master.opt new file mode 100644 index 00000000000..4368453928a --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_sp_statements-cl-master.opt @@ -0,0 +1 @@ +--log_slow_sp_statements diff --git a/mysql-test/suite/percona/percona_slow_extended-log_slow_sp_statements-cl.result b/mysql-test/suite/percona/percona_slow_extended-log_slow_sp_statements-cl.result new file mode 100644 index 00000000000..c5653429327 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_sp_statements-cl.result @@ -0,0 +1,3 @@ +show global variables like 'log_slow_sp_statements'; +Variable_name Value +log_slow_sp_statements ON diff --git a/mysql-test/suite/percona/percona_slow_extended-log_slow_sp_statements-cl.test b/mysql-test/suite/percona/percona_slow_extended-log_slow_sp_statements-cl.test new file mode 100644 index 00000000000..47bd960feb5 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_sp_statements-cl.test @@ -0,0 +1 @@ +show global variables like 'log_slow_sp_statements'; diff --git a/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-cl-master.opt b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-cl-master.opt new file mode 100644 index 00000000000..d8809c36981 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-cl-master.opt @@ -0,0 +1 @@ +--log_slow_verbosity="full" diff --git a/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-cl.result b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-cl.result new file mode 100644 index 00000000000..eb8228efb08 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-cl.result @@ -0,0 +1,9 @@ +show global variables like 'log_slow_verbosity'; +Variable_name Value +log_slow_verbosity microtime,query_plan,innodb +show variables like 'log_slow_verbosity'; +Variable_name Value +log_slow_verbosity microtime,query_plan,innodb +select @@log_slow_verbosity; +@@log_slow_verbosity +microtime,query_plan,innodb diff --git a/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-cl.test b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-cl.test new file mode 100644 index 00000000000..740c4deaebd --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-cl.test @@ -0,0 +1,3 @@ +show global variables like 'log_slow_verbosity'; +show variables like 'log_slow_verbosity'; +select @@log_slow_verbosity; diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity-master.opt b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-master.opt similarity index 72% rename from mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity-master.opt rename to mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-master.opt index 8d21f40a34f..19ae9c117f0 100644 --- a/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity-master.opt +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity-master.opt @@ -1 +1 @@ ---slow-query-log-file=percona_slow_query_log-log_slow_verbosity.log --long-query-time=1 \ No newline at end of file +--slow-query-log-file=percona_slow_query_log-log_slow_verbosity.log --long-query-time=1 diff --git a/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity.result b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity.result new file mode 100644 index 00000000000..1e7db10c8bd --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity.result @@ -0,0 +1,9 @@ +SELECT sleep(2); +sleep(2) +0 +set log_slow_verbosity=innodb; +SELECT sleep(2); +sleep(2) +0 +FLUSH LOGS; +1 diff --git a/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity.test b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity.test new file mode 100644 index 00000000000..e95ab54af61 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-log_slow_verbosity.test @@ -0,0 +1,12 @@ +source include/have_xtradb.inc; + +SELECT sleep(2); + +set log_slow_verbosity=innodb; + +SELECT sleep(2); + +FLUSH LOGS; +--let grep_file = $MYSQLTEST_VARDIR/mysqld.1/data/percona_slow_query_log-log_slow_verbosity.log +--let grep_pattern = No InnoDB statistics available for this query +--source grep.inc diff --git a/mysql-test/suite/percona/percona_slow_query_log-long_query_time-master.opt b/mysql-test/suite/percona/percona_slow_extended-long_query_time-master.opt similarity index 60% rename from mysql-test/suite/percona/percona_slow_query_log-long_query_time-master.opt rename to mysql-test/suite/percona/percona_slow_extended-long_query_time-master.opt index 5cbb82d1261..62e1e981558 100644 --- a/mysql-test/suite/percona/percona_slow_query_log-long_query_time-master.opt +++ b/mysql-test/suite/percona/percona_slow_extended-long_query_time-master.opt @@ -1 +1 @@ ---slow-query-log-file=percona_slow_query_log-long_query_time.log --long-query-time=3 +--slow-query-log-file=percona_slow_query_log-long_query_time.log --long-query-time=2 --slow-query-log=OFF diff --git a/mysql-test/suite/percona/percona_slow_extended-long_query_time.result b/mysql-test/suite/percona/percona_slow_extended-long_query_time.result new file mode 100644 index 00000000000..f2da4e4d9d6 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-long_query_time.result @@ -0,0 +1,24 @@ +SET GLOBAL SLOW_QUERY_LOG=ON; +SELECT sleep(1); +sleep(1) +0 +SELECT sleep(3); +sleep(3) +0 +SELECT sleep(5); +sleep(5) +0 +set long_query_time=4; +SELECT sleep(1); +sleep(1) +0 +SELECT sleep(3); +sleep(3) +0 +SELECT sleep(5); +sleep(5) +0 +set long_query_time=2; +SET GLOBAL SLOW_QUERY_LOG=OFF; +FLUSH LOGS; +3 diff --git a/mysql-test/suite/percona/percona_slow_extended-long_query_time.test b/mysql-test/suite/percona/percona_slow_extended-long_query_time.test new file mode 100644 index 00000000000..716cc7cb0c3 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-long_query_time.test @@ -0,0 +1,23 @@ +source include/have_xtradb.inc; + +SET GLOBAL SLOW_QUERY_LOG=ON; + +SELECT sleep(1); +SELECT sleep(3); +SELECT sleep(5); + +set long_query_time=4; + +SELECT sleep(1); +SELECT sleep(3); +SELECT sleep(5); + +set long_query_time=2; + +SET GLOBAL SLOW_QUERY_LOG=OFF; + +FLUSH LOGS; +--let grep_file = $MYSQLTEST_VARDIR/mysqld.1/data/percona_slow_query_log-long_query_time.log +--let grep_pattern = Query_time +--source grep.inc + diff --git a/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log-master.opt b/mysql-test/suite/percona/percona_slow_extended-microseconds_in_slow_extended-master.opt similarity index 52% rename from mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log-master.opt rename to mysql-test/suite/percona/percona_slow_extended-microseconds_in_slow_extended-master.opt index 6433539d3d1..ca486d356f5 100644 --- a/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log-master.opt +++ b/mysql-test/suite/percona/percona_slow_extended-microseconds_in_slow_extended-master.opt @@ -1 +1 @@ ---slow-query-log-file=percona_slow_query_log-microseconds_in_slow_query_log.log --long-query-time=1 \ No newline at end of file +--slow-query-log-file=percona_slow_query_log-microseconds_in_slow_query_log.log --long-query-time=1 --slow_query_log=OFF diff --git a/mysql-test/suite/percona/percona_slow_extended-microseconds_in_slow_extended.result b/mysql-test/suite/percona/percona_slow_extended-microseconds_in_slow_extended.result new file mode 100644 index 00000000000..ce27c518efe --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-microseconds_in_slow_extended.result @@ -0,0 +1,13 @@ +SET GLOBAL SLOW_QUERY_LOG=ON; +SELECT sleep(2); +sleep(2) +0 +set global slow_query_log_timestamp_precision='microsecond'; +SELECT sleep(2); +sleep(2) +0 +set global slow_query_log_timestamp_precision='second'; +SET GLOBAL SLOW_QUERY_LOG=OFF; +FLUSH LOGS; +1 +2 diff --git a/mysql-test/suite/percona/percona_slow_extended-microseconds_in_slow_extended.test b/mysql-test/suite/percona/percona_slow_extended-microseconds_in_slow_extended.test new file mode 100644 index 00000000000..4b437b21e4c --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-microseconds_in_slow_extended.test @@ -0,0 +1,23 @@ +source include/have_xtradb.inc; + +SET GLOBAL SLOW_QUERY_LOG=ON; + +SELECT sleep(2); + +set global slow_query_log_timestamp_precision='microsecond'; + +SELECT sleep(2); + +set global slow_query_log_timestamp_precision='second'; + +SET GLOBAL SLOW_QUERY_LOG=OFF; + +FLUSH LOGS; +--let grep_file = $MYSQLTEST_VARDIR/mysqld.1/data/percona_slow_query_log-microseconds_in_slow_query_log.log +--let grep_pattern = # Time: [0-9]+[ ]+[0-9]+:[0-9]+:[0-9]+.[0-9]+ +--source grep.inc + +--let grep_file = $MYSQLTEST_VARDIR/mysqld.1/data/percona_slow_query_log-microseconds_in_slow_query_log.log +--let grep_pattern = # Time: [0-9]+[ ]+[0-9]+:[0-9]+:[0-9]+ +--source grep.inc + diff --git a/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit-master.opt b/mysql-test/suite/percona/percona_slow_extended-min_examined_row_limit-master.opt similarity index 56% rename from mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit-master.opt rename to mysql-test/suite/percona/percona_slow_extended-min_examined_row_limit-master.opt index 6f82556fb0c..c1cf3ebdb30 100644 --- a/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit-master.opt +++ b/mysql-test/suite/percona/percona_slow_extended-min_examined_row_limit-master.opt @@ -1 +1 @@ ---slow-query-log-file=percona_slow_query_log-min_examined_row_limit.log --long-query-time=1 \ No newline at end of file +--slow-query-log-file=percona_slow_query_log-min_examined_row_limit.log --long-query-time=1 --slow-query-log=OFF diff --git a/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.result b/mysql-test/suite/percona/percona_slow_extended-min_examined_row_limit.result similarity index 83% rename from mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.result rename to mysql-test/suite/percona/percona_slow_extended-min_examined_row_limit.result index 32698a59837..1e8bc0723ac 100644 --- a/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.result +++ b/mysql-test/suite/percona/percona_slow_extended-min_examined_row_limit.result @@ -1,4 +1,3 @@ -SET GLOBAL SLOW_QUERY_LOG=OFF; drop table if exists t; # Create test table create table t(id INT PRIMARY KEY) engine=InnoDB; @@ -20,6 +19,7 @@ sleep(2) SELECT sleep(2); sleep(2) 0 +SET GLOBAL SLOW_QUERY_LOG=OFF; drop table if exists t; -cat MYSQLD_DATADIR/percona_slow_query_log-min_examined_row_limit.log | grep -c Query_time +FLUSH LOGS; 2 diff --git a/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test b/mysql-test/suite/percona/percona_slow_extended-min_examined_row_limit.test similarity index 63% rename from mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test rename to mysql-test/suite/percona/percona_slow_extended-min_examined_row_limit.test index 61276423b4d..ca68658a6c5 100644 --- a/mysql-test/suite/percona/percona_slow_query_log-min_examined_row_limit.test +++ b/mysql-test/suite/percona/percona_slow_extended-min_examined_row_limit.test @@ -1,7 +1,4 @@ -source include/not_windows.inc; -source include/have_innodb.inc; - -SET GLOBAL SLOW_QUERY_LOG=OFF; +source include/have_xtradb.inc; --disable_warnings drop table if exists t; @@ -23,12 +20,13 @@ set min_examined_row_limit=5; SELECT sleep(2) union select t2.id from t as t1,t as t2; SELECT sleep(2); +SET GLOBAL SLOW_QUERY_LOG=OFF; + --disable_warnings drop table if exists t; --enable_warnings -let $MYSQLD_DATADIR= `select @@datadir`; -let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-min_examined_row_limit.log | grep -c Query_time; ---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR -exec echo '$cmd'; -exec $cmd; +FLUSH LOGS; +--let grep_file = $MYSQLTEST_VARDIR/mysqld.1/data/percona_slow_query_log-min_examined_row_limit.log +--let grep_pattern = Query_time +--source grep.inc diff --git a/mysql-test/suite/percona/percona_slave_innodb_stats-master.opt b/mysql-test/suite/percona/percona_slow_extended-slave_innodb_stats-master.opt similarity index 100% rename from mysql-test/suite/percona/percona_slave_innodb_stats-master.opt rename to mysql-test/suite/percona/percona_slow_extended-slave_innodb_stats-master.opt diff --git a/mysql-test/suite/percona/percona_slave_innodb_stats-slave.opt b/mysql-test/suite/percona/percona_slow_extended-slave_innodb_stats-slave.opt similarity index 100% rename from mysql-test/suite/percona/percona_slave_innodb_stats-slave.opt rename to mysql-test/suite/percona/percona_slow_extended-slave_innodb_stats-slave.opt diff --git a/mysql-test/suite/percona/percona_slave_innodb_stats.result b/mysql-test/suite/percona/percona_slow_extended-slave_innodb_stats.result similarity index 73% rename from mysql-test/suite/percona/percona_slave_innodb_stats.result rename to mysql-test/suite/percona/percona_slow_extended-slave_innodb_stats.result index c2406bdfd85..51993e767c2 100644 --- a/mysql-test/suite/percona/percona_slave_innodb_stats.result +++ b/mysql-test/suite/percona/percona_slow_extended-slave_innodb_stats.result @@ -1,9 +1,5 @@ -stop slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -reset master; -reset slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -start slave; +include/master-slave.inc +[connection master] DROP TABLE IF EXISTS t; CREATE TABLE t(id INT,data CHAR(30)) ENGINE=InnoDB; INSERT INTO t VALUES @@ -15,7 +11,12 @@ INSERT INTO t VALUES INSERT INTO t SELECT t2.id,t2.data from t as t1, t as t2; INSERT INTO t SELECT t2.id,t2.data from t as t1, t as t2; STOP SLAVE; +include/wait_for_slave_to_stop.inc START SLAVE; +include/wait_for_slave_to_start.inc INSERT INTO t SELECT t.id,t.data from t; DROP TABLE IF EXISTS t; +FLUSH LOGS; 4 +STOP SLAVE; +include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/percona/percona_slave_innodb_stats.test b/mysql-test/suite/percona/percona_slow_extended-slave_innodb_stats.test similarity index 75% rename from mysql-test/suite/percona/percona_slave_innodb_stats.test rename to mysql-test/suite/percona/percona_slow_extended-slave_innodb_stats.test index defcd1fc406..b0a6c98870c 100644 --- a/mysql-test/suite/percona/percona_slave_innodb_stats.test +++ b/mysql-test/suite/percona/percona_slow_extended-slave_innodb_stats.test @@ -1,5 +1,6 @@ -source include/have_innodb.inc; -source include/master-slave.inc; +-- source include/have_binlog_format_mixed_or_statement.inc +-- source include/have_xtradb.inc +-- source include/master-slave.inc connection master; -- disable_warnings @@ -40,4 +41,11 @@ connection master; DROP TABLE IF EXISTS t; sync_slave_with_master; -exec cat var/mysqld.2/mysqld-slow.log | grep InnoDB_IO_r_ops | wc -l; +connection slave; +FLUSH LOGS; +--let grep_file = $MYSQLTEST_VARDIR/mysqld.2/mysqld-slow.log +--let grep_pattern = InnoDB_IO_r_ops +--source grep.inc + +STOP SLAVE; +-- source include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-master.opt b/mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time-master.opt similarity index 73% rename from mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-master.opt rename to mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time-master.opt index d600400af08..49038530c56 100644 --- a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-master.opt +++ b/mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time-master.opt @@ -1 +1 @@ ---slow-query-log-file=percona_log_slow_slave_statements-master.log --long-query-time=1 \ No newline at end of file +--slow-query-log-file=percona_log_slow_slave_statements-master.log --long-query-time=1 diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-slave.opt b/mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time-slave.opt similarity index 74% rename from mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-slave.opt rename to mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time-slave.opt index c79e637317b..648f309f744 100644 --- a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time-slave.opt +++ b/mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time-slave.opt @@ -1 +1 @@ ---slow-query-log-file=percona_log_slow_slave_statements-slave.log --long-query-time=1 \ No newline at end of file +--slow-query-log-file=percona_log_slow_slave_statements-slave.log --long-query-time=1 diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.result b/mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time.result similarity index 58% rename from mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.result rename to mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time.result index c17e7a3f508..e5f4568dd58 100644 --- a/mysql-test/suite/percona/percona_log_slow_slave_statements-and-use_global_long_query_time.result +++ b/mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time.result @@ -1,19 +1,10 @@ -# Activate master-slave replication -stop slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -reset master; -reset slave; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -start slave; -# Make table t for test +include/master-slave.inc +[connection master] DROP TABLE IF EXISTS t; CREATE TABLE t(id INT); -# Start slave replication START SLAVE; +include/wait_for_slave_to_start.inc INSERT INTO t VALUES (1); -# Read information about master binlog -# Sync(1) slave thread -# Read and change log_slow_slave_statements to ON on slave show variables like 'log_slow_slave_statements'; Variable_name Value log_slow_slave_statements OFF @@ -22,23 +13,20 @@ show variables like 'log_slow_slave_statements'; Variable_name Value log_slow_slave_statements ON INSERT INTO t VALUES (2); -# Read information about master binlog -# Sync slave(2) thread -# Restart slave STOP SLAVE; +include/wait_for_slave_to_stop.inc START SLAVE; +include/wait_for_slave_to_start.inc INSERT INTO t VALUES (3); -# Read information about master binlog -# Sync(3) slave thread show variables like 'long_query_time'; Variable_name Value long_query_time 1.000000 show global variables like 'long_query_time'; Variable_name Value long_query_time 1.000000 -show global variables like 'use_global_long_query_time'; +show global variables like 'slow_query_log_use_global_control'; Variable_name Value -use_global_long_query_time OFF +slow_query_log_use_global_control set global long_query_time=0; show variables like 'long_query_time'; Variable_name Value @@ -46,51 +34,49 @@ long_query_time 1.000000 show global variables like 'long_query_time'; Variable_name Value long_query_time 0.000000 -show global variables like 'use_global_long_query_time'; +show global variables like 'slow_query_log_use_global_control'; Variable_name Value -use_global_long_query_time OFF +slow_query_log_use_global_control INSERT INTO t VALUES (4); -# Read information about master binlog -# Sync slave(4) thread show variables like 'long_query_time'; Variable_name Value long_query_time 1.000000 show global variables like 'long_query_time'; Variable_name Value long_query_time 0.000000 -show global variables like 'use_global_long_query_time'; +show global variables like 'slow_query_log_use_global_control'; Variable_name Value -use_global_long_query_time OFF -set global use_global_long_query_time=1; +slow_query_log_use_global_control +set global slow_query_log_use_global_control='long_query_time'; show variables like 'long_query_time'; Variable_name Value long_query_time 0.000000 show global variables like 'long_query_time'; Variable_name Value long_query_time 0.000000 -show global variables like 'use_global_long_query_time'; +show global variables like 'slow_query_log_use_global_control'; Variable_name Value -use_global_long_query_time ON +slow_query_log_use_global_control long_query_time INSERT INTO t VALUES (5); -# Read information about master binlog -# Sync slave(5) thread show variables like 'long_query_time'; Variable_name Value long_query_time 0.000000 show global variables like 'long_query_time'; Variable_name Value long_query_time 0.000000 -show global variables like 'use_global_long_query_time'; +show global variables like 'slow_query_log_use_global_control'; Variable_name Value -use_global_long_query_time ON +slow_query_log_use_global_control long_query_time set global long_query_time=1; -set global use_global_long_query_time=0; +set global slow_query_log_use_global_control=''; +FLUSH LOGS; # Analyse master slow_query_log 0 0 0 0 0 +FLUSH LOGS; # Analyse slave slow_query_log 0 0 @@ -99,5 +85,5 @@ set global use_global_long_query_time=0; 1 set global log_slow_slave_statements=OFF; DROP TABLE t; -# Read information about master binlog -# Sync slave(6) thread +STOP SLAVE; +include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time.test b/mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time.test new file mode 100644 index 00000000000..c718b2c3d28 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-slave_statements-and-use_global_long_query_time.test @@ -0,0 +1,107 @@ +-- source include/have_binlog_format_mixed_or_statement.inc +-- source include/master-slave.inc + +connection master; +-- disable_warnings +DROP TABLE IF EXISTS t; +-- enable_warnings +CREATE TABLE t(id INT); + +-- disable_warnings +connection slave; +START SLAVE; +-- source include/wait_for_slave_to_start.inc +-- enable_warnings + +connection master; +INSERT INTO t VALUES (1); +sync_slave_with_master; + +connection slave; +show variables like 'log_slow_slave_statements'; +set global log_slow_slave_statements=ON; +show variables like 'log_slow_slave_statements'; + +connection master; +INSERT INTO t VALUES (2); +sync_slave_with_master; +connection slave; + +STOP SLAVE; +-- source include/wait_for_slave_to_stop.inc +START SLAVE; +-- source include/wait_for_slave_to_start.inc + +connection master; +INSERT INTO t VALUES (3); +sync_slave_with_master; + +connection slave; +show variables like 'long_query_time'; +show global variables like 'long_query_time'; +show global variables like 'slow_query_log_use_global_control'; +set global long_query_time=0; +show variables like 'long_query_time'; +show global variables like 'long_query_time'; +show global variables like 'slow_query_log_use_global_control'; + +connection master; +INSERT INTO t VALUES (4); +sync_slave_with_master; + +connection slave; +show variables like 'long_query_time'; +show global variables like 'long_query_time'; +show global variables like 'slow_query_log_use_global_control'; +set global slow_query_log_use_global_control='long_query_time'; +show variables like 'long_query_time'; +show global variables like 'long_query_time'; +show global variables like 'slow_query_log_use_global_control'; + +#-- echo # Make insert(5) on master +connection master; +INSERT INTO t VALUES (5); +sync_slave_with_master; +connection slave; +show variables like 'long_query_time'; +show global variables like 'long_query_time'; +show global variables like 'slow_query_log_use_global_control'; +set global long_query_time=1; +set global slow_query_log_use_global_control=''; + +connection master; +FLUSH LOGS; + +-- echo # Analyse master slow_query_log +let $i=5; +let $k=1; +while($i) +{ + --let grep_file = $MYSQLTEST_VARDIR/mysqld.1/data/percona_log_slow_slave_statements-master.log + --let grep_pattern = INSERT INTO t VALUES \($k\) + --source grep.inc + dec $i; + inc $k; +} + +connection slave; +FLUSH LOGS; + +-- echo # Analyse slave slow_query_log +let $i=5; +let $k=1; +while($i) +{ + --let grep_file = $MYSQLTEST_VARDIR/mysqld.2/data/percona_log_slow_slave_statements-slave.log + --let grep_pattern = INSERT INTO t VALUES \($k\) + --source grep.inc + dec $i; + inc $k; +} +set global log_slow_slave_statements=OFF; + +connection master; +DROP TABLE t; +sync_slave_with_master; +STOP SLAVE; +-- source include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-master.opt b/mysql-test/suite/percona/percona_slow_extended-slave_statements-master.opt similarity index 73% rename from mysql-test/suite/percona/percona_log_slow_slave_statements-master.opt rename to mysql-test/suite/percona/percona_slow_extended-slave_statements-master.opt index dd94fd90a57..ebf25ddd37d 100644 --- a/mysql-test/suite/percona/percona_log_slow_slave_statements-master.opt +++ b/mysql-test/suite/percona/percona_slow_extended-slave_statements-master.opt @@ -1 +1 @@ ---slow-query-log-file=percona_log_slow_slave_statements-master.log --long-query-time=0 \ No newline at end of file +--slow-query-log-file=percona_log_slow_slave_statements-master.log --long-query-time=0 diff --git a/mysql-test/suite/percona/percona_log_slow_slave_statements-slave.opt b/mysql-test/suite/percona/percona_slow_extended-slave_statements-slave.opt similarity index 74% rename from mysql-test/suite/percona/percona_log_slow_slave_statements-slave.opt rename to mysql-test/suite/percona/percona_slow_extended-slave_statements-slave.opt index e276b0bcfc8..96cd9004493 100644 --- a/mysql-test/suite/percona/percona_log_slow_slave_statements-slave.opt +++ b/mysql-test/suite/percona/percona_slow_extended-slave_statements-slave.opt @@ -1 +1 @@ ---slow-query-log-file=percona_log_slow_slave_statements-slave.log --long-query-time=0 \ No newline at end of file +--slow-query-log-file=percona_log_slow_slave_statements-slave.log --long-query-time=0 diff --git a/mysql-test/suite/percona/percona_slow_extended-slave_statements.result b/mysql-test/suite/percona/percona_slow_extended-slave_statements.result new file mode 100644 index 00000000000..0548dc370b4 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-slave_statements.result @@ -0,0 +1,94 @@ +include/master-slave.inc +[connection master] +DROP TABLE IF EXISTS t; +CREATE TABLE t(id INT); +START SLAVE; +include/wait_for_slave_to_start.inc +INSERT INTO t VALUES (1); +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements OFF +set global log_slow_slave_statements=ON; +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements ON +INSERT INTO t VALUES (2); +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements ON +set global log_slow_slave_statements=ON; +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements ON +STOP SLAVE; +include/wait_for_slave_to_stop.inc +START SLAVE; +include/wait_for_slave_to_start.inc +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements ON +set global log_slow_slave_statements=ON; +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements ON +INSERT INTO t VALUES (3); +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements ON +set global log_slow_slave_statements=OFF; +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements OFF +INSERT INTO t VALUES (4); +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements OFF +STOP SLAVE; +include/wait_for_slave_to_stop.inc +START SLAVE; +include/wait_for_slave_to_start.inc +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements OFF +INSERT INTO t VALUES (5); +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements OFF +set global log_slow_slave_statements=ON; +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements ON +INSERT INTO t VALUES (6); +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements ON +STOP SLAVE; +include/wait_for_slave_to_stop.inc +START SLAVE; +include/wait_for_slave_to_start.inc +show variables like 'log_slow_slave_statements'; +Variable_name Value +log_slow_slave_statements ON +INSERT INTO t VALUES (7); +FLUSH LOGS; +# Analyse master slow_query_log +1 +1 +1 +1 +1 +1 +1 +FLUSH LOGS; +# Analyse slave slow_query_log +0 +0 +1 +0 +0 +0 +1 +set global log_slow_slave_statements=OFF; +DROP TABLE t; +STOP SLAVE; +include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/percona/percona_slow_extended-slave_statements.test b/mysql-test/suite/percona/percona_slow_extended-slave_statements.test new file mode 100644 index 00000000000..88c74bab69b --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-slave_statements.test @@ -0,0 +1,133 @@ +-- source include/have_binlog_format_statement.inc +-- source include/master-slave.inc + +connection master; +-- disable_warnings +DROP TABLE IF EXISTS t; +-- enable_warnings + +CREATE TABLE t(id INT); + +-- disable_warnings +connection slave; +START SLAVE; +-- source include/wait_for_slave_to_start.inc +-- enable_warnings + +connection master; +INSERT INTO t VALUES (1); +sync_slave_with_master; + +connection slave; +show variables like 'log_slow_slave_statements'; +set global log_slow_slave_statements=ON; +show variables like 'log_slow_slave_statements'; + +connection master; +INSERT INTO t VALUES (2); +sync_slave_with_master; + +connection slave; +show variables like 'log_slow_slave_statements'; +set global log_slow_slave_statements=ON; +show variables like 'log_slow_slave_statements'; + +STOP SLAVE; +-- source include/wait_for_slave_to_stop.inc +START SLAVE; +-- source include/wait_for_slave_to_start.inc + +connection slave; +show variables like 'log_slow_slave_statements'; +set global log_slow_slave_statements=ON; +show variables like 'log_slow_slave_statements'; + +connection master; +INSERT INTO t VALUES (3); +sync_slave_with_master; + +connection slave; +show variables like 'log_slow_slave_statements'; +set global log_slow_slave_statements=OFF; +show variables like 'log_slow_slave_statements'; + +connection master; +INSERT INTO t VALUES (4); +sync_slave_with_master; + +connection slave; +show variables like 'log_slow_slave_statements'; + +STOP SLAVE; +-- source include/wait_for_slave_to_stop.inc +START SLAVE; +-- source include/wait_for_slave_to_start.inc + +connection slave; +show variables like 'log_slow_slave_statements'; + +connection master; +INSERT INTO t VALUES (5); +sync_slave_with_master; + +connection slave; +show variables like 'log_slow_slave_statements'; +set global log_slow_slave_statements=ON; +show variables like 'log_slow_slave_statements'; + +connection master; +INSERT INTO t VALUES (6); +sync_slave_with_master; + +connection slave; +show variables like 'log_slow_slave_statements'; + +STOP SLAVE; +-- source include/wait_for_slave_to_stop.inc +START SLAVE; +-- source include/wait_for_slave_to_start.inc + +connection slave; +show variables like 'log_slow_slave_statements'; + +connection master; +INSERT INTO t VALUES (7); +sync_slave_with_master; + +connection master; +FLUSH LOGS; + +-- echo # Analyse master slow_query_log +let $i=7; +let $k=1; +while($i) +{ + --let grep_file = $MYSQLTEST_VARDIR/mysqld.1/data/percona_log_slow_slave_statements-master.log + --let grep_pattern = INSERT INTO t VALUES \($k\) + --source grep.inc + dec $i; + inc $k; +} + +connection slave; +FLUSH LOGS; + +-- echo # Analyse slave slow_query_log +let $i=7; +let $k=1; +while($i) +{ + --let grep_file = $MYSQLTEST_VARDIR/mysqld.2/data/percona_log_slow_slave_statements-slave.log + --let grep_pattern = INSERT INTO t VALUES \($k\) + --source grep.inc + dec $i; + inc $k; +} +set global log_slow_slave_statements=OFF; + +connection master; +DROP TABLE t; +sync_slave_with_master; + +STOP SLAVE; +-- source include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/percona/percona_slow_extended-slow_query_log_microseconds_timestamp-cl-master.opt b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_microseconds_timestamp-cl-master.opt new file mode 100644 index 00000000000..c3ebcd95326 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_microseconds_timestamp-cl-master.opt @@ -0,0 +1 @@ +--slow_query_log_timestamp_precision='microsecond' diff --git a/mysql-test/suite/percona/percona_slow_extended-slow_query_log_microseconds_timestamp-cl.result b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_microseconds_timestamp-cl.result new file mode 100644 index 00000000000..5355922bb45 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_microseconds_timestamp-cl.result @@ -0,0 +1,3 @@ +show global variables like 'slow_query_log_timestamp_precision'; +Variable_name Value +slow_query_log_timestamp_precision microsecond diff --git a/mysql-test/suite/percona/percona_slow_extended-slow_query_log_microseconds_timestamp-cl.test b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_microseconds_timestamp-cl.test new file mode 100644 index 00000000000..8f6291e9897 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_microseconds_timestamp-cl.test @@ -0,0 +1 @@ +show global variables like 'slow_query_log_timestamp_precision'; diff --git a/mysql-test/suite/percona/percona_slow_extended-slow_query_log_timestamp_always-cl-master.opt b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_timestamp_always-cl-master.opt new file mode 100644 index 00000000000..233b50a1f89 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_timestamp_always-cl-master.opt @@ -0,0 +1 @@ +--slow_query_log_timestamp_always diff --git a/mysql-test/suite/percona/percona_slow_extended-slow_query_log_timestamp_always-cl.result b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_timestamp_always-cl.result new file mode 100644 index 00000000000..13684fad10c --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_timestamp_always-cl.result @@ -0,0 +1,3 @@ +show global variables like 'slow_query_log_timestamp_always'; +Variable_name Value +slow_query_log_timestamp_always ON diff --git a/mysql-test/suite/percona/percona_slow_extended-slow_query_log_timestamp_always-cl.test b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_timestamp_always-cl.test new file mode 100644 index 00000000000..e73c4202869 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-slow_query_log_timestamp_always-cl.test @@ -0,0 +1 @@ +show global variables like 'slow_query_log_timestamp_always'; diff --git a/mysql-test/suite/percona/percona_slow_query_log-control_global_slow-master.opt b/mysql-test/suite/percona/percona_slow_extended-use_global_control-master.opt similarity index 71% rename from mysql-test/suite/percona/percona_slow_query_log-control_global_slow-master.opt rename to mysql-test/suite/percona/percona_slow_extended-use_global_control-master.opt index 91dd41305cd..bd62c08c475 100644 --- a/mysql-test/suite/percona/percona_slow_query_log-control_global_slow-master.opt +++ b/mysql-test/suite/percona/percona_slow_extended-use_global_control-master.opt @@ -1 +1 @@ ---slow-query-log-file=percona_slow_query_log-control_global_slow.log --long-query-time=1 \ No newline at end of file +--slow-query-log-file=percona_slow_query_log-control_global_slow.log --long-query-time=1 diff --git a/mysql-test/suite/percona/percona_slow_extended-use_global_control.result b/mysql-test/suite/percona/percona_slow_extended-use_global_control.result new file mode 100644 index 00000000000..699c95e9671 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-use_global_control.result @@ -0,0 +1,12 @@ +SELECT sleep(2); +sleep(2) +0 +set global log_slow_verbosity=innodb; +set global slow_query_log_use_global_control="log_slow_verbosity,long_query_time"; +SELECT sleep(2); +sleep(2) +0 +set global slow_query_log_use_global_control=''; +set global log_slow_verbosity=''; +FLUSH LOGS; +1 diff --git a/mysql-test/suite/percona/percona_slow_extended-use_global_control.test b/mysql-test/suite/percona/percona_slow_extended-use_global_control.test new file mode 100644 index 00000000000..199b652561c --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-use_global_control.test @@ -0,0 +1,12 @@ +source include/have_xtradb.inc; +SELECT sleep(2); +set global log_slow_verbosity=innodb; +set global slow_query_log_use_global_control="log_slow_verbosity,long_query_time"; +SELECT sleep(2); +set global slow_query_log_use_global_control=''; +set global log_slow_verbosity=''; + +FLUSH LOGS; +--let grep_file = $MYSQLTEST_VARDIR/mysqld.1/data/percona_slow_query_log-control_global_slow.log +--let grep_pattern = No InnoDB statistics available for this query +--source grep.inc diff --git a/mysql-test/suite/percona/percona_slow_extended-use_global_long_query_time-master.opt b/mysql-test/suite/percona/percona_slow_extended-use_global_long_query_time-master.opt new file mode 100644 index 00000000000..16b6ca5b714 --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-use_global_long_query_time-master.opt @@ -0,0 +1 @@ +--slow-query-log-file=percona_slow_query_log-use_global_long_query_time.log --long-query-time=2 --slow_query_log_use_global_control=long_query_time --slow-query-log=OFF diff --git a/mysql-test/suite/percona/percona_slow_extended-use_global_long_query_time.result b/mysql-test/suite/percona/percona_slow_extended-use_global_long_query_time.result new file mode 100644 index 00000000000..e89edf0430f --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-use_global_long_query_time.result @@ -0,0 +1,46 @@ +SET GLOBAL SLOW_QUERY_LOG=ON; +SELECT sleep(1); +sleep(1) +0 +SELECT sleep(3); +sleep(3) +0 +SELECT sleep(5); +sleep(5) +0 +set global long_query_time=4; +set global slow_query_log_use_global_control='long_query_time'; +SELECT sleep(1); +sleep(1) +0 +SELECT sleep(3); +sleep(3) +0 +SELECT sleep(5); +sleep(5) +0 +set global long_query_time=2; +set global slow_query_log_use_global_control=''; +SET GLOBAL SLOW_QUERY_LOG=OFF; +FLUSH LOGS; +3 +show global variables like 'slow_query_log_use_global_control'; +Variable_name Value +slow_query_log_use_global_control +set global slow_query_log_use_global_control='long_query_time'; +show global variables like 'slow_query_log_use_global_control'; +Variable_name Value +slow_query_log_use_global_control long_query_time +set global slow_query_log_use_global_control='log_slow_filter,long_query_time'; +show global variables like 'slow_query_log_use_global_control'; +Variable_name Value +slow_query_log_use_global_control log_slow_filter,long_query_time +set global slow_query_log_use_global_control='log_slow_filter'; +show global variables like 'slow_query_log_use_global_control'; +Variable_name Value +slow_query_log_use_global_control log_slow_filter +set global slow_query_log_use_global_control=''; +show global variables like 'slow_query_log_use_global_control'; +Variable_name Value +slow_query_log_use_global_control +set global slow_query_log_use_global_control='long_query_time'; diff --git a/mysql-test/suite/percona/percona_slow_extended-use_global_long_query_time.test b/mysql-test/suite/percona/percona_slow_extended-use_global_long_query_time.test new file mode 100644 index 00000000000..61b2dabd23d --- /dev/null +++ b/mysql-test/suite/percona/percona_slow_extended-use_global_long_query_time.test @@ -0,0 +1,40 @@ +source include/have_xtradb.inc; + +SET GLOBAL SLOW_QUERY_LOG=ON; + +SELECT sleep(1); +SELECT sleep(3); +SELECT sleep(5); + +set global long_query_time=4; +set global slow_query_log_use_global_control='long_query_time'; + +SELECT sleep(1); +SELECT sleep(3); +SELECT sleep(5); + +set global long_query_time=2; +set global slow_query_log_use_global_control=''; + +SET GLOBAL SLOW_QUERY_LOG=OFF; + +FLUSH LOGS; +--let grep_file = $MYSQLTEST_VARDIR/mysqld.1/data/percona_slow_query_log-use_global_long_query_time.log +--let grep_pattern = Query_time +--source grep.inc + +show global variables like 'slow_query_log_use_global_control'; + +set global slow_query_log_use_global_control='long_query_time'; +show global variables like 'slow_query_log_use_global_control'; + +set global slow_query_log_use_global_control='log_slow_filter,long_query_time'; +show global variables like 'slow_query_log_use_global_control'; + +set global slow_query_log_use_global_control='log_slow_filter'; +show global variables like 'slow_query_log_use_global_control'; + +set global slow_query_log_use_global_control=''; +show global variables like 'slow_query_log_use_global_control'; + +set global slow_query_log_use_global_control='long_query_time'; diff --git a/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.result b/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.result deleted file mode 100644 index bc6ce100b35..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.result +++ /dev/null @@ -1,12 +0,0 @@ -SELECT sleep(2); -sleep(2) -0 -set global log_slow_verbosity=innodb; -set global use_global_log_slow_control="log_slow_verbosity,long_query_time"; -SELECT sleep(2); -sleep(2) -0 -set global use_global_log_slow_control=none; -set global log_slow_verbosity=microtime; -cat MYSQLD_DATADIR/percona_slow_query_log-control_global_slow.log | grep -c "No InnoDB statistics available for this query" -1 diff --git a/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test b/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test deleted file mode 100644 index 1c3dc937937..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-control_global_slow.test +++ /dev/null @@ -1,14 +0,0 @@ ---source include/not_windows.inc - -source include/have_innodb.inc; -SELECT sleep(2); -set global log_slow_verbosity=innodb; -set global use_global_log_slow_control="log_slow_verbosity,long_query_time"; -SELECT sleep(2); -set global use_global_log_slow_control=none; -set global log_slow_verbosity=microtime; -let $MYSQLD_DATADIR= `select @@datadir`; -let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-control_global_slow.log | grep -c "No InnoDB statistics available for this query"; ---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR -exec echo '$cmd'; -exec $cmd; diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.result b/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.result deleted file mode 100644 index ff42937fa4a..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.result +++ /dev/null @@ -1,9 +0,0 @@ -SELECT sleep(2); -sleep(2) -0 -set log_slow_verbosity=innodb; -SELECT sleep(2); -sleep(2) -0 -cat MYSQLD_DATADIR/percona_slow_query_log-log_slow_verbosity.log | grep -c "No InnoDB statistics available for this query" -1 diff --git a/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test b/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test deleted file mode 100644 index d1dc324fced..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-log_slow_verbosity.test +++ /dev/null @@ -1,15 +0,0 @@ --- source include/not_windows.inc - -source include/have_innodb.inc; - -SELECT sleep(2); - -set log_slow_verbosity=innodb; - -SELECT sleep(2); - -let $MYSQLD_DATADIR= `select @@datadir`; -let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-log_slow_verbosity.log | grep -c "No InnoDB statistics available for this query"; ---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR -exec echo '$cmd'; -exec $cmd; diff --git a/mysql-test/suite/percona/percona_slow_query_log-long_query_time.result b/mysql-test/suite/percona/percona_slow_query_log-long_query_time.result deleted file mode 100644 index 03f8745ca62..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-long_query_time.result +++ /dev/null @@ -1,21 +0,0 @@ -SELECT sleep(1); -sleep(1) -0 -SELECT sleep(6); -sleep(6) -0 -SELECT sleep(10); -sleep(10) -0 -set long_query_time=8; -SELECT sleep(1); -sleep(1) -0 -SELECT sleep(6); -sleep(6) -0 -SELECT sleep(12); -sleep(12) -0 -cat MYSQLD_DATADIR/percona_slow_query_log-long_query_time.log | grep -c Query_time -3 diff --git a/mysql-test/suite/percona/percona_slow_query_log-long_query_time.test b/mysql-test/suite/percona/percona_slow_query_log-long_query_time.test deleted file mode 100644 index 4161690e2ef..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-long_query_time.test +++ /dev/null @@ -1,18 +0,0 @@ -source include/not_windows.inc; -source include/have_innodb.inc; - -SELECT sleep(1); -SELECT sleep(6); -SELECT sleep(10); - -set long_query_time=8; - -SELECT sleep(1); -SELECT sleep(6); -SELECT sleep(12); - -let $MYSQLD_DATADIR= `select @@datadir`; -let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-long_query_time.log | grep -c Query_time; ---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR -exec echo '$cmd'; -exec $cmd; diff --git a/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.result b/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.result deleted file mode 100644 index fbfc954481e..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.result +++ /dev/null @@ -1,12 +0,0 @@ -SELECT sleep(2); -sleep(2) -0 -set global slow_query_log_microseconds_timestamp=ON; -SELECT sleep(2); -sleep(2) -0 -set global slow_query_log_microseconds_timestamp=OFF; -cat MYSQLD_DATADIR/percona_slow_query_log-microseconds_in_slow_query_log.log | grep -E -c '# Time: [0-9]+[ ]+[0-9]+:[0-\9]+:[0-9]+.[0-9]+' -1 -cat MYSQLD_DATADIR/percona_slow_query_log-microseconds_in_slow_query_log.log | grep -E -c '# Time: [0-9]+[ ]+[0-9]+:[0-\9]+:[0-9]+' -2 diff --git a/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test b/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test deleted file mode 100644 index bceada68d79..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-microseconds_in_slow_query_log.test +++ /dev/null @@ -1,21 +0,0 @@ -source include/not_windows.inc; -source include/have_innodb.inc; - -SELECT sleep(2); - -set global slow_query_log_microseconds_timestamp=ON; - -SELECT sleep(2); - -set global slow_query_log_microseconds_timestamp=OFF; - -let $MYSQLD_DATADIR= `select @@datadir`; -let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-microseconds_in_slow_query_log.log | grep -E -c '# Time: [0-9]+[ ]+[0-9]+:[0-\9]+:[0-9]+.[0-9]+'; ---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR -exec echo "$cmd"; -exec $cmd; - -let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-microseconds_in_slow_query_log.log | grep -E -c '# Time: [0-9]+[ ]+[0-9]+:[0-\9]+:[0-9]+'; ---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR -exec echo "$cmd"; -exec $cmd; diff --git a/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time-master.opt b/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time-master.opt deleted file mode 100644 index e2f3b6f2041..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time-master.opt +++ /dev/null @@ -1 +0,0 @@ ---slow-query-log-file=percona_slow_query_log-use_global_long_query_time.log --long-query-time=2 \ No newline at end of file diff --git a/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.result b/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.result deleted file mode 100644 index e294525fdd2..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.result +++ /dev/null @@ -1,59 +0,0 @@ -SELECT sleep(1); -sleep(1) -0 -SELECT sleep(3); -sleep(3) -0 -SELECT sleep(5); -sleep(5) -0 -set global long_query_time=4; -set global use_global_long_query_time=1; -SELECT sleep(1); -sleep(1) -0 -SELECT sleep(3); -sleep(3) -0 -SELECT sleep(5); -sleep(5) -0 -set global long_query_time=2; -set global use_global_long_query_time=0; -cat MYSQLD_DATADIR/percona_slow_query_log-use_global_long_query_time.log | grep -c Query_time -3 -show global variables like 'use_global_log_slow_control'; -Variable_name Value -use_global_log_slow_control none -show global variables like 'use_global_long_query_time'; -Variable_name Value -use_global_long_query_time OFF -set global use_global_log_slow_control = long_query_time; -show global variables like 'use_global_log_slow_control'; -Variable_name Value -use_global_log_slow_control long_query_time -show global variables like 'use_global_long_query_time'; -Variable_name Value -use_global_long_query_time ON -set global use_global_log_slow_control = log_slow_filter; -show global variables like 'use_global_log_slow_control'; -Variable_name Value -use_global_log_slow_control log_slow_filter -show global variables like 'use_global_long_query_time'; -Variable_name Value -use_global_long_query_time OFF -set global use_global_long_query_time = ON; -show global variables like 'use_global_log_slow_control'; -Variable_name Value -use_global_log_slow_control log_slow_filter,long_query_time -show global variables like 'use_global_long_query_time'; -Variable_name Value -use_global_long_query_time ON -set global use_global_long_query_time = OFF; -show global variables like 'use_global_log_slow_control'; -Variable_name Value -use_global_log_slow_control log_slow_filter -show global variables like 'use_global_long_query_time'; -Variable_name Value -use_global_long_query_time OFF -set global use_global_log_slow_control = none; diff --git a/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test b/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test deleted file mode 100644 index da627ae72b0..00000000000 --- a/mysql-test/suite/percona/percona_slow_query_log-use_global_long_query_time.test +++ /dev/null @@ -1,43 +0,0 @@ -source include/not_windows.inc; -source include/have_innodb.inc; - -SELECT sleep(1); -SELECT sleep(3); -SELECT sleep(5); - -set global long_query_time=4; -set global use_global_long_query_time=1; - -SELECT sleep(1); -SELECT sleep(3); -SELECT sleep(5); - -set global long_query_time=2; -set global use_global_long_query_time=0; - -let $MYSQLD_DATADIR= `select @@datadir`; -let $cmd = cat $MYSQLD_DATADIR/percona_slow_query_log-use_global_long_query_time.log | grep -c Query_time; ---replace_result $MYSQLD_DATADIR MYSQLD_DATADIR -exec echo '$cmd'; -exec $cmd; - -show global variables like 'use_global_log_slow_control'; -show global variables like 'use_global_long_query_time'; - -set global use_global_log_slow_control = long_query_time; -show global variables like 'use_global_log_slow_control'; -show global variables like 'use_global_long_query_time'; - -set global use_global_log_slow_control = log_slow_filter; -show global variables like 'use_global_log_slow_control'; -show global variables like 'use_global_long_query_time'; - -set global use_global_long_query_time = ON; -show global variables like 'use_global_log_slow_control'; -show global variables like 'use_global_long_query_time'; - -set global use_global_long_query_time = OFF; -show global variables like 'use_global_log_slow_control'; -show global variables like 'use_global_long_query_time'; - -set global use_global_log_slow_control = none; diff --git a/mysql-test/suite/percona/percona_sql_no_fcache.test b/mysql-test/suite/percona/percona_sql_no_fcache.test index da0c2ecef7d..1ed8be2196b 100644 --- a/mysql-test/suite/percona/percona_sql_no_fcache.test +++ b/mysql-test/suite/percona/percona_sql_no_fcache.test @@ -8,4 +8,4 @@ insert into t values (1),(2),(3); SELECT SQL_NO_FCACHE SLEEP(0); SELECT /*!40001 SQL_NO_CACHE */ /*!50084 SQL_NO_FCACHE */ * FROM t; -DROP TABLE t; \ No newline at end of file +DROP TABLE t; diff --git a/mysql-test/suite/percona/percona_status_wait_query_cache_mutex.result b/mysql-test/suite/percona/percona_status_wait_query_cache_mutex.result index 348dcef4d30..f951428abc7 100644 --- a/mysql-test/suite/percona/percona_status_wait_query_cache_mutex.result +++ b/mysql-test/suite/percona/percona_status_wait_query_cache_mutex.result @@ -18,10 +18,10 @@ SET SESSION debug="+d,status_wait_query_cache_mutex_sleep"; SELECT number from t where id > 0; SET SESSION debug="+d,status_wait_query_cache_mutex_sleep"; SHOW PROCESSLIST; -Id User Host db Command Time State Info -Id root localhost test Sleep Time NULL -Id root localhost test Query Time Waiting on query cache mutex SELECT number from t where id > 0 -Id root localhost test Query Time Waiting on query cache mutex SELECT number from t where id > 0 -Id root localhost test Query Time NULL SHOW PROCESSLIST +Id User Host db Command Time State Info Rows_sent Rows_examined Rows_read +Id root localhost test Sleep Time NULL Rows_sent Rows_examined Rows_read +Id root localhost test Query Time Waiting on query cache mutex SELECT number from t where id > 0 Rows_sent Rows_examined Rows_read +Id root localhost test Query Time Waiting on query cache mutex SELECT number from t where id > 0 Rows_sent Rows_examined Rows_read +Id root localhost test Query Time NULL SHOW PROCESSLIST Rows_sent Rows_examined Rows_read DROP TABLE t; set GLOBAL query_cache_size=0; diff --git a/mysql-test/suite/percona/percona_status_wait_query_cache_mutex.test b/mysql-test/suite/percona/percona_status_wait_query_cache_mutex.test index 64a9fe7db71..35e2d0ac549 100644 --- a/mysql-test/suite/percona/percona_status_wait_query_cache_mutex.test +++ b/mysql-test/suite/percona/percona_status_wait_query_cache_mutex.test @@ -30,8 +30,8 @@ SLEEP 1.0; --connection conn2 --error 0, ER_UNKNOWN_SYSTEM_VARIABLE SET SESSION debug="+d,status_wait_query_cache_mutex_sleep"; ---replace_column 1 Id 6 Time +--replace_column 1 Id 6 Time 9 Rows_sent 10 Rows_examined 11 Rows_read SHOW PROCESSLIST; DROP TABLE t; -set GLOBAL query_cache_size=0; \ No newline at end of file +set GLOBAL query_cache_size=0; diff --git a/mysql-test/suite/percona/percona_suppress_log_warning_1592.result b/mysql-test/suite/percona/percona_suppress_log_warning_1592.result deleted file mode 100644 index 4715499b08f..00000000000 --- a/mysql-test/suite/percona/percona_suppress_log_warning_1592.result +++ /dev/null @@ -1,28 +0,0 @@ -SET @old_log_warnings = @@log_warnings; -SET @old_suppress_log_warning_1592 = @@suppress_log_warning_1592; -DROP TABLE IF EXISTS t1; -CREATE TABLE t1 (a VARCHAR(36), b VARCHAR(20)); -SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 0; -SET GLOBAL LOG_WARNINGS = 0; -INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); -Warnings: -Note 1592 Statement may not be safe to log in statement format. -SET GLOBAL LOG_WARNINGS = 1; -INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); -Warnings: -Note 1592 Statement may not be safe to log in statement format. -SET GLOBAL SUPPRESS_LOG_WARNING_1592 = 1; -SET GLOBAL LOG_WARNINGS = 0; -INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); -Warnings: -Note 1592 Statement may not be safe to log in statement format. -SET GLOBAL LOG_WARNINGS = 1; -INSERT INTO t1 VALUES(UUID(), 'suppress_1592'); -Warnings: -Note 1592 Statement may not be safe to log in statement format. -DROP TABLE t1; -SET GLOBAL log_warnings = @old_log_warnings; -SET GLOBAL suppress_log_warning_1592 = @old_suppress_log_warning_1592; -# Count the number of times the "Unsafe" message was printed -# to the error log. -Occurrences: 1 diff --git a/mysql-test/suite/percona/percona_xtradb_bug317074.result b/mysql-test/suite/percona/percona_xtradb_bug317074.result index 82a98844652..7c1876fb7bf 100644 --- a/mysql-test/suite/percona/percona_xtradb_bug317074.result +++ b/mysql-test/suite/percona/percona_xtradb_bug317074.result @@ -1,4 +1,5 @@ SET @old_innodb_file_format=@@innodb_file_format; +SET @old_innodb_file_format_max=@@innodb_file_format_max; SET @old_innodb_file_per_table=@@innodb_file_per_table; SET GLOBAL innodb_file_format='Barracuda'; SET GLOBAL innodb_file_per_table=ON; diff --git a/mysql-test/suite/percona/percona_xtradb_bug317074.test b/mysql-test/suite/percona/percona_xtradb_bug317074.test index 029e0f8fcdf..5f9db073060 100644 --- a/mysql-test/suite/percona/percona_xtradb_bug317074.test +++ b/mysql-test/suite/percona/percona_xtradb_bug317074.test @@ -1,8 +1,8 @@ -- source include/have_xtradb.inc SET @old_innodb_file_format=@@innodb_file_format; +SET @old_innodb_file_format_max=@@innodb_file_format_max; SET @old_innodb_file_per_table=@@innodb_file_per_table; -let $innodb_file_format_check_orig=`select @@innodb_file_format_check`; SET GLOBAL innodb_file_format='Barracuda'; SET GLOBAL innodb_file_per_table=ON; @@ -44,5 +44,5 @@ ALTER TABLE test1 ENGINE=MyISAM; DROP TABLE test1; SET GLOBAL innodb_file_format=@old_innodb_file_format; +SET GLOBAL innodb_file_format_max=@old_innodb_file_format_max; SET GLOBAL innodb_file_per_table=@old_innodb_file_per_table; -eval set global innodb_file_format_check=$innodb_file_format_check_orig; diff --git a/mysql-test/suite/percona/userstat_bug602047.result b/mysql-test/suite/percona/userstat_bug602047.result new file mode 100644 index 00000000000..966439b817d --- /dev/null +++ b/mysql-test/suite/percona/userstat_bug602047.result @@ -0,0 +1,15 @@ +DROP TABLE IF EXISTS t1; +SET GLOBAL userstat=ON; +CREATE TABLE t1 ( id int(10), PRIMARY KEY (id)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +SELECT COUNT(*) FROM t1; +COUNT(*) +10 +SELECT ROWS_READ FROM information_schema.table_statistics WHERE TABLE_NAME='t1'; +ROWS_READ +10 +SELECT ROWS_READ FROM information_schema.index_statistics WHERE TABLE_NAME='t1'; +ROWS_READ +10 +SET GLOBAL userstat=OFF; +DROP TABLE t1; diff --git a/mysql-test/suite/percona/userstat_bug602047.test b/mysql-test/suite/percona/userstat_bug602047.test new file mode 100644 index 00000000000..31fc36b80e2 --- /dev/null +++ b/mysql-test/suite/percona/userstat_bug602047.test @@ -0,0 +1,12 @@ +--source include/have_xtradb.inc +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +SET GLOBAL userstat=ON; +CREATE TABLE t1 ( id int(10), PRIMARY KEY (id)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); +SELECT COUNT(*) FROM t1; +SELECT ROWS_READ FROM information_schema.table_statistics WHERE TABLE_NAME='t1'; +SELECT ROWS_READ FROM information_schema.index_statistics WHERE TABLE_NAME='t1'; +SET GLOBAL userstat=OFF; +DROP TABLE t1; diff --git a/mysql-test/suite/sys_vars/r/innodb_adaptive_flushing_method_basic.result b/mysql-test/suite/sys_vars/r/innodb_adaptive_flushing_method_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_adaptive_flushing_method_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_partitions_basic.result b/mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_partitions_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_adaptive_hash_index_partitions_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_buffer_pool_restore_at_startup_basic.result b/mysql-test/suite/sys_vars/r/innodb_buffer_pool_restore_at_startup_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_buffer_pool_restore_at_startup_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_buffer_pool_shm_checksum_basic.result b/mysql-test/suite/sys_vars/r/innodb_buffer_pool_shm_checksum_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_buffer_pool_shm_checksum_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_buffer_pool_shm_key_basic.result b/mysql-test/suite/sys_vars/r/innodb_buffer_pool_shm_key_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_buffer_pool_shm_key_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_checkpoint_age_target_basic.result b/mysql-test/suite/sys_vars/r/innodb_checkpoint_age_target_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_checkpoint_age_target_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_corrupt_table_action_basic.result b/mysql-test/suite/sys_vars/r/innodb_corrupt_table_action_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_corrupt_table_action_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_dict_size_limit_basic.result b/mysql-test/suite/sys_vars/r/innodb_dict_size_limit_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_dict_size_limit_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_doublewrite_file_basic.result b/mysql-test/suite/sys_vars/r/innodb_doublewrite_file_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_doublewrite_file_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_fast_checksum_basic.result b/mysql-test/suite/sys_vars/r/innodb_fast_checksum_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_fast_checksum_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result b/mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_file_format_max_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_flush_log_at_trx_commit_basic.result b/mysql-test/suite/sys_vars/r/innodb_flush_log_at_trx_commit_basic.result index eabafb26ccb..441fb4cd362 100644 --- a/mysql-test/suite/sys_vars/r/innodb_flush_log_at_trx_commit_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_flush_log_at_trx_commit_basic.result @@ -9,11 +9,6 @@ SELECT @@global.innodb_flush_log_at_trx_commit; @@global.innodb_flush_log_at_trx_commit 1 '#---------------------FN_DYNVARS_046_02-------------------------#' -SET innodb_flush_log_at_trx_commit = 1; -ERROR HY000: Variable 'innodb_flush_log_at_trx_commit' is a GLOBAL variable and should be set with SET GLOBAL -SELECT @@innodb_flush_log_at_trx_commit; -@@innodb_flush_log_at_trx_commit -1 SELECT local.innodb_flush_log_at_trx_commit; ERROR 42S02: Unknown table 'local' in field list SET global innodb_flush_log_at_trx_commit = 0; diff --git a/mysql-test/suite/sys_vars/r/innodb_flush_neighbor_pages_basic.result b/mysql-test/suite/sys_vars/r/innodb_flush_neighbor_pages_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_flush_neighbor_pages_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_ibuf_accel_rate_basic.result b/mysql-test/suite/sys_vars/r/innodb_ibuf_accel_rate_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_ibuf_accel_rate_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_ibuf_active_contract_basic.result b/mysql-test/suite/sys_vars/r/innodb_ibuf_active_contract_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_ibuf_active_contract_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_ibuf_max_size_basic.result b/mysql-test/suite/sys_vars/r/innodb_ibuf_max_size_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_ibuf_max_size_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_import_table_from_xtrabackup_basic.result b/mysql-test/suite/sys_vars/r/innodb_import_table_from_xtrabackup_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_import_table_from_xtrabackup_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result b/mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_large_prefix_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_lazy_drop_table_basic.result b/mysql-test/suite/sys_vars/r/innodb_lazy_drop_table_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_lazy_drop_table_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_log_block_size_basic.result b/mysql-test/suite/sys_vars/r/innodb_log_block_size_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_log_block_size_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_page_size_basic.result b/mysql-test/suite/sys_vars/r/innodb_page_size_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_page_size_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_read_ahead_basic.result b/mysql-test/suite/sys_vars/r/innodb_read_ahead_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_read_ahead_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_recovery_stats_basic.result b/mysql-test/suite/sys_vars/r/innodb_recovery_stats_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_recovery_stats_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_recovery_update_relay_log_basic.result b/mysql-test/suite/sys_vars/r/innodb_recovery_update_relay_log_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_recovery_update_relay_log_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result b/mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_rollback_segments_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_show_locks_held_basic.result b/mysql-test/suite/sys_vars/r/innodb_show_locks_held_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_show_locks_held_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_show_verbose_locks_basic.result b/mysql-test/suite/sys_vars/r/innodb_show_verbose_locks_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_show_verbose_locks_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_stats_auto_update_basic.result b/mysql-test/suite/sys_vars/r/innodb_stats_auto_update_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_stats_auto_update_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result b/mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_stats_method_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_stats_update_need_lock_basic.result b/mysql-test/suite/sys_vars/r/innodb_stats_update_need_lock_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_stats_update_need_lock_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_thread_concurrency_timer_based_basic.result b/mysql-test/suite/sys_vars/r/innodb_thread_concurrency_timer_based_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_thread_concurrency_timer_based_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_use_global_flush_log_at_trx_commit_basic.result b/mysql-test/suite/sys_vars/r/innodb_use_global_flush_log_at_trx_commit_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_use_global_flush_log_at_trx_commit_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/r/innodb_use_sys_stats_table_basic.result b/mysql-test/suite/sys_vars/r/innodb_use_sys_stats_table_basic.result new file mode 100644 index 00000000000..d9d067c2cf9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/innodb_use_sys_stats_table_basic.result @@ -0,0 +1 @@ +XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_adaptive_flushing_method_basic.test b/mysql-test/suite/sys_vars/t/innodb_adaptive_flushing_method_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_adaptive_flushing_method_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_partitions_basic.test b/mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_partitions_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_adaptive_hash_index_partitions_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_restore_at_startup_basic.test b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_restore_at_startup_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_restore_at_startup_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_shm_checksum_basic.test b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_shm_checksum_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_shm_checksum_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_shm_key_basic.test b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_shm_key_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_shm_key_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_checkpoint_age_target_basic.test b/mysql-test/suite/sys_vars/t/innodb_checkpoint_age_target_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_checkpoint_age_target_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_corrupt_table_action_basic.test b/mysql-test/suite/sys_vars/t/innodb_corrupt_table_action_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_corrupt_table_action_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_dict_size_limit_basic.test b/mysql-test/suite/sys_vars/t/innodb_dict_size_limit_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_dict_size_limit_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic.test b/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_fast_checksum_basic.test b/mysql-test/suite/sys_vars/t/innodb_fast_checksum_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_fast_checksum_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test b/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_file_format_max_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_flush_log_at_trx_commit_basic.test b/mysql-test/suite/sys_vars/t/innodb_flush_log_at_trx_commit_basic.test index 90da929d199..56cfc2ffebe 100644 --- a/mysql-test/suite/sys_vars/t/innodb_flush_log_at_trx_commit_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_flush_log_at_trx_commit_basic.test @@ -56,11 +56,6 @@ SELECT @@global.innodb_flush_log_at_trx_commit; # Check if variable can be accessed with and without @@ sign # ############################################################################### ---Error ER_GLOBAL_VARIABLE -SET innodb_flush_log_at_trx_commit = 1; -SELECT @@innodb_flush_log_at_trx_commit; - - --Error ER_UNKNOWN_TABLE SELECT local.innodb_flush_log_at_trx_commit; diff --git a/mysql-test/suite/sys_vars/t/innodb_flush_neighbor_pages_basic.test b/mysql-test/suite/sys_vars/t/innodb_flush_neighbor_pages_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_flush_neighbor_pages_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_ibuf_accel_rate_basic.test b/mysql-test/suite/sys_vars/t/innodb_ibuf_accel_rate_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_ibuf_accel_rate_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_ibuf_active_contract_basic.test b/mysql-test/suite/sys_vars/t/innodb_ibuf_active_contract_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_ibuf_active_contract_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_ibuf_max_size_basic.test b/mysql-test/suite/sys_vars/t/innodb_ibuf_max_size_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_ibuf_max_size_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_import_table_from_xtrabackup_basic.test b/mysql-test/suite/sys_vars/t/innodb_import_table_from_xtrabackup_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_import_table_from_xtrabackup_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test b/mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_large_prefix_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_lazy_drop_table_basic.test b/mysql-test/suite/sys_vars/t/innodb_lazy_drop_table_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_lazy_drop_table_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_log_block_size_basic.test b/mysql-test/suite/sys_vars/t/innodb_log_block_size_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_log_block_size_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_page_size_basic.test b/mysql-test/suite/sys_vars/t/innodb_page_size_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_page_size_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_read_ahead_basic.test b/mysql-test/suite/sys_vars/t/innodb_read_ahead_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_read_ahead_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_recovery_stats_basic.test b/mysql-test/suite/sys_vars/t/innodb_recovery_stats_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_recovery_stats_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_recovery_update_relay_log_basic.test b/mysql-test/suite/sys_vars/t/innodb_recovery_update_relay_log_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_recovery_update_relay_log_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test b/mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_rollback_segments_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_show_locks_held_basic.test b/mysql-test/suite/sys_vars/t/innodb_show_locks_held_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_show_locks_held_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_show_verbose_locks_basic.test b/mysql-test/suite/sys_vars/t/innodb_show_verbose_locks_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_show_verbose_locks_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_stats_auto_update_basic.test b/mysql-test/suite/sys_vars/t/innodb_stats_auto_update_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_stats_auto_update_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test b/mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_stats_method_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_stats_update_need_lock_basic.test b/mysql-test/suite/sys_vars/t/innodb_stats_update_need_lock_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_stats_update_need_lock_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_thread_concurrency_timer_based_basic.test b/mysql-test/suite/sys_vars/t/innodb_thread_concurrency_timer_based_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_thread_concurrency_timer_based_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_use_global_flush_log_at_trx_commit_basic.test b/mysql-test/suite/sys_vars/t/innodb_use_global_flush_log_at_trx_commit_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_use_global_flush_log_at_trx_commit_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/sys_vars/t/innodb_use_sys_stats_table_basic.test b/mysql-test/suite/sys_vars/t/innodb_use_sys_stats_table_basic.test new file mode 100644 index 00000000000..00aa476e8d2 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/innodb_use_sys_stats_table_basic.test @@ -0,0 +1 @@ +--echo XtraDB extension diff --git a/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result b/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result index a2ebc7a8cd8..2108576ce2c 100644 --- a/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result +++ b/mysql-test/suite/vcol/r/vcol_ins_upd_innodb.result @@ -25,8 +25,8 @@ a b c # INSERT INTO tbl_name VALUES... a non-NULL value is specified against vcols insert into t1 values (1,2,3); Warnings: -Warning 1647 The value specified for computed column 'b' in table 't1' ignored -Warning 1647 The value specified for computed column 'c' in table 't1' ignored +Warning 1718 The value specified for computed column 'b' in table 't1' ignored +Warning 1718 The value specified for computed column 'c' in table 't1' ignored select * from t1; a b c 1 -1 -1 @@ -65,8 +65,8 @@ a b c # against vcols insert into t1 (a,b) values (1,3), (2,4); Warnings: -Warning 1647 The value specified for computed column 'b' in table 't1' ignored -Warning 1647 The value specified for computed column 'b' in table 't1' ignored +Warning 1718 The value specified for computed column 'b' in table 't1' ignored +Warning 1718 The value specified for computed column 'b' in table 't1' ignored select * from t1; a b c 1 -1 -1 @@ -107,8 +107,8 @@ a b c create table t2 like t1; insert into t2 select * from t1; Warnings: -Warning 1647 The value specified for computed column 'b' in table 't2' ignored -Warning 1647 The value specified for computed column 'c' in table 't2' ignored +Warning 1718 The value specified for computed column 'b' in table 't2' ignored +Warning 1718 The value specified for computed column 'c' in table 't2' ignored select * from t1; a b c 2 -2 -2 @@ -123,8 +123,8 @@ a b c create table t2 like t1; insert into t2 (a,b) select a,b from t1; Warnings: -Warning 1647 The value specified for computed column 'b' in table 't2' ignored -Warning 1647 The value specified for computed column 'b' in table 't2' ignored +Warning 1718 The value specified for computed column 'b' in table 't2' ignored +Warning 1718 The value specified for computed column 'b' in table 't2' ignored select * from t2; a b c 2 -2 -2 @@ -159,7 +159,7 @@ a b c 2 -2 -2 update t1 set c=3 where a=2; Warnings: -Warning 1647 The value specified for computed column 'c' in table 't1' ignored +Warning 1718 The value specified for computed column 'c' in table 't1' ignored select * from t1; a b c 1 -1 -1 @@ -189,7 +189,7 @@ a b c 2 -2 -2 update t1 set c=3 where b=-2; Warnings: -Warning 1647 The value specified for computed column 'c' in table 't1' ignored +Warning 1718 The value specified for computed column 'c' in table 't1' ignored select * from t1; a b c 1 -1 -1 diff --git a/mysql-test/suite/vcol/r/vcol_select_innodb.result b/mysql-test/suite/vcol/r/vcol_select_innodb.result index aa32d91142e..a21a230a573 100644 --- a/mysql-test/suite/vcol/r/vcol_select_innodb.result +++ b/mysql-test/suite/vcol/r/vcol_select_innodb.result @@ -22,7 +22,7 @@ a b c 1 -1 -1 explain select * from t2 where c=-1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ref c c 5 const 1 +1 SIMPLE t2 ref c c 5 const 1 Using index condition # select_type=SIMPLE, type=ALL select * from t1 where b=-1; a b c @@ -53,7 +53,7 @@ a b c a b c explain select * from t1,t3 where t1.c=t3.c and t3.c=-1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 const c c 5 const 1 -1 SIMPLE t1 ref c c 5 const 2 +1 SIMPLE t1 ref c c 5 const 2 Using index condition # select_type=PRIMARY, type=index,ALL select * from t1 where b in (select c from t3); a b c @@ -130,7 +130,7 @@ count(distinct c) 3 explain select count(distinct c) from t1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL c 5 NULL 5 Using index +1 SIMPLE t1 range NULL c 5 NULL 6 Using index for group-by (scanning) ### ### filesort & range-based utils ### @@ -141,7 +141,7 @@ a b c 2 -2 -2 explain select * from t3 where c >= -2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using MRR +1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Using MRR # SELECT * FROM tbl_name WHERE select * from t3 where a between 1 and 2; a b c @@ -149,7 +149,7 @@ a b c 2 -2 -2 explain select * from t3 where a between 1 and 2; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 2 Using where # SELECT * FROM tbl_name WHERE select * from t3 where b between -2 and -1; a b c @@ -165,7 +165,7 @@ a b c 2 -2 -2 explain select * from t3 where c between -2 and -1; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using MRR +1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Using MRR # SELECT * FROM tbl_name WHERE ORDER BY select * from t3 where a between 1 and 2 order by b; a b c @@ -173,7 +173,7 @@ a b c 1 -1 -1 explain select * from t3 where a between 1 and 2 order by b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 2 Using where; Using filesort # SELECT * FROM tbl_name WHERE ORDER BY select * from t3 where a between 1 and 2 order by c; a b c @@ -181,7 +181,7 @@ a b c 1 -1 -1 explain select * from t3 where a between 1 and 2 order by c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 1 Using where; Using filesort +1 SIMPLE t3 range PRIMARY PRIMARY 4 NULL 2 Using where; Using filesort # SELECT * FROM tbl_name WHERE ORDER BY select * from t3 where b between -2 and -1 order by a; a b c @@ -205,7 +205,7 @@ a b c 1 -1 -1 explain select * from t3 where c between -2 and -1 order by b; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition; Using MRR; Using filesort +1 SIMPLE t3 range c c 5 NULL 2 Using index condition; Using MRR; Using filesort # SELECT * FROM tbl_name WHERE ORDER BY select * from t3 where b between -2 and -1 order by c; a b c @@ -221,7 +221,7 @@ a b c 1 -1 -1 explain select * from t3 where c between -2 and -1 order by c; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range c c 5 NULL 1 Using index condition +1 SIMPLE t3 range c c 5 NULL 2 Using index condition # SELECT sum() FROM tbl_name GROUP BY select sum(b) from t1 group by b; sum(b) diff --git a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result index 83f755a2e7f..c75b8a24575 100644 --- a/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result +++ b/mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result @@ -170,11 +170,11 @@ t1 CREATE TABLE `t1` ( `b` double AS (format(cot(a),6)) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 insert into t1 values (12,default); -insert into t1 values (0,default); +insert into t1 values (1,default); select * from t1; a b 12 -1.572673 -0 NULL +1 0.642093 drop table t1; set sql_warnings = 0; # CRC32() diff --git a/mysql-test/suite/vcol/r/vcol_view_innodb.result b/mysql-test/suite/vcol/r/vcol_view_innodb.result index ae834722606..18991634b62 100644 --- a/mysql-test/suite/vcol/r/vcol_view_innodb.result +++ b/mysql-test/suite/vcol/r/vcol_view_innodb.result @@ -266,8 +266,8 @@ insert into v1 (a) values (3); ERROR HY000: CHECK OPTION failed 'test.v1' insert ignore into v1 (a) values (2),(3),(0); Warnings: -Error 1369 CHECK OPTION failed 'test.v1' -Error 1369 CHECK OPTION failed 'test.v1' +Warning 1369 CHECK OPTION failed 'test.v1' +Warning 1369 CHECK OPTION failed 'test.v1' select * from t1; a b c 1 -1 -1 diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 698bf67b927..4a43969a057 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -536,7 +536,7 @@ connect (user10261,localhost,mysqltest_4,,); connection user10261; --sorted_result SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS -where COLUMN_NAME='TABLE_NAME'; +where COLUMN_NAME='TABLE_NAME' and table_name not like 'innodb%'; connection default; disconnect user10261; delete from mysql.user where user='mysqltest_4'; @@ -917,10 +917,10 @@ DROP USER mysql_bug20230@localhost; # INFORMARTION_SCHEMA.TABLES # -SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test'); +SELECT MAX(table_name) FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test') and table_name not like 'xtradb%'; SELECT table_name from information_schema.tables WHERE table_name=(SELECT MAX(table_name) - FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test')); + FROM information_schema.tables WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test') and table_name not like 'xtradb%'); # # Bug #23037 Bug in field "Default" of query "SHOW COLUMNS FROM table" # diff --git a/mysql-test/t/innodb-analyze.test b/mysql-test/t/innodb-analyze.test deleted file mode 100644 index 9bdb9db697c..00000000000 --- a/mysql-test/t/innodb-analyze.test +++ /dev/null @@ -1,65 +0,0 @@ -# -# Test that mysqld does not crash when running ANALYZE TABLE with -# different values of the parameter innodb_stats_sample_pages. -# - --- source include/have_innodb.inc - -# we care only that the following SQL commands do not produce errors -# and do not crash the server --- disable_query_log --- disable_result_log --- enable_warnings - -let $sample_pages=`select @@innodb_stats_sample_pages`; -SET GLOBAL innodb_stats_sample_pages=0; - -# check that the value has been adjusted to 1 --- enable_result_log -SHOW VARIABLES LIKE 'innodb_stats_sample_pages'; --- disable_result_log - -CREATE TABLE innodb_analyze ( - a INT, - b INT, - KEY(a), - KEY(b,a) -) ENGINE=InnoDB; - -# test with empty table - -ANALYZE TABLE innodb_analyze; - -SET GLOBAL innodb_stats_sample_pages=2; -ANALYZE TABLE innodb_analyze; - -SET GLOBAL innodb_stats_sample_pages=4; -ANALYZE TABLE innodb_analyze; - -SET GLOBAL innodb_stats_sample_pages=8; -ANALYZE TABLE innodb_analyze; - -SET GLOBAL innodb_stats_sample_pages=16; -ANALYZE TABLE innodb_analyze; - -INSERT INTO innodb_analyze VALUES -(1,1), (1,1), (1,2), (1,3), (1,4), (1,5), -(8,1), (8,8), (8,2), (7,1), (1,4), (3,5); - -SET GLOBAL innodb_stats_sample_pages=1; -ANALYZE TABLE innodb_analyze; - -SET GLOBAL innodb_stats_sample_pages=2; -ANALYZE TABLE innodb_analyze; - -SET GLOBAL innodb_stats_sample_pages=4; -ANALYZE TABLE innodb_analyze; - -SET GLOBAL innodb_stats_sample_pages=8; -ANALYZE TABLE innodb_analyze; - -SET GLOBAL innodb_stats_sample_pages=16; -ANALYZE TABLE innodb_analyze; - -DROP TABLE innodb_analyze; -EVAL SET GLOBAL innodb_stats_sample_pages=$sample_pages; diff --git a/mysql-test/t/innodb-consistent-master.opt b/mysql-test/t/innodb-consistent-master.opt deleted file mode 100644 index cb48f1aaf60..00000000000 --- a/mysql-test/t/innodb-consistent-master.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-innodb_lock_wait_timeout=2 diff --git a/mysql-test/t/innodb-consistent.test b/mysql-test/t/innodb-consistent.test deleted file mode 100644 index 5a7f4dc392d..00000000000 --- a/mysql-test/t/innodb-consistent.test +++ /dev/null @@ -1,58 +0,0 @@ --- source include/not_embedded.inc --- source include/have_innodb.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -# REPLACE INTO ... SELECT and INSERT INTO ... SELECT should do -# a consistent read of the source table. - -connect (a,localhost,root,,); -connect (b,localhost,root,,); -connection a; -set session transaction isolation level read committed; -create table t1(a int not null) engine=innodb DEFAULT CHARSET=latin1; -create table t2 like t1; -insert into t2 values (1),(2),(3),(4),(5),(6),(7); -set autocommit=0; - -# REPLACE INTO ... SELECT case -begin; -# this should not result in any locks on t2. -replace into t1 select * from t2; - -connection b; -set session transaction isolation level read committed; -set autocommit=0; -# should not cuase a lock wait. -delete from t2 where a=5; -commit; -delete from t2; -commit; -connection a; -commit; - -# INSERT INTO ... SELECT case -begin; -# this should not result in any locks on t2. -insert into t1 select * from t2; - -connection b; -set session transaction isolation level read committed; -set autocommit=0; -# should not cuase a lock wait. -delete from t2 where a=5; -commit; -delete from t2; -commit; -connection a; -commit; - -select * from t1; -drop table t1; -drop table t2; - -connection default; -disconnect a; -disconnect b; diff --git a/mysql-test/t/innodb-index_ucs2.test b/mysql-test/t/innodb-index_ucs2.test deleted file mode 100644 index fff9a4da1a8..00000000000 --- a/mysql-test/t/innodb-index_ucs2.test +++ /dev/null @@ -1,5 +0,0 @@ --- source include/have_innodb.inc --- source include/have_ucs2.inc - --- let charset = ucs2 --- source include/innodb-index.inc diff --git a/mysql-test/t/innodb-replace.test b/mysql-test/t/innodb-replace.test deleted file mode 100644 index 8c3aacde5e8..00000000000 --- a/mysql-test/t/innodb-replace.test +++ /dev/null @@ -1,22 +0,0 @@ --- source include/have_innodb.inc -# embedded server ignores 'delayed', so skip this --- source include/not_embedded.inc - ---disable_warnings -drop table if exists t1; ---enable_warnings - -# -# Bug #1078 -# -create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) engine=innodb; -select * from t1; ---error ER_DELAYED_NOT_SUPPORTED -replace delayed into t1 (c1, c2) values ( "text1","11"); -select * from t1; ---error ER_DELAYED_NOT_SUPPORTED -replace delayed into t1 (c1, c2) values ( "text1","12"); -select * from t1; -drop table t1; - -# End of 4.1 tests diff --git a/mysql-test/t/innodb-timeout.test b/mysql-test/t/innodb-timeout.test deleted file mode 100644 index 7f7bcecb4ee..00000000000 --- a/mysql-test/t/innodb-timeout.test +++ /dev/null @@ -1,69 +0,0 @@ --- source include/have_innodb.inc - -let $timeout=`select @@innodb_lock_wait_timeout`; -set global innodb_lock_wait_timeout=42; - -connect (a,localhost,root,,); -connect (b,localhost,root,,); - -connection a; -select @@innodb_lock_wait_timeout; -set innodb_lock_wait_timeout=1; -select @@innodb_lock_wait_timeout; - -connection b; -select @@innodb_lock_wait_timeout; -set global innodb_lock_wait_timeout=347; -select @@innodb_lock_wait_timeout; -set innodb_lock_wait_timeout=1; -select @@innodb_lock_wait_timeout; - -connect (c,localhost,root,,); -connection c; -select @@innodb_lock_wait_timeout; -connection default; -disconnect c; - -connection a; -create table t1(a int primary key)engine=innodb; -begin; -insert into t1 values(1),(2),(3); - -connection b; -set innodb_lock_wait_timeout=5; ---send -select * from t1 for update; - -connection a; -commit; - -connection b; -reap; - -connection a; -begin; -insert into t1 values(4); - -connection b; -# Test that we get a lock timeout. -# We cannot reliably test that the timeout is exactly 1 seconds due to -# process scheduling differences on the host running the test suite. But we -# can test that we are within reasonable range. -set innodb_lock_wait_timeout=2; -set @a= current_timestamp(); ---error ER_LOCK_WAIT_TIMEOUT -select * from t1 for update; -set @b= current_timestamp(); -set @c= timestampdiff(SECOND, @a, @b); -select if(@c >= 1 and @c <= 10, 'OK', concat("NOT OK, time passed=", @c)); - -connection a; -commit; -drop table t1; - -connection default; - -disconnect a; -disconnect b; - -eval set global innodb_lock_wait_timeout=$timeout; diff --git a/mysql-test/t/innodb_bug34053.test b/mysql-test/t/innodb_bug34053.test deleted file mode 100644 index b935e45c06d..00000000000 --- a/mysql-test/t/innodb_bug34053.test +++ /dev/null @@ -1,50 +0,0 @@ -# -# Make sure http://bugs.mysql.com/34053 remains fixed. -# - --- source include/not_embedded.inc --- source include/have_innodb.inc - -SET storage_engine=InnoDB; - -# we do not really care about what gets printed, we are only -# interested in getting success or failure according to our -# expectations --- disable_query_log --- disable_result_log - -GRANT USAGE ON *.* TO 'shane'@'localhost' IDENTIFIED BY '12345'; -FLUSH PRIVILEGES; - --- connect (con1,localhost,shane,12345,) - --- connection con1 --- error ER_SPECIFIC_ACCESS_DENIED_ERROR -CREATE TABLE innodb_monitor (a INT) ENGINE=INNODB; --- error ER_SPECIFIC_ACCESS_DENIED_ERROR -CREATE TABLE innodb_mem_validate (a INT) ENGINE=INNODB; -CREATE TABLE innodb_monitorx (a INT) ENGINE=INNODB; -DROP TABLE innodb_monitorx; -CREATE TABLE innodb_monito (a INT) ENGINE=INNODB; -DROP TABLE innodb_monito; -CREATE TABLE xinnodb_monitor (a INT) ENGINE=INNODB; -DROP TABLE xinnodb_monitor; -CREATE TABLE nnodb_monitor (a INT) ENGINE=INNODB; -DROP TABLE nnodb_monitor; - --- connection default -CREATE TABLE innodb_monitor (a INT) ENGINE=INNODB; -CREATE TABLE innodb_mem_validate (a INT) ENGINE=INNODB; - --- connection con1 --- error ER_SPECIFIC_ACCESS_DENIED_ERROR -DROP TABLE innodb_monitor; --- error ER_SPECIFIC_ACCESS_DENIED_ERROR -DROP TABLE innodb_mem_validate; - --- connection default -DROP TABLE innodb_monitor; -DROP TABLE innodb_mem_validate; -DROP USER 'shane'@'localhost'; - --- disconnect con1 diff --git a/mysql-test/t/innodb_bug34300.test b/mysql-test/t/innodb_bug34300.test deleted file mode 100644 index 5b1939e648e..00000000000 --- a/mysql-test/t/innodb_bug34300.test +++ /dev/null @@ -1,36 +0,0 @@ -# -# Bug#34300 Tinyblob & tinytext fields currupted after export/import and alter in 5.1 -# http://bugs.mysql.com/34300 -# - --- source include/have_innodb.inc - --- disable_query_log --- disable_result_log - -# set packet size and reconnect -let $max_packet=`select @@global.max_allowed_packet`; -SET @@global.max_allowed_packet=16777216; ---connect (newconn, localhost, root,,) - -DROP TABLE IF EXISTS bug34300; -CREATE TABLE bug34300 ( - f4 TINYTEXT, - f6 MEDIUMTEXT, - f8 TINYBLOB -) ENGINE=InnoDB; - -INSERT INTO bug34300 VALUES ('xxx', repeat('a', 8459264), 'zzz'); - --- enable_result_log - -SELECT f4, f8 FROM bug34300; - -ALTER TABLE bug34300 ADD COLUMN (f10 INT); - -SELECT f4, f8 FROM bug34300; - -DROP TABLE bug34300; -disconnect newconn; -connection default; -EVAL SET @@global.max_allowed_packet=$max_packet; diff --git a/mysql-test/t/innodb_bug35220.test b/mysql-test/t/innodb_bug35220.test deleted file mode 100644 index 26f7d6b1ddd..00000000000 --- a/mysql-test/t/innodb_bug35220.test +++ /dev/null @@ -1,16 +0,0 @@ -# -# Bug#35220 ALTER TABLE too picky on reserved word "foreign" -# http://bugs.mysql.com/35220 -# - --- source include/have_innodb.inc - -SET storage_engine=InnoDB; - -# we care only that the following SQL commands do not produce errors --- disable_query_log --- disable_result_log - -CREATE TABLE bug35220 (foreign_col INT, dummy_cant_delete_all_columns INT); -ALTER TABLE bug35220 DROP foreign_col; -DROP TABLE bug35220; diff --git a/mysql-test/t/innodb_bug36169.test b/mysql-test/t/innodb_bug36169.test deleted file mode 100644 index 5bf55193b5c..00000000000 --- a/mysql-test/t/innodb_bug36169.test +++ /dev/null @@ -1,1159 +0,0 @@ -# -# Bug#36169 create innodb compressed table with too large row size crashed -# http://bugs.mysql.com/36169 -# - --- source include/have_innodb.inc - -let $file_format=`select @@innodb_file_format`; -let $file_per_table=`select @@innodb_file_per_table`; -SET GLOBAL innodb_file_format='Barracuda'; -SET GLOBAL innodb_file_per_table=ON; - -# -# The following is copied from http://bugs.mysql.com/36169 -# (http://bugs.mysql.com/file.php?id=9121) -# Probably it can be simplified but that is not obvious. -# - -# we care only that the following SQL commands do produce errors -# as expected and do not crash the server --- disable_query_log --- disable_result_log - -# Generating 10 tables -# Creating a table with 94 columns and 24 indexes -DROP TABLE IF EXISTS `table0`; ---error ER_TOO_BIG_ROWSIZE -CREATE TABLE IF NOT EXISTS `table0` -(`col0` BOOL, -`col1` BOOL, -`col2` TINYINT, -`col3` DATE, -`col4` TIME, -`col5` SET ('test1','test2','test3'), -`col6` TIME, -`col7` TEXT, -`col8` DECIMAL, -`col9` SET ('test1','test2','test3'), -`col10` FLOAT, -`col11` DOUBLE PRECISION, -`col12` ENUM ('test1','test2','test3'), -`col13` TINYBLOB, -`col14` YEAR, -`col15` SET ('test1','test2','test3'), -`col16` NUMERIC, -`col17` NUMERIC, -`col18` BLOB, -`col19` DATETIME, -`col20` DOUBLE PRECISION, -`col21` DECIMAL, -`col22` DATETIME, -`col23` NUMERIC, -`col24` NUMERIC, -`col25` LONGTEXT, -`col26` TINYBLOB, -`col27` TIME, -`col28` TINYBLOB, -`col29` ENUM ('test1','test2','test3'), -`col30` SMALLINT, -`col31` REAL, -`col32` FLOAT, -`col33` CHAR (175), -`col34` TINYTEXT, -`col35` TINYTEXT, -`col36` TINYBLOB, -`col37` TINYBLOB, -`col38` TINYTEXT, -`col39` MEDIUMBLOB, -`col40` TIMESTAMP, -`col41` DOUBLE, -`col42` SMALLINT, -`col43` LONGBLOB, -`col44` VARCHAR (80), -`col45` MEDIUMTEXT, -`col46` NUMERIC, -`col47` BIGINT, -`col48` DATE, -`col49` TINYBLOB, -`col50` DATE, -`col51` BOOL, -`col52` MEDIUMINT, -`col53` FLOAT, -`col54` TINYBLOB, -`col55` LONGTEXT, -`col56` SMALLINT, -`col57` ENUM ('test1','test2','test3'), -`col58` DATETIME, -`col59` MEDIUMTEXT, -`col60` VARCHAR (232), -`col61` NUMERIC, -`col62` YEAR, -`col63` SMALLINT, -`col64` TIMESTAMP, -`col65` BLOB, -`col66` LONGBLOB, -`col67` INT, -`col68` LONGTEXT, -`col69` ENUM ('test1','test2','test3'), -`col70` INT, -`col71` TIME, -`col72` TIMESTAMP, -`col73` TIMESTAMP, -`col74` VARCHAR (170), -`col75` SET ('test1','test2','test3'), -`col76` TINYBLOB, -`col77` BIGINT, -`col78` NUMERIC, -`col79` DATETIME, -`col80` YEAR, -`col81` NUMERIC, -`col82` LONGBLOB, -`col83` TEXT, -`col84` CHAR (83), -`col85` DECIMAL, -`col86` FLOAT, -`col87` INT, -`col88` VARCHAR (145), -`col89` DATE, -`col90` DECIMAL, -`col91` DECIMAL, -`col92` MEDIUMBLOB, -`col93` TIME, -KEY `idx0` (`col69`,`col90`,`col8`), -KEY `idx1` (`col60`), -KEY `idx2` (`col60`,`col70`,`col74`), -KEY `idx3` (`col22`,`col32`,`col72`,`col30`), -KEY `idx4` (`col29`), -KEY `idx5` (`col19`,`col45`(143)), -KEY `idx6` (`col46`,`col48`,`col5`,`col39`(118)), -KEY `idx7` (`col48`,`col61`), -KEY `idx8` (`col93`), -KEY `idx9` (`col31`), -KEY `idx10` (`col30`,`col21`), -KEY `idx11` (`col67`), -KEY `idx12` (`col44`,`col6`,`col8`,`col38`(226)), -KEY `idx13` (`col71`,`col41`,`col15`,`col49`(88)), -KEY `idx14` (`col78`), -KEY `idx15` (`col63`,`col67`,`col64`), -KEY `idx16` (`col17`,`col86`), -KEY `idx17` (`col77`,`col56`,`col10`,`col55`(24)), -KEY `idx18` (`col62`), -KEY `idx19` (`col31`,`col57`,`col56`,`col53`), -KEY `idx20` (`col46`), -KEY `idx21` (`col83`(54)), -KEY `idx22` (`col51`,`col7`(120)), -KEY `idx23` (`col7`(163),`col31`,`col71`,`col14`) -)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; - -# Creating a table with 10 columns and 32 indexes -DROP TABLE IF EXISTS `table1`; ---error ER_TOO_BIG_ROWSIZE -CREATE TABLE IF NOT EXISTS `table1` -(`col0` CHAR (113), -`col1` FLOAT, -`col2` BIGINT, -`col3` DECIMAL, -`col4` BLOB, -`col5` LONGTEXT, -`col6` SET ('test1','test2','test3'), -`col7` BIGINT, -`col8` BIGINT, -`col9` TINYBLOB, -KEY `idx0` (`col5`(101),`col7`,`col8`), -KEY `idx1` (`col8`), -KEY `idx2` (`col4`(177),`col9`(126),`col6`,`col3`), -KEY `idx3` (`col5`(160)), -KEY `idx4` (`col9`(242)), -KEY `idx5` (`col4`(139),`col2`,`col3`), -KEY `idx6` (`col7`), -KEY `idx7` (`col6`,`col2`,`col0`,`col3`), -KEY `idx8` (`col9`(66)), -KEY `idx9` (`col5`(253)), -KEY `idx10` (`col1`,`col7`,`col2`), -KEY `idx11` (`col9`(242),`col0`,`col8`,`col5`(163)), -KEY `idx12` (`col8`), -KEY `idx13` (`col0`,`col9`(37)), -KEY `idx14` (`col0`), -KEY `idx15` (`col5`(111)), -KEY `idx16` (`col8`,`col0`,`col5`(13)), -KEY `idx17` (`col4`(139)), -KEY `idx18` (`col5`(189),`col2`,`col3`,`col9`(136)), -KEY `idx19` (`col0`,`col3`,`col1`,`col8`), -KEY `idx20` (`col8`), -KEY `idx21` (`col0`,`col7`,`col9`(227),`col3`), -KEY `idx22` (`col0`), -KEY `idx23` (`col2`), -KEY `idx24` (`col3`), -KEY `idx25` (`col2`,`col3`), -KEY `idx26` (`col0`), -KEY `idx27` (`col5`(254)), -KEY `idx28` (`col3`), -KEY `idx29` (`col3`), -KEY `idx30` (`col7`,`col3`,`col0`,`col4`(220)), -KEY `idx31` (`col4`(1),`col0`) -)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; - -# Creating a table with 141 columns and 18 indexes -DROP TABLE IF EXISTS `table2`; ---error ER_TOO_BIG_ROWSIZE -CREATE TABLE IF NOT EXISTS `table2` -(`col0` BOOL, -`col1` MEDIUMINT, -`col2` VARCHAR (209), -`col3` MEDIUMBLOB, -`col4` CHAR (13), -`col5` DOUBLE, -`col6` TINYTEXT, -`col7` REAL, -`col8` SMALLINT, -`col9` BLOB, -`col10` TINYINT, -`col11` DECIMAL, -`col12` BLOB, -`col13` DECIMAL, -`col14` LONGBLOB, -`col15` SMALLINT, -`col16` LONGBLOB, -`col17` TINYTEXT, -`col18` FLOAT, -`col19` CHAR (78), -`col20` MEDIUMTEXT, -`col21` SET ('test1','test2','test3'), -`col22` MEDIUMINT, -`col23` INT, -`col24` MEDIUMBLOB, -`col25` ENUM ('test1','test2','test3'), -`col26` TINYBLOB, -`col27` VARCHAR (116), -`col28` TIMESTAMP, -`col29` BLOB, -`col30` SMALLINT, -`col31` DOUBLE PRECISION, -`col32` DECIMAL, -`col33` DECIMAL, -`col34` TEXT, -`col35` MEDIUMINT, -`col36` MEDIUMINT, -`col37` BIGINT, -`col38` VARCHAR (253), -`col39` TINYBLOB, -`col40` MEDIUMBLOB, -`col41` BIGINT, -`col42` DOUBLE, -`col43` TEXT, -`col44` BLOB, -`col45` TIME, -`col46` MEDIUMINT, -`col47` DOUBLE PRECISION, -`col48` SET ('test1','test2','test3'), -`col49` DOUBLE PRECISION, -`col50` VARCHAR (97), -`col51` TEXT, -`col52` NUMERIC, -`col53` ENUM ('test1','test2','test3'), -`col54` MEDIUMTEXT, -`col55` MEDIUMINT, -`col56` DATETIME, -`col57` DATETIME, -`col58` MEDIUMTEXT, -`col59` CHAR (244), -`col60` LONGBLOB, -`col61` MEDIUMBLOB, -`col62` DOUBLE, -`col63` SMALLINT, -`col64` BOOL, -`col65` SMALLINT, -`col66` VARCHAR (212), -`col67` TIME, -`col68` REAL, -`col69` BOOL, -`col70` BIGINT, -`col71` DATE, -`col72` TINYINT, -`col73` ENUM ('test1','test2','test3'), -`col74` DATE, -`col75` TIME, -`col76` DATETIME, -`col77` BOOL, -`col78` TINYTEXT, -`col79` MEDIUMINT, -`col80` NUMERIC, -`col81` LONGTEXT, -`col82` SET ('test1','test2','test3'), -`col83` DOUBLE PRECISION, -`col84` NUMERIC, -`col85` VARCHAR (184), -`col86` DOUBLE PRECISION, -`col87` MEDIUMTEXT, -`col88` MEDIUMBLOB, -`col89` BOOL, -`col90` SMALLINT, -`col91` TINYINT, -`col92` ENUM ('test1','test2','test3'), -`col93` BOOL, -`col94` TIMESTAMP, -`col95` BOOL, -`col96` MEDIUMTEXT, -`col97` DECIMAL, -`col98` BOOL, -`col99` DECIMAL, -`col100` MEDIUMINT, -`col101` DOUBLE PRECISION, -`col102` TINYINT, -`col103` BOOL, -`col104` MEDIUMINT, -`col105` DECIMAL, -`col106` NUMERIC, -`col107` TIMESTAMP, -`col108` MEDIUMBLOB, -`col109` TINYBLOB, -`col110` SET ('test1','test2','test3'), -`col111` YEAR, -`col112` TIMESTAMP, -`col113` CHAR (201), -`col114` BOOL, -`col115` TINYINT, -`col116` DOUBLE, -`col117` TINYINT, -`col118` TIMESTAMP, -`col119` SET ('test1','test2','test3'), -`col120` SMALLINT, -`col121` TINYBLOB, -`col122` TIMESTAMP, -`col123` BLOB, -`col124` DATE, -`col125` SMALLINT, -`col126` ENUM ('test1','test2','test3'), -`col127` MEDIUMBLOB, -`col128` DOUBLE PRECISION, -`col129` REAL, -`col130` VARCHAR (159), -`col131` MEDIUMBLOB, -`col132` BIGINT, -`col133` INT, -`col134` SET ('test1','test2','test3'), -`col135` CHAR (198), -`col136` SET ('test1','test2','test3'), -`col137` MEDIUMTEXT, -`col138` SMALLINT, -`col139` BLOB, -`col140` LONGBLOB, -KEY `idx0` (`col14`(139),`col24`(208),`col38`,`col35`), -KEY `idx1` (`col48`,`col118`,`col29`(131),`col100`), -KEY `idx2` (`col86`,`col67`,`col43`(175)), -KEY `idx3` (`col19`), -KEY `idx4` (`col40`(220),`col67`), -KEY `idx5` (`col99`,`col56`), -KEY `idx6` (`col68`,`col28`,`col137`(157)), -KEY `idx7` (`col51`(160),`col99`,`col45`,`col39`(9)), -KEY `idx8` (`col15`,`col52`,`col90`,`col94`), -KEY `idx9` (`col24`(3),`col139`(248),`col108`(118),`col41`), -KEY `idx10` (`col36`,`col92`,`col114`), -KEY `idx11` (`col115`,`col9`(116)), -KEY `idx12` (`col130`,`col93`,`col134`), -KEY `idx13` (`col123`(65)), -KEY `idx14` (`col44`(90),`col86`,`col119`), -KEY `idx15` (`col69`), -KEY `idx16` (`col132`,`col81`(118),`col18`), -KEY `idx17` (`col24`(250),`col7`,`col92`,`col45`) -)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; - -# Creating a table with 199 columns and 1 indexes -DROP TABLE IF EXISTS `table3`; ---error ER_TOO_BIG_ROWSIZE -CREATE TABLE IF NOT EXISTS `table3` -(`col0` SMALLINT, -`col1` SET ('test1','test2','test3'), -`col2` TINYTEXT, -`col3` DOUBLE, -`col4` NUMERIC, -`col5` DATE, -`col6` BIGINT, -`col7` DOUBLE, -`col8` TEXT, -`col9` INT, -`col10` REAL, -`col11` TINYINT, -`col12` NUMERIC, -`col13` NUMERIC, -`col14` TIME, -`col15` DOUBLE, -`col16` REAL, -`col17` MEDIUMBLOB, -`col18` YEAR, -`col19` TINYTEXT, -`col20` YEAR, -`col21` CHAR (250), -`col22` TINYINT, -`col23` TINYINT, -`col24` SMALLINT, -`col25` DATETIME, -`col26` MEDIUMINT, -`col27` LONGBLOB, -`col28` VARCHAR (106), -`col29` FLOAT, -`col30` MEDIUMTEXT, -`col31` TINYBLOB, -`col32` BIGINT, -`col33` YEAR, -`col34` REAL, -`col35` MEDIUMBLOB, -`col36` LONGTEXT, -`col37` LONGBLOB, -`col38` BIGINT, -`col39` FLOAT, -`col40` TIME, -`col41` DATETIME, -`col42` BOOL, -`col43` BIGINT, -`col44` SMALLINT, -`col45` TIME, -`col46` DOUBLE PRECISION, -`col47` TIME, -`col48` TINYTEXT, -`col49` DOUBLE PRECISION, -`col50` BIGINT, -`col51` NUMERIC, -`col52` TINYBLOB, -`col53` DATE, -`col54` DECIMAL, -`col55` SMALLINT, -`col56` TINYTEXT, -`col57` ENUM ('test1','test2','test3'), -`col58` YEAR, -`col59` TIME, -`col60` TINYINT, -`col61` DECIMAL, -`col62` DOUBLE, -`col63` DATE, -`col64` LONGTEXT, -`col65` DOUBLE, -`col66` VARCHAR (88), -`col67` MEDIUMTEXT, -`col68` DATE, -`col69` MEDIUMINT, -`col70` DECIMAL, -`col71` MEDIUMTEXT, -`col72` LONGTEXT, -`col73` REAL, -`col74` DOUBLE, -`col75` TIME, -`col76` DATE, -`col77` DECIMAL, -`col78` MEDIUMBLOB, -`col79` NUMERIC, -`col80` BIGINT, -`col81` YEAR, -`col82` SMALLINT, -`col83` MEDIUMINT, -`col84` TINYINT, -`col85` MEDIUMBLOB, -`col86` TIME, -`col87` MEDIUMBLOB, -`col88` LONGTEXT, -`col89` BOOL, -`col90` BLOB, -`col91` LONGBLOB, -`col92` YEAR, -`col93` BLOB, -`col94` INT, -`col95` TINYTEXT, -`col96` TINYINT, -`col97` DECIMAL, -`col98` ENUM ('test1','test2','test3'), -`col99` MEDIUMINT, -`col100` TINYINT, -`col101` MEDIUMBLOB, -`col102` TINYINT, -`col103` SET ('test1','test2','test3'), -`col104` TIMESTAMP, -`col105` TEXT, -`col106` DATETIME, -`col107` MEDIUMTEXT, -`col108` CHAR (220), -`col109` TIME, -`col110` VARCHAR (131), -`col111` DECIMAL, -`col112` FLOAT, -`col113` SMALLINT, -`col114` BIGINT, -`col115` LONGBLOB, -`col116` SET ('test1','test2','test3'), -`col117` ENUM ('test1','test2','test3'), -`col118` BLOB, -`col119` MEDIUMTEXT, -`col120` SET ('test1','test2','test3'), -`col121` DATETIME, -`col122` FLOAT, -`col123` VARCHAR (242), -`col124` YEAR, -`col125` MEDIUMBLOB, -`col126` TIME, -`col127` BOOL, -`col128` TINYBLOB, -`col129` DOUBLE, -`col130` TINYINT, -`col131` BIGINT, -`col132` SMALLINT, -`col133` INT, -`col134` DOUBLE PRECISION, -`col135` MEDIUMBLOB, -`col136` SET ('test1','test2','test3'), -`col137` TINYTEXT, -`col138` DOUBLE PRECISION, -`col139` NUMERIC, -`col140` BLOB, -`col141` SET ('test1','test2','test3'), -`col142` INT, -`col143` VARCHAR (26), -`col144` BLOB, -`col145` REAL, -`col146` SET ('test1','test2','test3'), -`col147` LONGBLOB, -`col148` TEXT, -`col149` BLOB, -`col150` CHAR (189), -`col151` LONGTEXT, -`col152` INT, -`col153` FLOAT, -`col154` LONGTEXT, -`col155` DATE, -`col156` LONGBLOB, -`col157` TINYBLOB, -`col158` REAL, -`col159` DATE, -`col160` TIME, -`col161` YEAR, -`col162` DOUBLE, -`col163` VARCHAR (90), -`col164` FLOAT, -`col165` NUMERIC, -`col166` ENUM ('test1','test2','test3'), -`col167` DOUBLE PRECISION, -`col168` DOUBLE PRECISION, -`col169` TINYBLOB, -`col170` TIME, -`col171` SMALLINT, -`col172` TINYTEXT, -`col173` SMALLINT, -`col174` DOUBLE, -`col175` VARCHAR (14), -`col176` VARCHAR (90), -`col177` REAL, -`col178` MEDIUMINT, -`col179` TINYBLOB, -`col180` FLOAT, -`col181` TIMESTAMP, -`col182` REAL, -`col183` DOUBLE PRECISION, -`col184` BIGINT, -`col185` INT, -`col186` MEDIUMTEXT, -`col187` TIME, -`col188` FLOAT, -`col189` TIME, -`col190` INT, -`col191` FLOAT, -`col192` MEDIUMINT, -`col193` TINYINT, -`col194` MEDIUMTEXT, -`col195` DATE, -`col196` TIME, -`col197` YEAR, -`col198` CHAR (206), -KEY `idx0` (`col39`,`col23`) -)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; - -# Creating a table with 133 columns and 16 indexes -DROP TABLE IF EXISTS `table4`; ---error ER_TOO_BIG_ROWSIZE -CREATE TABLE IF NOT EXISTS `table4` -(`col0` VARCHAR (60), -`col1` NUMERIC, -`col2` LONGTEXT, -`col3` MEDIUMTEXT, -`col4` LONGTEXT, -`col5` LONGBLOB, -`col6` LONGBLOB, -`col7` DATETIME, -`col8` TINYTEXT, -`col9` BLOB, -`col10` BOOL, -`col11` BIGINT, -`col12` TEXT, -`col13` VARCHAR (213), -`col14` TINYBLOB, -`col15` BOOL, -`col16` MEDIUMTEXT, -`col17` DOUBLE, -`col18` TEXT, -`col19` BLOB, -`col20` SET ('test1','test2','test3'), -`col21` TINYINT, -`col22` DATETIME, -`col23` TINYINT, -`col24` ENUM ('test1','test2','test3'), -`col25` REAL, -`col26` BOOL, -`col27` FLOAT, -`col28` LONGBLOB, -`col29` DATETIME, -`col30` FLOAT, -`col31` SET ('test1','test2','test3'), -`col32` LONGBLOB, -`col33` NUMERIC, -`col34` YEAR, -`col35` VARCHAR (146), -`col36` BIGINT, -`col37` DATETIME, -`col38` DATE, -`col39` SET ('test1','test2','test3'), -`col40` CHAR (112), -`col41` FLOAT, -`col42` YEAR, -`col43` TIME, -`col44` DOUBLE, -`col45` NUMERIC, -`col46` FLOAT, -`col47` DECIMAL, -`col48` BIGINT, -`col49` DECIMAL, -`col50` YEAR, -`col51` MEDIUMTEXT, -`col52` LONGBLOB, -`col53` SET ('test1','test2','test3'), -`col54` BLOB, -`col55` FLOAT, -`col56` REAL, -`col57` REAL, -`col58` TEXT, -`col59` MEDIUMBLOB, -`col60` INT, -`col61` INT, -`col62` DATE, -`col63` TEXT, -`col64` DATE, -`col65` ENUM ('test1','test2','test3'), -`col66` DOUBLE PRECISION, -`col67` TINYTEXT, -`col68` TINYBLOB, -`col69` FLOAT, -`col70` BLOB, -`col71` DATETIME, -`col72` DOUBLE, -`col73` LONGTEXT, -`col74` TIME, -`col75` DATETIME, -`col76` VARCHAR (122), -`col77` MEDIUMTEXT, -`col78` MEDIUMTEXT, -`col79` BOOL, -`col80` LONGTEXT, -`col81` TINYTEXT, -`col82` NUMERIC, -`col83` DOUBLE PRECISION, -`col84` DATE, -`col85` YEAR, -`col86` BLOB, -`col87` TINYTEXT, -`col88` DOUBLE PRECISION, -`col89` MEDIUMINT, -`col90` MEDIUMTEXT, -`col91` NUMERIC, -`col92` DATETIME, -`col93` NUMERIC, -`col94` SET ('test1','test2','test3'), -`col95` TINYTEXT, -`col96` SET ('test1','test2','test3'), -`col97` YEAR, -`col98` MEDIUMINT, -`col99` TEXT, -`col100` TEXT, -`col101` TIME, -`col102` VARCHAR (225), -`col103` TINYTEXT, -`col104` TEXT, -`col105` MEDIUMTEXT, -`col106` TINYINT, -`col107` TEXT, -`col108` LONGBLOB, -`col109` LONGTEXT, -`col110` TINYTEXT, -`col111` CHAR (56), -`col112` YEAR, -`col113` ENUM ('test1','test2','test3'), -`col114` TINYBLOB, -`col115` DATETIME, -`col116` DATE, -`col117` TIME, -`col118` MEDIUMTEXT, -`col119` DOUBLE PRECISION, -`col120` FLOAT, -`col121` TIMESTAMP, -`col122` MEDIUMINT, -`col123` YEAR, -`col124` DATE, -`col125` TEXT, -`col126` FLOAT, -`col127` TINYTEXT, -`col128` BOOL, -`col129` NUMERIC, -`col130` TIMESTAMP, -`col131` INT, -`col132` MEDIUMBLOB, -KEY `idx0` (`col130`), -KEY `idx1` (`col30`,`col55`,`col19`(31)), -KEY `idx2` (`col104`(186)), -KEY `idx3` (`col131`), -KEY `idx4` (`col64`,`col93`,`col2`(11)), -KEY `idx5` (`col34`,`col121`,`col22`), -KEY `idx6` (`col33`,`col55`,`col83`), -KEY `idx7` (`col17`,`col87`(245),`col99`(17)), -KEY `idx8` (`col65`,`col120`), -KEY `idx9` (`col82`), -KEY `idx10` (`col9`(72)), -KEY `idx11` (`col88`), -KEY `idx12` (`col128`,`col9`(200),`col71`,`col66`), -KEY `idx13` (`col77`(126)), -KEY `idx14` (`col105`(26),`col13`,`col117`), -KEY `idx15` (`col4`(246),`col130`,`col115`,`col3`(141)) -)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; - -# Creating a table with 176 columns and 13 indexes -DROP TABLE IF EXISTS `table5`; ---error ER_TOO_BIG_ROWSIZE -CREATE TABLE IF NOT EXISTS `table5` -(`col0` MEDIUMTEXT, -`col1` VARCHAR (90), -`col2` TINYTEXT, -`col3` TIME, -`col4` BOOL, -`col5` TINYTEXT, -`col6` BOOL, -`col7` TIMESTAMP, -`col8` TINYBLOB, -`col9` TINYINT, -`col10` YEAR, -`col11` SET ('test1','test2','test3'), -`col12` TEXT, -`col13` CHAR (248), -`col14` BIGINT, -`col15` TEXT, -`col16` TINYINT, -`col17` NUMERIC, -`col18` SET ('test1','test2','test3'), -`col19` LONGBLOB, -`col20` FLOAT, -`col21` INT, -`col22` TEXT, -`col23` BOOL, -`col24` DECIMAL, -`col25` DOUBLE PRECISION, -`col26` FLOAT, -`col27` TINYBLOB, -`col28` NUMERIC, -`col29` MEDIUMBLOB, -`col30` DATE, -`col31` LONGTEXT, -`col32` DATE, -`col33` FLOAT, -`col34` BIGINT, -`col35` TINYTEXT, -`col36` MEDIUMTEXT, -`col37` TIME, -`col38` INT, -`col39` TINYINT, -`col40` SET ('test1','test2','test3'), -`col41` CHAR (130), -`col42` SMALLINT, -`col43` INT, -`col44` MEDIUMTEXT, -`col45` VARCHAR (126), -`col46` INT, -`col47` DOUBLE PRECISION, -`col48` BIGINT, -`col49` MEDIUMTEXT, -`col50` TINYBLOB, -`col51` MEDIUMINT, -`col52` TEXT, -`col53` VARCHAR (208), -`col54` VARCHAR (207), -`col55` NUMERIC, -`col56` DATETIME, -`col57` ENUM ('test1','test2','test3'), -`col58` NUMERIC, -`col59` TINYBLOB, -`col60` VARCHAR (73), -`col61` MEDIUMTEXT, -`col62` TINYBLOB, -`col63` DATETIME, -`col64` NUMERIC, -`col65` MEDIUMINT, -`col66` DATETIME, -`col67` NUMERIC, -`col68` TINYINT, -`col69` VARCHAR (58), -`col70` DECIMAL, -`col71` MEDIUMTEXT, -`col72` DATE, -`col73` TIME, -`col74` DOUBLE PRECISION, -`col75` DECIMAL, -`col76` MEDIUMBLOB, -`col77` REAL, -`col78` YEAR, -`col79` YEAR, -`col80` LONGBLOB, -`col81` BLOB, -`col82` BIGINT, -`col83` ENUM ('test1','test2','test3'), -`col84` NUMERIC, -`col85` SET ('test1','test2','test3'), -`col86` MEDIUMTEXT, -`col87` LONGBLOB, -`col88` TIME, -`col89` ENUM ('test1','test2','test3'), -`col90` DECIMAL, -`col91` FLOAT, -`col92` DATETIME, -`col93` TINYTEXT, -`col94` TIMESTAMP, -`col95` TIMESTAMP, -`col96` TEXT, -`col97` REAL, -`col98` VARCHAR (198), -`col99` TIME, -`col100` TINYINT, -`col101` BIGINT, -`col102` LONGBLOB, -`col103` LONGBLOB, -`col104` MEDIUMINT, -`col105` MEDIUMTEXT, -`col106` TIMESTAMP, -`col107` SMALLINT, -`col108` NUMERIC, -`col109` DECIMAL, -`col110` FLOAT, -`col111` DECIMAL, -`col112` REAL, -`col113` TINYTEXT, -`col114` FLOAT, -`col115` VARCHAR (7), -`col116` LONGTEXT, -`col117` DATE, -`col118` BIGINT, -`col119` TEXT, -`col120` BIGINT, -`col121` BLOB, -`col122` CHAR (110), -`col123` NUMERIC, -`col124` MEDIUMBLOB, -`col125` NUMERIC, -`col126` NUMERIC, -`col127` BOOL, -`col128` TIME, -`col129` TINYBLOB, -`col130` TINYBLOB, -`col131` DATE, -`col132` INT, -`col133` VARCHAR (123), -`col134` CHAR (238), -`col135` VARCHAR (225), -`col136` LONGTEXT, -`col137` LONGBLOB, -`col138` REAL, -`col139` TINYBLOB, -`col140` DATETIME, -`col141` TINYTEXT, -`col142` LONGBLOB, -`col143` BIGINT, -`col144` VARCHAR (236), -`col145` TEXT, -`col146` YEAR, -`col147` DECIMAL, -`col148` TEXT, -`col149` MEDIUMBLOB, -`col150` TINYINT, -`col151` BOOL, -`col152` VARCHAR (72), -`col153` INT, -`col154` VARCHAR (165), -`col155` TINYINT, -`col156` MEDIUMTEXT, -`col157` DOUBLE PRECISION, -`col158` TIME, -`col159` MEDIUMBLOB, -`col160` LONGBLOB, -`col161` DATETIME, -`col162` DOUBLE PRECISION, -`col163` BLOB, -`col164` ENUM ('test1','test2','test3'), -`col165` TIMESTAMP, -`col166` DATE, -`col167` TINYBLOB, -`col168` TINYBLOB, -`col169` LONGBLOB, -`col170` DATETIME, -`col171` BIGINT, -`col172` VARCHAR (30), -`col173` LONGTEXT, -`col174` TIME, -`col175` FLOAT, -KEY `idx0` (`col16`,`col156`(139),`col97`,`col120`), -KEY `idx1` (`col24`,`col0`(108)), -KEY `idx2` (`col117`,`col173`(34),`col132`,`col82`), -KEY `idx3` (`col2`(86)), -KEY `idx4` (`col2`(43)), -KEY `idx5` (`col83`,`col35`(87),`col111`), -KEY `idx6` (`col6`,`col134`,`col92`), -KEY `idx7` (`col56`), -KEY `idx8` (`col30`,`col53`,`col129`(66)), -KEY `idx9` (`col53`,`col113`(211),`col32`,`col15`(75)), -KEY `idx10` (`col34`), -KEY `idx11` (`col126`), -KEY `idx12` (`col24`) -)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; - -# Creating a table with 179 columns and 46 indexes -DROP TABLE IF EXISTS `table6`; --- error ER_TOO_BIG_ROWSIZE ---error ER_TOO_BIG_ROWSIZE -CREATE TABLE IF NOT EXISTS `table6` -(`col0` ENUM ('test1','test2','test3'), -`col1` MEDIUMBLOB, -`col2` MEDIUMBLOB, -`col3` DATETIME, -`col4` DATE, -`col5` YEAR, -`col6` REAL, -`col7` NUMERIC, -`col8` MEDIUMBLOB, -`col9` TEXT, -`col10` TIMESTAMP, -`col11` DOUBLE, -`col12` DOUBLE, -`col13` SMALLINT, -`col14` TIMESTAMP, -`col15` DECIMAL, -`col16` DATE, -`col17` TEXT, -`col18` LONGBLOB, -`col19` BIGINT, -`col20` FLOAT, -`col21` DATETIME, -`col22` TINYINT, -`col23` MEDIUMBLOB, -`col24` SET ('test1','test2','test3'), -`col25` TIME, -`col26` TEXT, -`col27` LONGTEXT, -`col28` BIGINT, -`col29` REAL, -`col30` YEAR, -`col31` MEDIUMBLOB, -`col32` MEDIUMINT, -`col33` FLOAT, -`col34` TEXT, -`col35` DATE, -`col36` TIMESTAMP, -`col37` REAL, -`col38` BLOB, -`col39` BLOB, -`col40` BLOB, -`col41` TINYBLOB, -`col42` INT, -`col43` TINYINT, -`col44` REAL, -`col45` BIGINT, -`col46` TIMESTAMP, -`col47` BLOB, -`col48` ENUM ('test1','test2','test3'), -`col49` BOOL, -`col50` CHAR (109), -`col51` DOUBLE, -`col52` DOUBLE PRECISION, -`col53` ENUM ('test1','test2','test3'), -`col54` FLOAT, -`col55` DOUBLE PRECISION, -`col56` CHAR (166), -`col57` TEXT, -`col58` TIME, -`col59` DECIMAL, -`col60` TEXT, -`col61` ENUM ('test1','test2','test3'), -`col62` LONGTEXT, -`col63` YEAR, -`col64` DOUBLE, -`col65` CHAR (87), -`col66` DATE, -`col67` BOOL, -`col68` MEDIUMBLOB, -`col69` DATETIME, -`col70` DECIMAL, -`col71` TIME, -`col72` REAL, -`col73` LONGTEXT, -`col74` BLOB, -`col75` REAL, -`col76` INT, -`col77` INT, -`col78` FLOAT, -`col79` DOUBLE, -`col80` MEDIUMINT, -`col81` ENUM ('test1','test2','test3'), -`col82` VARCHAR (221), -`col83` BIGINT, -`col84` TINYINT, -`col85` BIGINT, -`col86` FLOAT, -`col87` MEDIUMBLOB, -`col88` CHAR (126), -`col89` MEDIUMBLOB, -`col90` DATETIME, -`col91` TINYINT, -`col92` DOUBLE, -`col93` NUMERIC, -`col94` DATE, -`col95` BLOB, -`col96` DATETIME, -`col97` TIME, -`col98` LONGBLOB, -`col99` INT, -`col100` SET ('test1','test2','test3'), -`col101` TINYBLOB, -`col102` INT, -`col103` MEDIUMBLOB, -`col104` MEDIUMTEXT, -`col105` FLOAT, -`col106` TINYBLOB, -`col107` VARCHAR (26), -`col108` TINYINT, -`col109` TIME, -`col110` TINYBLOB, -`col111` LONGBLOB, -`col112` TINYTEXT, -`col113` FLOAT, -`col114` TINYINT, -`col115` NUMERIC, -`col116` TIME, -`col117` SET ('test1','test2','test3'), -`col118` DATE, -`col119` SMALLINT, -`col120` BLOB, -`col121` TINYTEXT, -`col122` REAL, -`col123` YEAR, -`col124` REAL, -`col125` BOOL, -`col126` BLOB, -`col127` REAL, -`col128` MEDIUMBLOB, -`col129` TIMESTAMP, -`col130` LONGBLOB, -`col131` MEDIUMBLOB, -`col132` YEAR, -`col133` YEAR, -`col134` INT, -`col135` MEDIUMINT, -`col136` MEDIUMINT, -`col137` TINYTEXT, -`col138` TINYBLOB, -`col139` BLOB, -`col140` SET ('test1','test2','test3'), -`col141` ENUM ('test1','test2','test3'), -`col142` ENUM ('test1','test2','test3'), -`col143` TINYTEXT, -`col144` DATETIME, -`col145` TEXT, -`col146` DOUBLE PRECISION, -`col147` DECIMAL, -`col148` MEDIUMTEXT, -`col149` TINYTEXT, -`col150` SET ('test1','test2','test3'), -`col151` MEDIUMTEXT, -`col152` CHAR (126), -`col153` DOUBLE, -`col154` CHAR (243), -`col155` SET ('test1','test2','test3'), -`col156` SET ('test1','test2','test3'), -`col157` DATETIME, -`col158` DOUBLE, -`col159` NUMERIC, -`col160` DECIMAL, -`col161` FLOAT, -`col162` LONGBLOB, -`col163` LONGTEXT, -`col164` INT, -`col165` TIME, -`col166` CHAR (27), -`col167` VARCHAR (63), -`col168` TEXT, -`col169` TINYBLOB, -`col170` TINYBLOB, -`col171` ENUM ('test1','test2','test3'), -`col172` INT, -`col173` TIME, -`col174` DECIMAL, -`col175` DOUBLE, -`col176` MEDIUMBLOB, -`col177` LONGBLOB, -`col178` CHAR (43), -KEY `idx0` (`col131`(219)), -KEY `idx1` (`col67`,`col122`,`col59`,`col87`(33)), -KEY `idx2` (`col83`,`col42`,`col57`(152)), -KEY `idx3` (`col106`(124)), -KEY `idx4` (`col173`,`col80`,`col165`,`col89`(78)), -KEY `idx5` (`col174`,`col145`(108),`col23`(228),`col141`), -KEY `idx6` (`col157`,`col140`), -KEY `idx7` (`col130`(188),`col15`), -KEY `idx8` (`col52`), -KEY `idx9` (`col144`), -KEY `idx10` (`col155`), -KEY `idx11` (`col62`(230),`col1`(109)), -KEY `idx12` (`col151`(24),`col95`(85)), -KEY `idx13` (`col114`), -KEY `idx14` (`col42`,`col98`(56),`col146`), -KEY `idx15` (`col147`,`col39`(254),`col35`), -KEY `idx16` (`col79`), -KEY `idx17` (`col65`), -KEY `idx18` (`col149`(165),`col168`(119),`col32`,`col117`), -KEY `idx19` (`col64`), -KEY `idx20` (`col93`), -KEY `idx21` (`col64`,`col113`,`col104`(182)), -KEY `idx22` (`col52`,`col111`(189)), -KEY `idx23` (`col45`), -KEY `idx24` (`col154`,`col107`,`col110`(159)), -KEY `idx25` (`col149`(1),`col87`(131)), -KEY `idx26` (`col58`,`col115`,`col63`), -KEY `idx27` (`col95`(9),`col0`,`col87`(113)), -KEY `idx28` (`col92`,`col130`(1)), -KEY `idx29` (`col151`(129),`col137`(254),`col13`), -KEY `idx30` (`col49`), -KEY `idx31` (`col28`), -KEY `idx32` (`col83`,`col146`), -KEY `idx33` (`col155`,`col90`,`col17`(245)), -KEY `idx34` (`col174`,`col169`(44),`col107`), -KEY `idx35` (`col113`), -KEY `idx36` (`col52`), -KEY `idx37` (`col16`,`col120`(190)), -KEY `idx38` (`col28`), -KEY `idx39` (`col131`(165)), -KEY `idx40` (`col135`,`col26`(86)), -KEY `idx41` (`col69`,`col94`), -KEY `idx42` (`col105`,`col151`(38),`col97`), -KEY `idx43` (`col88`), -KEY `idx44` (`col176`(100),`col42`,`col73`(189),`col94`), -KEY `idx45` (`col2`(27),`col27`(116)) -)engine=innodb ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; - -DROP TABLE IF EXISTS table0; -DROP TABLE IF EXISTS table1; -DROP TABLE IF EXISTS table2; -DROP TABLE IF EXISTS table3; -DROP TABLE IF EXISTS table4; -DROP TABLE IF EXISTS table5; -DROP TABLE IF EXISTS table6; - -EVAL SET GLOBAL innodb_file_format=$file_format; -EVAL SET GLOBAL innodb_file_per_table=$file_per_table; diff --git a/mysql-test/t/innodb_bug40360.test b/mysql-test/t/innodb_bug40360.test deleted file mode 100644 index e88837aab4f..00000000000 --- a/mysql-test/t/innodb_bug40360.test +++ /dev/null @@ -1,16 +0,0 @@ -# -# Make sure http://bugs.mysql.com/40360 remains fixed. -# - --- source include/not_embedded.inc --- source include/have_innodb.inc - -SET TX_ISOLATION='READ-COMMITTED'; - -# This is the default since MySQL 5.1.29 SET BINLOG_FORMAT='STATEMENT'; - -CREATE TABLE bug40360 (a INT) engine=innodb; - -INSERT INTO bug40360 VALUES (1); - -DROP TABLE bug40360; diff --git a/mysql-test/t/innodb_bug41904.test b/mysql-test/t/innodb_bug41904.test deleted file mode 100644 index 365c5229adc..00000000000 --- a/mysql-test/t/innodb_bug41904.test +++ /dev/null @@ -1,14 +0,0 @@ -# -# Make sure http://bugs.mysql.com/41904 remains fixed. -# - --- source include/not_embedded.inc --- source include/have_innodb.inc - -CREATE TABLE bug41904 (id INT PRIMARY KEY, uniquecol CHAR(15)) ENGINE=InnoDB; - -INSERT INTO bug41904 VALUES (1,NULL), (2,NULL); - -CREATE UNIQUE INDEX ui ON bug41904 (uniquecol); - -DROP TABLE bug41904; diff --git a/mysql-test/t/innodb_bug44571.test b/mysql-test/t/innodb_bug44571.test deleted file mode 100644 index f5d79e3070a..00000000000 --- a/mysql-test/t/innodb_bug44571.test +++ /dev/null @@ -1,13 +0,0 @@ -# -# Bug#44571 InnoDB Plugin crashes on ADD INDEX -# http://bugs.mysql.com/44571 -# --- source include/have_innodb.inc - -CREATE TABLE bug44571 (foo INT) ENGINE=InnoDB; -ALTER TABLE bug44571 CHANGE foo bar INT; --- error ER_KEY_COLUMN_DOES_NOT_EXITS -ALTER TABLE bug44571 ADD INDEX bug44571b (foo); -ALTER TABLE bug44571 ADD INDEX bug44571b (bar); -CREATE INDEX bug44571c ON bug44571 (bar); -DROP TABLE bug44571; diff --git a/mysql-test/t/innodb_bug46676.test b/mysql-test/t/innodb_bug46676.test deleted file mode 100644 index 440666c4226..00000000000 --- a/mysql-test/t/innodb_bug46676.test +++ /dev/null @@ -1,16 +0,0 @@ -# This is the test for bug 46676: mysqld got exception 0xc0000005 -# It is reproducible with InnoDB plugin 1.0.4 + MySQL 5.1.37. -# But no longer reproducible after MySQL 5.1.38 (with plugin 1.0.5). - ---source include/have_innodb.inc - -SET foreign_key_checks=0; -CREATE TABLE t1 (id int, foreign key (id) references t2(id)) ENGINE=INNODB; -CREATE TABLE t2 (id int, foreign key (id) references t1(id)) ENGINE=INNODB; -SET foreign_key_checks=1; - -# Server crashes -SELECT COUNT(*) FROM information_schema.key_column_usage WHERE REFERENCED_TABLE_NAME in ('t1', 't2'); - -SET foreign_key_checks=0; -DROP TABLE t1, t2; diff --git a/mysql-test/t/innodb_information_schema.test b/mysql-test/t/innodb_information_schema.test deleted file mode 100644 index fc1d38d8d14..00000000000 --- a/mysql-test/t/innodb_information_schema.test +++ /dev/null @@ -1,149 +0,0 @@ -# -# Test that user data is correctly "visualized" in -# INFORMATION_SCHEMA.innodb_locks.lock_data -# - --- source include/have_innodb.inc - --- disable_query_log --- disable_result_log - -SET storage_engine=InnoDB; - --- disable_warnings -DROP TABLE IF EXISTS t_min, t_max; --- enable_warnings - -let $table_def = -( - c01 TINYINT, - c02 TINYINT UNSIGNED, - c03 SMALLINT, - c04 SMALLINT UNSIGNED, - c05 MEDIUMINT, - c06 MEDIUMINT UNSIGNED, - c07 INT, - c08 INT UNSIGNED, - c09 BIGINT, - c10 BIGINT UNSIGNED, - PRIMARY KEY(c01, c02, c03, c04, c05, c06, c07, c08, c09, c10) -); - --- eval CREATE TABLE t_min $table_def; -INSERT INTO t_min VALUES -(-128, 0, - -32768, 0, - -8388608, 0, - -2147483648, 0, - -9223372036854775808, 0); - --- eval CREATE TABLE t_max $table_def; -INSERT INTO t_max VALUES -(127, 255, - 32767, 65535, - 8388607, 16777215, - 2147483647, 4294967295, - 9223372036854775807, 18446744073709551615); - -CREATE TABLE ```t'\"_str` ( - c1 VARCHAR(32), - c2 VARCHAR(32), - c3 VARCHAR(32), - c4 VARCHAR(32), - c5 VARCHAR(32), - c6 VARCHAR(32), - c7 VARCHAR(32), - PRIMARY KEY(c1, c2, c3, c4, c5, c6, c7) -); -INSERT INTO ```t'\"_str` VALUES -('1', 'abc', '''abc', 'abc''', 'a''bc', 'a''bc''', '''abc'''''); -INSERT INTO ```t'\"_str` VALUES -('2', 'abc', '"abc', 'abc"', 'a"bc', 'a"bc"', '"abc""'); -INSERT INTO ```t'\"_str` VALUES -('3', 'abc', '\\abc', 'abc\\', 'a\\bc', 'a\\bc\\', '\\abc\\\\'); -INSERT INTO ```t'\"_str` VALUES -('4', 'abc', 0x00616263, 0x61626300, 0x61006263, 0x6100626300, 0x610062630000); - --- connect (con_lock,localhost,root,,) --- connect (con_min_trylock,localhost,root,,) --- connect (con_max_trylock,localhost,root,,) --- connect (con_str_insert_supremum,localhost,root,,) --- connect (con_str_lock_row1,localhost,root,,) --- connect (con_str_lock_row2,localhost,root,,) --- connect (con_str_lock_row3,localhost,root,,) --- connect (con_str_lock_row4,localhost,root,,) --- connect (con_verify_innodb_locks,localhost,root,,) - --- connection con_lock -SET autocommit=0; -SELECT * FROM t_min FOR UPDATE; -SELECT * FROM t_max FOR UPDATE; -SELECT * FROM ```t'\"_str` FOR UPDATE; - --- connection con_min_trylock --- send -SELECT * FROM t_min FOR UPDATE; - --- connection con_max_trylock --- send -SELECT * FROM t_max FOR UPDATE; - --- connection con_str_insert_supremum --- send -INSERT INTO ```t'\"_str` VALUES -('z', 'z', 'z', 'z', 'z', 'z', 'z'); - --- connection con_str_lock_row1 --- send -SELECT * FROM ```t'\"_str` WHERE c1 = '1' FOR UPDATE; - --- connection con_str_lock_row2 --- send -SELECT * FROM ```t'\"_str` WHERE c1 = '2' FOR UPDATE; - --- connection con_str_lock_row3 --- send -SELECT * FROM ```t'\"_str` WHERE c1 = '3' FOR UPDATE; - --- connection con_str_lock_row4 --- send -SELECT * FROM ```t'\"_str` WHERE c1 = '4' FOR UPDATE; - --- enable_result_log --- connection con_verify_innodb_locks -# Wait for the above queries to execute before continuing. -# Without this, it sometimes happens that the SELECT from innodb_locks -# executes before some of them, resulting in less than expected number -# of rows being selected from innodb_locks. If there is a bug and there -# are no 14 rows in innodb_locks then this test will fail with timeout. -let $count = 14; -let $table = INFORMATION_SCHEMA.INNODB_LOCKS; --- source include/wait_until_rows_count.inc -# the above enables the query log, re-disable it --- disable_query_log -SELECT lock_mode, lock_type, lock_table, lock_index, lock_rec, lock_data -FROM INFORMATION_SCHEMA.INNODB_LOCKS ORDER BY lock_data; - -SELECT lock_table,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS -GROUP BY lock_table; - -set @save_sql_mode = @@sql_mode; -SET SQL_MODE='ANSI_QUOTES'; -SELECT lock_table,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_LOCKS -GROUP BY lock_table; -SET @@sql_mode=@save_sql_mode; --- disable_result_log - --- connection default - --- disconnect con_lock --- disconnect con_min_trylock --- disconnect con_max_trylock --- disconnect con_str_insert_supremum --- disconnect con_str_lock_row1 --- disconnect con_str_lock_row2 --- disconnect con_str_lock_row3 --- disconnect con_str_lock_row4 --- disconnect con_verify_innodb_locks - -DROP TABLE t_min, t_max, ```t'\"_str`; diff --git a/mysql-test/t/innodb_trx_weight.test b/mysql-test/t/innodb_trx_weight.test deleted file mode 100644 index b72eaad345f..00000000000 --- a/mysql-test/t/innodb_trx_weight.test +++ /dev/null @@ -1,108 +0,0 @@ -# -# Ensure that the number of locks (SELECT FOR UPDATE for example) is -# added to the number of altered rows when choosing the smallest -# transaction to kill as a victim when a deadlock is detected. -# Also transactions what had edited non-transactional tables should -# be heavier than ones that had not. -# - --- source include/have_innodb.inc - -SET storage_engine=InnoDB; - -# we do not really care about what gets printed, we are only -# interested in getting the deadlock resolved according to our -# expectations --- disable_query_log --- disable_result_log - -# we want to use "-- eval statement1; statement2" which does not work with -# prepared statements. Because this test should not behave differently with -# or without prepared statements we disable them so the test does not fail -# if someone runs ./mysql-test-run.pl --ps-protocol --- disable_ps_protocol - --- disable_warnings -DROP TABLE IF EXISTS t1, t2, t3, t4, t5_nontrans; --- enable_warnings - -# we will create a simple deadlock with t1, t2 and two connections -CREATE TABLE t1 (a INT); -CREATE TABLE t2 (a INT); - -# auxiliary table with a bulk of rows which will be locked by a -# transaction to increase its weight -CREATE TABLE t3 (a INT); - -# auxiliary empty table which will be inserted by a -# transaction to increase its weight -CREATE TABLE t4 (a INT); - -# auxiliary non-transactional table which will be edited by a -# transaction to tremendously increase its weight -CREATE TABLE t5_nontrans (a INT) ENGINE=MyISAM; - -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (1); -# insert a lot of rows in t3 -INSERT INTO t3 VALUES (1); -INSERT INTO t3 SELECT * FROM t3; -INSERT INTO t3 SELECT * FROM t3; -INSERT INTO t3 SELECT * FROM t3; -INSERT INTO t3 SELECT * FROM t3; -INSERT INTO t3 SELECT * FROM t3; -INSERT INTO t3 SELECT * FROM t3; -INSERT INTO t3 SELECT * FROM t3; -INSERT INTO t3 SELECT * FROM t3; -INSERT INTO t3 SELECT * FROM t3; -INSERT INTO t3 SELECT * FROM t3; -INSERT INTO t3 SELECT * FROM t3; - -# test locking weight - --- let $con1_extra_sql = --- let $con1_extra_sql_present = 0 --- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE --- let $con2_extra_sql_present = 1 --- let $con1_should_be_rolledback = 1 --- source include/innodb_trx_weight.inc - --- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1) --- let $con1_extra_sql_present = 1 --- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE --- let $con2_extra_sql_present = 1 --- let $con1_should_be_rolledback = 1 --- source include/innodb_trx_weight.inc - --- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1), (1), (1), (1) --- let $con1_extra_sql_present = 1 --- let $con2_extra_sql = SELECT * FROM t3 FOR UPDATE --- let $con2_extra_sql_present = 1 --- let $con1_should_be_rolledback = 0 --- source include/innodb_trx_weight.inc - -# test weight when non-transactional tables are edited - --- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1) --- let $con1_extra_sql_present = 1 --- let $con2_extra_sql = --- let $con2_extra_sql_present = 0 --- let $con1_should_be_rolledback = 0 --- source include/innodb_trx_weight.inc - --- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1) --- let $con1_extra_sql_present = 1 --- let $con2_extra_sql = INSERT INTO t5_nontrans VALUES (1) --- let $con2_extra_sql_present = 1 --- let $con1_should_be_rolledback = 1 --- source include/innodb_trx_weight.inc - --- let $con1_extra_sql = INSERT INTO t4 VALUES (1), (1), (1) --- let $con1_extra_sql = $con1_extra_sql; INSERT INTO t5_nontrans VALUES (1) --- let $con1_extra_sql_present = 1 --- let $con2_extra_sql = INSERT INTO t5_nontrans VALUES (1) --- let $con2_extra_sql_present = 1 --- let $con1_should_be_rolledback = 0 --- source include/innodb_trx_weight.inc - -DROP TABLE t1, t2, t3, t4, t5_nontrans; diff --git a/mysql-test/t/subselect_sj2.test b/mysql-test/t/subselect_sj2.test index d0794db68bb..0b5cb947588 100644 --- a/mysql-test/t/subselect_sj2.test +++ b/mysql-test/t/subselect_sj2.test @@ -61,6 +61,13 @@ insert into t3 select A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B where B.a <5; +# +# InnoDB does not use join buffer here, XtraDB does +# (despite the comment above which says "no join buffering", +# because it does not hold when this file is included +# into subselect_sj2_jcl6.test) +# +--replace_regex /Using join buffer// explain select * from t3 where b in (select a from t0); select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5); diff --git a/sql/slave.cc b/sql/slave.cc index 1d99d2b606b..1d0781aa7b2 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1006,6 +1006,8 @@ const char *print_slave_db_safe(const char* db) DBUG_RETURN((db ? db : "")); } +#endif /* HAVE_REPLICATION */ + int init_strvar_from_file(char *var, int max_size, IO_CACHE *f, const char *default_val) { @@ -1037,6 +1039,10 @@ int init_strvar_from_file(char *var, int max_size, IO_CACHE *f, } +/* + when moving these functions to mysys, don't forget to + remove slave.cc from libmysqld/CMakeLists.txt +*/ int init_intvar_from_file(int* var, IO_CACHE* f, int default_val) { char buf[32]; @@ -1165,6 +1171,8 @@ err: DBUG_RETURN(ret); } +#ifdef HAVE_REPLICATION + /* Check if the error is caused by network. @param[in] errorno Number of the error. diff --git a/storage/xtradb/CMakeLists.txt.disabled b/storage/xtradb/CMakeLists.txt similarity index 82% rename from storage/xtradb/CMakeLists.txt.disabled rename to storage/xtradb/CMakeLists.txt index 789dbd5327e..68b0e0cacc4 100644 --- a/storage/xtradb/CMakeLists.txt.disabled +++ b/storage/xtradb/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2011, 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 @@ -40,12 +40,9 @@ IF(UNIX) ENDIF() ENDIF() -# Enable InnoDB's UNIV_DEBUG if MySQL's WITH_DEBUG[_FULL] is defined -# enable when this bug is resolved: -# Bug#54861 Additional connections not handled properly in mtr --embedded -#IF(WITH_DEBUG) -# ADD_DEFINITIONS("-DUNIV_DEBUG") -#ENDIF() +# Enable InnoDB's UNIV_DEBUG for debug builds +SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DUNIV_DEBUG") +SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG") IF(NOT MSVC) # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not @@ -127,9 +124,13 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") CHECK_FUNCTION_EXISTS(atomic_cas_ulong HAVE_ATOMIC_CAS_ULONG) CHECK_FUNCTION_EXISTS(atomic_cas_32 HAVE_ATOMIC_CAS_32) CHECK_FUNCTION_EXISTS(atomic_cas_64 HAVE_ATOMIC_CAS_64) - CHECK_FUNCTION_EXISTS(atomic_add_long HAVE_ATOMIC_ADD_LONG) - IF(HAVE_ATOMIC_CAS_ULONG AND HAVE_ATOMIC_CAS_32 AND - HAVE_ATOMIC_CAS_64 AND HAVE_ATOMIC_ADD_LONG) + CHECK_FUNCTION_EXISTS(atomic_add_long_nv HAVE_ATOMIC_ADD_LONG_NV) + CHECK_FUNCTION_EXISTS(atomic_swap_uchar HAVE_ATOMIC_SWAP_UCHAR) + IF(HAVE_ATOMIC_CAS_ULONG AND + HAVE_ATOMIC_CAS_32 AND + HAVE_ATOMIC_CAS_64 AND + HAVE_ATOMIC_ADD_LONG_NV AND + HAVE_ATOMIC_SWAP_UCHAR) SET(HAVE_IB_SOLARIS_ATOMICS 1) ENDIF() @@ -188,13 +189,13 @@ IF(SIZEOF_PTHREAD_T) ENDIF() IF(MSVC) - ADD_DEFINITIONS(-DHAVE_WINDOWS_ATOMICS -DHAVE_IB_PAUSE_INSTRUCTION) + ADD_DEFINITIONS(-DHAVE_WINDOWS_ATOMICS) ENDIF() -# Include directories under innobase -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include - ${CMAKE_SOURCE_DIR}/storage/innobase/handler) +# Include directories under xtradb +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/xtradb/include + ${CMAKE_SOURCE_DIR}/storage/xtradb/handler) # Sun Studio bug with -xO2 IF(CMAKE_C_COMPILER_ID MATCHES "SunPro" @@ -213,9 +214,7 @@ IF (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) PROPERTIES COMPILE_FLAGS -Od) ENDIF() -ADD_DEFINITIONS(-D_WIN32 -D_LIB -DMYSQL_SERVER) - -SET(XTRADB_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c +SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c buf/buf0buddy.c buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c data/data0data.c data/data0type.c dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c dict/dict0load.c dict/dict0mem.c @@ -235,22 +234,23 @@ SET(XTRADB_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c os/os0file.c os/os0proc.c os/os0sync.c os/os0thread.c page/page0cur.c page/page0page.c page/page0zip.c que/que0que.c - handler/ha_innodb.cc handler/handler0alter.cc handler/i_s.cc handler/mysql_addons.cc + handler/ha_innodb.cc handler/handler0alter.cc handler/i_s.cc read/read0read.c rem/rem0cmp.c rem/rem0rec.c row/row0ext.c row/row0ins.c row/row0merge.c row/row0mysql.c row/row0purge.c row/row0row.c row/row0sel.c row/row0uins.c row/row0umod.c row/row0undo.c row/row0upd.c row/row0vers.c - srv/srv0que.c srv/srv0srv.c srv/srv0start.c + srv/srv0srv.c srv/srv0start.c sync/sync0arr.c sync/sync0rw.c sync/sync0sync.c - thr/thr0loc.c trx/trx0i_s.c trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c usr/usr0sess.c - ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rbt.c ut/ut0rnd.c ut/ut0ut.c ut/ut0vec.c - ut/ut0list.c ut/ut0wqueue.c) + ut/ut0byte.c ut/ut0dbg.c ut/ut0list.c ut/ut0mem.c ut/ut0rbt.c ut/ut0rnd.c + ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c ut/ut0bh.c) -# New plugin support, cross-platform , base name for shared module is "ha_innodb" -MYSQL_ADD_PLUGIN(innobase ${XTRADB_SOURCES} STORAGE_ENGINE - DEFAULT - MODULE_OUTPUT_NAME ha_xtradb - LINK_LIBRARIES ${ZLIB_LIBRARY}) +IF(WITH_INNODB) + # Legacy option + SET(WITH_INNOBASE_STORAGE_ENGINE TRUE) +ENDIF() + +MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE + LINK_LIBRARIES ${ZLIB_LIBRARY}) diff --git a/storage/xtradb/COPYING.Sun_Microsystems b/storage/xtradb/COPYING.Sun_Microsystems deleted file mode 100644 index 5a77ef3ab73..00000000000 --- a/storage/xtradb/COPYING.Sun_Microsystems +++ /dev/null @@ -1,31 +0,0 @@ -Portions of this software contain modifications contributed by -Sun Microsystems, Inc. These contributions are used with the following -license: - -Copyright (c) 2009, Sun Microsystems, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - * Neither the name of Sun Microsystems, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/storage/xtradb/ChangeLog b/storage/xtradb/ChangeLog deleted file mode 100644 index 43f87a1baf5..00000000000 --- a/storage/xtradb/ChangeLog +++ /dev/null @@ -1,1916 +0,0 @@ -2010-08-24 The InnoDB Team - - * handler/ha_innodb.c, dict/dict0dict.c: - Fix Bug #55832 selects crash too easily when innodb_force_recovery>3 - -2010-08-03 The InnoDB Team - - * include/dict0dict.h, include/dict0dict.ic, row/row0mysql.c: - Fix bug #54678, InnoDB, TRUNCATE, ALTER, I_S SELECT, crash or deadlock - -2010-08-03 The InnoDB Team - - * dict/dict0load.c, handler/ha_innodb.cc, include/db0err.h, - include/dict0load.h, include/dict0mem.h, include/que0que.h, - row/row0merge.c, row/row0mysql.c: - Fix Bug#54582 stack overflow when opening many tables linked - with foreign keys at once - -2010-08-03 The InnoDB Team - - * include/ut0mem.h, ut/ut0mem.c: - Fix Bug #55627 segv in ut_free pars_lexer_close innobase_shutdown - innodb-use-sys-malloc=0 - -2010-08-01 The InnoDB Team - - * handler/ha_innodb.cc - Fix Bug #55382 Assignment with SELECT expressions takes unexpected - S locks in READ COMMITTED ->>>>>>> MERGE-SOURCE - -2010-07-27 The InnoDB Team - - * include/mem0pool.h, mem/mem0mem.c, mem/mem0pool.c, srv/srv0start.c: - Fix Bug#55581 shutdown with innodb-use-sys-malloc=0: assert - mutex->magic_n == MUTEX_MAGIC_N. - -2010-06-30 The InnoDB Team - - * btr/btr0sea.c, ha/ha0ha.c, handler/ha_innodb.cc, include/btr0sea.h: - Fix Bug#54311 Crash on CHECK PARTITION after concurrent LOAD DATA - and adaptive_hash_index=OFF - -2010-06-29 The InnoDB Team - * row/row0row.c, row/row0undo.c, row/row0upd.c: - Fix Bug#54408 txn rollback after recovery: row0umod.c:673 - dict_table_get_format(index->table) - -2010-06-29 The InnoDB Team - - * btr/btr0cur.c, include/btr0cur.h, - include/row0mysql.h, row/row0merge.c, row/row0sel.c: - Fix Bug#54358 READ UNCOMMITTED access failure of off-page DYNAMIC - or COMPRESSED columns - -2010-06-24 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#54679 alter table causes compressed row_format to revert - to compact - -2010-06-22 The InnoDB Team - - * dict/dict0dict.c, dict/dict0mem.c, include/dict0mem.h, - include/univ.i, page/page0zip.c, row/row0merge.c: - Fix Bug#47991 InnoDB Dictionary Cache memory usage increases - indefinitely when renaming tables - -2010-06-22 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#54686: "field->col->mtype == type" assertion error at - row/row0sel.c - -2010-06-22 The InnoDB Team - - * handler/ha_innodb.cc, innodb_bug54044.result, innodb_bug54044.test: - Fix Bug#54044 Create temporary tables and using innodb crashes. - -2010-06-21 The InnoDB Team - - * dict/dict0load.c, fil/fil0fil.c: - Fix Bug#54658: InnoDB: Warning: allocated tablespace %lu, - old maximum was 0 (introduced in Bug #53578 fix) - -2010-06-16 The InnoDB Team - - * row/row0merge.c: - Fix Bug#54330 Broken fast index creation - -2010-06-10 The InnoDB Team - - * include/log0log.ic, row/row0ins.c, row/row0purge.c, - row/row0uins.c, row/row0umod.c, row/row0upd.c: - Fix Bug#39168 ERROR: the age of the last checkpoint ... exceeds - the log group capacity - -2010-06-08 The InnoDB Team - - * dict/dict0load.c: - Fix Bug#54009 Server crashes when data is selected from non backed - up table for InnoDB plugin - -2010-06-02 The InnoDB Team - - * include/db0err.h, include/lock0lock.h, include/row0mysql.h, - lock/lock0lock.c, row/row0ins.c, row/row0mysql.c, row/row0sel.c: - Fix Bug#53674 InnoDB: Error: unlock row could not find a - 4 mode lock on the record - -2010-06-01 The InnoDB Team - - * include/sync0rw.h, sync/sync0rw.c: - Fix Bug#48197 Concurrent rw_lock_free may cause assertion failure - -2010-06-01 The InnoDB Team - - * row/row0umod.c: - Fix Bug#53812 assert row/row0umod.c line 660 in txn rollback - after crash recovery - -2010-05-25 The InnoDB Team - - * handler/ha_innodb.cc, include/row0mysql.h, row/row0mysql.c: - Fix Bug#53592: crash replacing duplicates into table after fast - alter table added unique key - -2010-05-24 The InnoDB Team - - * dict/dict0boot.c, dict/dict0crea.c, fil/fil0fil.c, - include/dict0boot.h, include/fil0fil.h, row/row0mysql.c: - Fix Bug#53578: assert on invalid page access, in fil_io() - -2010-05-14 The InnoDB Team - * mysql-test/innodb_bug48024.test, mysql-test/innodb_bug48024.result, - dict/dict0dict.c, handler/ha_innodb.cc, handler/ha_innodb.h, - include/dict0dict.h, include/ha_prototypes.h, include/row0mysql.h, - include/trx0trx.h, row/row0mysql.c, trx/trx0i_s.c, trx/trx0trx.c: - Fix Bug#48024 Innodb doesn't work with multi-statements - Fix Bug#53644 InnoDB thinks that /*/ starts and ends a comment - -2010-05-12 The InnoDB Team - - * handler/handler0alter.cc: - Fix Bug#53591 crash with fast alter table and text/blob prefix - primary key - -2010-05-12 The InnoDB Team - - * row/row0merge.c: - Fix Bug#53471 row_merge_drop_temp_indexes() refers freed memory, SEGVs - -2010-05-11 The InnoDB Team - - * mysql-test/innodb_bug53290.test, mysql-test/innodb_bug53290.result, - include/rem0cmp.h, rem/rem0cmp.c, row/row0merge.c: - Fix Bug#53290 wrong duplicate key error when adding a unique index - via fast alter table - -2010-05-11 The InnoDB Team - * buf/buf0lru.c, include/buf0buf.ic: - Fix Bug#53307 valgrind: warnings in main.partition_innodb_plugin - -2010-05-05 The InnoDB Team - - * row/row0merge.c: - Fix Bug#53256 in a stress test, assert dict/dict0dict.c:815 - table2 == NULL - -2010-05-05 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#53165 Setting innodb_change_buffering=DEFAULT produces - incorrect result - -2010-05-04 The InnoDB Team - - * fsp/fsp0fsp.c: - Fix Bug#53306 valgrind: warnings in innodb.innodb - -2010-05-03 The InnoDB Team - - * buf0buf.c: - Fix Bug#53248 compressed tables page checksum mismatch after - re-enabling innodb_checksums - -2010-04-28 The InnoDB Team - - * log/log0recv.h, log/log0recv.c: - Fix Bug#53122 InnoDB recovery uses too big a hash table for redo - log records - -2010-04-27 The InnoDB Team - - * handler/ha_innodb.cc, lock/lock0lock.c, row/row0mysql.c, - row/row0sel.c: - Fix Bug#48607 READ UNCOMMITTED uses more locks than READ COMMITTED - in InnoDB 5.1+ - -2010-04-26 The InnoDB Team - - * row/row0sel.c: - Fix Bug#52663 Lost update incrementing column value under - READ COMMITTED isolation level - -2010-04-22 The InnoDB Team - - * include/dict0boot.h, dict/dict0boot.c: - Fix a bug that prevented the crash recovery of fast CREATE INDEX - from dropping partially created indexes. - -2010-04-21 The InnoDB Team - - * btr/btr0btr.c: - Fix Bug#52964 Infinite loop in btr_page_split_and_insert() - in ROW_FORMAT=COMPRESSED - -2010-04-21 The InnoDB Team - - * data/data0data.c: - Fix Bug#52745 Failing assertion: blob_no < page_zip->n_blobs - -2010-04-20 The InnoDB Team - - * dict/dict0crea.c, handler/ha_innodb.cc, include/trx0trx.h: - Fix Bug#50495 'Row size too large' for plugin, but works for - built-in InnoDB - Only check the record size at index creation time when - innodb_strict_mode is set or when ROW_FORMAT is DYNAMIC or COMPRESSED. - -2010-04-15 The InnoDB Team - - * trx/trx0rec.c: - Fix Bug#52746 InnoDB purge thread crashed with table containing - prefix indexed blobs - -2010-03-31 The InnoDB Team - - * mysql-test/innodb_bug51920.test, mysql-test/innodb_bug51920.result, - srv/srv0srv.c: - Fix Bug#51920 InnoDB connections in row lock wait ignore KILL - until lock wait timeout - -2010-03-31 The InnoDB Team - - * mysql-test/innodb_bug38231.test: - Remove non-determinism in the test case. - -2010-03-29 The InnoDB Team - - InnoDB Plugin 1.0.7 released - -2010-03-18 The InnoDB Team - - * CMakeLists.txt: - Fix Bug#52102 InnoDB Plugin shows performance drop compared to - InnoDB (Windows) - -2010-03-18 The InnoDB Team - - * buf0buf.ic: - When comparing the time of the first access to a block against - innodb_old_blocks_time, use 32-bit arithmetics. The comparison was - incorrect on 64-bit systems. - -2010-03-11 The InnoDB Team - - * buf0buf.h, buf0buf.ic: - Fix and clarify the latching of some buf_block_t members. - Note that check_index_page_at_flush is not protected by any mutex. - Note and assert that lock_hash_val is protected by the rw-latch. - -2010-03-10 The InnoDB Team - - * trx/trx0sys.c: - Fix Bug#51653 outdated reference to set-variable - -2010-03-10 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb_bug21704.result, - mysql-test/innodb_bug47621.result, mysql-test/innodb_bug47621.test: - Fix Bug#47621 MySQL and InnoDB data dictionaries will become out of - sync when renaming columns - -2010-03-10 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#51356 Many Valgrind errors in error messages - with concurrent DDL - -2010-03-10 The InnoDB Team - - * handler/ha_innodb.cc, handler/handler0alter.cc, - mysql-test/innodb_bug51378.result, mysql-test/innodb_bug51378.test: - Fix Bug#51378 Init 'ref_length' to correct value, in case an out - of bound MySQL primary_key - -2010-03-10 The InnoDB Team - - * log/log0recv.c: - Remove a bogus assertion about page numbers exceeding 0x90000000 - in the redo log. Abort when encountering a corrupted redo log - record, unless innodb_force_recovery is set. - -2010-03-09 The InnoDB Team - - * handler/ha_innodb.cc: - Make SHOW ENGINE INNODB MUTEX STATUS display SUM(os_waits) - for the buffer pool block mutexes and locks. - -2010-03-08 The InnoDB Team - - * fil/fil0fil.c: - Fix ALTER TABLE ... IMPORT TABLESPACE of compressed tables. - -2010-03-03 The InnoDB Team - - * handler/handler0alter.cc, innodb-index.result, innodb-index.test, - innodb.result, innodb.test: - Disallow a duplicate index name when creating an index. - -2010-02-11 The InnoDB Team - - * include/mem0mem.h, include/mem0mem.ic, mem/mem0mem.c: - Fix Bug#49535 Available memory check slows down crash - recovery tens of times - -2010-02-09 The InnoDB Team - - * buf/buf0buf.c: - Fix Bug#38901 InnoDB logs error repeatedly when trying to load - page into buffer pool - -2010-02-09 The InnoDB Team - - * srv/srv0srv.c: - Let the master thread sleep if the amount of work to be done is - calibrated as taking less than a second. - -2010-02-04 The InnoDB Team - - * btr/btr0btr.c, btr/btr0cur.c, btr/btr0pcur.c, buf/buf0buf.c, - include/btr0btr.h, include/btr0cur.h, include/btr0pcur.h, - include/btr0pcur.ic, include/buf0buf.h, row/row0ins.c, row/row0sel.c: - Pass the file name and line number of the caller of the - b-tree cursor functions to the buffer pool requests, in order - to make the latch diagnostics more accurate. - -2010-02-03 The InnoDB Team - - * lock/lock0lock.c: - Fix Bug#49001 SHOW INNODB STATUS deadlock info incorrect - when deadlock detection aborts - -2010-02-03 The InnoDB Team - - * buf/buf0lru.c: - Fix Bug#35077 Very slow DROP TABLE (ALTER TABLE, OPTIMIZE TABLE) - on compressed tables - -2010-02-03 The InnoDB Team - - * handler/ha_innodb.cc, include/row0mysql.h, row/row0mysql.c: - Clean up CHECK TABLE error handling. - -2010-02-01 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb-autoinc.test, - mysql-test/innodb-autoinc.result, - mysql-test/innodb-autoinc-44030.test, - mysql-test/innodb-autoinc-44030.result: - Fix Bug#49497 Error 1467 (ER_AUTOINC_READ_FAILED) on inserting - a negative value - -2010-01-28 The InnoDB Team - * handler/ha_innodb.h, handler/ha_innodb.cc, - handler/handler0alter.cc, - mysql-test/innodb_bug47622.test, - mysql-test/innodb_bug47622.result: - Fix Bug#47622 the new index is added before the existing ones - in MySQL, but after one in SE - -2010-01-27 The InnoDB Team - - * include/row0mysql.h, log/log0recv.c, row/row0mysql.c: - Drop temporary tables at startup. - This addresses the third aspect of - Bug#41609 Crash recovery does not work for InnoDB temporary tables. - -2010-01-21 The InnoDB Team - - * buf/buf0buf.c: - Do not merge buffered inserts to compressed pages before - the redo log has been applied in crash recovery. - -2010-01-13 The InnoDB Team - - * row/row0sel.c: - On the READ UNCOMMITTED isolation level, do not attempt to access - a clustered index record that has been marked for deletion. The - built-in InnoDB in MySQL 5.1 and earlier would attempt to retrieve - a previous version of the record in this case. - -2010-01-13 The InnoDB Team - - * buf/buf0buf.c: - When disabling the adaptive hash index, check the block state - before checking block->is_hashed, because the latter may be - uninitialized right after server startup. - -2010-01-12 The InnoDB Team - - * handler/ha_innodb.cc, handler/ha_innodb.h: - Fix Bug#46193 crash when accessing tables after enabling - innodb_force_recovery option - -2010-01-12 The InnoDB Team - - * row/row0mysql.c: - Fix Bug#49238 Creating/Dropping a temporary table while at 1023 - transactions will cause assert. - -2009-12-02 The InnoDB Team - - * srv/srv0start.c: - Display the zlib version number at startup. - InnoDB compressed tables use zlib, and the implementation depends - on the zlib function compressBound(), whose definition was slightly - changed in zlib version 1.2.3.1 in 2006. MySQL bundles zlib 1.2.3 - from 2005, but some installations use a more recent zlib. - -2009-11-30 The InnoDB Team - - * dict/dict0crea.c, dict/dict0mem.c, dict/dict0load.c, - dict/dict0boot.c, fil/fil0fil.c, handler/ha_innodb.cc, - include/dict0mem.h, row/row0mysql.c: - Fix the bogus warning messages for non-existing temporary - tables that were reported in - Bug#41609 Crash recovery does not work for InnoDB temporary tables. - The actual crash recovery bug was corrected on 2009-04-29. - -2009-11-27 The InnoDB Team - - InnoDB Plugin 1.0.6 released - -2009-11-20 The InnoDB Team - - * handler/ha_innodb.cc: - Add a workaround to prevent a crash due to Bug#45961 DDL on - partitioned innodb tables leaves data dictionary in an inconsistent - state - -2009-11-19 The InnoDB Team - - * btr/btr0btr.c: - Fix Bug#48469 when innodb tablespace is configured too small, crash - and corruption! - -2009-11-19 The InnoDB Team - - * data/data0type.c: - Fix Bug#48526 Data type for float and double is incorrectly reported - in InnoDB table monitor - -2009-11-19 The InnoDB Team - - * CMakeLists.txt: - Fix Bug#48317 cannot build innodb as static library - -2009-11-18 The InnoDB Team - - * handler/handler0alter.cc: - Fix Bug#48782 On lock wait timeout, CREATE INDEX (creating primary key) - attempts DROP TABLE - -2009-11-17 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb.result, - mysql-test/innodb.test, mysql-test/innodb_bug44369.result, - mysql-test/innodb_bug44369.test, mysql-test/patches/innodb-index.diff, - row/row0mysql.c: - Report duplicate table names to the client connection, not to the - error log. - -2009-11-12 The InnoDB Team - - * handler/ha_innodb.cc, include/db0err.h, row/row0merge.c, - row/row0mysql.c: - Allow CREATE INDEX to be interrupted. - Also, when CHECK TABLE is interrupted, report ER_QUERY_INTERRUPTED. - -2009-11-11 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb_bug47167.result, - mysql-test/innodb_bug47167.test, mysql-test/innodb_file_format.result: - Fix Bug#47167 "set global innodb_file_format_check" cannot set value - by User-Defined Variable - -2009-11-11 The InnoDB Team - - * include/os0file.h, os/os0file.c: - Fix Bug#3139 Mysql crashes: 'windows error 995' after several selects - on a large DB - -2009-11-04 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#32430 'show innodb status' causes errors - Invalid (old?) table or database name in logs - -2009-11-02 The InnoDB Team - - * btr/btr0sea.c, buf/buf0buf.c, dict/dict0dict.c, fil/fil0fil.c, - ibuf/ibuf0ibuf.c, include/btr0sea.h, include/dict0dict.h, - include/fil0fil.h, include/ibuf0ibuf.h, include/lock0lock.h, - include/log0log.h, include/log0recv.h, include/mem0mem.h, - include/mem0pool.h, include/os0file.h, include/pars0pars.h, - include/srv0srv.h, include/thr0loc.h, include/trx0i_s.h, - include/trx0purge.h, include/trx0rseg.h, include/trx0sys.h, - include/trx0undo.h, include/usr0sess.h, lock/lock0lock.c, - log/log0log.c, log/log0recv.c, mem/mem0dbg.c, mem/mem0pool.c, - os/os0file.c, os/os0sync.c, os/os0thread.c, pars/lexyy.c, - pars/pars0lex.l, que/que0que.c, srv/srv0srv.c, srv/srv0start.c, - sync/sync0arr.c, sync/sync0sync.c, thr/thr0loc.c, trx/trx0i_s.c, - trx/trx0purge.c, trx/trx0rseg.c, trx/trx0sys.c, trx/trx0undo.c, - usr/usr0sess.c, ut/ut0mem.c: - Fix Bug#45992 innodb memory not freed after shutdown - Fix Bug#46656 InnoDB plugin: memory leaks (Valgrind) - -2009-10-29 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb-autoinc.result, - mysql-test/innodb-autoinc.test: - Fix Bug#47125 auto_increment start value is ignored if an index is - created and engine=innodb - -2009-10-29 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb_bug47777.result, - mysql-test/innodb_bug47777.test: - Fix Bug#47777 innodb dies with spatial pk: Failing assertion: buf <= - original_buf + buf_len - -2009-10-29 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#38996 Race condition in ANALYZE TABLE - -2009-10-29 The InnoDB Team - - * handler/ha_innodb.cc: - Fix bug#42383: Can't create table 'test.bug39438' - -2009-10-29 The InnoDB Team - - * os/os0proc.c: - Fix Bug#48237 Error handling in os_mem_alloc_large appears to - be incorrect - -2009-10-29 The InnoDB Team - - * buf/buf0buf.c, buf/buf0lru.c, include/buf0buf.h, include/buf0buf.ic: - Fix corruption of the buf_pool->LRU_old list and improve debug - assertions. - -2009-10-28 The InnoDB Team - - * srv/srv0start.c: - Fix Bug#41490 After enlargement of InnoDB page size, the error message - become inaccurate - -2009-10-26 The InnoDB Team - - * row/row0ins.c: - When allocating a data tuple, zero out the system fields in order - to avoid Valgrind warnings about uninitialized fields in - dtuple_validate(). - -2009-10-22 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb-zip.result, - mysql-test/innodb-zip.test, mysql-test/innodb_bug44369.result, - mysql-test/innodb_bug44369.test: - Fix Bug#47233 Innodb calls push_warning(MYSQL_ERROR::WARN_LEVEL_ERROR) - -2009-10-19 The InnoDB Team - - * mysql-test/innodb_information_schema.test: - Fix Bug#47808 innodb_information_schema.test fails when run under - valgrind - -2009-10-15 The InnoDB Team - - * include/page0page.ic: - Fix Bug#47058 Failure to compile innodb_plugin on solaris 10u7 + spro - cc/CC 5.10 - -2009-10-13 The InnoDB Team - - * buf/buf0flu.c: - Call fsync() on datafiles after a batch of pages is written to disk - even when skip_innodb_doublewrite is set. - -2009-10-05 The InnoDB Team - - * buf/buf0buf.c: - Do not invalidate buffer pool while an LRU batch is active. Added code - to buf_pool_invalidate() to wait for the running batches to finish. - -2009-10-01 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#47763 typo in error message: Failed to open table %s after %lu - attemtps. - -2009-10-01 The InnoDB Team - - * fsp/fsp0fsp.c, row/row0merge.c: - Clean up after a crash during DROP INDEX. When InnoDB crashes - while dropping an index, ensure that the index will be completely - dropped during crash recovery. The MySQL .frm file may still - contain the dropped index, but there is little that we can do - about it. - -2009-09-28 The InnoDB Team - - * handler/ha_innodb.cc: - When a secondary index exists in the MySQL .frm file but not in - the InnoDB data dictionary, return an error instead of letting an - assertion fail in index_read. - -2009-09-28 The InnoDB Team - - * btr/btr0btr.c, buf/buf0buf.c, include/page0page.h, - include/page0zip.h, page/page0cur.c, page/page0page.c, - page/page0zip.c: - Do not write to PAGE_INDEX_ID when restoring an uncompressed page - after a compression failure. The field should only be written - when creating a B-tree page. This fix addresses a race condition - in a debug assertion. - -2009-09-28 The InnoDB Team - - * fil/fil0fil.c: - Try to prevent the reuse of tablespace identifiers after InnoDB - has crashed during table creation. Also, refuse to start if files - with duplicate tablespace identifiers are encountered. - -2009-09-25 The InnoDB Team - - * include/os0file.h, os/os0file.c: - Fix Bug#47055 unconditional exit(1) on ERROR_WORKING_SET_QUOTA - 1453 (0x5AD) for InnoDB backend - -2009-09-19 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb-consistent-master.opt, - mysql-test/innodb-consistent.result, - mysql-test/innodb-consistent.test: - Fix Bug#37232 Innodb might get too many read locks for DML with - repeatable-read - -2009-09-19 The InnoDB Team - - * fsp/fsp0fsp.c: - Fix Bug#31183 Tablespace full problems not reported in error log, - error message unclear - -2009-09-17 The InnoDB Team - - * mysql-test/innodb-zip.result, mysql-test/innodb-zip.test: - Make the test pass with zlib 1.2.3.3. Apparently, the definition - of compressBound() has changed between zlib versions, and the - maximum record size of a table with 1K compressed page size has - been reduced by one byte. This is an arbitrary test. In practical - applications, for good write performance, the compressed page size - should be chosen to be bigger than the absolute minimum. - -2009-09-16 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#46256 drop table with unknown collation crashes innodb - -2009-09-16 The InnoDB Team - - * dict/dict0dict.c, handler/ha_innodb.cc, - mysql-test/innodb_bug44369.result, mysql-test/innodb_bug44369.test, - row/row0mysql.c: - Fix Bug#44369 InnoDB: Does not uniformly disallow disallowed column - names - -2009-09-16 The InnoDB Team - - * handler/ha_innodb.cc, include/db0err.h, - mysql-test/innodb_bug46000.result, mysql-test/innodb_bug46000.test: - Fix Bug#46000 using index called GEN_CLUST_INDEX crashes server - -2009-09-02 The InnoDB Team - - * include/lock0lock.h, include/row0mysql.h, lock/lock0lock.c, - row/row0mysql.c: - Fix a regression introduced by the fix for MySQL bug#26316. We check - whether a transaction holds any AUTOINC locks before we acquire - the kernel mutex and release those locks. - -2009-08-27 The InnoDB Team - - * dict/dict0dict.c, include/dict0dict.h, - mysql-test/innodb_bug44571.result, mysql-test/innodb_bug44571.test: - Fix Bug#44571 InnoDB Plugin crashes on ADD INDEX - -2009-08-27 The InnoDB Team - - * row/row0merge.c: - Fix a bug in the merge sort that can corrupt indexes in fast index - creation. Add some consistency checks. Check that the number of - records remains constant in every merge sort pass. - -2009-08-27 The InnoDB Team - - * buf/buf0buf.c, buf/buf0lru.c, buf/buf0rea.c, handler/ha_innodb.cc, - include/buf0buf.h, include/buf0buf.ic, include/buf0lru.h, - include/ut0ut.h, ut/ut0ut.c: - Make it possible to tune the buffer pool LRU eviction policy to be - more resistant against index scans. Introduce the settable global - variables innodb_old_blocks_pct and innodb_old_blocks_time for - controlling the buffer pool eviction policy. The parameter - innodb_old_blocks_pct (5..95) controls the desired amount of "old" - blocks in the LRU list. The default is 37, corresponding to the - old fixed ratio of 3/8. Each time a block is accessed, it will be - moved to the "new" blocks if its first access was at least - innodb_old_blocks_time milliseconds ago (default 0, meaning every - block). The idea is that in index scans, blocks will be accessed - a few times within innodb_old_blocks_time, and they will remain in - the "old" section of the LRU list. Thus, when innodb_old_blocks_time - is nonzero, blocks retrieved for one-time index scans will be more - likely candidates for eviction than blocks that are accessed in - random patterns. - -2009-08-26 The InnoDB Team - - * handler/ha_innodb.cc, os/os0file.c: - Fix Bug#42885 buf_read_ahead_random, buf_read_ahead_linear counters, - thread wakeups - -2009-08-20 The InnoDB Team - - * lock/lock0lock.c: - Fix Bug#46650 Innodb assertion autoinc_lock == lock in - lock_table_remove_low on INSERT SELECT - -2009-08-13 The InnoDB Team - - * handler/handler0alter.cc: - Fix Bug#46657 InnoDB plugin: invalid read in index_merge_innodb test - (Valgrind) - -2009-08-11 The InnoDB Team - - InnoDB Plugin 1.0.4 released - -2009-07-20 The InnoDB Team - - * buf/buf0rea.c, handler/ha_innodb.cc, include/srv0srv.h, - srv/srv0srv.c: - Change the read ahead parameter name to innodb_read_ahead_threshold. - Change the meaning of this parameter to signify the number of pages - that must be sequentially accessed for InnoDB to trigger a readahead - request. - -2009-07-20 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#39802 On Windows, 32-bit time_t should be enforced - -2009-07-16 The InnoDB Team - - * include/univ.i: - Support inlining of functions and prefetch with Sun Studio. - These changes are based on contribution from Sun Microsystems Inc. - under a BSD license. - -2009-07-14 The InnoDB Team - - * fil/fil0fil.c: - Fix Bug#45814 URL reference in InnoDB server errors needs adjusting to - match documentation - -2009-07-14 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb_bug21704.result, - mysql-test/innodb_bug21704.test: - Fix Bug#21704 Renaming column does not update FK definition - -2009-07-10 The InnoDB Team - - * handler/ha_innodb.cc, srv/srv0srv.c: - Change the defaults for - innodb_sync_spin_loops: 20 -> 30 - innodb_spin_wait_delay: 5 -> 6 - -2009-07-08 The InnoDB Team - - * buf/buf0flu.c, handler/ha_innodb.cc, include/buf0flu.h, - include/log0log.h, include/log0log.ic, include/srv0srv.h, - srv/srv0srv.c: - Implement the adaptive flushing of dirty pages, which uses - a heuristics based flushing rate of dirty pages to avoid IO - bursts at checkpoint. Expose new configure knob - innodb_adaptive_flushing to control whether the new flushing - algorithm should be used. - -2009-07-07 The InnoDB Team - - * handler/ha_innodb.cc, include/srv0srv.h, log/log0log.c, - srv/srv0srv.c: - Implement IO capacity tuning. Expose new configure knob - innodb_io_capacity to control the master threads IO rate. The - ibuf merge is also changed from synchronous to asynchronous. - These changes are based on contribution from Google Inc. - under a BSD license. - -2009-07-02 The InnoDB Team - - * include/ut0ut.h, plug.in, ut/ut0ut.c: - Use the PAUSE instruction inside the spinloop if it is available, - Thanks to Mikael Ronstrom . - -2009-06-29 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb_file_format.test, - mysql-test/innodb_file_format.result: - Do not crash on SET GLOBAL innodb_file_format=DEFAULT - or SET GLOBAL innodb_file_format_check=DEFAULT. - -2009-06-29 The InnoDB Team - - * buf/buf0buf.c, buf/buf0rea.c, lock/lock0lock.c: - Tolerate missing tablespaces during crash recovery and when - printing information on locks. - -2009-06-29 The InnoDB Team - - * buf/buf0buf.c: - Fix a race condition when reading buf_fix_count. - Currently, it is not being protected by the buffer pool mutex, - but by the block mutex. - -2009-06-29 The InnoDB Team - - * handler/handler0alter.cc: - Start the user transaction prebuilt->trx if it was not started - before adding or dropping an index. Without this fix, the - table could be locked outside an active transaction. - -2009-06-25 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb_bug42101.test, - mysql-test/innodb_bug42101.result, - mysql-test/innodb_bug42101-nonzero.test, - mysql-test/innodb_bug42101-nonzero.result: - Fix Bug#45749 Race condition in SET GLOBAL - innodb_commit_concurrency=DEFAULT - -2009-06-25 The InnoDB Team - - * dict/dict0dict.c: - When an index column cannot be found in the table during index - creation, display additional diagnostic before an assertion failure. - This does NOT fix Bug#44571 InnoDB Plugin crashes on ADD INDEX, - but it helps understand the reason of the crash. - -2009-06-17 The InnoDB Team - - * row/row0merge.c: - Fix Bug#45426 UNIV_DEBUG build cause assertion error at CREATE INDEX - -2009-06-17 The InnoDB Team - - * mysql-test/innodb_bug45357.result, mysql-test/innodb_bug45357.test, - row/row0mysql.c: - Fix Bug#45357 5.1.35 crashes with Failing assertion: index->type & - DICT_CLUSTERED - -2009-06-17 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb-autoinc.result, - mysql-test/innodb-autoinc.test: - Fix Bug#44030 Error: (1500) Couldn't read the MAX(ID) autoinc value - from the index (PRIMARY) - -2009-06-11 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb.result, srv/srv0srv.c: - Change the following defaults: - max_dirty_pages_pct: from 90 to 75, max allowed from 100 to 99 - additional_mem_pool_size: from 1 to 8 MB - buffer_pool_size: from 8 to 128 MB - log_buffer_size: from 1 to 8 MB - read_io_threads/write_io_threads: from 1 to 4 - -2009-06-09 The InnoDB Team - - * handler/ha_innodb.cc, include/trx0trx.h, trx/trx0trx.c: - Enable Group Commit functionality that was broken in 5.0 when - distributed transactions were introduced. - -2009-06-05 The InnoDB Team - - * handler/ha_innodb.cc, include/os0file.h, include/srv0srv.h, - os/os0file.c, srv/srv0srv.c, srv/srv0start.c: - Enable functionality to have multiple background IO helper threads. - Expose new configure knobs innodb_read_io_threads and - innodb_write_io_threads and deprecate innodb_file_io_threads (this - parameter was relevant only on windows). Internally this allows - multiple segments for read and write IO request arrays where one - thread works on one segment. - -2009-06-05 The InnoDB Team - - * buf/buf0lru.c, buf/buf0rea.c, handler/ha_innodb.cc, - include/srv0srv.h, srv/srv0srv.c: - Fix a bug in linear read ahead: - 1) Take into account access pattern when deciding whether or not to - do linear read ahead. - 2) Expose a knob innodb_read_ahead_factor = [0-64] default (8), - dynamic, global to control linear read ahead behavior. This is the - value of the number of pages that InnoDB will tolerate within a - 64 page extent even if they are accessed out of order or have - not been accessed at all. This number (which varies from 0 to 64) - is indicative of the slack that we have when deciding about linear - readahead. - 3) Disable random read ahead. Keep the code for now. - -2009-06-03 The InnoDB Team - - * dict/dict0dict.c, mysql-test/t/innodb_mysql.test, - mysql-test/r/innodb_mysql.result: - Fix Bug#39793 Foreign keys not constructed when column - has a '#' in a comment or default value - -2009-05-27 The InnoDB Team - - * Doxyfile: - Allow the extraction of documentation from the code base with the - Doxygen tool. Convert and add many (but not yet all) comments to - Doxygen format. - -2009-05-19 The InnoDB Team - - * btr/btr0btr.c, btr/btr0cur.c, lock/lock0lock.c, - include/page0page.ic, include/lock0lock.h, include/dict0dict.h, - include/page0page.h, include/dict0dict.ic, ibuf/ibuf0ibuf.c, - page/page0zip.c, page/page0page.c: - Write updates of PAGE_MAX_TRX_ID to the redo log and add debug - assertions for checking that PAGE_MAX_TRX_ID is valid on leaf - pages of secondary indexes and the insert buffer B-tree. This bug - could cause failures in secondary index lookups in consistent - reads right after crash recovery. - -2009-05-18 The InnoDB Team - - * btr/btr0cur.c: - Correctly estimate the space needed on the compressed page when - performing an update by delete-and-insert. - -2009-05-14 The InnoDB Team - - * handler/ha_innodb.cc, include/srv0srv.h, - mysql-test/innodb_bug42101-nonzero-master.opt, - mysql-test/innodb_bug42101-nonzero.result, - mysql-test/innodb_bug42101-nonzero.test, - mysql-test/innodb_bug42101.result, mysql-test/innodb_bug42101.test, - srv/srv0srv.c: - Fix Bug#42101 Race condition in innodb_commit_concurrency - -2009-05-13 The InnoDB Team - - * dict/dict0dict.c: - Fix Bug#44320 InnoDB: missing DB_ROLL_PTR in Table Monitor COLUMNS - output - -2009-04-29 The InnoDB Team - - * fil/fil0fil.c, include/fil0fil.h, include/mtr0mtr.h, - log/log0recv.c: - Fix Bug#41609 Crash recovery does not work for InnoDB temporary tables - -2009-04-23 The InnoDB Team - - * row/row0mysql.c: - When scanning indexes, report in the error log any error codes - returned by the search function. These error codes will still be - ignored in CHECK TABLE. - -2009-04-23 The InnoDB Team - - * include/trx0types.h: - Define the logical type names trx_id_t, roll_ptr_t, and undo_no_t - and use them in place of dulint everywhere. - -2009-04-18 The InnoDB Team - - * handler/ha_innodb.cc, include/pars0pars.h: - Fix Bug#29125 Windows Server X64: so many compiler warnings - -2009-04-16 The InnoDB Team - - * include/univ.i: - Define REFMAN as the base URL of the MySQL Reference Manual and - use the macro in all diagnostic output. - -2009-04-16 The InnoDB Team - - * CMakeLists.txt, include/os0sync.h, include/sync0sync.h, - include/sync0sync.ic, include/univ.i, srv/srv0start.c, - sync/sync0sync.c: - Use the Windows Interlocked functions for atomic memory - access. - -2009-04-15 The InnoDB Team - - * mysql-test/innodb.result, mysql-test/innodb.test: - Fix Bug#43309 Test main.innodb can't be run twice - -2009-04-14 The InnoDB Team - - * CMakeLists.txt, handler/win_delay_loader.cc, - win-plugin/win-plugin.diff: - Remove statically linked libraries from MySQL (zlib and strings). - -2009-04-11 The InnoDB Team - - * CMakeLists.txt, win-plugin/README, win-plugin/win-plugin.diff: - Rewrite CMakeLists.txt. - -2009-04-07 The InnoDB Team - - * include/os0sync.h, include/sync0rw.ic, include/sync0sync.h, - include/sync0sync.ic, include/univ.i, plug.in, srv/srv0srv.c, - srv/srv0start.c, sync/sync0arr.c, sync/sync0sync.c: - Enable atomics on Solaris (using the libc functions as defined in - atomic.h) if GCC atomic builtins are not present. - -2009-04-07 The InnoDB Team - - * btr/btr0btr.c, dict/dict0dict.c, ibuf/ibuf0ibuf.c, - include/data0data.h, include/data0data.ic, include/data0type.h, - include/data0type.ic, include/dict0dict.h, include/dict0dict.ic, - include/rem0rec.ic, mysql-test/innodb.result, mysql-test/innodb.test, - pars/pars0pars.c, rem/rem0rec.c, row/row0upd.c: - Fix Bug#44032 In ROW_FORMAT=REDUNDANT, update UTF-8 CHAR - to/from NULL is not in-place - -2009-04-07 The InnoDB Team - - * page/page0cur.c: - Fix Bug#43660 SHOW INDEXES/ANALYZE does NOT update cardinality for - indexes of InnoDB table - -2009-04-06 The InnoDB Team - - * handler/ha_innodb.cc: - Make the parameter innodb_change_buffering settable by the - configuration file or mysqld command line options. Before this - fix, the initial value specified for this parameter was ignored. - -2009-04-06 The InnoDB Team - - * sync/sync0rw.c: - Avoid a bogus failure in UNIV_SYNC_DEBUG diagnostics. - -2009-04-02 The InnoDB Team - - * handler/ha_innodb.cc, include/srv0srv.h, srv/srv0srv.c: - Add new parameter innodb_spin_wait_delay to set the maximum delay - between polling for a spin lock. - -2009-04-02 The InnoDB Team - - * dict/dict0crea.c, handler/ha_innodb.cc, handler/ha_innodb.h, - include/dict0mem.h, include/row0merge.h, include/row0mysql.h, - mysql-test/innodb-index.result, mysql-test/innodb-index.test, - row/row0merge.c, row/row0sel.c: - In consistent reads, refuse to use newly created indexes that may - lack history. - -2009-03-25 The InnoDB Team - - * buf/buf0buf.c, handler/ha_innodb.cc, include/buf0buf.h: - In SHOW ENGINE INNODB MUTEX do not show the status of block->mutex, - block->lock, block->lock->mutex (if applicable) and all mutexes and - rw-locks for which number of os-waits are zero because this can - be overwhelming particularly when the buffer pool is very large. - -2009-03-20 The InnoDB Team - - * buf/buf0buf.c, include/log0recv.h, log/log0recv.c: - Remove the compile-time constant parameters of - recv_recover_page(), recv_scan_log_recs(), and recv_sys_init(). - -2009-03-20 The InnoDB Team - - * data/data0type.c, handler/ha_innodb.cc, include/ha_prototypes.h: - Declare innobase_get_at_most_n_mbchars() in ha_prototypes.h. - -2009-03-20 The InnoDB Team - - * fil/fil0fil.h, fil/fil0fil.c, srv/srv0start.c: - Add the parameter hash_size to fil_init(). - -2009-03-20 The InnoDB Team - - * fil/fil0fil.c: - Refer to fil_system directly, not via local variables. - -2009-03-20 The InnoDB Team - - * page/page0page.c: - In page_validate(), always report the space id, page number and - the name of the index when corruption is noticed. - -2009-03-20 The InnoDB Team - - * include/log0log.h, include/log0log.ic, log/log0log.c: - Add in/out comments or const qualifiers to some function - parameters as appropriate. - -2009-03-20 The InnoDB Team - - * dict/dict0boot.c, dict/dict0dict.c, fsp/fsp0fsp.c, - include/dict0dict.h, include/srv0srv.h, srv/srv0srv.c, - page/page0page.c: - Replace srv_sys->dummy_ind1 and srv_sys->dummy_ind2 with - dict_ind_redundant and dict_ind_compact, which are - initialized by dict_init(). - -2009-03-11 The InnoDB Team - - InnoDB Plugin 1.0.3 released - -2009-03-05 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb-autoinc.result, - mysql-test/innodb-autoinc.test: - Fix Bug#43203 Overflow from auto incrementing causes server segv - -2009-02-25 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb-autoinc.result, - mysql-test/innodb-autoinc.test: - Fix Bug#42714 AUTO_INCREMENT errors in 5.1.31 - -2009-02-23 The InnoDB Team - - * btr/btr0cur.c: - Fix Bug#43043 Crash on BLOB delete operation - -2009-02-20 The InnoDB Team - - * handler/ha_innodb.cc: - Make innodb_use_sys_malloc=ON the default. - -2009-02-20 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb-autoinc.result, - mysql-test/innodb-autoinc.test: - Fix Bug#42400 InnoDB autoinc code can't handle floating-point columns - -2009-02-18 The InnoDB Team - - * include/ut0mem.h, os/os0proc.c, ut/ut0mem.c: - Protect ut_total_allocated_memory with ut_list_mutex in - os_mem_alloc_large() and os_mem_free_large(). The lack of this mutex - protection could cause an assertion failure during fast index - creation. Also, add UNIV_MEM_ALLOC and UNIV_MEM_FREE instrumentation - to os_mem_alloc_large() and os_mem_free_large(), so that Valgrind can - detect more errors. - -2009-02-11 The InnoDB Team - - * handler/ha_innodb.cc: - Make innodb_thread_concurrency=0 the default. The old default value - was 8. A non-zero setting may be useful when InnoDB is showing severe - scalability problems under multiple concurrent connections. - -2009-02-10 The InnoDB Team - - * handler/ha_innodb.cc, handler/ha_innodb.h: - Fix Bug#41676 Table names are case insensitive in locking - -2009-02-10 The InnoDB Team - - * mem/mem0dbg.c, mem/mem0mem.c, mem/mem0pool.c: - When innodb_use_sys_malloc is set, ignore - innodb_additional_mem_pool_size, because nothing will be allocated - from mem_comm_pool. - -2009-02-10 The InnoDB Team - - * ut/ut0mem.c: - Map ut_malloc_low(), ut_realloc(), and ut_free() directly to malloc(), - realloc(), and free() when innodb_use_sys_malloc is set. As a side - effect, ut_total_allocated_memory ("Total memory allocated" in the - "BUFFER POOL AND MEMORY" section of SHOW ENGINE INNODB STATUS) will - exclude any memory allocated by these functions when - innodb_use_sys_malloc is set. - -2009-02-10 The InnoDB Team - - * btr/btr0cur.c, btr/btr0sea.c, buf/buf0buf.c, handler/ha_innodb.cc, - include/buf0buf.ic, include/os0sync.h, include/srv0srv.h, - include/sync0rw.h, include/sync0rw.ic, include/sync0sync.h, - include/sync0sync.ic, include/univ.i, row/row0sel.c, srv/srv0srv.c, - srv/srv0start.c, sync/sync0arr.c, sync/sync0rw.c, sync/sync0sync.c: - On those platforms that support it, implement the synchronization - primitives of InnoDB mutexes and read/write locks with GCC atomic - builtins instead of Pthreads mutexes and InnoDB mutexes. These changes - are based on a patch supplied by Mark Callaghan of Google under a BSD - license. - -2009-01-30 The InnoDB Team - - * btr/btr0cur.c, btr/btr0sea.c, buf/buf0buf.c, handler/ha_innodb.cc, - include/btr0sea.h, include/buf0buf.h, include/sync0sync.h, - sync/sync0sync.c: - Make the configuration parameter innodb_adaptive_hash_index dynamic, - so that it can be changed at runtime. - -2009-01-29 The InnoDB Team - - * handler/ha_innodb.cc, ibuf/ibuf0ibuf.c, include/ibuf0ibuf.h, - include/ibuf0ibuf.ic: - Implement the settable global variable innodb_change_buffering, - with the allowed values 'none' and 'inserts'. The default value - 'inserts' enables the buffering of inserts to non-unique secondary - index trees when the B-tree leaf page is not in the buffer pool. - -2009-01-27 The InnoDB Team - - * buf/buf0lru.c: - Fix a race condition in buf_LRU_invalidate_tablespace(): The - compressed page size (zip_size) was read while the block descriptor - was no longer protected by a mutex. This could lead to corruption - when a table is dropped on a busy system that contains compressed - tables. - -2009-01-26 The InnoDB Team - - * btr/btr0sea.c, buf/buf0buf.c, include/buf0buf.h, include/buf0buf.ic, - include/mtr0log.ic, include/row0upd.ic, mtr/mtr0mtr.c: - Implement buf_block_align() with pointer arithmetics, as it is in the - built-in InnoDB distributed with MySQL. Do not acquire the buffer pool - mutex before buf_block_align(). This removes a scalability bottleneck - in the adaptive hash index lookup. In CHECK TABLE, check that - buf_pool->page_hash is consistent with buf_block_align(). - -2009-01-23 The InnoDB Team - - * btr/btr0sea.c: - Fix Bug#42279 Race condition in btr_search_drop_page_hash_when_freed() - -2009-01-23 The InnoDB Team - - * buf/buf0buf.c, include/buf0buf.h: - Remove the unused mode BUF_GET_NOWAIT of buf_page_get_gen() - -2009-01-20 The InnoDB Team - - * include/rem0rec.h, include/rem0rec.ic: - Fix Bug#41571 MySQL segfaults after innodb recovery - -2009-01-20 The InnoDB Team - - * lock/lock0lock.c: - Fix Bug#42152 Race condition in lock_is_table_exclusive() - -2009-01-14 The InnoDB Team - - * include/trx0roll.h, trx/trx0roll.c, trx/trx0trx.c: - Fix Bug#38187 Error 153 when creating savepoints - -2009-01-14 The InnoDB Team - - * dict/dict0load.c: - Fix Bug#42075 dict_load_indexes failure in dict_load_table will - corrupt the dictionary cache - -2009-01-13 The InnoDB Team - - * buf/buf0buddy.c, dict/dict0dict.c, dict/dict0mem.c, fil/fil0fil.c, - ha/ha0storage.c, handler/ha_innodb.cc, handler/win_delay_loader.cc, - include/buf0buf.ic, include/dict0dict.ic, include/hash0hash.h, - thr/thr0loc.c, trx/trx0i_s.c: - Add the parameter ASSERTION to HASH_SEARCH() macro, and use it for - light validation of the traversed items in hash table lookups when - UNIV_DEBUG is enabled. - -2009-01-09 The InnoDB Team - - * buf/buf0flu.c, include/buf0flu.h, include/buf0flu.ic: - Remove unused code from the functions - buf_flush_insert_into_flush_list() and - buf_flush_insert_sorted_into_flush_list(). - -2009-01-09 The InnoDB Team - - * buf/buf0flu.c: - Simplify the functions buf_flush_try_page() and buf_flush_batch(). Add - debug assertions and an explanation to buf_flush_write_block_low(). - -2009-01-07 The InnoDB Team - - * row/row0merge.c: - Fix a bug in recovery when dropping temporary indexes. - -2009-01-07 The InnoDB Team - - * handler/ha_innodb.cc, handler/ha_innodb.h, handler/handler0alter.cc: - Fix Bug#41680 calls to trx_allocate_for_mysql are not consistent - -2009-01-07 The InnoDB Team - - * mysql-test/innodb_bug41904.result, mysql-test/innodb_bug41904.test, - row/row0merge.c: - Fix Bug#41904 create unique index problem - -2009-01-02 The InnoDB Team - - * handler/ha_innodb.cc, include/srv0srv.h, mem/mem0pool.c, - mysql-test/innodb-use-sys-malloc-master.opt, - mysql-test/innodb-use-sys-malloc.result, - mysql-test/innodb-use-sys-malloc.test, srv/srv0srv.c, srv/srv0start.c: - Implement the configuration parameter innodb_use_sys_malloc (false by - default), for disabling InnoDB's internal memory allocator and using - system malloc/free instead. The "BUFFER POOL AND MEMORY" section of - SHOW ENGINE INNODB STATUS will report "in additional pool allocated - allocated 0" when innodb_use_sys_malloc is set. - -2008-12-30 The InnoDB Team - - * btr/btr0btr.c: - When setting the PAGE_LEVEL of a compressed B-tree page from or to 0, - compress the page at the same time. This is necessary, because the - column information stored on the compressed page will differ between - leaf and non-leaf pages. Leaf pages are identified by PAGE_LEVEL=0. - This bug can make InnoDB crash when all rows of a compressed table are - deleted. - -2008-12-17 The InnoDB Team - - * include/row0sel.h, include/row0upd.h, pars/pars0pars.c, - row/row0mysql.c, row/row0sel.c, row/row0upd.c: - Remove update-in-place select from the internal SQL interpreter. It - was only used for updating the InnoDB internal data dictionary when - renaming or dropping tables. It could have caused deadlocks when - acquiring latches on insert buffer bitmap pages. - -2008-12-17 The InnoDB Team - - * btr/btr0sea.c, buf/buf0buf.c, buf/buf0lru.c, ha/ha0ha.c, - ha/hash0hash.c, include/buf0buf.h, include/ha0ha.h, include/ha0ha.ic, - include/hash0hash.h, include/univ.i: - Introduce the preprocessor symbol UNIV_AHI_DEBUG for enabling adaptive - hash index debugging independently of UNIV_DEBUG. - -2008-12-16 The InnoDB Team - - * btr/btr0cur.c: - Do not update the free bits in the insert buffer bitmap when inserting - or deleting from the insert buffer B-tree. Assert that records in the - insert buffer B-tree are never updated. - -2008-12-12 The InnoDB Team - - * buf/buf0buf.c, fil/fil0fil.c, fsp/fsp0fsp.c, ibuf/ibuf0ibuf.c, - include/fil0fil.h, include/ibuf0ibuf.h, include/ibuf0ibuf.ic, - include/ibuf0types.h: - Clean up the insert buffer subsystem so that only one insert - buffer B-tree exists. - Originally, there were provisions in InnoDB for multiple insert - buffer B-trees, apparently one for each tablespace. - When Heikki Tuuri implemented multiple InnoDB tablespaces in - MySQL/InnoDB 4.1, he made the insert buffer live only in the - system tablespace (space 0) but left the provisions in the code. - -2008-12-11 The InnoDB Team - - * include/srv0srv.h, os/os0proc.c, srv/srv0srv.c: - Fix the issue that the InnoDB plugin fails if innodb_buffer_pool_size - is defined bigger than 4096M on 64-bit Windows. This bug should not - have affected other 64-bit systems. - -2008-12-09 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#40386 Not flushing query cache after truncate. - -2008-12-09 The InnoDB Team - - * handler/ha_innodb.cc, srv/srv0srv.c, trx/trx0trx.c: - Fix Bug#40760 "set global innodb_thread_concurrency = 0;" is not safe - -2008-12-04 The InnoDB Team - - * handler/ha_innodb.cc, handler/mysql_addons.cc, - include/mysql_addons.h, trx/trx0i_s.c, win-plugin/win-plugin.diff: - Remove dependencies to MySQL internals (defining MYSQL_SERVER). - -2008-12-02 The InnoDB Team - - * page/page0cur.c: - When allocating space for a record from the free list of previously - purged records, zero out the DB_TRX_ID and DB_ROLL_PTR of the purged - record if the new record would not overwrite these fields. This fixes - a harmless content mismatch reported by page_zip_validate(). - -2008-12-02 The InnoDB Team - - * row/row0merge.c: - Replace the WHILE 1 with WHILE 1=1 in the SQL procedure, so that the - loop will actually be entered and temporary indexes be dropped during - crash recovery. - -2008-12-01 The InnoDB Team - - InnoDB Plugin 1.0.2 released - -2008-10-31 The InnoDB Team - - * dict/dict0mem.c, include/dict0mem.h, include/lock0lock.h, - include/row0mysql.h, include/trx0trx.h, include/univ.i, - include/ut0vec.h, include/ut0vec.ic, lock/lock0lock.c, - row/row0mysql.c, trx/trx0trx.c: - Fix Bug#26316 Triggers create duplicate entries on auto-increment - columns - -2008-10-30 The InnoDB Team - - * handler/ha_innodb.cc, handler/handler0vars.h, - handler/win_delay_loader.cc, mysql-test/innodb_bug40360.result, - mysql-test/innodb_bug40360.test: - Fix Bug#40360 Binlog related errors with binlog off - -2008-10-29 The InnoDB Team - - * include/data0type.ic: - Fix Bug#40369 dtype_get_sql_null_size() returns 0 or 1, not the size - -2008-10-29 The InnoDB Team - - * handler/ha_innodb.cc, include/srv0srv.h, srv/srv0srv.c: - Fix Bug#38189 innodb_stats_on_metadata missing - -2008-10-28 The InnoDB Team - - * CMakeLists.txt, ha_innodb.def, handler/ha_innodb.cc, - handler/handler0alter.cc, handler/handler0vars.h, handler/i_s.cc, - handler/win_delay_loader.cc, win-plugin/*: - Implemented the delayloading of externals for the plugin on Windows. - This makes it possible to build a dynamic plugin (ha_innodb.dll) on - Windows. - -2008-10-27 The InnoDB Team - - * CMakeLists.txt: - Fix Bug#19424 InnoDB: Possibly a memory overrun of the buffer being - freed (64-bit Visual C) - -2008-10-23 The InnoDB Team - - * ibuf/ibuf0ibuf.c: - ibuf_delete_rec(): When the cursor to the insert buffer record - cannot be restored, do not complain if the tablespace does not - exist, because the insert buffer record may have been discarded by - some other thread. This bug has existed in MySQL/InnoDB since - version 4.1, when innodb_file_per_table was implemented. - This may fix Bug#27276 InnoDB Error: ibuf cursor restoration fails. - -2008-10-22 The InnoDB Team - - * dict/dict0dict.c, dict/dict0mem.c, handler/ha_innodb.cc, - handler/ha_innodb.h, include/dict0dict.h, include/dict0mem.h, - row/row0mysql.c: - Fix Bug#39830 Table autoinc value not updated on first insert - Fix Bug#35498 Cannot get table test/table1 auto-inccounter value in - ::info - Fix Bug#36411 "Failed to read auto-increment value from storage - engine" in 5.1.24 auto-inc - -2008-10-22 The InnoDB Team - - * handler/ha_innodb.cc, include/row0mysql.h, row/row0mysql.c: - Fix Bug#40224 New AUTOINC changes mask reporting of deadlock/timeout - errors - -2008-10-16 The InnoDB Team - - * dict/dict0dict.c, mysql-test/innodb-index.result, - mysql-test/innodb-index.test: - Skip the undo log size check when creating REDUNDANT and COMPACT - tables. In ROW_FORMAT=DYNAMIC and ROW_FORMAT=COMPRESSED, column - prefix indexes require that prefixes of externally stored columns - be written to the undo log. This may make the undo log record - bigger than the record on the B-tree page. The maximum size of an - undo log record is the page size. That must be checked for, in - dict_index_add_to_cache(). However, this restriction must not - be enforced on REDUNDANT or COMPACT tables. - -2008-10-15 The InnoDB Team - - * btr/btr0cur.c, include/btr0cur.h, row/row0ext.c, row/row0sel.c, - row/row0upd.c: - When the server crashes while freeing an externally stored column - of a compressed table, the BTR_EXTERN_LEN field in the BLOB - pointer will be written as 0. Tolerate this in the functions that - deal with externally stored columns. This fixes problems after - crash recovery, in the rollback of incomplete transactions, and in - the purge of delete-marked records. - -2008-10-15 The InnoDB Team - - * btr/btr0btr.c, include/page0zip.h, page/page0zip.c, include/univ.i: - When a B-tree node of a compressed table is split or merged, the - compression may fail. In this case, the entire compressed page - will be copied and the excess records will be deleted. However, - page_zip_copy(), now renamed to page_zip_copy_recs(), copied too - many fields in the page header, overwriting PAGE_BTR_SEG_LEAF and - PAGE_BTR_SEG_TOP when splitting the B-tree root. This caused - corruption of compressed tables. Furthermore, the lock table and - the adaptive hash index would be corrupted, because we forgot to - update them when invoking page_zip_copy_recs(). - - Introduce the symbol UNIV_ZIP_DEBUG for triggering the copying of - compressed pages more often, for debugging purposes. - -2008-10-10 The InnoDB Team - - * handler/handler0alter.cc, include/row0merge.h, row/row0merge.c, - row/row0mysql.c: - Fix some locking issues, mainly in fast index creation. The - InnoDB data dictionary cache should be latched whenever a - transaction is holding locks on any data dictionary tables. - Otherwise, lock waits or deadlocks could occur. Furthermore, the - data dictionary transaction must be committed (and the locks - released) before the data dictionary latch is released. - - ha_innobase::add_index(): Lock the data dictionary before renaming - or dropping the created indexes, because neither operation will - commit the data dictionary transaction. - - ha_innobase::final_drop_index(): Commit the transactions before - unlocking the data dictionary. - -2008-10-09 The InnoDB Team - - * buf/buf0lru.c: - Fix Bug#39939 DROP TABLE/DISCARD TABLESPACE takes long time in - buf_LRU_invalidate_tablespace() - -2008-10-08 The InnoDB Team - - * dict/dict0crea.c, trx/trx0roll.c, include/row0mysql.h, - row/row0merge.c, row/row0mysql.c: - When dropping a table, hold the data dictionary latch until the - transaction has been committed. The data dictionary latch is - supposed to prevent lock waits and deadlocks in the data - dictionary tables. Due to this bug, DROP TABLE could cause a - deadlock or hang. Note that because of Bug#33650 and Bug#39833, - MySQL may also drop a (temporary) table when executing CREATE INDEX - or ALTER TABLE ... ADD INDEX. - -2008-10-04 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb_bug39438-master.opt, - mysql-test/innodb_bug39438.result, mysql-test/innodb_bug39438.test: - Fix Bug#39438 Testcase for Bug#39436 crashes on 5.1 in - fil_space_get_latch - -2008-10-04 The InnoDB Team - - * include/lock0lock.h, lock/lock0lock.c, - mysql-test/innodb_bug38231.result, mysql-test/innodb_bug38231.test, - row/row0mysql.c: - Fix Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + - LOCK / UNLOCK - -2008-10-04 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#35498 Cannot get table test/table1 auto-inccounter value in - ::info - -2008-10-04 The InnoDB Team - - * handler/ha_innodb.cc, handler/ha_innodb.h: - Fix Bug#37788 InnoDB Plugin: AUTO_INCREMENT wrong for compressed - tables - -2008-10-04 The InnoDB Team - - * dict/dict0dict.c, handler/ha_innodb.cc, handler/ha_innodb.h, - include/dict0dict.h, include/dict0mem.h, row/row0mysql.c: - Fix Bug#39830 Table autoinc value not updated on first insert - -2008-10-03 The InnoDB Team - - * mysql-test/innodb-index.test, mysql-test/innodb-index.result, - mysql-test/innodb-timeout.test, mysql-test/innodb-timeout.result, - srv/srv0srv.c, include/srv0srv.h, handler/ha_innodb.cc, - include/ha_prototypes.h: - Fix Bug#36285 innodb_lock_wait_timeout is not dynamic, not per session - -2008-09-19 The InnoDB Team - - * os/os0proc.c: - Fix a memory leak on Windows. The memory leak was due to wrong - parameters passed into VirtualFree() call. As the result, the - call fails with Windows error 87. - -2008-09-17 The InnoDB Team - - * mysql-test/innodb.result, mysql-test/innodb-zip.result, - mysql-test/innodb-zip.test, mysql-test/innodb.test, ibuf/ibuf0ibuf.c, - dict/dict0crea.c, dict/dict0load.c, dict/dict0boot.c, - include/dict0dict.h, include/trx0trx.h, dict/dict0dict.c, - trx/trx0trx.c, include/ha_prototypes.h, handler/ha_innodb.cc: - When creating an index in innodb_strict_mode, check that the - maximum record size will never exceed the B-tree page size limit. - For uncompressed tables, there should always be enough space for - two records in an empty B-tree page. For compressed tables, there - should be enough space for storing two node pointer records or one - data record in an empty page in uncompressed format. - The purpose of this check is to guarantee that INSERT or UPDATE - will never fail due to too big record size. - -2008-09-17 The InnoDB Team - - * btr/btr0cur.c, data/data0data.c, include/page0zip.h, - include/page0zip.ic, page/page0zip.c, mysql-test/innodb_bug36172.test: - Prevent infinite B-tree page splits in compressed tables by - ensuring that there will always be enough space for two node - pointer records in an empty B-tree page. Also, require that at - least one data record will fit in an empty compressed page. This - will reduce the maximum size of records in compressed tables. - -2008-09-09 The InnoDB Team - - * mysql-test/innodb.result: - Fix the failing innodb test by merging changes that MySQL made to - that file (r2646.12.1 in MySQL BZR repository) - -2008-09-09 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb-autoinc.result, - mysql-test/innodb-autoinc.test: - Fix Bug#38839 auto increment does not work properly with InnoDB after - update - -2008-09-09 The InnoDB Team - - * dict/dict0dict.c, handler/handler0alter.cc, include/dict0dict.h, - mysql-test/innodb-index.result, mysql-test/innodb-index.test: - Fix Bug#38786 InnoDB plugin crashes on drop table/create table with FK - -2008-08-21 The InnoDB Team - - * handler/ha_innodb.cc, include/ha_prototypes.h, row/row0sel.c: - Fix Bug#37885 row_search_for_mysql may gap lock unnecessarily with SQL - comments in query - -2008-08-21 The InnoDB Team - - * handler/ha_innodb.cc: - Fix Bug#38185 ha_innobase::info can hold locks even when called with - HA_STATUS_NO_LOCK - -2008-08-18 The InnoDB Team - - * buf/buf0buf.c, buf/buf0lru.c, include/buf0buf.ic, include/univ.i: - Introduce UNIV_LRU_DEBUG for debugging the LRU buffer pool cache - -2008-08-08 The InnoDB Team - - * buf/buf0lru.c, include/buf0buf.h: - Fix two recovery bugs that could lead to a crash in debug builds with - small buffer size - -2008-08-07 The InnoDB Team - - * btr/btr0cur.c, handler/ha_innodb.cc, include/srv0srv.h, - srv/srv0srv.c: - Add a parameter innodb_stats_sample_pages to allow users to control - the number of index dives when InnoDB estimates the cardinality of - an index (ANALYZE TABLE, SHOW TABLE STATUS etc) - -2008-08-07 The InnoDB Team - - * trx/trx0i_s.c: - Fix a bug that would lead to a crash if a SELECT was issued from the - INFORMATION_SCHEMA tables and there are rolling back transactions at - the same time - -2008-08-06 The InnoDB Team - - * btr/btr0btr.c, btr/btr0cur.c, ibuf/ibuf0ibuf.c, include/btr0cur.h, - include/trx0roll.h, include/trx0types.h, row/row0purge.c, - row/row0uins.c, row/row0umod.c, trx/trx0roll.c: - In the rollback of incomplete transactions after crash recovery, - tolerate clustered index records whose externally stored columns - have not been written. - -2008-07-30 The InnoDB Team - - * trx/trx0trx.c: - Fixes a race in recovery where the recovery thread recovering a - PREPARED trx and the background rollback thread can both try - to free the trx after its status is set to COMMITTED_IN_MEMORY. - -2008-07-29 The InnoDB Team - - * include/trx0rec.h, row/row0purge.c, row/row0vers.c, trx/trx0rec.c: - Fix a BLOB corruption bug - -2008-07-15 The InnoDB Team - - * btr/btr0sea.c, dict/dict0dict.c, include/btr0sea.h: - Fixed a timing hole where a thread dropping an index can free the - in-memory index struct while another thread is still using that - structure to remove entries from adaptive hash index belonging - to one of the pages that belongs to the index being dropped. - -2008-07-04 The InnoDB Team - - * mysql-test/innodb-index.result: - Fix the failing innodb-index test by adjusting the result to a new - MySQL behavior (the change occured in BZR-r2667) - -2008-07-03 The InnoDB Team - - * mysql-test/innodb-zip.result, mysql-test/innodb-zip.test: - Remove the negative test cases that produce warnings - -2008-07-02 The InnoDB Team - - * mysql-test/innodb-replace.result, mysql-test/innodb-index.test: - Disable part of innodb-index test because MySQL changed its behavior - and is not calling ::add_index() anymore when adding primary index on - non-NULL column - -2008-07-01 The InnoDB Team - - * mysql-test/innodb-replace.result, mysql-test/innodb-replace.test: - Fix the failing innodb-replace test by merging changes that MySQL - made to that file (r2659 in MySQL BZR repository) - -2008-07-01 The InnoDB Team - - * lock/lock0lock.c: - Fix Bug#36942 Performance problem in lock_get_n_rec_locks (SHOW INNODB - STATUS) - -2008-07-01 The InnoDB Team - - * ha/ha0ha.c: - Fix Bug#36941 Performance problem in ha_print_info (SHOW INNODB - STATUS) - -2008-07-01 The InnoDB Team - - * handler/ha_innodb.cc, mysql-test/innodb-autoinc.result, - mysql-test/innodb-autoinc.test: - Fix Bug#37531 After truncate, auto_increment behaves incorrectly for - InnoDB - -2008-06-19 The InnoDB Team - - * handler/ha_innodb.cc: - Rewrite the function innodb_plugin_init() to support parameters in - different order (in static and dynamic InnoDB) and to support more - parameters in the static InnoDB - -2008-06-19 The InnoDB Team - - * handler/handler0alter.cc: - Fix a bug in ::add_index() which set the transaction state to "active" - but never restored it to the original value. This bug caused warnings - to be printed by the rpl.rpl_ddl mysql-test. - -2008-06-19 The InnoDB Team - - * mysql-test/patches: - Add a directory which contains patches, which need to be applied to - MySQL source in order to get some mysql-tests to succeed. The patches - cannot be committed in MySQL repository because they are specific to - the InnoDB plugin. - -2008-06-19 The InnoDB Team - - * mysql-test/innodb-zip.result, mysql-test/innodb-zip.test, - row/row0row.c: - Fix an anomaly when updating a record with BLOB prefix - -2008-06-18 The InnoDB Team - - * include/trx0sys.h, srv/srv0start.c, trx/trx0sys.c: - Fix a bug in recovery which was a side effect of the file_format_check - changes - -2008-06-09 The InnoDB Team - - * mysql-test/innodb.result: - Fix the failing innodb test by merging changes that MySQL made to that - file - -2008-06-06 The InnoDB Team - - * buf/buf0buf.c, handler/ha_innodb.cc, include/buf0buf.h, - include/srv0srv.h, srv/srv0srv.c: - Fix Bug#36600 SHOW STATUS takes a lot of CPU in - buf_get_latched_pages_number - - * handler/ha_innodb.cc, os/os0file.c: - Fix Bug#11894 innodb_file_per_table crashes w/ Windows .sym symbolic - link hack - - * include/ut0ut.h, srv/srv0srv.c, ut/ut0ut.c: - Fix Bug#36819 ut_usectime does not handle errors from gettimeofday - - * handler/ha_innodb.cc: - Fix Bug#35602 Failed to read auto-increment value from storage engine - - * srv/srv0start.c: - Fix Bug#36149 Read buffer overflow in srv0start.c found during "make - test" - -2008-05-08 The InnoDB Team - - * btr/btr0btr.c, mysql-test/innodb_bug36172.result, - mysql-test/innodb_bug36172.test: - Fix Bug#36172 insert into compressed innodb table crashes - -2008-05-08 The InnoDB Team - - InnoDB Plugin 1.0.1 released - -2008-05-06 The InnoDB Team - - * handler/ha_innodb.cc, include/srv0srv.h, include/sync0sync.h, - include/trx0sys.h, mysql-test/innodb-zip.result, - mysql-test/innodb-zip.test, srv/srv0srv.c, srv/srv0start.c, - sync/sync0sync.c, trx/trx0sys.c: - Implement the system tablespace tagging - - * handler/ha_innodb.cc, handler/i_s.cc, include/univ.i, - srv/srv0start.c: - Add InnoDB version in INFORMATION_SCHEMA.PLUGINS.PLUGIN_VERSION, - in the startup message and in a server variable innodb_version. - - * sync/sync0sync.c: - Fix a bug in the sync debug code where a lock with level - SYNC_LEVEL_VARYING would cause an assertion failure when a thread - tried to release it. - -2008-04-30 The InnoDB Team - - * Makefile.am: - Fix Bug#36434 ha_innodb.so is installed in the wrong directory - - * handler/ha_innodb.cc: - Merge change from MySQL (Fix Bug#35406 5.1-opt crashes on select from - I_S.REFERENTIAL_CONSTRAINTS): - ChangeSet@1.2563, 2008-03-18 19:42:04+04:00, gluh@mysql.com +1 -0 - - * scripts/install_innodb_plugins.sql: - Added - - * mysql-test/innodb.result: - Merge change from MySQL (this fixes the failing innodb test): - ChangeSet@1.1810.3601.4, 2008-02-07 02:33:21+04:00 - - * row/row0sel.c: - Fix Bug#35226 RBR event crashes slave - - * handler/ha_innodb.cc: - Change the fix for Bug#32440 to show bytes instead of kilobytes in - INFORMATION_SCHEMA.TABLES.DATA_FREE - - * handler/ha_innodb.cc, mysql-test/innodb.result, - mysql-test/innodb.test: - Fix Bug#29507 TRUNCATE shows to many rows effected - - * handler/ha_innodb.cc, mysql-test/innodb.result, - mysql-test/innodb.test: - Fix Bug#35537 Innodb doesn't increment handler_update and - handler_delete - -2008-04-29 The InnoDB Team - - * handler/i_s.cc, include/srv0start.h, srv/srv0start.c: - Fix Bug#36310 InnoDB plugin crash - -2008-04-23 The InnoDB Team - - * mysql-test/innodb_bug36169.result, mysql-test/innodb_bug36169.test, - row/row0mysql.c: - Fix Bug#36169 create innodb compressed table with too large row size - crashed - - * (outside the source tree): - Fix Bug#36222 New InnoDB plugin 1.0 has wrong MKDIR_P defined in - Makefile.in - -2008-04-15 The InnoDB Team - - InnoDB Plugin 1.0.0 released diff --git a/storage/xtradb/Doxyfile b/storage/xtradb/Doxyfile index 62aa7dd8abc..7cf5048fa52 100644 --- a/storage/xtradb/Doxyfile +++ b/storage/xtradb/Doxyfile @@ -565,7 +565,7 @@ RECURSIVE = YES # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = ut0auxconf_* +EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded diff --git a/storage/xtradb/btr/btr0btr.c b/storage/xtradb/btr/btr0btr.c index ff047095aa4..c0c27128441 100644 --- a/storage/xtradb/btr/btr0btr.c +++ b/storage/xtradb/btr/btr0btr.c @@ -42,6 +42,560 @@ Created 6/2/1994 Heikki Tuuri #include "ibuf0ibuf.h" #include "trx0trx.h" +#ifdef UNIV_BLOB_DEBUG +# include "srv0srv.h" +# include "ut0rbt.h" + +/** TRUE when messages about index->blobs modification are enabled. */ +static ibool btr_blob_dbg_msg; + +/** Issue a message about an operation on index->blobs. +@param op operation +@param b the entry being subjected to the operation +@param ctx the context of the operation */ +#define btr_blob_dbg_msg_issue(op, b, ctx) \ + fprintf(stderr, op " %u:%u:%u->%u %s(%u,%u,%u)\n", \ + (b)->ref_page_no, (b)->ref_heap_no, \ + (b)->ref_field_no, (b)->blob_page_no, ctx, \ + (b)->owner, (b)->always_owner, (b)->del) + +/** Insert to index->blobs a reference to an off-page column. +@param index the index tree +@param b the reference +@param ctx context (for logging) */ +UNIV_INTERN +void +btr_blob_dbg_rbt_insert( +/*====================*/ + dict_index_t* index, /*!< in/out: index tree */ + const btr_blob_dbg_t* b, /*!< in: the reference */ + const char* ctx) /*!< in: context (for logging) */ +{ + if (btr_blob_dbg_msg) { + btr_blob_dbg_msg_issue("insert", b, ctx); + } + mutex_enter(&index->blobs_mutex); + rbt_insert(index->blobs, b, b); + mutex_exit(&index->blobs_mutex); +} + +/** Remove from index->blobs a reference to an off-page column. +@param index the index tree +@param b the reference +@param ctx context (for logging) */ +UNIV_INTERN +void +btr_blob_dbg_rbt_delete( +/*====================*/ + dict_index_t* index, /*!< in/out: index tree */ + const btr_blob_dbg_t* b, /*!< in: the reference */ + const char* ctx) /*!< in: context (for logging) */ +{ + if (btr_blob_dbg_msg) { + btr_blob_dbg_msg_issue("delete", b, ctx); + } + mutex_enter(&index->blobs_mutex); + ut_a(rbt_delete(index->blobs, b)); + mutex_exit(&index->blobs_mutex); +} + +/**************************************************************//** +Comparator for items (btr_blob_dbg_t) in index->blobs. +The key in index->blobs is (ref_page_no, ref_heap_no, ref_field_no). +@return negative, 0 or positive if *a<*b, *a=*b, *a>*b */ +static +int +btr_blob_dbg_cmp( +/*=============*/ + const void* a, /*!< in: first btr_blob_dbg_t to compare */ + const void* b) /*!< in: second btr_blob_dbg_t to compare */ +{ + const btr_blob_dbg_t* aa = a; + const btr_blob_dbg_t* bb = b; + + ut_ad(aa != NULL); + ut_ad(bb != NULL); + + if (aa->ref_page_no != bb->ref_page_no) { + return(aa->ref_page_no < bb->ref_page_no ? -1 : 1); + } + if (aa->ref_heap_no != bb->ref_heap_no) { + return(aa->ref_heap_no < bb->ref_heap_no ? -1 : 1); + } + if (aa->ref_field_no != bb->ref_field_no) { + return(aa->ref_field_no < bb->ref_field_no ? -1 : 1); + } + return(0); +} + +/**************************************************************//** +Add a reference to an off-page column to the index->blobs map. */ +UNIV_INTERN +void +btr_blob_dbg_add_blob( +/*==================*/ + const rec_t* rec, /*!< in: clustered index record */ + ulint field_no, /*!< in: off-page column number */ + ulint page_no, /*!< in: start page of the column */ + dict_index_t* index, /*!< in/out: index tree */ + const char* ctx) /*!< in: context (for logging) */ +{ + btr_blob_dbg_t b; + const page_t* page = page_align(rec); + + ut_a(index->blobs); + + b.blob_page_no = page_no; + b.ref_page_no = page_get_page_no(page); + b.ref_heap_no = page_rec_get_heap_no(rec); + b.ref_field_no = field_no; + ut_a(b.ref_field_no >= index->n_uniq); + b.always_owner = b.owner = TRUE; + b.del = FALSE; + ut_a(!rec_get_deleted_flag(rec, page_is_comp(page))); + btr_blob_dbg_rbt_insert(index, &b, ctx); +} + +/**************************************************************//** +Add to index->blobs any references to off-page columns from a record. +@return number of references added */ +UNIV_INTERN +ulint +btr_blob_dbg_add_rec( +/*=================*/ + const rec_t* rec, /*!< in: record */ + dict_index_t* index, /*!< in/out: index */ + const ulint* offsets,/*!< in: offsets */ + const char* ctx) /*!< in: context (for logging) */ +{ + ulint count = 0; + ulint i; + btr_blob_dbg_t b; + ibool del; + + ut_ad(rec_offs_validate(rec, index, offsets)); + + if (!rec_offs_any_extern(offsets)) { + return(0); + } + + b.ref_page_no = page_get_page_no(page_align(rec)); + b.ref_heap_no = page_rec_get_heap_no(rec); + del = (rec_get_deleted_flag(rec, rec_offs_comp(offsets)) != 0); + + for (i = 0; i < rec_offs_n_fields(offsets); i++) { + if (rec_offs_nth_extern(offsets, i)) { + ulint len; + const byte* field_ref = rec_get_nth_field( + rec, offsets, i, &len); + + ut_a(len != UNIV_SQL_NULL); + ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE); + field_ref += len - BTR_EXTERN_FIELD_REF_SIZE; + + if (!memcmp(field_ref, field_ref_zero, + BTR_EXTERN_FIELD_REF_SIZE)) { + /* the column has not been stored yet */ + continue; + } + + b.ref_field_no = i; + b.blob_page_no = mach_read_from_4( + field_ref + BTR_EXTERN_PAGE_NO); + ut_a(b.ref_field_no >= index->n_uniq); + b.always_owner = b.owner + = !(field_ref[BTR_EXTERN_LEN] + & BTR_EXTERN_OWNER_FLAG); + b.del = del; + + btr_blob_dbg_rbt_insert(index, &b, ctx); + count++; + } + } + + return(count); +} + +/**************************************************************//** +Display the references to off-page columns. +This function is to be called from a debugger, +for example when a breakpoint on ut_dbg_assertion_failed is hit. */ +UNIV_INTERN +void +btr_blob_dbg_print( +/*===============*/ + const dict_index_t* index) /*!< in: index tree */ +{ + const ib_rbt_node_t* node; + + if (!index->blobs) { + return; + } + + /* We intentionally do not acquire index->blobs_mutex here. + This function is to be called from a debugger, and the caller + should make sure that the index->blobs_mutex is held. */ + + for (node = rbt_first(index->blobs); + node != NULL; node = rbt_next(index->blobs, node)) { + const btr_blob_dbg_t* b + = rbt_value(btr_blob_dbg_t, node); + fprintf(stderr, "%u:%u:%u->%u%s%s%s\n", + b->ref_page_no, b->ref_heap_no, b->ref_field_no, + b->blob_page_no, + b->owner ? "" : "(disowned)", + b->always_owner ? "" : "(has disowned)", + b->del ? "(deleted)" : ""); + } +} + +/**************************************************************//** +Remove from index->blobs any references to off-page columns from a record. +@return number of references removed */ +UNIV_INTERN +ulint +btr_blob_dbg_remove_rec( +/*====================*/ + const rec_t* rec, /*!< in: record */ + dict_index_t* index, /*!< in/out: index */ + const ulint* offsets,/*!< in: offsets */ + const char* ctx) /*!< in: context (for logging) */ +{ + ulint i; + ulint count = 0; + btr_blob_dbg_t b; + + ut_ad(rec_offs_validate(rec, index, offsets)); + + if (!rec_offs_any_extern(offsets)) { + return(0); + } + + b.ref_page_no = page_get_page_no(page_align(rec)); + b.ref_heap_no = page_rec_get_heap_no(rec); + + for (i = 0; i < rec_offs_n_fields(offsets); i++) { + if (rec_offs_nth_extern(offsets, i)) { + ulint len; + const byte* field_ref = rec_get_nth_field( + rec, offsets, i, &len); + + ut_a(len != UNIV_SQL_NULL); + ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE); + field_ref += len - BTR_EXTERN_FIELD_REF_SIZE; + + b.ref_field_no = i; + b.blob_page_no = mach_read_from_4( + field_ref + BTR_EXTERN_PAGE_NO); + + switch (b.blob_page_no) { + case 0: + /* The column has not been stored yet. + The BLOB pointer must be all zero. + There cannot be a BLOB starting at + page 0, because page 0 is reserved for + the tablespace header. */ + ut_a(!memcmp(field_ref, field_ref_zero, + BTR_EXTERN_FIELD_REF_SIZE)); + /* fall through */ + case FIL_NULL: + /* the column has been freed already */ + continue; + } + + btr_blob_dbg_rbt_delete(index, &b, ctx); + count++; + } + } + + return(count); +} + +/**************************************************************//** +Check that there are no references to off-page columns from or to +the given page. Invoked when freeing or clearing a page. +@return TRUE when no orphan references exist */ +UNIV_INTERN +ibool +btr_blob_dbg_is_empty( +/*==================*/ + dict_index_t* index, /*!< in: index */ + ulint page_no) /*!< in: page number */ +{ + const ib_rbt_node_t* node; + ibool success = TRUE; + + if (!index->blobs) { + return(success); + } + + mutex_enter(&index->blobs_mutex); + + for (node = rbt_first(index->blobs); + node != NULL; node = rbt_next(index->blobs, node)) { + const btr_blob_dbg_t* b + = rbt_value(btr_blob_dbg_t, node); + + if (b->ref_page_no != page_no && b->blob_page_no != page_no) { + continue; + } + + fprintf(stderr, + "InnoDB: orphan BLOB ref%s%s%s %u:%u:%u->%u\n", + b->owner ? "" : "(disowned)", + b->always_owner ? "" : "(has disowned)", + b->del ? "(deleted)" : "", + b->ref_page_no, b->ref_heap_no, b->ref_field_no, + b->blob_page_no); + + if (b->blob_page_no != page_no || b->owner || !b->del) { + success = FALSE; + } + } + + mutex_exit(&index->blobs_mutex); + return(success); +} + +/**************************************************************//** +Count and process all references to off-page columns on a page. +@return number of references processed */ +UNIV_INTERN +ulint +btr_blob_dbg_op( +/*============*/ + const page_t* page, /*!< in: B-tree leaf page */ + const rec_t* rec, /*!< in: record to start from + (NULL to process the whole page) */ + dict_index_t* index, /*!< in/out: index */ + const char* ctx, /*!< in: context (for logging) */ + const btr_blob_dbg_op_f op) /*!< in: operation on records */ +{ + ulint count = 0; + mem_heap_t* heap = NULL; + ulint offsets_[REC_OFFS_NORMAL_SIZE]; + ulint* offsets = offsets_; + rec_offs_init(offsets_); + + ut_a(fil_page_get_type(page) == FIL_PAGE_INDEX); + ut_a(!rec || page_align(rec) == page); + + if (!index->blobs || !page_is_leaf(page) + || !dict_index_is_clust(index)) { + return(0); + } + + if (rec == NULL) { + rec = page_get_infimum_rec(page); + } + + do { + offsets = rec_get_offsets(rec, index, offsets, + ULINT_UNDEFINED, &heap); + count += op(rec, index, offsets, ctx); + rec = page_rec_get_next_const(rec); + } while (!page_rec_is_supremum(rec)); + + if (UNIV_LIKELY_NULL(heap)) { + mem_heap_free(heap); + } + + return(count); +} + +/**************************************************************//** +Count and add to index->blobs any references to off-page columns +from records on a page. +@return number of references added */ +UNIV_INTERN +ulint +btr_blob_dbg_add( +/*=============*/ + const page_t* page, /*!< in: rewritten page */ + dict_index_t* index, /*!< in/out: index */ + const char* ctx) /*!< in: context (for logging) */ +{ + btr_blob_dbg_assert_empty(index, page_get_page_no(page)); + + return(btr_blob_dbg_op(page, NULL, index, ctx, btr_blob_dbg_add_rec)); +} + +/**************************************************************//** +Count and remove from index->blobs any references to off-page columns +from records on a page. +Used when reorganizing a page, before copying the records. +@return number of references removed */ +UNIV_INTERN +ulint +btr_blob_dbg_remove( +/*================*/ + const page_t* page, /*!< in: b-tree page */ + dict_index_t* index, /*!< in/out: index */ + const char* ctx) /*!< in: context (for logging) */ +{ + ulint count; + + count = btr_blob_dbg_op(page, NULL, index, ctx, + btr_blob_dbg_remove_rec); + + /* Check that no references exist. */ + btr_blob_dbg_assert_empty(index, page_get_page_no(page)); + + return(count); +} + +/**************************************************************//** +Restore in index->blobs any references to off-page columns +Used when page reorganize fails due to compressed page overflow. */ +UNIV_INTERN +void +btr_blob_dbg_restore( +/*=================*/ + const page_t* npage, /*!< in: page that failed to compress */ + const page_t* page, /*!< in: copy of original page */ + dict_index_t* index, /*!< in/out: index */ + const char* ctx) /*!< in: context (for logging) */ +{ + ulint removed; + ulint added; + + ut_a(page_get_page_no(npage) == page_get_page_no(page)); + ut_a(page_get_space_id(npage) == page_get_space_id(page)); + + removed = btr_blob_dbg_remove(npage, index, ctx); + added = btr_blob_dbg_add(page, index, ctx); + ut_a(added == removed); +} + +/**************************************************************//** +Modify the 'deleted' flag of a record. */ +UNIV_INTERN +void +btr_blob_dbg_set_deleted_flag( +/*==========================*/ + const rec_t* rec, /*!< in: record */ + dict_index_t* index, /*!< in/out: index */ + const ulint* offsets,/*!< in: rec_get_offs(rec, index) */ + ibool del) /*!< in: TRUE=deleted, FALSE=exists */ +{ + const ib_rbt_node_t* node; + btr_blob_dbg_t b; + btr_blob_dbg_t* c; + ulint i; + + ut_ad(rec_offs_validate(rec, index, offsets)); + ut_a(dict_index_is_clust(index)); + ut_a(del == !!del);/* must be FALSE==0 or TRUE==1 */ + + if (!rec_offs_any_extern(offsets) || !index->blobs) { + + return; + } + + b.ref_page_no = page_get_page_no(page_align(rec)); + b.ref_heap_no = page_rec_get_heap_no(rec); + + for (i = 0; i < rec_offs_n_fields(offsets); i++) { + if (rec_offs_nth_extern(offsets, i)) { + ulint len; + const byte* field_ref = rec_get_nth_field( + rec, offsets, i, &len); + + ut_a(len != UNIV_SQL_NULL); + ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE); + field_ref += len - BTR_EXTERN_FIELD_REF_SIZE; + + b.ref_field_no = i; + b.blob_page_no = mach_read_from_4( + field_ref + BTR_EXTERN_PAGE_NO); + + switch (b.blob_page_no) { + case 0: + ut_a(memcmp(field_ref, field_ref_zero, + BTR_EXTERN_FIELD_REF_SIZE)); + /* page number 0 is for the + page allocation bitmap */ + case FIL_NULL: + /* the column has been freed already */ + ut_error; + } + + mutex_enter(&index->blobs_mutex); + node = rbt_lookup(index->blobs, &b); + ut_a(node); + + c = rbt_value(btr_blob_dbg_t, node); + /* The flag should be modified. */ + c->del = del; + if (btr_blob_dbg_msg) { + b = *c; + mutex_exit(&index->blobs_mutex); + btr_blob_dbg_msg_issue("del_mk", &b, ""); + } else { + mutex_exit(&index->blobs_mutex); + } + } + } +} + +/**************************************************************//** +Change the ownership of an off-page column. */ +UNIV_INTERN +void +btr_blob_dbg_owner( +/*===============*/ + const rec_t* rec, /*!< in: record */ + dict_index_t* index, /*!< in/out: index */ + const ulint* offsets,/*!< in: rec_get_offs(rec, index) */ + ulint i, /*!< in: ith field in rec */ + ibool own) /*!< in: TRUE=owned, FALSE=disowned */ +{ + const ib_rbt_node_t* node; + btr_blob_dbg_t b; + const byte* field_ref; + ulint len; + + ut_ad(rec_offs_validate(rec, index, offsets)); + ut_a(rec_offs_nth_extern(offsets, i)); + + field_ref = rec_get_nth_field(rec, offsets, i, &len); + ut_a(len != UNIV_SQL_NULL); + ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE); + field_ref += len - BTR_EXTERN_FIELD_REF_SIZE; + + b.ref_page_no = page_get_page_no(page_align(rec)); + b.ref_heap_no = page_rec_get_heap_no(rec); + b.ref_field_no = i; + b.owner = !(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG); + b.blob_page_no = mach_read_from_4(field_ref + BTR_EXTERN_PAGE_NO); + + ut_a(b.owner == own); + + mutex_enter(&index->blobs_mutex); + node = rbt_lookup(index->blobs, &b); + /* row_ins_clust_index_entry_by_modify() invokes + btr_cur_unmark_extern_fields() also for the newly inserted + references, which are all zero bytes until the columns are stored. + The node lookup must fail if and only if that is the case. */ + ut_a(!memcmp(field_ref, field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE) + == !node); + + if (node) { + btr_blob_dbg_t* c = rbt_value(btr_blob_dbg_t, node); + /* Some code sets ownership from TRUE to TRUE. + We do not allow changing ownership from FALSE to FALSE. */ + ut_a(own || c->owner); + + c->owner = own; + if (!own) { + c->always_owner = FALSE; + } + } + + mutex_exit(&index->blobs_mutex); +} +#endif /* UNIV_BLOB_DEBUG */ + /* Latching strategy of the InnoDB B-tree -------------------------------------- @@ -289,7 +843,7 @@ btr_get_next_user_rec( /**************************************************************//** Creates a new index page (not the root, and also not used in page reorganization). @see btr_page_empty(). */ -static +UNIV_INTERN void btr_page_create( /*============*/ @@ -302,6 +856,7 @@ btr_page_create( page_t* page = buf_block_get_frame(block); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); + btr_blob_dbg_assert_empty(index, buf_block_get_page_no(block)); if (UNIV_LIKELY_NULL(page_zip)) { page_create_zip(block, index, level, mtr); @@ -501,6 +1056,7 @@ btr_page_free_low( modify clock */ buf_block_modify_clock_inc(block); + btr_blob_dbg_assert_empty(index, buf_block_get_page_no(block)); if (dict_index_is_ibuf(index)) { @@ -631,6 +1187,7 @@ btr_page_get_father_node_ptr_func( ut_ad(dict_index_get_page(index) != page_no); level = btr_page_get_level(btr_cur_get_page(cursor), mtr); + user_rec = btr_cur_get_rec(cursor); ut_a(page_rec_is_user_rec(user_rec)); tuple = dict_index_build_node_ptr(index, user_rec, 0, heap, level); @@ -675,7 +1232,7 @@ btr_page_get_father_node_ptr_func( " to fix the\n" "InnoDB: corruption. If the crash happens at " "the database startup, see\n" - "InnoDB: " REFMAN "forcing-recovery.html about\n" + "InnoDB: " REFMAN "forcing-innodb-recovery.html about\n" "InnoDB: forcing recovery. " "Then dump + drop + reimport.\n", stderr); @@ -746,7 +1303,7 @@ btr_create( ulint space, /*!< in: space where created */ ulint zip_size,/*!< in: compressed page size in bytes or 0 for uncompressed pages */ - dulint index_id,/*!< in: index id */ + index_id_t index_id,/*!< in: index id */ dict_index_t* index, /*!< in: index */ mtr_t* mtr) /*!< in: mini-transaction handle */ { @@ -785,6 +1342,14 @@ btr_create( block = buf_page_get(space, zip_size, page_no, RW_X_LATCH, mtr); } else { +#ifdef UNIV_BLOB_DEBUG + if ((type & DICT_CLUSTERED) && !index->blobs) { + mutex_create(PFS_NOT_INSTRUMENTED, + &index->blobs_mutex, SYNC_ANY_LATCH); + index->blobs = rbt_create(sizeof(btr_blob_dbg_t), + btr_blob_dbg_cmp); + } +#endif /* UNIV_BLOB_DEBUG */ block = fseg_create(space, 0, PAGE_HEADER + PAGE_BTR_SEG_TOP, mtr); } @@ -953,7 +1518,7 @@ btr_free_root( } ut_a(block); - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, NULL); header = buf_block_get_frame(block) + PAGE_HEADER + PAGE_BTR_SEG_TOP; #ifdef UNIV_BTR_DEBUG @@ -979,6 +1544,7 @@ btr_page_reorganize_low( dict_index_t* index, /*!< in: record descriptor */ mtr_t* mtr) /*!< in: mtr */ { + buf_pool_t* buf_pool = buf_pool_from_bpage(&block->page); page_t* page = buf_block_get_frame(block); page_zip_des_t* page_zip = buf_block_get_page_zip(block); buf_block_t* temp_block; @@ -1009,7 +1575,7 @@ btr_page_reorganize_low( log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE); #ifndef UNIV_HOTBACKUP - temp_block = buf_block_alloc(0); + temp_block = buf_block_alloc(buf_pool); #else /* !UNIV_HOTBACKUP */ ut_ad(block == back_block1); temp_block = back_block2; @@ -1021,11 +1587,12 @@ btr_page_reorganize_low( #ifndef UNIV_HOTBACKUP if (UNIV_LIKELY(!recovery)) { - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, index); } block->check_index_page_at_flush = TRUE; #endif /* !UNIV_HOTBACKUP */ + btr_blob_dbg_remove(page, index, "btr_page_reorganize"); /* Recreate the page: note that global data on page (possible segment headers, next page-field, etc.) is preserved intact */ @@ -1046,7 +1613,7 @@ btr_page_reorganize_low( /* In crash recovery, dict_index_is_sec_or_ibuf() always returns TRUE, even for clustered indexes. max_trx_id is unused in clustered index pages. */ - ut_ad(!ut_dulint_is_zero(max_trx_id) || recovery); + ut_ad(max_trx_id != 0 || recovery); } if (UNIV_LIKELY_NULL(page_zip) @@ -1054,6 +1621,8 @@ btr_page_reorganize_low( (!page_zip_compress(page_zip, page, index, NULL))) { /* Restore the old page and exit. */ + btr_blob_dbg_restore(page, temp_page, index, + "btr_page_reorganize_compress_fail"); #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG /* Check that the bytes that we skip are identical. */ @@ -1168,7 +1737,7 @@ btr_parse_page_reorganize( #ifndef UNIV_HOTBACKUP /*************************************************************//** Empties an index page. @see btr_page_create(). */ -static +UNIV_INTERN void btr_page_empty( /*===========*/ @@ -1186,7 +1755,8 @@ btr_page_empty( ut_a(!page_zip || page_zip_validate(page_zip, page)); #endif /* UNIV_ZIP_DEBUG */ - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, index); + btr_blob_dbg_remove(page, index, "btr_page_empty"); /* Recreate the page: note that global data on page (possible segment headers, next page-field, etc.) is preserved intact */ @@ -1729,7 +2299,7 @@ btr_insert_on_non_leaf_level_func( /**************************************************************//** Attaches the halves of an index page on the appropriate level in an index tree. */ -static +UNIV_INTERN void btr_attach_half_pages( /*==================*/ @@ -1925,7 +2495,6 @@ btr_page_split_and_insert( buf_block_t* left_block; buf_block_t* right_block; buf_block_t* insert_block; - page_t* insert_page; page_cur_t* page_cursor; rec_t* first_rec; byte* buf = 0; /* remove warning */ @@ -2183,8 +2752,6 @@ insert_empty: insert_block = right_block; } - insert_page = buf_block_get_frame(insert_block); - /* 7. Reposition the cursor for insert and try insertion */ page_cursor = btr_cur_get_page_cur(cursor); @@ -2196,8 +2763,12 @@ insert_empty: #ifdef UNIV_ZIP_DEBUG { + page_t* insert_page + = buf_block_get_frame(insert_block); + page_zip_des_t* insert_page_zip = buf_block_get_page_zip(insert_block); + ut_a(!insert_page_zip || page_zip_validate(insert_page_zip, insert_page)); } @@ -2494,7 +3065,7 @@ btr_lift_page_up( mem_heap_free(heap); } - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, index); /* Make the father empty */ btr_page_empty(father_block, father_page_zip, index, page_level, mtr); @@ -2526,6 +3097,7 @@ btr_lift_page_up( index); } + btr_blob_dbg_remove(page, index, "btr_lift_page_up"); lock_update_copy_and_discard(father_block, block); /* Go upward to root page, decrementing levels by one. */ @@ -2590,7 +3162,6 @@ btr_compress( ulint n_recs; ulint max_ins_size; ulint max_ins_size_reorg; - ulint level; block = btr_cur_get_block(cursor); page = btr_cur_get_page(cursor); @@ -2600,7 +3171,6 @@ btr_compress( ut_ad(mtr_memo_contains(mtr, dict_index_get_lock(index), MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); - level = btr_page_get_level(page, mtr); space = dict_index_get_space(index); zip_size = dict_table_zip_size(index->table); @@ -2719,7 +3289,7 @@ err_exit: goto err_exit; } - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, index); /* Remove the page from the level list */ btr_level_list_remove(space, zip_size, page, mtr); @@ -2760,7 +3330,7 @@ err_exit: goto err_exit; } - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, index); #ifdef UNIV_BTR_DEBUG if (UNIV_LIKELY_NULL(merge_page_zip)) { @@ -2789,6 +3359,7 @@ err_exit: lock_update_merge_right(merge_block, orig_succ, block); } + btr_blob_dbg_remove(page, index, "btr_compress"); mem_heap_free(heap); if (!dict_index_is_clust(index) && page_is_leaf(merge_page)) { @@ -2874,7 +3445,7 @@ btr_discard_only_page_on_level( ut_a(btr_page_get_next(page, mtr) == FIL_NULL); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, index); btr_page_get_father(index, block, mtr, &cursor); father = btr_cur_get_block(&cursor); @@ -2909,7 +3480,7 @@ btr_discard_only_page_on_level( ibuf_reset_free_bits(block); if (page_is_leaf(buf_block_get_frame(block))) { - ut_a(!ut_dulint_is_zero(max_trx_id)); + ut_a(max_trx_id); page_set_max_trx_id(block, buf_block_get_page_zip(block), max_trx_id, mtr); @@ -2979,7 +3550,7 @@ btr_discard_page( page = buf_block_get_frame(block); ut_a(page_is_comp(merge_page) == page_is_comp(page)); - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, index); if (left_page_no == FIL_NULL && !page_is_leaf(page)) { @@ -3019,6 +3590,8 @@ btr_discard_page( block); } + btr_blob_dbg_remove(page, index, "btr_discard_page"); + /* Free the file page */ btr_page_free(index, block, mtr); diff --git a/storage/xtradb/btr/btr0cur.c b/storage/xtradb/btr/btr0cur.c index 3fc2b48162a..f6ef44e5b5c 100644 --- a/storage/xtradb/btr/btr0cur.c +++ b/storage/xtradb/btr/btr0cur.c @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved. +Copyright (c) 1994, 2011, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, Google Inc. Portions of this file contain modifications contributed and copyrighted by @@ -57,6 +57,8 @@ Created 10/16/1994 Heikki Tuuri #include "buf0lru.h" #include "btr0btr.h" #include "btr0sea.h" +#include "row0purge.h" +#include "row0upd.h" #include "trx0rec.h" #include "trx0roll.h" /* trx_is_recv() */ #include "que0que.h" @@ -66,6 +68,15 @@ Created 10/16/1994 Heikki Tuuri #include "lock0lock.h" #include "zlib.h" +/** Buffered B-tree operation types, introduced as part of delete buffering. */ +typedef enum btr_op_enum { + BTR_NO_OP = 0, /*!< Not buffered */ + BTR_INSERT_OP, /*!< Insert, do not ignore UNIQUE */ + BTR_INSERT_IGNORE_UNIQUE_OP, /*!< Insert, ignoring UNIQUE */ + BTR_DELETE_OP, /*!< Purge a delete-marked record */ + BTR_DELMARK_OP /*!< Mark a record for deletion */ +} btr_op_t; + #ifdef UNIV_DEBUG /** If the following is set to TRUE, this module prints a lot of trace information of individual record operations */ @@ -100,6 +111,18 @@ can be released by page reorganize, then it is reorganized */ /*--------------------------------------*/ #define BTR_BLOB_HDR_SIZE 8 /*!< Size of a BLOB part header, in bytes */ + +/** Estimated table level stats from sampled value. +@param value sampled stats +@param index index being sampled +@param sample number of sampled rows +@param ext_size external stored data size +@param not_empty table not empty +@return estimated table wide stats from sampled value */ +#define BTR_TABLE_STATS_FROM_SAMPLE(value, index, sample, ext_size, not_empty)\ + (((value) * (ib_int64_t) index->stat_n_leaf_pages \ + + (sample) - 1 + (ext_size) + (not_empty)) / ((sample) + (ext_size))) + /* @} */ #endif /* !UNIV_HOTBACKUP */ @@ -174,7 +197,7 @@ static ulint btr_rec_get_externally_stored_len( /*==============================*/ - rec_t* rec, /*!< in: record */ + const rec_t* rec, /*!< in: record */ const ulint* offsets);/*!< in: array returned by rec_get_offsets() */ #endif /* !UNIV_HOTBACKUP */ @@ -358,7 +381,8 @@ btr_cur_search_to_nth_level( Inserts should always be made using PAGE_CUR_LE to search the position! */ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ..., ORed with - BTR_INSERT and BTR_ESTIMATE; + at most one of BTR_INSERT, BTR_DELETE_MARK, + BTR_DELETE, or BTR_ESTIMATE; cursor->left_block is used to store a pointer to the left neighbor page, in the cases BTR_SEARCH_PREV and BTR_MODIFY_PREV; @@ -376,23 +400,26 @@ btr_cur_search_to_nth_level( ulint line, /*!< in: line where called */ mtr_t* mtr) /*!< in: mtr */ { - page_cur_t* page_cursor; page_t* page; - buf_block_t* guess; - rec_t* node_ptr; - ulint page_no; + buf_block_t* block; ulint space; + buf_block_t* guess; + ulint height; + ulint page_no; ulint up_match; ulint up_bytes; ulint low_match; ulint low_bytes; - ulint height; ulint savepoint; + ulint rw_latch; ulint page_mode; - ulint insert_planned; + ulint buf_mode; ulint estimate; - ulint ignore_sec_unique; + ulint zip_size; + page_cur_t* page_cursor; + btr_op_t btr_op; ulint root_height = 0; /* remove warning */ + #ifdef BTR_CUR_ADAPT btr_search_t* info; #endif @@ -405,24 +432,60 @@ btr_cur_search_to_nth_level( ut_ad(level == 0 || mode == PAGE_CUR_LE); ut_ad(dict_index_check_search_tuple(index, tuple)); - ut_ad(!dict_index_is_ibuf(index) || ibuf_inside()); + ut_ad(!dict_index_is_ibuf(index) || ibuf_inside(mtr)); ut_ad(dtuple_check_typed(tuple)); #ifdef UNIV_DEBUG cursor->up_match = ULINT_UNDEFINED; cursor->low_match = ULINT_UNDEFINED; #endif - insert_planned = latch_mode & BTR_INSERT; - estimate = latch_mode & BTR_ESTIMATE; - ignore_sec_unique = latch_mode & BTR_IGNORE_SEC_UNIQUE; - latch_mode = latch_mode & ~(BTR_INSERT | BTR_ESTIMATE - | BTR_IGNORE_SEC_UNIQUE); - ut_ad(!insert_planned || (mode == PAGE_CUR_LE)); + /* These flags are mutually exclusive, they are lumped together + with the latch mode for historical reasons. It's possible for + none of the flags to be set. */ + switch (UNIV_EXPECT(latch_mode + & (BTR_INSERT | BTR_DELETE | BTR_DELETE_MARK), + 0)) { + case 0: + btr_op = BTR_NO_OP; + break; + case BTR_INSERT: + btr_op = (latch_mode & BTR_IGNORE_SEC_UNIQUE) + ? BTR_INSERT_IGNORE_UNIQUE_OP + : BTR_INSERT_OP; + break; + case BTR_DELETE: + btr_op = BTR_DELETE_OP; + ut_a(cursor->purge_node); + break; + case BTR_DELETE_MARK: + btr_op = BTR_DELMARK_OP; + break; + default: + /* only one of BTR_INSERT, BTR_DELETE, BTR_DELETE_MARK + should be specified at a time */ + ut_error; + } + + /* Operations on the insert buffer tree cannot be buffered. */ + ut_ad(btr_op == BTR_NO_OP || !dict_index_is_ibuf(index)); + /* Operations on the clustered index cannot be buffered. */ + ut_ad(btr_op == BTR_NO_OP || !dict_index_is_clust(index)); + + estimate = latch_mode & BTR_ESTIMATE; + + /* Turn the flags unrelated to the latch mode off. */ + latch_mode &= ~(BTR_INSERT + | BTR_DELETE_MARK + | BTR_DELETE + | BTR_ESTIMATE + | BTR_IGNORE_SEC_UNIQUE); cursor->flag = BTR_CUR_BINARY; cursor->index = index; + cursor->ibuf_cnt = ULINT_UNDEFINED; + #ifndef BTR_CUR_ADAPT guess = NULL; #else @@ -435,8 +498,9 @@ btr_cur_search_to_nth_level( #ifdef UNIV_SEARCH_PERF_STAT info->n_searches++; #endif - if (rw_lock_get_writer(&btr_search_latch) == RW_LOCK_NOT_LOCKED - && latch_mode <= BTR_MODIFY_LEAF && info->last_hash_succ + if (rw_lock_get_writer(btr_search_get_latch(cursor->index->id)) == RW_LOCK_NOT_LOCKED + && latch_mode <= BTR_MODIFY_LEAF + && info->last_hash_succ && !estimate #ifdef PAGE_CUR_LE_OR_EXTENDS && mode != PAGE_CUR_LE_OR_EXTENDS @@ -470,7 +534,7 @@ btr_cur_search_to_nth_level( if (has_search_latch) { /* Release possible search latch to obey latching order */ - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(cursor->index->id)); } /* Store the position of the tree latch we push to mtr so that we @@ -525,176 +589,242 @@ btr_cur_search_to_nth_level( /* Loop and search until we arrive at the desired level */ - for (;;) { - ulint zip_size; - buf_block_t* block; - ulint rw_latch; - ulint buf_mode; +search_loop: + buf_mode = BUF_GET; + rw_latch = RW_NO_LATCH; - zip_size = dict_table_zip_size(index->table); - rw_latch = RW_NO_LATCH; - buf_mode = BUF_GET; + if (height != 0) { + /* We are about to fetch the root or a non-leaf page. */ + } else if (latch_mode <= BTR_MODIFY_LEAF) { + rw_latch = latch_mode; - if (height == 0 && latch_mode <= BTR_MODIFY_LEAF) { + if (btr_op != BTR_NO_OP + && ibuf_should_try(index, btr_op != BTR_INSERT_OP)) { - rw_latch = latch_mode; + /* Try to buffer the operation if the leaf + page is not in the buffer pool. */ - if (insert_planned - && ibuf_should_try(index, ignore_sec_unique)) { - - /* Try insert to the insert buffer if the - page is not in the buffer pool */ - - buf_mode = BUF_GET_IF_IN_POOL; - } + buf_mode = btr_op == BTR_DELETE_OP + ? BUF_GET_IF_IN_POOL_OR_WATCH + : BUF_GET_IF_IN_POOL; } + } + + zip_size = dict_table_zip_size(index->table); retry_page_get: - block = buf_page_get_gen(space, zip_size, page_no, - rw_latch, guess, buf_mode, - file, line, mtr); - if (block == NULL) { - if (srv_pass_corrupt_table && buf_mode != BUF_GET_IF_IN_POOL) { - page_cursor->block = 0; - page_cursor->rec = 0; - if (estimate) { - cursor->path_arr->nth_rec = ULINT_UNDEFINED; - } - break; - } - ut_a(buf_mode == BUF_GET_IF_IN_POOL); + block = buf_page_get_gen( + space, zip_size, page_no, rw_latch, guess, buf_mode, + file, line, mtr); - /* This must be a search to perform an insert; - try insert to the insert buffer */ - - ut_ad(buf_mode == BUF_GET_IF_IN_POOL); - ut_ad(insert_planned); - ut_ad(cursor->thr); - - if (ibuf_insert(tuple, index, space, zip_size, - page_no, cursor->thr)) { - /* Insertion to the insert buffer succeeded */ - cursor->flag = BTR_CUR_INSERT_TO_IBUF; - if (UNIV_LIKELY_NULL(heap)) { - mem_heap_free(heap); - } - goto func_exit; - } - - /* Insert to the insert buffer did not succeed: - retry page get */ - - buf_mode = BUF_GET; - - goto retry_page_get; - } - - page = buf_block_get_frame(block); - - if (srv_pass_corrupt_table && !page) { + if (block == NULL) { + if (srv_pass_corrupt_table + && buf_mode != BUF_GET_IF_IN_POOL + && buf_mode != BUF_GET_IF_IN_POOL_OR_WATCH) { page_cursor->block = 0; page_cursor->rec = 0; if (estimate) { cursor->path_arr->nth_rec = ULINT_UNDEFINED; } - break; + goto func_exit; } - ut_a(page); + ut_a(buf_mode == BUF_GET_IF_IN_POOL + || buf_mode == BUF_GET_IF_IN_POOL_OR_WATCH); - block->check_index_page_at_flush = TRUE; + /* This must be a search to perform an insert/delete + mark/ delete; try using the insert/delete buffer */ - if (rw_latch != RW_NO_LATCH) { + ut_ad(height == 0); + ut_ad(cursor->thr); + + switch (btr_op) { + case BTR_INSERT_OP: + case BTR_INSERT_IGNORE_UNIQUE_OP: + ut_ad(buf_mode == BUF_GET_IF_IN_POOL); + + if (ibuf_insert(IBUF_OP_INSERT, tuple, index, + space, zip_size, page_no, + cursor->thr)) { + + cursor->flag = BTR_CUR_INSERT_TO_IBUF; + + goto func_exit; + } + break; + + case BTR_DELMARK_OP: + ut_ad(buf_mode == BUF_GET_IF_IN_POOL); + + if (ibuf_insert(IBUF_OP_DELETE_MARK, tuple, + index, space, zip_size, + page_no, cursor->thr)) { + + cursor->flag = BTR_CUR_DEL_MARK_IBUF; + + goto func_exit; + } + + break; + + case BTR_DELETE_OP: + ut_ad(buf_mode == BUF_GET_IF_IN_POOL_OR_WATCH); + + if (!row_purge_poss_sec(cursor->purge_node, + index, tuple)) { + + /* The record cannot be purged yet. */ + cursor->flag = BTR_CUR_DELETE_REF; + } else if (ibuf_insert(IBUF_OP_DELETE, tuple, + index, space, zip_size, + page_no, + cursor->thr)) { + + /* The purge was buffered. */ + cursor->flag = BTR_CUR_DELETE_IBUF; + } else { + /* The purge could not be buffered. */ + buf_pool_watch_unset(space, page_no); + break; + } + + buf_pool_watch_unset(space, page_no); + goto func_exit; + + default: + ut_error; + } + + /* Insert to the insert/delete buffer did not succeed, we + must read the page from disk. */ + + buf_mode = BUF_GET; + + goto retry_page_get; + } + + block->check_index_page_at_flush = TRUE; + page = buf_block_get_frame(block); + + if (srv_pass_corrupt_table && !page) { + page_cursor->block = 0; + page_cursor->rec = 0; + if (estimate) { + cursor->path_arr->nth_rec = ULINT_UNDEFINED; + } + goto func_exit; + } + ut_a(page); + + if (rw_latch != RW_NO_LATCH) { #ifdef UNIV_ZIP_DEBUG - const page_zip_des_t* page_zip - = buf_block_get_page_zip(block); - ut_a(!page_zip || page_zip_validate(page_zip, page)); + const page_zip_des_t* page_zip + = buf_block_get_page_zip(block); + ut_a(!page_zip || page_zip_validate(page_zip, page)); #endif /* UNIV_ZIP_DEBUG */ - buf_block_dbg_add_level(block, SYNC_TREE_NODE); - } + buf_block_dbg_add_level(block, SYNC_TREE_NODE); + } - ut_ad(0 == ut_dulint_cmp(index->id, - btr_page_get_index_id(page))); + ut_ad(index->id == btr_page_get_index_id(page)); - if (UNIV_UNLIKELY(height == ULINT_UNDEFINED)) { - /* We are in the root node */ + if (UNIV_UNLIKELY(height == ULINT_UNDEFINED)) { + /* We are in the root node */ + + height = btr_page_get_level(page, mtr); + root_height = height; + cursor->tree_height = root_height + 1; - height = btr_page_get_level(page, mtr); - root_height = height; - cursor->tree_height = root_height + 1; #ifdef BTR_CUR_ADAPT - if (block != guess) { - info->root_guess = block; - } + if (block != guess) { + info->root_guess = block; + } #endif + } + + if (height == 0) { + if (rw_latch == RW_NO_LATCH) { + + btr_cur_latch_leaves( + page, space, zip_size, page_no, latch_mode, + cursor, mtr); } - if (height == 0) { - if (rw_latch == RW_NO_LATCH) { + if (latch_mode != BTR_MODIFY_TREE + && latch_mode != BTR_CONT_MODIFY_TREE) { - btr_cur_latch_leaves(page, space, zip_size, - page_no, latch_mode, - cursor, mtr); - } + /* Release the tree s-latch */ - if ((latch_mode != BTR_MODIFY_TREE) - && (latch_mode != BTR_CONT_MODIFY_TREE)) { - - /* Release the tree s-latch */ - - mtr_release_s_latch_at_savepoint( - mtr, savepoint, - dict_index_get_lock(index)); - } - - page_mode = mode; + mtr_release_s_latch_at_savepoint( + mtr, savepoint, dict_index_get_lock(index)); } - page_cur_search_with_match(block, index, tuple, page_mode, - &up_match, &up_bytes, - &low_match, &low_bytes, - page_cursor); + page_mode = mode; + } - if (estimate) { - btr_cur_add_path_info(cursor, height, root_height); - } + page_cur_search_with_match( + block, index, tuple, page_mode, &up_match, &up_bytes, + &low_match, &low_bytes, page_cursor); - /* If this is the desired level, leave the loop */ + if (estimate) { + btr_cur_add_path_info(cursor, height, root_height); + } - ut_ad(height == btr_page_get_level( - page_cur_get_page(page_cursor), mtr)); + /* If this is the desired level, leave the loop */ - if (level == height) { + ut_ad(height == btr_page_get_level(page_cur_get_page(page_cursor), + mtr)); - if (level > 0) { - /* x-latch the page */ - page = btr_page_get(space, zip_size, - page_no, RW_X_LATCH, mtr); - ut_a((ibool)!!page_is_comp(page) - == dict_table_is_comp(index->table)); - } - - break; - } + if (level != height) { + const rec_t* node_ptr; ut_ad(height > 0); height--; - guess = NULL; node_ptr = page_cur_get_rec(page_cursor); - offsets = rec_get_offsets(node_ptr, cursor->index, offsets, - ULINT_UNDEFINED, &heap); + + offsets = rec_get_offsets( + node_ptr, index, offsets, ULINT_UNDEFINED, &heap); + /* Go to the child node */ page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); + + if (UNIV_UNLIKELY(height == 0 && dict_index_is_ibuf(index))) { + /* We're doing a search on an ibuf tree and we're one + level above the leaf page. */ + + ulint is_min_rec; + + ut_ad(level == 0); + + is_min_rec = rec_get_info_bits(node_ptr, 0) + & REC_INFO_MIN_REC_FLAG; + + if (!is_min_rec) { + cursor->ibuf_cnt + = ibuf_rec_get_counter(node_ptr); + + ut_a(cursor->ibuf_cnt <= 0xFFFF + || cursor->ibuf_cnt == ULINT_UNDEFINED); + } + + buf_mode = BUF_GET; + rw_latch = RW_NO_LATCH; + goto retry_page_get; + } + + goto search_loop; } - if (UNIV_LIKELY_NULL(heap)) { - mem_heap_free(heap); - } + if (level != 0) { + /* x-latch the page */ + page = btr_page_get( + space, zip_size, page_no, RW_X_LATCH, mtr); - if (level == 0) { + ut_a((ibool)!!page_is_comp(page) + == dict_table_is_comp(index->table)); + } else { cursor->low_match = low_match; cursor->low_bytes = low_bytes; cursor->up_match = up_match; @@ -719,9 +849,14 @@ retry_page_get: } func_exit: + + if (UNIV_LIKELY_NULL(heap)) { + mem_heap_free(heap); + } + if (has_search_latch) { - rw_lock_s_lock(&btr_search_latch); + rw_lock_s_lock(btr_search_get_latch(cursor->index->id)); } } @@ -795,8 +930,7 @@ btr_cur_open_at_index_side_func( } ut_a(page); - ut_ad(0 == ut_dulint_cmp(index->id, - btr_page_get_index_id(page))); + ut_ad(index->id == btr_page_get_index_id(page)); block->check_index_page_at_flush = TRUE; @@ -924,8 +1058,7 @@ btr_cur_open_at_rnd_pos_func( } ut_a(page); - ut_ad(0 == ut_dulint_cmp(index->id, - btr_page_get_index_id(page))); + ut_ad(index->id == btr_page_get_index_id(page)); if (height == ULINT_UNDEFINED) { /* We are in the root node */ @@ -961,108 +1094,6 @@ btr_cur_open_at_rnd_pos_func( } } -/**********************************************************************//** -Positions a cursor at a randomly chosen position within a B-tree -after the given path -@return TRUE if the position is at the first page, and cursor must point - the first record for used by the caller.*/ -UNIV_INTERN -ibool -btr_cur_open_at_rnd_pos_after_path( -/*====================*/ - dict_index_t* index, /*!< in: index */ - ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */ - btr_path_t* first_rec_path, - btr_cur_t* cursor, /*!< in/out: B-tree cursor */ - mtr_t* mtr) /*!< in: mtr */ -{ - page_cur_t* page_cursor; - btr_path_t* slot; - ibool is_first_rec = TRUE; - ulint page_no; - ulint space; - ulint zip_size; - ulint height; - rec_t* node_ptr; - mem_heap_t* heap = NULL; - ulint offsets_[REC_OFFS_NORMAL_SIZE]; - ulint* offsets = offsets_; - rec_offs_init(offsets_); - - if (latch_mode == BTR_MODIFY_TREE) { - mtr_x_lock(dict_index_get_lock(index), mtr); - } else { - mtr_s_lock(dict_index_get_lock(index), mtr); - } - - page_cursor = btr_cur_get_page_cur(cursor); - cursor->index = index; - - space = dict_index_get_space(index); - zip_size = dict_table_zip_size(index->table); - page_no = dict_index_get_page(index); - - height = ULINT_UNDEFINED; - slot = first_rec_path; - - for (;;) { - buf_block_t* block; - page_t* page; - - block = buf_page_get_gen(space, zip_size, page_no, - RW_NO_LATCH, NULL, BUF_GET, - __FILE__, __LINE__, mtr); - page = buf_block_get_frame(block); - ut_ad(0 == ut_dulint_cmp(index->id, - btr_page_get_index_id(page))); - - if (height == ULINT_UNDEFINED) { - /* We are in the root node */ - - height = btr_page_get_level(page, mtr); - } - - if (height == 0) { - btr_cur_latch_leaves(page, space, zip_size, page_no, - latch_mode, cursor, mtr); - } - - if (is_first_rec && slot->nth_rec != ULINT_UNDEFINED) { - if (height == 0) { - /* must open the first rec */ - page_cur_open_on_nth_user_rec(block, page_cursor, slot->nth_rec); - } else { - is_first_rec = page_cur_open_on_rnd_user_rec_after_nth(block, - page_cursor, slot->nth_rec); - } - } else { - is_first_rec = FALSE; - page_cur_open_on_rnd_user_rec(block, page_cursor); - } - - if (height == 0) { - break; - } - - ut_ad(height > 0); - - height--; - slot++; - - node_ptr = page_cur_get_rec(page_cursor); - offsets = rec_get_offsets(node_ptr, cursor->index, offsets, - ULINT_UNDEFINED, &heap); - /* Go to the child node */ - page_no = btr_node_ptr_get_child_page_no(node_ptr, offsets); - } - - if (UNIV_LIKELY_NULL(heap)) { - mem_heap_free(heap); - } - - return (is_first_rec); -} - /*==================== B-TREE INSERT =========================*/ /*************************************************************//** @@ -1124,7 +1155,7 @@ btr_cur_ins_lock_and_undo( not zero, the parameters index and thr should be specified */ btr_cur_t* cursor, /*!< in: cursor on page after which to insert */ - const dtuple_t* entry, /*!< in: entry to insert */ + dtuple_t* entry, /*!< in/out: entry to insert */ que_thr_t* thr, /*!< in: query thread or NULL */ mtr_t* mtr, /*!< in/out: mini-transaction */ ibool* inherit)/*!< out: TRUE if the inserted new record maybe @@ -1186,7 +1217,7 @@ btr_cur_trx_report( const char* op) /*!< in: operation */ { fprintf(stderr, "Trx with id " TRX_ID_FMT " going to ", - TRX_ID_PREP_PRINTF(trx->id)); + (ullint) trx->id); fputs(op, stderr); dict_index_name_print(stderr, trx, index); putc('\n', stderr); @@ -1803,7 +1834,7 @@ func_exit: See if there is enough place in the page modification log to log an update-in-place. @return TRUE if enough place */ -static +UNIV_INTERN ibool btr_cur_update_alloc_zip( /*=====================*/ @@ -1883,7 +1914,7 @@ btr_cur_update_in_place( page_zip_des_t* page_zip; ulint err; rec_t* rec; - roll_ptr_t roll_ptr = ut_dulint_zero; + roll_ptr_t roll_ptr = 0; trx_t* trx; ulint was_delete_marked; mem_heap_t* heap = NULL; @@ -1933,13 +1964,14 @@ btr_cur_update_in_place( NOT call it if index is secondary */ if (!dict_index_is_clust(index) - || row_upd_changes_ord_field_binary(NULL, index, update)) { + || row_upd_changes_ord_field_binary(index, update, thr, + NULL, NULL)) { /* Remove possible hash index pointer to this record */ btr_search_update_hash_on_delete(cursor); } - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(cursor->index->id)); } if (!(flags & BTR_KEEP_SYS_FLAG)) { @@ -1953,7 +1985,7 @@ btr_cur_update_in_place( row_upd_rec_in_place(rec, index, offsets, update, page_zip); if (block->is_hashed) { - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); } if (page_zip && !dict_index_is_clust(index) @@ -2013,7 +2045,6 @@ btr_cur_optimistic_update( page_t* page; page_zip_des_t* page_zip; rec_t* rec; - rec_t* orig_rec; ulint max_size; ulint new_rec_size; ulint old_rec_size; @@ -2027,7 +2058,7 @@ btr_cur_optimistic_update( block = btr_cur_get_block(cursor); page = buf_block_get_frame(block); - orig_rec = rec = btr_cur_get_rec(cursor); + rec = btr_cur_get_rec(cursor); index = cursor->index; ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); @@ -2036,6 +2067,9 @@ btr_cur_optimistic_update( heap = mem_heap_create(1024); offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap); +#ifdef UNIV_BLOB_NULL_DEBUG + ut_a(!rec_offs_any_null_extern(rec, offsets)); +#endif /* UNIV_BLOB_NULL_DEBUG */ #ifdef UNIV_DEBUG if (btr_cur_print_record_ops && thr) { @@ -2476,8 +2510,8 @@ make_external: record on its page? */ was_first = page_cur_is_before_first(page_cursor); - /* The first parameter means that no lock checking and undo logging - is made in the insert */ + /* Lock checks and undo logging were already performed by + btr_cur_upd_lock_and_undo(). */ err = btr_cur_pessimistic_insert(BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG @@ -2686,27 +2720,24 @@ ulint btr_cur_del_mark_set_clust_rec( /*===========================*/ ulint flags, /*!< in: undo logging and locking flags */ - btr_cur_t* cursor, /*!< in: cursor */ + buf_block_t* block, /*!< in/out: buffer block of the record */ + rec_t* rec, /*!< in/out: record */ + dict_index_t* index, /*!< in: clustered index of the record */ + const ulint* offsets,/*!< in: rec_get_offsets(rec) */ ibool val, /*!< in: value to set */ que_thr_t* thr, /*!< in: query thread */ mtr_t* mtr) /*!< in: mtr */ { - dict_index_t* index; - buf_block_t* block; roll_ptr_t roll_ptr; ulint err; - rec_t* rec; page_zip_des_t* page_zip; trx_t* trx; - mem_heap_t* heap = NULL; - ulint offsets_[REC_OFFS_NORMAL_SIZE]; - ulint* offsets = offsets_; - rec_offs_init(offsets_); - rec = btr_cur_get_rec(cursor); - index = cursor->index; + ut_ad(dict_index_is_clust(index)); + ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); - offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); + ut_ad(buf_block_get_frame(block) == page_align(rec)); + ut_ad(page_is_leaf(page_align(rec))); #ifdef UNIV_DEBUG if (btr_cur_print_record_ops && thr) { @@ -2718,13 +2749,12 @@ btr_cur_del_mark_set_clust_rec( ut_ad(dict_index_is_clust(index)); ut_ad(!rec_get_deleted_flag(rec, rec_offs_comp(offsets))); - err = lock_clust_rec_modify_check_and_lock(flags, - btr_cur_get_block(cursor), + err = lock_clust_rec_modify_check_and_lock(flags, block, rec, index, offsets, thr); if (err != DB_SUCCESS) { - goto func_exit; + return(err); } err = trx_undo_report_row_operation(flags, TRX_UNDO_MODIFY_OP, thr, @@ -2732,17 +2762,16 @@ btr_cur_del_mark_set_clust_rec( &roll_ptr); if (err != DB_SUCCESS) { - goto func_exit; + return(err); } - block = btr_cur_get_block(cursor); - if (block->is_hashed) { - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(index->id)); } page_zip = buf_block_get_page_zip(block); + btr_blob_dbg_set_deleted_flag(rec, index, offsets, val); btr_rec_set_deleted_flag(rec, page_zip, val); trx = thr_get_trx(thr); @@ -2753,16 +2782,12 @@ btr_cur_del_mark_set_clust_rec( } if (block->is_hashed) { - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(index->id)); } btr_cur_del_mark_set_clust_rec_log(flags, rec, index, val, trx, roll_ptr, mtr); -func_exit: - if (UNIV_LIKELY_NULL(heap)) { - mem_heap_free(heap); - } return(err); } @@ -2884,13 +2909,13 @@ btr_cur_del_mark_set_sec_rec( == dict_table_is_comp(cursor->index->table)); if (block->is_hashed) { - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(cursor->index->id)); } btr_rec_set_deleted_flag(rec, buf_block_get_page_zip(block), val); if (block->is_hashed) { - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); } btr_cur_del_mark_set_sec_rec_log(rec, val, mtr); @@ -2899,25 +2924,26 @@ btr_cur_del_mark_set_sec_rec( } /***********************************************************//** -Clear a secondary index record's delete mark. This function is only -used by the insert buffer insert merge mechanism. */ +Sets a secondary index record's delete mark to the given value. This +function is only used by the insert buffer merge mechanism. */ UNIV_INTERN void -btr_cur_del_unmark_for_ibuf( -/*========================*/ - rec_t* rec, /*!< in/out: record to delete unmark */ +btr_cur_set_deleted_flag_for_ibuf( +/*==============================*/ + rec_t* rec, /*!< in/out: record */ page_zip_des_t* page_zip, /*!< in/out: compressed page corresponding to rec, or NULL when the tablespace is uncompressed */ + ibool val, /*!< in: value to set */ mtr_t* mtr) /*!< in: mtr */ { /* We do not need to reserve btr_search_latch, as the page has just been read to the buffer pool and there cannot be a hash index to it. */ - btr_rec_set_deleted_flag(rec, page_zip, FALSE); + btr_rec_set_deleted_flag(rec, page_zip, val); - btr_cur_del_mark_set_sec_rec_log(rec, FALSE, mtr); + btr_cur_del_mark_set_sec_rec_log(rec, val, mtr); } /*==================== B-TREE RECORD REMOVE =========================*/ @@ -3216,6 +3242,7 @@ btr_cur_add_path_info( { btr_path_t* slot; rec_t* rec; + page_t* page; ut_a(cursor->path_arr); @@ -3238,8 +3265,168 @@ btr_cur_add_path_info( slot = cursor->path_arr + (root_height - height); + page = page_align(rec); + slot->nth_rec = page_rec_get_n_recs_before(rec); - slot->n_recs = page_get_n_recs(page_align(rec)); + slot->n_recs = page_get_n_recs(page); + slot->page_no = page_get_page_no(page); + slot->page_level = btr_page_get_level_low(page); +} + +/*******************************************************************//** +Estimate the number of rows between slot1 and slot2 for any level on a +B-tree. This function starts from slot1->page and reads a few pages to +the right, counting their records. If we reach slot2->page quickly then +we know exactly how many records there are between slot1 and slot2 and +we set is_n_rows_exact to TRUE. If we cannot reach slot2->page quickly +then we calculate the average number of records in the pages scanned +so far and assume that all pages that we did not scan up to slot2->page +contain the same number of records, then we multiply that average to +the number of pages between slot1->page and slot2->page (which is +n_rows_on_prev_level). In this case we set is_n_rows_exact to FALSE. +@return number of rows (exact or estimated) */ +static +ib_int64_t +btr_estimate_n_rows_in_range_on_level( +/*==================================*/ + dict_index_t* index, /*!< in: index */ + btr_path_t* slot1, /*!< in: left border */ + btr_path_t* slot2, /*!< in: right border */ + ib_int64_t n_rows_on_prev_level, /*!< in: number of rows + on the previous level for the + same descend paths; used to + determine the numbe of pages + on this level */ + ibool* is_n_rows_exact) /*!< out: TRUE if the returned + value is exact i.e. not an + estimation */ +{ + ulint space; + ib_int64_t n_rows; + ulint n_pages_read; + ulint page_no; + ulint zip_size; + ulint level; + + space = dict_index_get_space(index); + + n_rows = 0; + n_pages_read = 0; + + /* Assume by default that we will scan all pages between + slot1->page_no and slot2->page_no */ + *is_n_rows_exact = TRUE; + + /* add records from slot1->page_no which are to the right of + the record which serves as a left border of the range, if any */ + if (slot1->nth_rec < slot1->n_recs) { + n_rows += slot1->n_recs - slot1->nth_rec; + } + + /* add records from slot2->page_no which are to the left of + the record which servers as a right border of the range, if any */ + if (slot2->nth_rec > 1) { + n_rows += slot2->nth_rec - 1; + } + + /* count the records in the pages between slot1->page_no and + slot2->page_no (non inclusive), if any */ + + zip_size = fil_space_get_zip_size(space); + + /* Do not read more than this number of pages in order not to hurt + performance with this code which is just an estimation. If we read + this many pages before reaching slot2->page_no then we estimate the + average from the pages scanned so far */ +# define N_PAGES_READ_LIMIT 10 + + page_no = slot1->page_no; + level = slot1->page_level; + + do { + mtr_t mtr; + page_t* page; + buf_block_t* block; + + mtr_start(&mtr); + + /* Fetch the page. Because we are not holding the + index->lock, the tree may have changed and we may be + attempting to read a page that is no longer part of + the B-tree. We pass BUF_GET_POSSIBLY_FREED in order to + silence a debug assertion about this. */ + block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, + NULL, BUF_GET_POSSIBLY_FREED, + __FILE__, __LINE__, &mtr); + + page = buf_block_get_frame(block); + + /* It is possible that the tree has been reorganized in the + meantime and this is a different page. If this happens the + calculated estimate will be bogus, which is not fatal as + this is only an estimate. We are sure that a page with + page_no exists because InnoDB never frees pages, only + reuses them. */ + if (fil_page_get_type(page) != FIL_PAGE_INDEX + || btr_page_get_index_id(page) != index->id + || btr_page_get_level_low(page) != level) { + + /* The page got reused for something else */ + mtr_commit(&mtr); + goto inexact; + } + + /* It is possible but highly unlikely that the page was + originally written by an old version of InnoDB that did + not initialize FIL_PAGE_TYPE on other than B-tree pages. + For example, this could be an almost-empty BLOB page + that happens to contain the magic values in the fields + that we checked above. */ + + n_pages_read++; + + if (page_no != slot1->page_no) { + /* Do not count the records on slot1->page_no, + we already counted them before this loop. */ + n_rows += page_get_n_recs(page); + } + + page_no = btr_page_get_next(page, &mtr); + + mtr_commit(&mtr); + + if (n_pages_read == N_PAGES_READ_LIMIT + || page_no == FIL_NULL) { + /* Either we read too many pages or + we reached the end of the level without passing + through slot2->page_no, the tree must have changed + in the meantime */ + goto inexact; + } + + } while (page_no != slot2->page_no); + + return(n_rows); + +inexact: + + *is_n_rows_exact = FALSE; + + /* We did interrupt before reaching slot2->page */ + + if (n_pages_read > 0) { + /* The number of pages on this level is + n_rows_on_prev_level, multiply it by the + average number of recs per page so far */ + n_rows = n_rows_on_prev_level + * n_rows / n_pages_read; + } else { + /* The tree changed before we could even + start with slot1->page_no */ + n_rows = 10; + } + + return(n_rows); } /*******************************************************************//** @@ -3264,6 +3451,7 @@ btr_estimate_n_rows_in_range( ibool diverged_lot; ulint divergence_level; ib_int64_t n_rows; + ibool is_n_rows_exact; ulint i; mtr_t mtr; @@ -3306,6 +3494,7 @@ btr_estimate_n_rows_in_range( /* We have the path information for the range in path1 and path2 */ n_rows = 1; + is_n_rows_exact = TRUE; diverged = FALSE; /* This becomes true when the path is not the same any more */ diverged_lot = FALSE; /* This becomes true when the paths are @@ -3321,7 +3510,7 @@ btr_estimate_n_rows_in_range( if (slot1->nth_rec == ULINT_UNDEFINED || slot2->nth_rec == ULINT_UNDEFINED) { - if (i > divergence_level + 1) { + if (i > divergence_level + 1 && !is_n_rows_exact) { /* In trees whose height is > 1 our algorithm tends to underestimate: multiply the estimate by 2: */ @@ -3333,7 +3522,9 @@ btr_estimate_n_rows_in_range( to over 1 / 2 of the estimated rows in the whole table */ - if (n_rows > index->table->stat_n_rows / 2) { + if (n_rows > index->table->stat_n_rows / 2 + && !is_n_rows_exact) { + n_rows = index->table->stat_n_rows / 2; /* If there are just 0 or 1 rows in the table, @@ -3359,10 +3550,15 @@ btr_estimate_n_rows_in_range( divergence_level = i; } } else { - /* Maybe the tree has changed between - searches */ - - return(10); + /* It is possible that + slot1->nth_rec >= slot2->nth_rec + if, for example, we have a single page + tree which contains (inf, 5, 6, supr) + and we select where x > 20 and x < 30; + in this case slot1->nth_rec will point + to the supr record and slot2->nth_rec + will point to 6 */ + n_rows = 0; } } else if (diverged && !diverged_lot) { @@ -3386,156 +3582,51 @@ btr_estimate_n_rows_in_range( } } else if (diverged_lot) { - n_rows = (n_rows * (slot1->n_recs + slot2->n_recs)) - / 2; + n_rows = btr_estimate_n_rows_in_range_on_level( + index, slot1, slot2, n_rows, + &is_n_rows_exact); } } } /*******************************************************************//** -Estimates the number of pages which have not null value of the key of n_cols. -@return estimated number of pages */ -UNIV_INTERN -ulint -btr_estimate_n_pages_not_null( -/*=========================*/ - dict_index_t* index, /*!< in: index */ - ulint n_cols, /*!< in: The cols should be not null */ - btr_path_t* path1) /*!< in: path1[BTR_PATH_ARRAY_N_SLOTS] */ +Record the number of non_null key values in a given index for +each n-column prefix of the index where n < dict_index_get_n_unique(index). +The estimates are eventually stored in the array: +index->stat_n_non_null_key_vals. */ +static +void +btr_record_not_null_field_in_rec( +/*=============================*/ + rec_t* rec, /*!< in: physical record */ + ulint n_unique, /*!< in: dict_index_get_n_unique(index), + number of columns uniquely determine + an index entry */ + const ulint* offsets, /*!< in: rec_get_offsets(rec, index), + its size could be for all fields or + that of "n_unique" */ + ib_int64_t* n_not_null) /*!< in/out: array to record number of + not null rows for n-column prefix */ { - dtuple_t* tuple1; - btr_path_t path2[BTR_PATH_ARRAY_N_SLOTS]; - btr_cur_t cursor; - btr_path_t* slot1; - btr_path_t* slot2; - ibool diverged; - ibool diverged_lot; - ulint divergence_level; - ulint n_pages; - ulint i; - mtr_t mtr; - mem_heap_t* heap; + ulint i; - heap = mem_heap_create(n_cols * sizeof(dfield_t) - + sizeof(dtuple_t)); + ut_ad(rec_offs_n_fields(offsets) >= n_unique); - /* make tuple1 (NULL,NULL,,,) from n_cols */ - tuple1 = dtuple_create(heap, n_cols); - dict_index_copy_types(tuple1, index, n_cols); - - for (i = 0; i < n_cols; i++) { - dfield_set_null(dtuple_get_nth_field(tuple1, i)); + if (n_not_null == NULL) { + return; } - mtr_start(&mtr); + for (i = 0; i < n_unique; i++) { + ulint rec_len; + byte* field; - cursor.path_arr = path1; + field = rec_get_nth_field(rec, offsets, i, &rec_len); - btr_cur_search_to_nth_level(index, 0, tuple1, PAGE_CUR_G, - BTR_SEARCH_LEAF | BTR_ESTIMATE, - &cursor, 0, __FILE__, __LINE__, &mtr); - - mtr_commit(&mtr); - - - - mtr_start(&mtr); - - cursor.path_arr = path2; - - btr_cur_open_at_index_side(FALSE, index, - BTR_SEARCH_LEAF | BTR_ESTIMATE, - &cursor, &mtr); - - mtr_commit(&mtr); - - mem_heap_free(heap); - - /* We have the path information for the range in path1 and path2 */ - - n_pages = 1; - diverged = FALSE; /* This becomes true when the path is not - the same any more */ - diverged_lot = FALSE; /* This becomes true when the paths are - not the same or adjacent any more */ - divergence_level = 1000000; /* This is the level where paths diverged - a lot */ - for (i = 0; ; i++) { - ut_ad(i < BTR_PATH_ARRAY_N_SLOTS); - - slot1 = path1 + i; - slot2 = path2 + i; - - if ((slot1 + 1)->nth_rec == ULINT_UNDEFINED - || (slot2 + 1)->nth_rec == ULINT_UNDEFINED) { - - if (i > divergence_level + 1) { - /* In trees whose height is > 1 our algorithm - tends to underestimate: multiply the estimate - by 2: */ - - n_pages = n_pages * 2; - } - - /* Do not estimate the number of rows in the range - to over 1 / 2 of the estimated rows in the whole - table */ - - if (n_pages > index->stat_n_leaf_pages / 2) { - n_pages = index->stat_n_leaf_pages / 2; - - /* If there are just 0 or 1 rows in the table, - then we estimate all rows are in the range */ - - if (n_pages == 0) { - n_pages = index->stat_n_leaf_pages; - } - } - - return(n_pages); - } - - if (!diverged && slot1->nth_rec != slot2->nth_rec) { - - diverged = TRUE; - - if (slot1->nth_rec < slot2->nth_rec) { - n_pages = slot2->nth_rec - slot1->nth_rec; - - if (n_pages > 1) { - diverged_lot = TRUE; - divergence_level = i; - } - } else { - /* Maybe the tree has changed between - searches */ - - return(10); - } - - } else if (diverged && !diverged_lot) { - - if (slot1->nth_rec < slot1->n_recs - || slot2->nth_rec > 1) { - - diverged_lot = TRUE; - divergence_level = i; - - n_pages = 0; - - if (slot1->nth_rec < slot1->n_recs) { - n_pages += slot1->n_recs - - slot1->nth_rec; - } - - if (slot2->nth_rec > 1) { - n_pages += slot2->nth_rec - 1; - } - } - } else if (diverged_lot) { - - n_pages = (n_pages * (slot1->n_recs + slot2->n_recs)) - / 2; + if (rec_len != UNIV_SQL_NULL) { + n_not_null[i]++; + } else { + /* Break if we hit the first NULL value */ + break; } } } @@ -3543,7 +3634,10 @@ btr_estimate_n_pages_not_null( /*******************************************************************//** Estimates the number of different key values in a given index, for each n-column prefix of the index where n <= dict_index_get_n_unique(index). -The estimates are stored in the array index->stat_n_diff_key_vals. */ +The estimates are stored in the array index->stat_n_diff_key_vals. +If innodb_stats_method is "nulls_ignored", we also record the number of +non-null values for each prefix and store the estimates in +array index->stat_n_non_null_key_vals. */ UNIV_INTERN void btr_estimate_number_of_different_key_vals( @@ -3557,6 +3651,8 @@ btr_estimate_number_of_different_key_vals( ulint matched_fields; ulint matched_bytes; ib_int64_t* n_diff; + ib_int64_t* n_not_null; + ibool stats_null_not_equal; ullint n_sample_pages; /* number of pages to sample */ ulint not_empty_flag = 0; ulint total_external_size = 0; @@ -3565,44 +3661,49 @@ btr_estimate_number_of_different_key_vals( ullint add_on; mtr_t mtr; mem_heap_t* heap = NULL; - ulint offsets_rec_[REC_OFFS_NORMAL_SIZE]; - ulint offsets_next_rec_[REC_OFFS_NORMAL_SIZE]; - ulint* offsets_rec = offsets_rec_; - ulint* offsets_next_rec= offsets_next_rec_; - ulint stats_method = srv_stats_method; - btr_path_t first_rec_path[BTR_PATH_ARRAY_N_SLOTS]; - ulint effective_pages; /* effective leaf pages */ - rec_offs_init(offsets_rec_); - rec_offs_init(offsets_next_rec_); + ulint* offsets_rec = NULL; + ulint* offsets_next_rec = NULL; n_cols = dict_index_get_n_unique(index); - if (stats_method == SRV_STATS_METHOD_IGNORE_NULLS) { - /* estimate effective pages and path for the first effective record */ - /* TODO: make it work also for n_cols > 1. */ - effective_pages = btr_estimate_n_pages_not_null(index, 1 /*k*/, first_rec_path); + heap = mem_heap_create((sizeof *n_diff + sizeof *n_not_null) + * (n_cols + 1) + + dict_index_get_n_fields(index) + * (sizeof *offsets_rec + + sizeof *offsets_next_rec)); - if (!effective_pages) { - dict_index_stat_mutex_enter(index); - for (j = 0; j <= n_cols; j++) { - index->stat_n_diff_key_vals[j] = (ib_int64_t)index->stat_n_leaf_pages; - } - dict_index_stat_mutex_exit(index); - return; - } else if (effective_pages > index->stat_n_leaf_pages) { - effective_pages = index->stat_n_leaf_pages; - } - } else { - effective_pages = index->stat_n_leaf_pages; - } + n_diff = mem_heap_zalloc(heap, (n_cols + 1) * sizeof(ib_int64_t)); - n_diff = mem_zalloc((n_cols + 1) * sizeof(ib_int64_t)); + n_not_null = NULL; + + /* Check srv_innodb_stats_method setting, and decide whether we + need to record non-null value and also decide if NULL is + considered equal (by setting stats_null_not_equal value) */ + switch (srv_innodb_stats_method) { + case SRV_STATS_NULLS_IGNORED: + n_not_null = mem_heap_zalloc(heap, (n_cols + 1) + * sizeof *n_not_null); + /* fall through */ + + case SRV_STATS_NULLS_UNEQUAL: + /* for both SRV_STATS_NULLS_IGNORED and SRV_STATS_NULLS_UNEQUAL + case, we will treat NULLs as unequal value */ + stats_null_not_equal = TRUE; + break; + + case SRV_STATS_NULLS_EQUAL: + stats_null_not_equal = FALSE; + break; + + default: + ut_error; + } /* It makes no sense to test more pages than are contained in the index, thus we lower the number if it is too high */ - if (srv_stats_sample_pages > effective_pages) { - if (effective_pages > 0) { - n_sample_pages = effective_pages; + if (srv_stats_sample_pages > index->stat_index_size) { + if (index->stat_index_size > 0) { + n_sample_pages = index->stat_index_size; } else { n_sample_pages = 1; } @@ -3613,16 +3714,9 @@ btr_estimate_number_of_different_key_vals( /* We sample some pages in the index to get an estimate */ for (i = 0; i < n_sample_pages; i++) { - rec_t* supremum; - ibool is_first_page = TRUE; mtr_start(&mtr); - if (stats_method == SRV_STATS_METHOD_IGNORE_NULLS) { - is_first_page = btr_cur_open_at_rnd_pos_after_path(index, BTR_SEARCH_LEAF, - first_rec_path, &cursor, &mtr); - } else { btr_cur_open_at_rnd_pos(index, BTR_SEARCH_LEAF, &cursor, &mtr); - } /* Count the number of different key values for each prefix of the key on this index page. If the prefix does not determine @@ -3637,25 +3731,25 @@ btr_estimate_number_of_different_key_vals( } ut_a(page); - supremum = page_get_supremum_rec(page); - if (stats_method == SRV_STATS_METHOD_IGNORE_NULLS && is_first_page) { - /* the cursor should be the first record of the page. */ - /* Counting should be started from here. */ - rec = btr_cur_get_rec(&cursor); - } else { rec = page_rec_get_next(page_get_infimum_rec(page)); - } - if (rec != supremum) { + if (!page_rec_is_supremum(rec)) { not_empty_flag = 1; offsets_rec = rec_get_offsets(rec, index, offsets_rec, ULINT_UNDEFINED, &heap); + + if (n_not_null) { + btr_record_not_null_field_in_rec( + rec, n_cols, offsets_rec, n_not_null); + } } - while (rec != supremum) { - rec_t* next_rec; - next_rec = page_rec_get_next(rec); - if (next_rec == supremum) { + while (!page_rec_is_supremum(rec)) { + rec_t* next_rec = page_rec_get_next(rec); + if (page_rec_is_supremum(next_rec)) { + total_external_size += + btr_rec_get_externally_stored_len( + rec, offsets_rec); break; } @@ -3663,15 +3757,14 @@ btr_estimate_number_of_different_key_vals( matched_bytes = 0; offsets_next_rec = rec_get_offsets(next_rec, index, offsets_next_rec, - n_cols, &heap); + ULINT_UNDEFINED, + &heap); cmp_rec_rec_with_match(rec, next_rec, offsets_rec, offsets_next_rec, - index, &matched_fields, - &matched_bytes, - (stats_method==SRV_STATS_METHOD_NULLS_NOT_EQUAL) ? - SRV_STATS_METHOD_NULLS_NOT_EQUAL : - SRV_STATS_METHOD_NULLS_EQUAL); + index, stats_null_not_equal, + &matched_fields, + &matched_bytes); for (j = matched_fields + 1; j <= n_cols; j++) { /* We add one if this index record has @@ -3680,6 +3773,12 @@ btr_estimate_number_of_different_key_vals( n_diff[j]++; } + if (n_not_null) { + btr_record_not_null_field_in_rec( + next_rec, n_cols, offsets_next_rec, + n_not_null); + } + total_external_size += btr_rec_get_externally_stored_len( rec, offsets_rec); @@ -3714,10 +3813,6 @@ btr_estimate_number_of_different_key_vals( } } - offsets_rec = rec_get_offsets(rec, index, offsets_rec, - ULINT_UNDEFINED, &heap); - total_external_size += btr_rec_get_externally_stored_len( - rec, offsets_rec); mtr_commit(&mtr); } @@ -3729,17 +3824,11 @@ btr_estimate_number_of_different_key_vals( also the pages used for external storage of fields (those pages are included in index->stat_n_leaf_pages) */ - dict_index_stat_mutex_enter(index); - for (j = 0; j <= n_cols; j++) { index->stat_n_diff_key_vals[j] - = ((n_diff[j] - * (ib_int64_t)effective_pages - + n_sample_pages - 1 - + total_external_size - + not_empty_flag) - / (n_sample_pages - + total_external_size)); + = BTR_TABLE_STATS_FROM_SAMPLE( + n_diff[j], index, n_sample_pages, + total_external_size, not_empty_flag); /* If the tree is small, smaller than 10 * n_sample_pages + total_external_size, then @@ -3749,7 +3838,7 @@ btr_estimate_number_of_different_key_vals( different key values, or even more. Let us try to approximate that: */ - add_on = effective_pages + add_on = index->stat_n_leaf_pages / (10 * (n_sample_pages + total_external_size)); @@ -3759,26 +3848,52 @@ btr_estimate_number_of_different_key_vals( index->stat_n_diff_key_vals[j] += add_on; - if (stats_method == SRV_STATS_METHOD_IGNORE_NULLS) { - /* index->stat_n_diff_key_vals[k] is used for calc rec_per_key, - as "stats.records / index->stat_n_diff_key_vals[x]". - So it should be adjusted to the value which is based on whole of the index. */ - index->stat_n_diff_key_vals[j] = - index->stat_n_diff_key_vals[j] * (ib_int64_t)index->stat_n_leaf_pages - / (ib_int64_t)effective_pages; + /* Update the stat_n_non_null_key_vals[] with our + sampled result. stat_n_non_null_key_vals[] is created + and initialized to zero in dict_index_add_to_cache(), + along with stat_n_diff_key_vals[] array */ + if (n_not_null != NULL && (j < n_cols)) { + index->stat_n_non_null_key_vals[j] = + BTR_TABLE_STATS_FROM_SAMPLE( + n_not_null[j], index, n_sample_pages, + total_external_size, not_empty_flag); } } - dict_index_stat_mutex_exit(index); - - mem_free(n_diff); - if (UNIV_LIKELY_NULL(heap)) { - mem_heap_free(heap); - } + mem_heap_free(heap); } /*================== EXTERNAL STORAGE OF BIG FIELDS ===================*/ +/***********************************************************//** +Gets the offset of the pointer to the externally stored part of a field. +@return offset of the pointer to the externally stored part */ +static +ulint +btr_rec_get_field_ref_offs( +/*=======================*/ + const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ + ulint n) /*!< in: index of the external field */ +{ + ulint field_ref_offs; + ulint local_len; + + ut_a(rec_offs_nth_extern(offsets, n)); + field_ref_offs = rec_get_nth_field_offs(offsets, n, &local_len); + ut_a(local_len != UNIV_SQL_NULL); + ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE); + + return(field_ref_offs + local_len - BTR_EXTERN_FIELD_REF_SIZE); +} + +/** Gets a pointer to the externally stored part of a field. +@param rec record +@param offsets rec_get_offsets(rec) +@param n index of the externally stored field +@return pointer to the externally stored part */ +#define btr_rec_get_field_ref(rec, offsets, n) \ + ((rec) + btr_rec_get_field_ref_offs(offsets, n)) + /***********************************************************//** Gets the externally stored size of a record, in units of a database page. @return externally stored part, in units of a database page */ @@ -3786,28 +3901,27 @@ static ulint btr_rec_get_externally_stored_len( /*==============================*/ - rec_t* rec, /*!< in: record */ + const rec_t* rec, /*!< in: record */ const ulint* offsets)/*!< in: array returned by rec_get_offsets() */ { ulint n_fields; - byte* data; - ulint local_len; - ulint extern_len; ulint total_extern_len = 0; ulint i; ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec)); + + if (!rec_offs_any_extern(offsets)) { + return(0); + } + n_fields = rec_offs_n_fields(offsets); for (i = 0; i < n_fields; i++) { if (rec_offs_nth_extern(offsets, i)) { - data = rec_get_nth_field(rec, offsets, i, &local_len); - - local_len -= BTR_EXTERN_FIELD_REF_SIZE; - - extern_len = mach_read_from_4(data + local_len - + BTR_EXTERN_LEN + 4); + ulint extern_len = mach_read_from_4( + btr_rec_get_field_ref(rec, offsets, i) + + BTR_EXTERN_LEN + 4); total_extern_len += ut_calc_align(extern_len, UNIV_PAGE_SIZE); @@ -3837,7 +3951,7 @@ btr_cur_set_ownership_of_extern_field( ulint byte_val; data = rec_get_nth_field(rec, offsets, i, &local_len); - + ut_ad(rec_offs_nth_extern(offsets, i)); ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE); local_len -= BTR_EXTERN_FIELD_REF_SIZE; @@ -3847,6 +3961,9 @@ btr_cur_set_ownership_of_extern_field( if (val) { byte_val = byte_val & (~BTR_EXTERN_OWNER_FLAG); } else { +#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG + ut_a(!(byte_val & BTR_EXTERN_OWNER_FLAG)); +#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ byte_val = byte_val | BTR_EXTERN_OWNER_FLAG; } @@ -3860,111 +3977,41 @@ btr_cur_set_ownership_of_extern_field( } else { mach_write_to_1(data + local_len + BTR_EXTERN_LEN, byte_val); } + + btr_blob_dbg_owner(rec, index, offsets, i, val); } /*******************************************************************//** -Marks not updated extern fields as not-owned by this record. The ownership -is transferred to the updated record which is inserted elsewhere in the +Marks non-updated off-page fields as disowned by this record. The ownership +must be transferred to the updated record which is inserted elsewhere in the index tree. In purge only the owner of externally stored field is allowed -to free the field. -@return TRUE if BLOB ownership was transferred */ +to free the field. */ UNIV_INTERN -ibool -btr_cur_mark_extern_inherited_fields( -/*=================================*/ +void +btr_cur_disown_inherited_fields( +/*============================*/ page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed part will be updated, or NULL */ rec_t* rec, /*!< in/out: record in a clustered index */ dict_index_t* index, /*!< in: index of the page */ const ulint* offsets,/*!< in: array returned by rec_get_offsets() */ const upd_t* update, /*!< in: update vector */ - mtr_t* mtr) /*!< in: mtr, or NULL if not logged */ + mtr_t* mtr) /*!< in/out: mini-transaction */ { - ulint n; - ulint j; ulint i; - ibool change_ownership = FALSE; - ut_ad(rec_offs_validate(rec, NULL, offsets)); + ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec)); + ut_ad(rec_offs_any_extern(offsets)); + ut_ad(mtr); - if (!rec_offs_any_extern(offsets)) { - - return(FALSE); - } - - n = rec_offs_n_fields(offsets); - - for (i = 0; i < n; i++) { - if (rec_offs_nth_extern(offsets, i)) { - - /* Check it is not in updated fields */ - - if (update) { - for (j = 0; j < upd_get_n_fields(update); - j++) { - if (upd_get_nth_field(update, j) - ->field_no == i) { - - goto updated; - } - } - } - + for (i = 0; i < rec_offs_n_fields(offsets); i++) { + if (rec_offs_nth_extern(offsets, i) + && !upd_get_field_by_field_no(update, i)) { btr_cur_set_ownership_of_extern_field( page_zip, rec, index, offsets, i, FALSE, mtr); - - change_ownership = TRUE; -updated: - ; } } - - return(change_ownership); -} - -/*******************************************************************//** -The complement of the previous function: in an update entry may inherit -some externally stored fields from a record. We must mark them as inherited -in entry, so that they are not freed in a rollback. */ -UNIV_INTERN -void -btr_cur_mark_dtuple_inherited_extern( -/*=================================*/ - dtuple_t* entry, /*!< in/out: updated entry to be - inserted to clustered index */ - const upd_t* update) /*!< in: update vector */ -{ - ulint i; - - for (i = 0; i < dtuple_get_n_fields(entry); i++) { - - dfield_t* dfield = dtuple_get_nth_field(entry, i); - byte* data; - ulint len; - ulint j; - - if (!dfield_is_ext(dfield)) { - continue; - } - - /* Check if it is in updated fields */ - - for (j = 0; j < upd_get_n_fields(update); j++) { - if (upd_get_nth_field(update, j)->field_no == i) { - - goto is_updated; - } - } - - data = dfield_get_data(dfield); - len = dfield_get_len(dfield); - data[len - BTR_EXTERN_FIELD_REF_SIZE + BTR_EXTERN_LEN] - |= BTR_EXTERN_INHERITED_FLAG; - -is_updated: - ; - } } /*******************************************************************//** @@ -4002,29 +4049,6 @@ btr_cur_unmark_extern_fields( } } -/*******************************************************************//** -Marks all extern fields in a dtuple as owned by the record. */ -UNIV_INTERN -void -btr_cur_unmark_dtuple_extern_fields( -/*================================*/ - dtuple_t* entry) /*!< in/out: clustered index entry */ -{ - ulint i; - - for (i = 0; i < dtuple_get_n_fields(entry); i++) { - dfield_t* dfield = dtuple_get_nth_field(entry, i); - - if (dfield_is_ext(dfield)) { - byte* data = dfield_get_data(dfield); - ulint len = dfield_get_len(dfield); - - data[len - BTR_EXTERN_FIELD_REF_SIZE + BTR_EXTERN_LEN] - &= ~BTR_EXTERN_OWNER_FLAG; - } - } -} - /*******************************************************************//** Flags the data tuple fields that are marked as extern storage in the update vector. We use this function to remember which fields we must @@ -4140,15 +4164,16 @@ btr_blob_free( if there is one */ mtr_t* mtr) /*!< in: mini-transaction to commit */ { - ulint space = buf_block_get_space(block); - ulint page_no = buf_block_get_page_no(block); + buf_pool_t* buf_pool = buf_pool_from_block(block); + ulint space = buf_block_get_space(block); + ulint page_no = buf_block_get_page_no(block); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); mtr_commit(mtr); - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); mutex_enter(&block->mutex); /* Only free the block if it is still allocated to @@ -4159,8 +4184,7 @@ btr_blob_free( && buf_block_get_space(block) == space && buf_block_get_page_no(block) == page_no) { - if (buf_LRU_free_block(&block->page, all, NULL, TRUE) - != BUF_LRU_FREED + if (buf_LRU_free_block(&block->page, all, TRUE) != BUF_LRU_FREED && all && block->page.zip.data /* Now, buf_LRU_free_block() may release mutex temporarily */ && buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE @@ -4169,12 +4193,12 @@ btr_blob_free( /* Attempt to deallocate the uncompressed page if the whole block cannot be deallocted. */ - buf_LRU_free_block(&block->page, FALSE, NULL, TRUE); + buf_LRU_free_block(&block->page, FALSE, TRUE); } } - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); mutex_exit(&block->mutex); } @@ -4183,11 +4207,11 @@ Stores the fields in big_rec_vec to the tablespace and puts pointers to them in rec. The extern flags in rec will have to be set beforehand. The fields are stored on pages allocated from leaf node file segment of the index tree. -@return DB_SUCCESS or error */ +@return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ UNIV_INTERN ulint -btr_store_big_rec_extern_fields( -/*============================*/ +btr_store_big_rec_extern_fields_func( +/*=================================*/ dict_index_t* index, /*!< in: index of rec; the index tree MUST be X-latched */ buf_block_t* rec_block, /*!< in/out: block containing rec */ @@ -4196,11 +4220,17 @@ btr_store_big_rec_extern_fields( the "external storage" flags in offsets will not correspond to rec when this function returns */ - big_rec_t* big_rec_vec, /*!< in: vector containing fields +#ifdef UNIV_DEBUG + mtr_t* local_mtr, /*!< in: mtr containing the + latch to rec and to the tree */ +#endif /* UNIV_DEBUG */ +#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG + ibool update_in_place,/*! in: TRUE if the record is updated + in place (not delete+insert) */ +#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ + const big_rec_t*big_rec_vec) /*!< in: vector containing fields to be stored externally */ - mtr_t* local_mtr __attribute__((unused))) /*!< in: mtr - containing the latch to rec and to the - tree */ + { ulint rec_page_no; byte* field_ref; @@ -4218,6 +4248,7 @@ btr_store_big_rec_extern_fields( z_stream c_stream; ut_ad(rec_offs_validate(rec, index, offsets)); + ut_ad(rec_offs_any_extern(offsets)); ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index), MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains(local_mtr, rec_block, MTR_MEMO_PAGE_X_FIX)); @@ -4249,21 +4280,37 @@ btr_store_big_rec_extern_fields( ut_a(err == Z_OK); } +#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG + /* All pointers to externally stored columns in the record + must either be zero or they must be pointers to inherited + columns, owned by this record or an earlier record version. */ + for (i = 0; i < rec_offs_n_fields(offsets); i++) { + if (!rec_offs_nth_extern(offsets, i)) { + continue; + } + field_ref = btr_rec_get_field_ref(rec, offsets, i); + + ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG)); + /* Either this must be an update in place, + or the BLOB must be inherited, or the BLOB pointer + must be zero (will be written in this function). */ + ut_a(update_in_place + || (field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_INHERITED_FLAG) + || !memcmp(field_ref, field_ref_zero, + BTR_EXTERN_FIELD_REF_SIZE)); + } +#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ /* We have to create a file segment to the tablespace for each field and put the pointer to the field in rec */ for (i = 0; i < big_rec_vec->n_fields; i++) { - ut_ad(rec_offs_nth_extern(offsets, - big_rec_vec->fields[i].field_no)); - { - ulint local_len; - field_ref = rec_get_nth_field( - rec, offsets, big_rec_vec->fields[i].field_no, - &local_len); - ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE); - local_len -= BTR_EXTERN_FIELD_REF_SIZE; - field_ref += local_len; - } + field_ref = btr_rec_get_field_ref( + rec, offsets, big_rec_vec->fields[i].field_no); +#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG + /* A zero BLOB pointer should have been initially inserted. */ + ut_a(!memcmp(field_ref, field_ref_zero, + BTR_EXTERN_FIELD_REF_SIZE)); +#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ extern_len = big_rec_vec->fields[i].len; UNIV_MEM_ASSERT_RW(big_rec_vec->fields[i].data, extern_len); @@ -4438,6 +4485,11 @@ btr_store_big_rec_extern_fields( } if (prev_page_no == FIL_NULL) { + btr_blob_dbg_add_blob( + rec, big_rec_vec->fields[i] + .field_no, page_no, index, + "store"); + mach_write_to_4(field_ref + BTR_EXTERN_SPACE_ID, space_id); @@ -4513,6 +4565,11 @@ next_zip_page: MLOG_4BYTES, &mtr); if (prev_page_no == FIL_NULL) { + btr_blob_dbg_add_blob( + rec, big_rec_vec->fields[i] + .field_no, page_no, index, + "store"); + mlog_write_ulint(field_ref + BTR_EXTERN_SPACE_ID, space_id, @@ -4545,6 +4602,23 @@ next_zip_page: mem_heap_free(heap); } +#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG + /* All pointers to externally stored columns in the record + must be valid. */ + for (i = 0; i < rec_offs_n_fields(offsets); i++) { + if (!rec_offs_nth_extern(offsets, i)) { + continue; + } + + field_ref = btr_rec_get_field_ref(rec, offsets, i); + + /* The pointer must not be zero. */ + ut_a(0 != memcmp(field_ref, field_ref_zero, + BTR_EXTERN_FIELD_REF_SIZE)); + /* The column must not be disowned by this record. */ + ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG)); + } +#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ return(DB_SUCCESS); } @@ -4567,6 +4641,7 @@ btr_check_blob_fil_page_type( if (UNIV_UNLIKELY(type != FIL_PAGE_TYPE_BLOB)) { ulint flags = fil_space_get_flags(space_id); +#ifndef UNIV_DEBUG /* Improve debug test coverage */ if (UNIV_LIKELY ((flags & DICT_TF_FORMAT_MASK) == DICT_TF_FORMAT_51)) { /* Old versions of InnoDB did not initialize @@ -4575,6 +4650,7 @@ btr_check_blob_fil_page_type( a BLOB page that is in Antelope format.*/ return; } +#endif /* !UNIV_DEBUG */ ut_print_timestamp(stderr); fprintf(stderr, @@ -4624,23 +4700,13 @@ btr_free_externally_stored_field( ulint page_no; ulint next_page_no; mtr_t mtr; -#ifdef UNIV_DEBUG + ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index), MTR_MEMO_X_LOCK)); ut_ad(mtr_memo_contains_page(local_mtr, field_ref, MTR_MEMO_PAGE_X_FIX)); ut_ad(!rec || rec_offs_validate(rec, index, offsets)); - - if (rec) { - ulint local_len; - const byte* f = rec_get_nth_field(rec, offsets, - i, &local_len); - ut_a(local_len >= BTR_EXTERN_FIELD_REF_SIZE); - local_len -= BTR_EXTERN_FIELD_REF_SIZE; - f += local_len; - ut_ad(f == field_ref); - } -#endif /* UNIV_DEBUG */ + ut_ad(!rec || field_ref == btr_rec_get_field_ref(rec, offsets, i)); if (UNIV_UNLIKELY(!memcmp(field_ref, field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE))) { @@ -4672,18 +4738,52 @@ btr_free_externally_stored_field( rec_zip_size = 0; } +#ifdef UNIV_BLOB_DEBUG + if (!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG) + && !((field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_INHERITED_FLAG) + && (rb_ctx == RB_NORMAL || rb_ctx == RB_RECOVERY))) { + /* This off-page column will be freed. + Check that no references remain. */ + + btr_blob_dbg_t b; + + b.blob_page_no = mach_read_from_4( + field_ref + BTR_EXTERN_PAGE_NO); + + if (rec) { + /* Remove the reference from the record to the + BLOB. If the BLOB were not freed, the + reference would be removed when the record is + removed. Freeing the BLOB will overwrite the + BTR_EXTERN_PAGE_NO in the field_ref of the + record with FIL_NULL, which would make the + btr_blob_dbg information inconsistent with the + record. */ + b.ref_page_no = page_get_page_no(page_align(rec)); + b.ref_heap_no = page_rec_get_heap_no(rec); + b.ref_field_no = i; + btr_blob_dbg_rbt_delete(index, &b, "free"); + } + + btr_blob_dbg_assert_empty(index, b.blob_page_no); + } +#endif /* UNIV_BLOB_DEBUG */ + for (;;) { +#ifdef UNIV_SYNC_DEBUG buf_block_t* rec_block; +#endif /* UNIV_SYNC_DEBUG */ buf_block_t* ext_block; mtr_start(&mtr); - rec_block = buf_page_get(page_get_space_id( - page_align(field_ref)), - rec_zip_size, - page_get_page_no( - page_align(field_ref)), - RW_X_LATCH, &mtr); +#ifdef UNIV_SYNC_DEBUG + rec_block = +#endif /* UNIV_SYNC_DEBUG */ + buf_page_get(page_get_space_id(page_align(field_ref)), + rec_zip_size, + page_get_page_no(page_align(field_ref)), + RW_X_LATCH, &mtr); buf_block_dbg_add_level(rec_block, SYNC_NO_ORDER_CHECK); page_no = mach_read_from_4(field_ref + BTR_EXTERN_PAGE_NO); @@ -4800,13 +4900,8 @@ btr_rec_free_externally_stored_fields( for (i = 0; i < n_fields; i++) { if (rec_offs_nth_extern(offsets, i)) { - ulint len; - byte* data - = rec_get_nth_field(rec, offsets, i, &len); - ut_a(len >= BTR_EXTERN_FIELD_REF_SIZE); - btr_free_externally_stored_field( - index, data + len - BTR_EXTERN_FIELD_REF_SIZE, + index, btr_rec_get_field_ref(rec, offsets, i), rec, offsets, page_zip, i, rb_ctx, mtr); } } @@ -4918,27 +5013,45 @@ btr_copy_blob_prefix( /*******************************************************************//** Copies the prefix of a compressed BLOB. The clustered index record -that points to this BLOB must be protected by a lock or a page latch. */ +that points to this BLOB must be protected by a lock or a page latch. +@return number of bytes written to buf */ static -void +ulint btr_copy_zblob_prefix( /*==================*/ - z_stream* d_stream,/*!< in/out: the decompressing stream */ + byte* buf, /*!< out: the externally stored part of + the field, or a prefix of it */ + ulint len, /*!< in: length of buf, in bytes */ ulint zip_size,/*!< in: compressed BLOB page size */ ulint space_id,/*!< in: space id of the BLOB pages */ ulint page_no,/*!< in: page number of the first BLOB page */ ulint offset) /*!< in: offset on the first BLOB page */ { - ulint page_type = FIL_PAGE_TYPE_ZBLOB; + ulint page_type = FIL_PAGE_TYPE_ZBLOB; + mem_heap_t* heap; + int err; + z_stream d_stream; + + d_stream.next_out = buf; + d_stream.avail_out = len; + d_stream.next_in = Z_NULL; + d_stream.avail_in = 0; + + /* Zlib inflate needs 32 kilobytes for the default + window size, plus a few kilobytes for small objects. */ + heap = mem_heap_create(40000); + page_zip_set_alloc(&d_stream, heap); ut_ad(ut_is_2pow(zip_size)); ut_ad(zip_size >= PAGE_ZIP_MIN_SIZE); ut_ad(zip_size <= UNIV_PAGE_SIZE); ut_ad(space_id); + err = inflateInit(&d_stream); + ut_a(err == Z_OK); + for (;;) { buf_page_t* bpage; - int err; ulint next_page_no; /* There is no latch on bpage directly. Instead, @@ -4954,7 +5067,7 @@ btr_copy_zblob_prefix( " compressed BLOB" " page %lu space %lu\n", (ulong) page_no, (ulong) space_id); - return; + goto func_exit; } if (UNIV_UNLIKELY @@ -4980,13 +5093,13 @@ btr_copy_zblob_prefix( offset += 4; } - d_stream->next_in = bpage->zip.data + offset; - d_stream->avail_in = zip_size - offset; + d_stream.next_in = bpage->zip.data + offset; + d_stream.avail_in = zip_size - offset; - err = inflate(d_stream, Z_NO_FLUSH); + err = inflate(&d_stream, Z_NO_FLUSH); switch (err) { case Z_OK: - if (!d_stream->avail_out) { + if (!d_stream.avail_out) { goto end_of_blob; } break; @@ -5003,13 +5116,13 @@ inflate_error: " compressed BLOB" " page %lu space %lu returned %d (%s)\n", (ulong) page_no, (ulong) space_id, - err, d_stream->msg); + err, d_stream.msg); case Z_BUF_ERROR: goto end_of_blob; } if (next_page_no == FIL_NULL) { - if (!d_stream->avail_in) { + if (!d_stream.avail_in) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: unexpected end of" @@ -5018,7 +5131,7 @@ inflate_error: (ulong) page_no, (ulong) space_id); } else { - err = inflate(d_stream, Z_FINISH); + err = inflate(&d_stream, Z_FINISH); switch (err) { case Z_STREAM_END: case Z_BUF_ERROR: @@ -5030,7 +5143,7 @@ inflate_error: end_of_blob: buf_page_release_zip(bpage); - return; + goto func_exit; } buf_page_release_zip(bpage); @@ -5042,6 +5155,12 @@ end_of_blob: offset = FIL_PAGE_NEXT; page_type = FIL_PAGE_TYPE_ZBLOB2; } + +func_exit: + inflateEnd(&d_stream); + mem_heap_free(heap); + UNIV_MEM_ASSERT_RW(buf, d_stream.total_out); + return(d_stream.total_out); } /*******************************************************************//** @@ -5067,28 +5186,8 @@ btr_copy_externally_stored_field_prefix_low( } if (UNIV_UNLIKELY(zip_size)) { - int err; - z_stream d_stream; - mem_heap_t* heap; - - /* Zlib inflate needs 32 kilobytes for the default - window size, plus a few kilobytes for small objects. */ - heap = mem_heap_create(40000); - page_zip_set_alloc(&d_stream, heap); - - err = inflateInit(&d_stream); - ut_a(err == Z_OK); - - d_stream.next_out = buf; - d_stream.avail_out = len; - d_stream.avail_in = 0; - - btr_copy_zblob_prefix(&d_stream, zip_size, - space_id, page_no, offset); - inflateEnd(&d_stream); - mem_heap_free(heap); - UNIV_MEM_ASSERT_RW(buf, d_stream.total_out); - return(d_stream.total_out); + return(btr_copy_zblob_prefix(buf, len, zip_size, + space_id, page_no, offset)); } else { return(btr_copy_blob_prefix(buf, len, space_id, page_no, offset)); diff --git a/storage/xtradb/btr/btr0pcur.c b/storage/xtradb/btr/btr0pcur.c index 537c26f6bf2..f95a5487c94 100644 --- a/storage/xtradb/btr/btr0pcur.c +++ b/storage/xtradb/btr/btr0pcur.c @@ -467,7 +467,6 @@ btr_pcur_move_backward_from_page( mtr_t* mtr) /*!< in: mtr */ { ulint prev_page_no; - ulint space; page_t* page; buf_block_t* prev_block; ulint latch_mode; @@ -503,7 +502,6 @@ btr_pcur_move_backward_from_page( page = btr_pcur_get_page(cursor); prev_page_no = btr_page_get_prev(page, mtr); - space = buf_block_get_space(btr_pcur_get_block(cursor)); if (prev_page_no == FIL_NULL) { } else if (btr_pcur_is_before_first_on_page(cursor)) { diff --git a/storage/xtradb/btr/btr0sea.c b/storage/xtradb/btr/btr0sea.c index 6628333d32a..0630b634b53 100644 --- a/storage/xtradb/btr/btr0sea.c +++ b/storage/xtradb/btr/btr0sea.c @@ -48,9 +48,16 @@ Protected by btr_search_latch and btr_search_enabled_mutex. */ UNIV_INTERN char btr_search_enabled = TRUE; UNIV_INTERN ibool btr_search_fully_disabled = FALSE; +UNIV_INTERN ulint btr_search_index_num = 1; + /** Mutex protecting btr_search_enabled */ static mutex_t btr_search_enabled_mutex; +#ifdef UNIV_PFS_MUTEX +/* Key to register btr_search_enabled_mutex with performance schema */ +UNIV_INTERN mysql_pfs_key_t btr_search_enabled_mutex_key; +#endif /* UNIV_PFS_MUTEX */ + /** A dummy variable to fool the compiler */ UNIV_INTERN ulint btr_search_this_is_zero = 0; @@ -74,7 +81,9 @@ indexes. */ /* We will allocate the latch from dynamic memory to get it to the same DRAM page as other hotspot semaphores */ -UNIV_INTERN rw_lock_t* btr_search_latch_temp; +//UNIV_INTERN rw_lock_t* btr_search_latch_temp; + +UNIV_INTERN rw_lock_t** btr_search_latch_part; /** padding to prevent other memory update hotspots from residing on the same memory cache line */ @@ -83,6 +92,11 @@ UNIV_INTERN byte btr_sea_pad2[64]; /** The adaptive hash index */ UNIV_INTERN btr_search_sys_t* btr_search_sys; +#ifdef UNIV_PFS_RWLOCK +/* Key to register btr_search_sys with performance schema */ +UNIV_INTERN mysql_pfs_key_t btr_search_latch_key; +#endif /* UNIV_PFS_RWLOCK */ + /** If the number of records on the page divided by this parameter would have been successfully accessed using a hash index, the index is then built on the page, assuming the global limit has been reached */ @@ -121,18 +135,19 @@ allocate a new node to the hash table, it will succeed. However, the check will not guarantee success. */ static void -btr_search_check_free_space_in_heap(void) +btr_search_check_free_space_in_heap( /*=====================================*/ + index_id_t key) { hash_table_t* table; mem_heap_t* heap; #ifdef UNIV_SYNC_DEBUG - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + ut_ad(!rw_lock_own(btr_search_get_latch(key), RW_LOCK_SHARED)); + ut_ad(!rw_lock_own(btr_search_get_latch(key), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ - table = btr_search_sys->hash_index; + table = btr_search_get_hash_index(key); heap = table->heap; @@ -141,9 +156,9 @@ btr_search_check_free_space_in_heap(void) be enough free space in the hash table. */ if (heap->free_block == NULL) { - buf_block_t* block = buf_block_alloc(0); + buf_block_t* block = buf_block_alloc(NULL); - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(key)); if (heap->free_block == NULL) { heap->free_block = block; @@ -151,7 +166,7 @@ btr_search_check_free_space_in_heap(void) buf_block_free(block); } - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(key)); } } @@ -163,17 +178,30 @@ btr_search_sys_create( /*==================*/ ulint hash_size) /*!< in: hash index hash table size */ { + ulint i; /* We allocate the search latch from dynamic memory: see above at the global variable definition */ - btr_search_latch_temp = mem_alloc(sizeof(rw_lock_t)); + //btr_search_latch_temp = mem_alloc(sizeof(rw_lock_t)); - rw_lock_create(&btr_search_latch, SYNC_SEARCH_SYS); - mutex_create(&btr_search_enabled_mutex, SYNC_SEARCH_SYS_CONF); + //rw_lock_create(btr_search_latch_key, &btr_search_latch, + // SYNC_SEARCH_SYS); + mutex_create(btr_search_enabled_mutex_key, + &btr_search_enabled_mutex, SYNC_SEARCH_SYS_CONF); btr_search_sys = mem_alloc(sizeof(btr_search_sys_t)); - btr_search_sys->hash_index = ha_create(hash_size, 0, 0); + /* btr_search_index_num should be <= 32. (bits of trx->has_search_latch) */ + btr_search_latch_part = mem_alloc(sizeof(rw_lock_t*) * btr_search_index_num); + btr_search_sys->hash_index = mem_alloc(sizeof(hash_table_t*) * btr_search_index_num); + for (i = 0; i < btr_search_index_num; i++) { + btr_search_latch_part[i] = mem_alloc(sizeof(rw_lock_t)); + + rw_lock_create(btr_search_latch_key, + btr_search_latch_part[i], SYNC_SEARCH_SYS); + + btr_search_sys->hash_index[i] = ha_create(hash_size, 0, 0); + } } /*****************************************************************//** @@ -183,11 +211,22 @@ void btr_search_sys_free(void) /*=====================*/ { - rw_lock_free(&btr_search_latch); - mem_free(btr_search_latch_temp); - btr_search_latch_temp = NULL; - mem_heap_free(btr_search_sys->hash_index->heap); - hash_table_free(btr_search_sys->hash_index); + ulint i; + + for (i = 0; i < btr_search_index_num; i++) { + mem_heap_free(btr_search_sys->hash_index[i]->heap); + hash_table_free(btr_search_sys->hash_index[i]); + + rw_lock_free(btr_search_latch_part[i]); + + mem_free(btr_search_latch_part[i]); + } + mem_free(btr_search_sys->hash_index); + mem_free(btr_search_latch_part); + + //rw_lock_free(&btr_search_latch); + //mem_free(btr_search_latch_temp); + //btr_search_latch_temp = NULL; mem_free(btr_search_sys); btr_search_sys = NULL; } @@ -200,7 +239,7 @@ btr_search_disable(void) /*====================*/ { mutex_enter(&btr_search_enabled_mutex); - rw_lock_x_lock(&btr_search_latch); + btr_search_x_lock_all(); /* Disable access to hash index, also tell ha_insert_for_fold() stop adding new nodes to hash index, but still allow updating @@ -218,7 +257,7 @@ btr_search_disable(void) /* btr_search_enabled_mutex should guarantee this. */ ut_ad(!btr_search_enabled); - rw_lock_x_unlock(&btr_search_latch); + btr_search_x_unlock_all(); mutex_exit(&btr_search_enabled_mutex); } @@ -230,12 +269,12 @@ btr_search_enable(void) /*====================*/ { mutex_enter(&btr_search_enabled_mutex); - rw_lock_x_lock(&btr_search_latch); + btr_search_x_lock_all(); btr_search_enabled = TRUE; btr_search_fully_disabled = FALSE; - rw_lock_x_unlock(&btr_search_latch); + btr_search_x_unlock_all(); mutex_exit(&btr_search_enabled_mutex); } @@ -288,20 +327,21 @@ UNIV_INTERN ulint btr_search_info_get_ref_count( /*==========================*/ - btr_search_t* info) /*!< in: search info. */ + btr_search_t* info, /*!< in: search info. */ + index_id_t key) { ulint ret; ut_ad(info); #ifdef UNIV_SYNC_DEBUG - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + ut_ad(!rw_lock_own(btr_search_get_latch(key), RW_LOCK_SHARED)); + ut_ad(!rw_lock_own(btr_search_get_latch(key), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ - rw_lock_s_lock(&btr_search_latch); + rw_lock_s_lock(btr_search_get_latch(key)); ret = info->ref_count; - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(key)); return(ret); } @@ -322,8 +362,8 @@ btr_search_info_update_hash( int cmp; #ifdef UNIV_SYNC_DEBUG - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + ut_ad(!rw_lock_own(btr_search_get_latch(cursor->index->id), RW_LOCK_SHARED)); + ut_ad(!rw_lock_own(btr_search_get_latch(cursor->index->id), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ index = cursor->index; @@ -441,8 +481,8 @@ btr_search_update_block_hash_info( /*!< in: cursor */ { #ifdef UNIV_SYNC_DEBUG - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + ut_ad(!rw_lock_own(btr_search_get_latch(cursor->index->id), RW_LOCK_SHARED)); + ut_ad(!rw_lock_own(btr_search_get_latch(cursor->index->id), RW_LOCK_EX)); ut_ad(rw_lock_own(&block->lock, RW_LOCK_SHARED) || rw_lock_own(&block->lock, RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ @@ -520,13 +560,13 @@ btr_search_update_hash_ref( buf_block_t* block, /*!< in: buffer block where cursor positioned */ btr_cur_t* cursor) /*!< in: cursor */ { - ulint fold; - rec_t* rec; - dulint index_id; + ulint fold; + rec_t* rec; + index_id_t index_id; ut_ad(cursor->flag == BTR_CUR_HASH_FAIL); #ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + ut_ad(rw_lock_own(btr_search_get_latch(cursor->index->id), RW_LOCK_EX)); ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) || rw_lock_own(&(block->lock), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ @@ -566,10 +606,10 @@ btr_search_update_hash_ref( mem_heap_free(heap); } #ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + ut_ad(rw_lock_own(btr_search_get_latch(cursor->index->id), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ - ha_insert_for_fold(btr_search_sys->hash_index, fold, + ha_insert_for_fold(btr_search_get_hash_index(cursor->index->id), fold, block, rec); } } @@ -589,8 +629,8 @@ btr_search_info_update_slow( ulint* params2; #ifdef UNIV_SYNC_DEBUG - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + ut_ad(!rw_lock_own(btr_search_get_latch(cursor->index->id), RW_LOCK_SHARED)); + ut_ad(!rw_lock_own(btr_search_get_latch(cursor->index->id), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ block = btr_cur_get_block(cursor); @@ -611,7 +651,7 @@ btr_search_info_update_slow( if (build_index || (cursor->flag == BTR_CUR_HASH_FAIL)) { - btr_search_check_free_space_in_heap(); + btr_search_check_free_space_in_heap(cursor->index->id); } if (cursor->flag == BTR_CUR_HASH_FAIL) { @@ -621,11 +661,11 @@ btr_search_info_update_slow( btr_search_n_hash_fail++; #endif /* UNIV_SEARCH_PERF_STAT */ - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(cursor->index->id)); btr_search_update_hash_ref(info, block, cursor); - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); } if (build_index) { @@ -828,10 +868,11 @@ btr_search_guess_on_hash( RW_S_LATCH, RW_X_LATCH, or 0 */ mtr_t* mtr) /*!< in: mtr */ { + buf_pool_t* buf_pool; buf_block_t* block; rec_t* rec; ulint fold; - dulint index_id; + index_id_t index_id; #ifdef notdefined btr_cur_t cursor2; btr_pcur_t pcur; @@ -868,17 +909,17 @@ btr_search_guess_on_hash( cursor->flag = BTR_CUR_HASH; if (UNIV_LIKELY(!has_search_latch)) { - rw_lock_s_lock(&btr_search_latch); + rw_lock_s_lock(btr_search_get_latch(index_id)); if (UNIV_UNLIKELY(!btr_search_enabled)) { goto failure_unlock; } } - ut_ad(rw_lock_get_writer(&btr_search_latch) != RW_LOCK_EX); - ut_ad(rw_lock_get_reader_count(&btr_search_latch) > 0); + ut_ad(rw_lock_get_writer(btr_search_get_latch(index_id)) != RW_LOCK_EX); + ut_ad(rw_lock_get_reader_count(btr_search_get_latch(index_id)) > 0); - rec = ha_search_and_get_data(btr_search_sys->hash_index, fold); + rec = ha_search_and_get_data(btr_search_get_hash_index(index_id), fold); if (UNIV_UNLIKELY(!rec)) { goto failure_unlock; @@ -896,7 +937,7 @@ btr_search_guess_on_hash( goto failure_unlock; } - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(index_id)); buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH); } @@ -923,8 +964,7 @@ btr_search_guess_on_hash( is positioned on. We cannot look at the next of the previous record to determine if our guess for the cursor position is right. */ - if (UNIV_EXPECT - (ut_dulint_cmp(index_id, btr_page_get_index_id(block->frame)), 0) + if (UNIV_UNLIKELY(index_id != btr_page_get_index_id(block->frame)) || !btr_search_check_guess(cursor, has_search_latch, tuple, mode, mtr)) { @@ -986,7 +1026,7 @@ btr_search_guess_on_hash( /* Increment the page get statistics though we did not really fix the page: for user info only */ - + buf_pool = buf_pool_from_bpage(&block->page); buf_pool->stat.n_page_gets++; return(TRUE); @@ -994,7 +1034,7 @@ btr_search_guess_on_hash( /*-------------------------------------------*/ failure_unlock: if (UNIV_LIKELY(!has_search_latch)) { - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(index_id)); } failure: cursor->flag = BTR_CUR_HASH_FAIL; @@ -1017,10 +1057,11 @@ UNIV_INTERN void btr_search_drop_page_hash_index( /*============================*/ - buf_block_t* block) /*!< in: block containing index page, + buf_block_t* block, /*!< in: block containing index page, s- or x-latched, or an index page for which we know that block->buf_fix_count == 0 */ + dict_index_t* index_in) { hash_table_t* table; ulint n_fields; @@ -1029,7 +1070,7 @@ btr_search_drop_page_hash_index( const rec_t* rec; ulint fold; ulint prev_fold; - dulint index_id; + index_id_t index_id; ulint n_cached; ulint n_recs; ulint* folds; @@ -1039,22 +1080,60 @@ btr_search_drop_page_hash_index( ulint* offsets; #ifdef UNIV_SYNC_DEBUG - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + if (index_in) { + ut_ad(!rw_lock_own(btr_search_get_latch(index_in->id), RW_LOCK_SHARED)); + ut_ad(!rw_lock_own(btr_search_get_latch(index_in->id), RW_LOCK_EX)); + } #endif /* UNIV_SYNC_DEBUG */ retry: - rw_lock_s_lock(&btr_search_latch); + if (index_in) { + index = index_in; + rw_lock_s_lock(btr_search_get_latch(index->id)); + } else if (btr_search_index_num > 1) { + rw_lock_t* btr_search_latch; + + /* FIXME: This may be optimistic implementation still. */ + btr_search_latch = (rw_lock_t*)(block->btr_search_latch); + if (UNIV_LIKELY(!btr_search_latch)) { + if (block->is_hashed) { + goto retry; + } + return; + } + rw_lock_s_lock(btr_search_latch); + if (UNIV_LIKELY(btr_search_latch != block->btr_search_latch)) { + rw_lock_s_unlock(btr_search_latch); + goto retry; + } + if (UNIV_LIKELY(!block->is_hashed)) { + rw_lock_s_unlock(btr_search_latch); + goto retry; + } + index = block->index; + ut_a(btr_search_latch == btr_search_get_latch(index->id)); + } else { + /* btr_search_index_num == 1 */ + /* btr_search_latch is only one and able to obtain + before evaluating block->is_hashed. */ + rw_lock_s_lock(btr_search_latch_part[0]); + if (UNIV_LIKELY(!block->is_hashed)) { + rw_lock_s_unlock(btr_search_latch_part[0]); + return; + } + index = block->index; + } + page = block->frame; if (UNIV_LIKELY(!block->is_hashed)) { - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(index->id)); return; } - table = btr_search_sys->hash_index; + table = btr_search_get_hash_index(index->id); #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) @@ -1064,14 +1143,14 @@ retry: n_fields = block->curr_n_fields; n_bytes = block->curr_n_bytes; - index = block->index; + ut_a(index == block->index); ut_a(!dict_index_is_ibuf(index)); /* NOTE: The fields of block must not be accessed after releasing btr_search_latch, as the index page might only be s-latched! */ - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(index->id)); ut_a(n_fields + n_bytes > 0); @@ -1089,7 +1168,7 @@ retry: index_id = btr_page_get_index_id(page); - ut_a(0 == ut_dulint_cmp(index_id, index->id)); + ut_a(index_id == index->id); prev_fold = 0; @@ -1121,7 +1200,7 @@ next_rec: mem_heap_free(heap); } - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(index->id)); if (UNIV_UNLIKELY(!block->is_hashed)) { /* Someone else has meanwhile dropped the hash index */ @@ -1137,7 +1216,7 @@ next_rec: /* Someone else has meanwhile built a new hash index on the page, with different parameters */ - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(index->id)); mem_free(folds); goto retry; @@ -1153,6 +1232,7 @@ next_rec: block->is_hashed = FALSE; block->index = NULL; + block->btr_search_latch = NULL; cleanup: #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG @@ -1165,14 +1245,14 @@ cleanup: "InnoDB: the hash index to a page of %s," " still %lu hash nodes remain.\n", index->name, (ulong) block->n_pointers); - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(index->id)); btr_search_validate(); } else { - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(index->id)); } #else /* UNIV_AHI_DEBUG || UNIV_DEBUG */ - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(index->id)); #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ mem_free(folds); @@ -1186,7 +1266,7 @@ btr_search_drop_page_hash_index_on_index( /*=====================================*/ dict_index_t* index) /* in: record descriptor */ { - buf_page_t* bpage; + hash_table_t* table; buf_block_t* block; ulint n_fields; @@ -1195,103 +1275,157 @@ btr_search_drop_page_hash_index_on_index( const rec_t* rec; ulint fold; ulint prev_fold; - dulint index_id; + index_id_t index_id; ulint n_cached; ulint n_recs; ulint* folds; - ulint i; + ulint i, j; mem_heap_t* heap = NULL; ulint* offsets; + ibool released_search_latch; - rw_lock_x_lock(&btr_search_latch); - mutex_enter(&LRU_list_mutex); + rw_lock_s_lock(btr_search_get_latch(index->id)); - table = btr_search_sys->hash_index; + table = btr_search_get_hash_index(index->id); - bpage = UT_LIST_GET_LAST(buf_pool->LRU); + for (j = 0; j < srv_buf_pool_instances; j++) { + buf_pool_t* buf_pool; - while (bpage != NULL) { - block = (buf_block_t*) bpage; - if (block->index == index && block->is_hashed) { - page = block->frame; + buf_pool = buf_pool_from_array(j); - /* from btr_search_drop_page_hash_index() */ - n_fields = block->curr_n_fields; - n_bytes = block->curr_n_bytes; + do { + buf_chunk_t* chunks = buf_pool->chunks; + buf_chunk_t* chunk = chunks + buf_pool->n_chunks; - ut_a(n_fields + n_bytes > 0); + released_search_latch = FALSE; - n_recs = page_get_n_recs(page); + while (--chunk >= chunks) { + block = chunk->blocks; + i = chunk->size; - /* Calculate and cache fold values into an array for fast deletion - from the hash index */ +retry: + for (; i--; block++) { + if (buf_block_get_state(block) + != BUF_BLOCK_FILE_PAGE + || block->index != index + || !block->is_hashed) { + continue; + } - folds = mem_alloc(n_recs * sizeof(ulint)); + page = block->frame; - n_cached = 0; + /* from btr_search_drop_page_hash_index() */ + n_fields = block->curr_n_fields; + n_bytes = block->curr_n_bytes; - rec = page_get_infimum_rec(page); - rec = page_rec_get_next_low(rec, page_is_comp(page)); - index_id = btr_page_get_index_id(page); + /* keeping latch order */ + rw_lock_s_unlock(btr_search_get_latch(index->id)); + released_search_latch = TRUE; + rw_lock_x_lock(&block->lock); + + + ut_a(n_fields + n_bytes > 0); + + n_recs = page_get_n_recs(page); + + /* Calculate and cache fold values into an array for fast deletion + from the hash index */ + + folds = mem_alloc(n_recs * sizeof(ulint)); + + n_cached = 0; + + rec = page_get_infimum_rec(page); + rec = page_rec_get_next_low(rec, page_is_comp(page)); + + index_id = btr_page_get_index_id(page); - ut_a(0 == ut_dulint_cmp(index_id, index->id)); + ut_a(index_id == index->id); - prev_fold = 0; + prev_fold = 0; - offsets = NULL; + offsets = NULL; - while (!page_rec_is_supremum(rec)) { - offsets = rec_get_offsets(rec, index, offsets, - n_fields + (n_bytes > 0), &heap); - ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0)); - fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id); + while (!page_rec_is_supremum(rec)) { + offsets = rec_get_offsets(rec, index, offsets, + n_fields + (n_bytes > 0), &heap); + ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0)); + fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id); - if (fold == prev_fold && prev_fold != 0) { + if (fold == prev_fold && prev_fold != 0) { - goto next_rec; - } + goto next_rec; + } - /* Remove all hash nodes pointing to this page from the - hash chain */ + /* Remove all hash nodes pointing to this page from the + hash chain */ - folds[n_cached] = fold; - n_cached++; + folds[n_cached] = fold; + n_cached++; next_rec: - rec = page_rec_get_next_low(rec, page_rec_is_comp(rec)); - prev_fold = fold; - } + rec = page_rec_get_next_low(rec, page_rec_is_comp(rec)); + prev_fold = fold; + } - for (i = 0; i < n_cached; i++) { + if (UNIV_LIKELY_NULL(heap)) { + mem_heap_empty(heap); + } - ha_remove_all_nodes_to_page(table, folds[i], page); - } + rw_lock_x_lock(btr_search_get_latch(index->id)); - ut_a(index->search_info->ref_count > 0); - index->search_info->ref_count--; + if (UNIV_UNLIKELY(!block->is_hashed)) { + goto cleanup; + } - block->is_hashed = FALSE; - block->index = NULL; - + ut_a(block->index == index); + + if (UNIV_UNLIKELY(block->curr_n_fields != n_fields) + || UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) { + rw_lock_x_unlock(btr_search_get_latch(index->id)); + rw_lock_x_unlock(&block->lock); + + mem_free(folds); + + rw_lock_s_lock(btr_search_get_latch(index->id)); + goto retry; + } + + for (i = 0; i < n_cached; i++) { + + ha_remove_all_nodes_to_page(table, folds[i], page); + } + + ut_a(index->search_info->ref_count > 0); + index->search_info->ref_count--; + + block->is_hashed = FALSE; + block->index = NULL; + block->btr_search_latch = NULL; + +cleanup: #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG - if (UNIV_UNLIKELY(block->n_pointers)) { - /* Corruption */ - ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Corruption of adaptive hash index. After dropping\n" -"InnoDB: the hash index to a page of %s, still %lu hash nodes remain.\n", - index->name, (ulong) block->n_pointers); - } + if (UNIV_UNLIKELY(block->n_pointers)) { + /* Corruption */ + ut_print_timestamp(stderr); + fprintf(stderr, +"InnoDB: The adaptive hash index is corrupted. After dropping\n" +"InnoDB: the hash index to a page of %s, %lu hash nodes still remain.\n", + index->name, (ulong) block->n_pointers); + } #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ + rw_lock_x_unlock(btr_search_get_latch(index->id)); + rw_lock_x_unlock(&block->lock); - mem_free(folds); - } + mem_free(folds); - bpage = UT_LIST_GET_PREV(LRU, bpage); + rw_lock_s_lock(btr_search_get_latch(index->id)); + } + } + } while (released_search_latch); } - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(index->id)); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -1326,8 +1460,8 @@ btr_search_drop_page_hash_when_freed( having to fear a deadlock. */ block = buf_page_get_gen(space, zip_size, page_no, RW_S_LATCH, NULL, - BUF_GET_IF_IN_POOL, __FILE__, __LINE__, - &mtr); + BUF_PEEK_IF_IN_POOL, __FILE__, __LINE__, + &mtr); /* Because the buffer pool mutex was released by buf_page_peek_if_search_hashed(), it is possible that the block was removed from the buffer pool by another thread @@ -1338,7 +1472,7 @@ btr_search_drop_page_hash_when_freed( buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH); - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, NULL); } mtr_commit(&mtr); @@ -1366,7 +1500,7 @@ btr_search_build_page_hash_index( rec_t* next_rec; ulint fold; ulint next_fold; - dulint index_id; + index_id_t index_id; ulint n_cached; ulint n_recs; ulint* folds; @@ -1380,26 +1514,26 @@ btr_search_build_page_hash_index( ut_ad(index); ut_a(!dict_index_is_ibuf(index)); - table = btr_search_sys->hash_index; + table = btr_search_get_hash_index(index->id); page = buf_block_get_frame(block); #ifdef UNIV_SYNC_DEBUG - ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + ut_ad(!rw_lock_own(btr_search_get_latch(index->id), RW_LOCK_EX)); ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) || rw_lock_own(&(block->lock), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ - rw_lock_s_lock(&btr_search_latch); + rw_lock_s_lock(btr_search_get_latch(index->id)); if (block->is_hashed && ((block->curr_n_fields != n_fields) || (block->curr_n_bytes != n_bytes) || (block->curr_left_side != left_side))) { - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(index->id)); - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, index); } else { - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(index->id)); } n_recs = page_get_n_recs(page); @@ -1493,9 +1627,9 @@ btr_search_build_page_hash_index( fold = next_fold; } - btr_search_check_free_space_in_heap(); + btr_search_check_free_space_in_heap(index->id); - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(index->id)); if (UNIV_UNLIKELY(btr_search_fully_disabled)) { goto exit_func; @@ -1523,6 +1657,7 @@ btr_search_build_page_hash_index( block->curr_n_bytes = n_bytes; block->curr_left_side = left_side; block->index = index; + block->btr_search_latch = btr_search_get_latch(index->id); for (i = 0; i < n_cached; i++) { @@ -1530,7 +1665,7 @@ btr_search_build_page_hash_index( } exit_func: - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(index->id)); mem_free(folds); mem_free(recs); @@ -1569,13 +1704,13 @@ btr_search_move_or_delete_hash_entries( ut_a(!(new_block->is_hashed || block->is_hashed) || !dict_index_is_ibuf(index)); - rw_lock_s_lock(&btr_search_latch); + rw_lock_s_lock(btr_search_get_latch(index->id)); if (new_block->is_hashed) { - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(index->id)); - btr_search_drop_page_hash_index(block); + btr_search_drop_page_hash_index(block, index); return; } @@ -1590,7 +1725,7 @@ btr_search_move_or_delete_hash_entries( new_block->n_bytes = block->curr_n_bytes; new_block->left_side = left_side; - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(index->id)); ut_a(n_fields + n_bytes > 0); @@ -1602,7 +1737,7 @@ btr_search_move_or_delete_hash_entries( return; } - rw_lock_s_unlock(&btr_search_latch); + rw_lock_s_unlock(btr_search_get_latch(index->id)); } /********************************************************************//** @@ -1619,8 +1754,7 @@ btr_search_update_hash_on_delete( buf_block_t* block; rec_t* rec; ulint fold; - dulint index_id; - ibool found; + index_id_t index_id; ulint offsets_[REC_OFFS_NORMAL_SIZE]; mem_heap_t* heap = NULL; rec_offs_init(offsets_); @@ -1642,7 +1776,7 @@ btr_search_update_hash_on_delete( ut_a(block->curr_n_fields + block->curr_n_bytes > 0); ut_a(!dict_index_is_ibuf(cursor->index)); - table = btr_search_sys->hash_index; + table = btr_search_get_hash_index(cursor->index->id); index_id = cursor->index->id; fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_, @@ -1651,11 +1785,11 @@ btr_search_update_hash_on_delete( if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(cursor->index->id)); - found = ha_search_and_delete_if_found(table, fold, rec); + ha_search_and_delete_if_found(table, fold, rec); - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); } /********************************************************************//** @@ -1689,21 +1823,21 @@ btr_search_update_hash_node_on_insert( ut_a(block->index == cursor->index); ut_a(!dict_index_is_ibuf(cursor->index)); - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(cursor->index->id)); if ((cursor->flag == BTR_CUR_HASH) && (cursor->n_fields == block->curr_n_fields) && (cursor->n_bytes == block->curr_n_bytes) && !block->curr_left_side) { - table = btr_search_sys->hash_index; + table = btr_search_get_hash_index(cursor->index->id); ha_search_and_update_if_found(table, cursor->fold, rec, block, page_rec_get_next(rec)); - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); } else { - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(cursor->index->id)); btr_search_update_hash_on_insert(cursor); } @@ -1725,7 +1859,7 @@ btr_search_update_hash_on_insert( rec_t* rec; rec_t* ins_rec; rec_t* next_rec; - dulint index_id; + index_id_t index_id; ulint fold; ulint ins_fold; ulint next_fold = 0; /* remove warning (??? bug ???) */ @@ -1738,9 +1872,9 @@ btr_search_update_hash_on_insert( ulint* offsets = offsets_; rec_offs_init(offsets_); - table = btr_search_sys->hash_index; + table = btr_search_get_hash_index(cursor->index->id); - btr_search_check_free_space_in_heap(); + btr_search_check_free_space_in_heap(cursor->index->id); rec = btr_cur_get_rec(cursor); @@ -1785,7 +1919,7 @@ btr_search_update_hash_on_insert( } else { if (left_side) { - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(index_id)); locked = TRUE; @@ -1799,7 +1933,7 @@ btr_search_update_hash_on_insert( if (!locked) { - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(index_id)); locked = TRUE; } @@ -1817,7 +1951,7 @@ check_next_rec: if (!left_side) { if (!locked) { - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(index_id)); locked = TRUE; } @@ -1832,7 +1966,7 @@ check_next_rec: if (!locked) { - rw_lock_x_lock(&btr_search_latch); + rw_lock_x_lock(btr_search_get_latch(index_id)); locked = TRUE; } @@ -1855,7 +1989,7 @@ function_exit: mem_heap_free(heap); } if (locked) { - rw_lock_x_unlock(&btr_search_latch); + rw_lock_x_unlock(btr_search_get_latch(index_id)); } } @@ -1871,7 +2005,7 @@ btr_search_validate(void) ha_node_t* node; ulint n_page_dumps = 0; ibool ok = TRUE; - ulint i; + ulint i,j; ulint cell_count; mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; @@ -1883,31 +2017,34 @@ btr_search_validate(void) rec_offs_init(offsets_); - rw_lock_x_lock(&btr_search_latch); - //buf_pool_mutex_enter(); - rw_lock_x_lock(&page_hash_latch); + btr_search_x_lock_all(); + buf_pool_page_hash_x_lock_all(); - cell_count = hash_get_n_cells(btr_search_sys->hash_index); + for (j = 0; j < btr_search_index_num; j++) { + + cell_count = hash_get_n_cells(btr_search_sys->hash_index[j]); for (i = 0; i < cell_count; i++) { /* We release btr_search_latch every once in a while to give other queries a chance to run. */ if ((i != 0) && ((i % chunk_size) == 0)) { - //buf_pool_mutex_exit(); - rw_lock_x_unlock(&page_hash_latch); - rw_lock_x_unlock(&btr_search_latch); + buf_pool_page_hash_x_unlock_all(); + btr_search_x_unlock_all(); os_thread_yield(); - rw_lock_x_lock(&btr_search_latch); - //buf_pool_mutex_enter(); - rw_lock_x_lock(&page_hash_latch); + btr_search_x_lock_all(); + buf_pool_page_hash_x_lock_all(); } - node = hash_get_nth_cell(btr_search_sys->hash_index, i)->node; + node = hash_get_nth_cell(btr_search_sys->hash_index[j], i)->node; for (; node != NULL; node = node->next) { const buf_block_t* block = buf_block_align(node->data); const buf_block_t* hash_block; + buf_pool_t* buf_pool; + index_id_t page_index_id; + + buf_pool = buf_pool_from_bpage((buf_page_t*) block); if (UNIV_LIKELY(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE)) { @@ -1918,6 +2055,7 @@ btr_search_validate(void) (BUF_BLOCK_REMOVE_HASH, see the assertion and the comment below) */ hash_block = buf_block_hash_get( + buf_pool, buf_block_get_space(block), buf_block_get_page_no(block)); } else { @@ -1949,12 +2087,15 @@ btr_search_validate(void) + (block->curr_n_bytes > 0), &heap); - if (!block->is_hashed || node->fold - != rec_fold((rec_t*)(node->data), - offsets, - block->curr_n_fields, - block->curr_n_bytes, - btr_page_get_index_id(block->frame))) { + page_index_id = btr_page_get_index_id(block->frame); + + if (UNIV_UNLIKELY + (!block->is_hashed || node->fold + != rec_fold((rec_t*)(node->data), + offsets, + block->curr_n_fields, + block->curr_n_bytes, + page_index_id))) { const page_t* page = block->frame; ok = FALSE; @@ -1964,21 +2105,17 @@ btr_search_validate(void) " InnoDB: Error in an adaptive hash" " index pointer to page %lu\n" "InnoDB: ptr mem address %p" - " index id %lu %lu," + " index id %llu," " node fold %lu, rec fold %lu\n", (ulong) page_get_page_no(page), node->data, - (ulong) ut_dulint_get_high( - btr_page_get_index_id(page)), - (ulong) ut_dulint_get_low( - btr_page_get_index_id(page)), + (ullint) page_index_id, (ulong) node->fold, (ulong) rec_fold((rec_t*)(node->data), offsets, block->curr_n_fields, block->curr_n_bytes, - btr_page_get_index_id( - page))); + page_index_id)); fputs("InnoDB: Record ", stderr); rec_print_new(stderr, (rec_t*)node->data, @@ -2006,23 +2143,22 @@ btr_search_validate(void) /* We release btr_search_latch every once in a while to give other queries a chance to run. */ if (i != 0) { - //buf_pool_mutex_exit(); - rw_lock_x_unlock(&page_hash_latch); - rw_lock_x_unlock(&btr_search_latch); + buf_pool_page_hash_x_unlock_all(); + btr_search_x_unlock_all(); os_thread_yield(); - rw_lock_x_lock(&btr_search_latch); - //buf_pool_mutex_enter(); - rw_lock_x_lock(&page_hash_latch); + btr_search_x_lock_all(); + buf_pool_page_hash_x_lock_all(); } - if (!ha_validate(btr_search_sys->hash_index, i, end_index)) { + if (!ha_validate(btr_search_sys->hash_index[j], i, end_index)) { ok = FALSE; } } - //buf_pool_mutex_exit(); - rw_lock_x_unlock(&page_hash_latch); - rw_lock_x_unlock(&btr_search_latch); + } /*for (j = 0; j < btr_search_index_num; j++)*/ + + buf_pool_page_hash_x_unlock_all(); + btr_search_x_unlock_all(); if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); } diff --git a/storage/xtradb/buf/buf0buddy.c b/storage/xtradb/buf/buf0buddy.c index e6b80bcda55..07898950fab 100644 --- a/storage/xtradb/buf/buf0buddy.c +++ b/storage/xtradb/buf/buf0buddy.c @@ -34,17 +34,6 @@ Created December 2006 by Marko Makela #include "buf0flu.h" #include "page0zip.h" -/* Statistic counters */ - -#ifdef UNIV_DEBUG -/** Number of frames allocated from the buffer pool to the buddy system. -Protected by buf_pool_mutex. */ -static ulint buf_buddy_n_frames; -#endif /* UNIV_DEBUG */ -/** Statistics of the buddy system, indexed by block size. -Protected by buf_pool_mutex. */ -UNIV_INTERN buf_buddy_stat_t buf_buddy_stat[BUF_BUDDY_SIZES_MAX + 1]; - /**********************************************************************//** Get the offset of the buddy of a compressed page frame. @return the buddy relative of page */ @@ -73,8 +62,10 @@ UNIV_INLINE void buf_buddy_add_to_free( /*==================*/ - buf_page_t* bpage, /*!< in,own: block to be freed */ - ulint i) /*!< in: index of buf_pool->zip_free[] */ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + buf_page_t* bpage, /*!< in,own: block to be freed */ + ulint i) /*!< in: index of + buf_pool->zip_free[] */ { #ifdef UNIV_DEBUG_VALGRIND buf_page_t* b = UT_LIST_GET_FIRST(buf_pool->zip_free[i]); @@ -82,8 +73,8 @@ buf_buddy_add_to_free( if (b) UNIV_MEM_VALID(b, BUF_BUDDY_LOW << i); #endif /* UNIV_DEBUG_VALGRIND */ - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&zip_free_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->zip_free_mutex)); ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE); ut_ad(buf_pool->zip_free[i].start != bpage); UT_LIST_ADD_FIRST(zip_list, buf_pool->zip_free[i], bpage); @@ -100,8 +91,10 @@ UNIV_INLINE void buf_buddy_remove_from_free( /*=======================*/ - buf_page_t* bpage, /*!< in: block to be removed */ - ulint i) /*!< in: index of buf_pool->zip_free[] */ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + buf_page_t* bpage, /*!< in: block to be removed */ + ulint i) /*!< in: index of + buf_pool->zip_free[] */ { #ifdef UNIV_DEBUG_VALGRIND buf_page_t* prev = UT_LIST_GET_PREV(zip_list, bpage); @@ -114,8 +107,8 @@ buf_buddy_remove_from_free( ut_ad(!next || buf_page_get_state(next) == BUF_BLOCK_ZIP_FREE); #endif /* UNIV_DEBUG_VALGRIND */ - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&zip_free_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->zip_free_mutex)); ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE); UT_LIST_REMOVE(zip_list, buf_pool->zip_free[i], bpage); @@ -132,12 +125,13 @@ static void* buf_buddy_alloc_zip( /*================*/ - ulint i) /*!< in: index of buf_pool->zip_free[] */ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + ulint i) /*!< in: index of buf_pool->zip_free[] */ { buf_page_t* bpage; - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&zip_free_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->zip_free_mutex)); ut_a(i < BUF_BUDDY_SIZES); #ifndef UNIV_DEBUG_VALGRIND @@ -152,19 +146,19 @@ buf_buddy_alloc_zip( UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i); ut_a(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_FREE); - buf_buddy_remove_from_free(bpage, i); + buf_buddy_remove_from_free(buf_pool, bpage, i); } else if (i + 1 < BUF_BUDDY_SIZES) { /* Attempt to split. */ - bpage = buf_buddy_alloc_zip(i + 1); + bpage = buf_buddy_alloc_zip(buf_pool, i + 1); if (bpage) { buf_page_t* buddy = (buf_page_t*) (((char*) bpage) + (BUF_BUDDY_LOW << i)); - ut_ad(!buf_pool_contains_zip(buddy)); + ut_ad(!buf_pool_contains_zip(buf_pool, buddy)); ut_d(memset(buddy, i, BUF_BUDDY_LOW << i)); buddy->state = BUF_BLOCK_ZIP_FREE; - buf_buddy_add_to_free(buddy, i); + buf_buddy_add_to_free(buf_pool, buddy, i); } } @@ -185,18 +179,19 @@ static void buf_buddy_block_free( /*=================*/ - void* buf, /*!< in: buffer frame to deallocate */ - ibool have_page_hash_mutex) + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + void* buf, /*!< in: buffer frame to deallocate */ + ibool have_page_hash_mutex) { const ulint fold = BUF_POOL_ZIP_FOLD_PTR(buf); buf_page_t* bpage; buf_block_t* block; - //ut_ad(buf_pool_mutex_own()); - ut_ad(!mutex_own(&buf_pool_zip_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(!mutex_own(&buf_pool->zip_mutex)); ut_a(!ut_align_offset(buf, UNIV_PAGE_SIZE)); - mutex_enter(&zip_hash_mutex); + mutex_enter(&buf_pool->zip_hash_mutex); HASH_SEARCH(hash, buf_pool->zip_hash, fold, buf_page_t*, bpage, ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_MEMORY @@ -209,7 +204,7 @@ buf_buddy_block_free( ut_d(bpage->in_zip_hash = FALSE); HASH_DELETE(buf_page_t, hash, buf_pool->zip_hash, fold, bpage); - mutex_exit(&zip_hash_mutex); + mutex_exit(&buf_pool->zip_hash_mutex); ut_d(memset(buf, 0, UNIV_PAGE_SIZE)); UNIV_MEM_INVALID(buf, UNIV_PAGE_SIZE); @@ -219,8 +214,8 @@ buf_buddy_block_free( buf_LRU_block_free_non_file_page(block, have_page_hash_mutex); mutex_exit(&block->mutex); - ut_ad(buf_buddy_n_frames > 0); - ut_d(buf_buddy_n_frames--); + ut_ad(buf_pool->buddy_n_frames > 0); + ut_d(buf_pool->buddy_n_frames--); } /**********************************************************************//** @@ -231,9 +226,10 @@ buf_buddy_block_register( /*=====================*/ buf_block_t* block) /*!< in: buffer frame to allocate */ { + buf_pool_t* buf_pool = buf_pool_from_block(block); const ulint fold = BUF_POOL_ZIP_FOLD(block); - //ut_ad(buf_pool_mutex_own()); - ut_ad(!mutex_own(&buf_pool_zip_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(!mutex_own(&buf_pool->zip_mutex)); ut_ad(buf_block_get_state(block) == BUF_BLOCK_READY_FOR_USE); buf_block_set_state(block, BUF_BLOCK_MEMORY); @@ -245,11 +241,11 @@ buf_buddy_block_register( ut_ad(!block->page.in_zip_hash); ut_d(block->page.in_zip_hash = TRUE); - mutex_enter(&zip_hash_mutex); + mutex_enter(&buf_pool->zip_hash_mutex); HASH_INSERT(buf_page_t, hash, buf_pool->zip_hash, fold, &block->page); - mutex_exit(&zip_hash_mutex); + mutex_exit(&buf_pool->zip_hash_mutex); - ut_d(buf_buddy_n_frames++); + ut_d(buf_pool->buddy_n_frames++); } /**********************************************************************//** @@ -259,10 +255,12 @@ static void* buf_buddy_alloc_from( /*=================*/ - void* buf, /*!< in: a block that is free to use */ - ulint i, /*!< in: index of buf_pool->zip_free[] */ - ulint j) /*!< in: size of buf as an index - of buf_pool->zip_free[] */ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + void* buf, /*!< in: a block that is free to use */ + ulint i, /*!< in: index of + buf_pool->zip_free[] */ + ulint j) /*!< in: size of buf as an index + of buf_pool->zip_free[] */ { ulint offs = BUF_BUDDY_LOW << j; ut_ad(j <= BUF_BUDDY_SIZES); @@ -286,7 +284,7 @@ buf_buddy_alloc_from( ut_list_node_313) == BUF_BLOCK_ZIP_FREE))); #endif /* !UNIV_DEBUG_VALGRIND */ - buf_buddy_add_to_free(bpage, j); + buf_buddy_add_to_free(buf_pool, bpage, j); } return(buf); @@ -294,41 +292,43 @@ buf_buddy_alloc_from( /**********************************************************************//** Allocate a block. The thread calling this function must hold -buf_pool_mutex and must not hold buf_pool_zip_mutex or any block->mutex. -The buf_pool_mutex may only be released and reacquired if lru != NULL. +buf_pool->mutex and must not hold buf_pool->zip_mutex or any block->mutex. +The buf_pool->mutex may only be released and reacquired if lru != NULL. @return allocated block, possibly NULL if lru==NULL */ UNIV_INTERN void* buf_buddy_alloc_low( /*================*/ - ulint i, /*!< in: index of buf_pool->zip_free[], - or BUF_BUDDY_SIZES */ - ibool* lru, /*!< in: pointer to a variable that will be assigned - TRUE if storage was allocated from the LRU list - and buf_pool_mutex was temporarily released, - or NULL if the LRU list should not be used */ - ibool have_page_hash_mutex) + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + ulint i, /*!< in: index of buf_pool->zip_free[], + or BUF_BUDDY_SIZES */ + ibool* lru, /*!< in: pointer to a variable that + will be assigned TRUE if storage was + allocated from the LRU list and + buf_pool->mutex was temporarily + released, or NULL if the LRU list + should not be used */ + ibool have_page_hash_mutex) { buf_block_t* block; - //ut_ad(buf_pool_mutex_own()); - ut_ad(!mutex_own(&buf_pool_zip_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); + ut_ad(!mutex_own(&buf_pool->zip_mutex)); if (i < BUF_BUDDY_SIZES) { /* Try to allocate from the buddy system. */ - mutex_enter(&zip_free_mutex); - block = buf_buddy_alloc_zip(i); + mutex_enter(&buf_pool->zip_free_mutex); + block = buf_buddy_alloc_zip(buf_pool, i); if (block) { - goto func_exit; } - - mutex_exit(&zip_free_mutex); + mutex_exit(&buf_pool->zip_free_mutex); } /* Try allocating from the buf_pool->free list. */ - block = buf_LRU_get_free_only(); + block = buf_LRU_get_free_only(buf_pool); if (block) { @@ -341,28 +341,29 @@ buf_buddy_alloc_low( } /* Try replacing an uncompressed page in the buffer pool. */ - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); if (have_page_hash_mutex) { - rw_lock_x_unlock(&page_hash_latch); + rw_lock_x_unlock(&buf_pool->page_hash_latch); } - block = buf_LRU_get_free_block(0); + block = buf_LRU_get_free_block(buf_pool); *lru = TRUE; - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); if (have_page_hash_mutex) { - rw_lock_x_lock(&page_hash_latch); + rw_lock_x_lock(&buf_pool->page_hash_latch); } alloc_big: buf_buddy_block_register(block); - mutex_enter(&zip_free_mutex); - block = buf_buddy_alloc_from(block->frame, i, BUF_BUDDY_SIZES); + mutex_enter(&buf_pool->zip_free_mutex); + block = buf_buddy_alloc_from( + buf_pool, block->frame, i, BUF_BUDDY_SIZES); func_exit: - buf_buddy_stat[i].used++; - mutex_exit(&zip_free_mutex); + buf_pool->buddy_stat[i].used++; + mutex_exit(&buf_pool->zip_free_mutex); return(block); } @@ -378,10 +379,11 @@ buf_buddy_relocate_block( buf_page_t* dpage) /*!< in: free block to relocate to */ { buf_page_t* b; + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); - //ut_ad(buf_pool_mutex_own()); + //ut_ad(buf_pool_mutex_own(buf_pool)); #ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX)); + ut_ad(rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_EX)); #endif switch (buf_page_get_state(bpage)) { @@ -400,18 +402,19 @@ buf_buddy_relocate_block( break; } - mutex_enter(&buf_pool_zip_mutex); - mutex_enter(&zip_free_mutex); + mutex_enter(&buf_pool->zip_mutex); + mutex_enter(&buf_pool->zip_free_mutex); if (!buf_page_can_relocate(bpage)) { - mutex_exit(&buf_pool_zip_mutex); - mutex_exit(&zip_free_mutex); + mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool->zip_free_mutex); return(FALSE); } - if (bpage != buf_page_hash_get(bpage->space, bpage->offset)) { - mutex_exit(&buf_pool_zip_mutex); - mutex_exit(&zip_free_mutex); + if (bpage != buf_page_hash_get(buf_pool, + bpage->space, bpage->offset)) { + mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool->zip_free_mutex); return(FALSE); } @@ -419,7 +422,6 @@ buf_buddy_relocate_block( ut_d(bpage->state = BUF_BLOCK_ZIP_FREE); /* relocate buf_pool->zip_clean */ - mutex_enter(&flush_list_mutex); b = UT_LIST_GET_PREV(zip_list, dpage); UT_LIST_REMOVE(zip_list, buf_pool->zip_clean, dpage); @@ -428,12 +430,11 @@ buf_buddy_relocate_block( } else { UT_LIST_ADD_FIRST(zip_list, buf_pool->zip_clean, dpage); } - mutex_exit(&flush_list_mutex); UNIV_MEM_INVALID(bpage, sizeof *bpage); - mutex_exit(&buf_pool_zip_mutex); - mutex_exit(&zip_free_mutex); + mutex_exit(&buf_pool->zip_mutex); + mutex_exit(&buf_pool->zip_free_mutex); return(TRUE); } @@ -444,20 +445,20 @@ static ibool buf_buddy_relocate( /*===============*/ - void* src, /*!< in: block to relocate */ - void* dst, /*!< in: free block to relocate to */ - ulint i, /*!< in: index of buf_pool->zip_free[] */ - ibool have_page_hash_mutex) + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + void* src, /*!< in: block to relocate */ + void* dst, /*!< in: free block to relocate to */ + ulint i, /*!< in: index of + buf_pool->zip_free[] */ + ibool have_page_hash_mutex) { buf_page_t* bpage; const ulint size = BUF_BUDDY_LOW << i; ullint usec = ut_time_us(NULL); - ulint space; - ulint page_no; - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&zip_free_mutex)); - ut_ad(!mutex_own(&buf_pool_zip_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->zip_free_mutex)); + ut_ad(!mutex_own(&buf_pool->zip_mutex)); ut_ad(!ut_align_offset(src, size)); ut_ad(!ut_align_offset(dst, size)); UNIV_MEM_ASSERT_W(dst, size); @@ -477,11 +478,12 @@ buf_buddy_relocate( if (size >= PAGE_ZIP_MIN_SIZE) { /* This is a compressed page. */ mutex_t* mutex; + ulint space, page_no; if (!have_page_hash_mutex) { - mutex_exit(&zip_free_mutex); - mutex_enter(&LRU_list_mutex); - rw_lock_x_lock(&page_hash_latch); + mutex_exit(&buf_pool->zip_free_mutex); + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); } /* The src block may be split into smaller blocks, @@ -500,7 +502,7 @@ buf_buddy_relocate( on uninitialized value. */ UNIV_MEM_VALID(&space, sizeof space); UNIV_MEM_VALID(&page_no, sizeof page_no); - bpage = buf_page_hash_get(space, page_no); + bpage = buf_page_hash_get(buf_pool, space, page_no); if (!bpage || bpage->zip.data != src) { /* The block has probably been freshly @@ -509,13 +511,15 @@ buf_buddy_relocate( it cannot be relocated. */ if (!have_page_hash_mutex) { - mutex_enter(&zip_free_mutex); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + mutex_enter(&buf_pool->zip_free_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); } return(FALSE); } + ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage)); + if (page_zip_get_size(&bpage->zip) != size) { /* The block is of different size. We would have to relocate all blocks covered by src. @@ -523,16 +527,16 @@ buf_buddy_relocate( ut_ad(page_zip_get_size(&bpage->zip) < size); if (!have_page_hash_mutex) { - mutex_enter(&zip_free_mutex); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + mutex_enter(&buf_pool->zip_free_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); } return(FALSE); } /* To keep latch order */ if (have_page_hash_mutex) - mutex_exit(&zip_free_mutex); + mutex_exit(&buf_pool->zip_free_mutex); /* The block must have been allocated, but it may contain uninitialized data. */ @@ -540,7 +544,7 @@ buf_buddy_relocate( mutex = buf_page_get_mutex_enter(bpage); - mutex_enter(&zip_free_mutex); + mutex_enter(&buf_pool->zip_free_mutex); if (mutex && buf_page_can_relocate(bpage)) { /* Relocate the compressed page. */ @@ -552,22 +556,22 @@ success: UNIV_MEM_INVALID(src, size); { buf_buddy_stat_t* buddy_stat - = &buf_buddy_stat[i]; + = &buf_pool->buddy_stat[i]; buddy_stat->relocated++; buddy_stat->relocated_usec += ut_time_us(NULL) - usec; } if (!have_page_hash_mutex) { - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); } return(TRUE); } if (!have_page_hash_mutex) { - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); } if (mutex) { @@ -582,29 +586,29 @@ success: UNIV_MEM_ASSERT_RW(src, size); #endif - mutex_exit(&zip_free_mutex); + mutex_exit(&buf_pool->zip_free_mutex); if (!have_page_hash_mutex) { - mutex_enter(&LRU_list_mutex); - rw_lock_x_lock(&page_hash_latch); + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); } if (buf_buddy_relocate_block(src, dst)) { - mutex_enter(&zip_free_mutex); + mutex_enter(&buf_pool->zip_free_mutex); if (!have_page_hash_mutex) { - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); } goto success; } - mutex_enter(&zip_free_mutex); + mutex_enter(&buf_pool->zip_free_mutex); if (!have_page_hash_mutex) { - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); } } @@ -617,36 +621,37 @@ UNIV_INTERN void buf_buddy_free_low( /*===============*/ - void* buf, /*!< in: block to be freed, must not be - pointed to by the buffer pool */ - ulint i, /*!< in: index of buf_pool->zip_free[], - or BUF_BUDDY_SIZES */ - ibool have_page_hash_mutex) + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + void* buf, /*!< in: block to be freed, must not be + pointed to by the buffer pool */ + ulint i, /*!< in: index of buf_pool->zip_free[], + or BUF_BUDDY_SIZES */ + ibool have_page_hash_mutex) { buf_page_t* bpage; buf_page_t* buddy; - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&zip_free_mutex)); - ut_ad(!mutex_own(&buf_pool_zip_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->zip_free_mutex)); + ut_ad(!mutex_own(&buf_pool->zip_mutex)); ut_ad(i <= BUF_BUDDY_SIZES); - ut_ad(buf_buddy_stat[i].used > 0); + ut_ad(buf_pool->buddy_stat[i].used > 0); - buf_buddy_stat[i].used--; + buf_pool->buddy_stat[i].used--; recombine: UNIV_MEM_ASSERT_AND_ALLOC(buf, BUF_BUDDY_LOW << i); ut_d(((buf_page_t*) buf)->state = BUF_BLOCK_ZIP_FREE); if (i == BUF_BUDDY_SIZES) { - mutex_exit(&zip_free_mutex); - buf_buddy_block_free(buf, have_page_hash_mutex); - mutex_enter(&zip_free_mutex); + mutex_exit(&buf_pool->zip_free_mutex); + buf_buddy_block_free(buf_pool, buf, have_page_hash_mutex); + mutex_enter(&buf_pool->zip_free_mutex); return; } ut_ad(i < BUF_BUDDY_SIZES); ut_ad(buf == ut_align_down(buf, BUF_BUDDY_LOW << i)); - ut_ad(!buf_pool_contains_zip(buf)); + ut_ad(!buf_pool_contains_zip(buf_pool, buf)); /* Try to combine adjacent blocks. */ @@ -672,10 +677,10 @@ recombine: if (bpage == buddy) { buddy_free: /* The buddy is free: recombine */ - buf_buddy_remove_from_free(bpage, i); + buf_buddy_remove_from_free(buf_pool, bpage, i); buddy_free2: ut_ad(buf_page_get_state(buddy) == BUF_BLOCK_ZIP_FREE); - ut_ad(!buf_pool_contains_zip(buddy)); + ut_ad(!buf_pool_contains_zip(buf_pool, buddy)); i++; buf = ut_align_down(buf, BUF_BUDDY_LOW << i); @@ -707,16 +712,16 @@ buddy_nonfree: buf_buddy_relocate() will overwrite bpage->list. */ UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i); - buf_buddy_remove_from_free(bpage, i); + buf_buddy_remove_from_free(buf_pool, bpage, i); /* Try to relocate the buddy of buf to the free block. */ - if (buf_buddy_relocate(buddy, bpage, i, have_page_hash_mutex)) { + if (buf_buddy_relocate(buf_pool, buddy, bpage, i, have_page_hash_mutex)) { ut_d(buddy->state = BUF_BLOCK_ZIP_FREE); goto buddy_free2; } - buf_buddy_add_to_free(bpage, i); + buf_buddy_add_to_free(buf_pool, bpage, i); /* Try to relocate the buddy of the free block to buf. */ buddy = (buf_page_t*) buf_buddy_get(((byte*) bpage), @@ -737,7 +742,7 @@ buddy_nonfree: && ut_list_node_313 != buddy))); #endif /* !UNIV_DEBUG_VALGRIND */ - if (buf_buddy_relocate(buddy, buf, i, have_page_hash_mutex)) { + if (buf_buddy_relocate(buf_pool, buddy, buf, i, have_page_hash_mutex)) { buf = bpage; UNIV_MEM_VALID(bpage, BUF_BUDDY_LOW << i); @@ -800,5 +805,5 @@ buddy_nonfree: } #endif /* UNIV_DEBUG */ bpage->state = BUF_BLOCK_ZIP_FREE; - buf_buddy_add_to_free(bpage, i); + buf_buddy_add_to_free(buf_pool, bpage, i); } diff --git a/storage/xtradb/buf/buf0buf.c b/storage/xtradb/buf/buf0buf.c index 1c08bd6d0bf..aed76e8121c 100644 --- a/storage/xtradb/buf/buf0buf.c +++ b/storage/xtradb/buf/buf0buf.c @@ -53,10 +53,6 @@ Created 11/5/1995 Heikki Tuuri #include "page0zip.h" #include "trx0trx.h" #include "srv0start.h" -#include "que0que.h" -#include "read0read.h" -#include "row0row.h" -#include "ha_prototypes.h" /* prototypes for new functions added to ha_innodb.cc */ trx_t* innobase_get_trx(); @@ -123,21 +119,21 @@ in the file along with the file page, resides in the control block. The buffer buf_pool contains a single mutex which protects all the control data structures of the buf_pool. The content of a buffer frame is protected by a separate read-write lock in its control block, though. -These locks can be locked and unlocked without owning the buf_pool mutex. +These locks can be locked and unlocked without owning the buf_pool->mutex. The OS events in the buf_pool struct can be waited for without owning the -buf_pool mutex. +buf_pool->mutex. -The buf_pool mutex is a hot-spot in main memory, causing a lot of +The buf_pool->mutex is a hot-spot in main memory, causing a lot of memory bus traffic on multiprocessor systems when processors alternately access the mutex. On our Pentium, the mutex is accessed maybe every 10 microseconds. We gave up the solution to have mutexes for each control block, for instance, because it seemed to be complicated. -A solution to reduce mutex contention of the buf_pool mutex is to +A solution to reduce mutex contention of the buf_pool->mutex is to create a separate mutex for the page hash table. On Pentium, accessing the hash table takes 2 microseconds, about half -of the total buf_pool mutex hold time. +of the total buf_pool->mutex hold time. Control blocks -------------- @@ -192,12 +188,12 @@ list. We also keep a pointer to near the end of the LRU list, which we can use when we want to artificially age a page in the buf_pool. This is used if we know that some page is not needed again for some time: we insert the block right after the pointer, -causing it to be replaced sooner than would noramlly be the case. +causing it to be replaced sooner than would normally be the case. Currently this aging mechanism is used for read-ahead mechanism of pages, and it can also be used when there is a scan of a full table which cannot fit in the memory. Putting the pages near the -of the LRU list, we make sure that most of the buf_pool stays in the -main memory, undisturbed. +end of the LRU list, we make sure that most of the buf_pool stays +in the main memory, undisturbed. The unzip_LRU list contains a subset of the common LRU list. The blocks on the unzip_LRU list hold a compressed file page and the @@ -211,6 +207,7 @@ The chain of modified blocks (buf_pool->flush_list) contains the blocks holding file pages that have been modified in the memory but not written to disk yet. The block with the oldest modification which has not yet been written to disk is at the end of the chain. +The access to this list is protected by buf_pool->flush_list_mutex. The chain of unmodified compressed blocks (buf_pool->zip_clean) contains the control blocks (buf_page_t) of those compressed pages @@ -284,29 +281,13 @@ static const int WAIT_FOR_READ = 5000; /** Number of attemtps made to read in a page in the buffer pool */ static const ulint BUF_PAGE_READ_MAX_RETRIES = 100; -/** The buffer buf_pool of the database */ -UNIV_INTERN buf_pool_t* buf_pool = NULL; - -/** mutex protecting the buffer pool struct and control blocks, except the -read-write lock in them */ -UNIV_INTERN mutex_t buf_pool_mutex; -UNIV_INTERN mutex_t LRU_list_mutex; -UNIV_INTERN mutex_t flush_list_mutex; -UNIV_INTERN rw_lock_t page_hash_latch; -UNIV_INTERN mutex_t free_list_mutex; -UNIV_INTERN mutex_t zip_free_mutex; -UNIV_INTERN mutex_t zip_hash_mutex; -/** mutex protecting the control blocks of compressed-only pages -(of type buf_page_t, not buf_block_t) */ -UNIV_INTERN mutex_t buf_pool_zip_mutex; +/** The buffer pools of the database */ +UNIV_INTERN buf_pool_t* buf_pool_ptr; #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG static ulint buf_dbg_counter = 0; /*!< This is used to insert validation - operations in excution in the + operations in execution in the debug version */ -/** Flag to forbid the release of the buffer pool mutex. -Protected by buf_pool_mutex. */ -UNIV_INTERN ulint buf_pool_mutex_exit_forbidden = 0; #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #ifdef UNIV_DEBUG /** If this is set TRUE, the program prints info whenever @@ -314,32 +295,191 @@ read-ahead or flush occurs */ UNIV_INTERN ibool buf_debug_prints = FALSE; #endif /* UNIV_DEBUG */ -/* Buffer pool shared memory segment information */ -typedef struct buf_shm_info_struct buf_shm_info_t; +#ifdef UNIV_PFS_RWLOCK +/* Keys to register buffer block related rwlocks and mutexes with +performance schema */ +UNIV_INTERN mysql_pfs_key_t buf_pool_page_hash_key; +UNIV_INTERN mysql_pfs_key_t buf_block_lock_key; +# ifdef UNIV_SYNC_DEBUG +UNIV_INTERN mysql_pfs_key_t buf_block_debug_latch_key; +# endif /* UNIV_SYNC_DEBUG */ +#endif /* UNIV_PFS_RWLOCK */ -struct buf_shm_info_struct { - char head_str[8]; - ulint binary_id; - ibool is_new; /* during initializing */ - ibool clean; /* clean shutdowned and free */ - ibool reusable; /* reusable */ - ulint buf_pool_size; /* backup value */ - ulint page_size; /* backup value */ - ulint frame_offset; /* offset of the first frame based on chunk->mem */ - ulint zip_hash_offset; - ulint zip_hash_n; +#ifdef UNIV_PFS_MUTEX +UNIV_INTERN mysql_pfs_key_t buffer_block_mutex_key; +UNIV_INTERN mysql_pfs_key_t buf_pool_mutex_key; +UNIV_INTERN mysql_pfs_key_t buf_pool_zip_mutex_key; +UNIV_INTERN mysql_pfs_key_t buf_pool_LRU_list_mutex_key; +UNIV_INTERN mysql_pfs_key_t buf_pool_free_list_mutex_key; +UNIV_INTERN mysql_pfs_key_t buf_pool_zip_free_mutex_key; +UNIV_INTERN mysql_pfs_key_t buf_pool_zip_hash_mutex_key; +UNIV_INTERN mysql_pfs_key_t flush_list_mutex_key; +#endif /* UNIV_PFS_MUTEX */ - ulint checksum; +#if defined UNIV_PFS_MUTEX || defined UNIV_PFS_RWLOCK +# ifndef PFS_SKIP_BUFFER_MUTEX_RWLOCK - buf_pool_t buf_pool_backup; - buf_chunk_t chunk_backup; +/* Buffer block mutexes and rwlocks can be registered +in one group rather than individually. If PFS_GROUP_BUFFER_SYNC +is defined, register buffer block mutex and rwlock +in one group after their initialization. */ +# define PFS_GROUP_BUFFER_SYNC - ib_uint64_t dummy; -}; +/* This define caps the number of mutexes/rwlocks can +be registered with performance schema. Developers can +modify this define if necessary. Please note, this would +be effective only if PFS_GROUP_BUFFER_SYNC is defined. */ +# define PFS_MAX_BUFFER_MUTEX_LOCK_REGISTER ULINT_MAX -#define BUF_SHM_INFO_HEAD "XTRA_SHM" +# endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */ +#endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */ + +/** A chunk of buffers. The buffer pool is allocated in chunks. (moved to buf0buf.h)*/ +//struct buf_chunk_struct{ +// ulint mem_size; /*!< allocated size of the chunk */ +// ulint size; /*!< size of frames[] and blocks[] */ +// void* mem; /*!< pointer to the memory area which +// was allocated for the frames */ +// buf_block_t* blocks; /*!< array of buffer control blocks */ +//}; #endif /* !UNIV_HOTBACKUP */ +/********************************************************************//** +Gets the smallest oldest_modification lsn for any page in the pool. Returns +zero if all modified pages have been flushed to disk. +@return oldest modification in pool, zero if none */ +UNIV_INTERN +ib_uint64_t +buf_pool_get_oldest_modification(void) +/*==================================*/ +{ + ulint i; + buf_page_t* bpage; + ib_uint64_t lsn = 0; + ib_uint64_t oldest_lsn = 0; + + /* When we traverse all the flush lists we don't want another + thread to add a dirty page to any flush list. */ + if (srv_buf_pool_instances > 1) + log_flush_order_mutex_enter(); + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + buf_flush_list_mutex_enter(buf_pool); + + bpage = UT_LIST_GET_LAST(buf_pool->flush_list); + + if (bpage != NULL) { + ut_ad(bpage->in_flush_list); + lsn = bpage->oldest_modification; + } + + buf_flush_list_mutex_exit(buf_pool); + + if (!oldest_lsn || oldest_lsn > lsn) { + oldest_lsn = lsn; + } + } + + if (srv_buf_pool_instances > 1) + log_flush_order_mutex_exit(); + + /* The returned answer may be out of date: the flush_list can + change after the mutex has been released. */ + + return(oldest_lsn); +} + +/********************************************************************//** +Get total buffer pool statistics. */ +UNIV_INTERN +void +buf_get_total_list_len( +/*===================*/ + ulint* LRU_len, /*!< out: length of all LRU lists */ + ulint* free_len, /*!< out: length of all free lists */ + ulint* flush_list_len) /*!< out: length of all flush lists */ +{ + ulint i; + + *LRU_len = 0; + *free_len = 0; + *flush_list_len = 0; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + *LRU_len += UT_LIST_GET_LEN(buf_pool->LRU); + *free_len += UT_LIST_GET_LEN(buf_pool->free); + *flush_list_len += UT_LIST_GET_LEN(buf_pool->flush_list); + } +} + +/********************************************************************//** +Get total buffer pool statistics. */ +UNIV_INTERN +void +buf_get_total_stat( +/*===============*/ + buf_pool_stat_t* tot_stat) /*!< out: buffer pool stats */ +{ + ulint i; + + memset(tot_stat, 0, sizeof(*tot_stat)); + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_stat_t*buf_stat; + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + buf_stat = &buf_pool->stat; + tot_stat->n_page_gets += buf_stat->n_page_gets; + tot_stat->n_pages_read += buf_stat->n_pages_read; + tot_stat->n_pages_written += buf_stat->n_pages_written; + tot_stat->n_pages_created += buf_stat->n_pages_created; + tot_stat->n_ra_pages_read += buf_stat->n_ra_pages_read; + tot_stat->n_ra_pages_evicted += buf_stat->n_ra_pages_evicted; + tot_stat->n_pages_made_young += buf_stat->n_pages_made_young; + + tot_stat->n_pages_not_made_young += + buf_stat->n_pages_not_made_young; + } +} + +/********************************************************************//** +Allocates a buffer block. +@return own: the allocated block, in state BUF_BLOCK_MEMORY */ +UNIV_INTERN +buf_block_t* +buf_block_alloc( +/*============*/ + buf_pool_t* buf_pool) /*!< in/out: buffer pool instance, + or NULL for round-robin selection + of the buffer pool */ +{ + buf_block_t* block; + ulint index; + static ulint buf_pool_index; + + if (buf_pool == NULL) { + /* We are allocating memory from any buffer pool, ensure + we spread the grace on all buffer pool instances. */ + index = buf_pool_index++ % srv_buf_pool_instances; + buf_pool = buf_pool_from_array(index); + } + + block = buf_LRU_get_free_block(buf_pool); + + buf_block_set_state(block, BUF_BLOCK_MEMORY); + + return(block); +} + /********************************************************************//** Calculates a page checksum which is stored to the page when it is written to a file. Note that we must be careful to calculate the same value on @@ -445,7 +585,9 @@ buf_page_is_corrupted( ib_uint64_t current_lsn; if (log_peek_lsn(¤t_lsn) - && current_lsn < mach_read_ull(read_buf + FIL_PAGE_LSN)) { + && UNIV_UNLIKELY + (current_lsn + < mach_read_from_8(read_buf + FIL_PAGE_LSN))) { ut_print_timestamp(stderr); fprintf(stderr, @@ -457,11 +599,11 @@ buf_page_is_corrupted( "you may have copied the InnoDB\n" "InnoDB: tablespace but not the InnoDB " "log files. See\n" - "InnoDB: " REFMAN "forcing-recovery.html\n" + "InnoDB: " REFMAN "forcing-innodb-recovery.html\n" "InnoDB: for more information.\n", (ulong) mach_read_from_4(read_buf + FIL_PAGE_OFFSET), - mach_read_ull(read_buf + FIL_PAGE_LSN), + mach_read_from_8(read_buf + FIL_PAGE_LSN), current_lsn); } } @@ -673,17 +815,15 @@ buf_page_print( #endif /* !UNIV_HOTBACKUP */ switch (fil_page_get_type(read_buf)) { + index_id_t index_id; case FIL_PAGE_INDEX: + index_id = btr_page_get_index_id(read_buf); fprintf(stderr, "InnoDB: Page may be an index page where" - " index id is %lu %lu\n", - (ulong) ut_dulint_get_high( - btr_page_get_index_id(read_buf)), - (ulong) ut_dulint_get_low( - btr_page_get_index_id(read_buf))); + " index id is %llu\n", + (ullint) index_id); #ifndef UNIV_HOTBACKUP - index = dict_index_find_on_id_low( - btr_page_get_index_id(read_buf)); + index = dict_index_find_on_id_low(index_id); if (index) { fputs("InnoDB: (", stderr); dict_index_name_print(stderr, NULL, index); @@ -735,31 +875,83 @@ buf_page_print( } #ifndef UNIV_HOTBACKUP + +# ifdef PFS_GROUP_BUFFER_SYNC +/********************************************************************//** +This function registers mutexes and rwlocks in buffer blocks with +performance schema. If PFS_MAX_BUFFER_MUTEX_LOCK_REGISTER is +defined to be a value less than chunk->size, then only mutexes +and rwlocks in the first PFS_MAX_BUFFER_MUTEX_LOCK_REGISTER +blocks are registered. */ +static +void +pfs_register_buffer_block( +/*======================*/ + buf_chunk_t* chunk) /*!< in/out: chunk of buffers */ +{ + ulint i; + ulint num_to_register; + buf_block_t* block; + + block = chunk->blocks; + + num_to_register = ut_min(chunk->size, + PFS_MAX_BUFFER_MUTEX_LOCK_REGISTER); + + for (i = 0; i < num_to_register; i++) { + mutex_t* mutex; + rw_lock_t* rwlock; + +# ifdef UNIV_PFS_MUTEX + mutex = &block->mutex; + ut_a(!mutex->pfs_psi); + mutex->pfs_psi = (PSI_server) + ? PSI_server->init_mutex(buffer_block_mutex_key, mutex) + : NULL; +# endif /* UNIV_PFS_MUTEX */ + +# ifdef UNIV_PFS_RWLOCK + rwlock = &block->lock; + ut_a(!rwlock->pfs_psi); + rwlock->pfs_psi = (PSI_server) + ? PSI_server->init_rwlock(buf_block_lock_key, rwlock) + : NULL; +# endif /* UNIV_PFS_RWLOCK */ + block++; + } +} +# endif /* PFS_GROUP_BUFFER_SYNC */ + /********************************************************************//** Initializes a buffer control block when the buf_pool is created. */ static void buf_block_init( /*===========*/ - buf_block_t* block, /*!< in: pointer to control block */ - byte* frame) /*!< in: pointer to buffer frame */ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + buf_block_t* block, /*!< in: pointer to control block */ + byte* frame) /*!< in: pointer to buffer frame */ { UNIV_MEM_DESC(frame, UNIV_PAGE_SIZE, block); block->frame = frame; + block->page.buf_pool_index = buf_pool_index(buf_pool); block->page.state = BUF_BLOCK_NOT_USED; block->page.buf_fix_count = 0; block->page.io_fix = BUF_IO_NONE; block->modify_clock = 0; -#ifdef UNIV_DEBUG_FILE_ACCESSES +#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG block->page.file_page_was_freed = FALSE; -#endif /* UNIV_DEBUG_FILE_ACCESSES */ +#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */ block->check_index_page_at_flush = FALSE; block->index = NULL; + block->btr_search_latch = NULL; + + block->is_hashed = FALSE; #ifdef UNIV_DEBUG block->page.in_page_hash = FALSE; @@ -767,6 +959,10 @@ buf_block_init( block->page.in_flush_list = FALSE; block->page.in_free_list = FALSE; #endif /* UNIV_DEBUG */ + block->page.flush_list.prev = NULL; + block->page.flush_list.next = NULL; + block->page.zip_list.prev = NULL; + block->page.zip_list.next = NULL; block->page.in_LRU_list = FALSE; block->in_unzip_LRU_list = FALSE; #if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG @@ -774,52 +970,25 @@ buf_block_init( #endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ page_zip_des_init(&block->page.zip); - mutex_create(&block->mutex, SYNC_BUF_BLOCK); +#if defined PFS_SKIP_BUFFER_MUTEX_RWLOCK || defined PFS_GROUP_BUFFER_SYNC + /* If PFS_SKIP_BUFFER_MUTEX_RWLOCK is defined, skip registration + of buffer block mutex/rwlock with performance schema. If + PFS_GROUP_BUFFER_SYNC is defined, skip the registration + since buffer block mutex/rwlock will be registered later in + pfs_register_buffer_block() */ + + mutex_create(PFS_NOT_INSTRUMENTED, &block->mutex, SYNC_BUF_BLOCK); + rw_lock_create(PFS_NOT_INSTRUMENTED, &block->lock, SYNC_LEVEL_VARYING); +#else /* PFS_SKIP_BUFFER_MUTEX_RWLOCK || PFS_GROUP_BUFFER_SYNC */ + mutex_create(buffer_block_mutex_key, &block->mutex, SYNC_BUF_BLOCK); + rw_lock_create(buf_block_lock_key, &block->lock, SYNC_LEVEL_VARYING); +#endif /* PFS_SKIP_BUFFER_MUTEX_RWLOCK || PFS_GROUP_BUFFER_SYNC */ - rw_lock_create(&block->lock, SYNC_LEVEL_VARYING); ut_ad(rw_lock_validate(&(block->lock))); #ifdef UNIV_SYNC_DEBUG - rw_lock_create(&block->debug_latch, SYNC_NO_ORDER_CHECK); -#endif /* UNIV_SYNC_DEBUG */ -} - -static -void -buf_block_reuse( -/*============*/ - buf_block_t* block, - ptrdiff_t frame_offset) -{ - /* block_init */ - block->frame += frame_offset; - - UNIV_MEM_DESC(block->frame, UNIV_PAGE_SIZE, block); - - block->index = NULL; - -#ifdef UNIV_DEBUG - /* recreate later */ - block->page.in_page_hash = FALSE; - block->page.in_zip_hash = FALSE; -#endif /* UNIV_DEBUG */ - -#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG - block->n_pointers = 0; -#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ - - if (block->page.zip.data) - block->page.zip.data += frame_offset; - - block->is_hashed = FALSE; - - mutex_create(&block->mutex, SYNC_BUF_BLOCK); - - rw_lock_create(&block->lock, SYNC_LEVEL_VARYING); - ut_ad(rw_lock_validate(&(block->lock))); - -#ifdef UNIV_SYNC_DEBUG - rw_lock_create(&block->debug_latch, SYNC_NO_ORDER_CHECK); + rw_lock_create(buf_block_debug_latch_key, + &block->debug_latch, SYNC_NO_ORDER_CHECK); #endif /* UNIV_SYNC_DEBUG */ } @@ -830,193 +999,34 @@ static buf_chunk_t* buf_chunk_init( /*===========*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ buf_chunk_t* chunk, /*!< out: chunk of buffers */ ulint mem_size) /*!< in: requested size in bytes */ { buf_block_t* block; byte* frame; - ulint zip_hash_n = 0; - ulint zip_hash_mem_size = 0; - hash_table_t* zip_hash_tmp = NULL; ulint i; - buf_shm_info_t* shm_info = NULL; + ulint size_target; /* Round down to a multiple of page size, although it already should be. */ mem_size = ut_2pow_round(mem_size, UNIV_PAGE_SIZE); - - srv_buffer_pool_shm_is_reused = FALSE; - - if (srv_buffer_pool_shm_key) { - /* zip_hash size */ - zip_hash_n = (mem_size / UNIV_PAGE_SIZE) * 2; - zip_hash_mem_size = ut_2pow_round(hash_create_needed(zip_hash_n) - + (UNIV_PAGE_SIZE - 1), UNIV_PAGE_SIZE); - } - + size_target = (mem_size / UNIV_PAGE_SIZE) - 1; /* Reserve space for the block descriptors. */ mem_size += ut_2pow_round((mem_size / UNIV_PAGE_SIZE) * (sizeof *block) + (UNIV_PAGE_SIZE - 1), UNIV_PAGE_SIZE); - if (srv_buffer_pool_shm_key) { - mem_size += ut_2pow_round(sizeof(buf_shm_info_t) - + (UNIV_PAGE_SIZE - 1), UNIV_PAGE_SIZE); - mem_size += zip_hash_mem_size; - } chunk->mem_size = mem_size; - - if (srv_buffer_pool_shm_key) { - ulint binary_id; - ibool is_new; - - ut_a(buf_pool->n_chunks == 1); - - fprintf(stderr, - "InnoDB: Warning: The innodb_buffer_pool_shm_key option has been specified.\n" - "InnoDB: Do not change the following between restarts of the server while this option is being used:\n" - "InnoDB: * the mysqld executable between restarts of the server.\n" - "InnoDB: * the value of innodb_buffer_pool_size.\n" - "InnoDB: * the value of innodb_page_size.\n" - "InnoDB: * datafiles created by InnoDB during this session.\n" - "InnoDB: Otherwise, data corruption in datafiles may result.\n"); - - /* FIXME: This is vague id still */ - binary_id = (ulint) ((byte*)mtr_commit - (byte*)btr_root_get) - + (ulint) ((byte*)os_get_os_version - (byte*)buf_calc_page_new_checksum) - + (ulint) ((byte*)page_dir_find_owner_slot - (byte*)dfield_data_is_binary_equal) - + (ulint) ((byte*)que_graph_publish - (byte*)dict_casedn_str) - + (ulint) ((byte*)read_view_oldest_copy_or_open_new - (byte*)fil_space_get_version) - + (ulint) ((byte*)rec_get_n_extern_new - (byte*)fsp_get_size_low) - + (ulint) ((byte*)row_get_trx_id_offset - (byte*)ha_create_func) - + (ulint) ((byte*)srv_set_io_thread_op_info - (byte*)thd_is_replication_slave_thread) - + (ulint) ((byte*)mutex_create_func - (byte*)ibuf_inside) - + (ulint) ((byte*)trx_set_detailed_error - (byte*)lock_check_trx_id_sanity) - + (ulint) ((byte*)ut_time - (byte*)mem_heap_strdup); - - chunk->mem = os_shm_alloc(&chunk->mem_size, srv_buffer_pool_shm_key, &is_new); - - if (UNIV_UNLIKELY(chunk->mem == NULL)) { - return(NULL); - } -init_again: -#ifdef UNIV_SET_MEM_TO_ZERO - if (is_new) { - memset(chunk->mem, '\0', chunk->mem_size); - } -#endif - /* for ut_fold_binary_32(), these values should be 32-bit aligned */ - ut_a(sizeof(buf_shm_info_t) % 4 == 0); - ut_a((ulint)chunk->mem % 4 == 0); - ut_a(chunk->mem_size % 4 == 0); - - shm_info = chunk->mem; - - zip_hash_tmp = (hash_table_t*)((byte*)chunk->mem + chunk->mem_size - zip_hash_mem_size); - - if (is_new) { - strncpy(shm_info->head_str, BUF_SHM_INFO_HEAD, 8); - shm_info->binary_id = binary_id; - shm_info->is_new = TRUE; /* changed to FALSE when the initialization is finished */ - shm_info->clean = FALSE; /* changed to TRUE when free the segment. */ - shm_info->reusable = FALSE; /* changed to TRUE when validation is finished. */ - shm_info->buf_pool_size = srv_buf_pool_size; - shm_info->page_size = srv_page_size; - shm_info->zip_hash_offset = chunk->mem_size - zip_hash_mem_size; - shm_info->zip_hash_n = zip_hash_n; - } else { - ulint checksum; - - if (strncmp(shm_info->head_str, BUF_SHM_INFO_HEAD, 8)) { - fprintf(stderr, - "InnoDB: Error: The shared memory segment seems not to be for buffer pool.\n"); - return(NULL); - } - if (shm_info->binary_id != binary_id) { - fprintf(stderr, - "InnoDB: Error: The shared memory segment seems not to be for this binary.\n"); - return(NULL); - } - if (shm_info->is_new) { - fprintf(stderr, - "InnoDB: Error: The shared memory was not initialized yet.\n"); - return(NULL); - } - if (shm_info->buf_pool_size != srv_buf_pool_size) { - fprintf(stderr, - "InnoDB: Error: srv_buf_pool_size is different (shm=%lu current=%lu).\n", - shm_info->buf_pool_size, srv_buf_pool_size); - return(NULL); - } - if (shm_info->page_size != srv_page_size) { - fprintf(stderr, - "InnoDB: Error: srv_page_size is different (shm=%lu current=%lu).\n", - shm_info->page_size, srv_page_size); - return(NULL); - } - if (!shm_info->reusable) { - fprintf(stderr, - "InnoDB: Warning: The shared memory has unrecoverable contents.\n" - "InnoDB: The shared memory segment is initialized.\n"); - is_new = TRUE; - goto init_again; - } - if (!shm_info->clean) { - fprintf(stderr, - "InnoDB: Warning: The shared memory was not shut down cleanly.\n" - "InnoDB: The shared memory segment is initialized.\n"); - is_new = TRUE; - goto init_again; - } - - ut_a(shm_info->zip_hash_offset == chunk->mem_size - zip_hash_mem_size); - ut_a(shm_info->zip_hash_n == zip_hash_n); - - /* check checksum */ - if (srv_buffer_pool_shm_checksum) { - checksum = ut_fold_binary_32((byte*)chunk->mem + sizeof(buf_shm_info_t), - chunk->mem_size - sizeof(buf_shm_info_t)); - } else { - checksum = BUF_NO_CHECKSUM_MAGIC; - } - - if (shm_info->checksum != BUF_NO_CHECKSUM_MAGIC - && shm_info->checksum != checksum) { - fprintf(stderr, - "InnoDB: Error: checksum of the shared memory is not match. " - "(stored=%lu calculated=%lu)\n", - shm_info->checksum, checksum); - return(NULL); - } - - /* flag to use the segment. */ - shm_info->clean = FALSE; /* changed to TRUE when free the segment. */ - } - - /* init zip_hash contents */ - if (is_new) { - hash_create_init(zip_hash_tmp, zip_hash_n); - } else { - /* adjust offset is done later */ - hash_create_reuse(zip_hash_tmp); - - srv_buffer_pool_shm_is_reused = TRUE; - } - } else { chunk->mem = os_mem_alloc_large(&chunk->mem_size); if (UNIV_UNLIKELY(chunk->mem == NULL)) { return(NULL); } - } /* Allocate the block descriptors from the start of the memory block. */ - if (srv_buffer_pool_shm_key) { - chunk->blocks = (buf_block_t*)((byte*)chunk->mem + sizeof(buf_shm_info_t)); - } else { chunk->blocks = chunk->mem; - } /* Align a pointer to the first frame. Note that when os_large_page_size is smaller than UNIV_PAGE_SIZE, @@ -1024,13 +1034,8 @@ init_again: it is bigger, we may allocate more blocks than requested. */ frame = ut_align(chunk->mem, UNIV_PAGE_SIZE); - if (srv_buffer_pool_shm_key) { - /* reserve zip_hash space and always -1 for reproductibity */ - chunk->size = (chunk->mem_size - zip_hash_mem_size) / UNIV_PAGE_SIZE - 1; - } else { chunk->size = chunk->mem_size / UNIV_PAGE_SIZE - (frame != chunk->mem); - } /* Subtract the space needed for block descriptors. */ { @@ -1044,98 +1049,10 @@ init_again: chunk->size = size; } - if (shm_info && !(shm_info->is_new)) { - /* convert the shared memory segment for reuse */ - ptrdiff_t phys_offset; - ptrdiff_t logi_offset; - ptrdiff_t blocks_offset; - byte* previous_frame_address; + if (chunk->size > size_target) { + chunk->size = size_target; + } - if (chunk->size < shm_info->chunk_backup.size) { - fprintf(stderr, - "InnoDB: Error: The buffer pool became smaller because of allocated address.\n" - "InnoDB: Retrying may avoid this situation.\n"); - shm_info->clean = TRUE; /* release the flag for retrying */ - return(NULL); - } - - chunk->size = shm_info->chunk_backup.size; - phys_offset = frame - ((byte*)chunk->mem + shm_info->frame_offset); - logi_offset = frame - chunk->blocks[0].frame; - previous_frame_address = chunk->blocks[0].frame; - blocks_offset = (byte*)chunk->blocks - (byte*)shm_info->chunk_backup.blocks; - - if (phys_offset || logi_offset || blocks_offset) { - fprintf(stderr, - "InnoDB: Buffer pool in the shared memory segment should be converted.\n" - "InnoDB: Previous frames in address : %p\n" - "InnoDB: Previous frames were located : %p\n" - "InnoDB: Current frames should be located: %p\n" - "InnoDB: Pysical offset : %ld (%#lx)\n" - "InnoDB: Logical offset (frames) : %ld (%#lx)\n" - "InnoDB: Logical offset (blocks) : %ld (%#lx)\n", - (byte*)chunk->mem + shm_info->frame_offset, - chunk->blocks[0].frame, frame, - (long) phys_offset, (ulong) phys_offset, (long) logi_offset, (ulong) logi_offset, - (long) blocks_offset, (ulong) blocks_offset); - } else { - fprintf(stderr, - "InnoDB: Buffer pool in the shared memory segment can be used as it is.\n"); - } - - if (phys_offset) { - fprintf(stderr, - "InnoDB: Aligning physical offset..."); - - memmove(frame, (byte*)chunk->mem + shm_info->frame_offset, - chunk->size * UNIV_PAGE_SIZE); - - fprintf(stderr, - " Done.\n"); - } - - /* buf_block_t */ - block = chunk->blocks; - for (i = chunk->size; i--; ) { - buf_block_reuse(block, logi_offset); - block++; - } - - if (logi_offset || blocks_offset) { - fprintf(stderr, - "InnoDB: Aligning logical offset..."); - - - /* buf_pool_t buf_pool_backup */ - UT_LIST_OFFSET(flush_list, buf_page_t, shm_info->buf_pool_backup.flush_list, - previous_frame_address, logi_offset, blocks_offset); - UT_LIST_OFFSET(free, buf_page_t, shm_info->buf_pool_backup.free, - previous_frame_address, logi_offset, blocks_offset); - UT_LIST_OFFSET(LRU, buf_page_t, shm_info->buf_pool_backup.LRU, - previous_frame_address, logi_offset, blocks_offset); - if (shm_info->buf_pool_backup.LRU_old) - shm_info->buf_pool_backup.LRU_old = - (buf_page_t*)((byte*)(shm_info->buf_pool_backup.LRU_old) - + (((byte*)shm_info->buf_pool_backup.LRU_old > previous_frame_address) - ? logi_offset : blocks_offset)); - - UT_LIST_OFFSET(unzip_LRU, buf_block_t, shm_info->buf_pool_backup.unzip_LRU, - previous_frame_address, logi_offset, blocks_offset); - - UT_LIST_OFFSET(zip_list, buf_page_t, shm_info->buf_pool_backup.zip_clean, - previous_frame_address, logi_offset, blocks_offset); - for (i = 0; i < BUF_BUDDY_SIZES_MAX; i++) { - UT_LIST_OFFSET(zip_list, buf_page_t, shm_info->buf_pool_backup.zip_free[i], - previous_frame_address, logi_offset, blocks_offset); - } - - HASH_OFFSET(zip_hash_tmp, buf_page_t, hash, - previous_frame_address, logi_offset, blocks_offset); - - fprintf(stderr, - " Done.\n"); - } - } else { /* Init block structs and assign frames for them. Then we assign the frames to the first blocks (we already mapped the memory above). */ @@ -1144,27 +1061,27 @@ init_again: for (i = chunk->size; i--; ) { - buf_block_init(block, frame); + buf_block_init(buf_pool, block, frame); #ifdef HAVE_valgrind /* Wipe contents of frame to eliminate a Purify warning */ memset(block->frame, '\0', UNIV_PAGE_SIZE); #endif /* Add the block to the free list */ - mutex_enter(&free_list_mutex); + mutex_enter(&buf_pool->free_list_mutex); UT_LIST_ADD_LAST(free, buf_pool->free, (&block->page)); + ut_d(block->page.in_free_list = TRUE); - mutex_exit(&free_list_mutex); + mutex_exit(&buf_pool->free_list_mutex); + ut_ad(buf_pool_from_block(block) == buf_pool); block++; frame += UNIV_PAGE_SIZE; } - } - - if (shm_info) { - shm_info->frame_offset = chunk->blocks[0].frame - (byte*)chunk->mem; - } +#ifdef PFS_GROUP_BUFFER_SYNC + pfs_register_buffer_block(chunk); +#endif return(chunk); } @@ -1183,9 +1100,6 @@ buf_chunk_contains_zip( buf_block_t* block; ulint i; - ut_ad(buf_pool); - //ut_ad(buf_pool_mutex_own()); - block = chunk->blocks; for (i = chunk->size; i--; block++) { @@ -1206,12 +1120,17 @@ UNIV_INTERN buf_block_t* buf_pool_contains_zip( /*==================*/ - const void* data) /*!< in: pointer to compressed page */ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + const void* data) /*!< in: pointer to compressed page */ { ulint n; buf_chunk_t* chunk = buf_pool->chunks; + ut_ad(buf_pool); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->zip_free_mutex)); for (n = buf_pool->n_chunks; n--; chunk++) { + buf_block_t* block = buf_chunk_contains_zip(chunk, data); if (block) { @@ -1235,9 +1154,6 @@ buf_chunk_not_freed( buf_block_t* block; ulint i; - ut_ad(buf_pool); - //ut_ad(buf_pool_mutex_own()); /*optimistic...*/ - block = chunk->blocks; for (i = chunk->size; i--; block++) { @@ -1292,9 +1208,6 @@ buf_chunk_all_free( const buf_block_t* block; ulint i; - ut_ad(buf_pool); - ut_ad(buf_pool_mutex_own()); /* but we need all mutex here */ - block = chunk->blocks; for (i = chunk->size; i--; block++) { @@ -1314,12 +1227,13 @@ static void buf_chunk_free( /*===========*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ buf_chunk_t* chunk) /*!< out: chunk of buffers */ { buf_block_t* block; const buf_block_t* block_end; - ut_ad(buf_pool_mutex_own()); /* but we need all mutex here */ + //ut_ad(buf_pool_mutex_own(buf_pool)); /* but we need all mutex here */ block_end = chunk->blocks + chunk->size; @@ -1331,10 +1245,10 @@ buf_chunk_free( ut_ad(!block->in_unzip_LRU_list); ut_ad(!block->page.in_flush_list); /* Remove the block from the free list. */ - mutex_enter(&free_list_mutex); + mutex_enter(&buf_pool->free_list_mutex); ut_ad(block->page.in_free_list); UT_LIST_REMOVE(free, buf_pool->free, (&block->page)); - mutex_exit(&free_list_mutex); + mutex_exit(&buf_pool->free_list_mutex); /* Free the latches. */ mutex_free(&block->mutex); @@ -1345,207 +1259,130 @@ buf_chunk_free( UNIV_MEM_UNDESC(block); } - ut_a(!srv_buffer_pool_shm_key); - os_mem_free_large(chunk->mem, chunk->mem_size); } /********************************************************************//** -Creates the buffer pool. -@return own: buf_pool object, NULL if not enough memory or error */ -UNIV_INTERN -buf_pool_t* -buf_pool_init(void) -/*===============*/ +Set buffer pool size variables after resizing it */ +static +void +buf_pool_set_sizes(void) +/*====================*/ { - buf_chunk_t* chunk; - ulint i; + ulint i; + ulint curr_size = 0; - buf_pool = mem_zalloc(sizeof(buf_pool_t)); + buf_pool_mutex_enter_all(); + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + curr_size += buf_pool->curr_pool_size; + } + + srv_buf_pool_curr_size = curr_size; + srv_buf_pool_old_size = srv_buf_pool_size; + + buf_pool_mutex_exit_all(); +} + +/********************************************************************//** +Initialize a buffer pool instance. +@return DB_SUCCESS if all goes well. */ +UNIV_INTERN +ulint +buf_pool_init_instance( +/*===================*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + ulint buf_pool_size, /*!< in: size in bytes */ + ulint instance_no) /*!< in: id of the instance */ +{ + ulint i; + buf_chunk_t* chunk; /* 1. Initialize general fields ------------------------------- */ - mutex_create(&buf_pool_mutex, SYNC_BUF_POOL); - mutex_create(&LRU_list_mutex, SYNC_BUF_LRU_LIST); - mutex_create(&flush_list_mutex, SYNC_BUF_FLUSH_LIST); - rw_lock_create(&page_hash_latch, SYNC_BUF_PAGE_HASH); - mutex_create(&free_list_mutex, SYNC_BUF_FREE_LIST); - mutex_create(&zip_free_mutex, SYNC_BUF_ZIP_FREE); - mutex_create(&zip_hash_mutex, SYNC_BUF_ZIP_HASH); + mutex_create(buf_pool_mutex_key, + &buf_pool->mutex, SYNC_BUF_POOL); + mutex_create(buf_pool_LRU_list_mutex_key, + &buf_pool->LRU_list_mutex, SYNC_BUF_LRU_LIST); + rw_lock_create(buf_pool_page_hash_key, + &buf_pool->page_hash_latch, SYNC_BUF_PAGE_HASH); + mutex_create(buf_pool_free_list_mutex_key, + &buf_pool->free_list_mutex, SYNC_BUF_FREE_LIST); + mutex_create(buf_pool_zip_free_mutex_key, + &buf_pool->zip_free_mutex, SYNC_BUF_ZIP_FREE); + mutex_create(buf_pool_zip_hash_mutex_key, + &buf_pool->zip_hash_mutex, SYNC_BUF_ZIP_HASH); + mutex_create(buf_pool_zip_mutex_key, + &buf_pool->zip_mutex, SYNC_BUF_BLOCK); - mutex_create(&buf_pool_zip_mutex, SYNC_BUF_BLOCK); + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); + buf_pool_mutex_enter(buf_pool); - mutex_enter(&LRU_list_mutex); - rw_lock_x_lock(&page_hash_latch); - buf_pool_mutex_enter(); + if (buf_pool_size > 0) { + buf_pool->n_chunks = 1; + buf_pool->chunks = chunk = mem_zalloc(sizeof *chunk); - buf_pool->n_chunks = 1; - buf_pool->chunks = chunk = mem_alloc(sizeof *chunk); + UT_LIST_INIT(buf_pool->free); - UT_LIST_INIT(buf_pool->free); + if (!buf_chunk_init(buf_pool, chunk, buf_pool_size)) { + mem_free(chunk); + mem_free(buf_pool); - if (!buf_chunk_init(chunk, srv_buf_pool_size)) { - mem_free(chunk); - mem_free(buf_pool); - buf_pool = NULL; - return(NULL); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); + buf_pool_mutex_exit(buf_pool); + + return(DB_ERROR); + } + + buf_pool->instance_no = instance_no; + buf_pool->old_pool_size = buf_pool_size; + buf_pool->curr_size = chunk->size; + buf_pool->curr_pool_size = buf_pool->curr_size * UNIV_PAGE_SIZE; + + buf_pool->page_hash = hash_create(2 * buf_pool->curr_size); + buf_pool->zip_hash = hash_create(2 * buf_pool->curr_size); + + buf_pool->last_printout_time = ut_time(); } - - srv_buf_pool_old_size = srv_buf_pool_size; - buf_pool->curr_size = chunk->size; - srv_buf_pool_curr_size = buf_pool->curr_size * UNIV_PAGE_SIZE; - - buf_pool->page_hash = hash_create(2 * buf_pool->curr_size); - /* zip_hash is allocated to shm when srv_buffer_pool_shm_key is enabled */ - if (!srv_buffer_pool_shm_key) { - buf_pool->zip_hash = hash_create(2 * buf_pool->curr_size); - } - - buf_pool->last_printout_time = time(NULL); - /* 2. Initialize flushing fields -------------------------------- */ + mutex_create(flush_list_mutex_key, &buf_pool->flush_list_mutex, + SYNC_BUF_FLUSH_LIST); + for (i = BUF_FLUSH_LRU; i < BUF_FLUSH_N_TYPES; i++) { buf_pool->no_flush[i] = os_event_create(NULL); } /* 3. Initialize LRU fields --------------------------- */ + /* All fields are initialized by mem_zalloc(). */ - if (srv_buffer_pool_shm_key) { - buf_shm_info_t* shm_info; + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); + buf_pool_mutex_exit(buf_pool); - ut_a((byte*)chunk->blocks == (byte*)chunk->mem + sizeof(buf_shm_info_t)); - shm_info = chunk->mem; - - buf_pool->zip_hash = (hash_table_t*)((byte*)chunk->mem + shm_info->zip_hash_offset); - - if(shm_info->is_new) { - shm_info->is_new = FALSE; /* initialization was finished */ - } else { - buf_block_t* block = chunk->blocks; - buf_page_t* b; - - /* shm_info->buf_pool_backup should be converted */ - /* at buf_chunk_init(). So copy simply. */ - buf_pool->flush_list = shm_info->buf_pool_backup.flush_list; - buf_pool->freed_page_clock = shm_info->buf_pool_backup.freed_page_clock; - buf_pool->free = shm_info->buf_pool_backup.free; - buf_pool->LRU = shm_info->buf_pool_backup.LRU; - buf_pool->LRU_old = shm_info->buf_pool_backup.LRU_old; - buf_pool->LRU_old_len = shm_info->buf_pool_backup.LRU_old_len; - buf_pool->unzip_LRU = shm_info->buf_pool_backup.unzip_LRU; - buf_pool->zip_clean = shm_info->buf_pool_backup.zip_clean; - for (i = 0; i < BUF_BUDDY_SIZES_MAX; i++) { - buf_pool->zip_free[i] = shm_info->buf_pool_backup.zip_free[i]; - } - - for (i = 0; i < chunk->size; i++, block++) { - if (buf_block_get_state(block) - == BUF_BLOCK_FILE_PAGE) { - ut_d(block->page.in_page_hash = TRUE); - HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, - buf_page_address_fold( - block->page.space, - block->page.offset), - &block->page); - } - } - - for (b = UT_LIST_GET_FIRST(buf_pool->zip_clean); b; - b = UT_LIST_GET_NEXT(zip_list, b)) { - ut_ad(!b->in_flush_list); - ut_ad(b->in_LRU_list); - - ut_d(b->in_page_hash = TRUE); - HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, - buf_page_address_fold(b->space, b->offset), b); - } - - for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; - b = UT_LIST_GET_NEXT(flush_list, b)) { - ut_ad(b->in_flush_list); - ut_ad(b->in_LRU_list); - - switch (buf_page_get_state(b)) { - case BUF_BLOCK_ZIP_DIRTY: - ut_d(b->in_page_hash = TRUE); - HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, - buf_page_address_fold(b->space, - b->offset), b); - break; - case BUF_BLOCK_FILE_PAGE: - /* uncompressed page */ - break; - case BUF_BLOCK_ZIP_FREE: - case BUF_BLOCK_ZIP_PAGE: - case BUF_BLOCK_NOT_USED: - case BUF_BLOCK_READY_FOR_USE: - case BUF_BLOCK_MEMORY: - case BUF_BLOCK_REMOVE_HASH: - ut_error; - break; - } - } - - - } - } - - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); - buf_pool_mutex_exit(); - - btr_search_sys_create(buf_pool->curr_size - * UNIV_PAGE_SIZE / sizeof(void*) / 64); - - /* 4. Initialize the buddy allocator fields */ - /* All fields are initialized by mem_zalloc(). */ - - return(buf_pool); + return(DB_SUCCESS); } /********************************************************************//** -Frees the buffer pool at shutdown. This must not be invoked before -freeing all mutexes. */ -UNIV_INTERN +free one buffer pool instance */ +static void -buf_pool_free(void) -/*===============*/ +buf_pool_free_instance( +/*===================*/ + buf_pool_t* buf_pool) /* in,own: buffer pool instance + to free */ { buf_chunk_t* chunk; buf_chunk_t* chunks; - if (srv_buffer_pool_shm_key) { - buf_shm_info_t* shm_info; - - ut_a(buf_pool->n_chunks == 1); - - chunk = buf_pool->chunks; - shm_info = chunk->mem; - ut_a((byte*)chunk->blocks == (byte*)chunk->mem + sizeof(buf_shm_info_t)); - - /* validation the shared memory segment doesn't have unrecoverable contents. */ - /* Currently, validation became not needed */ - shm_info->reusable = TRUE; - - memcpy(&(shm_info->buf_pool_backup), buf_pool, sizeof(buf_pool_t)); - memcpy(&(shm_info->chunk_backup), chunk, sizeof(buf_chunk_t)); - - if (srv_fast_shutdown < 2) { - if (srv_buffer_pool_shm_checksum) { - shm_info->checksum = ut_fold_binary_32((byte*)chunk->mem + sizeof(buf_shm_info_t), - chunk->mem_size - sizeof(buf_shm_info_t)); - } else { - shm_info->checksum = BUF_NO_CHECKSUM_MAGIC; - } - shm_info->clean = TRUE; - } - - os_shm_free(chunk->mem, chunk->mem_size); - } else { chunks = buf_pool->chunks; chunk = chunks + buf_pool->n_chunks; @@ -1554,15 +1391,143 @@ buf_pool_free(void) would fail at shutdown. */ os_mem_free_large(chunk->mem, chunk->mem_size); } - } mem_free(buf_pool->chunks); hash_table_free(buf_pool->page_hash); - if (!srv_buffer_pool_shm_key) { hash_table_free(buf_pool->zip_hash); +} + +/********************************************************************//** +Creates the buffer pool. +@return DB_SUCCESS if success, DB_ERROR if not enough memory or error */ +UNIV_INTERN +ulint +buf_pool_init( +/*==========*/ + ulint total_size, /*!< in: size of the total pool in bytes */ + ulint n_instances) /*!< in: number of instances */ +{ + ulint i; + const ulint size = total_size / n_instances; + + ut_ad(n_instances > 0); + ut_ad(n_instances <= MAX_BUFFER_POOLS); + ut_ad(n_instances == srv_buf_pool_instances); + + /* We create an extra buffer pool instance, this instance is used + for flushing the flush lists, to keep track of n_flush for all + the buffer pools and also used as a waiting object during flushing. */ + buf_pool_ptr = mem_zalloc(n_instances * sizeof *buf_pool_ptr); + + for (i = 0; i < n_instances; i++) { + buf_pool_t* ptr = &buf_pool_ptr[i]; + + if (buf_pool_init_instance(ptr, size, i) != DB_SUCCESS) { + + /* Free all the instances created so far. */ + buf_pool_free(i); + + return(DB_ERROR); + } + } + + buf_pool_set_sizes(); + buf_LRU_old_ratio_update(100 * 3/ 8, FALSE); + + btr_search_sys_create(buf_pool_get_curr_size() / sizeof(void*) / 64); + + return(DB_SUCCESS); +} + +/********************************************************************//** +Frees the buffer pool at shutdown. This must not be invoked before +freeing all mutexes. */ +UNIV_INTERN +void +buf_pool_free( +/*==========*/ + ulint n_instances) /*!< in: numbere of instances to free */ +{ + ulint i; + + for (i = 0; i < n_instances; i++) { + buf_pool_free_instance(buf_pool_from_array(i)); + } + + mem_free(buf_pool_ptr); + buf_pool_ptr = NULL; +} + +/********************************************************************//** +Drops adaptive hash index for a buffer pool instance. */ +static +void +buf_pool_drop_hash_index_instance( +/*==============================*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + ibool* released_search_latch) /*!< out: flag for signalling + whether the search latch was + released */ +{ + buf_chunk_t* chunks = buf_pool->chunks; + buf_chunk_t* chunk = chunks + buf_pool->n_chunks; + + while (--chunk >= chunks) { + ulint i; + buf_block_t* block = chunk->blocks; + + for (i = chunk->size; i--; block++) { + /* block->is_hashed cannot be modified + when we have an x-latch on btr_search_latch; + see the comment in buf0buf.h */ + + if (!block->is_hashed) { + continue; + } + + /* To follow the latching order, we + have to release btr_search_latch + before acquiring block->latch. */ + btr_search_x_unlock_all(); + /* When we release the search latch, + we must rescan all blocks, because + some may become hashed again. */ + *released_search_latch = TRUE; + + rw_lock_x_lock(&block->lock); + + /* This should be guaranteed by the + callers, which will be holding + btr_search_enabled_mutex. */ + ut_ad(!btr_search_enabled); + + /* Because we did not buffer-fix the + block by calling buf_block_get_gen(), + it is possible that the block has been + allocated for some other use after + btr_search_latch was released above. + We do not care which file page the + block is mapped to. All we want to do + is to drop any hash entries referring + to the page. */ + + /* It is possible that + block->page.state != BUF_FILE_PAGE. + Even that does not matter, because + btr_search_drop_page_hash_index() will + check block->is_hashed before doing + anything. block->is_hashed can only + be set on uncompressed file pages. */ + + btr_search_drop_page_hash_index(block, NULL); + + rw_lock_x_unlock(&block->lock); + + btr_search_x_lock_all(); + + ut_ad(!btr_search_enabled); + } } - mem_free(buf_pool); - buf_pool = NULL; } /********************************************************************//** @@ -1577,74 +1542,28 @@ buf_pool_drop_hash_index(void) ibool released_search_latch; #ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&btr_search_latch, RW_LOCK_EX)); + ulint j; + + for (j = 0; j < btr_search_index_num; j++) { + ut_ad(rw_lock_own(btr_search_latch_part[j], RW_LOCK_EX)); + } #endif /* UNIV_SYNC_DEBUG */ ut_ad(!btr_search_enabled); do { - buf_chunk_t* chunks = buf_pool->chunks; - buf_chunk_t* chunk = chunks + buf_pool->n_chunks; + ulint i; released_search_latch = FALSE; - while (--chunk >= chunks) { - buf_block_t* block = chunk->blocks; - ulint i = chunk->size; + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; - for (; i--; block++) { - /* block->is_hashed cannot be modified - when we have an x-latch on btr_search_latch; - see the comment in buf0buf.h */ + buf_pool = buf_pool_from_array(i); - if (buf_block_get_state(block) - != BUF_BLOCK_FILE_PAGE - || !block->is_hashed) { - continue; - } - - /* To follow the latching order, we - have to release btr_search_latch - before acquiring block->latch. */ - rw_lock_x_unlock(&btr_search_latch); - /* When we release the search latch, - we must rescan all blocks, because - some may become hashed again. */ - released_search_latch = TRUE; - - rw_lock_x_lock(&block->lock); - - /* This should be guaranteed by the - callers, which will be holding - btr_search_enabled_mutex. */ - ut_ad(!btr_search_enabled); - - /* Because we did not buffer-fix the - block by calling buf_block_get_gen(), - it is possible that the block has been - allocated for some other use after - btr_search_latch was released above. - We do not care which file page the - block is mapped to. All we want to do - is to drop any hash entries referring - to the page. */ - - /* It is possible that - block->page.state != BUF_FILE_PAGE. - Even that does not matter, because - btr_search_drop_page_hash_index() will - check block->is_hashed before doing - anything. block->is_hashed can only - be set on uncompressed file pages. */ - - btr_search_drop_page_hash_index(block); - - rw_lock_x_unlock(&block->lock); - - rw_lock_x_lock(&btr_search_latch); - - ut_ad(!btr_search_enabled); - } + buf_pool_drop_hash_index_instance( + buf_pool, &released_search_latch); } + } while (released_search_latch); } @@ -1663,11 +1582,12 @@ buf_relocate( { buf_page_t* b; ulint fold; + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); #ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX)); + ut_ad(rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_EX)); #endif ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_a(buf_page_get_io_fix(bpage) == BUF_IO_NONE); @@ -1675,7 +1595,9 @@ buf_relocate( ut_ad(bpage->in_LRU_list); ut_ad(!bpage->in_zip_hash); ut_ad(bpage->in_page_hash); - ut_ad(bpage == buf_page_hash_get(bpage->space, bpage->offset)); + ut_ad(bpage == buf_page_hash_get(buf_pool, + bpage->space, bpage->offset)); + ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage)); #ifdef UNIV_DEBUG switch (buf_page_get_state(bpage)) { case BUF_BLOCK_ZIP_FREE: @@ -1734,12 +1656,13 @@ buf_relocate( } /********************************************************************//** -Shrinks the buffer pool. */ +Shrinks a buffer pool instance. */ static void -buf_pool_shrink( -/*============*/ - ulint chunk_size) /*!< in: number of pages to remove */ +buf_pool_shrink_instance( +/*=====================*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + ulint chunk_size) /*!< in: number of pages to remove */ { buf_chunk_t* chunks; buf_chunk_t* chunk; @@ -1748,17 +1671,12 @@ buf_pool_shrink( buf_chunk_t* max_chunk; buf_chunk_t* max_free_chunk; - ut_ad(!buf_pool_mutex_own()); + ut_ad(!buf_pool_mutex_own(buf_pool)); try_again: btr_search_disable(); /* Empty the adaptive hash index again */ - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - - if (srv_buffer_pool_shm_key) { - /* Cannot support shrink */ - goto func_done; - } + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); shrink_again: if (buf_pool->n_chunks <= 1) { @@ -1821,7 +1739,7 @@ shrink_again: mutex_enter(&block->mutex); /* The following calls will temporarily - release block->mutex and buf_pool_mutex. + release block->mutex and buf_pool->mutex. Therefore, we have to always retry, even if !dirty && !nonfree. */ @@ -1829,7 +1747,7 @@ shrink_again: buf_LRU_make_block_old(&block->page); dirty++; - } else if (buf_LRU_free_block(&block->page, TRUE, NULL, FALSE) + } else if (buf_LRU_free_block(&block->page, TRUE, TRUE) != BUF_LRU_FREED) { nonfree++; } @@ -1837,8 +1755,8 @@ shrink_again: mutex_exit(&block->mutex); } - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); /* Request for a flush of the chunk if it helps. Do not flush if there are non-free blocks, since @@ -1847,10 +1765,10 @@ shrink_again: /* Avoid busy-waiting. */ os_thread_sleep(100000); } else if (dirty - && buf_flush_batch(BUF_FLUSH_LRU, dirty, 0) - == ULINT_UNDEFINED) { + && buf_flush_LRU(buf_pool, dirty) + == ULINT_UNDEFINED) { - buf_flush_wait_batch_end(BUF_FLUSH_LRU); + buf_flush_wait_batch_end(buf_pool, BUF_FLUSH_LRU); } goto try_again; @@ -1859,7 +1777,7 @@ shrink_again: max_size = max_free_size; max_chunk = max_free_chunk; - srv_buf_pool_old_size = srv_buf_pool_size; + buf_pool->old_pool_size = buf_pool->curr_pool_size; /* Rewrite buf_pool->chunks. Copy everything but max_chunk. */ chunks = mem_alloc((buf_pool->n_chunks - 1) * sizeof *chunks); @@ -1871,9 +1789,9 @@ shrink_again: - (max_chunk + 1)); ut_a(buf_pool->curr_size > max_chunk->size); buf_pool->curr_size -= max_chunk->size; - srv_buf_pool_curr_size = buf_pool->curr_size * UNIV_PAGE_SIZE; + buf_pool->curr_pool_size = buf_pool->curr_size * UNIV_PAGE_SIZE; chunk_size -= max_chunk->size; - buf_chunk_free(max_chunk); + buf_chunk_free(buf_pool, max_chunk); mem_free(buf_pool->chunks); buf_pool->chunks = chunks; buf_pool->n_chunks--; @@ -1883,34 +1801,56 @@ shrink_again: goto shrink_again; } + goto func_exit; func_done: - srv_buf_pool_old_size = srv_buf_pool_size; + buf_pool->old_pool_size = buf_pool->curr_pool_size; func_exit: - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); btr_search_enable(); } /********************************************************************//** -Rebuild buf_pool->page_hash. */ +Shrinks the buffer pool. */ static void -buf_pool_page_hash_rebuild(void) -/*============================*/ +buf_pool_shrink( +/*============*/ + ulint chunk_size) /*!< in: number of pages to remove */ +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + ulint instance_chunk_size; + + instance_chunk_size = chunk_size / srv_buf_pool_instances; + buf_pool = buf_pool_from_array(i); + buf_pool_shrink_instance(buf_pool, instance_chunk_size); + } + + buf_pool_set_sizes(); +} + +/********************************************************************//** +Rebuild buf_pool->page_hash for a buffer pool instance. */ +static +void +buf_pool_page_hash_rebuild_instance( +/*================================*/ + buf_pool_t* buf_pool) /*!< in: buffer pool instance */ { ulint i; - ulint n_chunks; - buf_chunk_t* chunk; - hash_table_t* page_hash; - hash_table_t* zip_hash; buf_page_t* b; + buf_chunk_t* chunk; + ulint n_chunks; + hash_table_t* zip_hash; + hash_table_t* page_hash; - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - rw_lock_x_lock(&page_hash_latch); - mutex_enter(&flush_list_mutex); - + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); /* Free, create, and populate the hash table. */ hash_table_free(buf_pool->page_hash); @@ -1951,6 +1891,7 @@ buf_pool_page_hash_rebuild(void) All such blocks are either in buf_pool->zip_clean or in buf_pool->flush_list. */ + mutex_enter(&buf_pool->zip_mutex); for (b = UT_LIST_GET_FIRST(buf_pool->zip_clean); b; b = UT_LIST_GET_NEXT(zip_list, b)) { ut_a(buf_page_get_state(b) == BUF_BLOCK_ZIP_PAGE); @@ -1962,7 +1903,9 @@ buf_pool_page_hash_rebuild(void) HASH_INSERT(buf_page_t, hash, page_hash, buf_page_address_fold(b->space, b->offset), b); } + mutex_exit(&buf_pool->zip_mutex); + buf_flush_list_mutex_enter(buf_pool); for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; b = UT_LIST_GET_NEXT(flush_list, b)) { ut_ad(b->in_flush_list); @@ -1990,10 +1933,201 @@ buf_pool_page_hash_rebuild(void) } } - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); - mutex_exit(&flush_list_mutex); + buf_flush_list_mutex_exit(buf_pool); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); +} + +/******************************************************************** +Determine if a block is a sentinel for a buffer pool watch. +@return TRUE if a sentinel for a buffer pool watch, FALSE if not */ +UNIV_INTERN +ibool +buf_pool_watch_is_sentinel( +/*=======================*/ + buf_pool_t* buf_pool, /*!< buffer pool instance */ + const buf_page_t* bpage) /*!< in: block */ +{ + ut_ad(buf_page_in_file(bpage)); + + if (bpage < &buf_pool->watch[0] + || bpage >= &buf_pool->watch[BUF_POOL_WATCH_SIZE]) { + + ut_ad(buf_page_get_state(bpage) != BUF_BLOCK_ZIP_PAGE + || bpage->zip.data != NULL); + + return(FALSE); + } + + ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_PAGE); + ut_ad(!bpage->in_zip_hash); + ut_ad(bpage->in_page_hash); + ut_ad(bpage->zip.data == NULL); + ut_ad(bpage->buf_fix_count > 0); + return(TRUE); +} + +/****************************************************************//** +Add watch for the given page to be read in. Caller must have the buffer pool +mutex reserved. +@return NULL if watch set, block if the page is in the buffer pool */ +UNIV_INTERN +buf_page_t* +buf_pool_watch_set( +/*===============*/ + ulint space, /*!< in: space id */ + ulint offset, /*!< in: page number */ + ulint fold) /*!< in: buf_page_address_fold(space, offset) */ +{ + buf_page_t* bpage; + ulint i; + buf_pool_t* buf_pool = buf_pool_get(space, offset); + mutex_t* block_mutex; + + //ut_ad(buf_pool_mutex_own(buf_pool)); + + rw_lock_x_lock(&buf_pool->page_hash_latch); + bpage = buf_page_hash_get_low(buf_pool, space, offset, fold); + if (bpage) { + block_mutex = buf_page_get_mutex_enter(bpage); + ut_a(block_mutex); + } + + if (UNIV_LIKELY_NULL(bpage)) { + if (!buf_pool_watch_is_sentinel(buf_pool, bpage)) { + /* The page was loaded meanwhile. */ + rw_lock_x_unlock(&buf_pool->page_hash_latch); + return(bpage); + } + /* Add to an existing watch. */ + bpage->buf_fix_count++; + rw_lock_x_unlock(&buf_pool->page_hash_latch); + mutex_exit(block_mutex); + return(NULL); + } + + /* buf_pool->watch is protected by zip_mutex for now */ + mutex_enter(&buf_pool->zip_mutex); + for (i = 0; i < BUF_POOL_WATCH_SIZE; i++) { + bpage = &buf_pool->watch[i]; + + ut_ad(bpage->access_time == 0); + ut_ad(bpage->newest_modification == 0); + ut_ad(bpage->oldest_modification == 0); + ut_ad(bpage->zip.data == NULL); + ut_ad(!bpage->in_zip_hash); + + switch (bpage->state) { + case BUF_BLOCK_POOL_WATCH: + ut_ad(!bpage->in_page_hash); + ut_ad(bpage->buf_fix_count == 0); + + /* bpage is pointing to buf_pool->watch[], + which is protected by buf_pool->mutex. + Normally, buf_page_t objects are protected by + buf_block_t::mutex or buf_pool->zip_mutex or both. */ + + bpage->state = BUF_BLOCK_ZIP_PAGE; + bpage->space = space; + bpage->offset = offset; + bpage->buf_fix_count = 1; + bpage->buf_pool_index = buf_pool_index(buf_pool); + ut_d(bpage->in_page_hash = TRUE); + HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, + fold, bpage); + rw_lock_x_unlock(&buf_pool->page_hash_latch); + mutex_exit(&buf_pool->zip_mutex); + return(NULL); + case BUF_BLOCK_ZIP_PAGE: + ut_ad(bpage->in_page_hash); + ut_ad(bpage->buf_fix_count > 0); + break; + default: + ut_error; + } + } + + /* Allocation failed. Either the maximum number of purge + threads should never exceed BUF_POOL_WATCH_SIZE, or this code + should be modified to return a special non-NULL value and the + caller should purge the record directly. */ + ut_error; + + /* Fix compiler warning */ + rw_lock_x_unlock(&buf_pool->page_hash_latch); + mutex_exit(&buf_pool->zip_mutex); + return(NULL); +} + +/********************************************************************//** +Rebuild buf_pool->page_hash. */ +static +void +buf_pool_page_hash_rebuild(void) +/*============================*/ +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_page_hash_rebuild_instance(buf_pool_from_array(i)); + } +} + +/********************************************************************//** +Increase the buffer pool size of one buffer pool instance. */ +static +void +buf_pool_increase_instance( +/*=======================*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instane */ + ulint change_size) /*!< in: new size of the pool */ +{ + buf_chunk_t* chunks; + buf_chunk_t* chunk; + + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); + buf_pool_mutex_enter(buf_pool); + chunks = mem_alloc((buf_pool->n_chunks + 1) * sizeof *chunks); + + memcpy(chunks, buf_pool->chunks, buf_pool->n_chunks * sizeof *chunks); + + chunk = &chunks[buf_pool->n_chunks]; + + if (!buf_chunk_init(buf_pool, chunk, change_size)) { + mem_free(chunks); + } else { + buf_pool->old_pool_size = buf_pool->curr_pool_size; + buf_pool->curr_size += chunk->size; + buf_pool->curr_pool_size = buf_pool->curr_size * UNIV_PAGE_SIZE; + mem_free(buf_pool->chunks); + buf_pool->chunks = chunks; + buf_pool->n_chunks++; + } + + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); + buf_pool_mutex_exit(buf_pool); +} + +/********************************************************************//** +Increase the buffer pool size. */ +static +void +buf_pool_increase( +/*==============*/ + ulint change_size) +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_increase_instance( + buf_pool_from_array(i), + change_size / srv_buf_pool_instances); + } + + buf_pool_set_sizes(); } /********************************************************************//** @@ -2003,63 +2137,146 @@ void buf_pool_resize(void) /*=================*/ { - if (srv_buffer_pool_shm_key) { - /* Cannot support resize */ + ulint change_size; + ulint min_change_size = 1048576 * srv_buf_pool_instances; + + buf_pool_mutex_enter_all(); + + if (srv_buf_pool_old_size == srv_buf_pool_size) { + + buf_pool_mutex_exit_all(); + + return; + + } else if (srv_buf_pool_curr_size + min_change_size + > srv_buf_pool_size) { + + change_size = (srv_buf_pool_curr_size - srv_buf_pool_size) + / UNIV_PAGE_SIZE; + + buf_pool_mutex_exit_all(); + + /* Disable adaptive hash indexes and empty the index + in order to free up memory in the buffer pool chunks. */ + buf_pool_shrink(change_size); + + } else if (srv_buf_pool_curr_size + min_change_size + < srv_buf_pool_size) { + + /* Enlarge the buffer pool by at least one megabyte */ + + change_size = srv_buf_pool_size - srv_buf_pool_curr_size; + + buf_pool_mutex_exit_all(); + + buf_pool_increase(change_size); + } else { + srv_buf_pool_size = srv_buf_pool_old_size; + + buf_pool_mutex_exit_all(); + return; } - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + buf_pool_page_hash_rebuild(); +} - if (srv_buf_pool_old_size == srv_buf_pool_size) { +/****************************************************************//** +Remove the sentinel block for the watch before replacing it with a real block. +buf_page_watch_clear() or buf_page_watch_occurred() will notice that +the block has been replaced with the real block. +@return reference count, to be added to the replacement block */ +static +void +buf_pool_watch_remove( +/*==================*/ + buf_pool_t* buf_pool, /*!< buffer pool instance */ + ulint fold, /*!< in: buf_page_address_fold( + space, offset) */ + buf_page_t* watch) /*!< in/out: sentinel for watch */ +{ + //ut_ad(buf_pool_mutex_own(buf_pool)); +#ifdef UNIV_SYNC_DEBUG + ut_ad(rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_EX)); +#endif + ut_ad(mutex_own(&buf_pool->zip_mutex)); /* for now */ - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - return; - } + HASH_DELETE(buf_page_t, hash, buf_pool->page_hash, fold, watch); + ut_d(watch->in_page_hash = FALSE); + watch->buf_fix_count = 0; + watch->state = BUF_BLOCK_POOL_WATCH; +} - if (srv_buf_pool_curr_size + 1048576 > srv_buf_pool_size) { +/****************************************************************//** +Stop watching if the page has been read in. +buf_pool_watch_set(space,offset) must have returned NULL before. */ +UNIV_INTERN +void +buf_pool_watch_unset( +/*=================*/ + ulint space, /*!< in: space id */ + ulint offset) /*!< in: page number */ +{ + buf_page_t* bpage; + buf_pool_t* buf_pool = buf_pool_get(space, offset); + ulint fold = buf_page_address_fold(space, offset); - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_enter(buf_pool); + rw_lock_x_lock(&buf_pool->page_hash_latch); + bpage = buf_page_hash_get_low(buf_pool, space, offset, fold); + /* The page must exist because buf_pool_watch_set() + increments buf_fix_count. */ + ut_a(bpage); - /* Disable adaptive hash indexes and empty the index - in order to free up memory in the buffer pool chunks. */ - buf_pool_shrink((srv_buf_pool_curr_size - srv_buf_pool_size) - / UNIV_PAGE_SIZE); - } else if (srv_buf_pool_curr_size + 1048576 < srv_buf_pool_size) { + if (UNIV_UNLIKELY(!buf_pool_watch_is_sentinel(buf_pool, bpage))) { + mutex_t* mutex = buf_page_get_mutex_enter(bpage); - /* Enlarge the buffer pool by at least one megabyte */ + ut_a(bpage->buf_fix_count > 0); + bpage->buf_fix_count--; + mutex_exit(mutex); + } else { + mutex_enter(&buf_pool->zip_mutex); + ut_a(bpage->buf_fix_count > 0); - ulint mem_size - = srv_buf_pool_size - srv_buf_pool_curr_size; - buf_chunk_t* chunks; - buf_chunk_t* chunk; - - chunks = mem_alloc((buf_pool->n_chunks + 1) * sizeof *chunks); - - memcpy(chunks, buf_pool->chunks, buf_pool->n_chunks - * sizeof *chunks); - - chunk = &chunks[buf_pool->n_chunks]; - - if (!buf_chunk_init(chunk, mem_size)) { - mem_free(chunks); - } else { - buf_pool->curr_size += chunk->size; - srv_buf_pool_curr_size = buf_pool->curr_size - * UNIV_PAGE_SIZE; - mem_free(buf_pool->chunks); - buf_pool->chunks = chunks; - buf_pool->n_chunks++; + if (UNIV_LIKELY(!--bpage->buf_fix_count)) { + buf_pool_watch_remove(buf_pool, fold, bpage); } - - srv_buf_pool_old_size = srv_buf_pool_size; - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + mutex_exit(&buf_pool->zip_mutex); } - buf_pool_page_hash_rebuild(); + //buf_pool_mutex_exit(buf_pool); + rw_lock_x_unlock(&buf_pool->page_hash_latch); +} + +/****************************************************************//** +Check if the page has been read in. +This may only be called after buf_pool_watch_set(space,offset) +has returned NULL and before invoking buf_pool_watch_unset(space,offset). +@return FALSE if the given page was not read in, TRUE if it was */ +UNIV_INTERN +ibool +buf_pool_watch_occurred( +/*====================*/ + ulint space, /*!< in: space id */ + ulint offset) /*!< in: page number */ +{ + ibool ret; + buf_page_t* bpage; + buf_pool_t* buf_pool = buf_pool_get(space, offset); + ulint fold = buf_page_address_fold(space, offset); + + //buf_pool_mutex_enter(buf_pool); + rw_lock_s_lock(&buf_pool->page_hash_latch); + + bpage = buf_page_hash_get_low(buf_pool, space, offset, fold); + /* The page must exist because buf_pool_watch_set() + increments buf_fix_count. */ + ut_a(bpage); + ret = !buf_pool_watch_is_sentinel(buf_pool, bpage); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); + + return(ret); } /********************************************************************//** @@ -2072,15 +2289,17 @@ buf_page_make_young( /*================*/ buf_page_t* bpage) /*!< in: buffer block of a file page */ { - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); ut_a(buf_page_in_file(bpage)); buf_LRU_make_block_young(bpage); - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); } /********************************************************************//** @@ -2098,24 +2317,26 @@ buf_page_set_accessed_make_young( read under mutex protection, or 0 if unknown */ { - ut_ad(!buf_pool_mutex_own()); + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + + ut_ad(!buf_pool_mutex_own(buf_pool)); ut_a(buf_page_in_file(bpage)); if (buf_page_peek_if_too_old(bpage)) { - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); buf_LRU_make_block_young(bpage); - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); } else if (!access_time) { ulint time_ms = ut_time_ms(); mutex_t* block_mutex = buf_page_get_mutex_enter(bpage); - //buf_pool_mutex_enter(); + //buf_pool_mutex_enter(buf_pool); if (block_mutex) { buf_page_set_accessed(bpage, time_ms); mutex_exit(block_mutex); } - //buf_pool_mutex_exit(); + //buf_pool_mutex_exit(buf_pool); } } @@ -2130,18 +2351,20 @@ buf_reset_check_index_page_at_flush( ulint offset) /*!< in: page number */ { buf_block_t* block; + buf_pool_t* buf_pool = buf_pool_get(space, offset); - //buf_pool_mutex_enter(); - rw_lock_s_lock(&page_hash_latch); + //buf_pool_mutex_enter(buf_pool); + rw_lock_s_lock(&buf_pool->page_hash_latch); - block = (buf_block_t*) buf_page_hash_get(space, offset); + block = (buf_block_t*) buf_page_hash_get(buf_pool, space, offset); if (block && buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE) { + ut_ad(!buf_pool_watch_is_sentinel(buf_pool, &block->page)); block->check_index_page_at_flush = FALSE; } - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); } /********************************************************************//** @@ -2158,25 +2381,27 @@ buf_page_peek_if_search_hashed( { buf_block_t* block; ibool is_hashed; + buf_pool_t* buf_pool = buf_pool_get(space, offset); - //buf_pool_mutex_enter(); - rw_lock_s_lock(&page_hash_latch); + //buf_pool_mutex_enter(buf_pool); + rw_lock_s_lock(&buf_pool->page_hash_latch); - block = (buf_block_t*) buf_page_hash_get(space, offset); + block = (buf_block_t*) buf_page_hash_get(buf_pool, space, offset); if (!block || buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE) { is_hashed = FALSE; } else { + ut_ad(!buf_pool_watch_is_sentinel(buf_pool, &block->page)); is_hashed = block->is_hashed; } - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); return(is_hashed); } -#ifdef UNIV_DEBUG_FILE_ACCESSES +#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG /********************************************************************//** Sets file_page_was_freed TRUE if the page is found in the buffer pool. This function should be called when we free a file page and want the @@ -2191,18 +2416,22 @@ buf_page_set_file_page_was_freed( ulint offset) /*!< in: page number */ { buf_page_t* bpage; + buf_pool_t* buf_pool = buf_pool_get(space, offset); - //buf_pool_mutex_enter(); - rw_lock_s_lock(&page_hash_latch); + //buf_pool_mutex_enter(buf_pool); + rw_lock_s_lock(&buf_pool->page_hash_latch); - bpage = buf_page_hash_get(space, offset); + bpage = buf_page_hash_get(buf_pool, space, offset); if (bpage) { + ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage)); + /* bpage->file_page_was_freed can already hold + when this code is invoked from dict_drop_index_tree() */ bpage->file_page_was_freed = TRUE; } - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); return(bpage); } @@ -2221,22 +2450,24 @@ buf_page_reset_file_page_was_freed( ulint offset) /*!< in: page number */ { buf_page_t* bpage; + buf_pool_t* buf_pool = buf_pool_get(space, offset); - //buf_pool_mutex_enter(); - rw_lock_s_lock(&page_hash_latch); + //buf_pool_mutex_enter(buf_pool); + rw_lock_s_lock(&buf_pool->page_hash_latch); - bpage = buf_page_hash_get(space, offset); + bpage = buf_page_hash_get(buf_pool, space, offset); if (bpage) { + ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage)); bpage->file_page_was_freed = FALSE; } - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); return(bpage); } -#endif /* UNIV_DEBUG_FILE_ACCESSES */ +#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */ /********************************************************************//** Get read access to a compressed page (usually of type @@ -2264,28 +2495,27 @@ buf_page_get_zip( ulint ms; ib_uint64_t start_time; ib_uint64_t finish_time; + buf_pool_t* buf_pool = buf_pool_get(space, offset); -#ifndef UNIV_LOG_DEBUG - ut_ad(!ibuf_inside()); -#endif if (innobase_get_slow_log()) { trx = innobase_get_trx(); } buf_pool->stat.n_page_gets++; for (;;) { - //buf_pool_mutex_enter(); + //buf_pool_mutex_enter(buf_pool); lookup: - rw_lock_s_lock(&page_hash_latch); - bpage = buf_page_hash_get(space, offset); + rw_lock_s_lock(&buf_pool->page_hash_latch); + bpage = buf_page_hash_get(buf_pool, space, offset); if (bpage) { + ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage)); break; } /* Page not in buf_pool: needs to be read from file */ - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); buf_read_page(space, zip_size, offset, trx); @@ -2297,22 +2527,23 @@ lookup: if (UNIV_UNLIKELY(!bpage->zip.data)) { /* There is no compressed page. */ err_exit: - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); return(NULL); } - if (srv_pass_corrupt_table) { + if (srv_pass_corrupt_table <= 1) { if (bpage->is_corrupt) { - rw_lock_s_unlock(&page_hash_latch); + rw_lock_s_unlock(&buf_pool->page_hash_latch); return(NULL); } } - ut_a(!(bpage->is_corrupt)); block_mutex = buf_page_get_mutex_enter(bpage); - rw_lock_s_unlock(&page_hash_latch); + rw_lock_s_unlock(&buf_pool->page_hash_latch); + + ut_ad(!buf_pool_watch_is_sentinel(buf_pool, bpage)); switch (buf_page_get_state(bpage)) { case BUF_BLOCK_NOT_USED: @@ -2325,20 +2556,38 @@ err_exit: break; case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_DIRTY: - ut_a(block_mutex == &buf_pool_zip_mutex); + ut_a(block_mutex == &buf_pool->zip_mutex); bpage->buf_fix_count++; goto got_block; case BUF_BLOCK_FILE_PAGE: ut_a(block_mutex == &((buf_block_t*) bpage)->mutex); - /* Discard the uncompressed page frame if possible. */ - if (buf_LRU_free_block(bpage, FALSE, NULL, FALSE) - == BUF_LRU_FREED) { + /* release mutex to obey to latch-order */ + mutex_exit(block_mutex); + /* get LRU_list_mutex for buf_LRU_free_block() */ + mutex_enter(&buf_pool->LRU_list_mutex); + mutex_enter(block_mutex); + + if (UNIV_UNLIKELY(bpage->space != space + || bpage->offset != offset + || !bpage->in_LRU_list + || !bpage->zip.data)) { + /* someone should interrupt, retry */ + mutex_exit(&buf_pool->LRU_list_mutex); mutex_exit(block_mutex); goto lookup; } + /* Discard the uncompressed page frame if possible. */ + if (buf_LRU_free_block(bpage, FALSE, TRUE) == BUF_LRU_FREED) { + mutex_exit(&buf_pool->LRU_list_mutex); + mutex_exit(block_mutex); + goto lookup; + } + + mutex_exit(&buf_pool->LRU_list_mutex); + buf_block_buf_fix_inc((buf_block_t*) bpage, __FILE__, __LINE__); goto got_block; @@ -2351,13 +2600,13 @@ got_block: must_read = buf_page_get_io_fix(bpage) == BUF_IO_READ; access_time = buf_page_is_accessed(bpage); - //buf_pool_mutex_exit(); + //buf_pool_mutex_exit(buf_pool); mutex_exit(block_mutex); buf_page_set_accessed_make_young(bpage, access_time); -#ifdef UNIV_DEBUG_FILE_ACCESSES +#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG ut_a(!bpage->file_page_was_freed); #endif @@ -2417,6 +2666,7 @@ buf_block_init_low( { block->check_index_page_at_flush = FALSE; block->index = NULL; + block->btr_search_latch = NULL; block->n_hash_helps = 0; block->is_hashed = FALSE; @@ -2494,13 +2744,16 @@ buf_zip_decompress( #ifndef UNIV_HOTBACKUP /*******************************************************************//** -Gets the block to whose frame the pointer is pointing to. -@return pointer to block, never NULL */ +Gets the block to whose frame the pointer is pointing to if found +in this buffer pool instance. +@return pointer to block */ UNIV_INTERN buf_block_t* -buf_block_align( -/*============*/ - const byte* ptr) /*!< in: pointer to a frame */ +buf_block_align_instance( +/*=====================*/ + buf_pool_t* buf_pool, /*!< in: buffer in which the block + resides */ + const byte* ptr) /*!< in: pointer to a frame */ { buf_chunk_t* chunk; ulint i; @@ -2508,16 +2761,19 @@ buf_block_align( /* TODO: protect buf_pool->chunks with a mutex (it will currently remain constant after buf_pool_init()) */ for (chunk = buf_pool->chunks, i = buf_pool->n_chunks; i--; chunk++) { - lint offs = ptr - chunk->blocks->frame; + ulint offs; - if (UNIV_UNLIKELY(offs < 0)) { + if (UNIV_UNLIKELY(ptr < chunk->blocks->frame)) { continue; } + /* else */ + + offs = ptr - chunk->blocks->frame; offs >>= UNIV_PAGE_SIZE_SHIFT; - if (UNIV_LIKELY((ulint) offs < chunk->size)) { + if (UNIV_LIKELY(offs < chunk->size)) { buf_block_t* block = &chunk->blocks[offs]; /* The function buf_chunk_init() invokes @@ -2526,7 +2782,7 @@ buf_block_align( ut_ad(block->frame == page_align(ptr)); #ifdef UNIV_DEBUG /* A thread that updates these fields must - hold buf_pool_mutex and block->mutex. Acquire + hold buf_pool->mutex and block->mutex. Acquire only the latter. */ mutex_enter(&block->mutex); @@ -2575,6 +2831,30 @@ buf_block_align( } } + return(NULL); +} + +/*******************************************************************//** +Gets the block to whose frame the pointer is pointing to. +@return pointer to block, never NULL */ +UNIV_INTERN +buf_block_t* +buf_block_align( +/*============*/ + const byte* ptr) /*!< in: pointer to a frame */ +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_block_t* block; + + block = buf_block_align_instance( + buf_pool_from_array(i), ptr); + if (block) { + return(block); + } + } + /* The block should always be found. */ ut_error; return(NULL); @@ -2582,14 +2862,15 @@ buf_block_align( /********************************************************************//** Find out if a pointer belongs to a buf_block_t. It can be a pointer to -the buf_block_t itself or a member of it +the buf_block_t itself or a member of it. This functions checks one of +the buffer pool instances. @return TRUE if ptr belongs to a buf_block_t struct */ -UNIV_INTERN +static ibool -buf_pointer_is_block_field( -/*=======================*/ - const void* ptr) /*!< in: pointer not - dereferenced */ +buf_pointer_is_block_field_instance( +/*================================*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + const void* ptr) /*!< in: pointer not dereferenced */ { const buf_chunk_t* chunk = buf_pool->chunks; const buf_chunk_t* const echunk = chunk + buf_pool->n_chunks; @@ -2609,6 +2890,31 @@ buf_pointer_is_block_field( return(FALSE); } +/********************************************************************//** +Find out if a pointer belongs to a buf_block_t. It can be a pointer to +the buf_block_t itself or a member of it +@return TRUE if ptr belongs to a buf_block_t struct */ +UNIV_INTERN +ibool +buf_pointer_is_block_field( +/*=======================*/ + const void* ptr) /*!< in: pointer not dereferenced */ +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + ibool found; + + found = buf_pointer_is_block_field_instance( + buf_pool_from_array(i), ptr); + if (found) { + return(TRUE); + } + } + + return(FALSE); +} + /********************************************************************//** Find out if a buffer block was created by buf_chunk_init(). @return TRUE if "block" has been added to buf_pool->free by buf_chunk_init() */ @@ -2616,17 +2922,18 @@ static ibool buf_block_is_uncompressed( /*======================*/ - const buf_block_t* block) /*!< in: pointer to block, - not dereferenced */ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + const buf_block_t* block) /*!< in: pointer to block, + not dereferenced */ { - //ut_ad(buf_pool_mutex_own()); + //ut_ad(buf_pool_mutex_own(buf_pool)); if (UNIV_UNLIKELY((((ulint) block) % sizeof *block) != 0)) { /* The pointer should be aligned. */ return(FALSE); } - return(buf_pointer_is_block_field((void *)block)); + return(buf_pointer_is_block_field_instance(buf_pool, (void *)block)); } /********************************************************************//** @@ -2643,43 +2950,61 @@ buf_page_get_gen( ulint rw_latch,/*!< in: RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH */ buf_block_t* guess, /*!< in: guessed block or NULL */ ulint mode, /*!< in: BUF_GET, BUF_GET_IF_IN_POOL, - BUF_GET_NO_LATCH */ + BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or + BUF_GET_IF_IN_POOL_OR_WATCH */ const char* file, /*!< in: file name */ ulint line, /*!< in: line where called */ mtr_t* mtr) /*!< in: mini-transaction */ { buf_block_t* block; + ulint fold; unsigned access_time; ulint fix_type; ibool must_read; ulint retries = 0; - mutex_t* block_mutex; - trx_t* trx = NULL; - ulint sec; - ulint ms; - ib_uint64_t start_time; - ib_uint64_t finish_time; + mutex_t* block_mutex = NULL; + trx_t* trx = NULL; + ulint sec; + ulint ms; + ib_uint64_t start_time; + ib_uint64_t finish_time; + buf_pool_t* buf_pool = buf_pool_get(space, offset); ut_ad(mtr); ut_ad(mtr->state == MTR_ACTIVE); ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH) || (rw_latch == RW_NO_LATCH)); - ut_ad((mode != BUF_GET_NO_LATCH) || (rw_latch == RW_NO_LATCH)); - ut_ad((mode == BUF_GET) || (mode == BUF_GET_IF_IN_POOL) - || (mode == BUF_GET_NO_LATCH)); +#ifdef UNIV_DEBUG + switch (mode) { + case BUF_GET_NO_LATCH: + ut_ad(rw_latch == RW_NO_LATCH); + break; + case BUF_GET: + case BUF_GET_IF_IN_POOL: + case BUF_PEEK_IF_IN_POOL: + case BUF_GET_IF_IN_POOL_OR_WATCH: + case BUF_GET_POSSIBLY_FREED: + break; + default: + ut_error; + } +#endif /* UNIV_DEBUG */ ut_ad(zip_size == fil_space_get_zip_size(space)); ut_ad(ut_is_2pow(zip_size)); #ifndef UNIV_LOG_DEBUG - ut_ad(!ibuf_inside() || ibuf_page(space, zip_size, offset, NULL)); + ut_ad(!ibuf_inside(mtr) + || ibuf_page_low(space, zip_size, offset, + FALSE, file, line, NULL)); #endif if (innobase_get_slow_log()) { trx = innobase_get_trx(); } buf_pool->stat.n_page_gets++; + fold = buf_page_address_fold(space, offset); loop: block = guess; - //buf_pool_mutex_enter(); + //buf_pool_mutex_enter(buf_pool); if (block) { block_mutex = buf_page_get_mutex_enter((buf_page_t*)block); @@ -2694,7 +3019,7 @@ loop: if (!block_mutex) { block = guess = NULL; - } else if (!buf_block_is_uncompressed(block) + } else if (!buf_block_is_uncompressed(buf_pool, block) || offset != block->page.offset || space != block->page.space || buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE) { @@ -2709,22 +3034,42 @@ loop: } if (block == NULL) { - rw_lock_s_lock(&page_hash_latch); - block = (buf_block_t*) buf_page_hash_get(space, offset); + rw_lock_s_lock(&buf_pool->page_hash_latch); + block = (buf_block_t*) buf_page_hash_get_low( + buf_pool, space, offset, fold); if (block) { block_mutex = buf_page_get_mutex_enter((buf_page_t*)block); ut_a(block_mutex); } - rw_lock_s_unlock(&page_hash_latch); + rw_lock_s_unlock(&buf_pool->page_hash_latch); } loop2: + if (block && buf_pool_watch_is_sentinel(buf_pool, &block->page)) { + mutex_exit(block_mutex); + block = NULL; + } + if (block == NULL) { /* Page not in buf_pool: needs to be read from file */ - //buf_pool_mutex_exit(); + if (mode == BUF_GET_IF_IN_POOL_OR_WATCH) { + block = (buf_block_t*) buf_pool_watch_set( + space, offset, fold); - if (mode == BUF_GET_IF_IN_POOL) { + if (UNIV_LIKELY_NULL(block)) { + block_mutex = buf_page_get_mutex((buf_page_t*)block); + ut_a(block_mutex); + ut_ad(mutex_own(block_mutex)); + goto got_block; + } + } + + //buf_pool_mutex_exit(buf_pool); + + if (mode == BUF_GET_IF_IN_POOL + || mode == BUF_PEEK_IF_IN_POOL + || mode == BUF_GET_IF_IN_POOL_OR_WATCH) { return(NULL); } @@ -2759,32 +3104,36 @@ loop2: goto loop; } +got_block: ut_ad(page_zip_get_size(&block->page.zip) == zip_size); must_read = buf_block_get_io_fix(block) == BUF_IO_READ; - if (must_read && mode == BUF_GET_IF_IN_POOL) { - /* The page is only being read to buffer */ - //buf_pool_mutex_exit(); + if (must_read && (mode == BUF_GET_IF_IN_POOL + || mode == BUF_PEEK_IF_IN_POOL)) { + + /* The page is being read to buffer pool, + but we cannot wait around for the read to + complete. */ + //buf_pool_mutex_exit(buf_pool); mutex_exit(block_mutex); return(NULL); } - if (srv_pass_corrupt_table) { + if (srv_pass_corrupt_table <= 1) { if (block->page.is_corrupt) { mutex_exit(block_mutex); return(NULL); } } - ut_a(!(block->page.is_corrupt)); switch (buf_block_get_state(block)) { buf_page_t* bpage; ibool success; case BUF_BLOCK_FILE_PAGE: - if (block_mutex == &buf_pool_zip_mutex) { + if (block_mutex == &buf_pool->zip_mutex) { /* it is wrong mutex... */ mutex_exit(block_mutex); goto loop; @@ -2793,22 +3142,21 @@ loop2: case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_DIRTY: - ut_ad(block_mutex == &buf_pool_zip_mutex); + ut_ad(block_mutex == &buf_pool->zip_mutex); bpage = &block->page; /* Protect bpage->buf_fix_count. */ - /* Already proteced here. */ - //mutex_enter(&buf_pool_zip_mutex); + //mutex_enter(&buf_pool->zip_mutex); if (bpage->buf_fix_count || buf_page_get_io_fix(bpage) != BUF_IO_NONE) { /* This condition often occurs when the buffer is not buffer-fixed, but I/O-fixed by buf_page_init_for_read(). */ - //mutex_exit(&buf_pool_zip_mutex); + //mutex_exit(&buf_pool->zip_mutex); wait_until_unfixed: /* The block is buffer-fixed or I/O-fixed. Try again later. */ - //buf_pool_mutex_exit(); + //buf_pool_mutex_exit(buf_pool); mutex_exit(block_mutex); os_thread_sleep(WAIT_FOR_READ); @@ -2816,26 +3164,28 @@ wait_until_unfixed: } /* Allocate an uncompressed page. */ - //buf_pool_mutex_exit(); - //mutex_exit(&buf_pool_zip_mutex); + //buf_pool_mutex_exit(buf_pool); + //mutex_exit(&buf_pool->zip_mutex); mutex_exit(block_mutex); - block = buf_LRU_get_free_block(0); + block = buf_LRU_get_free_block(buf_pool); ut_a(block); block_mutex = &block->mutex; - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - rw_lock_x_lock(&page_hash_latch); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); mutex_enter(block_mutex); { - buf_page_t* hash_bpage - = buf_page_hash_get(space, offset); + buf_page_t* hash_bpage; + + hash_bpage = buf_page_hash_get_low( + buf_pool, space, offset, fold); if (UNIV_UNLIKELY(bpage != hash_bpage)) { /* The buf_pool->page_hash was modified - while buf_pool_mutex was released. + while buf_pool->mutex was released. Free the block that was allocated. */ buf_LRU_block_free_non_file_page(block, TRUE); @@ -2846,40 +3196,38 @@ wait_until_unfixed: block_mutex = buf_page_get_mutex_enter((buf_page_t*)block); ut_a(block_mutex); } - rw_lock_x_unlock(&page_hash_latch); - mutex_exit(&LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); + mutex_exit(&buf_pool->LRU_list_mutex); goto loop2; } } - mutex_enter(&buf_pool_zip_mutex); + mutex_enter(&buf_pool->zip_mutex); if (UNIV_UNLIKELY (bpage->buf_fix_count || buf_page_get_io_fix(bpage) != BUF_IO_NONE)) { - mutex_exit(&buf_pool_zip_mutex); + mutex_exit(&buf_pool->zip_mutex); /* The block was buffer-fixed or I/O-fixed - while buf_pool_mutex was not held by this thread. + while buf_pool->mutex was not held by this thread. Free the block that was allocated and try again. This should be extremely unlikely. */ buf_LRU_block_free_non_file_page(block, TRUE); //mutex_exit(&block->mutex); - rw_lock_x_unlock(&page_hash_latch); - mutex_exit(&LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); + mutex_exit(&buf_pool->LRU_list_mutex); goto wait_until_unfixed; } /* Move the compressed page from bpage to block, and uncompress it. */ - mutex_enter(&flush_list_mutex); - buf_relocate(bpage, &block->page); - rw_lock_x_unlock(&page_hash_latch); + rw_lock_x_unlock(&buf_pool->page_hash_latch); buf_block_init_low(block); block->lock_hash_val = lock_rec_hash(space, offset); @@ -2898,8 +3246,6 @@ wait_until_unfixed: &block->page); } - mutex_exit(&flush_list_mutex); - /* Buffer-fix, I/O-fix, and X-latch the block for the duration of the decompression. Also add the block to the unzip_LRU list. */ @@ -2908,7 +3254,7 @@ wait_until_unfixed: /* Insert at the front of unzip_LRU list */ buf_unzip_LRU_add_block(block, FALSE); - mutex_exit(&LRU_list_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); block->page.buf_fix_count = 1; buf_block_set_io_fix(block, BUF_IO_READ); @@ -2917,18 +3263,19 @@ wait_until_unfixed: UNIV_MEM_INVALID(bpage, sizeof *bpage); mutex_exit(block_mutex); - mutex_exit(&buf_pool_zip_mutex); + mutex_exit(&buf_pool->zip_mutex); - mutex_enter(&buf_pool_mutex); + buf_pool_mutex_enter(buf_pool); buf_pool->n_pend_unzip++; - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); - buf_buddy_free(bpage, sizeof *bpage, FALSE); + bpage->state = BUF_BLOCK_ZIP_FREE; + buf_buddy_free(buf_pool, bpage, sizeof *bpage, FALSE); - //buf_pool_mutex_exit(); + //buf_pool_mutex_exit(buf_pool); /* Decompress the page and apply buffered operations - while not holding buf_pool_mutex or block->mutex. */ + while not holding buf_pool->mutex or block->mutex. */ success = buf_zip_decompress(block, srv_use_checksums); ut_a(success); @@ -2938,16 +3285,17 @@ wait_until_unfixed: } /* Unfix and unlatch the block. */ - //buf_pool_mutex_enter(); + //buf_pool_mutex_enter(buf_pool); block_mutex = &block->mutex; mutex_enter(block_mutex); block->page.buf_fix_count--; buf_block_set_io_fix(block, BUF_IO_NONE); - mutex_enter(&buf_pool_mutex); + buf_pool_mutex_enter(buf_pool); buf_pool->n_pend_unzip--; - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); rw_lock_x_unlock(&block->lock); + break; case BUF_BLOCK_ZIP_FREE: @@ -2968,23 +3316,66 @@ wait_until_unfixed: bytes. */ UNIV_MEM_ASSERT_RW(&block->page, sizeof block->page); #endif +#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG + if ((mode == BUF_GET_IF_IN_POOL || mode == BUF_GET_IF_IN_POOL_OR_WATCH) + && ibuf_debug) { + /* Try to evict the block from the buffer pool, to use the + insert buffer (change buffer) as much as possible. */ + + if (buf_LRU_free_block(&block->page, TRUE, FALSE) == BUF_LRU_FREED) { + mutex_exit(block_mutex); + if (mode == BUF_GET_IF_IN_POOL_OR_WATCH) { + /* Set the watch, as it would have + been set if the page were not in the + buffer pool in the first place. */ + block = (buf_block_t*) buf_pool_watch_set( + space, offset, fold); + + if (UNIV_LIKELY_NULL(block)) { + block_mutex = buf_page_get_mutex((buf_page_t*)block); + ut_a(block_mutex); + ut_ad(mutex_own(block_mutex)); + + /* The page entered the buffer + pool for some reason. Try to + evict it again. */ + goto got_block; + } + } + //buf_pool_mutex_exit(buf_pool); + fprintf(stderr, + "innodb_change_buffering_debug evict %u %u\n", + (unsigned) space, (unsigned) offset); + return(NULL); + } else if (buf_flush_page_try(buf_pool, block)) { + fprintf(stderr, + "innodb_change_buffering_debug flush %u %u\n", + (unsigned) space, (unsigned) offset); + guess = block; + goto loop; + } + + /* Failed to evict the page; change it directly */ + } +#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ buf_block_buf_fix_inc(block, file, line); - +#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG + ut_a(mode == BUF_GET_POSSIBLY_FREED + || !block->page.file_page_was_freed); +#endif //mutex_exit(&block->mutex); /* Check if this is the first access to the page */ access_time = buf_page_is_accessed(&block->page); - //buf_pool_mutex_exit(); + //buf_pool_mutex_exit(buf_pool); mutex_exit(block_mutex); - buf_page_set_accessed_make_young(&block->page, access_time); - -#ifdef UNIV_DEBUG_FILE_ACCESSES - ut_a(!block->page.file_page_was_freed); -#endif + if (UNIV_LIKELY(mode != BUF_PEEK_IF_IN_POOL)) { + buf_page_set_accessed_make_young(&block->page, access_time); + } #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG ut_a(++buf_dbg_counter % 5771 || buf_validate()); @@ -3046,11 +3437,12 @@ wait_until_unfixed: mtr_memo_push(mtr, block, fix_type); - if (!access_time) { + if (UNIV_LIKELY(mode != BUF_PEEK_IF_IN_POOL) && !access_time) { /* In the case of a first access, try to apply linear read-ahead */ - buf_read_ahead_linear(space, zip_size, offset, trx); + buf_read_ahead_linear(space, zip_size, offset, + ibuf_inside(mtr), trx); } #ifdef UNIV_IBUF_COUNT_DEBUG @@ -3080,6 +3472,7 @@ buf_page_optimistic_get( ulint line, /*!< in: line where called */ mtr_t* mtr) /*!< in: mini-transaction */ { + buf_pool_t* buf_pool; unsigned access_time; ibool success; ulint fix_type; @@ -3111,7 +3504,7 @@ buf_page_optimistic_get( access_time = buf_page_is_accessed(&block->page); buf_page_set_accessed_make_young(&block->page, access_time); - ut_ad(!ibuf_inside() + ut_ad(!ibuf_inside(mtr) || ibuf_page(buf_block_get_space(block), buf_block_get_zip_size(block), buf_block_get_page_no(block), NULL)); @@ -3158,7 +3551,7 @@ buf_page_optimistic_get( ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ -#ifdef UNIV_DEBUG_FILE_ACCESSES +#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG ut_a(block->page.file_page_was_freed == FALSE); #endif if (innobase_get_slow_log()) { @@ -3171,13 +3564,15 @@ buf_page_optimistic_get( buf_read_ahead_linear(buf_block_get_space(block), buf_block_get_zip_size(block), - buf_block_get_page_no(block), trx); + buf_block_get_page_no(block), + ibuf_inside(mtr), trx); } #ifdef UNIV_IBUF_COUNT_DEBUG ut_a(ibuf_count_get(buf_block_get_space(block), buf_block_get_page_no(block)) == 0); #endif + buf_pool = buf_pool_from_block(block); buf_pool->stat.n_page_gets++; if (innobase_get_slow_log()) { @@ -3202,6 +3597,7 @@ buf_page_get_known_nowait( ulint line, /*!< in: line where called */ mtr_t* mtr) /*!< in: mini-transaction */ { + buf_pool_t* buf_pool; ibool success; ulint fix_type; trx_t* trx = NULL; @@ -3231,12 +3627,14 @@ buf_page_get_known_nowait( mutex_exit(&block->mutex); + buf_pool = buf_pool_from_block(block); + if (mode == BUF_MAKE_YOUNG && buf_page_peek_if_too_old(&block->page)) { - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); buf_LRU_make_block_young(&block->page); - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); } else if (!buf_page_is_accessed(&block->page)) { /* Above, we do a dirty read on purpose, to avoid mutex contention. The field buf_page_t::access_time @@ -3244,14 +3642,14 @@ buf_page_get_known_nowait( field must be protected by mutex, however. */ ulint time_ms = ut_time_ms(); - //buf_pool_mutex_enter(); + //buf_pool_mutex_enter(buf_pool); mutex_enter(&block->mutex); buf_page_set_accessed(&block->page, time_ms); - //buf_pool_mutex_exit(); + //buf_pool_mutex_exit(buf_pool); mutex_exit(&block->mutex); } - ut_ad(!ibuf_inside() || (mode == BUF_KEEP_OLD)); + ut_ad(!ibuf_inside(mtr) || mode == BUF_KEEP_OLD); if (rw_latch == RW_S_LATCH) { success = rw_lock_s_lock_nowait(&(block->lock), @@ -3278,7 +3676,7 @@ buf_page_get_known_nowait( ut_a(block->page.buf_fix_count > 0); ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ -#ifdef UNIV_DEBUG_FILE_ACCESSES +#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG ut_a(block->page.file_page_was_freed == FALSE); #endif @@ -3315,23 +3713,26 @@ buf_page_try_get_func( buf_block_t* block; ibool success; ulint fix_type; + buf_pool_t* buf_pool = buf_pool_get(space_id, page_no); ut_ad(mtr); ut_ad(mtr->state == MTR_ACTIVE); - //buf_pool_mutex_enter(); - rw_lock_s_lock(&page_hash_latch); - block = buf_block_hash_get(space_id, page_no); + //buf_pool_mutex_enter(buf_pool); + rw_lock_s_lock(&buf_pool->page_hash_latch); + block = buf_block_hash_get(buf_pool, space_id, page_no); - if (!block) { - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + if (!block || buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE) { + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); return(NULL); } + ut_ad(!buf_pool_watch_is_sentinel(buf_pool, &block->page)); + mutex_enter(&block->mutex); - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); @@ -3369,9 +3770,9 @@ buf_page_try_get_func( ut_a(block->page.buf_fix_count > 0); ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ -#ifdef UNIV_DEBUG_FILE_ACCESSES +#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG ut_a(block->page.file_page_was_freed == FALSE); -#endif /* UNIV_DEBUG_FILE_ACCESSES */ +#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */ buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); buf_pool->stat.n_page_gets++; @@ -3401,9 +3802,9 @@ buf_page_init_low( bpage->oldest_modification = 0; HASH_INVALIDATE(bpage, hash); bpage->is_corrupt = FALSE; -#ifdef UNIV_DEBUG_FILE_ACCESSES +#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG bpage->file_page_was_freed = FALSE; -#endif /* UNIV_DEBUG_FILE_ACCESSES */ +#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */ } /********************************************************************//** @@ -3415,13 +3816,15 @@ buf_page_init( ulint space, /*!< in: space id */ ulint offset, /*!< in: offset of the page within space in units of a page */ + ulint fold, /*!< in: buf_page_address_fold(space,offset) */ buf_block_t* block) /*!< in: block to init */ { buf_page_t* hash_page; + buf_pool_t* buf_pool = buf_pool_get(space, offset); - //ut_ad(buf_pool_mutex_own()); + //ut_ad(buf_pool_mutex_own(buf_pool)); #ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX)); + ut_ad(rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_EX)); #endif ut_ad(mutex_own(&(block->mutex))); ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE); @@ -3440,13 +3843,26 @@ buf_page_init( buf_block_init_low(block); - block->lock_hash_val = lock_rec_hash(space, offset); + block->lock_hash_val = lock_rec_hash(space, offset); + + buf_page_init_low(&block->page); /* Insert into the hash table of file pages */ - hash_page = buf_page_hash_get(space, offset); + hash_page = buf_page_hash_get_low(buf_pool, space, offset, fold); - if (UNIV_LIKELY_NULL(hash_page)) { + if (UNIV_LIKELY(!hash_page)) { + } else if (buf_pool_watch_is_sentinel(buf_pool, hash_page)) { + /* Preserve the reference count. */ + ulint buf_fix_count; + + mutex_enter(&buf_pool->zip_mutex); + buf_fix_count = hash_page->buf_fix_count; + ut_a(buf_fix_count > 0); + block->page.buf_fix_count += buf_fix_count; + buf_pool_watch_remove(buf_pool, fold, hash_page); + mutex_exit(&buf_pool->zip_mutex); + } else { fprintf(stderr, "InnoDB: Error: page %lu %lu already found" " in the hash table: %p, %p\n", @@ -3455,8 +3871,8 @@ buf_page_init( (const void*) hash_page, (const void*) block); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG mutex_exit(&block->mutex); - //buf_pool_mutex_exit(); - rw_lock_x_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_x_unlock(&buf_pool->page_hash_latch); buf_print(); buf_LRU_print(); buf_validate(); @@ -3465,13 +3881,11 @@ buf_page_init( ut_error; } - buf_page_init_low(&block->page); - ut_ad(!block->page.in_zip_hash); ut_ad(!block->page.in_page_hash); ut_d(block->page.in_page_hash = TRUE); HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, - buf_page_address_fold(space, offset), &block->page); + fold, &block->page); } /********************************************************************//** @@ -3493,16 +3907,20 @@ buf_page_init_for_read( ulint space, /*!< in: space id */ ulint zip_size,/*!< in: compressed page size, or 0 */ ibool unzip, /*!< in: TRUE=request uncompressed page */ - ib_int64_t tablespace_version,/*!< in: prevents reading from a wrong + ib_int64_t tablespace_version, + /*!< in: prevents reading from a wrong version of the tablespace in case we have done DISCARD + IMPORT */ ulint offset) /*!< in: page number */ { buf_block_t* block; - buf_page_t* bpage; + buf_page_t* bpage = NULL; + buf_page_t* watch_page; mtr_t mtr; + ulint fold; ibool lru = FALSE; void* data; + buf_pool_t* buf_pool = buf_pool_get(space, offset); ut_ad(buf_pool); @@ -3512,14 +3930,13 @@ buf_page_init_for_read( /* It is a read-ahead within an ibuf routine */ ut_ad(!ibuf_bitmap_page(zip_size, offset)); - ut_ad(ibuf_inside()); - mtr_start(&mtr); + ibuf_mtr_start(&mtr); if (!recv_no_ibuf_operations && !ibuf_page(space, zip_size, offset, &mtr)) { - mtr_commit(&mtr); + ibuf_mtr_commit(&mtr); return(NULL); } @@ -3531,27 +3948,32 @@ buf_page_init_for_read( && UNIV_LIKELY(!recv_recovery_is_on())) { block = NULL; } else { - block = buf_LRU_get_free_block(0); + block = buf_LRU_get_free_block(buf_pool); ut_ad(block); + ut_ad(buf_pool_from_block(block) == buf_pool); } - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - rw_lock_x_lock(&page_hash_latch); + fold = buf_page_address_fold(space, offset); - if (buf_page_hash_get(space, offset)) { + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); + + watch_page = buf_page_hash_get_low(buf_pool, space, offset, fold); + if (watch_page && !buf_pool_watch_is_sentinel(buf_pool, watch_page)) { /* The page is already in the buffer pool. */ + watch_page = NULL; err_exit: if (block) { mutex_enter(&block->mutex); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); buf_LRU_block_free_non_file_page(block, FALSE); mutex_exit(&block->mutex); } else { - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); } bpage = NULL; @@ -3570,9 +3992,12 @@ err_exit: if (block) { bpage = &block->page; mutex_enter(&block->mutex); - buf_page_init(space, offset, block); - rw_lock_x_unlock(&page_hash_latch); + ut_ad(buf_pool_from_bpage(bpage) == buf_pool); + + buf_page_init(space, offset, fold, block); + + rw_lock_x_unlock(&buf_pool->page_hash_latch); /* The block must be put to the LRU list, to the old blocks */ buf_LRU_add_block(bpage, TRUE/* to old blocks */); @@ -3592,16 +4017,16 @@ err_exit: if (UNIV_UNLIKELY(zip_size)) { page_zip_set_size(&block->page.zip, zip_size); - /* buf_pool_mutex may be released and + /* buf_pool->mutex may be released and reacquired by buf_buddy_alloc(). Thus, we must release block->mutex in order not to break the latching order in the reacquisition - of buf_pool_mutex. We also must defer this + of buf_pool->mutex. We also must defer this operation until after the block descriptor has been added to buf_pool->LRU and buf_pool->page_hash. */ mutex_exit(&block->mutex); - data = buf_buddy_alloc(zip_size, &lru, FALSE); + data = buf_buddy_alloc(buf_pool, zip_size, &lru, FALSE); mutex_enter(&block->mutex); block->page.zip.data = data; @@ -3614,7 +4039,7 @@ err_exit: buf_unzip_LRU_add_block(block, TRUE); } - mutex_exit(&LRU_list_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); mutex_exit(&block->mutex); } else { /* Defer buf_buddy_alloc() until after the block has @@ -3626,37 +4051,53 @@ err_exit: control block (bpage), in order to avoid the invocation of buf_buddy_relocate_block() on uninitialized data. */ - data = buf_buddy_alloc(zip_size, &lru, TRUE); - bpage = buf_buddy_alloc(sizeof *bpage, &lru, TRUE); + data = buf_buddy_alloc(buf_pool, zip_size, &lru, TRUE); + bpage = buf_buddy_alloc(buf_pool, sizeof *bpage, &lru, TRUE); + + /* Initialize the buf_pool pointer. */ + bpage->buf_pool_index = buf_pool_index(buf_pool); /* If buf_buddy_alloc() allocated storage from the LRU list, - it released and reacquired buf_pool_mutex. Thus, we must + it released and reacquired buf_pool->mutex. Thus, we must check the page_hash again, as it may have been modified. */ - if (UNIV_UNLIKELY(lru) - && UNIV_LIKELY_NULL(buf_page_hash_get(space, offset))) { + if (UNIV_UNLIKELY(lru)) { - /* The block was added by some other thread. */ - buf_buddy_free(bpage, sizeof *bpage, TRUE); - buf_buddy_free(data, zip_size, TRUE); + watch_page = buf_page_hash_get_low( + buf_pool, space, offset, fold); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + if (watch_page + && !buf_pool_watch_is_sentinel(buf_pool, + watch_page)) { - bpage = NULL; - goto func_exit; + /* The block was added by some other thread. */ + watch_page = NULL; + bpage->state = BUF_BLOCK_ZIP_FREE; + buf_buddy_free(buf_pool, bpage, sizeof *bpage, TRUE); + buf_buddy_free(buf_pool, data, zip_size, TRUE); + + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); + + bpage = NULL; + goto func_exit; + } } page_zip_des_init(&bpage->zip); page_zip_set_size(&bpage->zip, zip_size); bpage->zip.data = data; - mutex_enter(&buf_pool_zip_mutex); + mutex_enter(&buf_pool->zip_mutex); UNIV_MEM_DESC(bpage->zip.data, page_zip_get_size(&bpage->zip), bpage); + buf_page_init_low(bpage); + bpage->state = BUF_BLOCK_ZIP_PAGE; bpage->space = space; bpage->offset = offset; + bpage->space_was_being_deleted = FALSE; + #ifdef UNIV_DEBUG bpage->in_page_hash = FALSE; @@ -3667,33 +4108,41 @@ err_exit: bpage->in_LRU_list = FALSE; ut_d(bpage->in_page_hash = TRUE); - HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, - buf_page_address_fold(space, offset), bpage); - rw_lock_x_unlock(&page_hash_latch); + if (UNIV_LIKELY_NULL(watch_page)) { + /* Preserve the reference count. */ + ulint buf_fix_count = watch_page->buf_fix_count; + ut_a(buf_fix_count > 0); + bpage->buf_fix_count += buf_fix_count; + ut_ad(buf_pool_watch_is_sentinel(buf_pool, watch_page)); + buf_pool_watch_remove(buf_pool, fold, watch_page); + } + + HASH_INSERT(buf_page_t, hash, buf_pool->page_hash, fold, + bpage); + + rw_lock_x_unlock(&buf_pool->page_hash_latch); /* The block must be put to the LRU list, to the old blocks */ buf_LRU_add_block(bpage, TRUE/* to old blocks */); - mutex_enter(&flush_list_mutex); buf_LRU_insert_zip_clean(bpage); - mutex_exit(&flush_list_mutex); - mutex_exit(&LRU_list_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); buf_page_set_io_fix(bpage, BUF_IO_READ); - mutex_exit(&buf_pool_zip_mutex); + mutex_exit(&buf_pool->zip_mutex); } - mutex_enter(&buf_pool_mutex); + buf_pool_mutex_enter(buf_pool); buf_pool->n_pend_reads++; - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); func_exit: - //buf_pool_mutex_exit(); + //buf_pool_mutex_exit(buf_pool); if (mode == BUF_READ_IBUF_PAGES_ONLY) { - mtr_commit(&mtr); + ibuf_mtr_commit(&mtr); } ut_ad(!bpage || buf_page_in_file(bpage)); @@ -3718,33 +4167,40 @@ buf_page_create( { buf_frame_t* frame; buf_block_t* block; + ulint fold; buf_block_t* free_block = NULL; ulint time_ms = ut_time_ms(); + buf_pool_t* buf_pool = buf_pool_get(space, offset); ut_ad(mtr); ut_ad(mtr->state == MTR_ACTIVE); ut_ad(space || !zip_size); - free_block = buf_LRU_get_free_block(0); + free_block = buf_LRU_get_free_block(buf_pool); - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - rw_lock_x_lock(&page_hash_latch); + fold = buf_page_address_fold(space, offset); - block = (buf_block_t*) buf_page_hash_get(space, offset); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); - if (block && buf_page_in_file(&block->page)) { + block = (buf_block_t*) buf_page_hash_get_low( + buf_pool, space, offset, fold); + + if (block + && buf_page_in_file(&block->page) + && !buf_pool_watch_is_sentinel(buf_pool, &block->page)) { #ifdef UNIV_IBUF_COUNT_DEBUG ut_a(ibuf_count_get(space, offset) == 0); #endif -#ifdef UNIV_DEBUG_FILE_ACCESSES +#if defined UNIV_DEBUG_FILE_ACCESSES || defined UNIV_DEBUG block->page.file_page_was_freed = FALSE; -#endif /* UNIV_DEBUG_FILE_ACCESSES */ +#endif /* UNIV_DEBUG_FILE_ACCESSES || UNIV_DEBUG */ /* Page can be found in buf_pool */ - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); buf_block_free(free_block); @@ -3765,8 +4221,8 @@ buf_page_create( mutex_enter(&block->mutex); - buf_page_init(space, offset, block); - rw_lock_x_unlock(&page_hash_latch); + buf_page_init(space, offset, fold, block); + rw_lock_x_unlock(&buf_pool->page_hash_latch); /* The block must be put to the LRU list */ buf_LRU_add_block(&block->page, FALSE); @@ -3779,7 +4235,7 @@ buf_page_create( ibool lru; /* Prevent race conditions during buf_buddy_alloc(), - which may release and reacquire buf_pool_mutex, + which may release and reacquire buf_pool->mutex, by IO-fixing and X-latching the block. */ buf_page_set_io_fix(&block->page, BUF_IO_READ); @@ -3787,13 +4243,13 @@ buf_page_create( page_zip_set_size(&block->page.zip, zip_size); mutex_exit(&block->mutex); - /* buf_pool_mutex may be released and reacquired by + /* buf_pool->mutex may be released and reacquired by buf_buddy_alloc(). Thus, we must release block->mutex in order not to break the latching order in - the reacquisition of buf_pool_mutex. We also must + the reacquisition of buf_pool->mutex. We also must defer this operation until after the block descriptor has been added to buf_pool->LRU and buf_pool->page_hash. */ - data = buf_buddy_alloc(zip_size, &lru, FALSE); + data = buf_buddy_alloc(buf_pool, zip_size, &lru, FALSE); mutex_enter(&block->mutex); block->page.zip.data = data; @@ -3811,8 +4267,8 @@ buf_page_create( buf_page_set_accessed(&block->page, time_ms); - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); mtr_memo_push(mtr, block, MTR_MEMO_BUF_FIX); @@ -3824,7 +4280,7 @@ buf_page_create( ibuf_merge_or_delete_for_page(NULL, space, offset, zip_size, TRUE); /* Flush pages from the end of the LRU list if necessary */ - buf_flush_free_margin(FALSE); + buf_flush_free_margin(buf_pool, FALSE); frame = block->frame; @@ -3857,13 +4313,13 @@ UNIV_INTERN void buf_page_io_complete( /*=================*/ - buf_page_t* bpage, /*!< in: pointer to the block in question */ - trx_t* trx) + buf_page_t* bpage) /*!< in: pointer to the block in question */ { enum buf_io_fix io_type; + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); const ibool uncompressed = (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); - enum buf_flush flush_type; + ibool have_LRU_mutex = FALSE; mutex_t* block_mutex; ut_a(buf_page_in_file(bpage)); @@ -3975,19 +4431,23 @@ corrupt: "InnoDB: TABLE to scan your" " table for corruption.\n" "InnoDB: See also " - REFMAN "forcing-recovery.html\n" + REFMAN "forcing-innodb-recovery.html\n" "InnoDB: about forcing recovery.\n", stderr); if (srv_pass_corrupt_table && !trx_sys_sys_space(bpage->space) && bpage->space < SRV_LOG_SPACE_FIRST_ID) { + trx_t* trx; + fprintf(stderr, "InnoDB: space %u will be treated as corrupt.\n", bpage->space); fil_space_set_corrupt(bpage->space); - if (trx && trx->dict_operation_lock_mode == 0) { - dict_table_set_corrupt_by_space(bpage->space, TRUE); - } else { + + trx = innobase_get_trx(); + if (trx && trx->dict_operation_lock_mode == RW_X_LATCH) { dict_table_set_corrupt_by_space(bpage->space, FALSE); + } else { + dict_table_set_corrupt_by_space(bpage->space, TRUE); } bpage->is_corrupt = TRUE; } else @@ -4017,17 +4477,26 @@ corrupt: } } - //buf_pool_mutex_enter(); - if (io_type == BUF_IO_WRITE) { - flush_type = buf_page_get_flush_type(bpage); + if (io_type == BUF_IO_WRITE + && (buf_page_get_state(bpage) == BUF_BLOCK_ZIP_DIRTY + || buf_page_get_flush_type(bpage) == BUF_FLUSH_LRU)) { /* to keep consistency at buf_LRU_insert_zip_clean() */ - //if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */ - mutex_enter(&LRU_list_mutex); - //} + have_LRU_mutex = TRUE; /* optimistic */ } +retry_mutex: + if (have_LRU_mutex) + mutex_enter(&buf_pool->LRU_list_mutex); block_mutex = buf_page_get_mutex_enter(bpage); ut_a(block_mutex); - mutex_enter(&buf_pool_mutex); + if (io_type == BUF_IO_WRITE + && (buf_page_get_state(bpage) == BUF_BLOCK_ZIP_DIRTY + || buf_page_get_flush_type(bpage) == BUF_FLUSH_LRU) + && !have_LRU_mutex) { + mutex_exit(block_mutex); + have_LRU_mutex = TRUE; + goto retry_mutex; + } + buf_pool_mutex_enter(buf_pool); #ifdef UNIV_IBUF_COUNT_DEBUG if (io_type == BUF_IO_WRITE || uncompressed) { @@ -4050,6 +4519,7 @@ corrupt: the x-latch to this OS thread: do not let this confuse you in debugging! */ + ut_a(!have_LRU_mutex); ut_ad(buf_pool->n_pend_reads > 0); buf_pool->n_pend_reads--; buf_pool->stat.n_pages_read++; @@ -4067,10 +4537,8 @@ corrupt: buf_flush_write_complete(bpage); - /* to keep consistency at buf_LRU_insert_zip_clean() */ - //if (flush_type == BUF_FLUSH_LRU) { /* optimistic! */ - mutex_exit(&LRU_list_mutex); - //} + if (have_LRU_mutex) + mutex_exit(&buf_pool->LRU_list_mutex); if (uncompressed) { rw_lock_s_unlock_gen(&((buf_block_t*) bpage)->lock, @@ -4094,24 +4562,92 @@ corrupt: } #endif /* UNIV_DEBUG */ - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); mutex_exit(block_mutex); - //buf_pool_mutex_exit(); +} + +/********************************************************************//** +*/ +UNIV_INTERN +buf_block_t* +buf_page_from_array( +/*================*/ + buf_pool_t* buf_pool, + ulint n_block) +{ + ulint n_chunks, offset; + buf_chunk_t* chunk; + + ut_a(n_block < buf_pool->curr_size); + + chunk = buf_pool->chunks; + offset = n_block; + + for (n_chunks = buf_pool->n_chunks; n_chunks--; chunk++) { + if (offset < chunk->size) { + return(&chunk->blocks[offset]); + } + + offset -= chunk->size; + } + + ut_error; + + return(NULL); } /*********************************************************************//** -Invalidates the file pages in the buffer pool when an archive recovery is -completed. All the file pages buffered must be in a replaceable state when -this function is called: not latched and not modified. */ -UNIV_INTERN +Asserts that all file pages in the buffer are in a replaceable state. +@return TRUE */ +static +ibool +buf_all_freed_instance( +/*===================*/ + buf_pool_t* buf_pool) /*!< in: buffer pool instancce */ +{ + ulint i; + buf_chunk_t* chunk; + + ut_ad(buf_pool); + + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); + + chunk = buf_pool->chunks; + + for (i = buf_pool->n_chunks; i--; chunk++) { + + const buf_block_t* block = buf_chunk_not_freed(chunk); + + if (UNIV_LIKELY_NULL(block)) { + fprintf(stderr, + "Page %lu %lu still fixed or dirty\n", + (ulong) block->page.space, + (ulong) block->page.offset); + ut_error; + } + } + + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); + + return(TRUE); +} + +/*********************************************************************//** +Invalidates file pages in one buffer pool instance */ +static void -buf_pool_invalidate(void) -/*=====================*/ +buf_pool_invalidate_instance( +/*=========================*/ + buf_pool_t* buf_pool) /*!< in: buffer pool instance */ { ibool freed; enum buf_flush i; - buf_pool_mutex_enter(); + buf_pool_mutex_enter(buf_pool); for (i = BUF_FLUSH_LRU; i < BUF_FLUSH_N_TYPES; i++) { @@ -4127,24 +4663,24 @@ buf_pool_invalidate(void) pool invalidation to proceed we must ensure there is NO write activity happening. */ if (buf_pool->n_flush[i] > 0) { - buf_pool_mutex_exit(); - buf_flush_wait_batch_end(i); - buf_pool_mutex_enter(); + buf_pool_mutex_exit(buf_pool); + buf_flush_wait_batch_end(buf_pool, i); + buf_pool_mutex_enter(buf_pool); } } - buf_pool_mutex_exit(); + buf_pool_mutex_exit(buf_pool); - ut_ad(buf_all_freed()); + ut_ad(buf_all_freed_instance(buf_pool)); freed = TRUE; while (freed) { - freed = buf_LRU_search_and_free_block(100); + freed = buf_LRU_search_and_free_block(buf_pool, 100); } - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); ut_ad(UT_LIST_GET_LEN(buf_pool->LRU) == 0); ut_ad(UT_LIST_GET_LEN(buf_pool->unzip_LRU) == 0); @@ -4155,20 +4691,37 @@ buf_pool_invalidate(void) buf_pool->LRU_flush_ended = 0; memset(&buf_pool->stat, 0x00, sizeof(buf_pool->stat)); - buf_refresh_io_stats(); + buf_refresh_io_stats(buf_pool); - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); +} + +/*********************************************************************//** +Invalidates the file pages in the buffer pool when an archive recovery is +completed. All the file pages buffered must be in a replaceable state when +this function is called: not latched and not modified. */ +UNIV_INTERN +void +buf_pool_invalidate(void) +/*=====================*/ +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_invalidate_instance(buf_pool_from_array(i)); + } } #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /*********************************************************************//** -Validates the buffer buf_pool data structure. +Validates data in one buffer pool instance @return TRUE */ -UNIV_INTERN +static ibool -buf_validate(void) -/*==============*/ +buf_pool_validate_instance( +/*=======================*/ + buf_pool_t* buf_pool) /*!< in: buffer pool instance */ { buf_page_t* b; buf_chunk_t* chunk; @@ -4183,9 +4736,9 @@ buf_validate(void) ut_ad(buf_pool); - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - rw_lock_x_lock(&page_hash_latch); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); /* for keep the new latch order, it cannot validate correctly... */ chunk = buf_pool->chunks; @@ -4211,7 +4764,8 @@ buf_validate(void) break; case BUF_BLOCK_FILE_PAGE: - ut_a(buf_page_hash_get(buf_block_get_space( + ut_a(buf_page_hash_get(buf_pool, + buf_block_get_space( block), buf_block_get_page_no( block)) @@ -4258,11 +4812,6 @@ buf_validate(void) } n_lru++; - - if (block->page.oldest_modification > 0) { - n_flush++; - } - break; case BUF_BLOCK_NOT_USED: @@ -4280,7 +4829,7 @@ buf_validate(void) } } - mutex_enter(&buf_pool_zip_mutex); + mutex_enter(&buf_pool->zip_mutex); /* Check clean compressed-only blocks. */ @@ -4301,31 +4850,34 @@ buf_validate(void) ut_error; break; } + + /* It is OK to read oldest_modification here because + we have acquired buf_pool->zip_mutex above which acts + as the 'block->mutex' for these bpages. */ ut_a(!b->oldest_modification); - ut_a(buf_page_hash_get(b->space, b->offset) == b); + ut_a(buf_page_hash_get(buf_pool, b->space, b->offset) == b); n_lru++; n_zip++; } - /* Check dirty compressed-only blocks. */ + /* Check dirty blocks. */ - mutex_enter(&flush_list_mutex); + buf_flush_list_mutex_enter(buf_pool); for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; b = UT_LIST_GET_NEXT(flush_list, b)) { ut_ad(b->in_flush_list); + ut_a(b->oldest_modification); + n_flush++; switch (buf_page_get_state(b)) { case BUF_BLOCK_ZIP_DIRTY: - ut_a(b->oldest_modification); n_lru++; - n_flush++; n_zip++; switch (buf_page_get_io_fix(b)) { case BUF_IO_NONE: case BUF_IO_READ: break; - case BUF_IO_WRITE: switch (buf_page_get_flush_type(b)) { case BUF_FLUSH_LRU: @@ -4355,11 +4907,14 @@ buf_validate(void) ut_error; break; } - ut_a(buf_page_hash_get(b->space, b->offset) == b); + ut_a(buf_page_hash_get(buf_pool, b->space, b->offset) == b); } - mutex_exit(&flush_list_mutex); - mutex_exit(&buf_pool_zip_mutex); + ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush); + + buf_flush_list_mutex_exit(buf_pool); + + mutex_exit(&buf_pool->zip_mutex); if (n_lru + n_free > buf_pool->curr_size + n_zip) { fprintf(stderr, "n LRU %lu, n free %lu, pool %lu zip %lu\n", @@ -4369,7 +4924,7 @@ buf_validate(void) } ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == n_lru); - /* because of latching order with block->mutex, we cannot get free_list_mutex before that */ + /* because of latching order with block->mutex, we cannot get needed mutexes before that */ /* if (UT_LIST_GET_LEN(buf_pool->free) != n_free) { fprintf(stderr, "Free list len %lu, free blocks %lu\n", @@ -4377,41 +4932,59 @@ buf_validate(void) (ulong) n_free); ut_error; } -*/ - /* because of latching order with block->mutex, we cannot get flush_list_mutex before that */ -/* - ut_a(UT_LIST_GET_LEN(buf_pool->flush_list) == n_flush); ut_a(buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE] == n_single_flush); ut_a(buf_pool->n_flush[BUF_FLUSH_LIST] == n_list_flush); ut_a(buf_pool->n_flush[BUF_FLUSH_LRU] == n_lru_flush); */ - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); ut_a(buf_LRU_validate()); - ut_a(buf_flush_validate()); + ut_a(buf_flush_validate(buf_pool)); return(TRUE); } + +/*********************************************************************//** +Validates the buffer buf_pool data structure. +@return TRUE */ +UNIV_INTERN +ibool +buf_validate(void) +/*==============*/ +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + buf_pool_validate_instance(buf_pool); + } + return(TRUE); +} + #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /*********************************************************************//** -Prints info of the buffer buf_pool data structure. */ -UNIV_INTERN +Prints info of the buffer buf_pool data structure for one instance. */ +static void -buf_print(void) -/*===========*/ +buf_print_instance( +/*===============*/ + buf_pool_t* buf_pool) { - dulint* index_ids; + index_id_t* index_ids; ulint* counts; ulint size; ulint i; ulint j; - dulint id; + index_id_t id; ulint n_found; buf_chunk_t* chunk; dict_index_t* index; @@ -4420,13 +4993,13 @@ buf_print(void) size = buf_pool->curr_size; - index_ids = mem_alloc(sizeof(dulint) * size); + index_ids = mem_alloc(size * sizeof *index_ids); counts = mem_alloc(sizeof(ulint) * size); - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - mutex_enter(&free_list_mutex); - mutex_enter(&flush_list_mutex); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + mutex_enter(&buf_pool->free_list_mutex); + buf_flush_list_mutex_enter(buf_pool); fprintf(stderr, "buf_pool size %lu\n" @@ -4453,6 +5026,8 @@ buf_print(void) (ulong) buf_pool->stat.n_pages_created, (ulong) buf_pool->stat.n_pages_written); + buf_flush_list_mutex_exit(buf_pool); + /* Count the number of blocks belonging to each index in the buffer */ n_found = 0; @@ -4475,8 +5050,7 @@ buf_print(void) while (j < n_found) { - if (ut_dulint_cmp(index_ids[j], - id) == 0) { + if (index_ids[j] == id) { counts[j]++; break; @@ -4493,17 +5067,16 @@ buf_print(void) } } - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - mutex_exit(&free_list_mutex); - mutex_exit(&flush_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + mutex_exit(&buf_pool->free_list_mutex); for (i = 0; i < n_found; i++) { index = dict_index_get_if_in_cache(index_ids[i]); fprintf(stderr, - "Block count for index %lu in buffer is about %lu", - (ulong) ut_dulint_get_low(index_ids[i]), + "Block count for index %llu in buffer is about %lu", + (ullint) index_ids[i], (ulong) counts[i]); if (index) { @@ -4517,7 +5090,24 @@ buf_print(void) mem_free(index_ids); mem_free(counts); - ut_a(buf_validate()); + ut_a(buf_pool_validate_instance(buf_pool)); +} + +/*********************************************************************//** +Prints info of the buffer buf_pool data structure. */ +UNIV_INTERN +void +buf_print(void) +/*===========*/ +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + buf_print_instance(buf_pool); + } } #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */ @@ -4527,15 +5117,16 @@ Returns the number of latched pages in the buffer pool. @return number of latched pages */ UNIV_INTERN ulint -buf_get_latched_pages_number(void) -/*==============================*/ +buf_get_latched_pages_number_instance( +/*==================================*/ + buf_pool_t* buf_pool) /*!< in: buffer pool instance */ { - buf_chunk_t* chunk; buf_page_t* b; ulint i; + buf_chunk_t* chunk; ulint fixed_pages_number = 0; - //buf_pool_mutex_enter(); + //buf_pool_mutex_enter(buf_pool); chunk = buf_pool->chunks; @@ -4564,7 +5155,7 @@ buf_get_latched_pages_number(void) } } - mutex_enter(&buf_pool_zip_mutex); + mutex_enter(&buf_pool->zip_mutex); /* Traverse the lists of clean and dirty compressed-only blocks. */ @@ -4579,7 +5170,7 @@ buf_get_latched_pages_number(void) } } - mutex_enter(&flush_list_mutex); + buf_flush_list_mutex_enter(buf_pool); for (b = UT_LIST_GET_FIRST(buf_pool->flush_list); b; b = UT_LIST_GET_NEXT(flush_list, b)) { ut_ad(b->in_flush_list); @@ -4604,13 +5195,37 @@ buf_get_latched_pages_number(void) break; } } - mutex_exit(&flush_list_mutex); - mutex_exit(&buf_pool_zip_mutex); - //buf_pool_mutex_exit(); + buf_flush_list_mutex_exit(buf_pool); + mutex_exit(&buf_pool->zip_mutex); + //buf_pool_mutex_exit(buf_pool); return(fixed_pages_number); } + +/*********************************************************************//** +Returns the number of latched pages in all the buffer pools. +@return number of latched pages */ +UNIV_INTERN +ulint +buf_get_latched_pages_number(void) +/*==============================*/ +{ + ulint i; + ulint total_latched_pages = 0; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + total_latched_pages += buf_get_latched_pages_number_instance( + buf_pool); + } + + return(total_latched_pages); +} + #endif /* UNIV_DEBUG */ /*********************************************************************//** @@ -4621,10 +5236,22 @@ ulint buf_get_n_pending_ios(void) /*=======================*/ { - return(buf_pool->n_pend_reads - + buf_pool->n_flush[BUF_FLUSH_LRU] - + buf_pool->n_flush[BUF_FLUSH_LIST] - + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); + ulint i; + ulint pend_ios = 0; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + pend_ios += + buf_pool->n_pend_reads + + buf_pool->n_flush[BUF_FLUSH_LRU] + + buf_pool->n_flush[BUF_FLUSH_LIST] + + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]; + } + + return(pend_ios); } /*********************************************************************//** @@ -4636,40 +5263,224 @@ ulint buf_get_modified_ratio_pct(void) /*============================*/ { - ulint ratio; + ulint ratio; + ulint lru_len = 0; + ulint free_len = 0; + ulint flush_list_len = 0; - //buf_pool_mutex_enter(); /* optimistic */ + buf_get_total_list_len(&lru_len, &free_len, &flush_list_len); - ratio = (100 * UT_LIST_GET_LEN(buf_pool->flush_list)) - / (1 + UT_LIST_GET_LEN(buf_pool->LRU) - + UT_LIST_GET_LEN(buf_pool->free)); + ratio = (100 * flush_list_len) / (1 + lru_len + free_len); /* 1 + is there to avoid division by zero */ - //buf_pool_mutex_exit(); /* optimistic */ - return(ratio); } +/*******************************************************************//** +Aggregates a pool stats information with the total buffer pool stats */ +static +void +buf_stats_aggregate_pool_info( +/*==========================*/ + buf_pool_info_t* total_info, /*!< in/out: the buffer pool + info to store aggregated + result */ + const buf_pool_info_t* pool_info) /*!< in: individual buffer pool + stats info */ +{ + ut_a(total_info && pool_info); + + /* Nothing to copy if total_info is the same as pool_info */ + if (total_info == pool_info) { + return; + } + + total_info->pool_size += pool_info->pool_size; + total_info->pool_size_bytes += pool_info->pool_size_bytes; + total_info->lru_len += pool_info->lru_len; + total_info->old_lru_len += pool_info->old_lru_len; + total_info->free_list_len += pool_info->free_list_len; + total_info->flush_list_len += pool_info->flush_list_len; + total_info->n_pend_unzip += pool_info->n_pend_unzip; + total_info->n_pend_reads += pool_info->n_pend_reads; + total_info->n_pending_flush_lru += pool_info->n_pending_flush_lru; + total_info->n_pending_flush_list += pool_info->n_pending_flush_list; + total_info->n_pending_flush_single_page += + pool_info->n_pending_flush_single_page; + total_info->n_pages_made_young += pool_info->n_pages_made_young; + total_info->n_pages_not_made_young += pool_info->n_pages_not_made_young; + total_info->n_pages_read += pool_info->n_pages_read; + total_info->n_pages_created += pool_info->n_pages_created; + total_info->n_pages_written += pool_info->n_pages_written; + total_info->n_page_gets += pool_info->n_page_gets; + total_info->n_ra_pages_read += pool_info->n_ra_pages_read; + total_info->n_ra_pages_evicted += pool_info->n_ra_pages_evicted; + total_info->page_made_young_rate += pool_info->page_made_young_rate; + total_info->page_not_made_young_rate += + pool_info->page_not_made_young_rate; + total_info->pages_read_rate += pool_info->pages_read_rate; + total_info->pages_created_rate += pool_info->pages_created_rate; + total_info->pages_written_rate += pool_info->pages_written_rate; + total_info->n_page_get_delta += pool_info->n_page_get_delta; + total_info->page_read_delta += pool_info->page_read_delta; + total_info->young_making_delta += pool_info->young_making_delta; + total_info->not_young_making_delta += pool_info->not_young_making_delta; + total_info->pages_readahead_rate += pool_info->pages_readahead_rate; + total_info->pages_evicted_rate += pool_info->pages_evicted_rate; + total_info->unzip_lru_len += pool_info->unzip_lru_len; + total_info->io_sum += pool_info->io_sum; + total_info->io_cur += pool_info->io_cur; + total_info->unzip_sum += pool_info->unzip_sum; + total_info->unzip_cur += pool_info->unzip_cur; +} +/*******************************************************************//** +Collect buffer pool stats information for a buffer pool. Also +record aggregated stats if there are more than one buffer pool +in the server */ +static +void +buf_stats_get_pool_info( +/*====================*/ + buf_pool_t* buf_pool, /*!< in: buffer pool */ + ulint pool_id, /*!< in: buffer pool ID */ + buf_pool_info_t* all_pool_info) /*!< in/out: buffer pool info + to fill */ +{ + buf_pool_info_t* pool_info; + time_t current_time; + double time_elapsed; + + /* Find appropriate pool_info to store stats for this buffer pool */ + pool_info = &all_pool_info[pool_id]; + + mutex_enter(&buf_pool->LRU_list_mutex); + mutex_enter(&buf_pool->free_list_mutex); + buf_pool_mutex_enter(buf_pool); + buf_flush_list_mutex_enter(buf_pool); + + pool_info->pool_unique_id = pool_id; + + pool_info->pool_size = buf_pool->curr_size; + + pool_info->pool_size_bytes = buf_pool->curr_pool_size; + + pool_info->lru_len = UT_LIST_GET_LEN(buf_pool->LRU); + + pool_info->old_lru_len = buf_pool->LRU_old_len; + + pool_info->free_list_len = UT_LIST_GET_LEN(buf_pool->free); + + pool_info->flush_list_len = UT_LIST_GET_LEN(buf_pool->flush_list); + + pool_info->n_pend_unzip = UT_LIST_GET_LEN(buf_pool->unzip_LRU); + + pool_info->n_pend_reads = buf_pool->n_pend_reads; + + pool_info->n_pending_flush_lru = + (buf_pool->n_flush[BUF_FLUSH_LRU] + + buf_pool->init_flush[BUF_FLUSH_LRU]); + + pool_info->n_pending_flush_list = + (buf_pool->n_flush[BUF_FLUSH_LIST] + + buf_pool->init_flush[BUF_FLUSH_LIST]); + + pool_info->n_pending_flush_single_page = + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]; + + buf_flush_list_mutex_exit(buf_pool); + + current_time = time(NULL); + time_elapsed = 0.001 + difftime(current_time, + buf_pool->last_printout_time); + + pool_info->n_pages_made_young = buf_pool->stat.n_pages_made_young; + + pool_info->n_pages_not_made_young = + buf_pool->stat.n_pages_not_made_young; + + pool_info->n_pages_read = buf_pool->stat.n_pages_read; + + pool_info->n_pages_created = buf_pool->stat.n_pages_created; + + pool_info->n_pages_written = buf_pool->stat.n_pages_written; + + pool_info->n_page_gets = buf_pool->stat.n_page_gets; + + pool_info->n_ra_pages_read = buf_pool->stat.n_ra_pages_read; + + pool_info->n_ra_pages_evicted = buf_pool->stat.n_ra_pages_evicted; + + pool_info->page_made_young_rate = + (buf_pool->stat.n_pages_made_young + - buf_pool->old_stat.n_pages_made_young) / time_elapsed; + + pool_info->page_not_made_young_rate = + (buf_pool->stat.n_pages_not_made_young + - buf_pool->old_stat.n_pages_not_made_young) / time_elapsed; + + pool_info->pages_read_rate = + (buf_pool->stat.n_pages_read + - buf_pool->old_stat.n_pages_read) / time_elapsed; + + pool_info->pages_created_rate = + (buf_pool->stat.n_pages_created + - buf_pool->old_stat.n_pages_created) / time_elapsed; + + pool_info->pages_written_rate = + (buf_pool->stat.n_pages_written + - buf_pool->old_stat.n_pages_written) / time_elapsed; + + pool_info->n_page_get_delta = buf_pool->stat.n_page_gets + - buf_pool->old_stat.n_page_gets; + + if (pool_info->n_page_get_delta) { + pool_info->page_read_delta = buf_pool->stat.n_pages_read + - buf_pool->old_stat.n_pages_read; + + pool_info->young_making_delta = + buf_pool->stat.n_pages_made_young + - buf_pool->old_stat.n_pages_made_young; + + pool_info->not_young_making_delta = + buf_pool->stat.n_pages_not_made_young + - buf_pool->old_stat.n_pages_not_made_young; + } + + pool_info->pages_readahead_rate = + (buf_pool->stat.n_ra_pages_read + - buf_pool->old_stat.n_ra_pages_read) / time_elapsed; + + pool_info->pages_evicted_rate = + (buf_pool->stat.n_ra_pages_evicted + - buf_pool->old_stat.n_ra_pages_evicted) / time_elapsed; + + pool_info->unzip_lru_len = UT_LIST_GET_LEN(buf_pool->unzip_LRU); + + pool_info->io_sum = buf_LRU_stat_sum.io; + + pool_info->io_cur = buf_LRU_stat_cur.io; + + pool_info->unzip_sum = buf_LRU_stat_sum.unzip; + + pool_info->unzip_cur = buf_LRU_stat_cur.unzip; + + buf_refresh_io_stats(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + mutex_exit(&buf_pool->free_list_mutex); + buf_pool_mutex_exit(buf_pool); +} + /*********************************************************************//** Prints info of the buffer i/o. */ UNIV_INTERN void -buf_print_io( -/*=========*/ - FILE* file) /*!< in/out: buffer where to print */ +buf_print_io_instance( +/*==================*/ + buf_pool_info_t*pool_info, /*!< in: buffer pool info */ + FILE* file) /*!< in/out: buffer where to print */ { - time_t current_time; - double time_elapsed; - ulint n_gets_diff; - - ut_ad(buf_pool); - - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - mutex_enter(&free_list_mutex); - mutex_enter(&buf_pool_mutex); - mutex_enter(&flush_list_mutex); + ut_ad(pool_info); fprintf(file, "Buffer pool size %lu\n" @@ -4680,68 +5491,43 @@ buf_print_io( "Modified db pages %lu\n" "Pending reads %lu\n" "Pending writes: LRU %lu, flush list %lu, single page %lu\n", - (ulong) buf_pool->curr_size, - (ulong) buf_pool->curr_size * UNIV_PAGE_SIZE, - (ulong) UT_LIST_GET_LEN(buf_pool->free), - (ulong) UT_LIST_GET_LEN(buf_pool->LRU), - (ulong) buf_pool->LRU_old_len, - (ulong) UT_LIST_GET_LEN(buf_pool->flush_list), - (ulong) buf_pool->n_pend_reads, - (ulong) buf_pool->n_flush[BUF_FLUSH_LRU] - + buf_pool->init_flush[BUF_FLUSH_LRU], - (ulong) buf_pool->n_flush[BUF_FLUSH_LIST] - + buf_pool->init_flush[BUF_FLUSH_LIST], - (ulong) buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]); - - current_time = time(NULL); - time_elapsed = 0.001 + difftime(current_time, - buf_pool->last_printout_time); + pool_info->pool_size, + pool_info->pool_size_bytes, + pool_info->free_list_len, + pool_info->lru_len, + pool_info->old_lru_len, + pool_info->flush_list_len, + pool_info->n_pend_reads, + pool_info->n_pending_flush_lru, + pool_info->n_pending_flush_list, + pool_info->n_pending_flush_single_page); fprintf(file, "Pages made young %lu, not young %lu\n" "%.2f youngs/s, %.2f non-youngs/s\n" "Pages read %lu, created %lu, written %lu\n" "%.2f reads/s, %.2f creates/s, %.2f writes/s\n", - (ulong) buf_pool->stat.n_pages_made_young, - (ulong) buf_pool->stat.n_pages_not_made_young, - (buf_pool->stat.n_pages_made_young - - buf_pool->old_stat.n_pages_made_young) - / time_elapsed, - (buf_pool->stat.n_pages_not_made_young - - buf_pool->old_stat.n_pages_not_made_young) - / time_elapsed, - (ulong) buf_pool->stat.n_pages_read, - (ulong) buf_pool->stat.n_pages_created, - (ulong) buf_pool->stat.n_pages_written, - (buf_pool->stat.n_pages_read - - buf_pool->old_stat.n_pages_read) - / time_elapsed, - (buf_pool->stat.n_pages_created - - buf_pool->old_stat.n_pages_created) - / time_elapsed, - (buf_pool->stat.n_pages_written - - buf_pool->old_stat.n_pages_written) - / time_elapsed); + pool_info->n_pages_made_young, + pool_info->n_pages_not_made_young, + pool_info->page_made_young_rate, + pool_info->page_not_made_young_rate, + pool_info->n_pages_read, + pool_info->n_pages_created, + pool_info->n_pages_written, + pool_info->pages_read_rate, + pool_info->pages_created_rate, + pool_info->pages_written_rate); - n_gets_diff = buf_pool->stat.n_page_gets - buf_pool->old_stat.n_page_gets; - - if (n_gets_diff) { + if (pool_info->n_page_get_delta) { fprintf(file, "Buffer pool hit rate %lu / 1000," " young-making rate %lu / 1000 not %lu / 1000\n", - (ulong) - (1000 - ((1000 * (buf_pool->stat.n_pages_read - - buf_pool->old_stat.n_pages_read)) - / (buf_pool->stat.n_page_gets - - buf_pool->old_stat.n_page_gets))), - (ulong) - (1000 * (buf_pool->stat.n_pages_made_young - - buf_pool->old_stat.n_pages_made_young) - / n_gets_diff), - (ulong) - (1000 * (buf_pool->stat.n_pages_not_made_young - - buf_pool->old_stat.n_pages_not_made_young) - / n_gets_diff)); + (ulong) (1000 - (1000 * pool_info->page_read_delta + / pool_info->n_page_get_delta)), + (ulong) (1000 * pool_info->young_making_delta + / pool_info->n_page_get_delta), + (ulong) (1000 * pool_info->not_young_making_delta + / pool_info->n_page_get_delta)); } else { fputs("No buffer pool page gets since the last printout\n", file); @@ -4750,73 +5536,130 @@ buf_print_io( /* Statistics about read ahead algorithm */ fprintf(file, "Pages read ahead %.2f/s," " evicted without access %.2f/s\n", - (buf_pool->stat.n_ra_pages_read - - buf_pool->old_stat.n_ra_pages_read) - / time_elapsed, - (buf_pool->stat.n_ra_pages_evicted - - buf_pool->old_stat.n_ra_pages_evicted) - / time_elapsed); + pool_info->pages_readahead_rate, + pool_info->pages_evicted_rate); /* Print some values to help us with visualizing what is happening with LRU eviction. */ fprintf(file, "LRU len: %lu, unzip_LRU len: %lu\n" "I/O sum[%lu]:cur[%lu], unzip sum[%lu]:cur[%lu]\n", - UT_LIST_GET_LEN(buf_pool->LRU), - UT_LIST_GET_LEN(buf_pool->unzip_LRU), - buf_LRU_stat_sum.io, buf_LRU_stat_cur.io, - buf_LRU_stat_sum.unzip, buf_LRU_stat_cur.unzip); + pool_info->lru_len, pool_info->unzip_lru_len, + pool_info->io_sum, pool_info->io_cur, + pool_info->unzip_sum, pool_info->unzip_cur); +} - buf_refresh_io_stats(); - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - mutex_exit(&free_list_mutex); - mutex_exit(&buf_pool_mutex); - mutex_exit(&flush_list_mutex); +/*********************************************************************//** +Prints info of the buffer i/o. */ +UNIV_INTERN +void +buf_print_io( +/*=========*/ + FILE* file) /*!< in/out: buffer where to print */ +{ + ulint i; + buf_pool_info_t* pool_info; + buf_pool_info_t* pool_info_total; + + /* If srv_buf_pool_instances is greater than 1, allocate + one extra buf_pool_info_t, the last one stores + aggregated/total values from all pools */ + if (srv_buf_pool_instances > 1) { + pool_info = (buf_pool_info_t*) mem_zalloc(( + srv_buf_pool_instances + 1) * sizeof *pool_info); + + pool_info_total = &pool_info[srv_buf_pool_instances]; + } else { + ut_a(srv_buf_pool_instances == 1); + pool_info_total = pool_info = (buf_pool_info_t*) mem_zalloc( + sizeof *pool_info) + } + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + /* Fetch individual buffer pool info and calculate + aggregated stats along the way */ + buf_stats_get_pool_info(buf_pool, i, pool_info); + + /* If we have more than one buffer pool, store + the aggregated stats */ + if (srv_buf_pool_instances > 1) { + buf_stats_aggregate_pool_info(pool_info_total, + &pool_info[i]); + } + } + + /* Print the aggreate buffer pool info */ + buf_print_io_instance(pool_info_total, file); + + /* If there are more than one buffer pool, print each individual pool + info */ + if (srv_buf_pool_instances > 1) { + fputs("----------------------\n" + "INDIVIDUAL BUFFER POOL INFO\n" + "----------------------\n", file); + + for (i = 0; i < srv_buf_pool_instances; i++) { + fprintf(file, "---BUFFER POOL %lu\n", i); + buf_print_io_instance(&pool_info[i], file); + } + } + + mem_free(pool_info); } /**********************************************************************//** Refreshes the statistics used to print per-second averages. */ UNIV_INTERN void -buf_refresh_io_stats(void) -/*======================*/ +buf_refresh_io_stats( +/*=================*/ + buf_pool_t* buf_pool) /*!< in: buffer pool instance */ { - buf_pool->last_printout_time = time(NULL); + buf_pool->last_printout_time = ut_time(); buf_pool->old_stat = buf_pool->stat; } -/*********************************************************************//** -Asserts that all file pages in the buffer are in a replaceable state. -@return TRUE */ +/**********************************************************************//** +Refreshes the statistics used to print per-second averages. */ +UNIV_INTERN +void +buf_refresh_io_stats_all(void) +/*==========================*/ +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + buf_refresh_io_stats(buf_pool); + } +} + +/**********************************************************************//** +Check if all pages in all buffer pools are in a replacable state. +@return FALSE if not */ UNIV_INTERN ibool buf_all_freed(void) /*===============*/ { - buf_chunk_t* chunk; - ulint i; + ulint i; - ut_ad(buf_pool); + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; - //buf_pool_mutex_enter(); /* optimistic */ + buf_pool = buf_pool_from_array(i); - chunk = buf_pool->chunks; - - for (i = buf_pool->n_chunks; i--; chunk++) { - - const buf_block_t* block = buf_chunk_not_freed(chunk); - - if (UNIV_LIKELY_NULL(block)) { - fprintf(stderr, - "Page %lu %lu still fixed or dirty\n", - (ulong) block->page.space, - (ulong) block->page.offset); - ut_error; + if (!buf_all_freed_instance(buf_pool)) { + return(FALSE); } - } - - //buf_pool_mutex_exit(); /* optimistic */ + } return(TRUE); } @@ -4830,25 +5673,32 @@ ibool buf_pool_check_no_pending_io(void) /*==============================*/ { - ibool ret; + ulint i; + ibool ret = TRUE; - //buf_pool_mutex_enter(); - mutex_enter(&buf_pool_mutex); + buf_pool_mutex_enter_all(); - if (buf_pool->n_pend_reads + buf_pool->n_flush[BUF_FLUSH_LRU] - + buf_pool->n_flush[BUF_FLUSH_LIST] - + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]) { - ret = FALSE; - } else { - ret = TRUE; + for (i = 0; i < srv_buf_pool_instances && ret; i++) { + const buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + if (buf_pool->n_pend_reads + + buf_pool->n_flush[BUF_FLUSH_LRU] + + buf_pool->n_flush[BUF_FLUSH_LIST] + + buf_pool->n_flush[BUF_FLUSH_SINGLE_PAGE]) { + + ret = FALSE; + } } - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit_all(); return(ret); } +#if 0 +Code currently not used /*********************************************************************//** Gets the current length of the free list of buffer blocks. @return length of the free list */ @@ -4859,16 +5709,18 @@ buf_get_free_list_len(void) { ulint len; - //buf_pool_mutex_enter(); - mutex_enter(&free_list_mutex); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->free_list_mutex); len = UT_LIST_GET_LEN(buf_pool->free); - //buf_pool_mutex_exit(); - mutex_exit(&free_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->free_list_mutex); return(len); } +#endif + #else /* !UNIV_HOTBACKUP */ /********************************************************************//** Inits a page to the buffer buf_pool, for use in ibbackup --restore. */ diff --git a/storage/xtradb/buf/buf0flu.c b/storage/xtradb/buf/buf0flu.c index 0a03d583549..09d11dd21db 100644 --- a/storage/xtradb/buf/buf0flu.c +++ b/storage/xtradb/buf/buf0flu.c @@ -43,6 +43,8 @@ Created 11/11/1995 Heikki Tuuri #include "log0log.h" #include "os0file.h" #include "trx0sys.h" +#include "mysql/plugin.h" +#include "mysql/service_thd_wait.h" /********************************************************************** These statistics are generated for heuristics used in estimating the @@ -73,7 +75,7 @@ Updated by buf_flush_stat_update(). Not protected by any mutex. */ static buf_flush_stat_t buf_flush_stat_sum; /** Number of pages flushed through non flush_list flushes. */ -static ulint buf_lru_flush_page_count = 0; +// static ulint buf_lru_flush_page_count = 0; /* @} */ @@ -83,27 +85,56 @@ Validates the flush list. @return TRUE if ok */ static ibool -buf_flush_validate_low(void); -/*========================*/ +buf_flush_validate_low( +/*===================*/ + buf_pool_t* buf_pool); /*!< in: Buffer pool instance */ + +/******************************************************************//** +Validates the flush list some of the time. +@return TRUE if ok or the check was skipped */ +static +ibool +buf_flush_validate_skip( +/*====================*/ + buf_pool_t* buf_pool) /*!< in: Buffer pool instance */ +{ +/** Try buf_flush_validate_low() every this many times */ +# define BUF_FLUSH_VALIDATE_SKIP 23 + + /** The buf_flush_validate_low() call skip counter. + Use a signed type because of the race condition below. */ + static int buf_flush_validate_count = BUF_FLUSH_VALIDATE_SKIP; + + /* There is a race condition below, but it does not matter, + because this call is only for heuristic purposes. We want to + reduce the call frequency of the costly buf_flush_validate_low() + check in debug builds. */ + if (--buf_flush_validate_count > 0) { + return(TRUE); + } + + buf_flush_validate_count = BUF_FLUSH_VALIDATE_SKIP; + return(buf_flush_validate_low(buf_pool)); +} #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ -/********************************************************************//** +/******************************************************************//** Insert a block in the flush_rbt and returns a pointer to its predecessor or NULL if no predecessor. The ordering is maintained on the basis of the key. -@return pointer to the predecessor or NULL if no predecessor. */ +@return pointer to the predecessor or NULL if no predecessor. */ static buf_page_t* buf_flush_insert_in_flush_rbt( /*==========================*/ - buf_page_t* bpage) /*!< in: bpage to be inserted. */ + buf_page_t* bpage) /*!< in: bpage to be inserted. */ { - buf_page_t* prev = NULL; const ib_rbt_node_t* c_node; const ib_rbt_node_t* p_node; + buf_page_t* prev = NULL; + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&flush_list_mutex)); + ut_ad(buf_flush_list_mutex_own(buf_pool)); /* Insert this buffer into the rbt. */ c_node = rbt_insert(buf_pool->flush_rbt, &bpage, &bpage); @@ -113,31 +144,39 @@ buf_flush_insert_in_flush_rbt( p_node = rbt_prev(buf_pool->flush_rbt, c_node); if (p_node != NULL) { - prev = *rbt_value(buf_page_t*, p_node); + buf_page_t** value; + value = rbt_value(buf_page_t*, p_node); + prev = *value; ut_a(prev != NULL); } return(prev); } -/********************************************************************//** +/*********************************************************//** Delete a bpage from the flush_rbt. */ static void buf_flush_delete_from_flush_rbt( /*============================*/ - buf_page_t* bpage) /*!< in: bpage to be removed. */ + buf_page_t* bpage) /*!< in: bpage to be removed. */ { +#ifdef UNIV_DEBUG + ibool ret = FALSE; +#endif /* UNIV_DEBUG */ + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); - ibool ret = FALSE; + ut_ad(buf_flush_list_mutex_own(buf_pool)); + +#ifdef UNIV_DEBUG + ret = +#endif /* UNIV_DEBUG */ + rbt_delete(buf_pool->flush_rbt, &bpage); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&flush_list_mutex)); - ret = rbt_delete(buf_pool->flush_rbt, &bpage); ut_ad(ret); } -/********************************************************************//** +/*****************************************************************//** Compare two modified blocks in the buffer pool. The key for comparison is: key = @@ -146,7 +185,7 @@ buf_pool->flush_rbt. Note that for the purpose of flush_rbt, we only need to order blocks on the oldest_modification. The other two fields are used to uniquely identify the blocks. -@return < 0 if b2 < b1, 0 if b2 == b1, > 0 if b2 > b1 */ +@return < 0 if b2 < b1, 0 if b2 == b1, > 0 if b2 > b1 */ static int buf_flush_block_cmp( @@ -154,29 +193,24 @@ buf_flush_block_cmp( const void* p1, /*!< in: block1 */ const void* p2) /*!< in: block2 */ { - int ret; - const buf_page_t* b1; - const buf_page_t* b2; - - ut_ad(p1 != NULL); - ut_ad(p2 != NULL); - - b1 = *(const buf_page_t**) p1; - b2 = *(const buf_page_t**) p2; + int ret; + const buf_page_t* b1 = *(const buf_page_t**) p1; + const buf_page_t* b2 = *(const buf_page_t**) p2; +#ifdef UNIV_DEBUG + buf_pool_t* buf_pool = buf_pool_from_bpage(b1); +#endif /* UNIV_DEBUG */ ut_ad(b1 != NULL); ut_ad(b2 != NULL); + ut_ad(buf_flush_list_mutex_own(buf_pool)); + ut_ad(b1->in_flush_list); ut_ad(b2->in_flush_list); - if (b2->oldest_modification - > b1->oldest_modification) { + if (b2->oldest_modification > b1->oldest_modification) { return(1); - } - - if (b2->oldest_modification - < b1->oldest_modification) { + } else if (b2->oldest_modification < b1->oldest_modification) { return(-1); } @@ -196,14 +230,21 @@ void buf_flush_init_flush_rbt(void) /*==========================*/ { - //buf_pool_mutex_enter(); - mutex_enter(&flush_list_mutex); + ulint i; - /* Create red black tree for speedy insertions in flush list. */ - buf_pool->flush_rbt = rbt_create(sizeof(buf_page_t*), - buf_flush_block_cmp); - //buf_pool_mutex_exit(); - mutex_exit(&flush_list_mutex); + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + buf_flush_list_mutex_enter(buf_pool); + + /* Create red black tree for speedy insertions in flush list. */ + buf_pool->flush_rbt = rbt_create( + sizeof(buf_page_t*), buf_flush_block_cmp); + + buf_flush_list_mutex_exit(buf_pool); + } } /********************************************************************//** @@ -213,18 +254,24 @@ void buf_flush_free_flush_rbt(void) /*==========================*/ { - //buf_pool_mutex_enter(); - mutex_enter(&flush_list_mutex); + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + buf_flush_list_mutex_enter(buf_pool); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG - ut_a(buf_flush_validate_low()); + ut_a(buf_flush_validate_low(buf_pool)); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ - rbt_free(buf_pool->flush_rbt); - buf_pool->flush_rbt = NULL; + rbt_free(buf_pool->flush_rbt); + buf_pool->flush_rbt = NULL; - //buf_pool_mutex_exit(); - mutex_exit(&flush_list_mutex); + buf_flush_list_mutex_exit(buf_pool); + } } /********************************************************************//** @@ -233,28 +280,33 @@ UNIV_INTERN void buf_flush_insert_into_flush_list( /*=============================*/ - buf_block_t* block) /*!< in/out: block which is modified */ + buf_pool_t* buf_pool, /*!< buffer pool instance */ + buf_block_t* block, /*!< in/out: block which is modified */ + ib_uint64_t lsn) /*!< in: oldest modification */ { - //ut_ad(buf_pool_mutex_own()); + ut_ad(!buf_pool_mutex_own(buf_pool)); + ut_ad(log_flush_order_mutex_own()); ut_ad(mutex_own(&block->mutex)); - ut_ad(mutex_own(&flush_list_mutex)); + + buf_flush_list_mutex_enter(buf_pool); + ut_ad((UT_LIST_GET_FIRST(buf_pool->flush_list) == NULL) || (UT_LIST_GET_FIRST(buf_pool->flush_list)->oldest_modification - <= block->page.oldest_modification)); + <= lsn)); /* If we are in the recovery then we need to update the flush red-black tree as well. */ if (UNIV_LIKELY_NULL(buf_pool->flush_rbt)) { - buf_flush_insert_sorted_into_flush_list(block); + buf_flush_list_mutex_exit(buf_pool); + buf_flush_insert_sorted_into_flush_list(buf_pool, block, lsn); return; } ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); - ut_ad(block->page.in_LRU_list); - ut_ad(block->page.in_page_hash); - ut_ad(!block->page.in_zip_hash); ut_ad(!block->page.in_flush_list); + ut_d(block->page.in_flush_list = TRUE); + block->page.oldest_modification = lsn; UT_LIST_ADD_FIRST(flush_list, buf_pool->flush_list, &block->page); #ifdef UNIV_DEBUG_VALGRIND @@ -269,8 +321,10 @@ buf_flush_insert_into_flush_list( } #endif /* UNIV_DEBUG_VALGRIND */ #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG - ut_a(buf_flush_validate_low()); + ut_a(buf_flush_validate_skip(buf_pool)); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ + + buf_flush_list_mutex_exit(buf_pool); } /********************************************************************//** @@ -281,21 +335,39 @@ UNIV_INTERN void buf_flush_insert_sorted_into_flush_list( /*====================================*/ - buf_block_t* block) /*!< in/out: block which is modified */ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + buf_block_t* block, /*!< in/out: block which is modified */ + ib_uint64_t lsn) /*!< in: oldest modification */ { buf_page_t* prev_b; buf_page_t* b; - //ut_ad(buf_pool_mutex_own()); + ut_ad(!buf_pool_mutex_own(buf_pool)); + ut_ad(log_flush_order_mutex_own()); ut_ad(mutex_own(&block->mutex)); - ut_ad(mutex_own(&flush_list_mutex)); ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); + buf_flush_list_mutex_enter(buf_pool); + + /* The field in_LRU_list is protected by buf_pool->mutex, which + we are not holding. However, while a block is in the flush + list, it is dirty and cannot be discarded, not from the + page_hash or from the LRU list. At most, the uncompressed + page frame of a compressed block may be discarded or created + (copying the block->page to or from a buf_page_t that is + dynamically allocated from buf_buddy_alloc()). Because those + transitions hold block->mutex and the flush list mutex (via + buf_flush_relocate_on_flush_list()), there is no possibility + of a race condition in the assertions below. */ ut_ad(block->page.in_LRU_list); ut_ad(block->page.in_page_hash); + /* buf_buddy_block_register() will take a block in the + BUF_BLOCK_MEMORY state, not a file page. */ ut_ad(!block->page.in_zip_hash); + ut_ad(!block->page.in_flush_list); ut_d(block->page.in_flush_list = TRUE); + block->page.oldest_modification = lsn; #ifdef UNIV_DEBUG_VALGRIND { @@ -341,8 +413,10 @@ buf_flush_insert_sorted_into_flush_list( } #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG - ut_a(buf_flush_validate_low()); + ut_a(buf_flush_validate_low(buf_pool)); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ + + buf_flush_list_mutex_exit(buf_pool); } /********************************************************************//** @@ -356,13 +430,16 @@ buf_flush_ready_for_replace( buf_page_t* bpage) /*!< in: buffer control block, must be buf_page_in_file(bpage) and in the LRU list */ { - //ut_ad(buf_pool_mutex_own()); +#ifdef UNIV_DEBUG + //buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + //ut_ad(buf_pool_mutex_own(buf_pool)); +#endif ut_ad(mutex_own(buf_page_get_mutex(bpage))); - //ut_ad(bpage->in_LRU_list); /* optimistic use */ + //ut_ad(bpage->in_LRU_list); if (UNIV_LIKELY(bpage->in_LRU_list && buf_page_in_file(bpage))) { - return(bpage->oldest_modification == 0 + return((bpage->oldest_modification == 0 || bpage->space_was_being_deleted) && buf_page_get_io_fix(bpage) == BUF_IO_NONE && bpage->buf_fix_count == 0); } @@ -392,8 +469,11 @@ buf_flush_ready_for_flush( buf_page_in_file(bpage) */ enum buf_flush flush_type)/*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ { +#ifdef UNIV_DEBUG + //buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + //ut_ad(buf_pool_mutex_own(buf_pool)); +#endif //ut_a(buf_page_in_file(bpage)); - //ut_ad(buf_pool_mutex_own()); /*optimistic...*/ ut_ad(mutex_own(buf_page_get_mutex(bpage))); ut_ad(flush_type == BUF_FLUSH_LRU || BUF_FLUSH_LIST); @@ -401,6 +481,13 @@ buf_flush_ready_for_flush( && buf_page_get_io_fix(bpage) == BUF_IO_NONE) { ut_ad(bpage->in_flush_list); + if (bpage->space_was_being_deleted) { + /* should be removed from flush_list here */ + /* because buf_flush_try_neighbors() cannot flush without fil_space_get_size(space) */ + buf_flush_remove(bpage); + return(FALSE); + } + if (flush_type != BUF_FLUSH_LRU) { return(TRUE); @@ -426,22 +513,22 @@ buf_flush_remove( /*=============*/ buf_page_t* bpage) /*!< in: pointer to the block in question */ { - //ut_ad(buf_pool_mutex_own()); + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + + //ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(mutex_own(buf_page_get_mutex(bpage))); - - mutex_enter(&flush_list_mutex); - ut_ad(bpage->in_flush_list); + buf_flush_list_mutex_enter(buf_pool); + switch (buf_page_get_state(bpage)) { case BUF_BLOCK_ZIP_PAGE: - /* clean compressed pages should not be on the flush list */ + /* Clean compressed pages should not be on the flush list */ case BUF_BLOCK_ZIP_FREE: case BUF_BLOCK_NOT_USED: case BUF_BLOCK_READY_FOR_USE: case BUF_BLOCK_MEMORY: case BUF_BLOCK_REMOVE_HASH: - mutex_exit(&flush_list_mutex); ut_error; return; case BUF_BLOCK_ZIP_DIRTY: @@ -454,7 +541,7 @@ buf_flush_remove( break; } - /* If the flush_rbt is active then delete from it as well. */ + /* If the flush_rbt is active then delete from there as well. */ if (UNIV_LIKELY_NULL(buf_pool->flush_rbt)) { buf_flush_delete_from_flush_rbt(bpage); } @@ -465,15 +552,24 @@ buf_flush_remove( bpage->oldest_modification = 0; - ut_d(UT_LIST_VALIDATE(flush_list, buf_page_t, buf_pool->flush_list, - ut_ad(ut_list_node_313->in_flush_list))); - mutex_exit(&flush_list_mutex); +#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG + ut_a(buf_flush_validate_skip(buf_pool)); +#endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ + + buf_flush_list_mutex_exit(buf_pool); } -/********************************************************************//** +/*******************************************************************//** Relocates a buffer control block on the flush_list. -Note that it is assumed that the contents of bpage has already been -copied to dpage. */ +Note that it is assumed that the contents of bpage have already been +copied to dpage. +IMPORTANT: When this function is called bpage and dpage are not +exact copies of each other. For example, they both will have different +::state. Also the ::list pointers in dpage may be stale. We need to +use the current list node (bpage) to do the list manipulation because +the list pointers could have changed between the time that we copied +the contents of bpage to the dpage and the flush list manipulation +below. */ UNIV_INTERN void buf_flush_relocate_on_flush_list( @@ -481,14 +577,25 @@ buf_flush_relocate_on_flush_list( buf_page_t* bpage, /*!< in/out: control block being moved */ buf_page_t* dpage) /*!< in/out: destination block */ { - buf_page_t* prev; - buf_page_t* prev_b = NULL; + buf_page_t* prev; + buf_page_t* prev_b = NULL; + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&flush_list_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + /* Must reside in the same buffer pool. */ + ut_ad(buf_pool == buf_pool_from_bpage(dpage)); ut_ad(mutex_own(buf_page_get_mutex(bpage))); + buf_flush_list_mutex_enter(buf_pool); + + /* FIXME: At this point we have both buf_pool and flush_list + mutexes. Theoretically removal of a block from flush list is + only covered by flush_list mutex but currently we do + have buf_pool mutex in buf_flush_remove() therefore this block + is guaranteed to be in the flush list. We need to check if + this will work without the assumption of block removing code + having the buf_pool mutex. */ ut_ad(bpage->in_flush_list); ut_ad(dpage->in_flush_list); @@ -524,8 +631,10 @@ buf_flush_relocate_on_flush_list( ut_a(!buf_pool->flush_rbt || prev_b == prev); #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG - ut_a(buf_flush_validate_low()); + ut_a(buf_flush_validate_low(buf_pool)); #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ + + buf_flush_list_mutex_exit(buf_pool); } /********************************************************************//** @@ -537,6 +646,7 @@ buf_flush_write_complete( buf_page_t* bpage) /*!< in: pointer to the block in question */ { enum buf_flush flush_type; + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); ut_ad(bpage); @@ -557,8 +667,8 @@ buf_flush_write_complete( /* fprintf(stderr, "n pending flush %lu\n", buf_pool->n_flush[flush_type]); */ - if ((buf_pool->n_flush[flush_type] == 0) - && (buf_pool->init_flush[flush_type] == FALSE)) { + if (buf_pool->n_flush[flush_type] == 0 + && buf_pool->init_flush[flush_type] == FALSE) { /* The running flush batch has ended */ @@ -757,7 +867,7 @@ corrupted_page: flush: /* Now flush the doublewrite buffer data to disk */ - fil_flush(srv_doublewrite_file ? TRX_DOUBLEWRITE_SPACE : TRX_SYS_SPACE); + fil_flush(srv_doublewrite_file ? TRX_DOUBLEWRITE_SPACE : TRX_SYS_SPACE, FALSE); /* We know that the writes have been flushed to disk now and in recovery we will find them in the doublewrite buffer @@ -920,8 +1030,8 @@ buf_flush_init_for_writing( case FIL_PAGE_TYPE_ZBLOB: case FIL_PAGE_TYPE_ZBLOB2: case FIL_PAGE_INDEX: - mach_write_ull(page_zip->data - + FIL_PAGE_LSN, newest_lsn); + mach_write_to_8(page_zip->data + + FIL_PAGE_LSN, newest_lsn); memset(page_zip->data + FIL_PAGE_FILE_FLUSH_LSN, 0, 8); mach_write_to_4(page_zip->data + FIL_PAGE_SPACE_OR_CHKSUM, @@ -943,10 +1053,10 @@ buf_flush_init_for_writing( } /* Write the newest modification lsn to the page header and trailer */ - mach_write_ull(page + FIL_PAGE_LSN, newest_lsn); + mach_write_to_8(page + FIL_PAGE_LSN, newest_lsn); - mach_write_ull(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, - newest_lsn); + mach_write_to_8(page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM, + newest_lsn); /* Store the new formula checksum */ @@ -981,20 +1091,26 @@ buf_flush_write_block_low( { ulint zip_size = buf_page_get_zip_size(bpage); page_t* frame = NULL; + +#ifdef UNIV_DEBUG + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + //ut_ad(!buf_pool_mutex_own(buf_pool)); +#endif + #ifdef UNIV_LOG_DEBUG static ibool univ_log_debug_warned; #endif /* UNIV_LOG_DEBUG */ ut_ad(buf_page_in_file(bpage)); - /* We are not holding buf_pool_mutex or block_mutex here. + /* We are not holding buf_pool->mutex or block_mutex here. Nevertheless, it is safe to access bpage, because it is io_fixed and oldest_modification != 0. Thus, it cannot be relocated in the buffer pool or removed from flush_list or LRU_list. */ - //ut_ad(!buf_pool_mutex_own()); - ut_ad(!mutex_own(&LRU_list_mutex)); - ut_ad(!mutex_own(&flush_list_mutex)); + //ut_ad(!buf_pool_mutex_own(buf_pool)); + ut_ad(!mutex_own(&buf_pool->LRU_list_mutex)); + ut_ad(!buf_flush_list_mutex_own(buf_pool)); ut_ad(!mutex_own(buf_page_get_mutex(bpage))); ut_ad(buf_page_get_io_fix(bpage) == BUF_IO_WRITE); ut_ad(bpage->oldest_modification != 0); @@ -1031,8 +1147,8 @@ buf_flush_write_block_low( ut_a(mach_read_from_4(frame + FIL_PAGE_SPACE_OR_CHKSUM) == page_zip_calc_checksum(frame, zip_size)); } - mach_write_ull(frame + FIL_PAGE_LSN, - bpage->newest_modification); + mach_write_to_8(frame + FIL_PAGE_LSN, + bpage->newest_modification); memset(frame + FIL_PAGE_FILE_FLUSH_LSN, 0, 8); break; case BUF_BLOCK_FILE_PAGE: @@ -1059,17 +1175,98 @@ buf_flush_write_block_low( } } +# if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG +/********************************************************************//** +Writes a flushable page asynchronously from the buffer pool to a file. +NOTE: buf_pool->mutex and block->mutex must be held upon entering this +function, and they will be released by this function after flushing. +This is loosely based on buf_flush_batch() and buf_flush_page(). +@return TRUE if the page was flushed and the mutexes released */ +UNIV_INTERN +ibool +buf_flush_page_try( +/*===============*/ + buf_pool_t* buf_pool, /*!< in/out: buffer pool instance */ + buf_block_t* block) /*!< in/out: buffer control block */ +{ + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE); + ut_ad(mutex_own(&block->mutex)); + + if (!buf_flush_ready_for_flush(&block->page, BUF_FLUSH_LRU)) { + return(FALSE); + } + + buf_pool_mutex_enter(buf_pool); + + if (buf_pool->n_flush[BUF_FLUSH_LRU] > 0 + || buf_pool->init_flush[BUF_FLUSH_LRU]) { + buf_pool_mutex_exit(buf_pool); + /* There is already a flush batch of the same type running */ + return(FALSE); + } + + buf_pool->init_flush[BUF_FLUSH_LRU] = TRUE; + + buf_page_set_io_fix(&block->page, BUF_IO_WRITE); + + buf_page_set_flush_type(&block->page, BUF_FLUSH_LRU); + + if (buf_pool->n_flush[BUF_FLUSH_LRU]++ == 0) { + + os_event_reset(buf_pool->no_flush[BUF_FLUSH_LRU]); + } + + /* VERY IMPORTANT: + Because any thread may call the LRU flush, even when owning + locks on pages, to avoid deadlocks, we must make sure that the + s-lock is acquired on the page without waiting: this is + accomplished because buf_flush_ready_for_flush() must hold, + and that requires the page not to be bufferfixed. */ + + rw_lock_s_lock_gen(&block->lock, BUF_IO_WRITE); + + /* Note that the s-latch is acquired before releasing the + buf_pool mutex: this ensures that the latch is acquired + immediately. */ + + mutex_exit(&block->mutex); + buf_pool_mutex_exit(buf_pool); + + /* Even though block is not protected by any mutex at this + point, it is safe to access block, because it is io_fixed and + oldest_modification != 0. Thus, it cannot be relocated in the + buffer pool or removed from flush_list or LRU_list. */ + + buf_flush_write_block_low(&block->page); + + buf_pool_mutex_enter(buf_pool); + buf_pool->init_flush[BUF_FLUSH_LRU] = FALSE; + + if (buf_pool->n_flush[BUF_FLUSH_LRU] == 0) { + /* The running flush batch has ended */ + os_event_set(buf_pool->no_flush[BUF_FLUSH_LRU]); + } + + buf_pool_mutex_exit(buf_pool); + buf_flush_buffered_writes(); + + return(TRUE); +} +# endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ + /********************************************************************//** Writes a flushable page asynchronously from the buffer pool to a file. NOTE: in simulated aio we must call os_aio_simulated_wake_handler_threads after we have posted a batch of -writes! NOTE: buf_pool_mutex and buf_page_get_mutex(bpage) must be +writes! NOTE: buf_pool->mutex and buf_page_get_mutex(bpage) must be held upon entering this function, and they will be released by this function. */ static void buf_flush_page( /*===========*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ buf_page_t* bpage, /*!< in: buffer control block */ enum buf_flush flush_type) /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ @@ -1078,18 +1275,17 @@ buf_flush_page( ibool is_uncompressed; ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST); - //ut_ad(buf_pool_mutex_own()); + //ut_ad(buf_pool_mutex_own(buf_pool)); #ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX) - || rw_lock_own(&page_hash_latch, RW_LOCK_SHARED)); + ut_ad(rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_SHARED)); #endif ut_ad(buf_page_in_file(bpage)); block_mutex = buf_page_get_mutex(bpage); ut_ad(mutex_own(block_mutex)); - mutex_enter(&buf_pool_mutex); - rw_lock_s_unlock(&page_hash_latch); + buf_pool_mutex_enter(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); ut_ad(buf_flush_ready_for_flush(bpage, flush_type)); @@ -1105,7 +1301,7 @@ buf_flush_page( buf_pool->n_flush[flush_type]++; is_uncompressed = (buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE); - ut_ad(is_uncompressed == (block_mutex != &buf_pool_zip_mutex)); + ut_ad(is_uncompressed == (block_mutex != &buf_pool->zip_mutex)); switch (flush_type) { ibool is_s_latched; @@ -1121,8 +1317,7 @@ buf_flush_page( } mutex_exit(block_mutex); - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); /* Even though bpage is not protected by any mutex at this point, it is safe to access bpage, because it is @@ -1159,8 +1354,7 @@ buf_flush_page( immediately. */ mutex_exit(block_mutex); - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); break; default: @@ -1193,27 +1387,35 @@ buf_flush_try_neighbors( ulint offset, /*!< in: page offset */ enum buf_flush flush_type, /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ - ulint flush_neighbors) + ulint n_flushed, /*!< in: number of pages + flushed so far in this batch */ + ulint n_to_flush) /*!< in: maximum number of pages + we are allowed to flush */ { - buf_page_t* bpage; - ulint low, high; - ulint count = 0; ulint i; + ulint low; + ulint high; + ulint count = 0; + buf_pool_t* buf_pool = buf_pool_get(space, offset); ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST); - if (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN || !flush_neighbors) { - /* If there is little space, it is better not to flush any - block except from the end of the LRU list */ + if (UT_LIST_GET_LEN(buf_pool->LRU) < BUF_LRU_OLD_MIN_LEN || !srv_flush_neighbor_pages) { + /* If there is little space, it is better not to flush + any block except from the end of the LRU list */ low = offset; high = offset + 1; } else { - /* When flushed, dirty blocks are searched in neighborhoods of - this size, and flushed along with the original page. */ + /* When flushed, dirty blocks are searched in + neighborhoods of this size, and flushed along with the + original page. */ - ulint buf_flush_area = ut_min(BUF_READ_AHEAD_AREA, - buf_pool->curr_size / 16); + ulint buf_flush_area; + + buf_flush_area = ut_min( + BUF_READ_AHEAD_AREA(buf_pool), + buf_pool->curr_size / 16); low = (offset / buf_flush_area) * buf_flush_area; high = (offset / buf_flush_area + 1) * buf_flush_area; @@ -1225,15 +1427,37 @@ buf_flush_try_neighbors( high = fil_space_get_size(space); } - //buf_pool_mutex_enter(); - rw_lock_s_lock(&page_hash_latch); - for (i = low; i < high; i++) { - bpage = buf_page_hash_get(space, i); + buf_page_t* bpage; + + if ((count + n_flushed) >= n_to_flush) { + + /* We have already flushed enough pages and + should call it a day. There is, however, one + exception. If the page whose neighbors we + are flushing has not been flushed yet then + we'll try to flush the victim that we + selected originally. */ + if (i <= offset) { + i = offset; + } else { + break; + } + } + + buf_pool = buf_pool_get(space, i); + + //buf_pool_mutex_enter(buf_pool); + rw_lock_s_lock(&buf_pool->page_hash_latch); + + /* We only want to flush pages from this buffer pool. */ + bpage = buf_page_hash_get(buf_pool, space, i); if (!bpage) { + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); continue; } @@ -1250,27 +1474,259 @@ buf_flush_try_neighbors( if (block_mutex && buf_flush_ready_for_flush(bpage, flush_type) && (i == offset || !bpage->buf_fix_count)) { /* We only try to flush those - neighbors != offset where the buf fix count is - zero, as we then know that we probably can - latch the page without a semaphore wait. - Semaphore waits are expensive because we must - flush the doublewrite buffer before we start + neighbors != offset where the buf fix + count is zero, as we then know that we + probably can latch the page without a + semaphore wait. Semaphore waits are + expensive because we must flush the + doublewrite buffer before we start waiting. */ - buf_flush_page(bpage, flush_type); + buf_flush_page(buf_pool, bpage, flush_type); ut_ad(!mutex_own(block_mutex)); + ut_ad(!buf_pool_mutex_own(buf_pool)); count++; - - //buf_pool_mutex_enter(); - rw_lock_s_lock(&page_hash_latch); + continue; } else if (block_mutex) { mutex_exit(block_mutex); } } + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); } - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + return(count); +} + +/********************************************************************//** +Check if the block is modified and ready for flushing. If the the block +is ready to flush then flush the page and try o flush its neighbors. + +@return TRUE if buf_pool mutex was not released during this function. +This does not guarantee that some pages were written as well. +Number of pages written are incremented to the count. */ +static +ibool +buf_flush_page_and_try_neighbors( +/*=============================*/ + buf_page_t* bpage, /*!< in: buffer control block, + must be + buf_page_in_file(bpage) */ + enum buf_flush flush_type, /*!< in: BUF_FLUSH_LRU + or BUF_FLUSH_LIST */ + ulint n_to_flush, /*!< in: number of pages to + flush */ + ulint* count) /*!< in/out: number of pages + flushed */ +{ + mutex_t* block_mutex; + ibool flushed = FALSE; +#ifdef UNIV_DEBUG + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); +#endif /* UNIV_DEBUG */ + + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(flush_type != BUF_FLUSH_LRU + || mutex_own(&buf_pool->LRU_list_mutex)); + + block_mutex = buf_page_get_mutex_enter(bpage); + + //ut_a(buf_page_in_file(bpage)); + + if (block_mutex && buf_flush_ready_for_flush(bpage, flush_type)) { + ulint space; + ulint offset; + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_bpage(bpage); + + //buf_pool_mutex_exit(buf_pool); + if (flush_type == BUF_FLUSH_LRU) { + mutex_exit(&buf_pool->LRU_list_mutex); + } + + /* These fields are protected by both the + buffer pool mutex and block mutex. */ + space = buf_page_get_space(bpage); + offset = buf_page_get_page_no(bpage); + + mutex_exit(block_mutex); + + /* Try to flush also all the neighbors */ + *count += buf_flush_try_neighbors(space, + offset, + flush_type, + *count, + n_to_flush); + + //buf_pool_mutex_enter(buf_pool); + if (flush_type == BUF_FLUSH_LRU) { + mutex_enter(&buf_pool->LRU_list_mutex); + } + flushed = TRUE; + } else if (block_mutex) { + mutex_exit(block_mutex); + } + + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(flush_type != BUF_FLUSH_LRU + || mutex_own(&buf_pool->LRU_list_mutex)); + + return(flushed); +} + +/*******************************************************************//** +This utility flushes dirty blocks from the end of the LRU list. +In the case of an LRU flush the calling thread may own latches to +pages: to avoid deadlocks, this function must be written so that it +cannot end up waiting for these latches! +@return number of blocks for which the write request was queued. */ +static +ulint +buf_flush_LRU_list_batch( +/*=====================*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + ulint max) /*!< in: max of blocks to flush */ +{ + buf_page_t* bpage; + ulint count = 0; + + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); + + do { + /* Start from the end of the list looking for a + suitable block to be flushed. */ + bpage = UT_LIST_GET_LAST(buf_pool->LRU); + + /* Iterate backwards over the flush list till we find + a page that isn't ready for flushing. */ + while (bpage != NULL + && !buf_flush_page_and_try_neighbors( + bpage, BUF_FLUSH_LRU, max, &count)) { + + bpage = UT_LIST_GET_PREV(LRU, bpage); + } + } while (bpage != NULL && count < max); + + /* We keep track of all flushes happening as part of LRU + flush. When estimating the desired rate at which flush_list + should be flushed, we factor in this value. */ + buf_lru_flush_page_count += count; + + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); + + return(count); +} + +/*******************************************************************//** +This utility flushes dirty blocks from the end of the flush_list. +the calling thread is not allowed to own any latches on pages! +@return number of blocks for which the write request was queued; +ULINT_UNDEFINED if there was a flush of the same type already +running */ +static +ulint +buf_flush_flush_list_batch( +/*=======================*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + ulint min_n, /*!< in: wished minimum mumber + of blocks flushed (it is not + guaranteed that the actual + number is that big, though) */ + ib_uint64_t lsn_limit) /*!< all blocks whose + oldest_modification is smaller + than this should be flushed (if + their number does not exceed + min_n) */ +{ + ulint len; + buf_page_t* bpage; + buf_page_t* prev_bpage = NULL; + ulint count = 0; + + //ut_ad(buf_pool_mutex_own(buf_pool)); + + /* If we have flushed enough, leave the loop */ + do { + /* Start from the end of the list looking for a suitable + block to be flushed. */ + + buf_flush_list_mutex_enter(buf_pool); + + /* We use len here because theoretically insertions can + happen in the flush_list below while we are traversing + it for a suitable candidate for flushing. We'd like to + set a limit on how farther we are willing to traverse + the list. */ + len = UT_LIST_GET_LEN(buf_pool->flush_list); + bpage = UT_LIST_GET_LAST(buf_pool->flush_list); + + if (bpage) { + ut_a(bpage->oldest_modification > 0); + prev_bpage = UT_LIST_GET_PREV(flush_list, bpage); + } + + if (!bpage || bpage->oldest_modification >= lsn_limit) { + + /* We have flushed enough */ + buf_flush_list_mutex_exit(buf_pool); + break; + } + + ut_a(bpage->oldest_modification > 0); + + ut_ad(bpage->in_flush_list); + + buf_flush_list_mutex_exit(buf_pool); + + /* The list may change during the flushing and we cannot + safely preserve within this function a pointer to a + block in the list! */ + while (bpage != NULL + && len > 0 + && !buf_flush_page_and_try_neighbors( + bpage, BUF_FLUSH_LIST, min_n, &count)) { + + buf_flush_list_mutex_enter(buf_pool); + + /* If we are here that means that buf_pool->mutex + was not released in buf_flush_page_and_try_neighbors() + above and this guarantees that bpage didn't get + relocated since we released the flush_list + mutex above. There is a chance, however, that + the bpage got removed from flush_list (not + currently possible because flush_list_remove() + also obtains buf_pool mutex but that may change + in future). To avoid this scenario we check + the oldest_modification and if it is zero + we start all over again. */ + if (bpage->oldest_modification == 0) { + buf_flush_list_mutex_exit(buf_pool); + break; + } + + bpage = UT_LIST_GET_PREV(flush_list, bpage); + + //ut_ad(!bpage || bpage->in_flush_list); + if (bpage != prev_bpage) { + /* the search might warp.. retrying */ + buf_flush_list_mutex_exit(buf_pool); + break; + } + if (bpage) { + prev_bpage = UT_LIST_GET_PREV(flush_list, bpage); + } + + buf_flush_list_mutex_exit(buf_pool); + + --len; + } + + } while (count < min_n && bpage != NULL && len > 0); + + //ut_ad(buf_pool_mutex_own(buf_pool)); return(count); } @@ -1283,10 +1739,11 @@ end up waiting for these latches! NOTE 2: in the case of a flush list flush, the calling thread is not allowed to own any latches on pages! @return number of blocks for which the write request was queued; ULINT_UNDEFINED if there was a flush of the same type already running */ -UNIV_INTERN +static ulint buf_flush_batch( /*============*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ enum buf_flush flush_type, /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST; if BUF_FLUSH_LIST, then the caller must not own any @@ -1294,157 +1751,127 @@ buf_flush_batch( ulint min_n, /*!< in: wished minimum mumber of blocks flushed (it is not guaranteed that the actual number is that big, though) */ - ib_uint64_t lsn_limit) /*!< in the case BUF_FLUSH_LIST all - blocks whose oldest_modification is + ib_uint64_t lsn_limit) /*!< in: in the case of BUF_FLUSH_LIST + all blocks whose oldest_modification is smaller than this should be flushed (if their number does not exceed min_n), otherwise ignored */ { - buf_page_t* bpage; - buf_page_t* prev_bpage = NULL; - ulint page_count = 0; - ulint old_page_count; - ulint space; - ulint offset; - ulint remaining = 0; + ulint count = 0; - ut_ad((flush_type == BUF_FLUSH_LRU) - || (flush_type == BUF_FLUSH_LIST)); + ut_ad(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST); #ifdef UNIV_SYNC_DEBUG ut_ad((flush_type != BUF_FLUSH_LIST) - || sync_thread_levels_empty_gen(TRUE)); + || sync_thread_levels_empty_except_dict()); #endif /* UNIV_SYNC_DEBUG */ - //buf_pool_mutex_enter(); - mutex_enter(&buf_pool_mutex); - if ((buf_pool->n_flush[flush_type] > 0) - || (buf_pool->init_flush[flush_type] == TRUE)) { + //buf_pool_mutex_enter(buf_pool); + + /* Note: The buffer pool mutex is released and reacquired within + the flush functions. */ + switch(flush_type) { + case BUF_FLUSH_LRU: + mutex_enter(&buf_pool->LRU_list_mutex); + count = buf_flush_LRU_list_batch(buf_pool, min_n); + mutex_exit(&buf_pool->LRU_list_mutex); + break; + case BUF_FLUSH_LIST: + count = buf_flush_flush_list_batch(buf_pool, min_n, lsn_limit); + break; + default: + ut_error; + } + + //buf_pool_mutex_exit(buf_pool); + + buf_flush_buffered_writes(); + +#ifdef UNIV_DEBUG + if (buf_debug_prints && count > 0) { + fprintf(stderr, flush_type == BUF_FLUSH_LRU + ? "Flushed %lu pages in LRU flush\n" + : "Flushed %lu pages in flush list flush\n", + (ulong) count); + } +#endif /* UNIV_DEBUG */ + + srv_buf_pool_flushed += count; + + return(count); +} + +/******************************************************************//** +Gather the aggregated stats for both flush list and LRU list flushing */ +static +void +buf_flush_common( +/*=============*/ + enum buf_flush flush_type, /*!< in: type of flush */ + ulint page_count) /*!< in: number of pages flushed */ +{ + buf_flush_buffered_writes(); + + ut_a(flush_type == BUF_FLUSH_LRU || flush_type == BUF_FLUSH_LIST); + +#ifdef UNIV_DEBUG + if (buf_debug_prints && page_count > 0) { + fprintf(stderr, flush_type == BUF_FLUSH_LRU + ? "Flushed %lu pages in LRU flush\n" + : "Flushed %lu pages in flush list flush\n", + (ulong) page_count); + } +#endif /* UNIV_DEBUG */ + + srv_buf_pool_flushed += page_count; + + if (flush_type == BUF_FLUSH_LRU) { + /* We keep track of all flushes happening as part of LRU + flush. When estimating the desired rate at which flush_list + should be flushed we factor in this value. */ + buf_lru_flush_page_count += page_count; + } +} + +/******************************************************************//** +Start a buffer flush batch for LRU or flush list */ +static +ibool +buf_flush_start( +/*============*/ + buf_pool_t* buf_pool, /*!< buffer pool instance */ + enum buf_flush flush_type) /*!< in: BUF_FLUSH_LRU + or BUF_FLUSH_LIST */ +{ + buf_pool_mutex_enter(buf_pool); + + if (buf_pool->n_flush[flush_type] > 0 + || buf_pool->init_flush[flush_type] == TRUE) { /* There is already a flush batch of the same type running */ - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); - return(ULINT_UNDEFINED); + return(FALSE); } buf_pool->init_flush[flush_type] = TRUE; - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); - if (flush_type == BUF_FLUSH_LRU) { - mutex_enter(&LRU_list_mutex); - } + return(TRUE); +} - for (;;) { -flush_next: - /* If we have flushed enough, leave the loop */ - if (page_count >= min_n) { - - break; - } - - /* Start from the end of the list looking for a suitable - block to be flushed. */ - - if (flush_type == BUF_FLUSH_LRU) { - bpage = UT_LIST_GET_LAST(buf_pool->LRU); - } else { - ut_ad(flush_type == BUF_FLUSH_LIST); - - mutex_enter(&flush_list_mutex); - remaining = UT_LIST_GET_LEN(buf_pool->flush_list); - bpage = UT_LIST_GET_LAST(buf_pool->flush_list); - if (bpage) { - prev_bpage = UT_LIST_GET_PREV(flush_list, bpage); - } - mutex_exit(&flush_list_mutex); - if (!bpage - || bpage->oldest_modification >= lsn_limit) { - /* We have flushed enough */ - - break; - } - ut_ad(bpage->in_flush_list); - } - - /* Note that after finding a single flushable page, we try to - flush also all its neighbors, and after that start from the - END of the LRU list or flush list again: the list may change - during the flushing and we cannot safely preserve within this - function a pointer to a block in the list! */ - - do { - mutex_t*block_mutex = buf_page_get_mutex_enter(bpage); - ibool ready; - - //ut_a(buf_page_in_file(bpage)); - - if (block_mutex) { - ready = buf_flush_ready_for_flush(bpage, flush_type); - mutex_exit(block_mutex); - } else { - ready = FALSE; - } - - if (ready) { - space = buf_page_get_space(bpage); - offset = buf_page_get_page_no(bpage); - - //buf_pool_mutex_exit(); - if (flush_type == BUF_FLUSH_LRU) { - mutex_exit(&LRU_list_mutex); - } - - old_page_count = page_count; - - /* Try to flush also all the neighbors */ - page_count += buf_flush_try_neighbors( - space, offset, flush_type, srv_flush_neighbor_pages); - /* fprintf(stderr, - "Flush type %lu, page no %lu, neighb %lu\n", - flush_type, offset, - page_count - old_page_count); */ - - //buf_pool_mutex_enter(); - if (flush_type == BUF_FLUSH_LRU) { - mutex_enter(&LRU_list_mutex); - } - goto flush_next; - - } else if (flush_type == BUF_FLUSH_LRU) { - bpage = UT_LIST_GET_PREV(LRU, bpage); - } else { - ut_ad(flush_type == BUF_FLUSH_LIST); - - mutex_enter(&flush_list_mutex); - bpage = UT_LIST_GET_PREV(flush_list, bpage); - //ut_ad(!bpage || bpage->in_flush_list); /* optimistic */ - if (bpage != prev_bpage) { - /* the search may warp.. retrying */ - bpage = NULL; - } - if (bpage) { - prev_bpage = UT_LIST_GET_PREV(flush_list, bpage); - } - mutex_exit(&flush_list_mutex); - remaining--; - } - } while (bpage != NULL); - - if (remaining) - goto flush_next; - - /* If we could not find anything to flush, leave the loop */ - - break; - } - - if (flush_type == BUF_FLUSH_LRU) { - mutex_exit(&LRU_list_mutex); - } - - mutex_enter(&buf_pool_mutex); +/******************************************************************//** +End a buffer flush batch for LRU or flush list */ +static +void +buf_flush_end( +/*==========*/ + buf_pool_t* buf_pool, /*!< buffer pool instance */ + enum buf_flush flush_type) /*!< in: BUF_FLUSH_LRU + or BUF_FLUSH_LIST */ +{ + buf_pool_mutex_enter(buf_pool); buf_pool->init_flush[flush_type] = FALSE; @@ -1455,32 +1882,7 @@ flush_next: os_event_set(buf_pool->no_flush[flush_type]); } - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); - - buf_flush_buffered_writes(); - -#ifdef UNIV_DEBUG - if (buf_debug_prints && page_count > 0) { - ut_a(flush_type == BUF_FLUSH_LRU - || flush_type == BUF_FLUSH_LIST); - fprintf(stderr, flush_type == BUF_FLUSH_LRU - ? "Flushed %lu pages in LRU flush\n" - : "Flushed %lu pages in flush list flush\n", - (ulong) page_count); - } -#endif /* UNIV_DEBUG */ - - srv_buf_pool_flushed += page_count; - - /* We keep track of all flushes happening as part of LRU - flush. When estimating the desired rate at which flush_list - should be flushed we factor in this value. */ - if (flush_type == BUF_FLUSH_LRU) { - buf_lru_flush_page_count += page_count; - } - - return(page_count); + buf_pool_mutex_exit(buf_pool); } /******************************************************************//** @@ -1489,13 +1891,131 @@ UNIV_INTERN void buf_flush_wait_batch_end( /*=====================*/ - enum buf_flush type) /*!< in: BUF_FLUSH_LRU or BUF_FLUSH_LIST */ + buf_pool_t* buf_pool, /*!< buffer pool instance */ + enum buf_flush type) /*!< in: BUF_FLUSH_LRU + or BUF_FLUSH_LIST */ { - ut_ad((type == BUF_FLUSH_LRU) || (type == BUF_FLUSH_LIST)); + ut_ad(type == BUF_FLUSH_LRU || type == BUF_FLUSH_LIST); - os_event_wait(buf_pool->no_flush[type]); + if (buf_pool == NULL) { + ulint i; + + for (i = 0; i < srv_buf_pool_instances; ++i) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + thd_wait_begin(NULL, THD_WAIT_DISKIO); + os_event_wait(buf_pool->no_flush[type]); + thd_wait_end(NULL); + } + } else { + thd_wait_begin(NULL, THD_WAIT_DISKIO); + os_event_wait(buf_pool->no_flush[type]); + thd_wait_end(NULL); + } } +/*******************************************************************//** +This utility flushes dirty blocks from the end of the LRU list. +NOTE: The calling thread may own latches to pages: to avoid deadlocks, +this function must be written so that it cannot end up waiting for these +latches! +@return number of blocks for which the write request was queued; +ULINT_UNDEFINED if there was a flush of the same type already running */ +UNIV_INTERN +ulint +buf_flush_LRU( +/*==========*/ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + ulint min_n) /*!< in: wished minimum mumber of blocks + flushed (it is not guaranteed that the + actual number is that big, though) */ +{ + ulint page_count; + + if (!buf_flush_start(buf_pool, BUF_FLUSH_LRU)) { + return(ULINT_UNDEFINED); + } + + page_count = buf_flush_batch(buf_pool, BUF_FLUSH_LRU, min_n, 0); + + buf_flush_end(buf_pool, BUF_FLUSH_LRU); + + buf_flush_common(BUF_FLUSH_LRU, page_count); + + return(page_count); +} + +/*******************************************************************//** +This utility flushes dirty blocks from the end of the flush list of +all buffer pool instances. +NOTE: The calling thread is not allowed to own any latches on pages! +@return number of blocks for which the write request was queued; +ULINT_UNDEFINED if there was a flush of the same type already running */ +UNIV_INTERN +ulint +buf_flush_list( +/*===========*/ + ulint min_n, /*!< in: wished minimum mumber of blocks + flushed (it is not guaranteed that the + actual number is that big, though) */ + ib_uint64_t lsn_limit) /*!< in the case BUF_FLUSH_LIST all + blocks whose oldest_modification is + smaller than this should be flushed + (if their number does not exceed + min_n), otherwise ignored */ +{ + ulint i; + ulint total_page_count = 0; + ibool skipped = FALSE; + + if (min_n != ULINT_MAX) { + /* Ensure that flushing is spread evenly amongst the + buffer pool instances. When min_n is ULINT_MAX + we need to flush everything up to the lsn limit + so no limit here. */ + min_n = (min_n + srv_buf_pool_instances - 1) + / srv_buf_pool_instances; + } + + /* Flush to lsn_limit in all buffer pool instances */ + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + ulint page_count = 0; + + buf_pool = buf_pool_from_array(i); + + if (!buf_flush_start(buf_pool, BUF_FLUSH_LIST)) { + /* We have two choices here. If lsn_limit was + specified then skipping an instance of buffer + pool means we cannot guarantee that all pages + up to lsn_limit has been flushed. We can + return right now with failure or we can try + to flush remaining buffer pools up to the + lsn_limit. We attempt to flush other buffer + pools based on the assumption that it will + help in the retry which will follow the + failure. */ + skipped = TRUE; + + continue; + } + + page_count = buf_flush_batch( + buf_pool, BUF_FLUSH_LIST, min_n, lsn_limit); + + buf_flush_end(buf_pool, BUF_FLUSH_LIST); + + buf_flush_common(BUF_FLUSH_LIST, page_count); + + total_page_count += page_count; + } + + return(lsn_limit != IB_ULONGLONG_MAX && skipped + ? ULINT_UNDEFINED : total_page_count); +} + /******************************************************************//** Gives a recommendation of how many blocks should be flushed to establish a big enough margin of replaceable blocks near the end of the LRU list @@ -1504,8 +2024,9 @@ and in the free list. LRU list */ static ulint -buf_flush_LRU_recommendation(void) -/*==============================*/ +buf_flush_LRU_recommendation( +/*=========================*/ + buf_pool_t* buf_pool) /*!< in: Buffer pool instance */ { buf_page_t* bpage; ulint n_replaceable; @@ -1515,18 +2036,18 @@ buf_flush_LRU_recommendation(void) if(UT_LIST_GET_LEN(buf_pool->unzip_LRU)) have_LRU_mutex = TRUE; retry: - //buf_pool_mutex_enter(); + //buf_pool_mutex_enter(buf_pool); if (have_LRU_mutex) - mutex_enter(&LRU_list_mutex); + mutex_enter(&buf_pool->LRU_list_mutex); n_replaceable = UT_LIST_GET_LEN(buf_pool->free); bpage = UT_LIST_GET_LAST(buf_pool->LRU); while ((bpage != NULL) - && (n_replaceable < BUF_FLUSH_FREE_BLOCK_MARGIN - + BUF_FLUSH_EXTRA_MARGIN) - && (distance < BUF_LRU_FREE_SEARCH_LEN)) { + && (n_replaceable < BUF_FLUSH_FREE_BLOCK_MARGIN(buf_pool) + + BUF_FLUSH_EXTRA_MARGIN(buf_pool)) + && (distance < BUF_LRU_FREE_SEARCH_LEN(buf_pool))) { mutex_t* block_mutex; if (!bpage->in_LRU_list) { @@ -1549,11 +2070,11 @@ retry: bpage = UT_LIST_GET_PREV(LRU, bpage); } - //buf_pool_mutex_exit(); + //buf_pool_mutex_exit(buf_pool); if (have_LRU_mutex) - mutex_exit(&LRU_list_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); - if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN) { + if (n_replaceable >= BUF_FLUSH_FREE_BLOCK_MARGIN(buf_pool)) { return(0); } else if (!have_LRU_mutex) { @@ -1563,7 +2084,8 @@ retry: goto retry; } - return(BUF_FLUSH_FREE_BLOCK_MARGIN + BUF_FLUSH_EXTRA_MARGIN + return(BUF_FLUSH_FREE_BLOCK_MARGIN(buf_pool) + + BUF_FLUSH_EXTRA_MARGIN(buf_pool) - n_replaceable); } @@ -1576,25 +2098,47 @@ immediately, without waiting. */ UNIV_INTERN void buf_flush_free_margin( -/*=======================*/ - ibool wait) +/*==================*/ + buf_pool_t* buf_pool, /*!< in: Buffer pool instance */ + ibool wait) { ulint n_to_flush; - ulint n_flushed; - n_to_flush = buf_flush_LRU_recommendation(); + n_to_flush = buf_flush_LRU_recommendation(buf_pool); if (n_to_flush > 0) { - n_flushed = buf_flush_batch(BUF_FLUSH_LRU, n_to_flush, 0); + ulint n_flushed; + + n_flushed = buf_flush_LRU(buf_pool, n_to_flush); + if (wait && n_flushed == ULINT_UNDEFINED) { /* There was an LRU type flush batch already running; let us wait for it to end */ - buf_flush_wait_batch_end(BUF_FLUSH_LRU); + buf_flush_wait_batch_end(buf_pool, BUF_FLUSH_LRU); } } } +/*********************************************************************//** +Flushes pages from the end of all the LRU lists. */ +UNIV_INTERN +void +buf_flush_free_margins( +/*========================*/ + ibool wait) +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + buf_flush_free_margin(buf_pool, wait); + } +} + /********************************************************************* Update the historical stats that we are collecting for flush rate heuristics at the end of each interval. @@ -1655,22 +2199,28 @@ ulint buf_flush_get_desired_flush_rate(void) /*==================================*/ { - ulint redo_avg; - ulint lru_flush_avg; - ulint n_dirty; - ulint n_flush_req; - lint rate; - ib_uint64_t lsn = log_get_lsn(); - ulint log_capacity = log_get_capacity(); + ulint i; + lint rate; + ulint redo_avg; + ulint n_dirty = 0; + ulint n_flush_req; + ulint lru_flush_avg; + ib_uint64_t lsn = log_get_lsn(); + ulint log_capacity = log_get_capacity(); /* log_capacity should never be zero after the initialization of log subsystem. */ ut_ad(log_capacity != 0); /* Get total number of dirty pages. It is OK to access - flush_list without holding any mtex as we are using this + flush_list without holding any mutex as we are using this only for heuristics. */ - n_dirty = UT_LIST_GET_LEN(buf_pool->flush_list); + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + n_dirty += UT_LIST_GET_LEN(buf_pool->flush_list); + } /* An overflow can happen if we generate more than 2^32 bytes of redo in this interval i.e.: 4G of redo in 1 second. We can @@ -1712,12 +2262,15 @@ Validates the flush list. @return TRUE if ok */ static ibool -buf_flush_validate_low(void) -/*========================*/ +buf_flush_validate_low( +/*===================*/ + buf_pool_t* buf_pool) /*!< in: Buffer pool instance */ { buf_page_t* bpage; const ib_rbt_node_t* rnode = NULL; + ut_ad(buf_flush_list_mutex_own(buf_pool)); + UT_LIST_VALIDATE(flush_list, buf_page_t, buf_pool->flush_list, ut_ad(ut_list_node_313->in_flush_list)); @@ -1732,16 +2285,29 @@ buf_flush_validate_low(void) while (bpage != NULL) { const ib_uint64_t om = bpage->oldest_modification; + + ut_ad(buf_pool_from_bpage(bpage) == buf_pool); + ut_ad(bpage->in_flush_list); - //ut_a(buf_page_in_file(bpage)); /* optimistic */ + + /* A page in buf_pool->flush_list can be in + BUF_BLOCK_REMOVE_HASH state. This happens when a page + is in the middle of being relocated. In that case the + original descriptor can have this state and still be + in the flush list waiting to acquire the + buf_pool->flush_list_mutex to complete the relocation. */ + ut_a(buf_page_in_file(bpage) + || buf_page_get_state(bpage) == BUF_BLOCK_REMOVE_HASH); ut_a(om > 0); if (UNIV_LIKELY_NULL(buf_pool->flush_rbt)) { + buf_page_t** prpage; + ut_a(rnode); - buf_page_t* rpage = *rbt_value(buf_page_t*, - rnode); - ut_a(rpage); - ut_a(rpage == bpage); + prpage = rbt_value(buf_page_t*, rnode); + + ut_a(*prpage); + ut_a(*prpage == bpage); rnode = rbt_next(buf_pool->flush_rbt, rnode); } @@ -1762,18 +2328,17 @@ Validates the flush list. @return TRUE if ok */ UNIV_INTERN ibool -buf_flush_validate(void) -/*====================*/ +buf_flush_validate( +/*===============*/ + buf_pool_t* buf_pool) /*!< buffer pool instance */ { ibool ret; - //buf_pool_mutex_enter(); - mutex_enter(&flush_list_mutex); + buf_flush_list_mutex_enter(buf_pool); - ret = buf_flush_validate_low(); + ret = buf_flush_validate_low(buf_pool); - //buf_pool_mutex_exit(); - mutex_exit(&flush_list_mutex); + buf_flush_list_mutex_exit(buf_pool); return(ret); } diff --git a/storage/xtradb/buf/buf0lru.c b/storage/xtradb/buf/buf0lru.c index 94828940fd4..49f3b09c817 100644 --- a/storage/xtradb/buf/buf0lru.c +++ b/storage/xtradb/buf/buf0lru.c @@ -50,7 +50,7 @@ Created 11/5/1995 Heikki Tuuri #include "srv0srv.h" /** The number of blocks from the LRU_old pointer onward, including -the block pointed to, must be buf_LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV +the block pointed to, must be buf_pool->LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV of the whole LRU list length, except that the tolerance defined below is allowed. Note that the tolerance must be small enough such that for even the BUF_LRU_OLD_MIN_LEN long LRU list, the LRU_old pointer is not @@ -96,8 +96,9 @@ with page_zip_decompress() operations. */ #define BUF_LRU_IO_TO_UNZIP_FACTOR 50 /** Sampled values buf_LRU_stat_cur. -Protected by buf_pool_mutex. Updated by buf_LRU_stat_update(). */ +Not protected by any mutex. Updated by buf_LRU_stat_update(). */ static buf_LRU_stat_t buf_LRU_stat_arr[BUF_LRU_STAT_N_INTERVAL]; + /** Cursor to buf_LRU_stat_arr[] that is updated in a round-robin fashion. */ static ulint buf_LRU_stat_arr_ind; @@ -106,15 +107,12 @@ by buf_LRU_stat_update(). */ UNIV_INTERN buf_LRU_stat_t buf_LRU_stat_cur; /** Running sum of past values of buf_LRU_stat_cur. -Updated by buf_LRU_stat_update(). Protected by buf_pool_mutex. */ +Updated by buf_LRU_stat_update(). Not Protected by any mutex. */ UNIV_INTERN buf_LRU_stat_t buf_LRU_stat_sum; /* @} */ /** @name Heuristics for detecting index scan @{ */ -/** Reserve this much/BUF_LRU_OLD_RATIO_DIV of the buffer pool for -"old" blocks. Protected by buf_pool_mutex. */ -UNIV_INTERN uint buf_LRU_old_ratio; /** Move blocks to "new" LRU list only if the first access was at least this many milliseconds ago. Not protected by any mutex or latch. */ UNIV_INTERN uint buf_LRU_old_threshold_ms; @@ -123,7 +121,7 @@ UNIV_INTERN uint buf_LRU_old_threshold_ms; /******************************************************************//** Takes a block out of the LRU list and page hash table. If the block is compressed-only (BUF_BLOCK_ZIP_PAGE), -the object will be freed and buf_pool_zip_mutex will be released. +the object will be freed and buf_pool->zip_mutex will be released. If a compressed page or a compressed-only block descriptor is freed, other compressed pages or compressed-only block descriptors may be @@ -156,20 +154,21 @@ instead of the general LRU list. UNIV_INLINE ibool buf_LRU_evict_from_unzip_LRU( +/*=========================*/ + buf_pool_t* buf_pool, ibool have_LRU_mutex) -/*==============================*/ { ulint io_avg; ulint unzip_avg; - //ut_ad(buf_pool_mutex_own()); + //ut_ad(buf_pool_mutex_own(buf_pool)); if (!have_LRU_mutex) - mutex_enter(&LRU_list_mutex); + mutex_enter(&buf_pool->LRU_list_mutex); /* If the unzip_LRU list is empty, we can only use the LRU. */ if (UT_LIST_GET_LEN(buf_pool->unzip_LRU) == 0) { if (!have_LRU_mutex) - mutex_exit(&LRU_list_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); return(FALSE); } @@ -179,7 +178,7 @@ buf_LRU_evict_from_unzip_LRU( if (UT_LIST_GET_LEN(buf_pool->unzip_LRU) <= UT_LIST_GET_LEN(buf_pool->LRU) / 10) { if (!have_LRU_mutex) - mutex_exit(&LRU_list_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); return(FALSE); } @@ -187,11 +186,11 @@ buf_LRU_evict_from_unzip_LRU( that a workload is disk bound. */ if (buf_pool->freed_page_clock == 0) { if (!have_LRU_mutex) - mutex_exit(&LRU_list_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); return(TRUE); } if (!have_LRU_mutex) - mutex_exit(&LRU_list_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); /* Calculate the average over past intervals, and add the values of the current interval. */ @@ -240,7 +239,8 @@ static void buf_LRU_drop_page_hash_for_tablespace( /*==================================*/ - ulint id) /*!< in: space id */ + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + ulint id) /*!< in: space id */ { buf_page_t* bpage; ulint* page_arr; @@ -255,22 +255,25 @@ buf_LRU_drop_page_hash_for_tablespace( return; } - page_arr = ut_malloc(sizeof(ulint) - * BUF_LRU_DROP_SEARCH_HASH_SIZE); - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + page_arr = ut_malloc( + sizeof(ulint) * BUF_LRU_DROP_SEARCH_HASH_SIZE); + + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + num_entries = 0; scan_again: - num_entries = 0; bpage = UT_LIST_GET_LAST(buf_pool->LRU); while (bpage != NULL) { + /* bpage->state,space,io_fix,buf_fix_count are protected by block_mutex at XtraDB */ mutex_t* block_mutex = buf_page_get_mutex_enter(bpage); buf_page_t* prev_bpage; + ibool is_fixed; prev_bpage = UT_LIST_GET_PREV(LRU, bpage); - if (!block_mutex) { + if (UNIV_UNLIKELY(!block_mutex)) { goto next_page; } @@ -278,63 +281,84 @@ scan_again: if (buf_page_get_state(bpage) != BUF_BLOCK_FILE_PAGE || bpage->space != id - || bpage->buf_fix_count > 0 || bpage->io_fix != BUF_IO_NONE) { - /* We leave the fixed pages as is in this scan. - To be dealt with later in the final scan. */ + /* Compressed pages are never hashed. + Skip blocks of other tablespaces. + Skip I/O-fixed blocks (to be dealt with later). */ + mutex_exit(block_mutex); +next_page: + bpage = prev_bpage; + continue; + } + + //mutex_enter(&((buf_block_t*) bpage)->mutex); + is_fixed = bpage->buf_fix_count > 0 + || !((buf_block_t*) bpage)->is_hashed; + //mutex_exit(&((buf_block_t*) bpage)->mutex); + + if (is_fixed) { mutex_exit(block_mutex); goto next_page; } - if (((buf_block_t*) bpage)->is_hashed) { + /* Store the page number so that we can drop the hash + index in a batch later. */ + page_arr[num_entries] = bpage->offset; + mutex_exit(block_mutex); - /* Store the offset(i.e.: page_no) in the array - so that we can drop hash index in a batch - later. */ - page_arr[num_entries] = bpage->offset; - mutex_exit(block_mutex); - ut_a(num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE); - ++num_entries; + ut_a(num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE); + ++num_entries; - if (num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE) { - goto next_page; - } - /* Array full. We release the buf_pool_mutex to - obey the latching order. */ - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - - buf_LRU_drop_page_hash_batch(id, zip_size, page_arr, - num_entries); - num_entries = 0; - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - } else { - mutex_exit(block_mutex); + if (num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE) { + goto next_page; } -next_page: - /* Note that we may have released the buf_pool mutex - above after reading the prev_bpage during processing - of a page_hash_batch (i.e.: when the array was full). - This means that prev_bpage can change in LRU list. - This is OK because this function is a 'best effort' - to drop as many search hash entries as possible and - it does not guarantee that ALL such entries will be - dropped. */ - bpage = prev_bpage; + /* Array full. We release the buf_pool->mutex to obey + the latching order. */ + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + + buf_LRU_drop_page_hash_batch( + id, zip_size, page_arr, num_entries); + + num_entries = 0; + + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + + /* Note that we released the buf_pool mutex above + after reading the prev_bpage during processing of a + page_hash_batch (i.e.: when the array was full). + Because prev_bpage could belong to a compressed-only + block, it may have been relocated, and thus the + pointer cannot be trusted. Because bpage is of type + buf_block_t, it is safe to dereference. + + bpage can change in the LRU list. This is OK because + this function is a 'best effort' to drop as many + search hash entries as possible and it does not + guarantee that ALL such entries will be dropped. */ /* If, however, bpage has been removed from LRU list to the free list then we should restart the scan. bpage->state is protected by buf_pool mutex. */ - if (bpage && !buf_page_in_file(bpage)) { - ut_a(num_entries == 0); + + /* obtain block_mutex again to avoid race condition of bpage->state */ + block_mutex = buf_page_get_mutex_enter(bpage); + if (!block_mutex) { goto scan_again; } + + if (bpage + && buf_page_get_state(bpage) != BUF_BLOCK_FILE_PAGE) { + mutex_exit(block_mutex); + goto scan_again; + } + mutex_exit(block_mutex); } - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); /* Drop any remaining batch of search hashed pages. */ buf_LRU_drop_page_hash_batch(id, zip_size, page_arr, num_entries); @@ -342,29 +366,23 @@ next_page: } /******************************************************************//** -Invalidates all pages belonging to a given tablespace when we are deleting -the data file(s) of that tablespace. */ -UNIV_INTERN +Invalidates all pages belonging to a given tablespace inside a specific +buffer pool instance when we are deleting the data file(s) of that +tablespace. */ +static void -buf_LRU_invalidate_tablespace( -/*==========================*/ - ulint id) /*!< in: space id */ +buf_LRU_invalidate_tablespace_buf_pool_instance( +/*============================================*/ + buf_pool_t* buf_pool, /*!< buffer pool instance */ + ulint id) /*!< in: space id */ { buf_page_t* bpage; ibool all_freed; - /* Before we attempt to drop pages one by one we first - attempt to drop page hash index entries in batches to make - it more efficient. The batching attempt is a best effort - attempt and does not guarantee that all pages hash entries - will be dropped. We get rid of remaining page hash entries - one by one below. */ - buf_LRU_drop_page_hash_for_tablespace(id); - scan_again: - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - rw_lock_x_lock(&page_hash_latch); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + rw_lock_x_lock(&buf_pool->page_hash_latch); all_freed = TRUE; @@ -379,8 +397,8 @@ scan_again: prev_bpage = UT_LIST_GET_PREV(LRU, bpage); /* bpage->space and bpage->io_fix are protected by - buf_pool_mutex and block_mutex. It is safe to check - them while holding buf_pool_mutex only. */ + buf_pool->mutex and block_mutex. It is safe to check + them while holding buf_pool->mutex only. */ if (buf_page_get_space(bpage) != id) { /* Skip this block, as it does not belong to @@ -434,7 +452,7 @@ scan_again: /* Descriptors of uncompressed blocks will not be relocated, because we are holding the - buf_pool_mutex. */ + buf_pool->mutex. */ break; case BUF_BLOCK_ZIP_PAGE: case BUF_BLOCK_ZIP_DIRTY: @@ -446,7 +464,7 @@ scan_again: buf_pool_zip_mutex, it is not necessary to acquire further mutexes. */ - ut_ad(&buf_pool_zip_mutex + ut_ad(&buf_pool->zip_mutex == block_mutex); ut_ad(mutex_own(block_mutex)); prev_bpage_buf_fix = TRUE; @@ -460,9 +478,9 @@ scan_again: ulint page_no; ulint zip_size; - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); zip_size = buf_page_get_zip_size(bpage); page_no = buf_page_get_page_no(bpage); @@ -492,7 +510,7 @@ scan_again: /* The block_mutex should have been released by buf_LRU_block_remove_hashed_page() when it returns BUF_BLOCK_ZIP_FREE. */ - ut_ad(block_mutex == &buf_pool_zip_mutex); + ut_ad(block_mutex == &buf_pool->zip_mutex); ut_ad(!mutex_own(block_mutex)); if (prev_bpage_buf_fix) { @@ -519,9 +537,9 @@ next_page_no_mutex: bpage = prev_bpage; } - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); if (!all_freed) { os_thread_sleep(20000); @@ -530,6 +548,63 @@ next_page_no_mutex: } } +/******************************************************************//** +Invalidates all pages belonging to a given tablespace when we are deleting +the data file(s) of that tablespace. */ +UNIV_INTERN +void +buf_LRU_invalidate_tablespace( +/*==========================*/ + ulint id) /*!< in: space id */ +{ + ulint i; + + /* Before we attempt to drop pages one by one we first + attempt to drop page hash index entries in batches to make + it more efficient. The batching attempt is a best effort + attempt and does not guarantee that all pages hash entries + will be dropped. We get rid of remaining page hash entries + one by one below. */ + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + buf_LRU_drop_page_hash_for_tablespace(buf_pool, id); + buf_LRU_invalidate_tablespace_buf_pool_instance(buf_pool, id); + } +} + +/******************************************************************//** +*/ +UNIV_INTERN +void +buf_LRU_mark_space_was_deleted( +/*===========================*/ + ulint id) /*!< in: space id */ +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + buf_page_t* bpage; + + buf_pool = buf_pool_from_array(i); + + mutex_enter(&buf_pool->LRU_list_mutex); + + bpage = UT_LIST_GET_FIRST(buf_pool->LRU); + + while (bpage != NULL) { + if (buf_page_get_space(bpage) == id) { + bpage->space_was_being_deleted = TRUE; + } + bpage = UT_LIST_GET_NEXT(LRU, bpage); + } + + mutex_exit(&buf_pool->LRU_list_mutex); + } +} + /********************************************************************//** Insert a compressed block into buf_pool->zip_clean in the LRU order. */ UNIV_INTERN @@ -539,10 +614,11 @@ buf_LRU_insert_zip_clean( buf_page_t* bpage) /*!< in: pointer to the block in question */ { buf_page_t* b; + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); - ut_ad(mutex_own(&flush_list_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); + ut_ad(mutex_own(&buf_pool->zip_mutex)); ut_ad(buf_page_get_state(bpage) == BUF_BLOCK_ZIP_PAGE); /* Find the first successor of bpage in the LRU list @@ -572,17 +648,20 @@ UNIV_INLINE ibool buf_LRU_free_from_unzip_LRU_list( /*=============================*/ - ulint n_iterations, /*!< in: how many times this has been called - repeatedly without result: a high value means - that we should search farther; we will search - n_iterations / 5 of the unzip_LRU list, - or nothing if n_iterations >= 5 */ - ibool have_LRU_mutex) + buf_pool_t* buf_pool, /*!< in: buffer pool instance */ + ulint n_iterations, /*!< in: how many times this has + been called repeatedly without + result: a high value means that + we should search farther; we will + search n_iterations / 5 of the + unzip_LRU list, or nothing if + n_iterations >= 5 */ + ibool have_LRU_mutex) { buf_block_t* block; ulint distance; - //ut_ad(buf_pool_mutex_own()); /* optimistic */ + //ut_ad(buf_pool_mutex_own(buf_pool)); /* Theoratically it should be much easier to find a victim from unzip_LRU as we can choose even a dirty block (as we'll @@ -592,7 +671,7 @@ buf_LRU_free_from_unzip_LRU_list( if we have done five iterations so far. */ if (UNIV_UNLIKELY(n_iterations >= 5) - || !buf_LRU_evict_from_unzip_LRU(have_LRU_mutex)) { + || !buf_LRU_evict_from_unzip_LRU(buf_pool, have_LRU_mutex)) { return(FALSE); } @@ -618,7 +697,7 @@ restart: ut_ad(block->in_unzip_LRU_list); ut_ad(block->page.in_LRU_list); - freed = buf_LRU_free_block(&block->page, FALSE, NULL, have_LRU_mutex); + freed = buf_LRU_free_block(&block->page, FALSE, have_LRU_mutex); mutex_exit(&block->mutex); switch (freed) { @@ -651,18 +730,20 @@ UNIV_INLINE ibool buf_LRU_free_from_common_LRU_list( /*==============================*/ - ulint n_iterations, /*!< in: how many times this has been called + buf_pool_t* buf_pool, + ulint n_iterations, + /*!< in: how many times this has been called repeatedly without result: a high value means that we should search farther; if n_iterations < 10, then we search n_iterations / 10 * buf_pool->curr_size pages from the end of the LRU list */ - ibool have_LRU_mutex) + ibool have_LRU_mutex) { buf_page_t* bpage; ulint distance; - //ut_ad(buf_pool_mutex_own()); /* optimistic */ + //ut_ad(buf_pool_mutex_own(buf_pool)); distance = 100 + (n_iterations * buf_pool->curr_size) / 10; @@ -690,7 +771,7 @@ restart: ut_ad(bpage->in_LRU_list); accessed = buf_page_is_accessed(bpage); - freed = buf_LRU_free_block(bpage, TRUE, NULL, have_LRU_mutex); + freed = buf_LRU_free_block(bpage, TRUE, have_LRU_mutex); mutex_exit(block_mutex); switch (freed) { @@ -729,7 +810,10 @@ UNIV_INTERN ibool buf_LRU_search_and_free_block( /*==========================*/ - ulint n_iterations) /*!< in: how many times this has been called + buf_pool_t* buf_pool, + /*!< in: buffer pool instance */ + ulint n_iterations) + /*!< in: how many times this has been called repeatedly without result: a high value means that we should search farther; if n_iterations < 10, then we search @@ -744,28 +828,27 @@ buf_LRU_search_and_free_block( if (UT_LIST_GET_LEN(buf_pool->unzip_LRU)) have_LRU_mutex = TRUE; - /* optimistic search... */ - //buf_pool_mutex_enter(); + //buf_pool_mutex_enter(buf_pool); if (have_LRU_mutex) - mutex_enter(&LRU_list_mutex); + mutex_enter(&buf_pool->LRU_list_mutex); - freed = buf_LRU_free_from_unzip_LRU_list(n_iterations, have_LRU_mutex); + freed = buf_LRU_free_from_unzip_LRU_list(buf_pool, n_iterations, have_LRU_mutex); if (!freed) { - freed = buf_LRU_free_from_common_LRU_list(n_iterations, have_LRU_mutex); + freed = buf_LRU_free_from_common_LRU_list( + buf_pool, n_iterations, have_LRU_mutex); } - mutex_enter(&buf_pool_mutex); + buf_pool_mutex_enter(buf_pool); if (!freed) { buf_pool->LRU_flush_ended = 0; } else if (buf_pool->LRU_flush_ended > 0) { buf_pool->LRU_flush_ended--; } - mutex_exit(&buf_pool_mutex); - //buf_pool_mutex_exit(); + buf_pool_mutex_exit(buf_pool); if (have_LRU_mutex) - mutex_exit(&LRU_list_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); return(freed); } @@ -780,53 +863,69 @@ operations need new buffer blocks, and the i/o work done in flushing would be wasted. */ UNIV_INTERN void -buf_LRU_try_free_flushed_blocks(void) -/*=================================*/ +buf_LRU_try_free_flushed_blocks( +/*============================*/ + buf_pool_t* buf_pool) /*!< in: buffer pool instance */ { - //buf_pool_mutex_enter(); - mutex_enter(&buf_pool_mutex); - while (buf_pool->LRU_flush_ended > 0) { + if (buf_pool == NULL) { + ulint i; - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool = buf_pool_from_array(i); + buf_LRU_try_free_flushed_blocks(buf_pool); + } + } else { + buf_pool_mutex_enter(buf_pool); - buf_LRU_search_and_free_block(1); + while (buf_pool->LRU_flush_ended > 0) { - //buf_pool_mutex_enter(); - mutex_enter(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); + + buf_LRU_search_and_free_block(buf_pool, 1); + + buf_pool_mutex_enter(buf_pool); + } + + buf_pool_mutex_exit(buf_pool); } - - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); } /******************************************************************//** -Returns TRUE if less than 25 % of the buffer pool is available. This can be -used in heuristics to prevent huge transactions eating up the whole buffer -pool for their locks. +Returns TRUE if less than 25 % of the buffer pool in any instance is +available. This can be used in heuristics to prevent huge transactions +eating up the whole buffer pool for their locks. @return TRUE if less than 25 % of buffer pool left */ UNIV_INTERN ibool buf_LRU_buf_pool_running_out(void) /*==============================*/ { - ibool ret = FALSE; + ulint i; + ibool ret = FALSE; - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); - mutex_enter(&free_list_mutex); + for (i = 0; i < srv_buf_pool_instances && !ret; i++) { + buf_pool_t* buf_pool; - if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) - + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->curr_size / 4) { + buf_pool = buf_pool_from_array(i); - ret = TRUE; + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); + mutex_enter(&buf_pool->free_list_mutex); + + if (!recv_recovery_on + && UT_LIST_GET_LEN(buf_pool->free) + + UT_LIST_GET_LEN(buf_pool->LRU) + < buf_pool->curr_size / 4) { + + ret = TRUE; + } + + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + mutex_exit(&buf_pool->free_list_mutex); } - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - mutex_exit(&free_list_mutex); - return(ret); } @@ -836,17 +935,19 @@ free list. If it is empty, returns NULL. @return a free control block, or NULL if the buf_block->free list is empty */ UNIV_INTERN buf_block_t* -buf_LRU_get_free_only(void) -/*=======================*/ +buf_LRU_get_free_only( +/*==================*/ + buf_pool_t* buf_pool) { buf_block_t* block; - //ut_ad(buf_pool_mutex_own()); + //ut_ad(buf_pool_mutex_own(buf_pool)); - mutex_enter(&free_list_mutex); + mutex_enter(&buf_pool->free_list_mutex); block = (buf_block_t*) UT_LIST_GET_LAST(buf_pool->free); if (block) { + ut_ad(block->page.in_free_list); ut_d(block->page.in_free_list = FALSE); ut_ad(!block->page.in_flush_list); @@ -854,16 +955,18 @@ buf_LRU_get_free_only(void) ut_a(!buf_page_in_file(&block->page)); UT_LIST_REMOVE(free, buf_pool->free, (&block->page)); - mutex_exit(&free_list_mutex); + mutex_exit(&buf_pool->free_list_mutex); mutex_enter(&block->mutex); buf_block_set_state(block, BUF_BLOCK_READY_FOR_USE); UNIV_MEM_ALLOC(block->frame, UNIV_PAGE_SIZE); + ut_ad(buf_pool_from_block(block) == buf_pool); + mutex_exit(&block->mutex); } else { - mutex_exit(&free_list_mutex); + mutex_exit(&buf_pool->free_list_mutex); } return(block); @@ -878,8 +981,7 @@ UNIV_INTERN buf_block_t* buf_LRU_get_free_block( /*===================*/ - ulint zip_size) /*!< in: compressed page size in bytes, - or 0 if uncompressed tablespace */ + buf_pool_t* buf_pool) /*!< in/out: buffer pool instance */ { buf_block_t* block = NULL; ibool freed; @@ -887,7 +989,7 @@ buf_LRU_get_free_block( ibool mon_value_was = FALSE; ibool started_monitor = FALSE; loop: - //buf_pool_mutex_enter(); + //buf_pool_mutex_enter(buf_pool); if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->curr_size / 20) { @@ -954,29 +1056,12 @@ loop: } /* If there is a block in the free list, take it */ - block = buf_LRU_get_free_only(); + block = buf_LRU_get_free_only(buf_pool); + //buf_pool_mutex_exit(buf_pool); + if (block) { - -#ifdef UNIV_DEBUG - block->page.zip.m_start = -#endif /* UNIV_DEBUG */ - block->page.zip.m_end = - block->page.zip.m_nonempty = - block->page.zip.n_blobs = 0; - - if (UNIV_UNLIKELY(zip_size)) { - ibool lru; - page_zip_set_size(&block->page.zip, zip_size); - mutex_enter(&LRU_list_mutex); - block->page.zip.data = buf_buddy_alloc(zip_size, &lru, FALSE); - mutex_exit(&LRU_list_mutex); - UNIV_MEM_DESC(block->page.zip.data, zip_size, block); - } else { - page_zip_set_size(&block->page.zip, 0); - block->page.zip.data = NULL; - } - - //buf_pool_mutex_exit(); + ut_ad(buf_pool_from_block(block) == buf_pool); + memset(&block->page.zip, 0, sizeof block->page.zip); if (started_monitor) { srv_print_innodb_monitor = mon_value_was; @@ -988,9 +1073,7 @@ loop: /* If no block was in the free list, search from the end of the LRU list and try to free a block there */ - //buf_pool_mutex_exit(); - - freed = buf_LRU_search_and_free_block(n_iterations); + freed = buf_LRU_search_and_free_block(buf_pool, n_iterations); if (freed > 0) { goto loop; @@ -1032,26 +1115,23 @@ loop: /* No free block was found: try to flush the LRU list */ - buf_flush_free_margin(TRUE); + buf_flush_free_margin(buf_pool, TRUE); ++srv_buf_pool_wait_free; os_aio_simulated_wake_handler_threads(); - //buf_pool_mutex_enter(); - mutex_enter(&buf_pool_mutex); + buf_pool_mutex_enter(buf_pool); if (buf_pool->LRU_flush_ended > 0) { /* We have written pages in an LRU flush. To make the insert buffer more efficient, we try to move these pages to the free list. */ - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); - buf_LRU_try_free_flushed_blocks(); + buf_LRU_try_free_flushed_blocks(buf_pool); } else { - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); } if (n_iterations > 10) { @@ -1069,17 +1149,18 @@ Moves the LRU_old pointer so that the length of the old blocks list is inside the allowed limits. */ UNIV_INLINE void -buf_LRU_old_adjust_len(void) -/*========================*/ +buf_LRU_old_adjust_len( +/*===================*/ + buf_pool_t* buf_pool) /*!< in: buffer pool instance */ { ulint old_len; ulint new_len; ut_a(buf_pool->LRU_old); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); - ut_ad(buf_LRU_old_ratio >= BUF_LRU_OLD_RATIO_MIN); - ut_ad(buf_LRU_old_ratio <= BUF_LRU_OLD_RATIO_MAX); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); + ut_ad(buf_pool->LRU_old_ratio >= BUF_LRU_OLD_RATIO_MIN); + ut_ad(buf_pool->LRU_old_ratio <= BUF_LRU_OLD_RATIO_MAX); #if BUF_LRU_OLD_RATIO_MIN * BUF_LRU_OLD_MIN_LEN <= BUF_LRU_OLD_RATIO_DIV * (BUF_LRU_OLD_TOLERANCE + 5) # error "BUF_LRU_OLD_RATIO_MIN * BUF_LRU_OLD_MIN_LEN <= BUF_LRU_OLD_RATIO_DIV * (BUF_LRU_OLD_TOLERANCE + 5)" #endif @@ -1095,7 +1176,7 @@ buf_LRU_old_adjust_len(void) old_len = buf_pool->LRU_old_len; new_len = ut_min(UT_LIST_GET_LEN(buf_pool->LRU) - * buf_LRU_old_ratio / BUF_LRU_OLD_RATIO_DIV, + * buf_pool->LRU_old_ratio / BUF_LRU_OLD_RATIO_DIV, UT_LIST_GET_LEN(buf_pool->LRU) - (BUF_LRU_OLD_TOLERANCE + BUF_LRU_NON_OLD_MIN_LEN)); @@ -1137,13 +1218,14 @@ Initializes the old blocks pointer in the LRU list. This function should be called when the LRU list grows to BUF_LRU_OLD_MIN_LEN length. */ static void -buf_LRU_old_init(void) -/*==================*/ +buf_LRU_old_init( +/*=============*/ + buf_pool_t* buf_pool) { buf_page_t* bpage; - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); ut_a(UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN); /* We first initialize all blocks in the LRU list as old and then use @@ -1162,7 +1244,7 @@ buf_LRU_old_init(void) buf_pool->LRU_old = UT_LIST_GET_FIRST(buf_pool->LRU); buf_pool->LRU_old_len = UT_LIST_GET_LEN(buf_pool->LRU); - buf_LRU_old_adjust_len(); + buf_LRU_old_adjust_len(buf_pool); } /******************************************************************//** @@ -1173,11 +1255,13 @@ buf_unzip_LRU_remove_block_if_needed( /*=================================*/ buf_page_t* bpage) /*!< in/out: control block */ { + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + ut_ad(buf_pool); ut_ad(bpage); ut_ad(buf_page_in_file(bpage)); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); if (buf_page_belongs_to_unzip_LRU(bpage)) { buf_block_t* block = (buf_block_t*) bpage; @@ -1197,10 +1281,12 @@ buf_LRU_remove_block( /*=================*/ buf_page_t* bpage) /*!< in: control block */ { + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + ut_ad(buf_pool); ut_ad(bpage); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); ut_a(buf_page_in_file(bpage)); @@ -1214,7 +1300,7 @@ buf_LRU_remove_block( /* Below: the previous block is guaranteed to exist, because the LRU_old pointer is only allowed to differ by BUF_LRU_OLD_TOLERANCE from strict - buf_LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV of the LRU + buf_pool->LRU_old_ratio/BUF_LRU_OLD_RATIO_DIV of the LRU list length. */ buf_page_t* prev_bpage = UT_LIST_GET_PREV(LRU, bpage); @@ -1260,7 +1346,7 @@ buf_LRU_remove_block( } /* Adjust the length of the old block list if necessary */ - buf_LRU_old_adjust_len(); + buf_LRU_old_adjust_len(buf_pool); } /******************************************************************//** @@ -1273,10 +1359,12 @@ buf_unzip_LRU_add_block( ibool old) /*!< in: TRUE if should be put to the end of the list, else put to the start */ { + buf_pool_t* buf_pool = buf_pool_from_block(block); + ut_ad(buf_pool); ut_ad(block); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); ut_a(buf_page_belongs_to_unzip_LRU(&block->page)); @@ -1298,10 +1386,12 @@ buf_LRU_add_block_to_end_low( /*=========================*/ buf_page_t* bpage) /*!< in: control block */ { + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + ut_ad(buf_pool); ut_ad(bpage); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); ut_a(buf_page_in_file(bpage)); @@ -1317,14 +1407,14 @@ buf_LRU_add_block_to_end_low( buf_page_set_old(bpage, TRUE); buf_pool->LRU_old_len++; - buf_LRU_old_adjust_len(); + buf_LRU_old_adjust_len(buf_pool); } else if (UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN) { /* The LRU list is now long enough for LRU_old to become defined: init it */ - buf_LRU_old_init(); + buf_LRU_old_init(buf_pool); } else { buf_page_set_old(bpage, buf_pool->LRU_old != NULL); } @@ -1348,10 +1438,12 @@ buf_LRU_add_block_low( LRU list is very short, the block is added to the start, regardless of this parameter */ { + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + ut_ad(buf_pool); ut_ad(bpage); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); ut_a(buf_page_in_file(bpage)); ut_ad(!bpage->in_LRU_list); @@ -1385,14 +1477,14 @@ buf_LRU_add_block_low( /* Adjust the length of the old block list if necessary */ buf_page_set_old(bpage, old); - buf_LRU_old_adjust_len(); + buf_LRU_old_adjust_len(buf_pool); } else if (UT_LIST_GET_LEN(buf_pool->LRU) == BUF_LRU_OLD_MIN_LEN) { /* The LRU list is now long enough for LRU_old to become defined: init it */ - buf_LRU_old_init(); + buf_LRU_old_init(buf_pool); } else { buf_page_set_old(bpage, buf_pool->LRU_old != NULL); } @@ -1428,8 +1520,10 @@ buf_LRU_make_block_young( /*=====================*/ buf_page_t* bpage) /*!< in: control block */ { - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); if (bpage->old) { buf_pool->stat.n_pages_made_young++; @@ -1456,10 +1550,10 @@ Try to free a block. If bpage is a descriptor of a compressed-only page, the descriptor object will be freed as well. NOTE: If this function returns BUF_LRU_FREED, it will temporarily -release buf_pool_mutex. Furthermore, the page frame will no longer be +release buf_pool->mutex. Furthermore, the page frame will no longer be accessible via bpage. -The caller must hold buf_pool_mutex and buf_page_get_mutex(bpage) and +The caller must hold buf_pool->mutex and buf_page_get_mutex(bpage) and release these two mutexes after the call. No other buf_page_get_mutex() may be held when calling this function. @return BUF_LRU_FREED if freed, BUF_LRU_CANNOT_RELOCATE or @@ -1471,16 +1565,13 @@ buf_LRU_free_block( buf_page_t* bpage, /*!< in: block to be freed */ ibool zip, /*!< in: TRUE if should remove also the compressed page of an uncompressed page */ - ibool* buf_pool_mutex_released, - /*!< in: pointer to a variable that will - be assigned TRUE if buf_pool_mutex - was temporarily released, or NULL */ ibool have_LRU_mutex) { buf_page_t* b = NULL; + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); mutex_t* block_mutex = buf_page_get_mutex(bpage); - //ut_ad(buf_pool_mutex_own()); + //ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(mutex_own(block_mutex)); ut_ad(buf_page_in_file(bpage)); //ut_ad(bpage->in_LRU_list); @@ -1498,6 +1589,10 @@ buf_LRU_free_block( return(BUF_LRU_NOT_FREED); } + if (bpage->space_was_being_deleted && bpage->oldest_modification != 0) { + buf_flush_remove(bpage); + } + #ifdef UNIV_IBUF_COUNT_DEBUG ut_a(ibuf_count_get(bpage->space, bpage->offset) == 0); #endif /* UNIV_IBUF_COUNT_DEBUG */ @@ -1524,9 +1619,9 @@ buf_LRU_free_block( If it cannot be allocated (without freeing a block from the LRU list), refuse to free bpage. */ alloc: - //buf_pool_mutex_exit_forbid(); - b = buf_buddy_alloc(sizeof *b, NULL, FALSE); - //buf_pool_mutex_exit_allow(); + //buf_pool_mutex_exit_forbid(buf_pool); + b = buf_buddy_alloc(buf_pool, sizeof *b, NULL, FALSE); + //buf_pool_mutex_exit_allow(buf_pool); if (UNIV_UNLIKELY(!b)) { return(BUF_LRU_CANNOT_RELOCATE); @@ -1547,8 +1642,8 @@ alloc: mutex_exit(block_mutex); if (!have_LRU_mutex) - mutex_enter(&LRU_list_mutex); /* optimistic */ - rw_lock_x_lock(&page_hash_latch); + mutex_enter(&buf_pool->LRU_list_mutex); /* optimistic */ + rw_lock_x_lock(&buf_pool->page_hash_latch); mutex_enter(block_mutex); /* recheck states of block */ @@ -1556,11 +1651,11 @@ alloc: || !buf_page_can_relocate(bpage)) { not_freed: if (b) { - buf_buddy_free(b, sizeof *b, TRUE); + buf_buddy_free(buf_pool, b, sizeof *b, TRUE); } if (!have_LRU_mutex) - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); return(BUF_LRU_NOT_FREED); } else if (zip || !bpage->zip.data) { if (bpage->oldest_modification) @@ -1581,11 +1676,16 @@ not_freed: ut_a(bpage->buf_fix_count == 0); if (b) { + buf_page_t* hash_b; buf_page_t* prev_b = UT_LIST_GET_PREV(LRU, b); - const ulint fold = buf_page_address_fold( + + const ulint fold = buf_page_address_fold( bpage->space, bpage->offset); - ut_a(!buf_page_hash_get(bpage->space, bpage->offset)); + hash_b = buf_page_hash_get_low( + buf_pool, bpage->space, bpage->offset, fold); + + ut_a(!hash_b); while (prev_b && !prev_b->in_LRU_list) { prev_b = UT_LIST_GET_PREV(LRU, prev_b); @@ -1649,12 +1749,12 @@ not_freed: ut_ad(buf_pool->LRU_old); /* Adjust the length of the old block list if necessary */ - buf_LRU_old_adjust_len(); + buf_LRU_old_adjust_len(buf_pool); } else if (lru_len == BUF_LRU_OLD_MIN_LEN) { /* The LRU list is now long enough for LRU_old to become defined: init it */ - buf_LRU_old_init(); + buf_LRU_old_init(buf_pool); } #ifdef UNIV_LRU_DEBUG /* Check that the "old" flag is consistent @@ -1666,32 +1766,28 @@ not_freed: buf_LRU_add_block_low(b, buf_page_is_old(b)); } - mutex_enter(&flush_list_mutex); + mutex_enter(&buf_pool->zip_mutex); if (b->state == BUF_BLOCK_ZIP_PAGE) { buf_LRU_insert_zip_clean(b); } else { /* Relocate on buf_pool->flush_list. */ buf_flush_relocate_on_flush_list(bpage, b); } - mutex_exit(&flush_list_mutex); bpage->zip.data = NULL; page_zip_set_size(&bpage->zip, 0); /* Prevent buf_page_get_gen() from decompressing the block while we release - buf_pool_mutex and block_mutex. */ + buf_pool->mutex and block_mutex. */ b->buf_fix_count++; b->io_fix = BUF_IO_READ; + mutex_exit(&buf_pool->zip_mutex); } - if (buf_pool_mutex_released) { - *buf_pool_mutex_released = TRUE; - } - - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); mutex_exit(block_mutex); /* Remove possible adaptive hash index on the page. @@ -1702,7 +1798,7 @@ not_freed: UNIV_MEM_VALID(((buf_block_t*) bpage)->frame, UNIV_PAGE_SIZE); - btr_search_drop_page_hash_index((buf_block_t*) bpage); + btr_search_drop_page_hash_index((buf_block_t*) bpage, NULL); UNIV_MEM_INVALID(((buf_block_t*) bpage)->frame, UNIV_PAGE_SIZE); @@ -1723,16 +1819,16 @@ not_freed: : BUF_NO_CHECKSUM_MAGIC); } - //buf_pool_mutex_enter(); + //buf_pool_mutex_enter(buf_pool); if (have_LRU_mutex) - mutex_enter(&LRU_list_mutex); + mutex_enter(&buf_pool->LRU_list_mutex); mutex_enter(block_mutex); if (b) { - mutex_enter(&buf_pool_zip_mutex); + mutex_enter(&buf_pool->zip_mutex); b->buf_fix_count--; buf_page_set_io_fix(b, BUF_IO_NONE); - mutex_exit(&buf_pool_zip_mutex); + mutex_exit(&buf_pool->zip_mutex); } buf_LRU_block_free_hashed_page((buf_block_t*) bpage, FALSE); @@ -1740,12 +1836,12 @@ not_freed: /* The block_mutex should have been released by buf_LRU_block_remove_hashed_page() when it returns BUF_BLOCK_ZIP_FREE. */ - ut_ad(block_mutex == &buf_pool_zip_mutex); + ut_ad(block_mutex == &buf_pool->zip_mutex); mutex_enter(block_mutex); if (!have_LRU_mutex) - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); } return(BUF_LRU_FREED); @@ -1760,10 +1856,11 @@ buf_LRU_block_free_non_file_page( buf_block_t* block, /*!< in: block, must not contain a file page */ ibool have_page_hash_mutex) { - void* data; + void* data; + buf_pool_t* buf_pool = buf_pool_from_block(block); ut_ad(block); - //ut_ad(buf_pool_mutex_own()); + //ut_ad(buf_pool_mutex_own(buf_pool)); ut_ad(mutex_own(&block->mutex)); switch (buf_block_get_state(block)) { @@ -1797,17 +1894,21 @@ buf_LRU_block_free_non_file_page( if (data) { block->page.zip.data = NULL; mutex_exit(&block->mutex); - //buf_pool_mutex_exit_forbid(); - buf_buddy_free(data, page_zip_get_size(&block->page.zip), have_page_hash_mutex); - //buf_pool_mutex_exit_allow(); + //buf_pool_mutex_exit_forbid(buf_pool); + + buf_buddy_free( + buf_pool, data, page_zip_get_size(&block->page.zip), + have_page_hash_mutex); + + //buf_pool_mutex_exit_allow(buf_pool); mutex_enter(&block->mutex); page_zip_set_size(&block->page.zip, 0); } - mutex_enter(&free_list_mutex); + mutex_enter(&buf_pool->free_list_mutex); UT_LIST_ADD_FIRST(free, buf_pool->free, (&block->page)); ut_d(block->page.in_free_list = TRUE); - mutex_exit(&free_list_mutex); + mutex_exit(&buf_pool->free_list_mutex); UNIV_MEM_ASSERT_AND_FREE(block->frame, UNIV_PAGE_SIZE); } @@ -1815,7 +1916,7 @@ buf_LRU_block_free_non_file_page( /******************************************************************//** Takes a block out of the LRU list and page hash table. If the block is compressed-only (BUF_BLOCK_ZIP_PAGE), -the object will be freed and buf_pool_zip_mutex will be released. +the object will be freed and buf_pool->zip_mutex will be released. If a compressed page or a compressed-only block descriptor is freed, other compressed pages or compressed-only block descriptors may be @@ -1832,12 +1933,15 @@ buf_LRU_block_remove_hashed_page( ibool zip) /*!< in: TRUE if should remove also the compressed page of an uncompressed page */ { + ulint fold; const buf_page_t* hashed_bpage; + buf_pool_t* buf_pool = buf_pool_from_bpage(bpage); + ut_ad(bpage); - //ut_ad(buf_pool_mutex_own()); - ut_ad(mutex_own(&LRU_list_mutex)); + //ut_ad(buf_pool_mutex_own(buf_pool)); + ut_ad(mutex_own(&buf_pool->LRU_list_mutex)); #ifdef UNIV_SYNC_DEBUG - ut_ad(rw_lock_own(&page_hash_latch, RW_LOCK_EX)); + ut_ad(rw_lock_own(&buf_pool->page_hash_latch, RW_LOCK_EX)); #endif ut_ad(mutex_own(buf_page_get_mutex(bpage))); @@ -1924,7 +2028,9 @@ buf_LRU_block_remove_hashed_page( break; } - hashed_bpage = buf_page_hash_get(bpage->space, bpage->offset); + fold = buf_page_address_fold(bpage->space, bpage->offset); + hashed_bpage = buf_page_hash_get_low( + buf_pool, bpage->space, bpage->offset, fold); if (UNIV_UNLIKELY(bpage != hashed_bpage)) { fprintf(stderr, @@ -1944,9 +2050,9 @@ buf_LRU_block_remove_hashed_page( #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG mutex_exit(buf_page_get_mutex(bpage)); - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); - rw_lock_x_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); + rw_lock_x_unlock(&buf_pool->page_hash_latch); buf_print(); buf_LRU_print(); buf_validate(); @@ -1958,9 +2064,7 @@ buf_LRU_block_remove_hashed_page( ut_ad(!bpage->in_zip_hash); ut_ad(bpage->in_page_hash); ut_d(bpage->in_page_hash = FALSE); - HASH_DELETE(buf_page_t, hash, buf_pool->page_hash, - buf_page_address_fold(bpage->space, bpage->offset), - bpage); + HASH_DELETE(buf_page_t, hash, buf_pool->page_hash, fold, bpage); switch (buf_page_get_state(bpage)) { case BUF_BLOCK_ZIP_PAGE: ut_ad(!bpage->in_free_list); @@ -1971,12 +2075,17 @@ buf_LRU_block_remove_hashed_page( UT_LIST_REMOVE(zip_list, buf_pool->zip_clean, bpage); - mutex_exit(&buf_pool_zip_mutex); - //buf_pool_mutex_exit_forbid(); - buf_buddy_free(bpage->zip.data, - page_zip_get_size(&bpage->zip), TRUE); - buf_buddy_free(bpage, sizeof(*bpage), TRUE); - //buf_pool_mutex_exit_allow(); + mutex_exit(&buf_pool->zip_mutex); + //buf_pool_mutex_exit_forbid(buf_pool); + + buf_buddy_free( + buf_pool, bpage->zip.data, + page_zip_get_size(&bpage->zip), TRUE); + + bpage->state = BUF_BLOCK_ZIP_FREE; + buf_buddy_free(buf_pool, bpage, sizeof(*bpage), TRUE); + //buf_pool_mutex_exit_allow(buf_pool); + UNIV_MEM_UNDESC(bpage); return(BUF_BLOCK_ZIP_FREE); @@ -1998,9 +2107,13 @@ buf_LRU_block_remove_hashed_page( ut_ad(!bpage->in_flush_list); ut_ad(!bpage->in_LRU_list); mutex_exit(&((buf_block_t*) bpage)->mutex); - //buf_pool_mutex_exit_forbid(); - buf_buddy_free(data, page_zip_get_size(&bpage->zip), TRUE); - //buf_pool_mutex_exit_allow(); + //buf_pool_mutex_exit_forbid(buf_pool); + + buf_buddy_free( + buf_pool, data, + page_zip_get_size(&bpage->zip), TRUE); + + //buf_pool_mutex_exit_allow(buf_pool); mutex_enter(&((buf_block_t*) bpage)->mutex); page_zip_set_size(&bpage->zip, 0); } @@ -2030,7 +2143,10 @@ buf_LRU_block_free_hashed_page( be in a state where it can be freed */ ibool have_page_hash_mutex) { - //ut_ad(buf_pool_mutex_own()); +#ifdef UNIV_DEBUG + //buf_pool_t* buf_pool = buf_pool_from_block(block); + //ut_ad(buf_pool_mutex_own(buf_pool)); +#endif ut_ad(mutex_own(&block->mutex)); buf_block_set_state(block, BUF_BLOCK_MEMORY); @@ -2039,17 +2155,18 @@ buf_LRU_block_free_hashed_page( } /**********************************************************************//** -Updates buf_LRU_old_ratio. +Updates buf_pool->LRU_old_ratio for one buffer pool instance. @return updated old_pct */ -UNIV_INTERN +static uint -buf_LRU_old_ratio_update( -/*=====================*/ - uint old_pct,/*!< in: Reserve this percentage of - the buffer pool for "old" blocks. */ - ibool adjust) /*!< in: TRUE=adjust the LRU list; - FALSE=just assign buf_LRU_old_ratio - during the initialization of InnoDB */ +buf_LRU_old_ratio_update_instance( +/*==============================*/ + buf_pool_t* buf_pool,/*!< in: buffer pool instance */ + uint old_pct,/*!< in: Reserve this percentage of + the buffer pool for "old" blocks. */ + ibool adjust) /*!< in: TRUE=adjust the LRU list; + FALSE=just assign buf_pool->LRU_old_ratio + during the initialization of InnoDB */ { uint ratio; @@ -2061,29 +2178,57 @@ buf_LRU_old_ratio_update( } if (adjust) { - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); - if (ratio != buf_LRU_old_ratio) { - buf_LRU_old_ratio = ratio; + if (ratio != buf_pool->LRU_old_ratio) { + buf_pool->LRU_old_ratio = ratio; if (UT_LIST_GET_LEN(buf_pool->LRU) - >= BUF_LRU_OLD_MIN_LEN) { - buf_LRU_old_adjust_len(); + >= BUF_LRU_OLD_MIN_LEN) { + + buf_LRU_old_adjust_len(buf_pool); } } - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); } else { - buf_LRU_old_ratio = ratio; + buf_pool->LRU_old_ratio = ratio; } - /* the reverse of ratio = old_pct * BUF_LRU_OLD_RATIO_DIV / 100 */ return((uint) (ratio * 100 / (double) BUF_LRU_OLD_RATIO_DIV + 0.5)); } +/**********************************************************************//** +Updates buf_pool->LRU_old_ratio. +@return updated old_pct */ +UNIV_INTERN +ulint +buf_LRU_old_ratio_update( +/*=====================*/ + uint old_pct,/*!< in: Reserve this percentage of + the buffer pool for "old" blocks. */ + ibool adjust) /*!< in: TRUE=adjust the LRU list; + FALSE=just assign buf_pool->LRU_old_ratio + during the initialization of InnoDB */ +{ + ulint i; + ulint new_ratio = 0; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + + new_ratio = buf_LRU_old_ratio_update_instance( + buf_pool, old_pct, adjust); + } + + return(new_ratio); +} + /********************************************************************//** Update the historical stats that we are collecting for LRU eviction policy at the end of each interval. */ @@ -2092,30 +2237,45 @@ void buf_LRU_stat_update(void) /*=====================*/ { + ulint i; buf_LRU_stat_t* item; + buf_pool_t* buf_pool; + ibool evict_started = FALSE; + buf_LRU_stat_t cur_stat; /* If we haven't started eviction yet then don't update stats. */ - if (buf_pool->freed_page_clock == 0) { - goto func_exit; + for (i = 0; i < srv_buf_pool_instances; i++) { + + buf_pool = buf_pool_from_array(i); + + if (buf_pool->freed_page_clock != 0) { + evict_started = TRUE; + break; + } } - //buf_pool_mutex_enter(); - mutex_enter(&buf_pool_mutex); + if (!evict_started) { + goto func_exit; + } /* Update the index. */ item = &buf_LRU_stat_arr[buf_LRU_stat_arr_ind]; buf_LRU_stat_arr_ind++; buf_LRU_stat_arr_ind %= BUF_LRU_STAT_N_INTERVAL; - /* Add the current value and subtract the obsolete entry. */ - buf_LRU_stat_sum.io += buf_LRU_stat_cur.io - item->io; - buf_LRU_stat_sum.unzip += buf_LRU_stat_cur.unzip - item->unzip; + /* Add the current value and subtract the obsolete entry. + Since buf_LRU_stat_cur is not protected by any mutex, + it can be changing between adding to buf_LRU_stat_sum + and copying to item. Assign it to local variables to make + sure the same value assign to the buf_LRU_stat_sum + and item */ + cur_stat = buf_LRU_stat_cur; + + buf_LRU_stat_sum.io += cur_stat.io - item->io; + buf_LRU_stat_sum.unzip += cur_stat.unzip - item->unzip; /* Put current entry in the array. */ - memcpy(item, &buf_LRU_stat_cur, sizeof *item); - - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); + memcpy(item, &cur_stat, sizeof *item); func_exit: /* Clear the current entry. */ @@ -2145,8 +2305,8 @@ buf_LRU_file_dump(void) if (strstr(srv_data_file_names[i], LRU_DUMP_FILE) != NULL) { fprintf(stderr, " InnoDB: The name '%s' seems to be used for" - " innodb_data_file_path. Dumping LRU list is not" - " done for safeness.\n", LRU_DUMP_FILE); + " innodb_data_file_path. For safety, dumping of the LRU list" + " is not being done.\n", LRU_DUMP_FILE); goto end; } } @@ -2159,7 +2319,7 @@ buf_LRU_file_dump(void) goto end; } - dump_file = os_file_create(LRU_DUMP_FILE, OS_FILE_OVERWRITE, + dump_file = os_file_create(innodb_file_temp_key, LRU_DUMP_FILE, OS_FILE_OVERWRITE, OS_FILE_NORMAL, OS_DATA_FILE, &success); if (!success) { os_file_get_last_error(TRUE); @@ -2168,39 +2328,46 @@ buf_LRU_file_dump(void) goto end; } - mutex_enter(&LRU_list_mutex); - bpage = UT_LIST_GET_LAST(buf_pool->LRU); - buffers = offset = 0; - while (bpage != NULL) { - if (offset == 0) { - memset(buffer, 0, UNIV_PAGE_SIZE); - } - mach_write_to_4(buffer + offset * 4, bpage->space); - offset++; - mach_write_to_4(buffer + offset * 4, bpage->offset); - offset++; + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; - if (offset == UNIV_PAGE_SIZE/4) { - success = os_file_write(LRU_DUMP_FILE, dump_file, buffer, - (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL, - (buffers >> (32 - UNIV_PAGE_SIZE_SHIFT)), - UNIV_PAGE_SIZE); - if (!success) { - mutex_exit(&LRU_list_mutex); - fprintf(stderr, - " InnoDB: cannot write page %lu of %s\n", - buffers, LRU_DUMP_FILE); - goto end; + buf_pool = buf_pool_from_array(i); + + mutex_enter(&buf_pool->LRU_list_mutex); + bpage = UT_LIST_GET_LAST(buf_pool->LRU); + + while (bpage != NULL) { + if (offset == 0) { + memset(buffer, 0, UNIV_PAGE_SIZE); } - buffers++; - offset = 0; - } - bpage = UT_LIST_GET_PREV(LRU, bpage); + mach_write_to_4(buffer + offset * 4, bpage->space); + offset++; + mach_write_to_4(buffer + offset * 4, bpage->offset); + offset++; + + if (offset == UNIV_PAGE_SIZE/4) { + success = os_file_write(LRU_DUMP_FILE, dump_file, buffer, + (buffers << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFFUL, + (buffers >> (32 - UNIV_PAGE_SIZE_SHIFT)), + UNIV_PAGE_SIZE); + if (!success) { + mutex_exit(&buf_pool->LRU_list_mutex); + fprintf(stderr, + " InnoDB: cannot write page %lu of %s\n", + buffers, LRU_DUMP_FILE); + goto end; + } + buffers++; + offset = 0; + } + + bpage = UT_LIST_GET_PREV(LRU, bpage); + } + mutex_exit(&buf_pool->LRU_list_mutex); } - mutex_exit(&LRU_list_mutex); if (offset == 0) { memset(buffer, 0, UNIV_PAGE_SIZE); @@ -2265,12 +2432,12 @@ buf_LRU_file_restore(void) ulint req = 0; ibool terminated = FALSE; ibool ret = FALSE; - dump_record_t* records= 0; + dump_record_t* records = NULL; ulint size; ulint size_high; ulint length; - dump_file = os_file_create_simple_no_error_handling( + dump_file = os_file_create_simple_no_error_handling(innodb_file_temp_key, LRU_DUMP_FILE, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success); if (!success || !os_file_get_size(dump_file, &size, &size_high)) { os_file_get_last_error(TRUE); @@ -2300,8 +2467,8 @@ buf_LRU_file_restore(void) UNIV_PAGE_SIZE); if (!success) { fprintf(stderr, - " InnoDB: cannot read page %lu of %s," - " or meet unexpected terminal.\n", + " InnoDB: either could not read page %lu of %s," + " or terminated unexpectedly.\n", buffers, LRU_DUMP_FILE); goto end; } @@ -2353,7 +2520,7 @@ buf_LRU_file_restore(void) if (offset % 16 == 15) { os_aio_simulated_wake_handler_threads(); - buf_flush_free_margin(FALSE); + buf_flush_free_margins(FALSE); } zip_size = fil_space_get_zip_size(space_id); @@ -2361,8 +2528,7 @@ buf_LRU_file_restore(void) continue; } - if (fil_area_is_exist(space_id, zip_size, page_no, 0, - zip_size ? zip_size : UNIV_PAGE_SIZE)) { + if (fil_is_exist(space_id, page_no)) { tablespace_version = fil_space_get_version(space_id); @@ -2376,7 +2542,7 @@ buf_LRU_file_restore(void) } os_aio_simulated_wake_handler_threads(); - buf_flush_free_margin(FALSE); + buf_flush_free_margins(FALSE); ut_print_timestamp(stderr); fprintf(stderr, @@ -2396,12 +2562,12 @@ end: #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /**********************************************************************//** -Validates the LRU list. -@return TRUE */ -UNIV_INTERN -ibool -buf_LRU_validate(void) -/*==================*/ +Validates the LRU list for one buffer pool instance. */ +static +void +buf_LRU_validate_instance( +/*======================*/ + buf_pool_t* buf_pool) { buf_page_t* bpage; buf_block_t* block; @@ -2409,15 +2575,16 @@ buf_LRU_validate(void) ulint new_len; ut_ad(buf_pool); - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); if (UT_LIST_GET_LEN(buf_pool->LRU) >= BUF_LRU_OLD_MIN_LEN) { ut_a(buf_pool->LRU_old); old_len = buf_pool->LRU_old_len; new_len = ut_min(UT_LIST_GET_LEN(buf_pool->LRU) - * buf_LRU_old_ratio / BUF_LRU_OLD_RATIO_DIV, + * buf_pool->LRU_old_ratio + / BUF_LRU_OLD_RATIO_DIV, UT_LIST_GET_LEN(buf_pool->LRU) - (BUF_LRU_OLD_TOLERANCE + BUF_LRU_NON_OLD_MIN_LEN)); @@ -2470,8 +2637,8 @@ buf_LRU_validate(void) ut_a(buf_pool->LRU_old_len == old_len); - mutex_exit(&LRU_list_mutex); - mutex_enter(&free_list_mutex); + mutex_exit(&buf_pool->LRU_list_mutex); + mutex_enter(&buf_pool->free_list_mutex); UT_LIST_VALIDATE(free, buf_page_t, buf_pool->free, ut_ad(ut_list_node_313->in_free_list)); @@ -2483,8 +2650,8 @@ buf_LRU_validate(void) ut_a(buf_page_get_state(bpage) == BUF_BLOCK_NOT_USED); } - mutex_exit(&free_list_mutex); - mutex_enter(&LRU_list_mutex); + mutex_exit(&buf_pool->free_list_mutex); + mutex_enter(&buf_pool->LRU_list_mutex); UT_LIST_VALIDATE(unzip_LRU, buf_block_t, buf_pool->unzip_LRU, ut_ad(ut_list_node_313->in_unzip_LRU_list @@ -2499,30 +2666,51 @@ buf_LRU_validate(void) ut_a(buf_page_belongs_to_unzip_LRU(&block->page)); } - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); +} + +/**********************************************************************//** +Validates the LRU list. +@return TRUE */ +UNIV_INTERN +ibool +buf_LRU_validate(void) +/*==================*/ +{ + ulint i; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool_t* buf_pool; + + buf_pool = buf_pool_from_array(i); + buf_LRU_validate_instance(buf_pool); + } + return(TRUE); } #endif /* UNIV_DEBUG || UNIV_BUF_DEBUG */ #if defined UNIV_DEBUG_PRINT || defined UNIV_DEBUG || defined UNIV_BUF_DEBUG /**********************************************************************//** -Prints the LRU list. */ +Prints the LRU list for one buffer pool instance. */ UNIV_INTERN void -buf_LRU_print(void) -/*===============*/ +buf_LRU_print_instance( +/*===================*/ + buf_pool_t* buf_pool) { const buf_page_t* bpage; ut_ad(buf_pool); - //buf_pool_mutex_enter(); - mutex_enter(&LRU_list_mutex); + //buf_pool_mutex_enter(buf_pool); + mutex_enter(&buf_pool->LRU_list_mutex); bpage = UT_LIST_GET_FIRST(buf_pool->LRU); while (bpage != NULL) { + mutex_enter(buf_page_get_mutex(bpage)); fprintf(stderr, "BLOCK space %lu page %lu ", (ulong) buf_page_get_space(bpage), (ulong) buf_page_get_page_no(bpage)); @@ -2550,19 +2738,17 @@ buf_LRU_print(void) case BUF_BLOCK_FILE_PAGE: frame = buf_block_get_frame((buf_block_t*) bpage); fprintf(stderr, "\ntype %lu" - " index id %lu\n", + " index id %llu\n", (ulong) fil_page_get_type(frame), - (ulong) ut_dulint_get_low( - btr_page_get_index_id(frame))); + (ullint) btr_page_get_index_id(frame)); break; case BUF_BLOCK_ZIP_PAGE: frame = bpage->zip.data; fprintf(stderr, "\ntype %lu size %lu" - " index id %lu\n", + " index id %llu\n", (ulong) fil_page_get_type(frame), (ulong) buf_page_get_zip_size(bpage), - (ulong) ut_dulint_get_low( - btr_page_get_index_id(frame))); + (ullint) btr_page_get_index_id(frame)); break; default: @@ -2571,10 +2757,27 @@ buf_LRU_print(void) break; } + mutex_exit(buf_page_get_mutex(bpage)); bpage = UT_LIST_GET_NEXT(LRU, bpage); } - //buf_pool_mutex_exit(); - mutex_exit(&LRU_list_mutex); + //buf_pool_mutex_exit(buf_pool); + mutex_exit(&buf_pool->LRU_list_mutex); +} + +/**********************************************************************//** +Prints the LRU list. */ +UNIV_INTERN +void +buf_LRU_print(void) +/*===============*/ +{ + ulint i; + buf_pool_t* buf_pool; + + for (i = 0; i < srv_buf_pool_instances; i++) { + buf_pool = buf_pool_from_array(i); + buf_LRU_print_instance(buf_pool); + } } #endif /* UNIV_DEBUG_PRINT || UNIV_DEBUG || UNIV_BUF_DEBUG */ diff --git a/storage/xtradb/buf/buf0rea.c b/storage/xtradb/buf/buf0rea.c index 59de70d9a8a..587b982b3e0 100644 --- a/storage/xtradb/buf/buf0rea.c +++ b/storage/xtradb/buf/buf0rea.c @@ -37,6 +37,8 @@ Created 11/5/1995 Heikki Tuuri #include "os0file.h" #include "srv0start.h" #include "srv0srv.h" +#include "mysql/plugin.h" +#include "mysql/service_thd_wait.h" /** The linear read-ahead area size */ #define BUF_READ_AHEAD_LINEAR_AREA BUF_READ_AHEAD_AREA @@ -178,6 +180,7 @@ not_to_recover: ut_ad(buf_page_in_file(bpage)); + thd_wait_begin(NULL, THD_WAIT_DISKIO); if (zip_size) { *err = _fil_io(OS_FILE_READ | wake_later, sync, space, zip_size, offset, 0, zip_size, @@ -189,6 +192,7 @@ not_to_recover: sync, space, 0, offset, 0, UNIV_PAGE_SIZE, ((buf_block_t*) bpage)->frame, bpage, trx); } + thd_wait_end(NULL); if (srv_pass_corrupt_table) { if (*err != DB_SUCCESS) { @@ -201,7 +205,7 @@ not_to_recover: if (sync) { /* The i/o is already completed when we arrive from fil_read */ - buf_page_io_complete(bpage, trx); + buf_page_io_complete(bpage); } return(1); @@ -222,6 +226,7 @@ buf_read_page( ulint offset, /*!< in: page number */ trx_t* trx) { + buf_pool_t* buf_pool = buf_pool_get(space, offset); ib_int64_t tablespace_version; ulint count; ulint err; @@ -246,7 +251,7 @@ buf_read_page( } /* Flush pages from the end of the LRU list if necessary */ - buf_flush_free_margin(FALSE); + buf_flush_free_margin(buf_pool, TRUE); /* Increment number of I/O operations used for LRU policy. */ buf_LRU_stat_inc_io(); @@ -282,12 +287,13 @@ UNIV_INTERN ulint buf_read_ahead_linear( /*==================*/ - ulint space, /*!< in: space id */ - ulint zip_size,/*!< in: compressed page size in bytes, or 0 */ - ulint offset, /*!< in: page number of a page; NOTE: the current thread - must want access to this page (see NOTE 3 above) */ + ulint space, /*!< in: space id */ + ulint zip_size, /*!< in: compressed page size in bytes, or 0 */ + ulint offset, /*!< in: page number; see NOTE 3 above */ + ibool inside_ibuf, /*!< in: TRUE if we are inside ibuf routine */ trx_t* trx) { + buf_pool_t* buf_pool = buf_pool_get(space, offset); ib_int64_t tablespace_version; buf_page_t* bpage; buf_frame_t* frame; @@ -303,12 +309,12 @@ buf_read_ahead_linear( ulint err; ulint i; const ulint buf_read_ahead_linear_area - = BUF_READ_AHEAD_LINEAR_AREA; + = BUF_READ_AHEAD_LINEAR_AREA(buf_pool); ulint threshold; - if (!(srv_read_ahead & 2)) { - return(0); - } + if (!(srv_read_ahead & 2)) { + return(0); + } if (UNIV_UNLIKELY(srv_startup_is_before_trx_rollback_phase)) { /* No read-ahead to avoid thread deadlocks */ @@ -342,12 +348,10 @@ buf_read_ahead_linear( tablespace_version = fil_space_get_version(space); - //buf_pool_mutex_enter(); - mutex_enter(&buf_pool_mutex); + buf_pool_mutex_enter(buf_pool); if (high > fil_space_get_size(space)) { - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); /* The area is not whole, return */ return(0); @@ -355,12 +359,11 @@ buf_read_ahead_linear( if (buf_pool->n_pend_reads > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { - //buf_pool_mutex_exit(); - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); return(0); } - mutex_exit(&buf_pool_mutex); + buf_pool_mutex_exit(buf_pool); /* Check that almost all pages in the area have been accessed; if offset == low, the accesses must be in a descending order, otherwise, @@ -375,15 +378,15 @@ buf_read_ahead_linear( /* How many out of order accessed pages can we ignore when working out the access pattern for linear readahead */ threshold = ut_min((64 - srv_read_ahead_threshold), - BUF_READ_AHEAD_AREA); + BUF_READ_AHEAD_AREA(buf_pool)); fail_count = 0; - rw_lock_s_lock(&page_hash_latch); + rw_lock_s_lock(&buf_pool->page_hash_latch); for (i = low; i < high; i++) { - bpage = buf_page_hash_get(space, i); + bpage = buf_page_hash_get(buf_pool, space, i); - if ((bpage == NULL) || !buf_page_is_accessed(bpage)) { + if (bpage == NULL || !buf_page_is_accessed(bpage)) { /* Not accessed */ fail_count++; @@ -407,8 +410,8 @@ buf_read_ahead_linear( if (fail_count > threshold) { /* Too many failures: return */ - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); return(0); } @@ -420,11 +423,11 @@ buf_read_ahead_linear( /* If we got this far, we know that enough pages in the area have been accessed in the right order: linear read-ahead can be sensible */ - bpage = buf_page_hash_get(space, offset); + bpage = buf_page_hash_get(buf_pool, space, offset); if (bpage == NULL) { - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); return(0); } @@ -450,8 +453,8 @@ buf_read_ahead_linear( pred_offset = fil_page_get_prev(frame); succ_offset = fil_page_get_next(frame); - //buf_pool_mutex_exit(); - rw_lock_s_unlock(&page_hash_latch); + //buf_pool_mutex_exit(buf_pool); + rw_lock_s_unlock(&buf_pool->page_hash_latch); if ((offset == low) && (succ_offset == offset + 1)) { @@ -487,11 +490,9 @@ buf_read_ahead_linear( /* If we got this far, read-ahead can be sensible: do it */ - if (ibuf_inside()) { - ibuf_mode = BUF_READ_IBUF_PAGES_ONLY; - } else { - ibuf_mode = BUF_READ_ANY_PAGE; - } + ibuf_mode = inside_ibuf + ? BUF_READ_IBUF_PAGES_ONLY | OS_AIO_SIMULATED_WAKE_LATER + : BUF_READ_ANY_PAGE | OS_AIO_SIMULATED_WAKE_LATER; count = 0; @@ -508,7 +509,7 @@ buf_read_ahead_linear( if (!ibuf_bitmap_page(zip_size, i)) { count += buf_read_page_low( &err, FALSE, - ibuf_mode | OS_AIO_SIMULATED_WAKE_LATER, + ibuf_mode, space, zip_size, FALSE, tablespace_version, i, trx); if (err == DB_TABLESPACE_DELETED) { ut_print_timestamp(stderr); @@ -530,7 +531,7 @@ buf_read_ahead_linear( os_aio_simulated_wake_handler_threads(); /* Flush pages from the end of the LRU list if necessary */ - buf_flush_free_margin(FALSE); + buf_flush_free_margin(buf_pool, TRUE); #ifdef UNIV_DEBUG if (buf_debug_prints && (count > 0)) { @@ -578,18 +579,21 @@ buf_read_ibuf_merge_pages( { ulint i; - ut_ad(!ibuf_inside()); #ifdef UNIV_IBUF_DEBUG ut_a(n_stored < UNIV_PAGE_SIZE); #endif - while (buf_pool->n_pend_reads - > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { - os_thread_sleep(500000); - } for (i = 0; i < n_stored; i++) { - ulint zip_size = fil_space_get_zip_size(space_ids[i]); - ulint err; + ulint err; + buf_pool_t* buf_pool; + ulint zip_size = fil_space_get_zip_size(space_ids[i]); + + buf_pool = buf_pool_get(space_ids[i], page_nos[i]); + + while (buf_pool->n_pend_reads + > buf_pool->curr_size / BUF_READ_AHEAD_PEND_LIMIT) { + os_thread_sleep(500000); + } if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) { @@ -614,8 +618,8 @@ tablespace_deleted: os_aio_simulated_wake_handler_threads(); - /* Flush pages from the end of the LRU list if necessary */ - buf_flush_free_margin(FALSE); + /* Flush pages from the end of all the LRU lists if necessary */ + buf_flush_free_margins(FALSE); #ifdef UNIV_DEBUG if (buf_debug_prints) { @@ -708,11 +712,12 @@ not_to_recover: tablespace_version = fil_space_get_version(space); for (i = 0; i < n_stored; i++) { + buf_pool_t* buf_pool; count = 0; os_aio_print_debug = FALSE; - + buf_pool = buf_pool_get(space, page_nos[i]); while (buf_pool->n_pend_reads >= recv_n_pool_free_frames / 2) { os_aio_simulated_wake_handler_threads(); @@ -751,8 +756,8 @@ not_to_recover: os_aio_simulated_wake_handler_threads(); - /* Flush pages from the end of the LRU list if necessary */ - buf_flush_free_margin(FALSE); + /* Flush pages from the end of all the LRU lists if necessary */ + buf_flush_free_margins(FALSE); #ifdef UNIV_DEBUG if (buf_debug_prints) { diff --git a/storage/xtradb/build/debian/README.Maintainer b/storage/xtradb/build/debian/README.Maintainer deleted file mode 100644 index 9554bdd7c62..00000000000 --- a/storage/xtradb/build/debian/README.Maintainer +++ /dev/null @@ -1,116 +0,0 @@ - -########################### -## FIXME for 5.1 ## -########################### - -* put this trigger-recreation thing into the init scripts -- what?! -* Let debian-i10n-english review all template changes before the translaters start. -* Mark debconf translations as obsolete with debconf-updatepo. - -########################################################################### -# Here are some information that are only of interest for the current and # -# following Debian maintainers of MySQL. # -########################################################################### - -The debian/ directory is under SVN control, see debian/control for URL. - -# -# Preparing a new version -# -The new orig.tar.gz (without non-free documentation) is created in /tmp/ when -running this command: - -debian/rules get-orig-source - -# -# mysqlreport -# -The authors e-mail address is . - -# -# Remarks to dependencies -# -libwrap0-dev (>= 7.6-8.3) - According to bug report 114582 where where build problems on - IA-64/sid with at least two prior versions. -psmisc - /usr/bin/killall in the initscript - -zlib1g in libmysqlclient-dev: - "mysql_config --libs" ads "-lz" - -Build-Dep: - -debhelper (>=4.1.16): - See po-debconf(7). - -autoconf (>= 2.13-20), automake1.7 - Try to get rid of them. - -doxygen, tetex-bin, tetex-extra, gs - for ndb/docs/*tex - -# -# Remarks to the start scripts -# - -## initscripts rely on mysqladmin from a different package -We have the problem that "/etc/init.d/mysql stop" relies on mysqladmin which -is in another package (mysql-client) and a passwordless access that's maybe -only available if the user configured his /root/.my.cnf. Can this be a problem? -* normal mode: not because the user is required to have it. Else: -* purge/remove: not, same as normal mode -* upgrade: not, same as normal mode -* first install: not, it depends on mysql-client which at least is unpacked - so mysqladmin is there (to ping). It is not yet configured - passwordles but if there's a server running then there's a - /root/.my.cnf. Anyways, we simply kill anything that's mysqld. - -## Passwordless access for the maintainer scripts -Another issue is that the scripts needs passwordless access. To ensure this -a debian-sys-maint user is configured which has process and shutdown privs. -The file with the randomly (that's important!) generated password must be -present as long as the databases remain installed because else a new install -would have no access. This file should be used like: - mysqladmin --defaults-file=/etc/mysql/debian.cnf restart -to avoid providing the password in plaintext on a commandline where it would -be visible to any user via the "ps" command. - -## When to start the daemon? -We aim to give the admin full control on when MySQL is running. -Issues to be faced here: -OLD: - 1. Debconf asks whether MySQL should be started on boot so update-rc.d is - only run if the answer has been yes. The admin is likely to forget - this decision but update-rc.d checks for an existing line in - /etc/runlevel.conf and leaves it intact. - 2. On initial install, if the answer is yes, the daemon has to be started. - 3. On upgrades it should only be started if it was already running, everything - else is confusing. Especiall relying on an debconf decision made month ago - is considered suboptimal. See bug #274264 - Implementation so far: - prerm (called on upgrade before stopping the server): - check for a running server and set flag if necessary - preinst (called on initial install and before unpacking when upgrading): - check for the debconf variable and set flag if necessary - postinst (called on initial install and after each upgrade after unpacking): - call update-rc.d if debconf says yes - call invoce-rc.d if the flag has been set - Problems remaining: - dpkg-reconfigure and setting mysql start on boot to yes did not start mysql - (ok "start on boot" literally does not mean "start now" so that might have been ok) -NEW: - 1. --- no debconf anymore for the sake of simplicity. We have runlevel.conf, - the admin should use it - 2. On initial install the server is started. - 3. On upgrades the server is started exactly if it was running before so the - runlevel configuration is irrelevant. It will be preserved by the mean of - update-rc.d's builtin check. - Implementation: - prerm (called on upgrade before stopping the server): - check for a running server and set flag if necessary - preinst (called on initial install and before unpacking when upgrading): - check for $1 beeing (initial) "install" and set flag - postinst (called on initial install and after each upgrade after unpacking): - call update-rc.d - call invoce-rc.d if the flag has been set diff --git a/storage/xtradb/build/debian/additions/Docs__Images__Makefile.in b/storage/xtradb/build/debian/additions/Docs__Images__Makefile.in deleted file mode 100644 index f7316d4e345..00000000000 --- a/storage/xtradb/build/debian/additions/Docs__Images__Makefile.in +++ /dev/null @@ -1,6 +0,0 @@ -all: - -distclean: - -rm -f Makefile - -.PHONY: all distclean clean install check diff --git a/storage/xtradb/build/debian/additions/Docs__Makefile.in b/storage/xtradb/build/debian/additions/Docs__Makefile.in deleted file mode 100644 index f7316d4e345..00000000000 --- a/storage/xtradb/build/debian/additions/Docs__Makefile.in +++ /dev/null @@ -1,6 +0,0 @@ -all: - -distclean: - -rm -f Makefile - -.PHONY: all distclean clean install check diff --git a/storage/xtradb/build/debian/additions/debian-start b/storage/xtradb/build/debian/additions/debian-start deleted file mode 100644 index 10628019e40..00000000000 --- a/storage/xtradb/build/debian/additions/debian-start +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# This script is executed by "/etc/init.d/mysql" on every (re)start. -# -# Changes to this file will be preserved when updating the Debian package. -# - -source /usr/share/mysql/debian-start.inc.sh - -MYSQL="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf" -MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" -MYUPGRADE="/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf" -MYCHECK="/usr/bin/mysqlcheck --defaults-file=/etc/mysql/debian.cnf" -MYCHECK_SUBJECT="WARNING: mysqlcheck has found corrupt tables" -MYCHECK_PARAMS="--all-databases --fast --silent" -MYCHECK_RCPT="root" - -# The following commands should be run when the server is up but in background -# where they do not block the server start and in one shell instance so that -# they run sequentially. They are supposed not to echo anything to stdout. -# If you want to disable the check for crashed tables comment -# "check_for_crashed_tables" out. -# (There may be no output to stdout inside the background process!) -echo "Checking for corrupt, not cleanly closed and upgrade needing tables." -( - upgrade_system_tables_if_necessary; - check_root_accounts; - check_for_crashed_tables; -) >&2 & - -exit 0 diff --git a/storage/xtradb/build/debian/additions/debian-start.inc.sh b/storage/xtradb/build/debian/additions/debian-start.inc.sh deleted file mode 100644 index 736cb3448eb..00000000000 --- a/storage/xtradb/build/debian/additions/debian-start.inc.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# -# This file is included by /etc/mysql/debian-start -# - -## Check all unclosed tables. -# - Requires the server to be up. -# - Is supposed to run silently in background. -function check_for_crashed_tables() { - set -e - set -u - - # But do it in the background to not stall the boot process. - logger -p daemon.info -i -t$0 "Triggering myisam-recover for all MyISAM tables" - - # Checking for $? is unreliable so the size of the output is checked. - # Some table handlers like HEAP do not support CHECK TABLE. - tempfile=`tempfile` - # We have to use xargs in this case, because a for loop barfs on the - # spaces in the thing to be looped over. - LC_ALL=C $MYSQL --skip-column-names --batch -e ' - select concat("select count(*) into @discard from `", - TABLE_SCHEMA, "`.`", TABLE_NAME, "`") - from information_schema.TABLES where ENGINE="MyISAM"' | \ - xargs -i $MYSQL --skip-column-names --silent --batch \ - --force -e "{}" >$tempfile - if [ -s $tempfile ]; then - ( - /bin/echo -e "\n" \ - "Improperly closed tables are also reported if clients are accessing\n" \ - "the tables *now*. A list of current connections is below.\n"; - $MYADMIN processlist status - ) >> $tempfile - # Check for presence as a dependency on mailx would require an MTA. - if [ -x /usr/bin/mailx ]; then - mailx -e -s"$MYCHECK_SUBJECT" $MYCHECK_RCPT < $tempfile - fi - (echo "$MYCHECK_SUBJECT"; cat $tempfile) | logger -p daemon.warn -i -t$0 - fi - rm $tempfile -} - -## Check for tables needing an upgrade. -# - Requires the server to be up. -# - Is supposed to run silently in background. -function upgrade_system_tables_if_necessary() { - set -e - set -u - - logger -p daemon.info -i -t$0 "Upgrading MySQL tables if necessary." - - # Filter all "duplicate column", "duplicate key" and "unknown column" - # errors as the script is designed to be idempotent. - LC_ALL=C $MYUPGRADE \ - 2>&1 \ - | egrep -v '^(1|@had|ERROR (1054|1060|1061))' \ - | logger -p daemon.warn -i -t$0 -} - -## Check for the presence of both, root accounts with and without password. -# This might have been caused by a bug related to mysql_install_db (#418672). -function check_root_accounts() { - set -e - set -u - - logger -p daemon.info -i -t$0 "Checking for insecure root accounts." - - ret=$( echo "SELECT count(*) FROM mysql.user WHERE user='root' and password='';" | $MYSQL --skip-column-names ) - if [ "$ret" -ne "0" ]; then - logger -p daemon.warn -i -t$0 "WARNING: mysql.user contains $ret root accounts without password!" - fi -} diff --git a/storage/xtradb/build/debian/additions/echo_stderr b/storage/xtradb/build/debian/additions/echo_stderr deleted file mode 100644 index 67b3ed7cfb3..00000000000 --- a/storage/xtradb/build/debian/additions/echo_stderr +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echo "$*" 1>&2 diff --git a/storage/xtradb/build/debian/additions/innotop/InnoDBParser.pm b/storage/xtradb/build/debian/additions/innotop/InnoDBParser.pm deleted file mode 100644 index 3aaa7acd5b8..00000000000 --- a/storage/xtradb/build/debian/additions/innotop/InnoDBParser.pm +++ /dev/null @@ -1,1089 +0,0 @@ -use strict; -use warnings FATAL => 'all'; - -package InnoDBParser; - -# This program is copyright (c) 2006 Baron Schwartz, baron at xaprb dot com. -# Feedback and improvements are gratefully received. -# -# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -# -# 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; OR the Perl Artistic License. On UNIX and similar -# systems, you can issue `man perlgpl' or `man perlartistic' to read these - -# 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., 59 Temple -# Place, Suite 330, Boston, MA 02111-1307 USA - -our $VERSION = '1.6.0'; - -use Data::Dumper; -$Data::Dumper::Sortkeys = 1; -use English qw(-no_match_vars); -use List::Util qw(max); - -# Some common patterns -my $d = qr/(\d+)/; # Digit -my $f = qr/(\d+\.\d+)/; # Float -my $t = qr/(\d+ \d+)/; # Transaction ID -my $i = qr/((?:\d{1,3}\.){3}\d+)/; # IP address -my $n = qr/([^`\s]+)/; # MySQL object name -my $w = qr/(\w+)/; # Words -my $fl = qr/([\w\.\/]+) line $d/; # Filename and line number -my $h = qr/((?:0x)?[0-9a-f]*)/; # Hex -my $s = qr/(\d{6} .\d:\d\d:\d\d)/; # InnoDB timestamp - -# If you update this variable, also update the SYNOPSIS in the pod. -my %innodb_section_headers = ( - "TRANSACTIONS" => "tx", - "BUFFER POOL AND MEMORY" => "bp", - "SEMAPHORES" => "sm", - "LOG" => "lg", - "ROW OPERATIONS" => "ro", - "INSERT BUFFER AND ADAPTIVE HASH INDEX" => "ib", - "FILE I/O" => "io", - "LATEST DETECTED DEADLOCK" => "dl", - "LATEST FOREIGN KEY ERROR" => "fk", -); - -my %parser_for = ( - tx => \&parse_tx_section, - bp => \&parse_bp_section, - sm => \&parse_sm_section, - lg => \&parse_lg_section, - ro => \&parse_ro_section, - ib => \&parse_ib_section, - io => \&parse_io_section, - dl => \&parse_dl_section, - fk => \&parse_fk_section, -); - -my %fk_parser_for = ( - Transaction => \&parse_fk_transaction_error, - Error => \&parse_fk_bad_constraint_error, - Cannot => \&parse_fk_cant_drop_parent_error, -); - -# A thread's proc_info can be at least 98 different things I've found in the -# source. Fortunately, most of them begin with a gerunded verb. These are -# the ones that don't. -my %is_proc_info = ( - 'After create' => 1, - 'Execution of init_command' => 1, - 'FULLTEXT initialization' => 1, - 'Reopen tables' => 1, - 'Repair done' => 1, - 'Repair with keycache' => 1, - 'System lock' => 1, - 'Table lock' => 1, - 'Thread initialized' => 1, - 'User lock' => 1, - 'copy to tmp table' => 1, - 'discard_or_import_tablespace' => 1, - 'end' => 1, - 'got handler lock' => 1, - 'got old table' => 1, - 'init' => 1, - 'key cache' => 1, - 'locks' => 1, - 'malloc' => 1, - 'query end' => 1, - 'rename result table' => 1, - 'rename' => 1, - 'setup' => 1, - 'statistics' => 1, - 'status' => 1, - 'table cache' => 1, - 'update' => 1, -); - -sub new { - bless {}, shift; -} - -# Parse the status and return it. -# See srv_printf_innodb_monitor in innobase/srv/srv0srv.c -# Pass in the text to parse, whether to be in debugging mode, which sections -# to parse (hashref; if empty, parse all), and whether to parse full info from -# locks and such (probably shouldn't unless you need to). -sub parse_status_text { - my ( $self, $fulltext, $debug, $sections, $full ) = @_; - - die "I can't parse undef" unless defined $fulltext; - $fulltext =~ s/[\r\n]+/\n/g; - - $sections ||= {}; - die '$sections must be a hashref' unless ref($sections) eq 'HASH'; - - my %innodb_data = ( - got_all => 0, # Whether I was able to get the whole thing - ts => '', # Timestamp the server put on it - last_secs => 0, # Num seconds the averages are over - sections => {}, # Parsed values from each section - ); - - if ( $debug ) { - $innodb_data{'fulltext'} = $fulltext; - } - - # Get the most basic info about the status: beginning and end, and whether - # I got the whole thing (if there has been a big deadlock and there are - # too many locks to print, the output might be truncated) - my ( $time_text ) = $fulltext =~ m/^$s INNODB MONITOR OUTPUT$/m; - $innodb_data{'ts'} = [ parse_innodb_timestamp( $time_text ) ]; - $innodb_data{'timestring'} = ts_to_string($innodb_data{'ts'}); - ( $innodb_data{'last_secs'} ) = $fulltext - =~ m/Per second averages calculated from the last $d seconds/; - - ( my $got_all ) = $fulltext =~ m/END OF INNODB MONITOR OUTPUT/; - $innodb_data{'got_all'} = $got_all || 0; - - # Split it into sections. Each section begins with - # ----- - # LABEL - # ----- - my %innodb_sections; - my @matches = $fulltext - =~ m#\n(---+)\n([A-Z /]+)\n\1\n(.*?)(?=\n(---+)\n[A-Z /]+\n\4\n|$)#gs; - while ( my ( $start, $name, $text, $end ) = splice(@matches, 0, 4) ) { - $innodb_sections{$name} = [ $text, $end ? 1 : 0 ]; - } - # The Row Operations section is a special case, because instead of ending - # with the beginning of another section, it ends with the end of the file. - # So this section is complete if the entire file is complete. - $innodb_sections{'ROW OPERATIONS'}->[1] ||= $innodb_data{'got_all'}; - - # Just for sanity's sake, make sure I understand what to do with each - # section - eval { - foreach my $section ( keys %innodb_sections ) { - my $header = $innodb_section_headers{$section}; - die "Unknown section $section in $fulltext\n" - unless $header; - $innodb_data{'sections'}->{ $header } - ->{'fulltext'} = $innodb_sections{$section}->[0]; - $innodb_data{'sections'}->{ $header } - ->{'complete'} = $innodb_sections{$section}->[1]; - } - }; - if ( $EVAL_ERROR ) { - _debug( $debug, $EVAL_ERROR); - } - - # ################################################################ - # Parse the detailed data out of the sections. - # ################################################################ - eval { - foreach my $section ( keys %parser_for ) { - if ( defined $innodb_data{'sections'}->{$section} - && (!%$sections || (defined($sections->{$section} && $sections->{$section})) )) { - $parser_for{$section}->( - $innodb_data{'sections'}->{$section}, - $innodb_data{'sections'}->{$section}->{'complete'}, - $debug, - $full ) - or delete $innodb_data{'sections'}->{$section}; - } - else { - delete $innodb_data{'sections'}->{$section}; - } - } - }; - if ( $EVAL_ERROR ) { - _debug( $debug, $EVAL_ERROR); - } - - return \%innodb_data; -} - -# Parses the status text and returns it flattened out as a single hash. -sub get_status_hash { - my ( $self, $fulltext, $debug, $sections, $full ) = @_; - - # Parse the status text... - my $innodb_status - = $self->parse_status_text($fulltext, $debug, $sections, $full ); - - # Flatten the hierarchical structure into a single list by grabbing desired - # sections from it. - return - (map { 'IB_' . $_ => $innodb_status->{$_} } qw(timestring last_secs got_all)), - (map { 'IB_bp_' . $_ => $innodb_status->{'sections'}->{'bp'}->{$_} } - qw( writes_pending buf_pool_hit_rate total_mem_alloc buf_pool_reads - awe_mem_alloc pages_modified writes_pending_lru page_creates_sec - reads_pending pages_total buf_pool_hits writes_pending_single_page - page_writes_sec pages_read pages_written page_reads_sec - writes_pending_flush_list buf_pool_size add_pool_alloc - dict_mem_alloc pages_created buf_free complete )), - (map { 'IB_tx_' . $_ => $innodb_status->{'sections'}->{'tx'}->{$_} } - qw( num_lock_structs history_list_len purge_done_for transactions - purge_undo_for is_truncated trx_id_counter complete )), - (map { 'IB_ib_' . $_ => $innodb_status->{'sections'}->{'ib'}->{$_} } - qw( hash_table_size hash_searches_s non_hash_searches_s - bufs_in_node_heap used_cells size free_list_len seg_size inserts - merged_recs merges complete )), - (map { 'IB_lg_' . $_ => $innodb_status->{'sections'}->{'lg'}->{$_} } - qw( log_ios_done pending_chkp_writes last_chkp log_ios_s - log_flushed_to log_seq_no pending_log_writes complete )), - (map { 'IB_sm_' . $_ => $innodb_status->{'sections'}->{'sm'}->{$_} } - qw( wait_array_size rw_shared_spins rw_excl_os_waits mutex_os_waits - mutex_spin_rounds mutex_spin_waits rw_excl_spins rw_shared_os_waits - waits signal_count reservation_count complete )), - (map { 'IB_ro_' . $_ => $innodb_status->{'sections'}->{'ro'}->{$_} } - qw( queries_in_queue n_reserved_extents main_thread_state - main_thread_proc_no main_thread_id read_sec del_sec upd_sec ins_sec - read_views_open num_rows_upd num_rows_ins num_rows_read - queries_inside num_rows_del complete )), - (map { 'IB_fk_' . $_ => $innodb_status->{'sections'}->{'fk'}->{$_} } - qw( trigger parent_table child_index parent_index attempted_op - child_db timestring fk_name records col_name reason txn parent_db - type child_table parent_col complete )), - (map { 'IB_io_' . $_ => $innodb_status->{'sections'}->{'io'}->{$_} } - qw( pending_buffer_pool_flushes pending_pwrites pending_preads - pending_normal_aio_reads fsyncs_s os_file_writes pending_sync_ios - reads_s flush_type avg_bytes_s pending_ibuf_aio_reads writes_s - threads os_file_reads pending_aio_writes pending_log_ios os_fsyncs - pending_log_flushes complete )), - (map { 'IB_dl_' . $_ => $innodb_status->{'sections'}->{'dl'}->{$_} } - qw( timestring rolled_back txns complete )); - -} - -sub ts_to_string { - my $parts = shift; - return sprintf('%02d-%02d-%02d %02d:%02d:%02d', @$parts); -} - -sub parse_innodb_timestamp { - my $text = shift; - my ( $y, $m, $d, $h, $i, $s ) - = $text =~ m/^(\d\d)(\d\d)(\d\d) +(\d+):(\d+):(\d+)$/; - die("Can't get timestamp from $text\n") unless $y; - $y += 2000; - return ( $y, $m, $d, $h, $i, $s ); -} - -sub parse_fk_section { - my ( $section, $complete, $debug, $full ) = @_; - my $fulltext = $section->{'fulltext'}; - - return 0 unless $fulltext; - - my ( $ts, $type ) = $fulltext =~ m/^$s\s+(\w+)/m; - $section->{'ts'} = [ parse_innodb_timestamp( $ts ) ]; - $section->{'timestring'} = ts_to_string($section->{'ts'}); - $section->{'type'} = $type; - - # Decide which type of FK error happened, and dispatch to the right parser. - if ( $type && $fk_parser_for{$type} ) { - $fk_parser_for{$type}->( $section, $complete, $debug, $fulltext, $full ); - } - - delete $section->{'fulltext'} unless $debug; - - return 1; -} - -sub parse_fk_cant_drop_parent_error { - my ( $section, $complete, $debug, $fulltext, $full ) = @_; - - # Parse the parent/child table info out - @{$section}{ qw(attempted_op parent_db parent_table) } = $fulltext - =~ m{Cannot $w table `(.*)/(.*)`}m; - @{$section}{ qw(child_db child_table) } = $fulltext - =~ m{because it is referenced by `(.*)/(.*)`}m; - - ( $section->{'reason'} ) = $fulltext =~ m/(Cannot .*)/s; - $section->{'reason'} =~ s/\n(?:InnoDB: )?/ /gm - if $section->{'reason'}; - - # Certain data may not be present. Make them '' if not present. - map { $section->{$_} ||= "" } - qw(child_index fk_name col_name parent_col); -} - -# See dict/dict0dict.c, function dict_foreign_error_report -# I don't care much about these. There are lots of different messages, and -# they come from someone trying to create a foreign key, or similar -# statements. They aren't indicative of some transaction trying to insert, -# delete or update data. Sometimes it is possible to parse out a lot of -# information about the tables and indexes involved, but often the message -# contains the DDL string the user entered, which is way too much for this -# module to try to handle. -sub parse_fk_bad_constraint_error { - my ( $section, $complete, $debug, $fulltext, $full ) = @_; - - # Parse the parent/child table and index info out - @{$section}{ qw(child_db child_table) } = $fulltext - =~ m{Error in foreign key constraint of table (.*)/(.*):$}m; - $section->{'attempted_op'} = 'DDL'; - - # FK name, parent info... if possible. - @{$section}{ qw(fk_name col_name parent_db parent_table parent_col) } - = $fulltext - =~ m/CONSTRAINT `?$n`? FOREIGN KEY \(`?$n`?\) REFERENCES (?:`?$n`?\.)?`?$n`? \(`?$n`?\)/; - - if ( !defined($section->{'fk_name'}) ) { - # Try to parse SQL a user might have typed in a CREATE statement or such - @{$section}{ qw(col_name parent_db parent_table parent_col) } - = $fulltext - =~ m/FOREIGN\s+KEY\s*\(`?$n`?\)\s+REFERENCES\s+(?:`?$n`?\.)?`?$n`?\s*\(`?$n`?\)/i; - } - $section->{'parent_db'} ||= $section->{'child_db'}; - - # Name of the child index (index in the same table where the FK is, see - # definition of dict_foreign_struct in include/dict0mem.h, where it is - # called foreign_index, as opposed to referenced_index which is in the - # parent table. This may not be possible to find. - @{$section}{ qw(child_index) } = $fulltext - =~ m/^The index in the foreign key in table is $n$/m; - - @{$section}{ qw(reason) } = $fulltext =~ m/:\s*([^:]+)(?= Constraint:|$)/ms; - $section->{'reason'} =~ s/\s+/ /g - if $section->{'reason'}; - - # Certain data may not be present. Make them '' if not present. - map { $section->{$_} ||= "" } - qw(child_index fk_name col_name parent_table parent_col); -} - -# see source file row/row0ins.c -sub parse_fk_transaction_error { - my ( $section, $complete, $debug, $fulltext, $full ) = @_; - - # Parse the txn info out - my ( $txn ) = $fulltext - =~ m/Transaction:\n(TRANSACTION.*)\nForeign key constraint fails/s; - if ( $txn ) { - $section->{'txn'} = parse_tx_text( $txn, $complete, $debug, $full ); - } - - # Parse the parent/child table and index info out. There are two types: an - # update or a delete of a parent record leaves a child orphaned - # (row_ins_foreign_report_err), and an insert or update of a child record has - # no matching parent record (row_ins_foreign_report_add_err). - - @{$section}{ qw(reason child_db child_table) } - = $fulltext =~ m{^(Foreign key constraint fails for table `(.*)/(.*)`:)$}m; - - @{$section}{ qw(fk_name col_name parent_db parent_table parent_col) } - = $fulltext - =~ m/CONSTRAINT `$n` FOREIGN KEY \(`$n`\) REFERENCES (?:`$n`\.)?`$n` \(`$n`\)/; - $section->{'parent_db'} ||= $section->{'child_db'}; - - # Special case, which I don't know how to trigger, but see - # innobase/row/row0ins.c row_ins_check_foreign_constraint - if ( $fulltext =~ m/ibd file does not currently exist!/ ) { - my ( $attempted_op, $index, $records ) - = $fulltext =~ m/^Trying to (add to index) `$n` tuple:\n(.*))?/sm; - $section->{'child_index'} = $index; - $section->{'attempted_op'} = $attempted_op || ''; - if ( $records && $full ) { - ( $section->{'records'} ) - = parse_innodb_record_dump( $records, $complete, $debug ); - } - @{$section}{qw(parent_db parent_table)} - =~ m/^But the parent table `$n`\.`$n`$/m; - } - else { - my ( $attempted_op, $which, $index ) - = $fulltext =~ m/^Trying to ([\w ]*) in (child|parent) table, in index `$n` tuple:$/m; - if ( $which ) { - $section->{$which . '_index'} = $index; - $section->{'attempted_op'} = $attempted_op || ''; - - # Parse out the related records in the other table. - my ( $search_index, $records ); - if ( $which eq 'child' ) { - ( $search_index, $records ) = $fulltext - =~ m/^But in parent table [^,]*, in index `$n`,\nthe closest match we can find is record:\n(.*)/ms; - $section->{'parent_index'} = $search_index; - } - else { - ( $search_index, $records ) = $fulltext - =~ m/^But in child table [^,]*, in index `$n`, (?:the record is not available|there is a record:\n(.*))?/ms; - $section->{'child_index'} = $search_index; - } - if ( $records && $full ) { - $section->{'records'} - = parse_innodb_record_dump( $records, $complete, $debug ); - } - else { - $section->{'records'} = ''; - } - } - } - - # Parse out the tuple trying to be updated, deleted or inserted. - my ( $trigger ) = $fulltext =~ m/^(DATA TUPLE: \d+ fields;\n.*)$/m; - if ( $trigger ) { - $section->{'trigger'} = parse_innodb_record_dump( $trigger, $complete, $debug ); - } - - # Certain data may not be present. Make them '' if not present. - map { $section->{$_} ||= "" } - qw(child_index fk_name col_name parent_table parent_col); -} - -# There are new-style and old-style record formats. See rem/rem0rec.c -# TODO: write some tests for this -sub parse_innodb_record_dump { - my ( $dump, $complete, $debug ) = @_; - return undef unless $dump; - - my $result = {}; - - if ( $dump =~ m/PHYSICAL RECORD/ ) { - my $style = $dump =~ m/compact format/ ? 'new' : 'old'; - $result->{'style'} = $style; - - # This is a new-style record. - if ( $style eq 'new' ) { - @{$result}{qw( heap_no type num_fields info_bits )} - = $dump - =~ m/^(?:Record lock, heap no $d )?([A-Z ]+): n_fields $d; compact format; info bits $d$/m; - } - - # OK, it's old-style. Unfortunately there are variations here too. - elsif ( $dump =~ m/-byte offs / ) { - # Older-old style. - @{$result}{qw( heap_no type num_fields byte_offset info_bits )} - = $dump - =~ m/^(?:Record lock, heap no $d )?([A-Z ]+): n_fields $d; $d-byte offs [A-Z]+; info bits $d$/m; - if ( $dump !~ m/-byte offs TRUE/ ) { - $result->{'byte_offset'} = 0; - } - } - else { - # Newer-old style. - @{$result}{qw( heap_no type num_fields byte_offset info_bits )} - = $dump - =~ m/^(?:Record lock, heap no $d )?([A-Z ]+): n_fields $d; $d-byte offsets; info bits $d$/m; - } - - } - else { - $result->{'style'} = 'tuple'; - @{$result}{qw( type num_fields )} - = $dump =~ m/^(DATA TUPLE): $d fields;$/m; - } - - # Fill in default values for things that couldn't be parsed. - map { $result->{$_} ||= 0 } - qw(heap_no num_fields byte_offset info_bits); - map { $result->{$_} ||= '' } - qw(style type ); - - my @fields = $dump =~ m/ (\d+:.*?;?);(?=$| \d+:)/gm; - $result->{'fields'} = [ map { parse_field($_, $complete, $debug ) } @fields ]; - - return $result; -} - -# New/old-style applies here. See rem/rem0rec.c -# $text should not include the leading space or the second trailing semicolon. -sub parse_field { - my ( $text, $complete, $debug ) = @_; - - # Sample fields: - # '4: SQL NULL, size 4 ' - # '1: len 6; hex 000000005601; asc V ;' - # '6: SQL NULL' - # '5: len 30; hex 687474703a2f2f7777772e737765657477617465722e636f6d2f73746f72; asc http://www.sweetwater.com/stor;...(truncated)' - my ( $id, $nullsize, $len, $hex, $asc, $truncated ); - ( $id, $nullsize ) = $text =~ m/^$d: SQL NULL, size $d $/; - if ( !defined($id) ) { - ( $id ) = $text =~ m/^$d: SQL NULL$/; - } - if ( !defined($id) ) { - ( $id, $len, $hex, $asc, $truncated ) - = $text =~ m/^$d: len $d; hex $h; asc (.*);(\.\.\.\(truncated\))?$/; - } - - die "Could not parse this field: '$text'" unless defined $id; - return { - id => $id, - len => defined($len) ? $len : defined($nullsize) ? $nullsize : 0, - 'hex' => defined($hex) ? $hex : '', - asc => defined($asc) ? $asc : '', - trunc => $truncated ? 1 : 0, - }; - -} - -sub parse_dl_section { - my ( $dl, $complete, $debug, $full ) = @_; - return unless $dl; - my $fulltext = $dl->{'fulltext'}; - return 0 unless $fulltext; - - my ( $ts ) = $fulltext =~ m/^$s$/m; - return 0 unless $ts; - - $dl->{'ts'} = [ parse_innodb_timestamp( $ts ) ]; - $dl->{'timestring'} = ts_to_string($dl->{'ts'}); - $dl->{'txns'} = {}; - - my @sections - = $fulltext - =~ m{ - ^\*{3}\s([^\n]*) # *** (1) WAITING FOR THIS... - (.*?) # Followed by anything, non-greedy - (?=(?:^\*{3})|\z) # Followed by another three stars or EOF - }gmsx; - - - # Loop through each section. There are no assumptions about how many - # there are, who holds and wants what locks, and who gets rolled back. - while ( my ($header, $body) = splice(@sections, 0, 2) ) { - my ( $txn_id, $what ) = $header =~ m/^\($d\) (.*):$/; - next unless $txn_id; - $dl->{'txns'}->{$txn_id} ||= {}; - my $txn = $dl->{'txns'}->{$txn_id}; - - if ( $what eq 'TRANSACTION' ) { - $txn->{'tx'} = parse_tx_text( $body, $complete, $debug, $full ); - } - else { - push @{$txn->{'locks'}}, parse_innodb_record_locks( $body, $complete, $debug, $full ); - } - } - - @{ $dl }{ qw(rolled_back) } - = $fulltext =~ m/^\*\*\* WE ROLL BACK TRANSACTION \($d\)$/m; - - # Make sure certain values aren't undef - map { $dl->{$_} ||= '' } qw(rolled_back); - - delete $dl->{'fulltext'} unless $debug; - return 1; -} - -sub parse_innodb_record_locks { - my ( $text, $complete, $debug, $full ) = @_; - my @result; - - foreach my $lock ( $text =~ m/(^(?:RECORD|TABLE) LOCKS?.*$)/gm ) { - my $hash = {}; - @{$hash}{ qw(lock_type space_id page_no n_bits index db table txn_id lock_mode) } - = $lock - =~ m{^(RECORD|TABLE) LOCKS? (?:space id $d page no $d n bits $d index `?$n`? of )?table `$n(?:/|`\.`)$n` trx id $t lock.mode (\S+)}m; - ( $hash->{'special'} ) - = $lock =~ m/^(?:RECORD|TABLE) .*? locks (rec but not gap|gap before rec)/m; - $hash->{'insert_intention'} - = $lock =~ m/^(?:RECORD|TABLE) .*? insert intention/m ? 1 : 0; - $hash->{'waiting'} - = $lock =~ m/^(?:RECORD|TABLE) .*? waiting/m ? 1 : 0; - - # Some things may not be in the text, so make sure they are not - # undef. - map { $hash->{$_} ||= 0 } qw(n_bits page_no space_id); - map { $hash->{$_} ||= "" } qw(index special); - push @result, $hash; - } - - return @result; -} - -sub parse_tx_text { - my ( $txn, $complete, $debug, $full ) = @_; - - my ( $txn_id, $txn_status, $active_secs, $proc_no, $os_thread_id ) - = $txn - =~ m/^(?:---)?TRANSACTION $t, (\D*?)(?: $d sec)?, (?:process no $d, )?OS thread id $d/m; - my ( $thread_status, $thread_decl_inside ) - = $txn - =~ m/OS thread id \d+(?: ([^,]+?))?(?:, thread declared inside InnoDB $d)?$/m; - - # Parsing the line that begins 'MySQL thread id' is complicated. The only - # thing always in the line is the thread and query id. See function - # innobase_mysql_print_thd in InnoDB source file sql/ha_innodb.cc. - my ( $thread_line ) = $txn =~ m/^(MySQL thread id .*)$/m; - my ( $mysql_thread_id, $query_id, $hostname, $ip, $user, $query_status ); - - if ( $thread_line ) { - # These parts can always be gotten. - ( $mysql_thread_id, $query_id ) = $thread_line =~ m/^MySQL thread id $d, query id $d/m; - - # If it's a master/slave thread, "Has (read|sent) all" may be the thread's - # proc_info. In these cases, there won't be any host/ip/user info - ( $query_status ) = $thread_line =~ m/(Has (?:read|sent) all .*$)/m; - if ( defined($query_status) ) { - $user = 'system user'; - } - - # It may be the case that the query id is the last thing in the line. - elsif ( $thread_line =~ m/query id \d+ / ) { - # The IP address is the only non-word thing left, so it's the most - # useful marker for where I have to start guessing. - ( $hostname, $ip ) = $thread_line =~ m/query id \d+(?: ([A-Za-z]\S+))? $i/m; - if ( defined $ip ) { - ( $user, $query_status ) = $thread_line =~ m/$ip $w(?: (.*))?$/; - } - else { # OK, there wasn't an IP address. - # There might not be ANYTHING except the query status. - ( $query_status ) = $thread_line =~ m/query id \d+ (.*)$/; - if ( $query_status !~ m/^\w+ing/ && !exists($is_proc_info{$query_status}) ) { - # The remaining tokens are, in order: hostname, user, query_status. - # It's basically impossible to know which is which. - ( $hostname, $user, $query_status ) = $thread_line - =~ m/query id \d+(?: ([A-Za-z]\S+))?(?: $w(?: (.*))?)?$/m; - } - else { - $user = 'system user'; - } - } - } - } - - my ( $lock_wait_status, $lock_structs, $heap_size, $row_locks, $undo_log_entries ) - = $txn - =~ m/^(?:(\D*) )?$d lock struct\(s\), heap size $d(?:, $d row lock\(s\))?(?:, undo log entries $d)?$/m; - my ( $lock_wait_time ) - = $txn - =~ m/^------- TRX HAS BEEN WAITING $d SEC/m; - - my $locks; - # If the transaction has locks, grab the locks. - if ( $txn =~ m/^TABLE LOCK|RECORD LOCKS/ ) { - $locks = [parse_innodb_record_locks($txn, $complete, $debug, $full)]; - } - - my ( $tables_in_use, $tables_locked ) - = $txn - =~ m/^mysql tables in use $d, locked $d$/m; - my ( $txn_doesnt_see_ge, $txn_sees_lt ) - = $txn - =~ m/^Trx read view will not see trx with id >= $t, sees < $t$/m; - my $has_read_view = defined($txn_doesnt_see_ge); - # Only a certain number of bytes of the query text are included here, at least - # under some circumstances. Some versions include 300, some 600. - my ( $query_text ) - = $txn - =~ m{ - ^MySQL\sthread\sid\s[^\n]+\n # This comes before the query text - (.*?) # The query text - (?= # Followed by any of... - ^Trx\sread\sview - |^-------\sTRX\sHAS\sBEEN\sWAITING - |^TABLE\sLOCK - |^RECORD\sLOCKS\sspace\sid - |^(?:---)?TRANSACTION - |^\*\*\*\s\(\d\) - |\Z - ) - }xms; - if ( $query_text ) { - $query_text =~ s/\s+$//; - } - else { - $query_text = ''; - } - - my %stuff = ( - active_secs => $active_secs, - has_read_view => $has_read_view, - heap_size => $heap_size, - hostname => $hostname, - ip => $ip, - lock_structs => $lock_structs, - lock_wait_status => $lock_wait_status, - lock_wait_time => $lock_wait_time, - mysql_thread_id => $mysql_thread_id, - os_thread_id => $os_thread_id, - proc_no => $proc_no, - query_id => $query_id, - query_status => $query_status, - query_text => $query_text, - row_locks => $row_locks, - tables_in_use => $tables_in_use, - tables_locked => $tables_locked, - thread_decl_inside => $thread_decl_inside, - thread_status => $thread_status, - txn_doesnt_see_ge => $txn_doesnt_see_ge, - txn_id => $txn_id, - txn_sees_lt => $txn_sees_lt, - txn_status => $txn_status, - undo_log_entries => $undo_log_entries, - user => $user, - ); - $stuff{'fulltext'} = $txn if $debug; - $stuff{'locks'} = $locks if $locks; - - # Some things may not be in the txn text, so make sure they are not - # undef. - map { $stuff{$_} ||= 0 } qw(active_secs heap_size lock_structs - tables_in_use undo_log_entries tables_locked has_read_view - thread_decl_inside lock_wait_time proc_no row_locks); - map { $stuff{$_} ||= "" } qw(thread_status txn_doesnt_see_ge - txn_sees_lt query_status ip query_text lock_wait_status user); - $stuff{'hostname'} ||= $stuff{'ip'}; - - return \%stuff; -} - -sub parse_tx_section { - my ( $section, $complete, $debug, $full ) = @_; - return unless $section && $section->{'fulltext'}; - my $fulltext = $section->{'fulltext'}; - $section->{'transactions'} = []; - - # Handle the individual transactions - my @transactions = $fulltext =~ m/(---TRANSACTION \d.*?)(?=\n---TRANSACTION|$)/gs; - foreach my $txn ( @transactions ) { - my $stuff = parse_tx_text( $txn, $complete, $debug, $full ); - delete $stuff->{'fulltext'} unless $debug; - push @{$section->{'transactions'}}, $stuff; - } - - # Handle the general info - @{$section}{ 'trx_id_counter' } - = $fulltext =~ m/^Trx id counter $t$/m; - @{$section}{ 'purge_done_for', 'purge_undo_for' } - = $fulltext =~ m/^Purge done for trx's n:o < $t undo n:o < $t$/m; - @{$section}{ 'history_list_len' } # This isn't present in some 4.x versions - = $fulltext =~ m/^History list length $d$/m; - @{$section}{ 'num_lock_structs' } - = $fulltext =~ m/^Total number of lock structs in row lock hash table $d$/m; - @{$section}{ 'is_truncated' } - = $fulltext =~ m/^\.\.\. truncated\.\.\.$/m ? 1 : 0; - - # Fill in things that might not be present - foreach ( qw(history_list_len) ) { - $section->{$_} ||= 0; - } - - delete $section->{'fulltext'} unless $debug; - return 1; -} - -# I've read the source for this section. -sub parse_ro_section { - my ( $section, $complete, $debug, $full ) = @_; - return unless $section && $section->{'fulltext'}; - my $fulltext = $section->{'fulltext'}; - - # Grab the info - @{$section}{ 'queries_inside', 'queries_in_queue' } - = $fulltext =~ m/^$d queries inside InnoDB, $d queries in queue$/m; - ( $section->{ 'read_views_open' } ) - = $fulltext =~ m/^$d read views open inside InnoDB$/m; - ( $section->{ 'n_reserved_extents' } ) - = $fulltext =~ m/^$d tablespace extents now reserved for B-tree/m; - @{$section}{ 'main_thread_proc_no', 'main_thread_id', 'main_thread_state' } - = $fulltext =~ m/^Main thread (?:process no. $d, )?id $d, state: (.*)$/m; - @{$section}{ 'num_rows_ins', 'num_rows_upd', 'num_rows_del', 'num_rows_read' } - = $fulltext =~ m/^Number of rows inserted $d, updated $d, deleted $d, read $d$/m; - @{$section}{ 'ins_sec', 'upd_sec', 'del_sec', 'read_sec' } - = $fulltext =~ m#^$f inserts/s, $f updates/s, $f deletes/s, $f reads/s$#m; - $section->{'main_thread_proc_no'} ||= 0; - - map { $section->{$_} ||= 0 } qw(read_views_open n_reserved_extents); - delete $section->{'fulltext'} unless $debug; - return 1; -} - -sub parse_lg_section { - my ( $section, $complete, $debug, $full ) = @_; - return unless $section; - my $fulltext = $section->{'fulltext'}; - - # Grab the info - ( $section->{ 'log_seq_no' } ) - = $fulltext =~ m/Log sequence number \s*(\d.*)$/m; - ( $section->{ 'log_flushed_to' } ) - = $fulltext =~ m/Log flushed up to \s*(\d.*)$/m; - ( $section->{ 'last_chkp' } ) - = $fulltext =~ m/Last checkpoint at \s*(\d.*)$/m; - @{$section}{ 'pending_log_writes', 'pending_chkp_writes' } - = $fulltext =~ m/$d pending log writes, $d pending chkp writes/; - @{$section}{ 'log_ios_done', 'log_ios_s' } - = $fulltext =~ m#$d log i/o's done, $f log i/o's/second#; - - delete $section->{'fulltext'} unless $debug; - return 1; -} - -sub parse_ib_section { - my ( $section, $complete, $debug, $full ) = @_; - return unless $section && $section->{'fulltext'}; - my $fulltext = $section->{'fulltext'}; - - # Some servers will output ibuf information for tablespace 0, as though there - # might be many tablespaces with insert buffers. (In practice I believe - # the source code shows there will only ever be one). I have to parse both - # cases here, but I assume there will only be one. - @{$section}{ 'size', 'free_list_len', 'seg_size' } - = $fulltext =~ m/^Ibuf(?: for space 0)?: size $d, free list len $d, seg size $d,$/m; - @{$section}{ 'inserts', 'merged_recs', 'merges' } - = $fulltext =~ m/^$d inserts, $d merged recs, $d merges$/m; - - @{$section}{ 'hash_table_size', 'used_cells', 'bufs_in_node_heap' } - = $fulltext =~ m/^Hash table size $d, used cells $d, node heap has $d buffer\(s\)$/m; - @{$section}{ 'hash_searches_s', 'non_hash_searches_s' } - = $fulltext =~ m{^$f hash searches/s, $f non-hash searches/s$}m; - - delete $section->{'fulltext'} unless $debug; - return 1; -} - -sub parse_wait_array { - my ( $text, $complete, $debug, $full ) = @_; - my %result; - - @result{ qw(thread waited_at_filename waited_at_line waited_secs) } - = $text =~ m/^--Thread $d has waited at $fl for $f seconds/m; - - # Depending on whether it's a SYNC_MUTEX,RW_LOCK_EX,RW_LOCK_SHARED, - # there will be different text output - if ( $text =~ m/^Mutex at/m ) { - $result{'request_type'} = 'M'; - @result{ qw( lock_mem_addr lock_cfile_name lock_cline lock_var) } - = $text =~ m/^Mutex at $h created file $fl, lock var $d$/m; - @result{ qw( waiters_flag )} - = $text =~ m/^waiters flag $d$/m; - } - else { - @result{ qw( request_type lock_mem_addr lock_cfile_name lock_cline) } - = $text =~ m/^(.)-lock on RW-latch at $h created in file $fl$/m; - @result{ qw( writer_thread writer_lock_mode ) } - = $text =~ m/^a writer \(thread id $d\) has reserved it in mode (.*)$/m; - @result{ qw( num_readers waiters_flag )} - = $text =~ m/^number of readers $d, waiters flag $d$/m; - @result{ qw(last_s_file_name last_s_line ) } - = $text =~ m/Last time read locked in file $fl$/m; - @result{ qw(last_x_file_name last_x_line ) } - = $text =~ m/Last time write locked in file $fl$/m; - } - - $result{'cell_waiting'} = $text =~ m/^wait has ended$/m ? 0 : 1; - $result{'cell_event_set'} = $text =~ m/^wait is ending$/m ? 1 : 0; - - # Because there are two code paths, some things won't get set. - map { $result{$_} ||= '' } - qw(last_s_file_name last_x_file_name writer_lock_mode); - map { $result{$_} ||= 0 } - qw(num_readers lock_var last_s_line last_x_line writer_thread); - - return \%result; -} - -sub parse_sm_section { - my ( $section, $complete, $debug, $full ) = @_; - return 0 unless $section && $section->{'fulltext'}; - my $fulltext = $section->{'fulltext'}; - - # Grab the info - @{$section}{ 'reservation_count', 'signal_count' } - = $fulltext =~ m/^OS WAIT ARRAY INFO: reservation count $d, signal count $d$/m; - @{$section}{ 'mutex_spin_waits', 'mutex_spin_rounds', 'mutex_os_waits' } - = $fulltext =~ m/^Mutex spin waits $d, rounds $d, OS waits $d$/m; - @{$section}{ 'rw_shared_spins', 'rw_shared_os_waits', 'rw_excl_spins', 'rw_excl_os_waits' } - = $fulltext =~ m/^RW-shared spins $d, OS waits $d; RW-excl spins $d, OS waits $d$/m; - - # Look for info on waits. - my @waits = $fulltext =~ m/^(--Thread.*?)^(?=Mutex spin|--Thread)/gms; - $section->{'waits'} = [ map { parse_wait_array($_, $complete, $debug) } @waits ]; - $section->{'wait_array_size'} = scalar(@waits); - - delete $section->{'fulltext'} unless $debug; - return 1; -} - -# I've read the source for this section. -sub parse_bp_section { - my ( $section, $complete, $debug, $full ) = @_; - return unless $section && $section->{'fulltext'}; - my $fulltext = $section->{'fulltext'}; - - # Grab the info - @{$section}{ 'total_mem_alloc', 'add_pool_alloc' } - = $fulltext =~ m/^Total memory allocated $d; in additional pool allocated $d$/m; - @{$section}{'dict_mem_alloc'} = $fulltext =~ m/Dictionary memory allocated $d/; - @{$section}{'awe_mem_alloc'} = $fulltext =~ m/$d MB of AWE memory/; - @{$section}{'buf_pool_size'} = $fulltext =~ m/^Buffer pool size\s*$d$/m; - @{$section}{'buf_free'} = $fulltext =~ m/^Free buffers\s*$d$/m; - @{$section}{'pages_total'} = $fulltext =~ m/^Database pages\s*$d$/m; - @{$section}{'pages_modified'} = $fulltext =~ m/^Modified db pages\s*$d$/m; - @{$section}{'pages_read', 'pages_created', 'pages_written'} - = $fulltext =~ m/^Pages read $d, created $d, written $d$/m; - @{$section}{'page_reads_sec', 'page_creates_sec', 'page_writes_sec'} - = $fulltext =~ m{^$f reads/s, $f creates/s, $f writes/s$}m; - @{$section}{'buf_pool_hits', 'buf_pool_reads'} - = $fulltext =~ m{Buffer pool hit rate $d / $d$}m; - if ($fulltext =~ m/^No buffer pool page gets since the last printout$/m) { - @{$section}{'buf_pool_hits', 'buf_pool_reads'} = (0, 0); - @{$section}{'buf_pool_hit_rate'} = '--'; - } - else { - @{$section}{'buf_pool_hit_rate'} - = $fulltext =~ m{Buffer pool hit rate (\d+ / \d+)$}m; - } - @{$section}{'reads_pending'} = $fulltext =~ m/^Pending reads $d/m; - @{$section}{'writes_pending_lru', 'writes_pending_flush_list', 'writes_pending_single_page' } - = $fulltext =~ m/^Pending writes: LRU $d, flush list $d, single page $d$/m; - - map { $section->{$_} ||= 0 } - qw(writes_pending_lru writes_pending_flush_list writes_pending_single_page - awe_mem_alloc dict_mem_alloc); - @{$section}{'writes_pending'} = List::Util::sum( - @{$section}{ qw(writes_pending_lru writes_pending_flush_list writes_pending_single_page) }); - - delete $section->{'fulltext'} unless $debug; - return 1; -} - -# I've read the source for this. -sub parse_io_section { - my ( $section, $complete, $debug, $full ) = @_; - return unless $section && $section->{'fulltext'}; - my $fulltext = $section->{'fulltext'}; - $section->{'threads'} = {}; - - # Grab the I/O thread info - my @threads = $fulltext =~ m<^(I/O thread \d+ .*)$>gm; - foreach my $thread (@threads) { - my ( $tid, $state, $purpose, $event_set ) - = $thread =~ m{I/O thread $d state: (.+?) \((.*)\)(?: ev set)?$}m; - if ( defined $tid ) { - $section->{'threads'}->{$tid} = { - thread => $tid, - state => $state, - purpose => $purpose, - event_set => $event_set ? 1 : 0, - }; - } - } - - # Grab the reads/writes/flushes info - @{$section}{ 'pending_normal_aio_reads', 'pending_aio_writes' } - = $fulltext =~ m/^Pending normal aio reads: $d, aio writes: $d,$/m; - @{$section}{ 'pending_ibuf_aio_reads', 'pending_log_ios', 'pending_sync_ios' } - = $fulltext =~ m{^ ibuf aio reads: $d, log i/o's: $d, sync i/o's: $d$}m; - @{$section}{ 'flush_type', 'pending_log_flushes', 'pending_buffer_pool_flushes' } - = $fulltext =~ m/^Pending flushes \($w\) log: $d; buffer pool: $d$/m; - @{$section}{ 'os_file_reads', 'os_file_writes', 'os_fsyncs' } - = $fulltext =~ m/^$d OS file reads, $d OS file writes, $d OS fsyncs$/m; - @{$section}{ 'reads_s', 'avg_bytes_s', 'writes_s', 'fsyncs_s' } - = $fulltext =~ m{^$f reads/s, $d avg bytes/read, $f writes/s, $f fsyncs/s$}m; - @{$section}{ 'pending_preads', 'pending_pwrites' } - = $fulltext =~ m/$d pending preads, $d pending pwrites$/m; - @{$section}{ 'pending_preads', 'pending_pwrites' } = (0, 0) - unless defined($section->{'pending_preads'}); - - delete $section->{'fulltext'} unless $debug; - return 1; -} - -sub _debug { - my ( $debug, $msg ) = @_; - if ( $debug ) { - die $msg; - } - else { - warn $msg; - } - return 1; -} - -1; - -# end_of_package -# ############################################################################ -# Perldoc section. I put this last as per the Dog book. -# ############################################################################ -=pod - -=head1 NAME - -InnoDBParser - Parse InnoDB monitor text. - -=head1 DESCRIPTION - -InnoDBParser tries to parse the output of the InnoDB monitor. One way to get -this output is to connect to a MySQL server and issue the command SHOW ENGINE -INNODB STATUS (omit 'ENGINE' on earlier versions of MySQL). The goal is to -turn text into data that something else (e.g. innotop) can use. - -The output comes from all over, but the place to start in the source is -innobase/srv/srv0srv.c. - -=head1 SYNOPSIS - - use InnoDBParser; - use DBI; - - # Get the status text. - my $dbh = DBI->connect( - "DBI::mysql:test;host=localhost", - 'user', - 'password' - ); - my $query = 'SHOW /*!5 ENGINE */ INNODB STATUS'; - my $text = $dbh->selectcol_arrayref($query)->[0]; - - # 1 or 0 - my $debug = 1; - - # Choose sections of the monitor text you want. Possible values: - # TRANSACTIONS => tx - # BUFFER POOL AND MEMORY => bp - # SEMAPHORES => sm - # LOG => lg - # ROW OPERATIONS => ro - # INSERT BUFFER AND ADAPTIVE HASH INDEX => ib - # FILE I/O => io - # LATEST DETECTED DEADLOCK => dl - # LATEST FOREIGN KEY ERROR => fk - - my $required_sections = { - tx => 1, - }; - - # Parse the status text. - my $parser = InnoDBParser->new; - $innodb_status = $parser->parse_status_text( - $text, - $debug, - # Omit the following parameter to get all sections. - $required_sections, - ); - -=head1 COPYRIGHT, LICENSE AND WARRANTY - -This package is copyright (c) 2006 Baron Schwartz, baron at xaprb dot com. -Feedback and improvements are gratefully received. - -THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - -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; OR the Perl Artistic License. On UNIX and similar -systems, you can issue `man perlgpl' or `man perlartistic' to read these -licenses. - -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., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA - -=head1 AUTHOR - -Baron Schwartz, baron at xaprb dot com. - -=head1 BUGS - -None known, but I bet there are some. The InnoDB monitor text wasn't really -designed to be parsable. - -=head1 SEE ALSO - -innotop - a program that can format the parsed status information for humans -to read and enjoy. - -=cut diff --git a/storage/xtradb/build/debian/additions/innotop/changelog.innotop b/storage/xtradb/build/debian/additions/innotop/changelog.innotop deleted file mode 100644 index baff706e235..00000000000 --- a/storage/xtradb/build/debian/additions/innotop/changelog.innotop +++ /dev/null @@ -1,318 +0,0 @@ -Changelog for innotop and InnoDBParser: - -2007-11-09: version 1.6.0 - - * S mode crashed on non-numeric values. - * New user-defined columns crashed upon restart. - * Added --color option to control terminal coloring. - -2007-09-18: version 1.5.2 - - * Added the ability to monitor InnoDB status from a file. - * Changed W mode to L mode; it monitors all locks, not just lock waits. - -2007-09-16: version 1.5.1 - - * Added C (Command Summary) mode. - * Fixed a bug in the 'avg' aggregate function. - -2007-09-10: version 1.5.0 - - Changes: - * Added plugin functionality. - * Added group-by functionality. - * Moved the configuration file to a directory. - * Enhanced filtering and sorting on pivoted tables. - * Many small bug fixes. - -2007-07-16: version 1.4.3 - - Changes: - * Added standard --version command-line option - * Changed colors to cyan instead of blue; more visible on dark terminals. - * Added information to the filter-choosing dialog. - * Added column auto-completion when entering a filter expression. - * Changed Term::ReadKey from optional to mandatory. - * Clarified username in password prompting. - * Ten thousand words of documentation! - - Bugs fixed: - * innotop crashed in W mode when InnoDB status data was truncated. - * innotop didn't display errors in tables if debug was enabled. - * The colored() subroutine wasn't being created in non-interactive mode. - * Don't prompt to save password except the first time. - -2007-05-03: version 1.4.2 - - This version contains all changes to the trunk until revision 239; some - changes in revisions 240:250 are included. - - MAJOR CHANGES: - - * Quick-filters to easily filter any column in any display - * Compatibility with MySQL 3.23 through 6.0 - * Improved error handling when a server is down, permissions denied, etc - * Use additional SHOW INNODB STATUS information in 5.1.x - * Make all modes use tables consistently, so they can all be edited, - filtered, colored and sorted consistently - * Combine V, G and S modes into S mode, with v, g, and s hot-keys - * Let DBD driver read MySQL option files; permit connections without - user/pass/etc - * Compile SQL-like expressions into Perl subroutines; eliminate need to - know Perl - * Do not save all config data to config file, only save user's customizations - * Rewritten and improved command-line option handling - * Added --count, --delay, and other command-line options to support - run-and-exit operation - * Improve built-in variable sets - * Improve help screen with three-part balanced-column layout - * Simplify table-editor and improve hotkey support - * Require Perl to have high-resolution time support (Time::HiRes) - * Help the user choose a query to analyze or kill - * Enable EXPLAIN, show-full-query in T mode just like Q mode - * Let data-extraction access current, previous and incremental data sets - all at once - - MINOR CHANGES: - - * Column stabilizing for Q mode - * New color rules for T, Q, W modes - * Apply slave I/O filter to Q mode - * Improve detection of server version and other meta-data - * Make connection timeout a config variable - * Improve cross-version-compatible SQL syntax - * Get some information from the DBD driver instead of asking MySQL for it - * Improved error messages - * Improve server group creation/editing - * Improve connection/thread killing - * Fix broken key bindings and restore previously mapped hot-keys for - choosing columns - * Some documentation updates (but not nearly enough) - * Allow the user to specify graphing char in S mode (formerly G mode) - * Allow easy switching between variable sets in S mode - * Bind 'n' key globally to choose the 'next' server connection - * Bind '%' key globally to filter displayed tables - * Allow aligning columns on the decimal place for easy readability - * Add hide_hdr config variable to hide column headers in tables - * Add a feature to smartly run PURGE MASTER LOGS in Replication mode - * Enable debug mode as a globally configurable variable - * Improve error messages when an expression or filter doesn't compile or has - a run-time error; die on error when debug is enabled - * Allow user-configurable delays after executing SQL (to let the server - settle down before taking another measurement) - * Add an expression to show how long until a transaction is finished - * Add skip_innodb as a global config variable - * Add '%' after percentages to help disambiguate (user-configurable) - * Add column to M mode to help see how fast slave is catching up to master - - BUG FIXES: - - * T and W modes had wrong value for wait_status column - * Error tracking on connections didn't reset when the connection recovered - * wait_timeout on connections couldn't be set before MySQL 4.0.3 - * There was a crash on 3.23 when wiping deadlocks - * Lettercase changes in some result sets (SHOW MASTER/SLAVE STATUS) between - MySQL versions crashed innotop - * Inactive connections crashed innotop upon access to DBD driver - * set_precision did not respect user defaults for number of digits - * --inc command-line option could not be negated - * InnoDB status parsing was not always parsing all needed information - * S mode (formerly G mode) could crash trying to divide non-numeric data - * M table didn't show Slave_open_temp_tables variable; incorrect lettercase - * DBD drivers with broken AutoCommit would crash innotop - * Some key bindings had incorrect labels - * Some config-file loading routines could load data for things that didn't - exist - * Headers printed too often in S mode - * High-resolution time was not used even when the user had it - * Non-interactive mode printed blank lines sometimes - * Q-mode header and statusbar showed different QPS numbers - * Formulas for key-cache and query-cache hit ratios were wrong - * Mac OS "Darwin" machines were mis-identified as Microsoft Windows - * Some multiplications crashed when given undefined input - * The commify transformation did not check its input and could crash - * Specifying an invalid mode on the command line or config file could crash - innotop - -2007-03-29: version 1.4.1 - - * More tweaks to display of connection errors. - * Fixed a problem with skip-innodb in MySQL 5.1. - * Fix a bug with dead connections in single-connection mode. - * Fix a regex to allow parsing more data from truncated deadlocks. - * Don't load active cxns from the config file if the cxn isn't defined. - -2007-03-03: version 1.4.0 - - * Further tweak error handling and display of connection errors - * More centralization of querying - * Fix forking so it doesn't kill all database connections - * Allow user to run innotop without permissions for GLOBAL variables and status - -2007-02-11: version 1.3.6 - - * Handle some connection failures so innotop doesn't crash because of one server. - * Enable incremental display in more modes. - * Tweaks to colorizing, color editor, and default color rules. - * Tweaks to default sorting rules. - * Use prepared statements for efficiency. - * Bug fixes and code cleanups. - * Data storage is keyed on clock ticks now. - -2007-02-03: version 1.3.5 - - * Bug fixes. - * More tools for editing configuration from within innotop. - * Filters and transformations are constrained to valid values. - * Support for colorizing rows. - * Sorting by multiple columns. - * Compress headers when display is very wide. - * Stabilize and limit column widths. - * Check config file formats when upgrading so upgrades go smoothly. - * Make D mode handle many connections at once. - * Extract simple expressions from data sets in column src property. - This makes innotop more awk-ish. - -2007-01-16: version 1.3 - - * Readline support. - * Can be used unattended, or in a pipe-and-filter mode - where it outputs tab-separated data to standard output. - * You can specify a config file on the command line. - Config files can be marked read-only. - * Monitor multiple servers simultaneously. - * Server groups to help manage many servers conveniently. - * Monitor master/slave status, and control slaves. - * Columns can have user-defined expressions as their data sources. - * Better configuration tools. - * InnoDB status information is merged into SHOW VARIABLES and - SHOW STATUS information, so you can access it all together. - * High-precision time support in more places. - * Lots of tweaks to make things display more readably and compactly. - * Column transformations and filters. - -2007-01-16: version 1.0.1 - * NOTE: innotop is now hosted at Sourceforge, in Subversion not CVS. - The new project homepage is http://sourceforge.net/projects/innotop/ - * Tweak default T/Q mode sort columns to match what people expect. - * Fix broken InnoDBParser.pm documentation (and hence man page). - -2007-01-06: version 1.0 - * NOTE: innotop is now hosted at Sourceforge, in Subversion not CVS. - The new project homepage is http://sourceforge.net/projects/innotop/ - * Prevent control characters from freaking terminal out. - * Set timeout to keep busy servers from closing connection. - * There is only one InnoDB insert buffer. - * Make licenses clear and consistent. - -2006-11-14: innotop 0.1.160, InnoDBParser version 1.69 - * Support for ANSI color on Microsoft Windows (more readable, compact - display; thanks Gisbert W. Selke). - * Better handling of $ENV{HOME} on Windows. - * Added a LICENSE file to the package as per Gentoo bug: - http://bugs.gentoo.org/show_bug.cgi?id=147600 - -2006-11-11: innotop 0.1.157, InnoDBParser version 1.69 - * Add Microsoft Windows support. - -2006-10-19: innotop 0.1.154, InnoDBParser version 1.69 - * Add O (Open Tables) mode - * Add some more checks to handle incomplete InnoDB status information - -2006-09-30: innotop 0.1.152, InnoDBParser version 1.69 - * Figured out what was wrong with package $VERSION variable: it wasn't - after the package declaration! - -2006-09-28: innotop 0.1.152, InnoDBParser version 1.67 - * Make more efforts towards crash-resistance and tolerance of completely - messed-up inputs. If innotop itself is broken, it is now much harder to - tell, because it just keeps on running without complaining. - * Fix a small bug parsing out some information and displaying it. - -2006-09-05: innotop 0.1.149, InnoDBParser version 1.64 - * Try to find and eliminate any parsing code that assumes pattern matches - will succeed. - -2006-09-05: innotop 0.1.149, InnoDBParser version 1.62 - * Make innotop crash-resistant, so I can declare it STABLE finally. - * Instead of using SQL conditional comments, detect MySQL version. - -2006-08-22: innotop 0.1.147, InnoDBParser version 1.60 - * Fix some innotop bugs with undefined values, bad formatting etc. - -2006-08-19: innotop 0.1.146, InnoDBParser version 1.60 - * Make innotop handle some unexpected NULL values in Q mode. - * Add OS wait information to W mode, so it is now "everything that waits." - * Center section captions better. - * Make R mode more readable and compact. - * Make InnoDBParser parse lock waits even when they've been waiting 0 secs. - -2006-08-12: innotop 0.1.139, InnoDBParser version 1.59 - * Add more documentation - * Tweak V mode to show more info in less space. - * Fix a bug in G mode. - -2006-08-10: innotop 0.1.132, InnoDBParser version 1.58 - * Handle yet more types of FK error... it will never end! - * Handle some special cases when DEADLOCK info truncated - * Add a bit more FK info to F mode in innotop - * More tests added to the test suite - -2006-08-07: innotop 0.1.131, InnoDBParser version 1.55 - * Fix another issue with configuration - * Handle another type of FK error - -2006-08-03: innotop 0.1.130, InnoDBParser version 1.54 - * Fix an issue loading config file - * Add heap_no to 'D' (InnoDB Deadlock) mode to ease deadlock debugging. - -2006-08-02: innotop 0.1.128, InnoDBParser version 1.54 - * Parse lock wait information from the TRANSACTION section. - * Even more OS-specific parsing... pain in the butt... - * Add 'W' (InnoDB Lock Wait) mode. - * Fix some minor display issues with statusbar. - -2006-08-02: innotop 0.1.125, InnoDBParser version 1.50 - * Don't try to get references to Perl built-in functions like time() - * Handle more OS-specific variations of InnoDB status text - * Add some more information to various places in innotop - -2006-08-01: innotop 0.1.123, InnoDBParser version 1.47 - - * Enhance S and G modes: clear screen and re-print headers - * Don't crash when deadlock data is truncated - * Make Analyze mode say how to get back to whatever you came from - * Display 'nothing to display' when there is nothing - * Add ability to read InnoDB status text from a file (mostly helps test) - * Add table of Wait Array Information in Row Op/Semaphore mode - * Add table of lock information in InnoDB deadlock mode - * Ensure new features in upgrades don't get masked by existing config files - * Tweak default column choices for T mode - * Enhance foreign key parsing - * Enhance physical record and data tuple parsing - * Enhance lock parsing (handle old-style and new-style formats) - -2006-07-24: innotop 0.1.112, InnoDBParser version 1.36 - - * InnoDBParser enhancements for FK error messages. - * A fix to innotop to prevent it from crashing while trying to display a FK - error message. - * Some minor cosmetic changes to number formatting in innotop. - -2006-07-22: innotop 0.1.106, InnoDBParser version 1.35 - - * InnoDBParser is much more complete and accurate. - * Tons of bug fixes. - * Add partitions to EXPLAIN mode. - * Enhance Q mode header, add T mode header. - * Share some configuration variables across modes. - * Add formatted time columns to Q, T modes. - * Add command-line argument parsing. - * Turn off echo when asking for password. - * Add option to specify port when connecting. - * Let display-optimized-query display multiple notes. - * Lots of small improvements, such as showing more info in statusbar. - -2006-07-02: innotop 0.1.74, InnoDBParser version 1.24 - - * Initial release for public consumption. diff --git a/storage/xtradb/build/debian/additions/innotop/innotop b/storage/xtradb/build/debian/additions/innotop/innotop deleted file mode 100644 index e2bfc1bd965..00000000000 --- a/storage/xtradb/build/debian/additions/innotop/innotop +++ /dev/null @@ -1,9485 +0,0 @@ -#!/usr/bin/perl - -# vim: tw=160:nowrap:expandtab:tabstop=3:shiftwidth=3:softtabstop=3 - -use strict; -use warnings FATAL => 'all'; -use sigtrap qw(handler finish untrapped normal-signals); - -use Data::Dumper; -use DBI; -use English qw(-no_match_vars); -use File::Basename qw(dirname); -use Getopt::Long; -use List::Util qw(max min maxstr sum); -use InnoDBParser; -use POSIX qw(ceil); -use Time::HiRes qw(time sleep); -use Term::ReadKey qw(ReadMode ReadKey); - -# Version, license and warranty information. {{{1 -# ########################################################################### -our $VERSION = '1.6.0'; -our $SVN_REV = sprintf("%d", q$Revision: 383 $ =~ m/(\d+)/g); -our $SVN_URL = sprintf("%s", q$URL: https://innotop.svn.sourceforge.net/svnroot/innotop/trunk/innotop $ =~ m$svnroot/innotop/(\S+)$g); - -my $innotop_license = <<"LICENSE"; - -This is innotop version $VERSION, a MySQL and InnoDB monitor. - -This program is copyright (c) 2006 Baron Schwartz. -Feedback and improvements are welcome. - -THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - -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; OR the Perl Artistic License. On UNIX and similar -systems, you can issue `man perlgpl' or `man perlartistic' to read these -licenses. - -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., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA. -LICENSE - -# Configuration information and global setup {{{1 -# ########################################################################### - -# Really, really, super-global variables. -my @config_versions = ( - "000-000-000", "001-003-000", # config file was one big name-value hash. - "001-003-000", "001-004-002", # config file contained non-user-defined stuff. -); - -my $clear_screen_sub; - -# This defines expected properties and defaults for the column definitions that -# eventually end up in tbl_meta. -my %col_props = ( - hdr => '', - just => '-', - dec => 0, # Whether to align the column on the decimal point - num => 0, - label => '', - user => 0, - src => '', - tbl => '', # Helps when writing/reading custom columns in config files - minw => 0, - maxw => 0, - trans => [], - agg => 'first', # Aggregate function - aggonly => 0, # Whether to show only when tbl_meta->{aggregate} is true -); - -# Actual DBI connections to MySQL servers. -my %dbhs; - -# Command-line parameters {{{2 -# ########################################################################### - -my @opt_spec = ( - { s => 'help', d => 'Show this help message' }, - { s => 'color|C!', d => 'Use terminal coloring (default)', c => 'color' }, - { s => 'config|c=s', d => 'Config file to read' }, - { s => 'nonint|n', d => 'Non-interactive, output tab-separated fields' }, - { s => 'count=i', d => 'Number of updates before exiting' }, - { s => 'delay|d=f', d => 'Delay between updates in seconds', c => 'interval' }, - { s => 'mode|m=s', d => 'Operating mode to start in', c => 'mode' }, - { s => 'inc|i!', d => 'Measure incremental differences', c => 'status_inc' }, - { s => 'version', d => 'Output version information and exit' }, -); - -# This is the container for the command-line options' values to be stored in -# after processing. Initial values are defaults. -my %opts = ( - n => !( -t STDIN && -t STDOUT ), # If in/out aren't to terminals, we're interactive -); -# Post-process... -my %opt_seen; -foreach my $spec ( @opt_spec ) { - my ( $long, $short ) = $spec->{s} =~ m/^(\w+)(?:\|([^!+=]*))?/; - $spec->{k} = $short || $long; - $spec->{l} = $long; - $spec->{t} = $short; - $spec->{n} = $spec->{s} =~ m/!/; - $opts{$spec->{k}} = undef unless defined $opts{$spec->{k}}; - die "Duplicate option $spec->{k}" if $opt_seen{$spec->{k}}++; -} - -Getopt::Long::Configure('no_ignore_case', 'bundling'); -GetOptions( map { $_->{s} => \$opts{$_->{k}} } @opt_spec) or $opts{help} = 1; - -if ( $opts{version} ) { - print "innotop Ver $VERSION Changeset $SVN_REV from $SVN_URL\n"; - exit(0); -} - -if ( $opts{'help'} ) { - print "Usage: innotop \n\n"; - my $maxw = max(map { length($_->{l}) + ($_->{n} ? 4 : 0)} @opt_spec); - foreach my $spec ( sort { $a->{l} cmp $b->{l} } @opt_spec ) { - my $long = $spec->{n} ? "[no]$spec->{l}" : $spec->{l}; - my $short = $spec->{t} ? "-$spec->{t}" : ''; - printf(" --%-${maxw}s %-4s %s\n", $long, $short, $spec->{d}); - } - print < q{my $host = host || hostname || ''; ($host) = $host =~ m/^((?:[\d.]+(?=:))|(?:[a-zA-Z]\w+))/; return $host || ''}, - Port => q{my ($p) = host =~ m/:(.*)$/; return $p || 0}, - OldVersions => q{dulint_to_int(IB_tx_trx_id_counter) - dulint_to_int(IB_tx_purge_done_for)}, - MaxTxnTime => q/max(map{ $_->{active_secs} } @{ IB_tx_transactions }) || 0/, - NumTxns => q{scalar @{ IB_tx_transactions } }, - DirtyBufs => q{ $cur->{IB_bp_pages_modified} / ($cur->{IB_bp_buf_pool_size} || 1) }, - BufPoolFill => q{ $cur->{IB_bp_pages_total} / ($cur->{IB_bp_buf_pool_size} || 1) }, - ServerLoad => q{ $cur->{Threads_connected}/(Questions||1)/Uptime_hires }, - TxnTimeRemain => q{ defined undo_log_entries && defined $pre->{undo_log_entries} && undo_log_entries < $pre->{undo_log_entries} ? undo_log_entries / (($pre->{undo_log_entries} - undo_log_entries)/((active_secs-$pre->{active_secs})||1))||1 : 0}, - SlaveCatchupRate => ' defined $cur->{seconds_behind_master} && defined $pre->{seconds_behind_master} && $cur->{seconds_behind_master} < $pre->{seconds_behind_master} ? ($pre->{seconds_behind_master}-$cur->{seconds_behind_master})/($cur->{Uptime_hires}-$pre->{Uptime_hires}) : 0', - QcacheHitRatio => q{(Qcache_hits||0)/(((Com_select||0)+(Qcache_hits||0))||1)}, -); - -# ########################################################################### -# Column definitions {{{3 -# Defines every column in every table. A named column has the following -# properties: -# * hdr Column header/title -# * label Documentation for humans. -# * num Whether it's numeric (for sorting). -# * just Alignment; generated from num, user-overridable in tbl_meta -# * minw, maxw Auto-generated, user-overridable. -# Values from this hash are just copied to tbl_meta, which is where everything -# else in the program should read from. -# ########################################################################### - -my %columns = ( - active_secs => { hdr => 'SecsActive', num => 1, label => 'Seconds transaction has been active', }, - add_pool_alloc => { hdr => 'Add\'l Pool', num => 1, label => 'Additonal pool allocated' }, - attempted_op => { hdr => 'Action', num => 0, label => 'The action that caused the error' }, - awe_mem_alloc => { hdr => 'AWE Memory', num => 1, label => '[Windows] AWE memory allocated' }, - binlog_cache_overflow => { hdr => 'Binlog Cache', num => 1, label => 'Transactions too big for binlog cache that went to disk' }, - binlog_do_db => { hdr => 'Binlog Do DB', num => 0, label => 'binlog-do-db setting' }, - binlog_ignore_db => { hdr => 'Binlog Ignore DB', num => 0, label => 'binlog-ignore-db setting' }, - bps_in => { hdr => 'BpsIn', num => 1, label => 'Bytes per second received by the server', }, - bps_out => { hdr => 'BpsOut', num => 1, label => 'Bytes per second sent by the server', }, - buf_free => { hdr => 'Free Bufs', num => 1, label => 'Buffers free in the buffer pool' }, - buf_pool_hit_rate => { hdr => 'Hit Rate', num => 0, label => 'Buffer pool hit rate' }, - buf_pool_hits => { hdr => 'Hits', num => 1, label => 'Buffer pool hits' }, - buf_pool_reads => { hdr => 'Reads', num => 1, label => 'Buffer pool reads' }, - buf_pool_size => { hdr => 'Size', num => 1, label => 'Buffer pool size' }, - bufs_in_node_heap => { hdr => 'Node Heap Bufs', num => 1, label => 'Buffers in buffer pool node heap' }, - bytes_behind_master => { hdr => 'ByteLag', num => 1, label => 'Bytes the slave lags the master in binlog' }, - cell_event_set => { hdr => 'Ending?', num => 1, label => 'Whether the cell event is set' }, - cell_waiting => { hdr => 'Waiting?', num => 1, label => 'Whether the cell is waiting' }, - child_db => { hdr => 'Child DB', num => 0, label => 'The database of the child table' }, - child_index => { hdr => 'Child Index', num => 0, label => 'The index in the child table' }, - child_table => { hdr => 'Child Table', num => 0, label => 'The child table' }, - cmd => { hdr => 'Cmd', num => 0, label => 'Type of command being executed', }, - cnt => { hdr => 'Cnt', num => 0, label => 'Count', agg => 'count', aggonly => 1 }, - connect_retry => { hdr => 'Connect Retry', num => 1, label => 'Slave connect-retry timeout' }, - cxn => { hdr => 'CXN', num => 0, label => 'Connection from which the data came', }, - db => { hdr => 'DB', num => 0, label => 'Current database', }, - dict_mem_alloc => { hdr => 'Dict Mem', num => 1, label => 'Dictionary memory allocated' }, - dirty_bufs => { hdr => 'Dirty Buf', num => 1, label => 'Dirty buffer pool pages' }, - dl_txn_num => { hdr => 'Num', num => 0, label => 'Deadlocked transaction number', }, - event_set => { hdr => 'Evt Set?', num => 1, label => '[Win32] if a wait event is set', }, - exec_master_log_pos => { hdr => 'Exec Master Log Pos', num => 1, label => 'Exec Master Log Position' }, - fk_name => { hdr => 'Constraint', num => 0, label => 'The name of the FK constraint' }, - free_list_len => { hdr => 'Free List Len', num => 1, label => 'Length of the free list' }, - has_read_view => { hdr => 'Rd View', num => 1, label => 'Whether the transaction has a read view' }, - hash_searches_s => { hdr => 'Hash/Sec', num => 1, label => 'Number of hash searches/sec' }, - hash_table_size => { hdr => 'Size', num => 1, label => 'Number of non-hash searches/sec' }, - heap_no => { hdr => 'Heap', num => 1, label => 'Heap number' }, - heap_size => { hdr => 'Heap', num => 1, label => 'Heap size' }, - history_list_len => { hdr => 'History', num => 1, label => 'History list length' }, - host_and_domain => { hdr => 'Host', num => 0, label => 'Hostname/IP and domain' }, - host_and_port => { hdr => 'Host/IP', num => 0, label => 'Hostname or IP address, and port number', }, - hostname => { hdr => 'Host', num => 0, label => 'Hostname' }, - index => { hdr => 'Index', num => 0, label => 'The index involved' }, - index_ref => { hdr => 'Index Ref', num => 0, label => 'Index referenced' }, - info => { hdr => 'Query', num => 0, label => 'Info or the current query', }, - insert_intention => { hdr => 'Ins Intent', num => 1, label => 'Whether the thread was trying to insert' }, - inserts => { hdr => 'Inserts', num => 1, label => 'Inserts' }, - io_bytes_s => { hdr => 'Bytes/Sec', num => 1, label => 'Average I/O bytes/sec' }, - io_flush_type => { hdr => 'Flush Type', num => 0, label => 'I/O Flush Type' }, - io_fsyncs_s => { hdr => 'fsyncs/sec', num => 1, label => 'I/O fsyncs/sec' }, - io_reads_s => { hdr => 'Reads/Sec', num => 1, label => 'Average I/O reads/sec' }, - io_writes_s => { hdr => 'Writes/Sec', num => 1, label => 'Average I/O writes/sec' }, - ip => { hdr => 'IP', num => 0, label => 'IP address' }, - is_name_locked => { hdr => 'Locked', num => 1, label => 'Whether table is name locked', }, - key_buffer_hit => { hdr => 'KCacheHit', num => 1, label => 'Key cache hit ratio', }, - key_len => { hdr => 'Key Length', num => 1, label => 'Number of bytes used in the key' }, - last_chkp => { hdr => 'Last Checkpoint', num => 0, label => 'Last log checkpoint' }, - last_errno => { hdr => 'Last Errno', num => 1, label => 'Last error number' }, - last_error => { hdr => 'Last Error', num => 0, label => 'Last error' }, - last_s_file_name => { hdr => 'S-File', num => 0, label => 'Filename where last read locked' }, - last_s_line => { hdr => 'S-Line', num => 1, label => 'Line where last read locked' }, - last_x_file_name => { hdr => 'X-File', num => 0, label => 'Filename where last write locked' }, - last_x_line => { hdr => 'X-Line', num => 1, label => 'Line where last write locked' }, - last_pct => { hdr => 'Pct', num => 1, label => 'Last Percentage' }, - last_total => { hdr => 'Last Total', num => 1, label => 'Last Total' }, - last_value => { hdr => 'Last Incr', num => 1, label => 'Last Value' }, - load => { hdr => 'Load', num => 1, label => 'Server load' }, - lock_cfile_name => { hdr => 'Crtd File', num => 0, label => 'Filename where lock created' }, - lock_cline => { hdr => 'Crtd Line', num => 1, label => 'Line where lock created' }, - lock_mem_addr => { hdr => 'Addr', num => 0, label => 'The lock memory address' }, - lock_mode => { hdr => 'Mode', num => 0, label => 'The lock mode' }, - lock_structs => { hdr => 'LStrcts', num => 1, label => 'Number of lock structs' }, - lock_type => { hdr => 'Type', num => 0, label => 'The lock type' }, - lock_var => { hdr => 'Lck Var', num => 1, label => 'The lock variable' }, - lock_wait_time => { hdr => 'Wait', num => 1, label => 'How long txn has waited for a lock' }, - log_flushed_to => { hdr => 'Flushed To', num => 0, label => 'Log position flushed to' }, - log_ios_done => { hdr => 'IO Done', num => 1, label => 'Log I/Os done' }, - log_ios_s => { hdr => 'IO/Sec', num => 1, label => 'Average log I/Os per sec' }, - log_seq_no => { hdr => 'Sequence No.', num => 0, label => 'Log sequence number' }, - main_thread_id => { hdr => 'Main Thread ID', num => 1, label => 'Main thread ID' }, - main_thread_proc_no => { hdr => 'Main Thread Proc', num => 1, label => 'Main thread process number' }, - main_thread_state => { hdr => 'Main Thread State', num => 0, label => 'Main thread state' }, - master_file => { hdr => 'File', num => 0, label => 'Master file' }, - master_host => { hdr => 'Master', num => 0, label => 'Master server hostname' }, - master_log_file => { hdr => 'Master Log File', num => 0, label => 'Master log file' }, - master_port => { hdr => 'Master Port', num => 1, label => 'Master port' }, - master_pos => { hdr => 'Position', num => 1, label => 'Master position' }, - master_ssl_allowed => { hdr => 'Master SSL Allowed', num => 0, label => 'Master SSL Allowed' }, - master_ssl_ca_file => { hdr => 'Master SSL CA File', num => 0, label => 'Master SSL Cert Auth File' }, - master_ssl_ca_path => { hdr => 'Master SSL CA Path', num => 0, label => 'Master SSL Cert Auth Path' }, - master_ssl_cert => { hdr => 'Master SSL Cert', num => 0, label => 'Master SSL Cert' }, - master_ssl_cipher => { hdr => 'Master SSL Cipher', num => 0, label => 'Master SSL Cipher' }, - master_ssl_key => { hdr => 'Master SSL Key', num => 0, label => 'Master SSL Key' }, - master_user => { hdr => 'Master User', num => 0, label => 'Master username' }, - max_txn => { hdr => 'MaxTxnTime', num => 1, label => 'MaxTxn' }, - merged_recs => { hdr => 'Merged Recs', num => 1, label => 'Merged records' }, - merges => { hdr => 'Merges', num => 1, label => 'Merges' }, - mutex_os_waits => { hdr => 'Waits', num => 1, label => 'Mutex OS Waits' }, - mutex_spin_rounds => { hdr => 'Rounds', num => 1, label => 'Mutex Spin Rounds' }, - mutex_spin_waits => { hdr => 'Spins', num => 1, label => 'Mutex Spin Waits' }, - mysql_thread_id => { hdr => 'ID', num => 1, label => 'MySQL connection (thread) ID', }, - name => { hdr => 'Name', num => 0, label => 'Variable Name' }, - n_bits => { hdr => '# Bits', num => 1, label => 'Number of bits' }, - non_hash_searches_s => { hdr => 'Non-Hash/Sec', num => 1, label => 'Non-hash searches/sec' }, - num_deletes => { hdr => 'Del', num => 1, label => 'Number of deletes' }, - num_deletes_sec => { hdr => 'Del/Sec', num => 1, label => 'Number of deletes' }, - num_inserts => { hdr => 'Ins', num => 1, label => 'Number of inserts' }, - num_inserts_sec => { hdr => 'Ins/Sec', num => 1, label => 'Number of inserts' }, - num_readers => { hdr => 'Readers', num => 1, label => 'Number of readers' }, - num_reads => { hdr => 'Read', num => 1, label => 'Number of reads' }, - num_reads_sec => { hdr => 'Read/Sec', num => 1, label => 'Number of reads' }, - num_res_ext => { hdr => 'BTree Extents', num => 1, label => 'Number of extents reserved for B-Tree' }, - num_rows => { hdr => 'Row Count', num => 1, label => 'Number of rows estimated to examine' }, - num_times_open => { hdr => 'In Use', num => 1, label => '# times table is opened', }, - num_txns => { hdr => 'Txns', num => 1, label => 'Number of transactions' }, - num_updates => { hdr => 'Upd', num => 1, label => 'Number of updates' }, - num_updates_sec => { hdr => 'Upd/Sec', num => 1, label => 'Number of updates' }, - os_file_reads => { hdr => 'OS Reads', num => 1, label => 'OS file reads' }, - os_file_writes => { hdr => 'OS Writes', num => 1, label => 'OS file writes' }, - os_fsyncs => { hdr => 'OS fsyncs', num => 1, label => 'OS fsyncs' }, - os_thread_id => { hdr => 'OS Thread', num => 1, label => 'The operating system thread ID' }, - p_aio_writes => { hdr => 'Async Wrt', num => 1, label => 'Pending asynchronous I/O writes' }, - p_buf_pool_flushes => { hdr => 'Buffer Pool Flushes', num => 1, label => 'Pending buffer pool flushes' }, - p_ibuf_aio_reads => { hdr => 'IBuf Async Rds', num => 1, label => 'Pending insert buffer asynch I/O reads' }, - p_log_flushes => { hdr => 'Log Flushes', num => 1, label => 'Pending log flushes' }, - p_log_ios => { hdr => 'Log I/Os', num => 1, label => 'Pending log I/O operations' }, - p_normal_aio_reads => { hdr => 'Async Rds', num => 1, label => 'Pending asynchronous I/O reads' }, - p_preads => { hdr => 'preads', num => 1, label => 'Pending p-reads' }, - p_pwrites => { hdr => 'pwrites', num => 1, label => 'Pending p-writes' }, - p_sync_ios => { hdr => 'Sync I/Os', num => 1, label => 'Pending synchronous I/O operations' }, - page_creates_sec => { hdr => 'Creates/Sec', num => 1, label => 'Page creates/sec' }, - page_no => { hdr => 'Page', num => 1, label => 'Page number' }, - page_reads_sec => { hdr => 'Reads/Sec', num => 1, label => 'Page reads per second' }, - page_writes_sec => { hdr => 'Writes/Sec', num => 1, label => 'Page writes per second' }, - pages_created => { hdr => 'Created', num => 1, label => 'Pages created' }, - pages_modified => { hdr => 'Dirty Pages', num => 1, label => 'Pages modified (dirty)' }, - pages_read => { hdr => 'Reads', num => 1, label => 'Pages read' }, - pages_total => { hdr => 'Pages', num => 1, label => 'Pages total' }, - pages_written => { hdr => 'Writes', num => 1, label => 'Pages written' }, - parent_col => { hdr => 'Parent Column', num => 0, label => 'The referred column in the parent table', }, - parent_db => { hdr => 'Parent DB', num => 0, label => 'The database of the parent table' }, - parent_index => { hdr => 'Parent Index', num => 0, label => 'The referred index in the parent table' }, - parent_table => { hdr => 'Parent Table', num => 0, label => 'The parent table' }, - part_id => { hdr => 'Part ID', num => 1, label => 'Sub-part ID of the query' }, - partitions => { hdr => 'Partitions', num => 0, label => 'Query partitions used' }, - pct => { hdr => 'Pct', num => 1, label => 'Percentage' }, - pending_chkp_writes => { hdr => 'Chkpt Writes', num => 1, label => 'Pending log checkpoint writes' }, - pending_log_writes => { hdr => 'Log Writes', num => 1, label => 'Pending log writes' }, - port => { hdr => 'Port', num => 1, label => 'Client port number', }, - possible_keys => { hdr => 'Poss. Keys', num => 0, label => 'Possible keys' }, - proc_no => { hdr => 'Proc', num => 1, label => 'Process number' }, - q_cache_hit => { hdr => 'QCacheHit', num => 1, label => 'Query cache hit ratio', }, - qps => { hdr => 'QPS', num => 1, label => 'How many queries/sec', }, - queries_in_queue => { hdr => 'Queries Queued', num => 1, label => 'Queries in queue' }, - queries_inside => { hdr => 'Queries Inside', num => 1, label => 'Queries inside InnoDB' }, - query_id => { hdr => 'Query ID', num => 1, label => 'Query ID' }, - query_status => { hdr => 'Query Status', num => 0, label => 'The query status' }, - query_text => { hdr => 'Query Text', num => 0, label => 'The query text' }, - questions => { hdr => 'Questions', num => 1, label => 'How many queries the server has gotten', }, - read_master_log_pos => { hdr => 'Read Master Pos', num => 1, label => 'Read master log position' }, - read_views_open => { hdr => 'Rd Views', num => 1, label => 'Number of read views open' }, - reads_pending => { hdr => 'Pending Reads', num => 1, label => 'Reads pending' }, - relay_log_file => { hdr => 'Relay File', num => 0, label => 'Relay log file' }, - relay_log_pos => { hdr => 'Relay Pos', num => 1, label => 'Relay log position' }, - relay_log_size => { hdr => 'Relay Size', num => 1, label => 'Relay log size' }, - relay_master_log_file => { hdr => 'Relay Master File', num => 0, label => 'Relay master log file' }, - replicate_do_db => { hdr => 'Do DB', num => 0, label => 'Replicate-do-db setting' }, - replicate_do_table => { hdr => 'Do Table', num => 0, label => 'Replicate-do-table setting' }, - replicate_ignore_db => { hdr => 'Ignore DB', num => 0, label => 'Replicate-ignore-db setting' }, - replicate_ignore_table => { hdr => 'Ignore Table', num => 0, label => 'Replicate-do-table setting' }, - replicate_wild_do_table => { hdr => 'Wild Do Table', num => 0, label => 'Replicate-wild-do-table setting' }, - replicate_wild_ignore_table => { hdr => 'Wild Ignore Table', num => 0, label => 'Replicate-wild-ignore-table setting' }, - request_type => { hdr => 'Type', num => 0, label => 'Type of lock the thread waits for' }, - reservation_count => { hdr => 'ResCnt', num => 1, label => 'Reservation Count' }, - row_locks => { hdr => 'RLocks', num => 1, label => 'Number of row locks' }, - rw_excl_os_waits => { hdr => 'RW Waits', num => 1, label => 'R/W Excl. OS Waits' }, - rw_excl_spins => { hdr => 'RW Spins', num => 1, label => 'R/W Excl. Spins' }, - rw_shared_os_waits => { hdr => 'Sh Waits', num => 1, label => 'R/W Shared OS Waits' }, - rw_shared_spins => { hdr => 'Sh Spins', num => 1, label => 'R/W Shared Spins' }, - scan_type => { hdr => 'Type', num => 0, label => 'Scan type in chosen' }, - seg_size => { hdr => 'Seg. Size', num => 1, label => 'Segment size' }, - select_type => { hdr => 'Select Type', num => 0, label => 'Type of select used' }, - signal_count => { hdr => 'Signals', num => 1, label => 'Signal Count' }, - size => { hdr => 'Size', num => 1, label => 'Size of the tablespace' }, - skip_counter => { hdr => 'Skip Counter', num => 1, label => 'Skip counter' }, - slave_catchup_rate => { hdr => 'Catchup', num => 1, label => 'How fast the slave is catching up in the binlog' }, - slave_io_running => { hdr => 'Slave-IO', num => 0, label => 'Whether the slave I/O thread is running' }, - slave_io_state => { hdr => 'Slave IO State', num => 0, label => 'Slave I/O thread state' }, - slave_open_temp_tables => { hdr => 'Temp', num => 1, label => 'Slave open temp tables' }, - slave_sql_running => { hdr => 'Slave-SQL', num => 0, label => 'Whether the slave SQL thread is running' }, - slow => { hdr => 'Slow', num => 1, label => 'How many slow queries', }, - space_id => { hdr => 'Space', num => 1, label => 'Tablespace ID' }, - special => { hdr => 'Special', num => 0, label => 'Special/Other info' }, - state => { hdr => 'State', num => 0, label => 'Connection state', maxw => 18, }, - tables_in_use => { hdr => 'Tbl Used', num => 1, label => 'Number of tables in use' }, - tables_locked => { hdr => 'Tbl Lck', num => 1, label => 'Number of tables locked' }, - tbl => { hdr => 'Table', num => 0, label => 'Table', }, - thread => { hdr => 'Thread', num => 1, label => 'Thread number' }, - thread_decl_inside => { hdr => 'Thread Inside', num => 0, label => 'What the thread is declared inside' }, - thread_purpose => { hdr => 'Purpose', num => 0, label => "The thread's purpose" }, - thread_status => { hdr => 'Thread Status', num => 0, label => 'The thread status' }, - time => { hdr => 'Time', num => 1, label => 'Time since the last event', }, - time_behind_master => { hdr => 'TimeLag', num => 1, label => 'Time slave lags master' }, - timestring => { hdr => 'Timestring', num => 0, label => 'Time the event occurred' }, - total => { hdr => 'Total', num => 1, label => 'Total' }, - total_mem_alloc => { hdr => 'Memory', num => 1, label => 'Total memory allocated' }, - truncates => { hdr => 'Trunc', num => 0, label => 'Whether the deadlock is truncating InnoDB status' }, - txn_doesnt_see_ge => { hdr => "Txn Won't See", num => 0, label => 'Where txn read view is limited' }, - txn_id => { hdr => 'ID', num => 0, label => 'Transaction ID' }, - txn_sees_lt => { hdr => 'Txn Sees', num => 1, label => 'Where txn read view is limited' }, - txn_status => { hdr => 'Txn Status', num => 0, label => 'Transaction status' }, - txn_time_remain => { hdr => 'Remaining', num => 1, label => 'Time until txn rollback/commit completes' }, - undo_log_entries => { hdr => 'Undo', num => 1, label => 'Number of undo log entries' }, - undo_for => { hdr => 'Undo', num => 0, label => 'Undo for' }, - until_condition => { hdr => 'Until Condition', num => 0, label => 'Slave until condition' }, - until_log_file => { hdr => 'Until Log File', num => 0, label => 'Slave until log file' }, - until_log_pos => { hdr => 'Until Log Pos', num => 1, label => 'Slave until log position' }, - used_cells => { hdr => 'Cells Used', num => 1, label => 'Number of cells used' }, - used_bufs => { hdr => 'Used Bufs', num => 1, label => 'Number of buffer pool pages used' }, - user => { hdr => 'User', num => 0, label => 'Database username', }, - value => { hdr => 'Value', num => 1, label => 'Value' }, - versions => { hdr => 'Versions', num => 1, label => 'Number of InnoDB MVCC versions unpurged' }, - victim => { hdr => 'Victim', num => 0, label => 'Whether this txn was the deadlock victim' }, - wait_array_size => { hdr => 'Wait Array Size', num => 1, label => 'Wait Array Size' }, - wait_status => { hdr => 'Lock Status', num => 0, label => 'Status of txn locks' }, - waited_at_filename => { hdr => 'File', num => 0, label => 'Filename at which thread waits' }, - waited_at_line => { hdr => 'Line', num => 1, label => 'Line at which thread waits' }, - waiters_flag => { hdr => 'Waiters', num => 1, label => 'Waiters Flag' }, - waiting => { hdr => 'Waiting', num => 1, label => 'Whether lock is being waited for' }, - when => { hdr => 'When', num => 0, label => 'Time scale' }, - writer_lock_mode => { hdr => 'Wrtr Lck Mode', num => 0, label => 'Writer lock mode' }, - writer_thread => { hdr => 'Wrtr Thread', num => 1, label => 'Writer thread ID' }, - writes_pending => { hdr => 'Writes', num => 1, label => 'Number of writes pending' }, - writes_pending_flush_list => { hdr => 'Flush List Writes', num => 1, label => 'Number of flush list writes pending' }, - writes_pending_lru => { hdr => 'LRU Writes', num => 1, label => 'Number of LRU writes pending' }, - writes_pending_single_page => { hdr => '1-Page Writes', num => 1, label => 'Number of 1-page writes pending' }, -); - -# Apply a default property or three. By default, columns are not width-constrained, -# aligned left, and sorted alphabetically, not numerically. -foreach my $col ( values %columns ) { - map { $col->{$_} ||= 0 } qw(num minw maxw); - $col->{just} = $col->{num} ? '' : '-'; -} - -# Filters {{{3 -# This hash defines every filter that can be applied to a table. These -# become part of tbl_meta as well. Each filter is just an expression that -# returns true or false. -# Properties of each entry: -# * func: the subroutine -# * name: the name, repeated -# * user: whether it's a user-defined filter (saved in config) -# * text: text of the subroutine -# * note: explanation -my %filters = (); - -# These are pre-processed to live in %filters above, by compiling them. -my %builtin_filters = ( - hide_self => { - text => <<' END', - return ( !$set->{info} || $set->{info} ne 'SHOW FULL PROCESSLIST' ) - && ( !$set->{query_text} || $set->{query_text} !~ m/INNODB STATUS$/ ); - END - note => 'Removes the innotop processes from the list', - tbls => [qw(innodb_transactions processlist)], - }, - hide_inactive => { - text => <<' END', - return ( !defined($set->{txn_status}) || $set->{txn_status} ne 'not started' ) - && ( !defined($set->{cmd}) || $set->{cmd} !~ m/Sleep|Binlog Dump/ ) - && ( !defined($set->{info}) || $set->{info} =~ m/\S/ ); - END - note => 'Removes processes which are not doing anything', - tbls => [qw(innodb_transactions processlist)], - }, - hide_slave_io => { - text => <<' END', - return !$set->{state} || $set->{state} !~ m/^(?:Waiting for master|Has read all relay)/; - END - note => 'Removes slave I/O threads from the list', - tbls => [qw(processlist slave_io_status)], - }, - table_is_open => { - text => <<' END', - return $set->{num_times_open} + $set->{is_name_locked}; - END - note => 'Removes tables that are not in use or locked', - tbls => [qw(open_tables)], - }, - cxn_is_master => { - text => <<' END', - return $set->{master_file} ? 1 : 0; - END - note => 'Removes servers that are not masters', - tbls => [qw(master_status)], - }, - cxn_is_slave => { - text => <<' END', - return $set->{master_host} ? 1 : 0; - END - note => 'Removes servers that are not slaves', - tbls => [qw(slave_io_status slave_sql_status)], - }, - thd_is_not_waiting => { - text => <<' END', - return $set->{thread_status} !~ m#waiting for i/o request#; - END - note => 'Removes idle I/O threads', - tbls => [qw(io_threads)], - }, -); -foreach my $key ( keys %builtin_filters ) { - my ( $sub, $err ) = compile_filter($builtin_filters{$key}->{text}); - $filters{$key} = { - func => $sub, - text => $builtin_filters{$key}->{text}, - user => 0, - name => $key, # useful for later - note => $builtin_filters{$key}->{note}, - tbls => $builtin_filters{$key}->{tbls}, - } -} - -# Variable sets {{{3 -# Sets (arrayrefs) of variables that are used in S mode. They are read/written to -# the config file. -my %var_sets = ( - general => { - text => join( - ', ', - 'set_precision(Questions/Uptime_hires) as QPS', - 'set_precision(Com_commit/Uptime_hires) as Commit_PS', - 'set_precision((Com_rollback||0)/(Com_commit||1)) as Rollback_Commit', - 'set_precision((' - . join('+', map { "($_||0)" } - qw(Com_delete Com_delete_multi Com_insert Com_insert_select Com_replace - Com_replace_select Com_select Com_update Com_update_multi)) - . ')/(Com_commit||1)) as Write_Commit', - 'set_precision((Com_select+(Qcache_hits||0))/((' - . join('+', map { "($_||0)" } - qw(Com_delete Com_delete_multi Com_insert Com_insert_select Com_replace - Com_replace_select Com_select Com_update Com_update_multi)) - . ')||1)) as R_W_Ratio', - 'set_precision(Opened_tables/Uptime_hires) as Opens_PS', - 'percent($cur->{Open_tables}/($cur->{table_cache})) as Table_Cache_Used', - 'set_precision(Threads_created/Uptime_hires) as Threads_PS', - 'percent($cur->{Threads_cached}/($cur->{thread_cache_size}||1)) as Thread_Cache_Used', - 'percent($cur->{Max_used_connections}/($cur->{max_connections}||1)) as CXN_Used_Ever', - 'percent($cur->{Threads_connected}/($cur->{max_connections}||1)) as CXN_Used_Now', - ), - }, - commands => { - text => join( - ', ', - qw(Uptime Questions Com_delete Com_delete_multi Com_insert - Com_insert_select Com_replace Com_replace_select Com_select Com_update - Com_update_multi) - ), - }, - query_status => { - text => join( - ',', - qw( Uptime Select_full_join Select_full_range_join Select_range - Select_range_check Select_scan Slow_queries Sort_merge_passes - Sort_range Sort_rows Sort_scan) - ), - }, - innodb => { - text => join( - ',', - qw( Uptime Innodb_row_lock_current_waits Innodb_row_lock_time - Innodb_row_lock_time_avg Innodb_row_lock_time_max Innodb_row_lock_waits - Innodb_rows_deleted Innodb_rows_inserted Innodb_rows_read - Innodb_rows_updated) - ), - }, - txn => { - text => join( - ',', - qw( Uptime Com_begin Com_commit Com_rollback Com_savepoint - Com_xa_commit Com_xa_end Com_xa_prepare Com_xa_recover Com_xa_rollback - Com_xa_start) - ), - }, - key_cache => { - text => join( - ',', - qw( Uptime Key_blocks_not_flushed Key_blocks_unused Key_blocks_used - Key_read_requests Key_reads Key_write_requests Key_writes ) - ), - }, - query_cache => { - text => join( - ',', - "percent($exprs{QcacheHitRatio}) as Hit_Pct", - 'set_precision((Qcache_hits||0)/(Qcache_inserts||1)) as Hit_Ins', - 'set_precision((Qcache_lowmem_prunes||0)/Uptime_hires) as Lowmem_Prunes_sec', - 'percent(1-((Qcache_free_blocks||0)/(Qcache_total_blocks||1))) as Blocks_used', - qw( Qcache_free_blocks Qcache_free_memory Qcache_not_cached Qcache_queries_in_cache) - ), - }, - handler => { - text => join( - ',', - qw( Uptime Handler_read_key Handler_read_first Handler_read_next - Handler_read_prev Handler_read_rnd Handler_read_rnd_next Handler_delete - Handler_update Handler_write) - ), - }, - cxns_files_threads => { - text => join( - ',', - qw( Uptime Aborted_clients Aborted_connects Bytes_received Bytes_sent - Compression Connections Created_tmp_disk_tables Created_tmp_files - Created_tmp_tables Max_used_connections Open_files Open_streams - Open_tables Opened_tables Table_locks_immediate Table_locks_waited - Threads_cached Threads_connected Threads_created Threads_running) - ), - }, - prep_stmt => { - text => join( - ',', - qw( Uptime Com_dealloc_sql Com_execute_sql Com_prepare_sql Com_reset - Com_stmt_close Com_stmt_execute Com_stmt_fetch Com_stmt_prepare - Com_stmt_reset Com_stmt_send_long_data ) - ), - }, - innodb_health => { - text => join( - ',', - "$exprs{OldVersions} as OldVersions", - qw(IB_sm_mutex_spin_waits IB_sm_mutex_spin_rounds IB_sm_mutex_os_waits), - "$exprs{NumTxns} as NumTxns", - "$exprs{MaxTxnTime} as MaxTxnTime", - qw(IB_ro_queries_inside IB_ro_queries_in_queue), - "set_precision($exprs{DirtyBufs} * 100) as dirty_bufs", - "set_precision($exprs{BufPoolFill} * 100) as buf_fill", - qw(IB_bp_pages_total IB_bp_pages_read IB_bp_pages_written IB_bp_pages_created) - ), - }, - innodb_health2 => { - text => join( - ', ', - 'percent(1-((Innodb_buffer_pool_pages_free||0)/($cur->{Innodb_buffer_pool_pages_total}||1))) as BP_page_cache_usage', - 'percent(1-((Innodb_buffer_pool_reads||0)/(Innodb_buffer_pool_read_requests||1))) as BP_cache_hit_ratio', - 'Innodb_buffer_pool_wait_free', - 'Innodb_log_waits', - ), - }, - slow_queries => { - text => join( - ', ', - 'set_precision(Slow_queries/Uptime_hires) as Slow_PS', - 'set_precision(Select_full_join/Uptime_hires) as Full_Join_PS', - 'percent(Select_full_join/(Com_select||1)) as Full_Join_Ratio', - ), - }, -); - -# Server sets {{{3 -# Defines sets of servers between which the user can quickly switch. -my %server_groups; - -# Connections {{{3 -# This hash defines server connections. Each connection is a string that can be passed to -# the DBI connection. These are saved in the connections section in the config file. -my %connections; -# Defines the parts of connections. -my @conn_parts = qw(user have_user pass have_pass dsn savepass dl_table); - -# Graph widths {{{3 -# This hash defines the max values seen for various status/variable values, for graphing. -# These are stored in their own section in the config file. These are just initial values: -my %mvs = ( - Com_select => 50, - Com_insert => 50, - Com_update => 50, - Com_delete => 50, - Questions => 100, -); - -# ########################################################################### -# Valid Term::ANSIColor color strings. -# ########################################################################### -my %ansicolors = map { $_ => 1 } - qw( black blink blue bold clear concealed cyan dark green magenta on_black - on_blue on_cyan on_green on_magenta on_red on_white on_yellow red reset - reverse underline underscore white yellow); - -# ########################################################################### -# Valid comparison operators for color rules -# ########################################################################### -my %comp_ops = ( - '==' => 'Numeric equality', - '>' => 'Numeric greater-than', - '<' => 'Numeric less-than', - '>=' => 'Numeric greater-than/equal', - '<=' => 'Numeric less-than/equal', - '!=' => 'Numeric not-equal', - 'eq' => 'String equality', - 'gt' => 'String greater-than', - 'lt' => 'String less-than', - 'ge' => 'String greater-than/equal', - 'le' => 'String less-than/equal', - 'ne' => 'String not-equal', - '=~' => 'Pattern match', - '!~' => 'Negated pattern match', -); - -# ########################################################################### -# Valid aggregate functions. -# ########################################################################### -my %agg_funcs = ( - first => sub { - return $_[0] - }, - count => sub { - return 0 + @_; - }, - avg => sub { - my @args = grep { defined $_ } @_; - return (sum(map { m/([\d\.-]+)/g } @args) || 0) / (scalar(@args) || 1); - }, - sum => \&sum, -); - -# ########################################################################### -# Valid functions for transformations. -# ########################################################################### -my %trans_funcs = ( - shorten => \&shorten, - secs_to_time => \&secs_to_time, - no_ctrl_char => \&no_ctrl_char, - percent => \&percent, - commify => \&commify, - dulint_to_int => \&dulint_to_int, - set_precision => \&set_precision, -); - -# Table definitions {{{3 -# This hash defines every table that can get displayed in every mode. Each -# table specifies columns and column data sources. The column is -# defined by the %columns hash. -# -# Example: foo => { src => 'bar' } means the foo column (look at -# $columns{foo} for its definition) gets its data from the 'bar' element of -# the current data set, whatever that is. -# -# These columns are post-processed after being defined, because they get stuff -# from %columns. After all the config is loaded for columns, there's more -# post-processing too; the subroutines compiled from src get added to -# the hash elements for extract_values to use. -# ########################################################################### - -my %tbl_meta = ( - adaptive_hash_index => { - capt => 'Adaptive Hash Index', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - hash_table_size => { src => 'IB_ib_hash_table_size', trans => [qw(shorten)], }, - used_cells => { src => 'IB_ib_used_cells' }, - bufs_in_node_heap => { src => 'IB_ib_bufs_in_node_heap' }, - hash_searches_s => { src => 'IB_ib_hash_searches_s' }, - non_hash_searches_s => { src => 'IB_ib_non_hash_searches_s' }, - }, - visible => [ qw(cxn hash_table_size used_cells bufs_in_node_heap hash_searches_s non_hash_searches_s) ], - filters => [], - sort_cols => 'cxn', - sort_dir => '1', - innodb => 'ib', - group_by => [], - aggregate => 0, - }, - buffer_pool => { - capt => 'Buffer Pool', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - total_mem_alloc => { src => 'IB_bp_total_mem_alloc', trans => [qw(shorten)], }, - awe_mem_alloc => { src => 'IB_bp_awe_mem_alloc', trans => [qw(shorten)], }, - add_pool_alloc => { src => 'IB_bp_add_pool_alloc', trans => [qw(shorten)], }, - buf_pool_size => { src => 'IB_bp_buf_pool_size', trans => [qw(shorten)], }, - buf_free => { src => 'IB_bp_buf_free' }, - buf_pool_hit_rate => { src => 'IB_bp_buf_pool_hit_rate' }, - buf_pool_reads => { src => 'IB_bp_buf_pool_reads' }, - buf_pool_hits => { src => 'IB_bp_buf_pool_hits' }, - dict_mem_alloc => { src => 'IB_bp_dict_mem_alloc' }, - pages_total => { src => 'IB_bp_pages_total' }, - pages_modified => { src => 'IB_bp_pages_modified' }, - reads_pending => { src => 'IB_bp_reads_pending' }, - writes_pending => { src => 'IB_bp_writes_pending' }, - writes_pending_lru => { src => 'IB_bp_writes_pending_lru' }, - writes_pending_flush_list => { src => 'IB_bp_writes_pending_flush_list' }, - writes_pending_single_page => { src => 'IB_bp_writes_pending_single_page' }, - page_creates_sec => { src => 'IB_bp_page_creates_sec' }, - page_reads_sec => { src => 'IB_bp_page_reads_sec' }, - page_writes_sec => { src => 'IB_bp_page_writes_sec' }, - pages_created => { src => 'IB_bp_pages_created' }, - pages_read => { src => 'IB_bp_pages_read' }, - pages_written => { src => 'IB_bp_pages_written' }, - }, - visible => [ qw(cxn buf_pool_size buf_free pages_total pages_modified buf_pool_hit_rate total_mem_alloc add_pool_alloc)], - filters => [], - sort_cols => 'cxn', - sort_dir => '1', - innodb => 'bp', - group_by => [], - aggregate => 0, - }, - # TODO: a new step in set_to_tbl: join result to itself, grouped? - # TODO: this would also enable pulling Q and T data together. - # TODO: using a SQL-ish language would also allow pivots to be easier -- treat the pivoted data as a view and SELECT from it. - cmd_summary => { - capt => 'Command Summary', - cust => {}, - cols => { - name => { src => 'name' }, - total => { src => 'total' }, - value => { src => 'value', agg => 'sum'}, - pct => { src => 'value/total', trans => [qw(percent)] }, - last_total => { src => 'last_total' }, - last_value => { src => 'last_value', agg => 'sum'}, - last_pct => { src => 'last_value/last_total', trans => [qw(percent)] }, - }, - visible => [qw(name value pct last_value last_pct)], - filters => [qw()], - sort_cols => '-value', - sort_dir => '1', - innodb => '', - group_by => [qw(name)], - aggregate => 1, - }, - deadlock_locks => { - capt => 'Deadlock Locks', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - mysql_thread_id => { src => 'mysql_thread_id' }, - dl_txn_num => { src => 'dl_txn_num' }, - lock_type => { src => 'lock_type' }, - space_id => { src => 'space_id' }, - page_no => { src => 'page_no' }, - heap_no => { src => 'heap_no' }, - n_bits => { src => 'n_bits' }, - index => { src => 'index' }, - db => { src => 'db' }, - tbl => { src => 'table' }, - lock_mode => { src => 'lock_mode' }, - special => { src => 'special' }, - insert_intention => { src => 'insert_intention' }, - waiting => { src => 'waiting' }, - }, - visible => [ qw(cxn mysql_thread_id waiting lock_mode db tbl index special insert_intention)], - filters => [], - sort_cols => 'cxn mysql_thread_id', - sort_dir => '1', - innodb => 'dl', - group_by => [], - aggregate => 0, - }, - deadlock_transactions => { - capt => 'Deadlock Transactions', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - active_secs => { src => 'active_secs' }, - dl_txn_num => { src => 'dl_txn_num' }, - has_read_view => { src => 'has_read_view' }, - heap_size => { src => 'heap_size' }, - host_and_domain => { src => 'hostname' }, - hostname => { src => $exprs{Host} }, - ip => { src => 'ip' }, - lock_structs => { src => 'lock_structs' }, - lock_wait_time => { src => 'lock_wait_time', trans => [ qw(secs_to_time) ] }, - mysql_thread_id => { src => 'mysql_thread_id' }, - os_thread_id => { src => 'os_thread_id' }, - proc_no => { src => 'proc_no' }, - query_id => { src => 'query_id' }, - query_status => { src => 'query_status' }, - query_text => { src => 'query_text', trans => [ qw(no_ctrl_char) ] }, - row_locks => { src => 'row_locks' }, - tables_in_use => { src => 'tables_in_use' }, - tables_locked => { src => 'tables_locked' }, - thread_decl_inside => { src => 'thread_decl_inside' }, - thread_status => { src => 'thread_status' }, - 'time' => { src => 'active_secs', trans => [ qw(secs_to_time) ] }, - timestring => { src => 'timestring' }, - txn_doesnt_see_ge => { src => 'txn_doesnt_see_ge' }, - txn_id => { src => 'txn_id' }, - txn_sees_lt => { src => 'txn_sees_lt' }, - txn_status => { src => 'txn_status' }, - truncates => { src => 'truncates' }, - undo_log_entries => { src => 'undo_log_entries' }, - user => { src => 'user' }, - victim => { src => 'victim' }, - wait_status => { src => 'lock_wait_status' }, - }, - visible => [ qw(cxn mysql_thread_id timestring user hostname victim time undo_log_entries lock_structs query_text)], - filters => [], - sort_cols => 'cxn mysql_thread_id', - sort_dir => '1', - innodb => 'dl', - group_by => [], - aggregate => 0, - }, - explain => { - capt => 'EXPLAIN Results', - cust => {}, - cols => { - part_id => { src => 'id' }, - select_type => { src => 'select_type' }, - tbl => { src => 'table' }, - partitions => { src => 'partitions' }, - scan_type => { src => 'type' }, - possible_keys => { src => 'possible_keys' }, - index => { src => 'key' }, - key_len => { src => 'key_len' }, - index_ref => { src => 'ref' }, - num_rows => { src => 'rows' }, - special => { src => 'extra' }, - }, - visible => [ qw(select_type tbl partitions scan_type possible_keys index key_len index_ref num_rows special)], - filters => [], - sort_cols => '', - sort_dir => '1', - innodb => '', - group_by => [], - aggregate => 0, - }, - file_io_misc => { - capt => 'File I/O Misc', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - io_bytes_s => { src => 'IB_io_avg_bytes_s' }, - io_flush_type => { src => 'IB_io_flush_type' }, - io_fsyncs_s => { src => 'IB_io_fsyncs_s' }, - io_reads_s => { src => 'IB_io_reads_s' }, - io_writes_s => { src => 'IB_io_writes_s' }, - os_file_reads => { src => 'IB_io_os_file_reads' }, - os_file_writes => { src => 'IB_io_os_file_writes' }, - os_fsyncs => { src => 'IB_io_os_fsyncs' }, - }, - visible => [ qw(cxn os_file_reads os_file_writes os_fsyncs io_reads_s io_writes_s io_bytes_s)], - filters => [], - sort_cols => 'cxn', - sort_dir => '1', - innodb => 'io', - group_by => [], - aggregate => 0, - }, - fk_error => { - capt => 'Foreign Key Error Info', - cust => {}, - cols => { - timestring => { src => 'IB_fk_timestring' }, - child_db => { src => 'IB_fk_child_db' }, - child_table => { src => 'IB_fk_child_table' }, - child_index => { src => 'IB_fk_child_index' }, - fk_name => { src => 'IB_fk_fk_name' }, - parent_db => { src => 'IB_fk_parent_db' }, - parent_table => { src => 'IB_fk_parent_table' }, - parent_col => { src => 'IB_fk_parent_col' }, - parent_index => { src => 'IB_fk_parent_index' }, - attempted_op => { src => 'IB_fk_attempted_op' }, - }, - visible => [ qw(timestring child_db child_table child_index parent_db parent_table parent_col parent_index fk_name attempted_op)], - filters => [], - sort_cols => '', - sort_dir => '1', - innodb => 'fk', - group_by => [], - aggregate => 0, - }, - insert_buffers => { - capt => 'Insert Buffers', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - inserts => { src => 'IB_ib_inserts' }, - merged_recs => { src => 'IB_ib_merged_recs' }, - merges => { src => 'IB_ib_merges' }, - size => { src => 'IB_ib_size' }, - free_list_len => { src => 'IB_ib_free_list_len' }, - seg_size => { src => 'IB_ib_seg_size' }, - }, - visible => [ qw(cxn inserts merged_recs merges size free_list_len seg_size)], - filters => [], - sort_cols => 'cxn', - sort_dir => '1', - innodb => 'ib', - group_by => [], - aggregate => 0, - }, - innodb_locks => { - capt => 'InnoDB Locks', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - db => { src => 'db' }, - index => { src => 'index' }, - insert_intention => { src => 'insert_intention' }, - lock_mode => { src => 'lock_mode' }, - lock_type => { src => 'lock_type' }, - lock_wait_time => { src => 'lock_wait_time', trans => [ qw(secs_to_time) ] }, - mysql_thread_id => { src => 'mysql_thread_id' }, - n_bits => { src => 'n_bits' }, - page_no => { src => 'page_no' }, - space_id => { src => 'space_id' }, - special => { src => 'special' }, - tbl => { src => 'table' }, - 'time' => { src => 'active_secs', hdr => 'Active', trans => [ qw(secs_to_time) ] }, - txn_id => { src => 'txn_id' }, - waiting => { src => 'waiting' }, - }, - visible => [ qw(cxn mysql_thread_id lock_type waiting lock_wait_time time lock_mode db tbl index insert_intention special)], - filters => [], - sort_cols => 'cxn -lock_wait_time', - sort_dir => '1', - innodb => 'tx', - colors => [ - { col => 'lock_wait_time', op => '>', arg => 60, color => 'red' }, - { col => 'lock_wait_time', op => '>', arg => 30, color => 'yellow' }, - { col => 'lock_wait_time', op => '>', arg => 10, color => 'green' }, - ], - group_by => [], - aggregate => 0, - }, - innodb_transactions => { - capt => 'InnoDB Transactions', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - active_secs => { src => 'active_secs' }, - has_read_view => { src => 'has_read_view' }, - heap_size => { src => 'heap_size' }, - hostname => { src => $exprs{Host} }, - ip => { src => 'ip' }, - wait_status => { src => 'lock_wait_status' }, - lock_wait_time => { src => 'lock_wait_time', trans => [ qw(secs_to_time) ] }, - lock_structs => { src => 'lock_structs' }, - mysql_thread_id => { src => 'mysql_thread_id' }, - os_thread_id => { src => 'os_thread_id' }, - proc_no => { src => 'proc_no' }, - query_id => { src => 'query_id' }, - query_status => { src => 'query_status' }, - query_text => { src => 'query_text', trans => [ qw(no_ctrl_char) ] }, - txn_time_remain => { src => $exprs{TxnTimeRemain}, trans => [ qw(secs_to_time) ] }, - row_locks => { src => 'row_locks' }, - tables_in_use => { src => 'tables_in_use' }, - tables_locked => { src => 'tables_locked' }, - thread_decl_inside => { src => 'thread_decl_inside' }, - thread_status => { src => 'thread_status' }, - 'time' => { src => 'active_secs', trans => [ qw(secs_to_time) ], agg => 'sum' }, - txn_doesnt_see_ge => { src => 'txn_doesnt_see_ge' }, - txn_id => { src => 'txn_id' }, - txn_sees_lt => { src => 'txn_sees_lt' }, - txn_status => { src => 'txn_status', minw => 10, maxw => 10 }, - undo_log_entries => { src => 'undo_log_entries' }, - user => { src => 'user', maxw => 10 }, - cnt => { src => 'mysql_thread_id', minw => 0 }, - }, - visible => [ qw(cxn cnt mysql_thread_id user hostname txn_status time undo_log_entries query_text)], - filters => [ qw( hide_self hide_inactive ) ], - sort_cols => '-active_secs txn_status cxn mysql_thread_id', - sort_dir => '1', - innodb => 'tx', - hide_caption => 1, - colors => [ - { col => 'wait_status', op => 'eq', arg => 'LOCK WAIT', color => 'black on_red' }, - { col => 'time', op => '>', arg => 600, color => 'red' }, - { col => 'time', op => '>', arg => 300, color => 'yellow' }, - { col => 'time', op => '>', arg => 60, color => 'green' }, - { col => 'time', op => '>', arg => 30, color => 'cyan' }, - { col => 'txn_status', op => 'eq', arg => 'not started', color => 'white' }, - ], - group_by => [ qw(cxn txn_status) ], - aggregate => 0, - }, - io_threads => { - capt => 'I/O Threads', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - thread => { src => 'thread' }, - thread_purpose => { src => 'purpose' }, - event_set => { src => 'event_set' }, - thread_status => { src => 'state' }, - }, - visible => [ qw(cxn thread thread_purpose thread_status)], - filters => [ qw() ], - sort_cols => 'cxn thread', - sort_dir => '1', - innodb => 'io', - group_by => [], - aggregate => 0, - }, - log_statistics => { - capt => 'Log Statistics', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - last_chkp => { src => 'IB_lg_last_chkp' }, - log_flushed_to => { src => 'IB_lg_log_flushed_to' }, - log_ios_done => { src => 'IB_lg_log_ios_done' }, - log_ios_s => { src => 'IB_lg_log_ios_s' }, - log_seq_no => { src => 'IB_lg_log_seq_no' }, - pending_chkp_writes => { src => 'IB_lg_pending_chkp_writes' }, - pending_log_writes => { src => 'IB_lg_pending_log_writes' }, - }, - visible => [ qw(cxn log_seq_no log_flushed_to last_chkp log_ios_done log_ios_s)], - filters => [], - sort_cols => 'cxn', - sort_dir => '1', - innodb => 'lg', - group_by => [], - aggregate => 0, - }, - master_status => { - capt => 'Master Status', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - binlog_do_db => { src => 'binlog_do_db' }, - binlog_ignore_db => { src => 'binlog_ignore_db' }, - master_file => { src => 'file' }, - master_pos => { src => 'position' }, - binlog_cache_overflow => { src => '(Binlog_cache_disk_use||0)/(Binlog_cache_use||1)', trans => [ qw(percent) ] }, - }, - visible => [ qw(cxn master_file master_pos binlog_cache_overflow)], - filters => [ qw(cxn_is_master) ], - sort_cols => 'cxn', - sort_dir => '1', - innodb => '', - group_by => [], - aggregate => 0, - }, - pending_io => { - capt => 'Pending I/O', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - p_normal_aio_reads => { src => 'IB_io_pending_normal_aio_reads' }, - p_aio_writes => { src => 'IB_io_pending_aio_writes' }, - p_ibuf_aio_reads => { src => 'IB_io_pending_ibuf_aio_reads' }, - p_sync_ios => { src => 'IB_io_pending_sync_ios' }, - p_buf_pool_flushes => { src => 'IB_io_pending_buffer_pool_flushes' }, - p_log_flushes => { src => 'IB_io_pending_log_flushes' }, - p_log_ios => { src => 'IB_io_pending_log_ios' }, - p_preads => { src => 'IB_io_pending_preads' }, - p_pwrites => { src => 'IB_io_pending_pwrites' }, - }, - visible => [ qw(cxn p_normal_aio_reads p_aio_writes p_ibuf_aio_reads p_sync_ios p_log_flushes p_log_ios)], - filters => [], - sort_cols => 'cxn', - sort_dir => '1', - innodb => 'io', - group_by => [], - aggregate => 0, - }, - open_tables => { - capt => 'Open Tables', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - db => { src => 'database' }, - tbl => { src => 'table' }, - num_times_open => { src => 'in_use' }, - is_name_locked => { src => 'name_locked' }, - }, - visible => [ qw(cxn db tbl num_times_open is_name_locked)], - filters => [ qw(table_is_open) ], - sort_cols => '-num_times_open cxn db tbl', - sort_dir => '1', - innodb => '', - group_by => [], - aggregate => 0, - }, - page_statistics => { - capt => 'Page Statistics', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - pages_read => { src => 'IB_bp_pages_read' }, - pages_written => { src => 'IB_bp_pages_written' }, - pages_created => { src => 'IB_bp_pages_created' }, - page_reads_sec => { src => 'IB_bp_page_reads_sec' }, - page_writes_sec => { src => 'IB_bp_page_writes_sec' }, - page_creates_sec => { src => 'IB_bp_page_creates_sec' }, - }, - visible => [ qw(cxn pages_read pages_written pages_created page_reads_sec page_writes_sec page_creates_sec)], - filters => [], - sort_cols => 'cxn', - sort_dir => '1', - innodb => 'bp', - group_by => [], - aggregate => 0, - }, - processlist => { - capt => 'MySQL Process List', - cust => {}, - cols => { - cxn => { src => 'cxn', minw => 6, maxw => 10 }, - mysql_thread_id => { src => 'id', minw => 6, maxw => 0 }, - user => { src => 'user', minw => 5, maxw => 8 }, - hostname => { src => $exprs{Host}, minw => 13, maxw => 8, }, - port => { src => $exprs{Port}, minw => 0, maxw => 0, }, - host_and_port => { src => 'host', minw => 0, maxw => 0 }, - db => { src => 'db', minw => 6, maxw => 12 }, - cmd => { src => 'command', minw => 5, maxw => 0 }, - time => { src => 'time', minw => 5, maxw => 0, trans => [ qw(secs_to_time) ], agg => 'sum' }, - state => { src => 'state', minw => 0, maxw => 0 }, - info => { src => 'info', minw => 0, maxw => 0, trans => [ qw(no_ctrl_char) ] }, - cnt => { src => 'id', minw => 0, maxw => 0 }, - }, - visible => [ qw(cxn cmd cnt mysql_thread_id user hostname db time info)], - filters => [ qw(hide_self hide_inactive hide_slave_io) ], - sort_cols => '-time cxn hostname mysql_thread_id', - sort_dir => '1', - innodb => '', - hide_caption => 1, - colors => [ - { col => 'state', op => 'eq', arg => 'Locked', color => 'black on_red' }, - { col => 'cmd', op => 'eq', arg => 'Sleep', color => 'white' }, - { col => 'user', op => 'eq', arg => 'system user', color => 'white' }, - { col => 'cmd', op => 'eq', arg => 'Connect', color => 'white' }, - { col => 'cmd', op => 'eq', arg => 'Binlog Dump', color => 'white' }, - { col => 'time', op => '>', arg => 600, color => 'red' }, - { col => 'time', op => '>', arg => 120, color => 'yellow' }, - { col => 'time', op => '>', arg => 60, color => 'green' }, - { col => 'time', op => '>', arg => 30, color => 'cyan' }, - ], - group_by => [qw(cxn cmd)], - aggregate => 0, - }, - - # TODO: some more columns: - # kb_used=hdr='BufUsed' minw='0' num='0' src='percent(1 - ((Key_blocks_unused * key_cache_block_size) / (key_buffer_size||1)))' dec='0' trans='' tbl='q_header' just='-' user='1' maxw='0' label='User-defined' - # retries=hdr='Retries' minw='0' num='0' src='Slave_retried_transactions' dec='0' trans='' tbl='slave_sql_status' just='-' user='1' maxw='0' label='User-defined' - # thd=hdr='Thd' minw='0' num='0' src='Threads_connected' dec='0' trans='' tbl='slave_sql_status' just='-' user='1' maxw='0' label='User-defined' - - q_header => { - capt => 'Q-mode Header', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - questions => { src => 'Questions' }, - qps => { src => 'Questions/Uptime_hires', dec => 1, trans => [qw(shorten)] }, - load => { src => $exprs{ServerLoad}, dec => 1, trans => [qw(shorten)] }, - slow => { src => 'Slow_queries', dec => 1, trans => [qw(shorten)] }, - q_cache_hit => { src => $exprs{QcacheHitRatio}, dec => 1, trans => [qw(percent)] }, - key_buffer_hit => { src => '1-(Key_reads/(Key_read_requests||1))', dec => 1, trans => [qw(percent)] }, - bps_in => { src => 'Bytes_received/Uptime_hires', dec => 1, trans => [qw(shorten)] }, - bps_out => { src => 'Bytes_sent/Uptime_hires', dec => 1, trans => [qw(shorten)] }, - when => { src => 'when' }, - }, - visible => [ qw(cxn when load qps slow q_cache_hit key_buffer_hit bps_in bps_out)], - filters => [], - sort_cols => 'when cxn', - sort_dir => '1', - innodb => '', - hide_caption => 1, - group_by => [], - aggregate => 0, - }, - row_operations => { - capt => 'InnoDB Row Operations', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - num_inserts => { src => 'IB_ro_num_rows_ins' }, - num_updates => { src => 'IB_ro_num_rows_upd' }, - num_reads => { src => 'IB_ro_num_rows_read' }, - num_deletes => { src => 'IB_ro_num_rows_del' }, - num_inserts_sec => { src => 'IB_ro_ins_sec' }, - num_updates_sec => { src => 'IB_ro_upd_sec' }, - num_reads_sec => { src => 'IB_ro_read_sec' }, - num_deletes_sec => { src => 'IB_ro_del_sec' }, - }, - visible => [ qw(cxn num_inserts num_updates num_reads num_deletes num_inserts_sec - num_updates_sec num_reads_sec num_deletes_sec)], - filters => [], - sort_cols => 'cxn', - sort_dir => '1', - innodb => 'ro', - group_by => [], - aggregate => 0, - }, - row_operation_misc => { - capt => 'Row Operation Misc', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - queries_in_queue => { src => 'IB_ro_queries_in_queue' }, - queries_inside => { src => 'IB_ro_queries_inside' }, - read_views_open => { src => 'IB_ro_read_views_open' }, - main_thread_id => { src => 'IB_ro_main_thread_id' }, - main_thread_proc_no => { src => 'IB_ro_main_thread_proc_no' }, - main_thread_state => { src => 'IB_ro_main_thread_state' }, - num_res_ext => { src => 'IB_ro_n_reserved_extents' }, - }, - visible => [ qw(cxn queries_in_queue queries_inside read_views_open main_thread_state)], - filters => [], - sort_cols => 'cxn', - sort_dir => '1', - innodb => 'ro', - group_by => [], - aggregate => 0, - }, - semaphores => { - capt => 'InnoDB Semaphores', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - mutex_os_waits => { src => 'IB_sm_mutex_os_waits' }, - mutex_spin_rounds => { src => 'IB_sm_mutex_spin_rounds' }, - mutex_spin_waits => { src => 'IB_sm_mutex_spin_waits' }, - reservation_count => { src => 'IB_sm_reservation_count' }, - rw_excl_os_waits => { src => 'IB_sm_rw_excl_os_waits' }, - rw_excl_spins => { src => 'IB_sm_rw_excl_spins' }, - rw_shared_os_waits => { src => 'IB_sm_rw_shared_os_waits' }, - rw_shared_spins => { src => 'IB_sm_rw_shared_spins' }, - signal_count => { src => 'IB_sm_signal_count' }, - wait_array_size => { src => 'IB_sm_wait_array_size' }, - }, - visible => [ qw(cxn mutex_os_waits mutex_spin_waits mutex_spin_rounds - rw_excl_os_waits rw_excl_spins rw_shared_os_waits rw_shared_spins - signal_count reservation_count )], - filters => [], - sort_cols => 'cxn', - sort_dir => '1', - innodb => 'sm', - group_by => [], - aggregate => 0, - }, - slave_io_status => { - capt => 'Slave I/O Status', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - connect_retry => { src => 'connect_retry' }, - master_host => { src => 'master_host', hdr => 'Master'}, - master_log_file => { src => 'master_log_file', hdr => 'File' }, - master_port => { src => 'master_port' }, - master_ssl_allowed => { src => 'master_ssl_allowed' }, - master_ssl_ca_file => { src => 'master_ssl_ca_file' }, - master_ssl_ca_path => { src => 'master_ssl_ca_path' }, - master_ssl_cert => { src => 'master_ssl_cert' }, - master_ssl_cipher => { src => 'master_ssl_cipher' }, - master_ssl_key => { src => 'master_ssl_key' }, - master_user => { src => 'master_user' }, - read_master_log_pos => { src => 'read_master_log_pos', hdr => 'Pos' }, - relay_log_size => { src => 'relay_log_space', trans => [qw(shorten)] }, - slave_io_running => { src => 'slave_io_running', hdr => 'On?' }, - slave_io_state => { src => 'slave_io_state', hdr => 'State' }, - }, - visible => [ qw(cxn master_host slave_io_running master_log_file relay_log_size read_master_log_pos slave_io_state)], - filters => [ qw( cxn_is_slave ) ], - sort_cols => 'slave_io_running cxn', - colors => [ - { col => 'slave_io_running', op => 'ne', arg => 'Yes', color => 'black on_red' }, - ], - sort_dir => '1', - innodb => '', - group_by => [], - aggregate => 0, - }, - slave_sql_status => { - capt => 'Slave SQL Status', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - exec_master_log_pos => { src => 'exec_master_log_pos', hdr => 'Master Pos' }, - last_errno => { src => 'last_errno' }, - last_error => { src => 'last_error' }, - master_host => { src => 'master_host', hdr => 'Master' }, - relay_log_file => { src => 'relay_log_file' }, - relay_log_pos => { src => 'relay_log_pos' }, - relay_log_size => { src => 'relay_log_space', trans => [qw(shorten)] }, - relay_master_log_file => { src => 'relay_master_log_file', hdr => 'Master File' }, - replicate_do_db => { src => 'replicate_do_db' }, - replicate_do_table => { src => 'replicate_do_table' }, - replicate_ignore_db => { src => 'replicate_ignore_db' }, - replicate_ignore_table => { src => 'replicate_ignore_table' }, - replicate_wild_do_table => { src => 'replicate_wild_do_table' }, - replicate_wild_ignore_table => { src => 'replicate_wild_ignore_table' }, - skip_counter => { src => 'skip_counter' }, - slave_sql_running => { src => 'slave_sql_running', hdr => 'On?' }, - until_condition => { src => 'until_condition' }, - until_log_file => { src => 'until_log_file' }, - until_log_pos => { src => 'until_log_pos' }, - time_behind_master => { src => 'seconds_behind_master', trans => [ qw(secs_to_time) ] }, - bytes_behind_master => { src => 'master_log_file && master_log_file eq relay_master_log_file ? read_master_log_pos - exec_master_log_pos : 0', trans => [qw(shorten)] }, - slave_catchup_rate => { src => $exprs{SlaveCatchupRate}, trans => [ qw(set_precision) ] }, - slave_open_temp_tables => { src => 'Slave_open_temp_tables' }, - }, - visible => [ qw(cxn master_host slave_sql_running time_behind_master slave_catchup_rate slave_open_temp_tables relay_log_pos last_error)], - filters => [ qw( cxn_is_slave ) ], - sort_cols => 'slave_sql_running cxn', - sort_dir => '1', - innodb => '', - colors => [ - { col => 'slave_sql_running', op => 'ne', arg => 'Yes', color => 'black on_red' }, - { col => 'time_behind_master', op => '>', arg => 600, color => 'red' }, - { col => 'time_behind_master', op => '>', arg => 60, color => 'yellow' }, - { col => 'time_behind_master', op => '==', arg => 0, color => 'white' }, - ], - group_by => [], - aggregate => 0, - }, - t_header => { - capt => 'T-Mode Header', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - dirty_bufs => { src => $exprs{DirtyBufs}, trans => [qw(percent)] }, - history_list_len => { src => 'IB_tx_history_list_len' }, - lock_structs => { src => 'IB_tx_num_lock_structs' }, - num_txns => { src => $exprs{NumTxns} }, - max_txn => { src => $exprs{MaxTxnTime}, trans => [qw(secs_to_time)] }, - undo_for => { src => 'IB_tx_purge_undo_for' }, - used_bufs => { src => $exprs{BufPoolFill}, trans => [qw(percent)]}, - versions => { src => $exprs{OldVersions} }, - }, - visible => [ qw(cxn history_list_len versions undo_for dirty_bufs used_bufs num_txns max_txn lock_structs)], - filters => [ ], - sort_cols => 'cxn', - sort_dir => '1', - innodb => '', - colors => [], - hide_caption => 1, - group_by => [], - aggregate => 0, - }, - var_status => { - capt => 'Variables & Status', - cust => {}, - cols => {}, # Generated from current varset - visible => [], # Generated from current varset - filters => [], - sort_cols => '', - sort_dir => 1, - innodb => '', - temp => 1, # Do not persist to config file. - hide_caption => 1, - pivot => 0, - group_by => [], - aggregate => 0, - }, - wait_array => { - capt => 'InnoDB Wait Array', - cust => {}, - cols => { - cxn => { src => 'cxn' }, - thread => { src => 'thread' }, - waited_at_filename => { src => 'waited_at_filename' }, - waited_at_line => { src => 'waited_at_line' }, - 'time' => { src => 'waited_secs', trans => [ qw(secs_to_time) ] }, - request_type => { src => 'request_type' }, - lock_mem_addr => { src => 'lock_mem_addr' }, - lock_cfile_name => { src => 'lock_cfile_name' }, - lock_cline => { src => 'lock_cline' }, - writer_thread => { src => 'writer_thread' }, - writer_lock_mode => { src => 'writer_lock_mode' }, - num_readers => { src => 'num_readers' }, - lock_var => { src => 'lock_var' }, - waiters_flag => { src => 'waiters_flag' }, - last_s_file_name => { src => 'last_s_file_name' }, - last_s_line => { src => 'last_s_line' }, - last_x_file_name => { src => 'last_x_file_name' }, - last_x_line => { src => 'last_x_line' }, - cell_waiting => { src => 'cell_waiting' }, - cell_event_set => { src => 'cell_event_set' }, - }, - visible => [ qw(cxn thread time waited_at_filename waited_at_line request_type num_readers lock_var waiters_flag cell_waiting cell_event_set)], - filters => [], - sort_cols => 'cxn -time', - sort_dir => '1', - innodb => 'sm', - group_by => [], - aggregate => 0, - }, -); - -# Initialize %tbl_meta from %columns and do some checks. -foreach my $table_name ( keys %tbl_meta ) { - my $table = $tbl_meta{$table_name}; - my $cols = $table->{cols}; - - foreach my $col_name ( keys %$cols ) { - my $col_def = $table->{cols}->{$col_name}; - die "I can't find a column named '$col_name' for '$table_name'" unless $columns{$col_name}; - $columns{$col_name}->{referenced} = 1; - - foreach my $prop ( keys %col_props ) { - # Each column gets non-existing values set from %columns or defaults from %col_props. - if ( !$col_def->{$prop} ) { - $col_def->{$prop} - = defined($columns{$col_name}->{$prop}) - ? $columns{$col_name}->{$prop} - : $col_props{$prop}; - } - } - - # Ensure transformations and aggregate functions are valid - die "Unknown aggregate function '$col_def->{agg}' " - . "for column '$col_name' in table '$table_name'" - unless exists $agg_funcs{$col_def->{agg}}; - foreach my $trans ( @{$col_def->{trans}} ) { - die "Unknown transformation '$trans' " - . "for column '$col_name' in table '$table_name'" - unless exists $trans_funcs{$trans}; - } - } - - # Ensure each column in visible and group_by exists in cols - foreach my $place ( qw(visible group_by) ) { - foreach my $col_name ( @{$table->{$place}} ) { - if ( !exists $cols->{$col_name} ) { - die "Column '$col_name' is listed in '$place' for '$table_name', but doesn't exist"; - } - } - } - - # Compile sort and color subroutines - $table->{sort_func} = make_sort_func($table); - $table->{color_func} = make_color_func($table); -} - -# This is for code cleanup: -{ - my @unused_cols = grep { !$columns{$_}->{referenced} } sort keys %columns; - if ( @unused_cols ) { - die "The following columns are not used: " - . join(' ', @unused_cols); - } -} - -# ########################################################################### -# Operating modes {{{3 -# ########################################################################### -my %modes = ( - B => { - hdr => 'InnoDB Buffers', - cust => {}, - note => 'Shows buffer info from InnoDB', - action_for => { - i => { - action => sub { toggle_config('status_inc') }, - label => 'Toggle incremental status display', - }, - }, - display_sub => \&display_B, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(buffer_pool page_statistics insert_buffers adaptive_hash_index)], - visible_tables => [qw(buffer_pool page_statistics insert_buffers adaptive_hash_index)], - }, - C => { - hdr => 'Command Summary', - cust => {}, - note => 'Shows relative magnitude of variables', - action_for => { - s => { - action => sub { get_config_interactive('cmd_filter') }, - label => 'Choose variable prefix', - }, - }, - display_sub => \&display_C, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(cmd_summary)], - visible_tables => [qw(cmd_summary)], - }, - D => { - hdr => 'InnoDB Deadlocks', - cust => {}, - note => 'View InnoDB deadlock information', - action_for => { - c => { - action => sub { edit_table('deadlock_transactions') }, - label => 'Choose visible columns', - }, - w => { - action => \&create_deadlock, - label => 'Wipe deadlock status info by creating a deadlock', - }, - }, - display_sub => \&display_D, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(deadlock_transactions deadlock_locks)], - visible_tables => [qw(deadlock_transactions deadlock_locks)], - }, - F => { - hdr => 'InnoDB FK Err', - cust => {}, - note => 'View the latest InnoDB foreign key error', - action_for => {}, - display_sub => \&display_F, - connections => [], - server_group => '', - one_connection => 1, - tables => [qw(fk_error)], - visible_tables => [qw(fk_error)], - }, - I => { - hdr => 'InnoDB I/O Info', - cust => {}, - note => 'Shows I/O info (i/o, log...) from InnoDB', - action_for => { - i => { - action => sub { toggle_config('status_inc') }, - label => 'Toggle incremental status display', - }, - }, - display_sub => \&display_I, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(io_threads pending_io file_io_misc log_statistics)], - visible_tables => [qw(io_threads pending_io file_io_misc log_statistics)], - }, - L => { - hdr => 'Locks', - cust => {}, - note => 'Shows transaction locks', - action_for => { - a => { - action => sub { send_cmd_to_servers('CREATE TABLE IF NOT EXISTS test.innodb_lock_monitor(a int) ENGINE=InnoDB', 0, '', []); }, - label => 'Start the InnoDB Lock Monitor', - }, - o => { - action => sub { send_cmd_to_servers('DROP TABLE IF EXISTS test.innodb_lock_monitor', 0, '', []); }, - label => 'Stop the InnoDB Lock Monitor', - }, - }, - display_sub => \&display_L, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(innodb_locks)], - visible_tables => [qw(innodb_locks)], - }, - M => { - hdr => 'Replication Status', - cust => {}, - note => 'Shows replication (master and slave) status', - action_for => { - a => { - action => sub { send_cmd_to_servers('START SLAVE', 0, 'START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE = ?, MASTER_LOG_POS = ?', []); }, - label => 'Start slave(s)', - }, - i => { - action => sub { toggle_config('status_inc') }, - label => 'Toggle incremental status display', - }, - o => { - action => sub { send_cmd_to_servers('STOP SLAVE', 0, '', []); }, - label => 'Stop slave(s)', - }, - b => { - action => sub { purge_master_logs() }, - label => 'Purge unused master logs', - }, - }, - display_sub => \&display_M, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(slave_sql_status slave_io_status master_status)], - visible_tables => [qw(slave_sql_status slave_io_status master_status)], - }, - O => { - hdr => 'Open Tables', - cust => {}, - note => 'Shows open tables in MySQL', - action_for => { - r => { - action => sub { reverse_sort('open_tables'); }, - label => 'Reverse sort order', - }, - s => { - action => sub { choose_sort_cols('open_tables'); }, - label => "Choose sort column", - }, - }, - display_sub => \&display_O, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(open_tables)], - visible_tables => [qw(open_tables)], - }, - Q => { - hdr => 'Query List', - cust => {}, - note => 'Shows queries from SHOW FULL PROCESSLIST', - action_for => { - a => { - action => sub { toggle_filter('processlist', 'hide_self') }, - label => 'Toggle the innotop process', - }, - c => { - action => sub { edit_table('processlist') }, - label => 'Choose visible columns', - }, - e => { - action => sub { analyze_query('e'); }, - label => "Explain a thread's query", - }, - f => { - action => sub { analyze_query('f'); }, - label => "Show a thread's full query", - }, - h => { - action => sub { toggle_visible_table('Q', 'q_header') }, - label => 'Toggle the header on and off', - }, - i => { - action => sub { toggle_filter('processlist', 'hide_inactive') }, - label => 'Toggle idle processes', - }, - k => { - action => sub { kill_query('CONNECTION') }, - label => "Kill a query's connection", - }, - r => { - action => sub { reverse_sort('processlist'); }, - label => 'Reverse sort order', - }, - s => { - action => sub { choose_sort_cols('processlist'); }, - label => "Change the display's sort column", - }, - x => { - action => sub { kill_query('QUERY') }, - label => "Kill a query", - }, - }, - display_sub => \&display_Q, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(q_header processlist)], - visible_tables => [qw(q_header processlist)], - }, - R => { - hdr => 'InnoDB Row Ops', - cust => {}, - note => 'Shows InnoDB row operation and semaphore info', - action_for => { - i => { - action => sub { toggle_config('status_inc') }, - label => 'Toggle incremental status display', - }, - }, - display_sub => \&display_R, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(row_operations row_operation_misc semaphores wait_array)], - visible_tables => [qw(row_operations row_operation_misc semaphores wait_array)], - }, - S => { - hdr => 'Variables & Status', - cust => {}, - note => 'Shows query load statistics a la vmstat', - action_for => { - '>' => { - action => sub { switch_var_set('S_set', 1) }, - label => 'Switch to next variable set', - }, - '<' => { - action => sub { switch_var_set('S_set', -1) }, - label => 'Switch to prev variable set', - }, - c => { - action => sub { - choose_var_set('S_set'); - start_S_mode(); - }, - label => "Choose which set to display", - }, - e => { - action => \&edit_current_var_set, - label => 'Edit the current set of variables', - }, - i => { - action => sub { $clear_screen_sub->(); toggle_config('status_inc') }, - label => 'Toggle incremental status display', - }, - '-' => { - action => sub { set_display_precision(-1) }, - label => 'Decrease fractional display precision', - }, - '+' => { - action => sub { set_display_precision(1) }, - label => 'Increase fractional display precision', - }, - g => { - action => sub { set_s_mode('g') }, - label => 'Switch to graph (tload) view', - }, - s => { - action => sub { set_s_mode('s') }, - label => 'Switch to standard (vmstat) view', - }, - v => { - action => sub { set_s_mode('v') }, - label => 'Switch to pivoted view', - }, - }, - display_sub => \&display_S, - no_clear_screen => 1, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(var_status)], - visible_tables => [qw(var_status)], - }, - T => { - hdr => 'InnoDB Txns', - cust => {}, - note => 'Shows InnoDB transactions in top-like format', - action_for => { - a => { - action => sub { toggle_filter('innodb_transactions', 'hide_self') }, - label => 'Toggle the innotop process', - }, - c => { - action => sub { edit_table('innodb_transactions') }, - label => 'Choose visible columns', - }, - e => { - action => sub { analyze_query('e'); }, - label => "Explain a thread's query", - }, - f => { - action => sub { analyze_query('f'); }, - label => "Show a thread's full query", - }, - h => { - action => sub { toggle_visible_table('T', 't_header') }, - label => 'Toggle the header on and off', - }, - i => { - action => sub { toggle_filter('innodb_transactions', 'hide_inactive') }, - label => 'Toggle inactive transactions', - }, - k => { - action => sub { kill_query('CONNECTION') }, - label => "Kill a transaction's connection", - }, - r => { - action => sub { reverse_sort('innodb_transactions'); }, - label => 'Reverse sort order', - }, - s => { - action => sub { choose_sort_cols('innodb_transactions'); }, - label => "Change the display's sort column", - }, - x => { - action => sub { kill_query('QUERY') }, - label => "Kill a query", - }, - }, - display_sub => \&display_T, - connections => [], - server_group => '', - one_connection => 0, - tables => [qw(t_header innodb_transactions)], - visible_tables => [qw(t_header innodb_transactions)], - }, -); - -# ########################################################################### -# Global key mappings {{{3 -# Keyed on a single character, which is read from the keyboard. Uppercase -# letters switch modes. Lowercase letters access commands when in a mode. -# These can be overridden by action_for in %modes. -# ########################################################################### -my %action_for = ( - '$' => { - action => \&edit_configuration, - label => 'Edit configuration settings', - }, - '?' => { - action => \&display_help, - label => 'Show help', - }, - '!' => { - action => \&display_license, - label => 'Show license and warranty', - }, - '^' => { - action => \&edit_table, - label => "Edit the displayed table(s)", - }, - '#' => { - action => \&choose_server_groups, - label => 'Select/create server groups', - }, - '@' => { - action => \&choose_servers, - label => 'Select/create server connections', - }, - '/' => { - action => \&add_quick_filter, - label => 'Quickly filter what you see', - }, - '\\' => { - action => \&clear_quick_filters, - label => 'Clear quick-filters', - }, - '%' => { - action => \&choose_filters, - label => 'Choose and edit table filters', - }, - "\t" => { - action => \&next_server_group, - label => 'Switch to the next server group', - key => 'TAB', - }, - '=' => { - action => \&toggle_aggregate, - label => 'Toggle aggregation', - }, - # TODO: can these be auto-generated from %modes? - B => { - action => sub { switch_mode('B') }, - label => '', - }, - C => { - action => sub { switch_mode('C') }, - label => '', - }, - D => { - action => sub { switch_mode('D') }, - label => '', - }, - F => { - action => sub { switch_mode('F') }, - label => '', - }, - I => { - action => sub { switch_mode('I') }, - label => '', - }, - L => { - action => sub { switch_mode('L') }, - label => '', - }, - M => { - action => sub { switch_mode('M') }, - label => '', - }, - O => { - action => sub { switch_mode('O') }, - label => '', - }, - Q => { - action => sub { switch_mode('Q') }, - label => '', - }, - R => { - action => sub { switch_mode('R') }, - label => '', - }, - S => { - action => \&start_S_mode, - label => '', - }, - T => { - action => sub { switch_mode('T') }, - label => '', - }, - d => { - action => sub { get_config_interactive('interval') }, - label => 'Change refresh interval', - }, - n => { action => \&next_server, label => 'Switch to the next connection' }, - p => { action => \&pause, label => 'Pause innotop', }, - q => { action => \&finish, label => 'Quit innotop', }, -); - -# ########################################################################### -# Sleep times after certain statements {{{3 -# ########################################################################### -my %stmt_sleep_time_for = (); - -# ########################################################################### -# Config editor key mappings {{{3 -# ########################################################################### -my %cfg_editor_action = ( - c => { - note => 'Edit columns, etc in the displayed table(s)', - func => \&edit_table, - }, - g => { - note => 'Edit general configuration', - func => \&edit_configuration_variables, - }, - k => { - note => 'Edit row-coloring rules', - func => \&edit_color_rules, - }, - p => { - note => 'Manage plugins', - func => \&edit_plugins, - }, - s => { - note => 'Edit server groups', - func => \&edit_server_groups, - }, - S => { - note => 'Edit SQL statement sleep delays', - func => \&edit_stmt_sleep_times, - }, - t => { - note => 'Choose which table(s) to display in this mode', - func => \&choose_mode_tables, - }, -); - -# ########################################################################### -# Color editor key mappings {{{3 -# ########################################################################### -my %color_editor_action = ( - n => { - note => 'Create a new color rule', - func => sub { - my ( $tbl, $idx ) = @_; - my $meta = $tbl_meta{$tbl}; - - $clear_screen_sub->(); - my $col; - do { - $col = prompt_list( - 'Choose the target column for the rule', - '', - sub { return keys %{$meta->{cols}} }, - { map { $_ => $meta->{cols}->{$_}->{label} } keys %{$meta->{cols}} }); - } while ( !$col ); - ( $col ) = grep { $_ } split(/\W+/, $col); - return $idx unless $col && exists $meta->{cols}->{$col}; - - $clear_screen_sub->(); - my $op; - do { - $op = prompt_list( - 'Choose the comparison operator for the rule', - '', - sub { return keys %comp_ops }, - { map { $_ => $comp_ops{$_} } keys %comp_ops } ); - } until ( $op ); - $op =~ s/\s+//g; - return $idx unless $op && exists $comp_ops{$op}; - - my $arg; - do { - $arg = prompt('Specify an argument for the comparison'); - } until defined $arg; - - my $color; - do { - $color = prompt_list( - 'Choose the color(s) the row should be when the rule matches', - '', - sub { return keys %ansicolors }, - { map { $_ => $_ } keys %ansicolors } ); - } until defined $color; - $color = join(' ', unique(grep { exists $ansicolors{$_} } split(/\W+/, $color))); - return $idx unless $color; - - push @{$tbl_meta{$tbl}->{colors}}, { - col => $col, - op => $op, - arg => $arg, - color => $color - }; - $tbl_meta{$tbl}->{cust}->{colors} = 1; - - return $idx; - }, - }, - d => { - note => 'Remove the selected rule', - func => sub { - my ( $tbl, $idx ) = @_; - my @rules = @{ $tbl_meta{$tbl}->{colors} }; - return 0 unless @rules > 0 && $idx < @rules && $idx >= 0; - splice(@{$tbl_meta{$tbl}->{colors}}, $idx, 1); - $tbl_meta{$tbl}->{cust}->{colors} = 1; - return $idx == @rules ? $#rules : $idx; - }, - }, - j => { - note => 'Move highlight down one', - func => sub { - my ( $tbl, $idx ) = @_; - my $num_rules = scalar @{$tbl_meta{$tbl}->{colors}}; - return ($idx + 1) % $num_rules; - }, - }, - k => { - note => 'Move highlight up one', - func => sub { - my ( $tbl, $idx ) = @_; - my $num_rules = scalar @{$tbl_meta{$tbl}->{colors}}; - return ($idx - 1) % $num_rules; - }, - }, - '+' => { - note => 'Move selected rule up one', - func => sub { - my ( $tbl, $idx ) = @_; - my $meta = $tbl_meta{$tbl}; - my $dest = $idx == 0 ? scalar(@{$meta->{colors}} - 1) : $idx - 1; - my $temp = $meta->{colors}->[$idx]; - $meta->{colors}->[$idx] = $meta->{colors}->[$dest]; - $meta->{colors}->[$dest] = $temp; - $meta->{cust}->{colors} = 1; - return $dest; - }, - }, - '-' => { - note => 'Move selected rule down one', - func => sub { - my ( $tbl, $idx ) = @_; - my $meta = $tbl_meta{$tbl}; - my $dest = $idx == scalar(@{$meta->{colors}} - 1) ? 0 : $idx + 1; - my $temp = $meta->{colors}->[$idx]; - $meta->{colors}->[$idx] = $meta->{colors}->[$dest]; - $meta->{colors}->[$dest] = $temp; - $meta->{cust}->{colors} = 1; - return $dest; - }, - }, -); - -# ########################################################################### -# Plugin editor key mappings {{{3 -# ########################################################################### -my %plugin_editor_action = ( - '*' => { - note => 'Toggle selected plugin active/inactive', - func => sub { - my ( $plugins, $idx ) = @_; - my $plugin = $plugins->[$idx]; - $plugin->{active} = $plugin->{active} ? 0 : 1; - return $idx; - }, - }, - j => { - note => 'Move highlight down one', - func => sub { - my ( $plugins, $idx ) = @_; - return ($idx + 1) % scalar(@$plugins); - }, - }, - k => { - note => 'Move highlight up one', - func => sub { - my ( $plugins, $idx ) = @_; - return $idx == 0 ? @$plugins - 1 : $idx - 1; - }, - }, -); - -# ########################################################################### -# Table editor key mappings {{{3 -# ########################################################################### -my %tbl_editor_action = ( - a => { - note => 'Add a column to the table', - func => sub { - my ( $tbl, $col ) = @_; - my @visible_cols = @{ $tbl_meta{$tbl}->{visible} }; - my %all_cols = %{ $tbl_meta{$tbl}->{cols} }; - delete @all_cols{@visible_cols}; - my $choice = prompt_list( - 'Choose a column', - '', - sub { return keys %all_cols; }, - { map { $_ => $all_cols{$_}->{label} || $all_cols{$_}->{hdr} } keys %all_cols }); - if ( $all_cols{$choice} ) { - push @{$tbl_meta{$tbl}->{visible}}, $choice; - $tbl_meta{$tbl}->{cust}->{visible} = 1; - return $choice; - } - return $col; - }, - }, - n => { - note => 'Create a new column and add it to the table', - func => sub { - my ( $tbl, $col ) = @_; - - $clear_screen_sub->(); - print word_wrap("Choose a name for the column. This name is not displayed, and is used only " - . "for internal reference. It can contain only lowercase letters, numbers, " - . "and underscores."); - print "\n\n"; - do { - $col = prompt("Enter column name"); - $col = '' if $col =~ m/[^a-z0-9_]/; - } while ( !$col ); - - $clear_screen_sub->(); - my $hdr; - do { - $hdr = prompt("Enter column header"); - } while ( !$hdr ); - - $clear_screen_sub->(); - print "Choose a source for the column's data\n\n"; - my ( $src, $sub, $err ); - do { - if ( $err ) { - print "Error: $err\n\n"; - } - $src = prompt("Enter column source"); - if ( $src ) { - ( $sub, $err ) = compile_expr($src); - } - } until ( !$err); - - # TODO: this duplicates %col_props. - $tbl_meta{$tbl}->{cols}->{$col} = { - hdr => $hdr, - src => $src, - just => '-', - num => 0, - label => 'User-defined', - user => 1, - tbl => $tbl, - minw => 0, - maxw => 0, - trans => [], - func => $sub, - dec => 0, - agg => 0, - aggonly => 0, - }; - - $tbl_meta{$tbl}->{visible} = [ unique(@{$tbl_meta{$tbl}->{visible}}, $col) ]; - $tbl_meta{$tbl}->{cust}->{visible} = 1; - return $col; - }, - }, - d => { - note => 'Remove selected column', - func => sub { - my ( $tbl, $col ) = @_; - my @visible_cols = @{ $tbl_meta{$tbl}->{visible} }; - my $idx = 0; - return $col unless @visible_cols > 1; - while ( $visible_cols[$idx] ne $col ) { - $idx++; - } - $tbl_meta{$tbl}->{visible} = [ grep { $_ ne $col } @visible_cols ]; - $tbl_meta{$tbl}->{cust}->{visible} = 1; - return $idx == $#visible_cols ? $visible_cols[$idx - 1] : $visible_cols[$idx + 1]; - }, - }, - e => { - note => 'Edit selected column', - func => sub { - # TODO: make this editor hotkey-driven and give readline support. - my ( $tbl, $col ) = @_; - $clear_screen_sub->(); - my $meta = $tbl_meta{$tbl}->{cols}->{$col}; - my @prop = qw(hdr label src just num minw maxw trans agg); # TODO redundant - - my $answer; - do { - # Do what the user asked... - if ( $answer && grep { $_ eq $answer } @prop ) { - # Some properties are arrays, others scalars. - my $ini = ref $col_props{$answer} ? join(' ', @{$meta->{$answer}}) : $meta->{$answer}; - my $val = prompt("New value for $answer", undef, $ini); - $val = [ split(' ', $val) ] if ref($col_props{$answer}); - if ( $answer eq 'trans' ) { - $val = [ unique(grep{ exists $trans_funcs{$_} } @$val) ]; - } - @{$meta}{$answer, 'user', 'tbl' } = ( $val, 1, $tbl ); - } - - my @display_lines = ( - '', - "You are editing column $tbl.$col.\n", - ); - - push @display_lines, create_table2( - \@prop, - { map { $_ => $_ } @prop }, - { map { $_ => ref $meta->{$_} eq 'ARRAY' ? join(' ', @{$meta->{$_}}) - : ref $meta->{$_} ? '[expression code]' - : $meta->{$_} - } @prop - }, - { sep => ' ' }); - draw_screen(\@display_lines, { raw => 1 }); - print "\n\n"; # One to add space, one to clear readline artifacts - $answer = prompt('Edit what? (q to quit)'); - } while ( $answer ne 'q' ); - - return $col; - }, - }, - j => { - note => 'Move highlight down one', - func => sub { - my ( $tbl, $col ) = @_; - my @visible_cols = @{ $tbl_meta{$tbl}->{visible} }; - my $idx = 0; - while ( $visible_cols[$idx] ne $col ) { - $idx++; - } - return $visible_cols[ ($idx + 1) % @visible_cols ]; - }, - }, - k => { - note => 'Move highlight up one', - func => sub { - my ( $tbl, $col ) = @_; - my @visible_cols = @{ $tbl_meta{$tbl}->{visible} }; - my $idx = 0; - while ( $visible_cols[$idx] ne $col ) { - $idx++; - } - return $visible_cols[ $idx - 1 ]; - }, - }, - '+' => { - note => 'Move selected column up one', - func => sub { - my ( $tbl, $col ) = @_; - my $meta = $tbl_meta{$tbl}; - my @visible_cols = @{$meta->{visible}}; - my $idx = 0; - while ( $visible_cols[$idx] ne $col ) { - $idx++; - } - if ( $idx ) { - $visible_cols[$idx] = $visible_cols[$idx - 1]; - $visible_cols[$idx - 1] = $col; - $meta->{visible} = \@visible_cols; - } - else { - shift @{$meta->{visible}}; - push @{$meta->{visible}}, $col; - } - $meta->{cust}->{visible} = 1; - return $col; - }, - }, - '-' => { - note => 'Move selected column down one', - func => sub { - my ( $tbl, $col ) = @_; - my $meta = $tbl_meta{$tbl}; - my @visible_cols = @{$meta->{visible}}; - my $idx = 0; - while ( $visible_cols[$idx] ne $col ) { - $idx++; - } - if ( $idx == $#visible_cols ) { - unshift @{$meta->{visible}}, $col; - pop @{$meta->{visible}}; - } - else { - $visible_cols[$idx] = $visible_cols[$idx + 1]; - $visible_cols[$idx + 1] = $col; - $meta->{visible} = \@visible_cols; - } - $meta->{cust}->{visible} = 1; - return $col; - }, - }, - f => { - note => 'Choose filters', - func => sub { - my ( $tbl, $col ) = @_; - choose_filters($tbl); - return $col; - }, - }, - o => { - note => 'Edit color rules', - func => sub { - my ( $tbl, $col ) = @_; - edit_color_rules($tbl); - return $col; - }, - }, - s => { - note => 'Choose sort columns', - func => sub { - my ( $tbl, $col ) = @_; - choose_sort_cols($tbl); - return $col; - }, - }, - g => { - note => 'Choose group-by (aggregate) columns', - func => sub { - my ( $tbl, $col ) = @_; - choose_group_cols($tbl); - return $col; - }, - }, -); - -# ########################################################################### -# Global variables and environment {{{2 -# ########################################################################### - -my @this_term_size; # w_chars, h_chars, w_pix, h_pix -my @last_term_size; # w_chars, h_chars, w_pix, h_pix -my $char; -my $windows = $OSNAME =~ m/MSWin/; -my $have_color = 0; -my $MAX_ULONG = 4294967295; # 2^32-1 -my $num_regex = qr/^[+-]?(?=\d|\.)\d*(?:\.\d+)?(?:E[+-]?\d+|)$/i; -my $int_regex = qr/^\d+$/; -my $bool_regex = qr/^[01]$/; -my $term = undef; -my $file = undef; # File to watch for InnoDB monitor output -my $file_mtime = undef; # Status of watched file -my $file_data = undef; # Last chunk of text read from file -my $innodb_parser = InnoDBParser->new; - -my $nonfatal_errs = join('|', - 'Access denied for user', - 'Unknown MySQL server host', - 'Unknown database', - 'Can\'t connect to local MySQL server through socket', - 'Can\'t connect to MySQL server on', - 'MySQL server has gone away', - 'Cannot call SHOW INNODB STATUS', - 'Access denied', - 'AutoCommit', -); - -if ( !$opts{n} ) { - require Term::ReadLine; - $term = Term::ReadLine->new('innotop'); -} - -# Stores status, variables, innodb status, master/slave status etc. -# Keyed on connection name. Each entry is a hashref of current and past data sets, -# keyed on clock tick. -my %vars; -my %info_gotten = (); # Which things have been retrieved for the current clock tick. - -# Stores info on currently displayed queries: cxn, connection ID, query text. -my @current_queries; - -my $lines_printed = 0; -my $clock = 0; # Incremented with every wake-sleep cycle -my $clearing_deadlocks = 0; - -# Find the home directory; it's different on different OSes. -my $homepath = $ENV{HOME} || $ENV{HOMEPATH} || $ENV{USERPROFILE} || '.'; - -# If terminal coloring is available, use it. The only function I want from -# the module is the colored() function. -eval { - if ( !$opts{n} ) { - if ( $windows ) { - require Win32::Console::ANSI; - } - require Term::ANSIColor; - import Term::ANSIColor qw(colored); - $have_color = 1; - } -}; -if ( $EVAL_ERROR || $opts{n} ) { - # If there was an error, manufacture my own colored() function that does no - # coloring. - *colored = sub { pop @_; @_; }; -} - -if ( $opts{n} ) { - $clear_screen_sub = sub {}; -} -elsif ( $windows ) { - $clear_screen_sub = sub { $lines_printed = 0; system("cls") }; -} -else { - my $clear = `clear`; - $clear_screen_sub = sub { $lines_printed = 0; print $clear }; -} - -# ########################################################################### -# Config storage. {{{2 -# ########################################################################### -my %config = ( - color => { - val => $have_color, - note => 'Whether to use terminal coloring', - conf => 'ALL', - pat => $bool_regex, - }, - cmd_filter => { - val => 'Com_', - note => 'Prefix for values in C mode', - conf => [qw(C)], - }, - plugin_dir => { - val => "$homepath/.innotop/plugins", - note => 'Directory where plugins can be found', - conf => 'ALL', - }, - show_percent => { - val => 1, - note => 'Show the % symbol after percentages', - conf => 'ALL', - pat => $bool_regex, - }, - skip_innodb => { - val => 0, - note => 'Disable SHOW INNODB STATUS', - conf => 'ALL', - pat => $bool_regex, - }, - S_func => { - val => 's', - note => 'What to display in S mode: graph, status, pivoted status', - conf => [qw(S)], - pat => qr/^[gsv]$/, - }, - cxn_timeout => { - val => 28800, - note => 'Connection timeout for keeping unused connections alive', - conf => 'ALL', - pat => $int_regex, - }, - graph_char => { - val => '*', - note => 'Character for drawing graphs', - conf => [ qw(S) ], - pat => qr/^.$/, - }, - show_cxn_errors_in_tbl => { - val => 1, - note => 'Whether to display connection errors as rows in the table', - conf => 'ALL', - pat => $bool_regex, - }, - hide_hdr => { - val => 0, - note => 'Whether to show column headers', - conf => 'ALL', - pat => $bool_regex, - }, - show_cxn_errors => { - val => 1, - note => 'Whether to print connection errors to STDOUT', - conf => 'ALL', - pat => $bool_regex, - }, - readonly => { - val => 0, - note => 'Whether the config file is read-only', - conf => [ qw() ], - pat => $bool_regex, - }, - global => { - val => 1, - note => 'Whether to show GLOBAL variables and status', - conf => 'ALL', - pat => $bool_regex, - }, - header_highlight => { - val => 'bold', - note => 'How to highlight table column headers', - conf => 'ALL', - pat => qr/^(?:bold|underline)$/, - }, - display_table_captions => { - val => 1, - note => 'Whether to put captions on tables', - conf => 'ALL', - pat => $bool_regex, - }, - charset => { - val => 'ascii', - note => 'What type of characters should be displayed in queries (ascii, unicode, none)', - conf => 'ALL', - pat => qr/^(?:ascii|unicode|none)$/, - }, - auto_wipe_dl => { - val => 0, - note => 'Whether to auto-wipe InnoDB deadlocks', - conf => 'ALL', - pat => $bool_regex, - }, - max_height => { - val => 30, - note => '[Win32] Max window height', - conf => 'ALL', - }, - debug => { - val => 0, - pat => $bool_regex, - note => 'Debug mode (more verbose errors, uses more memory)', - conf => 'ALL', - }, - num_digits => { - val => 2, - pat => $int_regex, - note => 'How many digits to show in fractional numbers and percents', - conf => 'ALL', - }, - debugfile => { - val => "$homepath/.innotop/core_dump", - note => 'A debug file in case you are interested in error output', - }, - show_statusbar => { - val => 1, - pat => $bool_regex, - note => 'Whether to show the status bar in the display', - conf => 'ALL', - }, - mode => { - val => "T", - note => "Which mode to start in", - cmdline => 1, - }, - status_inc => { - val => 0, - note => 'Whether to show raw or incremental values for status variables', - pat => $bool_regex, - }, - interval => { - val => 10, - pat => qr/^(?:(?:\d*?[1-9]\d*(?:\.\d*)?)|(?:\d*\.\d*?[1-9]\d*))$/, - note => "The interval at which the display will be refreshed. Fractional values allowed.", - }, - num_status_sets => { - val => 9, - pat => $int_regex, - note => 'How many sets of STATUS and VARIABLES values to show', - conf => [ qw(S) ], - }, - S_set => { - val => 'general', - pat => qr/^\w+$/, - note => 'Which set of variables to display in S (Variables & Status) mode', - conf => [ qw(S) ], - }, -); - -# ########################################################################### -# Config file sections {{{2 -# The configuration file is broken up into sections like a .ini file. This -# variable defines those sections and the subroutines responsible for reading -# and writing them. -# ########################################################################### -my %config_file_sections = ( - plugins => { - reader => \&load_config_plugins, - writer => \&save_config_plugins, - }, - group_by => { - reader => \&load_config_group_by, - writer => \&save_config_group_by, - }, - filters => { - reader => \&load_config_filters, - writer => \&save_config_filters, - }, - active_filters => { - reader => \&load_config_active_filters, - writer => \&save_config_active_filters, - }, - visible_tables => { - reader => \&load_config_visible_tables, - writer => \&save_config_visible_tables, - }, - sort_cols => { - reader => \&load_config_sort_cols, - writer => \&save_config_sort_cols, - }, - active_columns => { - reader => \&load_config_active_columns, - writer => \&save_config_active_columns, - }, - tbl_meta => { - reader => \&load_config_tbl_meta, - writer => \&save_config_tbl_meta, - }, - general => { - reader => \&load_config_config, - writer => \&save_config_config, - }, - connections => { - reader => \&load_config_connections, - writer => \&save_config_connections, - }, - active_connections => { - reader => \&load_config_active_connections, - writer => \&save_config_active_connections, - }, - server_groups => { - reader => \&load_config_server_groups, - writer => \&save_config_server_groups, - }, - active_server_groups => { - reader => \&load_config_active_server_groups, - writer => \&save_config_active_server_groups, - }, - max_values_seen => { - reader => \&load_config_mvs, - writer => \&save_config_mvs, - }, - varsets => { - reader => \&load_config_varsets, - writer => \&save_config_varsets, - }, - colors => { - reader => \&load_config_colors, - writer => \&save_config_colors, - }, - stmt_sleep_times => { - reader => \&load_config_stmt_sleep_times, - writer => \&save_config_stmt_sleep_times, - }, -); - -# Config file sections have some dependencies, so they have to be read/written in order. -my @ordered_config_file_sections = qw(general plugins filters active_filters tbl_meta - connections active_connections server_groups active_server_groups max_values_seen - active_columns sort_cols visible_tables varsets colors stmt_sleep_times - group_by); - -# All events for which plugins may register themselves. Entries are arrayrefs. -my %event_listener_for = map { $_ => [] } - qw( - extract_values - set_to_tbl_pre_filter set_to_tbl_pre_sort set_to_tbl_pre_group - set_to_tbl_pre_colorize set_to_tbl_pre_transform set_to_tbl_pre_pivot - set_to_tbl_pre_create set_to_tbl_post_create - draw_screen - ); - -# All variables to which plugins have access. -my %pluggable_vars = ( - action_for => \%action_for, - agg_funcs => \%agg_funcs, - config => \%config, - connections => \%connections, - dbhs => \%dbhs, - filters => \%filters, - modes => \%modes, - server_groups => \%server_groups, - tbl_meta => \%tbl_meta, - trans_funcs => \%trans_funcs, - var_sets => \%var_sets, -); - -# ########################################################################### -# Contains logic to generate prepared statements for a given function for a -# given DB connection. Returns a $sth. -# ########################################################################### -my %stmt_maker_for = ( - INNODB_STATUS => sub { - my ( $dbh ) = @_; - return $dbh->prepare(version_ge( $dbh, '5.0.0' ) - ? 'SHOW ENGINE INNODB STATUS' - : 'SHOW INNODB STATUS'); - }, - SHOW_VARIABLES => sub { - my ( $dbh ) = @_; - return $dbh->prepare($config{global}->{val} && version_ge( $dbh, '4.0.3' ) - ? 'SHOW GLOBAL VARIABLES' - : 'SHOW VARIABLES'); - }, - SHOW_STATUS => sub { - my ( $dbh ) = @_; - return $dbh->prepare($config{global}->{val} && version_ge( $dbh, '5.0.2' ) - ? 'SHOW GLOBAL STATUS' - : 'SHOW STATUS'); - }, - KILL_QUERY => sub { - my ( $dbh ) = @_; - return $dbh->prepare(version_ge( $dbh, '5.0.0' ) - ? 'KILL QUERY ?' - : 'KILL ?'); - }, - SHOW_MASTER_LOGS => sub { - my ( $dbh ) = @_; - return $dbh->prepare('SHOW MASTER LOGS'); - }, - SHOW_MASTER_STATUS => sub { - my ( $dbh ) = @_; - return $dbh->prepare('SHOW MASTER STATUS'); - }, - SHOW_SLAVE_STATUS => sub { - my ( $dbh ) = @_; - return $dbh->prepare('SHOW SLAVE STATUS'); - }, - KILL_CONNECTION => sub { - my ( $dbh ) = @_; - return $dbh->prepare(version_ge( $dbh, '5.0.0' ) - ? 'KILL CONNECTION ?' - : 'KILL ?'); - }, - OPEN_TABLES => sub { - my ( $dbh ) = @_; - return version_ge($dbh, '4.0.0') - ? $dbh->prepare('SHOW OPEN TABLES') - : undef; - }, - PROCESSLIST => sub { - my ( $dbh ) = @_; - return $dbh->prepare('SHOW FULL PROCESSLIST'); - }, -); - -# Plugins! -my %plugins = ( -); - -# ########################################################################### -# Run the program {{{1 -# ########################################################################### - -# This config variable is only useful for MS Windows because its terminal -# can't tell how tall it is. -if ( !$windows ) { - delete $config{max_height}; -} - -# Try to lower my priority. -eval { setpriority(0, 0, getpriority(0, 0) + 10); }; - -# Print stuff to the screen immediately, don't wait for a newline. -$OUTPUT_AUTOFLUSH = 1; - -# Clear the screen and load the configuration. -$clear_screen_sub->(); -load_config(); -post_process_tbl_meta(); - -# Make sure no changes are written to config file in non-interactive mode. -if ( $opts{n} ) { - $config{readonly}->{val} = 1; -} - -eval { - - # Open the file for InnoDB status - if ( @ARGV ) { - my $filename = shift @ARGV; - open $file, "<", $filename - or die "Cannot open '$filename': $OS_ERROR"; - } - - # In certain modes we might have to collect data for two cycles - # before printing anything out, so we need to bump up the count one. - if ( $opts{n} && $opts{count} && $config{status_inc}->{val} - && $config{mode}->{val} =~ m/[S]/ ) - { - $opts{count}++; - } - - while (++$clock) { - - my $mode = $config{mode}->{val} || 'T'; - if ( !$modes{$mode} ) { - die "Mode '$mode' doesn't exist; try one of these:\n" - . join("\n", map { " $_ $modes{$_}->{hdr}" } sort keys %modes) - . "\n"; - } - - if ( !$opts{n} ) { - @last_term_size = @this_term_size; - @this_term_size = Term::ReadKey::GetTerminalSize(\*STDOUT); - if ( $windows ) { - $this_term_size[0]--; - $this_term_size[1] - = min($this_term_size[1], $config{max_height}->{val}); - } - die("Can't read terminal size") unless @this_term_size; - } - - # If there's no connection to a database server, we need to fix that... - if ( !%connections ) { - print "You have not defined any database connections.\n\n"; - add_new_dsn(); - } - - # See whether there are any connections defined for this mode. If there's only one - # connection total, assume the user wants to just use innotop for a single server - # and don't ask which server to connect to. Also, if we're monitoring from a file, - # we just use the first connection. - if ( !get_connections() ) { - if ( $file || 1 == scalar keys %connections ) { - $modes{$config{mode}->{val}}->{connections} = [ keys %connections ]; - } - else { - choose_connections(); - } - } - - # Term::ReadLine might have re-set $OUTPUT_AUTOFLUSH. - $OUTPUT_AUTOFLUSH = 1; - - # Prune old data - my $sets = $config{num_status_sets}->{val}; - foreach my $store ( values %vars ) { - delete @{$store}{ grep { $_ < $clock - $sets } keys %$store }; - } - %info_gotten = (); - - # Call the subroutine to display this mode. - $modes{$mode}->{display_sub}->(); - - # It may be time to quit now. - if ( $opts{count} && $clock >= $opts{count} ) { - finish(); - } - - # Wait for a bit. - if ( $opts{n} ) { - sleep($config{interval}->{val}); - } - else { - ReadMode('cbreak'); - $char = ReadKey($config{interval}->{val}); - ReadMode('normal'); - } - - # Handle whatever action the key indicates. - do_key_action(); - - } -}; -if ( $EVAL_ERROR ) { - core_dump( $EVAL_ERROR ); -} -finish(); - -# Subroutines {{{1 -# Mode functions{{{2 -# switch_mode {{{3 -sub switch_mode { - my $mode = shift; - $config{mode}->{val} = $mode; -} - -# Prompting functions {{{2 -# prompt_list {{{3 -# Prompts the user for a value, given a question, initial value, -# a completion function and a hashref of hints. -sub prompt_list { - die "Can't call in non-interactive mode" if $opts{n}; - my ( $question, $init, $completion, $hints ) = @_; - if ( $hints ) { - # Figure out how wide the table will be - my $max_name = max(map { length($_) } keys %$hints ); - $max_name ||= 0; - $max_name += 3; - my @meta_rows = create_table2( - [ sort keys %$hints ], - { map { $_ => $_ } keys %$hints }, - { map { $_ => trunc($hints->{$_}, $this_term_size[0] - $max_name) } keys %$hints }, - { sep => ' ' }); - if (@meta_rows > 10) { - # Try to split and stack the meta rows next to each other - my $split = int(@meta_rows / 2); - @meta_rows = stack_next( - [@meta_rows[0..$split - 1]], - [@meta_rows[$split..$#meta_rows]], - { pad => ' | '}, - ); - } - print join( "\n", - '', - map { ref $_ ? colored(@$_) : $_ } create_caption('Choose from', @meta_rows), ''), - "\n"; - } - $term->Attribs->{completion_function} = $completion; - my $answer = $term->readline("$question: ", $init); - $OUTPUT_AUTOFLUSH = 1; - $answer = '' if !defined($answer); - $answer =~ s/\s+$//; - return $answer; -} - -# prompt {{{3 -# Prints out a prompt and reads from the keyboard, then validates with the -# validation regex until the input is correct. -sub prompt { - die "Can't call in non-interactive mode" if $opts{n}; - my ( $prompt, $regex, $init, $completion ) = @_; - my $response; - my $success = 0; - do { - if ( $completion ) { - $term->Attribs->{completion_function} = $completion; - } - $response = $term->readline("$prompt: ", $init); - if ( $regex && $response !~ m/$regex/ ) { - print "Invalid response.\n\n"; - } - else { - $success = 1; - } - } while ( !$success ); - $OUTPUT_AUTOFLUSH = 1; - $response =~ s/\s+$//; - return $response; -} - -# prompt_noecho {{{3 -# Unfortunately, suppressing echo with Term::ReadLine isn't reliable; the user might not -# have that library, or it might not support that feature. -sub prompt_noecho { - my ( $prompt ) = @_; - print colored("$prompt: ", 'underline'); - my $response; - ReadMode('noecho'); - $response = ; - chomp($response); - ReadMode('normal'); - return $response; -} - -# do_key_action {{{3 -# Depending on whether a key was read, do something. Keys have certain -# actions defined in lookup tables. Each mode may have its own lookup table, -# which trumps the global table -- so keys can be context-sensitive. The key -# may be read and written in a subroutine, so it's a global. -sub do_key_action { - if ( defined $char ) { - my $mode = $config{mode}->{val}; - my $action - = defined($modes{$mode}->{action_for}->{$char}) - ? $modes{$mode}->{action_for}->{$char}->{action} - : defined($action_for{$char}) - ? $action_for{$char}->{action} - : sub{}; - $action->(); - } -} - -# pause {{{3 -sub pause { - die "Can't call in non-interactive mode" if $opts{n}; - my $msg = shift; - print defined($msg) ? "\n$msg" : "\nPress any key to continue"; - ReadMode('cbreak'); - my $char = ReadKey(0); - ReadMode('normal'); - return $char; -} - -# reverse_sort {{{3 -sub reverse_sort { - my $tbl = shift; - $tbl_meta{$tbl}->{sort_dir} *= -1; -} - -# select_cxn {{{3 -# Selects connection(s). If the mode (or argument list) has only one, returns -# it without prompt. -sub select_cxn { - my ( $prompt, @cxns ) = @_; - if ( !@cxns ) { - @cxns = get_connections(); - } - if ( @cxns == 1 ) { - return $cxns[0]; - } - my $choices = prompt_list( - $prompt, - $cxns[0], - sub{ return @cxns }, - { map { $_ => $connections{$_}->{dsn} } @cxns }); - my @result = unique(grep { my $a = $_; grep { $_ eq $a } @cxns } split(/\s+/, $choices)); - return @result; -} - -# kill_query {{{3 -# Kills a connection, or on new versions, optionally a query but not connection. -sub kill_query { - my ( $q_or_c ) = @_; - - my $info = choose_thread( - sub { 1 }, - 'Select a thread to kill the ' . $q_or_c, - ); - return unless $info; - return unless pause("Kill $info->{id}?") =~ m/y/i; - - eval { - do_stmt($info->{cxn}, $q_or_c eq 'QUERY' ? 'KILL_QUERY' : 'KILL_CONNECTION', $info->{id} ); - }; - - if ( $EVAL_ERROR ) { - print "\nError: $EVAL_ERROR"; - pause(); - } -} - -# set_display_precision {{{3 -sub set_display_precision { - my $dir = shift; - $config{num_digits}->{val} = min(9, max(0, $config{num_digits}->{val} + $dir)); -} - -sub toggle_visible_table { - my ( $mode, $table ) = @_; - my $visible = $modes{$mode}->{visible_tables}; - if ( grep { $_ eq $table } @$visible ) { - $modes{$mode}->{visible_tables} = [ grep { $_ ne $table } @$visible ]; - } - else { - unshift @$visible, $table; - } - $modes{$mode}->{cust}->{visible_tables} = 1; -} - -# toggle_filter{{{3 -sub toggle_filter { - my ( $tbl, $filter ) = @_; - my $filters = $tbl_meta{$tbl}->{filters}; - if ( grep { $_ eq $filter } @$filters ) { - $tbl_meta{$tbl}->{filters} = [ grep { $_ ne $filter } @$filters ]; - } - else { - push @$filters, $filter; - } - $tbl_meta{$tbl}->{cust}->{filters} = 1; -} - -# toggle_config {{{3 -sub toggle_config { - my ( $key ) = @_; - $config{$key}->{val} ^= 1; -} - -# create_deadlock {{{3 -sub create_deadlock { - $clear_screen_sub->(); - - print "This function will deliberately cause a small deadlock, " - . "clearing deadlock information from the InnoDB monitor.\n\n"; - - my $answer = prompt("Are you sure you want to proceed? Say 'y' if you do"); - return 0 unless $answer eq 'y'; - - my ( $cxn ) = select_cxn('Clear on which server? '); - return unless $cxn && exists($connections{$cxn}); - - clear_deadlock($cxn); -} - -# deadlock_thread {{{3 -sub deadlock_thread { - my ( $id, $tbl, $cxn ) = @_; - - eval { - my $dbh = get_new_db_connection($cxn, 1); - my @stmts = ( - "set transaction isolation level serializable", - (version_ge($dbh, '4.0.11') ? "start transaction" : 'begin'), - "select * from $tbl where a = $id", - "update $tbl set a = $id where a <> $id", - ); - - foreach my $stmt (@stmts[0..2]) { - $dbh->do($stmt); - } - sleep(1 + $id); - $dbh->do($stmts[-1]); - }; - if ( $EVAL_ERROR ) { - if ( $EVAL_ERROR !~ m/Deadlock found/ ) { - die $EVAL_ERROR; - } - } - exit(0); -} - -# Purges unused binlogs on the master, up to but not including the latest log. -# TODO: guess which connections are slaves of a given master. -sub purge_master_logs { - my @cxns = get_connections(); - - get_master_slave_status(@cxns); - - # Toss out the rows that don't have master/slave status... - my @vars = - grep { $_ && ($_->{file} || $_->{master_host}) } - map { $vars{$_}->{$clock} } @cxns; - @cxns = map { $_->{cxn} } @vars; - - # Figure out which master to purge ons. - my @masters = map { $_->{cxn} } grep { $_->{file} } @vars; - my ( $master ) = select_cxn('Which master?', @masters ); - return unless $master; - my ($master_status) = grep { $_->{cxn} eq $master } @vars; - - # Figure out the result order (not lexical order) of master logs. - my @master_logs = get_master_logs($master); - my $i = 0; - my %master_logs = map { $_->{log_name} => $i++ } @master_logs; - - # Ask which slave(s) are reading from this master. - my @slave_status = grep { $_->{master_host} } @vars; - my @slaves = map { $_->{cxn} } @slave_status; - @slaves = select_cxn("Which slaves are reading from $master?", @slaves); - @slave_status = grep { my $item = $_; grep { $item->{cxn} eq $_ } @slaves } @slave_status; - return unless @slave_status; - - # Find the minimum binary log in use. - my $min_log = min(map { $master_logs{$_->{master_log_file}} } @slave_status); - my $log_name = $master_logs[$min_log]->{log_name}; - - my $stmt = "PURGE MASTER LOGS TO '$log_name'"; - send_cmd_to_servers($stmt, 0, 'PURGE {MASTER | BINARY} LOGS {TO "log_name" | BEFORE "date"}', [$master]); -} - -sub send_cmd_to_servers { - my ( $cmd, $all, $hint, $cxns ) = @_; - if ( $all ) { - @$cxns = get_connections(); - } - elsif ( !@$cxns ) { - @$cxns = select_cxn('Which servers?', @$cxns); - } - if ( $hint ) { - print "\nHint: $hint\n"; - } - $cmd = prompt('Command to send', undef, $cmd); - foreach my $cxn ( @$cxns ) { - eval { - my $sth = do_query($cxn, $cmd); - }; - if ( $EVAL_ERROR ) { - print "Error from $cxn: $EVAL_ERROR\n"; - } - else { - print "Success on $cxn\n"; - } - } - pause(); -} - -# Display functions {{{2 - -sub set_s_mode { - my ( $func ) = @_; - $clear_screen_sub->(); - $config{S_func}->{val} = $func; -} - -# start_S_mode {{{3 -sub start_S_mode { - $clear_screen_sub->(); - switch_mode('S'); -} - -# display_B {{{3 -sub display_B { - my @display_lines; - my @cxns = get_connections(); - get_innodb_status(\@cxns); - - my @buffer_pool; - my @page_statistics; - my @insert_buffers; - my @adaptive_hash_index; - my %rows_for = ( - buffer_pool => \@buffer_pool, - page_statistics => \@page_statistics, - insert_buffers => \@insert_buffers, - adaptive_hash_index => \@adaptive_hash_index, - ); - - my @visible = get_visible_tables(); - my %wanted = map { $_ => 1 } @visible; - - foreach my $cxn ( @cxns ) { - my $set = $vars{$cxn}->{$clock}; - my $pre = $vars{$cxn}->{$clock-1} || $set; - - if ( $set->{IB_bp_complete} ) { - if ( $wanted{buffer_pool} ) { - push @buffer_pool, extract_values($set, $set, $pre, 'buffer_pool'); - } - if ( $wanted{page_statistics} ) { - push @page_statistics, extract_values($set, $set, $pre, 'page_statistics'); - } - } - if ( $set->{IB_ib_complete} ) { - if ( $wanted{insert_buffers} ) { - push @insert_buffers, extract_values( - $config{status_inc}->{val} ? inc(0, $cxn) : $set, $set, $pre, - 'insert_buffers'); - } - if ( $wanted{adaptive_hash_index} ) { - push @adaptive_hash_index, extract_values($set, $set, $pre, 'adaptive_hash_index'); - } - } - } - - my $first_table = 0; - foreach my $tbl ( @visible ) { - push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl); - push @display_lines, get_cxn_errors(@cxns) - if ( $config{debug}->{val} || !$first_table++ ); - } - - draw_screen(\@display_lines); -} - -# display_C {{{3 -sub display_C { - my @display_lines; - my @cxns = get_connections(); - get_status_info(@cxns); - - my @cmd_summary; - my %rows_for = ( - cmd_summary => \@cmd_summary, - ); - - my @visible = get_visible_tables(); - my %wanted = map { $_ => 1 } @visible; - - # For now, I'm manually pulling these variables out and pivoting. Eventually a SQL-ish - # dialect should let me join a table to a grouped and pivoted table and do this more easily. - # TODO: make it so. - my $prefix = qr/^$config{cmd_filter}->{val}/; # TODO: this is a total hack - my @values; - my ($total, $last_total) = (0, 0); - foreach my $cxn ( @cxns ) { - my $set = $vars{$cxn}->{$clock}; - my $pre = $vars{$cxn}->{$clock-1} || $set; - foreach my $key ( keys %$set ) { - next unless $key =~ m/$prefix/i; - my $val = $set->{$key}; - next unless defined $val && $val =~ m/^\d+$/; - my $last_val = $val - ($pre->{$key} || 0); - $total += $val; - $last_total += $last_val; - push @values, { - name => $key, - value => $val, - last_value => $last_val, - }; - } - } - - # Add aggregation and turn into a real set TODO: total hack - if ( $wanted{cmd_summary} ) { - foreach my $value ( @values ) { - @{$value}{qw(total last_total)} = ($total, $last_total); - push @cmd_summary, extract_values($value, $value, $value, 'cmd_summary'); - } - } - - my $first_table = 0; - foreach my $tbl ( @visible ) { - push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl); - push @display_lines, get_cxn_errors(@cxns) - if ( $config{debug}->{val} || !$first_table++ ); - } - - draw_screen(\@display_lines); -} - -# display_D {{{3 -sub display_D { - my @display_lines; - my @cxns = get_connections(); - get_innodb_status(\@cxns); - - my @deadlock_transactions; - my @deadlock_locks; - my %rows_for = ( - deadlock_transactions => \@deadlock_transactions, - deadlock_locks => \@deadlock_locks, - ); - - my @visible = get_visible_tables(); - my %wanted = map { $_ => 1 } @visible; - - foreach my $cxn ( @cxns ) { - my $innodb_status = $vars{$cxn}->{$clock}; - my $prev_status = $vars{$cxn}->{$clock-1} || $innodb_status; - - if ( $innodb_status->{IB_dl_timestring} ) { - - my $victim = $innodb_status->{IB_dl_rolled_back} || 0; - - if ( %wanted ) { - foreach my $txn_id ( keys %{$innodb_status->{IB_dl_txns}} ) { - my $txn = $innodb_status->{IB_dl_txns}->{$txn_id}; - my $pre = $prev_status->{IB_dl_txns}->{$txn_id} || $txn; - - if ( $wanted{deadlock_transactions} ) { - my $hash = extract_values($txn->{tx}, $txn->{tx}, $pre->{tx}, 'deadlock_transactions'); - $hash->{cxn} = $cxn; - $hash->{dl_txn_num} = $txn_id; - $hash->{victim} = $txn_id == $victim ? 'Yes' : 'No'; - $hash->{timestring} = $innodb_status->{IB_dl_timestring}; - $hash->{truncates} = $innodb_status->{IB_dl_complete} ? 'No' : 'Yes'; - push @deadlock_transactions, $hash; - } - - if ( $wanted{deadlock_locks} ) { - foreach my $lock ( @{$txn->{locks}} ) { - my $hash = extract_values($lock, $lock, $lock, 'deadlock_locks'); - $hash->{dl_txn_num} = $txn_id; - $hash->{cxn} = $cxn; - $hash->{mysql_thread_id} = $txn->{tx}->{mysql_thread_id}; - push @deadlock_locks, $hash; - } - } - - } - } - } - } - - my $first_table = 0; - foreach my $tbl ( @visible ) { - push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl); - push @display_lines, get_cxn_errors(@cxns) - if ( $config{debug}->{val} || !$first_table++ ); - } - - draw_screen(\@display_lines); -} - -# display_F {{{3 -sub display_F { - my @display_lines; - my ( $cxn ) = get_connections(); - get_innodb_status([$cxn]); - my $innodb_status = $vars{$cxn}->{$clock}; - - if ( $innodb_status->{IB_fk_timestring} ) { - - push @display_lines, 'Reason: ' . $innodb_status->{IB_fk_reason}; - - # Display FK errors caused by invalid DML. - if ( $innodb_status->{IB_fk_txn} ) { - my $txn = $innodb_status->{IB_fk_txn}; - push @display_lines, - '', - "User $txn->{user} from $txn->{hostname}, thread $txn->{mysql_thread_id} was executing:", - '', no_ctrl_char($txn->{query_text}); - } - - my @fk_table = create_table2( - $tbl_meta{fk_error}->{visible}, - meta_to_hdr('fk_error'), - extract_values($innodb_status, $innodb_status, $innodb_status, 'fk_error'), - { just => '-', sep => ' '}); - push @display_lines, '', @fk_table; - - } - else { - push @display_lines, '', 'No foreign key error data.'; - } - draw_screen(\@display_lines, { raw => 1 } ); -} - -# display_I {{{3 -sub display_I { - my @display_lines; - my @cxns = get_connections(); - get_innodb_status(\@cxns); - - my @io_threads; - my @pending_io; - my @file_io_misc; - my @log_statistics; - my %rows_for = ( - io_threads => \@io_threads, - pending_io => \@pending_io, - file_io_misc => \@file_io_misc, - log_statistics => \@log_statistics, - ); - - my @visible = get_visible_tables(); - my %wanted = map { $_ => 1 } @visible; - - foreach my $cxn ( @cxns ) { - my $set = $vars{$cxn}->{$clock}; - my $pre = $vars{$cxn}->{$clock-1} || $set; - - if ( $set->{IB_io_complete} ) { - if ( $wanted{io_threads} ) { - my $cur_threads = $set->{IB_io_threads}; - my $pre_threads = $pre->{IB_io_threads} || $cur_threads; - foreach my $key ( sort keys %$cur_threads ) { - my $cur_thd = $cur_threads->{$key}; - my $pre_thd = $pre_threads->{$key} || $cur_thd; - my $hash = extract_values($cur_thd, $cur_thd, $pre_thd, 'io_threads'); - $hash->{cxn} = $cxn; - push @io_threads, $hash; - } - } - if ( $wanted{pending_io} ) { - push @pending_io, extract_values($set, $set, $pre, 'pending_io'); - } - if ( $wanted{file_io_misc} ) { - push @file_io_misc, extract_values( - $config{status_inc}->{val} ? inc(0, $cxn) : $set, - $set, $pre, 'file_io_misc'); - } - } - if ( $set->{IB_lg_complete} && $wanted{log_statistics} ) { - push @log_statistics, extract_values($set, $set, $pre, 'log_statistics'); - } - } - - my $first_table = 0; - foreach my $tbl ( @visible ) { - push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl); - push @display_lines, get_cxn_errors(@cxns) - if ( $config{debug}->{val} || !$first_table++ ); - } - - draw_screen(\@display_lines); -} - -# display_L {{{3 -sub display_L { - my @display_lines; - my @cxns = get_connections(); - get_innodb_status(\@cxns); - - my @innodb_locks; - my %rows_for = ( - innodb_locks => \@innodb_locks, - ); - - my @visible = get_visible_tables(); - my %wanted = map { $_ => 1 } @visible; - - # Get info on locks - foreach my $cxn ( @cxns ) { - my $set = $vars{$cxn}->{$clock} or next; - my $pre = $vars{$cxn}->{$clock-1} || $set; - - if ( $wanted{innodb_locks} && defined $set->{IB_tx_transactions} && @{$set->{IB_tx_transactions}} ) { - - my $cur_txns = $set->{IB_tx_transactions}; - my $pre_txns = $pre->{IB_tx_transactions} || $cur_txns; - my %cur_txns = map { $_->{mysql_thread_id} => $_ } @$cur_txns; - my %pre_txns = map { $_->{mysql_thread_id} => $_ } @$pre_txns; - foreach my $txn ( @$cur_txns ) { - foreach my $lock ( @{$txn->{locks}} ) { - my %hash = map { $_ => $txn->{$_} } qw(txn_id mysql_thread_id lock_wait_time active_secs); - map { $hash{$_} = $lock->{$_} } qw(lock_type space_id page_no n_bits index db table txn_id lock_mode special insert_intention waiting); - $hash{cxn} = $cxn; - push @innodb_locks, extract_values(\%hash, \%hash, \%hash, 'innodb_locks'); - } - } - } - } - - my $first_table = 0; - foreach my $tbl ( @visible ) { - push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl); - push @display_lines, get_cxn_errors(@cxns) - if ( $config{debug}->{val} || !$first_table++ ); - } - - draw_screen(\@display_lines); -} - -# display_M {{{3 -sub display_M { - my @display_lines; - my @cxns = get_connections(); - get_master_slave_status(@cxns); - get_status_info(@cxns); - - my @slave_sql_status; - my @slave_io_status; - my @master_status; - my %rows_for = ( - slave_sql_status => \@slave_sql_status, - slave_io_status => \@slave_io_status, - master_status => \@master_status, - ); - - my @visible = get_visible_tables(); - my %wanted = map { $_ => 1 } @visible; - - foreach my $cxn ( @cxns ) { - my $set = $config{status_inc}->{val} ? inc(0, $cxn) : $vars{$cxn}->{$clock}; - my $pre = $vars{$cxn}->{$clock - 1} || $set; - if ( $wanted{slave_sql_status} ) { - push @slave_sql_status, extract_values($set, $set, $pre, 'slave_sql_status'); - } - if ( $wanted{slave_io_status} ) { - push @slave_io_status, extract_values($set, $set, $pre, 'slave_io_status'); - } - if ( $wanted{master_status} ) { - push @master_status, extract_values($set, $set, $pre, 'master_status'); - } - } - - my $first_table = 0; - foreach my $tbl ( @visible ) { - push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl); - push @display_lines, get_cxn_errors(@cxns) - if ( $config{debug}->{val} || !$first_table++ ); - } - - draw_screen(\@display_lines); -} - -# display_O {{{3 -sub display_O { - my @display_lines = (''); - my @cxns = get_connections(); - my @open_tables = get_open_tables(@cxns); - my @tables = map { extract_values($_, $_, $_, 'open_tables') } @open_tables; - push @display_lines, set_to_tbl(\@tables, 'open_tables'), get_cxn_errors(@cxns); - draw_screen(\@display_lines); -} - -# display_Q {{{3 -sub display_Q { - my @display_lines; - - my @q_header; - my @processlist; - my %rows_for = ( - q_header => \@q_header, - processlist => \@processlist, - ); - - my @visible = $opts{n} ? 'processlist' : get_visible_tables(); - my %wanted = map { $_ => 1 } @visible; - - # Get the data - my @cxns = get_connections(); - my @full_processlist = get_full_processlist(@cxns); - - # Create header - if ( $wanted{q_header} ) { - get_status_info(@cxns); - foreach my $cxn ( @cxns ) { - my $set = $vars{$cxn}->{$clock}; - my $pre = $vars{$cxn}->{$clock-1} || $set; - my $hash = extract_values($set, $set, $pre, 'q_header'); - $hash->{cxn} = $cxn; - $hash->{when} = 'Total'; - push @q_header, $hash; - - if ( exists $vars{$cxn}->{$clock - 1} ) { - my $inc = inc(0, $cxn); - my $hash = extract_values($inc, $set, $pre, 'q_header'); - $hash->{cxn} = $cxn; - $hash->{when} = 'Now'; - push @q_header, $hash; - } - } - } - - if ( $wanted{processlist} ) { - # TODO: save prev values - push @processlist, map { extract_values($_, $_, $_, 'processlist') } @full_processlist; - } - - my $first_table = 0; - foreach my $tbl ( @visible ) { - next unless $wanted{$tbl}; - push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl); - push @display_lines, get_cxn_errors(@cxns) - if ( $config{debug}->{val} || !$first_table++ ); - } - - # Save queries in global variable for analysis. The rows in %rows_for have been - # filtered, etc as a side effect of set_to_tbl(), so they are the same as the rows - # that get pushed to the screen. - @current_queries = map { - my %hash; - @hash{ qw(cxn id db query secs) } = @{$_}{ qw(cxn mysql_thread_id db info secs) }; - \%hash; - } @{$rows_for{processlist}}; - - draw_screen(\@display_lines); -} - -# display_R {{{3 -sub display_R { - my @display_lines; - my @cxns = get_connections(); - get_innodb_status(\@cxns); - - my @row_operations; - my @row_operation_misc; - my @semaphores; - my @wait_array; - my %rows_for = ( - row_operations => \@row_operations, - row_operation_misc => \@row_operation_misc, - semaphores => \@semaphores, - wait_array => \@wait_array, - ); - - my @visible = get_visible_tables(); - my %wanted = map { $_ => 1 } @visible; - my $incvar = $config{status_inc}->{val}; - - foreach my $cxn ( @cxns ) { - my $set = $vars{$cxn}->{$clock}; - my $pre = $vars{$cxn}->{$clock-1} || $set; - my $inc; # Only assigned to if wanted - - if ( $set->{IB_ro_complete} ) { - if ( $wanted{row_operations} ) { - $inc ||= $incvar ? inc(0, $cxn) : $set; - push @row_operations, extract_values($inc, $set, $pre, 'row_operations'); - } - if ( $wanted{row_operation_misc} ) { - push @row_operation_misc, extract_values($set, $set, $pre, 'row_operation_misc'), - } - } - - if ( $set->{IB_sm_complete} && $wanted{semaphores} ) { - $inc ||= $incvar ? inc(0, $cxn) : $set; - push @semaphores, extract_values($inc, $set, $pre, 'semaphores'); - } - - if ( $set->{IB_sm_wait_array_size} && $wanted{wait_array} ) { - foreach my $wait ( @{$set->{IB_sm_waits}} ) { - my $hash = extract_values($wait, $wait, $wait, 'wait_array'); - $hash->{cxn} = $cxn; - push @wait_array, $hash; - } - } - } - - my $first_table = 0; - foreach my $tbl ( @visible ) { - push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl); - push @display_lines, get_cxn_errors(@cxns) - if ( $config{debug}->{val} || !$first_table++ ); - } - - draw_screen(\@display_lines); -} - -# display_T {{{3 -sub display_T { - my @display_lines; - - my @t_header; - my @innodb_transactions; - my %rows_for = ( - t_header => \@t_header, - innodb_transactions => \@innodb_transactions, - ); - - my @visible = $opts{n} ? 'innodb_transactions' : get_visible_tables(); - my %wanted = map { $_ => 1 } @visible; - - my @cxns = get_connections(); - - # If the header is to be shown, buffer pool data is required. - get_innodb_status( \@cxns, [ $wanted{t_header} ? qw(bp) : () ] ); - - foreach my $cxn ( get_connections() ) { - my $set = $vars{$cxn}->{$clock}; - my $pre = $vars{$cxn}->{$clock-1} || $set; - - next unless $set->{IB_tx_transactions}; - - if ( $wanted{t_header} ) { - my $hash = extract_values($set, $set, $pre, 't_header'); - push @t_header, $hash; - } - - if ( $wanted{innodb_transactions} ) { - my $cur_txns = $set->{IB_tx_transactions}; - my $pre_txns = $pre->{IB_tx_transactions} || $cur_txns; - my %cur_txns = map { $_->{mysql_thread_id} => $_ } @$cur_txns; - my %pre_txns = map { $_->{mysql_thread_id} => $_ } @$pre_txns; - foreach my $thd_id ( sort keys %cur_txns ) { - my $cur_txn = $cur_txns{$thd_id}; - my $pre_txn = $pre_txns{$thd_id} || $cur_txn; - my $hash = extract_values($cur_txn, $cur_txn, $pre_txn, 'innodb_transactions'); - $hash->{cxn} = $cxn; - push @innodb_transactions, $hash; - } - } - - } - - my $first_table = 0; - foreach my $tbl ( @visible ) { - push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl); - push @display_lines, get_cxn_errors(@cxns) - if ( $config{debug}->{val} || !$first_table++ ); - } - - # Save queries in global variable for analysis. The rows in %rows_for have been - # filtered, etc as a side effect of set_to_tbl(), so they are the same as the rows - # that get pushed to the screen. - @current_queries = map { - my %hash; - @hash{ qw(cxn id db query secs) } = @{$_}{ qw(cxn mysql_thread_id db query_text active_secs) }; - \%hash; - } @{$rows_for{innodb_transactions}}; - - draw_screen(\@display_lines); -} - -# display_S {{{3 -sub display_S { - my $fmt = get_var_set('S_set'); - my $func = $config{S_func}->{val}; - my $inc = $func eq 'g' || $config{status_inc}->{val}; - - # The table's meta-data is generated from the compiled var_set. - my ( $cols, $visible ); - if ( $tbl_meta{var_status}->{fmt} && $fmt eq $tbl_meta{var_status}->{fmt} ) { - ( $cols, $visible ) = @{$tbl_meta{var_status}}{qw(cols visible)}; - } - else { - ( $cols, $visible ) = compile_select_stmt($fmt); - - # Apply missing values to columns. Always apply averages across all connections. - map { - $_->{agg} = 'avg'; - $_->{label} = $_->{hdr}; - } values %$cols; - - $tbl_meta{var_status}->{cols} = $cols; - $tbl_meta{var_status}->{visible} = $visible; - $tbl_meta{var_status}->{fmt} = $fmt; - map { $tbl_meta{var_status}->{cols}->{$_}->{just} = ''} @$visible; - } - - my @var_status; - my %rows_for = ( - var_status => \@var_status, - ); - - my @visible = get_visible_tables(); - my %wanted = map { $_ => 1 } @visible; - my @cxns = get_connections(); - - get_status_info(@cxns); - get_innodb_status(\@cxns); - - # Set up whether to pivot and how many sets to extract. - $tbl_meta{var_status}->{pivot} = $func eq 'v'; - - my $num_sets - = $func eq 'v' - ? $config{num_status_sets}->{val} - : 0; - foreach my $set ( 0 .. $num_sets ) { - my @rows; - foreach my $cxn ( @cxns ) { - my $vars = $inc ? inc($set, $cxn) : $vars{$cxn}->{$clock - $set}; - my $cur = $vars{$cxn}->{$clock-$set}; - my $pre = $vars{$cxn}->{$clock-$set-1} || $cur; - next unless $vars && %$vars; - my $hash = extract_values($vars, $cur, $pre, 'var_status'); - push @rows, $hash; - } - @rows = apply_group_by('var_status', [], @rows); - push @var_status, @rows; - } - - # Recompile the sort func. TODO: avoid recompiling at every refresh. - # Figure out whether the data is all numeric and decide on a sort type. - # my $cmp - # = scalar( - # grep { !defined $_ || $_ !~ m/^\d+$/ } - # map { my $col = $_; map { $_->{$col} } @var_status } - # $tbl_meta{var_status}->{sort_cols} =~ m/(\w+)/g) - # ? 'cmp' - # : '<=>'; - $tbl_meta{var_status}->{sort_func} = make_sort_func($tbl_meta{var_status}); - - # ################################################################ - # Now there is specific display code based on $config{S_func} - # ################################################################ - if ( $func =~ m/s|g/ ) { - my $min_width = 4; - - # Clear the screen if the display width changed. - if ( @last_term_size && $this_term_size[0] != $last_term_size[0] ) { - $lines_printed = 0; - $clear_screen_sub->(); - } - - if ( $func eq 's' ) { - # Decide how wide columns should be. - my $num_cols = scalar(@$visible); - my $width = $opts{n} ? 0 : max($min_width, int(($this_term_size[0] - $num_cols + 1) / $num_cols)); - my $g_format = $opts{n} ? ( "%s\t" x $num_cols ) : ( "%-${width}s " x $num_cols ); - - # Print headers every now and then. Headers can get really long, so compact them. - my @hdr = @$visible; - if ( $opts{n} ) { - if ( $lines_printed == 0 ) { - print join("\t", @hdr), "\n"; - $lines_printed++; - } - } - elsif ( $lines_printed == 0 || $lines_printed > $this_term_size[1] - 2 ) { - @hdr = map { donut(crunch($_, $width), $width) } @hdr; - print join(' ', map { sprintf( "%${width}s", donut($_, $width)) } @hdr) . "\n"; - $lines_printed = 1; - } - - # Design a column format for the values. - my $format - = $opts{n} - ? join("\t", map { '%s' } @$visible) . "\n" - : join(' ', map { "%${width}s" } @hdr) . "\n"; - - foreach my $row ( @var_status ) { - printf($format, map { defined $_ ? $_ : '' } @{$row}{ @$visible }); - $lines_printed++; - } - } - else { # 'g' mode - # Design a column format for the values. - my $num_cols = scalar(@$visible); - my $width = $opts{n} ? 0 : int(($this_term_size[0] - $num_cols + 1) / $num_cols); - my $format = $opts{n} ? ( "%s\t" x $num_cols ) : ( "%-${width}s " x $num_cols ); - $format =~ s/\s$/\n/; - - # Print headers every now and then. - if ( $opts{n} ) { - if ( $lines_printed == 0 ) { - print join("\t", @$visible), "\n"; - print join("\t", map { shorten($mvs{$_}) } @$visible), "\n"; - } - } - elsif ( $lines_printed == 0 || $lines_printed > $this_term_size[1] - 2 ) { - printf($format, map { donut(crunch($_, $width), $width) } @$visible); - printf($format, map { shorten($mvs{$_} || 0) } @$visible); - $lines_printed = 2; - } - - # Update the max ever seen, and scale by the max ever seen. - my $set = $var_status[0]; - foreach my $col ( @$visible ) { - $set->{$col} = 1 unless defined $set->{$col} && $set->{$col} =~ m/$num_regex/; - $set->{$col} = ($set->{$col} || 1) / ($set->{Uptime_hires} || 1); - $mvs{$col} = max($mvs{$col} || 1, $set->{$col}); - $set->{$col} /= $mvs{$col}; - } - printf($format, map { ( $config{graph_char}->{val} x int( $width * $set->{$_} )) || '.' } @$visible ); - $lines_printed++; - - } - } - else { # 'v' - my $first_table = 0; - my @display_lines; - foreach my $tbl ( @visible ) { - push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl); - push @display_lines, get_cxn_errors(@cxns) - if ( $config{debug}->{val} || !$first_table++ ); - } - $clear_screen_sub->(); - draw_screen( \@display_lines ); - } -} - -# display_explain {{{3 -sub display_explain { - my $info = shift; - my $cxn = $info->{cxn}; - my $db = $info->{db}; - - my ( $mods, $query ) = rewrite_for_explain($info->{query}); - - my @display_lines; - - if ( $query ) { - - my $part = version_ge($dbhs{$cxn}->{dbh}, '5.1.5') ? 'PARTITIONS' : ''; - $query = "EXPLAIN $part\n" . $query; - - eval { - if ( $db ) { - do_query($cxn, "use $db"); - } - my $sth = do_query($cxn, $query); - - my $res; - while ( $res = $sth->fetchrow_hashref() ) { - map { $res->{$_} ||= '' } ( 'partitions', keys %$res); - my @this_table = create_caption("Sub-Part $res->{id}", - create_table2( - $tbl_meta{explain}->{visible}, - meta_to_hdr('explain'), - extract_values($res, $res, $res, 'explain'))); - @display_lines = stack_next(\@display_lines, \@this_table, { pad => ' ', vsep => 2 }); - } - }; - - if ( $EVAL_ERROR ) { - push @display_lines, - '', - "The query could not be explained. Only SELECT queries can be " - . "explained; innotop tries to rewrite certain REPLACE and INSERT queries " - . "into SELECT, but this doesn't always succeed."; - } - - } - else { - push @display_lines, '', 'The query could not be explained.'; - } - - if ( $mods ) { - push @display_lines, '', '[This query has been re-written to be explainable]'; - } - - unshift @display_lines, no_ctrl_char($query); - draw_screen(\@display_lines, { raw => 1 } ); -} - -# rewrite_for_explain {{{3 -sub rewrite_for_explain { - my $query = shift; - - my $mods = 0; - my $orig = $query; - $mods += $query =~ s/^\s*(?:replace|insert).*?select/select/is; - $mods += $query =~ s/^ - \s*create\s+(?:temporary\s+)?table - \s+(?:\S+\s+)as\s+select/select/xis; - $mods += $query =~ s/\s+on\s+duplicate\s+key\s+update.*$//is; - return ( $mods, $query ); -} - -# show_optimized_query {{{3 -sub show_optimized_query { - my $info = shift; - my $cxn = $info->{cxn}; - my $db = $info->{db}; - my $meta = $dbhs{$cxn}; - - my @display_lines; - - my ( $mods, $query ) = rewrite_for_explain($info->{query}); - - if ( $mods ) { - push @display_lines, '[This query has been re-written to be explainable]'; - } - - if ( $query ) { - push @display_lines, no_ctrl_char($info->{query}); - - eval { - if ( $db ) { - do_query($cxn, "use $db"); - } - do_query( $cxn, 'EXPLAIN EXTENDED ' . $query ) or die "Can't explain query"; - my $sth = do_query($cxn, 'SHOW WARNINGS'); - my $res = $sth->fetchall_arrayref({}); - - if ( $res ) { - foreach my $result ( @$res ) { - push @display_lines, 'Note:', no_ctrl_char($result->{message}); - } - } - else { - push @display_lines, '', 'The query optimization could not be generated.'; - } - }; - - if ( $EVAL_ERROR ) { - push @display_lines, '', "The optimization could not be generated: $EVAL_ERROR"; - } - - } - else { - push @display_lines, '', 'The query optimization could not be generated.'; - } - - draw_screen(\@display_lines, { raw => 1 } ); -} - -# display_help {{{3 -sub display_help { - my $mode = $config{mode}->{val}; - - # Get globally mapped keys, then overwrite them with mode-specific ones. - my %keys = map { - $_ => $action_for{$_}->{label} - } keys %action_for; - foreach my $key ( keys %{$modes{$mode}->{action_for}} ) { - $keys{$key} = $modes{$mode}->{action_for}->{$key}->{label}; - } - delete $keys{'?'}; - - # Split them into three kinds of keys: MODE keys, action keys, and - # magic (special character) keys. - my @modes = sort grep { m/[A-Z]/ } keys %keys; - my @actions = sort grep { m/[a-z]/ } keys %keys; - my @magic = sort grep { m/[^A-Z]/i } keys %keys; - - my @display_lines = ( '', 'Switch to a different mode:' ); - - # Mode keys - my @all_modes = map { "$_ $modes{$_}->{hdr}" } @modes; - my @col1 = splice(@all_modes, 0, ceil(@all_modes/3)); - my @col2 = splice(@all_modes, 0, ceil(@all_modes/2)); - my $max1 = max(map {length($_)} @col1); - my $max2 = max(map {length($_)} @col2); - while ( @col1 ) { - push @display_lines, sprintf(" %-${max1}s %-${max2}s %s", - (shift @col1 || ''), - (shift @col2 || ''), - (shift @all_modes || '')); - } - - # Action keys - my @all_actions = map { "$_ $keys{$_}" } @actions; - @col1 = splice(@all_actions, 0, ceil(@all_actions/2)); - $max1 = max(map {length($_)} @col1); - push @display_lines, '', 'Actions:'; - while ( @col1 ) { - push @display_lines, sprintf(" %-${max1}s %s", - (shift @col1 || ''), - (shift @all_actions || '')); - } - - # Magic keys - my @all_magic = map { sprintf('%4s', $action_for{$_}->{key} || $_) . " $keys{$_}" } @magic; - @col1 = splice(@all_magic, 0, ceil(@all_magic/2)); - $max1 = max(map {length($_)} @col1); - push @display_lines, '', 'Other:'; - while ( @col1 ) { - push @display_lines, sprintf("%-${max1}s%s", - (shift @col1 || ''), - (shift @all_magic || '')); - } - - $clear_screen_sub->(); - draw_screen(\@display_lines, { show_all => 1 } ); - pause(); - $clear_screen_sub->(); -} - -# show_full_query {{{3 -sub show_full_query { - my $info = shift; - my @display_lines = no_ctrl_char($info->{query}); - draw_screen(\@display_lines, { raw => 1 }); -} - -# Formatting functions {{{2 - -# create_table2 {{{3 -# Makes a two-column table, labels on left, data on right. -# Takes refs of @cols, %labels and %data, %user_prefs -sub create_table2 { - my ( $cols, $labels, $data, $user_prefs ) = @_; - my @rows; - - if ( @$cols && %$data ) { - - # Override defaults - my $p = { - just => '', - sep => ':', - just1 => '-', - }; - if ( $user_prefs ) { - map { $p->{$_} = $user_prefs->{$_} } keys %$user_prefs; - } - - # Fix undef values - map { $data->{$_} = '' unless defined $data->{$_} } @$cols; - - # Format the table - my $max_l = max(map{ length($labels->{$_}) } @$cols); - my $max_v = max(map{ length($data->{$_}) } @$cols); - my $format = "%$p->{just}${max_l}s$p->{sep} %$p->{just1}${max_v}s"; - foreach my $col ( @$cols ) { - push @rows, sprintf($format, $labels->{$col}, $data->{$col}); - } - } - return @rows; -} - -# stack_next {{{3 -# Stacks one display section next to the other. Accepts left-hand arrayref, -# right-hand arrayref, and options hashref. Tries to stack as high as -# possible, so -# aaaaaa -# bbb -# can stack ccc next to the bbb. -# NOTE: this DOES modify its arguments, even though it returns a new array. -sub stack_next { - my ( $left, $right, $user_prefs ) = @_; - my @result; - - my $p = { - pad => ' ', - vsep => 0, - }; - if ( $user_prefs ) { - map { $p->{$_} = $user_prefs->{$_} } keys %$user_prefs; - } - - # Find out how wide the LHS can be and still let the RHS fit next to it. - my $pad = $p->{pad}; - my $max_r = max( map { length($_) } @$right) || 0; - my $max_l = $this_term_size[0] - $max_r - length($pad); - - # Find the minimum row on the LHS that the RHS will fit next to. - my $i = scalar(@$left) - 1; - while ( $i >= 0 && length($left->[$i]) <= $max_l ) { - $i--; - } - $i++; - my $offset = $i; - - if ( $i < scalar(@$left) ) { - # Find the max width of the section of the LHS against which the RHS - # will sit. - my $max_i_in_common = min($i + scalar(@$right) - 1, scalar(@$left) - 1); - my $max_width = max( map { length($_) } @{$left}[$i..$max_i_in_common]); - - # Append the RHS onto the LHS until one runs out. - while ( $i < @$left && $i - $offset < @$right ) { - my $format = "%-${max_width}s$pad%${max_r}s"; - $left->[$i] = sprintf($format, $left->[$i], $right->[$i - $offset]); - $i++; - } - while ( $i - $offset < @$right ) { - # There is more RHS to push on the end of the array - push @$left, - sprintf("%${max_width}s$pad%${max_r}s", ' ', $right->[$i - $offset]); - $i++; - } - push @result, @$left; - } - else { - # There is no room to put them side by side. Add them below, with - # a blank line above them if specified. - push @result, @$left; - push @result, (' ' x $this_term_size[0]) if $p->{vsep} && @$left; - push @result, @$right; - } - return @result; -} - -# create_caption {{{3 -sub create_caption { - my ( $caption, @rows ) = @_; - if ( @rows ) { - - # Calculate the width of what will be displayed, so it can be centered - # in that space. When the thing is wider than the display, center the - # caption in the display. - my $width = min($this_term_size[0], max(map { length(ref($_) ? $_->[0] : $_) } @rows)); - - my $cap_len = length($caption); - - # It may be narrow enough to pad the sides with underscores and save a - # line on the screen. - if ( $cap_len <= $width - 6 ) { - my $left = int(($width - 2 - $cap_len) / 2); - unshift @rows, - ("_" x $left) . " $caption " . ("_" x ($width - $left - $cap_len - 2)); - } - - # The caption is too wide to add underscores on each side. - else { - - # Color is supported, so we can use terminal underlining. - if ( $config{color}->{val} ) { - my $left = int(($width - $cap_len) / 2); - unshift @rows, [ - (" " x $left) . $caption . (" " x ($width - $left - $cap_len)), - 'underline', - ]; - } - - # Color is not supported, so we have to add a line underneath to separate the - # caption from whatever it's captioning. - else { - my $left = int(($width - $cap_len) / 2); - unshift @rows, ('-' x $width); - unshift @rows, (" " x $left) . $caption . (" " x ($width - $left - $cap_len)); - } - - # The caption is wider than the thing it labels, so we have to pad the - # thing it labels to a consistent width. - if ( $cap_len > $width ) { - @rows = map { - ref($_) - ? [ sprintf('%-' . $cap_len . 's', $_->[0]), $_->[1] ] - : sprintf('%-' . $cap_len . 's', $_); - } @rows; - } - - } - } - return @rows; -} - -# create_table {{{3 -# Input: an arrayref of columns, hashref of col info, and an arrayref of hashes -# Example: [ 'a', 'b' ] -# { a => spec, b => spec } -# [ { a => 1, b => 2}, { a => 3, b => 4 } ] -# The 'spec' is a hashref of hdr => label, just => ('-' or ''). It also supports min and max-widths -# vi the minw and maxw params. -# Output: an array of strings, one per row. -# Example: -# Column One Column Two -# ---------- ---------- -# 1 2 -# 3 4 -sub create_table { - my ( $cols, $info, $data, $prefs ) = @_; - $prefs ||= {}; - $prefs->{no_hdr} ||= ($opts{n} && $clock != 1); - - # Truncate rows that will surely be off screen even if this is the only table. - if ( !$opts{n} && !$prefs->{raw} && !$prefs->{show_all} && $this_term_size[1] < @$data-1 ) { - $data = [ @$data[0..$this_term_size[1] - 1] ]; - } - - my @rows = (); - - if ( @$cols && %$info ) { - - # Fix undef values, collapse whitespace. - foreach my $row ( @$data ) { - map { $row->{$_} = collapse_ws($row->{$_}) } @$cols; - } - - my $col_sep = $opts{n} ? "\t" : ' '; - - # Find each column's max width. - my %width_for; - if ( !$opts{n} ) { - %width_for = map { - my $col_name = $_; - if ( $info->{$_}->{dec} ) { - # Align along the decimal point - my $max_rodp = max(0, map { $_->{$col_name} =~ m/([^\s\d-].*)$/ ? length($1) : 0 } @$data); - foreach my $row ( @$data ) { - my $col = $row->{$col_name}; - my ( $l, $r ) = $col =~ m/^([\s\d]*)(.*)$/; - $row->{$col_name} = sprintf("%s%-${max_rodp}s", $l, $r); - } - } - my $max_width = max( length($info->{$_}->{hdr}), map { length($_->{$col_name}) } @$data); - if ( $info->{$col_name}->{maxw} ) { - $max_width = min( $max_width, $info->{$col_name}->{maxw} ); - } - if ( $info->{$col_name}->{minw} ) { - $max_width = max( $max_width, $info->{$col_name}->{minw} ); - } - $col_name => $max_width; - } @$cols; - } - - # The table header. - if ( !$config{hide_hdr}->{val} && !$prefs->{no_hdr} ) { - push @rows, $opts{n} - ? join( $col_sep, @$cols ) - : join( $col_sep, map { sprintf( "%-$width_for{$_}s", trunc($info->{$_}->{hdr}, $width_for{$_}) ) } @$cols ); - if ( $config{color}->{val} && $config{header_highlight}->{val} ) { - push @rows, [ pop @rows, $config{header_highlight}->{val} ]; - } - elsif ( !$opts{n} ) { - push @rows, join( $col_sep, map { "-" x $width_for{$_} } @$cols ); - } - } - - # The table data. - if ( $opts{n} ) { - foreach my $item ( @$data ) { - push @rows, join($col_sep, map { $item->{$_} } @$cols ); - } - } - else { - my $format = join( $col_sep, - map { "%$info->{$_}->{just}$width_for{$_}s" } @$cols ); - foreach my $item ( @$data ) { - my $row = sprintf($format, map { trunc($item->{$_}, $width_for{$_}) } @$cols ); - if ( $config{color}->{val} && $item->{_color} ) { - push @rows, [ $row, $item->{_color} ]; - } - else { - push @rows, $row; - } - } - } - } - - return @rows; -} - -# Aggregates a table. If $group_by is an arrayref of columns, the grouping key -# is the specified columns; otherwise it's just the empty string (e.g. -# everything is grouped as one group). -sub apply_group_by { - my ( $tbl, $group_by, @rows ) = @_; - my $meta = $tbl_meta{$tbl}; - my %is_group = map { $_ => 1 } @$group_by; - my @non_grp = grep { !$is_group{$_} } keys %{$meta->{cols}}; - - my %temp_table; - foreach my $row ( @rows ) { - my $group_key - = @$group_by - ? '{' . join('}{', map { defined $_ ? $_ : '' } @{$row}{@$group_by}) . '}' - : ''; - $temp_table{$group_key} ||= []; - push @{$temp_table{$group_key}}, $row; - } - - # Crush the rows together... - my @new_rows; - foreach my $key ( sort keys %temp_table ) { - my $group = $temp_table{$key}; - my %new_row; - @new_row{@$group_by} = @{$group->[0]}{@$group_by}; - foreach my $col ( @non_grp ) { - my $agg = $meta->{cols}->{$col}->{agg} || 'first'; - $new_row{$col} = $agg_funcs{$agg}->( map { $_->{$col} } @$group ); - } - push @new_rows, \%new_row; - } - return @new_rows; -} - -# set_to_tbl {{{3 -# Unifies all the work of filtering, sorting etc. Alters the input. -# TODO: pull all the little pieces out into subroutines and stick events in each of them. -sub set_to_tbl { - my ( $rows, $tbl ) = @_; - my $meta = $tbl_meta{$tbl} or die "No such table $tbl in tbl_meta"; - - if ( !$meta->{pivot} ) { - - # Hook in event listeners - foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_filter}} ) { - $listener->set_to_tbl_pre_filter($rows, $tbl); - } - - # Apply filters. Note that if the table is pivoted, filtering and sorting - # are applied later. - foreach my $filter ( @{$meta->{filters}} ) { - eval { - @$rows = grep { $filters{$filter}->{func}->($_) } @$rows; - }; - if ( $EVAL_ERROR && $config{debug}->{val} ) { - die $EVAL_ERROR; - } - } - - foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_sort}} ) { - $listener->set_to_tbl_pre_sort($rows, $tbl); - } - - # Sort. Note that if the table is pivoted, sorting might have the wrong - # columns and it could crash. This will only be an issue if it's possible - # to toggle pivoting on and off, which it's not at the moment. - if ( @$rows && $meta->{sort_func} && !$meta->{aggregate} ) { - if ( $meta->{sort_dir} > 0 ) { - @$rows = $meta->{sort_func}->( @$rows ); - } - else { - @$rows = reverse $meta->{sort_func}->( @$rows ); - } - } - - } - - # Stop altering arguments now. - my @rows = @$rows; - - foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_group}} ) { - $listener->set_to_tbl_pre_group(\@rows, $tbl); - } - - # Apply group-by. - if ( $meta->{aggregate} ) { - @rows = apply_group_by($tbl, $meta->{group_by}, @rows); - - # Sort. Note that if the table is pivoted, sorting might have the wrong - # columns and it could crash. This will only be an issue if it's possible - # to toggle pivoting on and off, which it's not at the moment. - if ( @rows && $meta->{sort_func} ) { - if ( $meta->{sort_dir} > 0 ) { - @rows = $meta->{sort_func}->( @rows ); - } - else { - @rows = reverse $meta->{sort_func}->( @rows ); - } - } - - } - - foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_colorize}} ) { - $listener->set_to_tbl_pre_colorize(\@rows, $tbl); - } - - if ( !$meta->{pivot} ) { - # Colorize. Adds a _color column to rows. - if ( @rows && $meta->{color_func} ) { - eval { - foreach my $row ( @rows ) { - $row->{_color} = $meta->{color_func}->($row); - } - }; - if ( $EVAL_ERROR ) { - pause($EVAL_ERROR); - } - } - } - - foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_transform}} ) { - $listener->set_to_tbl_pre_transform(\@rows, $tbl); - } - - # Apply_transformations. - if ( @rows ) { - my $cols = $meta->{cols}; - foreach my $col ( keys %{$rows->[0]} ) { - # Don't auto-vivify $tbl_meta{tbl}-{cols}->{_color}->{trans} - next if $col eq '_color'; - foreach my $trans ( @{$cols->{$col}->{trans}} ) { - map { $_->{$col} = $trans_funcs{$trans}->($_->{$col}) } @rows; - } - } - } - - my ($fmt_cols, $fmt_meta); - - # Pivot. - if ( $meta->{pivot} ) { - - foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_pivot}} ) { - $listener->set_to_tbl_pre_pivot(\@rows, $tbl); - } - - my @vars = @{$meta->{visible}}; - my @tmp = map { { name => $_ } } @vars; - my @cols = 'name'; - foreach my $i ( 0..@$rows-1 ) { - my $col = "set_$i"; - push @cols, $col; - foreach my $j ( 0..@vars-1 ) { - $tmp[$j]->{$col} = $rows[$i]->{$vars[$j]}; - } - } - $fmt_meta = { map { $_ => { hdr => $_, just => '-' } } @cols }; - $fmt_cols = \@cols; - @rows = @tmp; - - # Hook in event listeners - foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_filter}} ) { - $listener->set_to_tbl_pre_filter($rows, $tbl); - } - - # Apply filters. - foreach my $filter ( @{$meta->{filters}} ) { - eval { - @rows = grep { $filters{$filter}->{func}->($_) } @rows; - }; - if ( $EVAL_ERROR && $config{debug}->{val} ) { - die $EVAL_ERROR; - } - } - - foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_sort}} ) { - $listener->set_to_tbl_pre_sort($rows, $tbl); - } - - # Sort. - if ( @rows && $meta->{sort_func} ) { - if ( $meta->{sort_dir} > 0 ) { - @rows = $meta->{sort_func}->( @rows ); - } - else { - @rows = reverse $meta->{sort_func}->( @rows ); - } - } - - } - else { - # If the table isn't pivoted, just show all columns that are supposed to - # be shown; but eliminate aggonly columns if the table isn't aggregated. - my $aggregated = $meta->{aggregate}; - $fmt_cols = [ grep { $aggregated || !$meta->{cols}->{$_}->{aggonly} } @{$meta->{visible}} ]; - $fmt_meta = { map { $_ => $meta->{cols}->{$_} } @$fmt_cols }; - - # If the table is aggregated, re-order the group_by columns to the left of - # the display. - if ( $aggregated ) { - my %is_group = map { $_ => 1 } @{$meta->{group_by}}; - $fmt_cols = [ @{$meta->{group_by}}, grep { !$is_group{$_} } @$fmt_cols ]; - } - } - - foreach my $listener ( @{$event_listener_for{set_to_tbl_pre_create}} ) { - $listener->set_to_tbl_pre_create(\@rows, $tbl); - } - - @rows = create_table( $fmt_cols, $fmt_meta, \@rows); - if ( !$meta->{hide_caption} && !$opts{n} && $config{display_table_captions}->{val} ) { - @rows = create_caption($meta->{capt}, @rows) - } - - foreach my $listener ( @{$event_listener_for{set_to_tbl_post_create}} ) { - $listener->set_to_tbl_post_create(\@rows, $tbl); - } - - return @rows; -} - -# meta_to_hdr {{{3 -sub meta_to_hdr { - my $tbl = shift; - my $meta = $tbl_meta{$tbl}; - my %labels = map { $_ => $meta->{cols}->{$_}->{hdr} } @{$meta->{visible}}; - return \%labels; -} - -# commify {{{3 -# From perlfaq5: add commas. -sub commify { - my ( $num ) = @_; - $num = 0 unless defined $num; - $num =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g; - return $num; -} - -# set_precision {{{3 -# Trim to desired precision. -sub set_precision { - my ( $num, $precision ) = @_; - $precision = $config{num_digits}->{val} if !defined $precision; - sprintf("%.${precision}f", $num); -} - -# percent {{{3 -# Convert to percent -sub percent { - my ( $num ) = @_; - $num = 0 unless defined $num; - my $digits = $config{num_digits}->{val}; - return sprintf("%.${digits}f", $num * 100) - . ($config{show_percent}->{val} ? '%' : ''); -} - -# shorten {{{3 -sub shorten { - my ( $num, $opts ) = @_; - - return $num if !defined($num) || $opts{n} || $num !~ m/$num_regex/; - - $opts ||= {}; - my $pad = defined $opts->{pad} ? $opts->{pad} : ''; - my $num_digits = defined $opts->{num_digits} - ? $opts->{num_digits} - : $config{num_digits}->{val}; - my $force = defined $opts->{force}; - - my $n = 0; - while ( $num >= 1_024 ) { - $num /= 1_024; - ++$n; - } - return sprintf( - $num =~ m/\./ || $n || $force - ? "%.${num_digits}f%s" - : '%d', - $num, ($pad,'k','M','G', 'T')[$n]); - -} - -# Utility functions {{{2 -# unique {{{3 -sub unique { - my %seen; - return grep { !$seen{$_}++ } @_; -} - -# make_color_func {{{3 -sub make_color_func { - my ( $tbl ) = @_; - my @criteria; - foreach my $spec ( @{$tbl->{colors}} ) { - next unless exists $comp_ops{$spec->{op}}; - my $val = $spec->{op} =~ m/^(?:eq|ne|le|ge|lt|gt)$/ ? "'$spec->{arg}'" - : $spec->{op} =~ m/^(?:=~|!~)$/ ? "m/" . quotemeta($spec->{arg}) . "/" - : $spec->{arg}; - push @criteria, - "( defined \$set->{$spec->{col}} && \$set->{$spec->{col}} $spec->{op} $val ) { return '$spec->{color}'; }"; - } - return undef unless @criteria; - my $sub = eval 'sub { my ( $set ) = @_; if ' . join(" elsif ", @criteria) . '}'; - die if $EVAL_ERROR; - return $sub; -} - -# make_sort_func {{{3 -# Gets a list of sort columns from the table, like "+cxn -time" and returns a -# subroutine that will sort that way. -sub make_sort_func { - my ( $tbl ) = @_; - my @criteria; - - # Pivoted tables can be sorted by 'name' and set_x columns; others must be - # sorted by existing columns. TODO: this will crash if you toggle between - # pivoted and nonpivoted. I have several other 'crash' notes about this if - # this ever becomes possible. - - if ( $tbl->{pivot} ) { - # Sort type is not really possible on pivoted columns, because a 'column' - # contains data from an entire non-pivoted row, so there could be a mix of - # numeric and non-numeric data. Thus everything has to be 'cmp' type. - foreach my $col ( split(/\s+/, $tbl->{sort_cols} ) ) { - next unless $col; - my ( $dir, $name ) = $col =~ m/([+-])?(\w+)$/; - next unless $name && $name =~ m/^(?:name|set_\d+)$/; - $dir ||= '+'; - my $op = 'cmp'; - my $df = "''"; - push @criteria, - $dir eq '+' - ? "(\$a->{$name} || $df) $op (\$b->{$name} || $df)" - : "(\$b->{$name} || $df) $op (\$a->{$name} || $df)"; - } - } - else { - foreach my $col ( split(/\s+/, $tbl->{sort_cols} ) ) { - next unless $col; - my ( $dir, $name ) = $col =~ m/([+-])?(\w+)$/; - next unless $name && $tbl->{cols}->{$name}; - $dir ||= '+'; - my $op = $tbl->{cols}->{$name}->{num} ? "<=>" : "cmp"; - my $df = $tbl->{cols}->{$name}->{num} ? "0" : "''"; - push @criteria, - $dir eq '+' - ? "(\$a->{$name} || $df) $op (\$b->{$name} || $df)" - : "(\$b->{$name} || $df) $op (\$a->{$name} || $df)"; - } - } - return sub { return @_ } unless @criteria; - my $sub = eval 'sub { sort {' . join("||", @criteria) . '} @_; }'; - die if $EVAL_ERROR; - return $sub; -} - -# trunc {{{3 -# Shortens text to specified length. -sub trunc { - my ( $text, $len ) = @_; - if ( length($text) <= $len ) { - return $text; - } - return substr($text, 0, $len); -} - -# donut {{{3 -# Takes out the middle of text to shorten it. -sub donut { - my ( $text, $len ) = @_; - return $text if length($text) <= $len; - my $max = length($text) - $len; - my $min = $max - 1; - - # Try to remove a single "word" from somewhere in the center - if ( $text =~ s/_[^_]{$min,$max}_/_/ ) { - return $text; - } - - # Prefer removing the end of a "word" - if ( $text =~ s/([^_]+)[^_]{$max}_/$1_/ ) { - return $text; - } - - $text = substr($text, 0, int($len/2)) - . "_" - . substr($text, int($len/2) + $max + 1); - return $text; -} - -# crunch {{{3 -# Removes vowels and compacts repeated letters to shorten text. -sub crunch { - my ( $text, $len ) = @_; - return $text if $len && length($text) <= $len; - $text =~ s/^IB_\w\w_//; - $text =~ s/(?{val}; - if ( $charset && $charset eq 'unicode' ) { - $text =~ s/ - ("(?:(?!(?{val} ) { - unshift @$display_lines, create_statusbar(); - } - - foreach my $listener ( @{$event_listener_for{draw_screen}} ) { - $listener->draw_screen($display_lines); - } - - $clear_screen_sub->() - if $prefs->{clear} || !$modes{$config{mode}->{val}}->{no_clear_screen}; - if ( $opts{n} || $prefs->{raw} ) { - my $num_lines = 0; - print join("\n", - map { - $num_lines++; - ref $_ - ? colored($_->[0], $_->[1]) - : $_; - } - grep { !$opts{n} || $_ } # Suppress empty lines - @$display_lines); - if ( $opts{n} && $num_lines ) { - print "\n"; - } - } - else { - my $max_lines = $prefs->{show_all} - ? scalar(@$display_lines)- 1 - : min(scalar(@$display_lines), $this_term_size[1]); - print join("\n", - map { - ref $_ - ? colored(substr($_->[0], 0, $this_term_size[0]), $_->[1]) - : substr($_, 0, $this_term_size[0]); - } @$display_lines[0..$max_lines - 1]); - } -} - -# secs_to_time {{{3 -sub secs_to_time { - my ( $secs, $fmt ) = @_; - $secs ||= 0; - return '00:00' unless $secs; - - # Decide what format to use, if not given - $fmt ||= $secs >= 86_400 ? 'd' - : $secs >= 3_600 ? 'h' - : 'm'; - - return - $fmt eq 'd' ? sprintf( - "%d+%02d:%02d:%02d", - int($secs / 86_400), - int(($secs % 86_400) / 3_600), - int(($secs % 3_600) / 60), - $secs % 60) - : $fmt eq 'h' ? sprintf( - "%02d:%02d:%02d", - int(($secs % 86_400) / 3_600), - int(($secs % 3_600) / 60), - $secs % 60) - : sprintf( - "%02d:%02d", - int(($secs % 3_600) / 60), - $secs % 60); -} - -# dulint_to_int {{{3 -# Takes a number that InnoDB formats as two ulint integers, like transaction IDs -# and such, and turns it into a single integer -sub dulint_to_int { - my $num = shift; - return 0 unless $num; - my ( $high, $low ) = $num =~ m/^(\d+) (\d+)$/; - return $low unless $high; - return $low + ( $high * $MAX_ULONG ); -} - -# create_statusbar {{{3 -sub create_statusbar { - my $mode = $config{mode}->{val}; - my @cxns = sort { $a cmp $b } get_connections(); - - my $modeline = ( $config{readonly}->{val} ? '[RO] ' : '' ) - . $modes{$mode}->{hdr} . " (? for help)"; - my $mode_width = length($modeline); - my $remaining_width = $this_term_size[0] - $mode_width - 1; - my $result; - - # The thingie in top-right that says what we're monitoring. - my $cxn = ''; - - if ( 1 == @cxns && $dbhs{$cxns[0]} && $dbhs{$cxns[0]}->{dbh} ) { - $cxn = $dbhs{$cxns[0]}->{dbh}->{mysql_serverinfo} || ''; - } - else { - if ( $modes{$mode}->{server_group} ) { - $cxn = "Servers: " . $modes{$mode}->{server_group}; - my $err_count = grep { $dbhs{$_} && $dbhs{$_}->{err_count} } @cxns; - if ( $err_count ) { - $cxn .= "(" . ( scalar(@cxns) - $err_count ) . "/" . scalar(@cxns) . ")"; - } - } - else { - $cxn = join(' ', map { ($dbhs{$_}->{err_count} ? '!' : '') . $_ } - grep { $dbhs{$_} } @cxns); - } - } - - if ( 1 == @cxns ) { - get_driver_status(@cxns); - my $vars = $vars{$cxns[0]}->{$clock}; - my $inc = inc(0, $cxns[0]); - - # Format server uptime human-readably, calculate QPS... - my $uptime = secs_to_time( $vars->{Uptime_hires} ); - my $qps = ($inc->{Questions}||0) / ($inc->{Uptime_hires}||1); - my $ibinfo = ''; - - if ( exists $vars->{IB_last_secs} ) { - $ibinfo .= "InnoDB $vars->{IB_last_secs}s "; - if ( $vars->{IB_got_all} ) { - if ( ($mode eq 'T' || $mode eq 'W') - && $vars->{IB_tx_is_truncated} ) { - $ibinfo .= ':^|'; - } - else { - $ibinfo .= ':-)'; - } - } - else { - $ibinfo .= ':-('; - } - } - $result = sprintf( - "%-${mode_width}s %${remaining_width}s", - $modeline, - join(', ', grep { $_ } ( - $cxns[0], - $uptime, - $ibinfo, - shorten($qps) . " QPS", - ($vars->{Threads} || 0) . " thd", - $cxn))); - } - else { - $result = sprintf( - "%-${mode_width}s %${remaining_width}s", - $modeline, - $cxn); - } - - return $config{color}->{val} ? [ $result, 'bold reverse' ] : $result; -} - -# Database connections {{{3 -sub add_new_dsn { - my ( $name ) = @_; - - if ( defined $name ) { - $name =~ s/[\s:;]//g; - } - - if ( !$name ) { - print word_wrap("Choose a name for the connection. It cannot contain " - . "whitespace, colons or semicolons."), "\n\n"; - do { - $name = prompt("Enter a name"); - $name =~ s/[\s:;]//g; - } until ( $name ); - } - - my $dsn; - do { - $clear_screen_sub->(); - print "Typical DSN strings look like\n DBI:mysql:;host=hostname;port=port\n" - . "The db and port are optional and can usually be omitted.\n" - . "If you specify 'mysql_read_default_group=mysql' many options can be read\n" - . "from your mysql options files (~/.my.cnf, /etc/my.cnf).\n\n"; - $dsn = prompt("Enter a DSN string", undef, "DBI:mysql:;mysql_read_default_group=mysql;host=$name"); - } until ( $dsn ); - - $clear_screen_sub->(); - my $dl_table = prompt("Optional: enter a table (must not exist) to use when resetting InnoDB deadlock information", - undef, 'test.innotop_dl'); - - $connections{$name} = { - dsn => $dsn, - dl_table => $dl_table, - }; -} - -sub add_new_server_group { - my ( $name ) = @_; - - if ( defined $name ) { - $name =~ s/[\s:;]//g; - } - - if ( !$name ) { - print word_wrap("Choose a name for the group. It cannot contain " - . "whitespace, colons or semicolons."), "\n\n"; - do { - $name = prompt("Enter a name"); - $name =~ s/[\s:;]//g; - } until ( $name ); - } - - my @cxns; - do { - $clear_screen_sub->(); - @cxns = select_cxn("Choose servers for $name", keys %connections); - } until ( @cxns ); - - $server_groups{$name} = \@cxns; - return $name; -} - -sub get_var_set { - my ( $name ) = @_; - while ( !$name || !exists($var_sets{$config{$name}->{val}}) ) { - $name = choose_var_set($name); - } - return $var_sets{$config{$name}->{val}}->{text}; -} - -sub add_new_var_set { - my ( $name ) = @_; - - if ( defined $name ) { - $name =~ s/\W//g; - } - - if ( !$name ) { - do { - $name = prompt("Enter a name"); - $name =~ s/\W//g; - } until ( $name ); - } - - my $variables; - do { - $clear_screen_sub->(); - $variables = prompt("Enter variables for $name", undef ); - } until ( $variables ); - - $var_sets{$name} = { text => $variables, user => 1 }; -} - -sub next_server { - my $mode = $config{mode}->{val}; - my @cxns = sort keys %connections; - my ($cur) = get_connections($mode); - $cur ||= $cxns[0]; - my $pos = grep { $_ lt $cur } @cxns; - my $newpos = ($pos + 1) % @cxns; - $modes{$mode}->{server_group} = ''; - $modes{$mode}->{connections} = [ $cxns[$newpos] ]; - $clear_screen_sub->(); -} - -sub next_server_group { - my $mode = shift || $config{mode}->{val}; - my @grps = sort keys %server_groups; - my $curr = $modes{$mode}->{server_group}; - - return unless @grps; - - if ( $curr ) { - # Find the current group's position. - my $pos = 0; - while ( $curr ne $grps[$pos] ) { - $pos++; - } - $modes{$mode}->{server_group} = $grps[ ($pos + 1) % @grps ]; - } - else { - $modes{$mode}->{server_group} = $grps[0]; - } -} - -# Get a list of connection names used in this mode. -sub get_connections { - if ( $file ) { - return qw(file); - } - my $mode = shift || $config{mode}->{val}; - my @connections = $modes{$mode}->{server_group} - ? @{$server_groups{$modes{$mode}->{server_group}}} - : @{$modes{$mode}->{connections}}; - if ( $modes{$mode}->{one_connection} ) { - @connections = @connections ? $connections[0] : (); - } - return unique(@connections); -} - -# Get a list of tables used in this mode. If innotop is running non-interactively, just use the first. -sub get_visible_tables { - my $mode = shift || $config{mode}->{val}; - my @tbls = @{$modes{$mode}->{visible_tables}}; - if ( $opts{n} ) { - return $tbls[0]; - } - else { - return @tbls; - } -} - -# Choose from among available connections or server groups. -# If the mode has a server set in use, prefers that instead. -sub choose_connections { - $clear_screen_sub->(); - my $mode = $config{mode}->{val}; - my $meta = { map { $_ => $connections{$_}->{dsn} } keys %connections }; - foreach my $group ( keys %server_groups ) { - $meta->{"#$group"} = join(' ', @{$server_groups{$group}}); - } - - my $choices = prompt_list("Choose connections or a group for $mode mode", - undef, sub { return keys %$meta }, $meta); - - my @choices = unique(grep { $_ } split(/\s+/, $choices)); - if ( @choices ) { - if ( $choices[0] =~ s/^#// && exists $server_groups{$choices[0]} ) { - $modes{$mode}->{server_group} = $choices[0]; - } - else { - $modes{$mode}->{connections} = [ grep { exists $connections{$_} } @choices ]; - } - } -} - -# Accepts a DB connection name and the name of a prepared query (e.g. status, kill). -# Also a list of params for the prepared query. This allows not storing prepared -# statements globally. Returns a $sth that's been executed. -# ERROR-HANDLING SEMANTICS: if the statement throws an error, propagate, but if the -# connection has gone away or can't connect, DO NOT. Just return undef. -sub do_stmt { - my ( $cxn, $stmt_name, @args ) = @_; - - return undef if $file; - - # Test if the cxn should not even be tried - return undef if $dbhs{$cxn} - && $dbhs{$cxn}->{err_count} - && ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} ) - && $dbhs{$cxn}->{wake_up} > $clock; - - my $sth; - my $retries = 1; - my $success = 0; - TRY: - while ( $retries-- >= 0 && !$success ) { - - eval { - my $dbh = connect_to_db($cxn); - - # If the prepared query doesn't exist, make it. - if ( !exists $dbhs{$cxn}->{stmts}->{$stmt_name} ) { - $dbhs{$cxn}->{stmts}->{$stmt_name} = $stmt_maker_for{$stmt_name}->($dbh); - } - - $sth = $dbhs{$cxn}->{stmts}->{$stmt_name}; - if ( $sth ) { - $sth->execute(@args); - } - $success = 1; - }; - if ( $EVAL_ERROR ) { - if ( $EVAL_ERROR =~ m/$nonfatal_errs/ ) { - handle_cxn_error($cxn, $EVAL_ERROR); - } - else { - die "$cxn $stmt_name: $EVAL_ERROR"; - } - if ( $retries < 0 ) { - $sth = undef; - } - } - } - - if ( $sth && $sth->{NUM_OF_FIELDS} ) { - sleep($stmt_sleep_time_for{$stmt_name}) if $stmt_sleep_time_for{$stmt_name}; - return $sth; - } -} - -# Keeps track of error count, sleep times till retries, etc etc. -# When there's an error we retry the connection every so often, increasing in -# Fibonacci series to prevent too much banging on the server. -sub handle_cxn_error { - my ( $cxn, $err ) = @_; - my $meta = $dbhs{$cxn}; - $meta->{err_count}++; - - # This is used so errors that have to do with permissions needed by the current - # mode will get displayed as long as we're in this mode, but get ignored if the - # mode changes. - $meta->{mode} = $config{mode}->{val}; - - # Strip garbage from the error text if possible. - $err =~ s/\s+/ /g; - if ( $err =~ m/failed: (.*?) at \S*innotop line/ ) { - $err = $1; - } - - $meta->{last_err} = $err; - my $sleep_time = $meta->{this_sleep} + $meta->{prev_sleep}; - $meta->{prev_sleep} = $meta->{this_sleep}; - $meta->{this_sleep} = $sleep_time; - $meta->{wake_up} = $clock + $sleep_time; - if ( $config{show_cxn_errors}->{val} ) { - print STDERR "Error at tick $clock $cxn $err" if $config{debug}->{val}; - } -} - -# Accepts a DB connection name and a (string) query. Returns a $sth that's been -# executed. -sub do_query { - my ( $cxn, $query ) = @_; - - return undef if $file; - - # Test if the cxn should not even be tried - return undef if $dbhs{$cxn} - && $dbhs{$cxn}->{err_count} - && ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} ) - && $dbhs{$cxn}->{wake_up} > $clock; - - my $sth; - my $retries = 1; - my $success = 0; - TRY: - while ( $retries-- >= 0 && !$success ) { - - eval { - my $dbh = connect_to_db($cxn); - - $sth = $dbh->prepare($query); - $sth->execute(); - $success = 1; - }; - if ( $EVAL_ERROR ) { - if ( $EVAL_ERROR =~ m/$nonfatal_errs/ ) { - handle_cxn_error($cxn, $EVAL_ERROR); - } - else { - die $EVAL_ERROR; - } - if ( $retries < 0 ) { - $sth = undef; - } - } - } - - return $sth; -} - -sub get_uptime { - my ( $cxn ) = @_; - $dbhs{$cxn}->{start_time} ||= time(); - # Avoid dividing by zero - return (time() - $dbhs{$cxn}->{start_time}) || .001; -} - -sub connect_to_db { - my ( $cxn ) = @_; - - $dbhs{$cxn} ||= { - stmts => {}, # bucket for prepared statements. - prev_sleep => 0, - this_sleep => 1, - wake_up => 0, - start_time => 0, - dbh => undef, - }; - my $href = $dbhs{$cxn}; - - if ( !$href->{dbh} || ref($href->{dbh}) !~ m/DBI/ || !$href->{dbh}->ping ) { - my $dbh = get_new_db_connection($cxn); - @{$href}{qw(dbh err_count wake_up this_sleep start_time prev_sleep)} - = ($dbh, 0, 0, 1, 0, 0); - - # Derive and store the server's start time in hi-res - my $uptime = $dbh->selectrow_hashref("show status like 'Uptime'")->{value}; - $href->{start_time} = time() - $uptime; - - # Set timeouts so an unused connection stays alive. - # For example, a connection might be used in Q mode but idle in T mode. - if ( version_ge($dbh, '4.0.3')) { - my $timeout = $config{cxn_timeout}->{val}; - $dbh->do("set session wait_timeout=$timeout, interactive_timeout=$timeout"); - } - } - return $href->{dbh}; -} - -# Compares versions like 5.0.27 and 4.1.15-standard-log -sub version_ge { - my ( $dbh, $target ) = @_; - my $version = sprintf('%03d%03d%03d', $dbh->{mysql_serverinfo} =~ m/(\d+)/g); - return $version ge sprintf('%03d%03d%03d', $target =~ m/(\d+)/g); -} - -# Extracts status values that can be gleaned from the DBD driver without doing a whole query. -sub get_driver_status { - my @cxns = @_; - if ( !$info_gotten{driver_status}++ ) { - foreach my $cxn ( @cxns ) { - next unless $dbhs{$cxn} && $dbhs{$cxn}->{dbh} && $dbhs{$cxn}->{dbh}->{Active}; - $vars{$cxn}->{$clock} ||= {}; - my $vars = $vars{$cxn}->{$clock}; - my %res = map { $_ =~ s/ +/_/g; $_ } $dbhs{$cxn}->{dbh}->{mysql_stat} =~ m/(\w[^:]+): ([\d\.]+)/g; - map { $vars->{$_} ||= $res{$_} } keys %res; - $vars->{Uptime_hires} ||= get_uptime($cxn); - $vars->{cxn} = $cxn; - } - } -} - -sub get_new_db_connection { - my ( $connection, $destroy ) = @_; - if ( $file ) { - die "You can't connect to a MySQL server while monitoring a file. This is probably a bug."; - } - - my $dsn = $connections{$connection} - or die "No connection named '$connection' is defined in your configuration"; - - if ( !defined $dsn->{have_user} ) { - my $answer = prompt("Do you want to specify a username for $connection?", undef, 'n'); - $dsn->{have_user} = $answer && $answer =~ m/1|y/i; - } - - if ( !defined $dsn->{have_pass} ) { - my $answer = prompt("Do you want to specify a password for $connection?", undef, 'n'); - $dsn->{have_pass} = $answer && $answer =~ m/1|y/i; - } - - if ( !$dsn->{user} && $dsn->{have_user} ) { - my $user = $ENV{USERNAME} || $ENV{USER} || getlogin() || getpwuid($REAL_USER_ID) || undef; - $dsn->{user} = prompt("Enter username for $connection", undef, $user); - } - - if ( !defined $dsn->{user} ) { - $dsn->{user} = ''; - } - - if ( !$dsn->{pass} && !$dsn->{savepass} && $dsn->{have_pass} ) { - $dsn->{pass} = prompt_noecho("Enter password for '$dsn->{user}' on $connection"); - print "\n"; - if ( !defined($dsn->{savepass}) ) { - my $answer = prompt("Save password in plain text in the config file?", undef, 'y'); - $dsn->{savepass} = $answer && $answer =~ m/1|y/i; - } - } - - my $dbh = DBI->connect( - $dsn->{dsn}, $dsn->{user}, $dsn->{pass}, - { RaiseError => 1, PrintError => 0, AutoCommit => 1 }); - $dbh->{InactiveDestroy} = 1 unless $destroy; # Can't be set in $db_options - $dbh->{FetchHashKeyName} = 'NAME_lc'; # Lowercases all column names for fetchrow_hashref - return $dbh; -} - -sub get_cxn_errors { - my @cxns = @_; - return () unless $config{show_cxn_errors_in_tbl}->{val}; - return - map { [ $_ . ': ' . $dbhs{$_}->{last_err}, 'red' ] } - grep { $dbhs{$_} && $dbhs{$_}->{err_count} && $dbhs{$_}->{mode} eq $config{mode}->{val} } - @cxns; -} - -# Setup and tear-down functions {{{2 - -# Takes a string and turns it into a hashref you can apply to %tbl_meta tables. The string -# can be in the form 'foo, bar, foo/bar, foo as bar' much like a SQL SELECT statement. -sub compile_select_stmt { - my ($str) = @_; - my @exps = $str =~ m/\s*([^,]+(?i:\s+as\s+[^,\s]+)?)\s*(?=,|$)/g; - my %cols; - my @visible; - foreach my $exp ( @exps ) { - my ( $text, $colname ); - if ( $exp =~ m/as\s+(\w+)\s*/ ) { - $colname = $1; - $exp =~ s/as\s+(\w+)\s*//; - $text = $exp; - } - else { - $text = $colname = $exp; - } - my ($func, $err) = compile_expr($text); - $cols{$colname} = { - src => $text, - hdr => $colname, - num => 0, - func => $func, - }; - push @visible, $colname; - } - return (\%cols, \@visible); -} - -# compile_filter {{{3 -sub compile_filter { - my ( $text ) = @_; - my ( $sub, $err ); - eval "\$sub = sub { my \$set = shift; $text }"; - if ( $EVAL_ERROR ) { - $EVAL_ERROR =~ s/at \(eval.*$//; - $sub = sub { return $EVAL_ERROR }; - $err = $EVAL_ERROR; - } - return ( $sub, $err ); -} - -# compile_expr {{{3 -sub compile_expr { - my ( $expr ) = @_; - # Leave built-in functions alone so they get called as Perl functions, unless - # they are the only word in $expr, in which case treat them as hash keys. - if ( $expr =~ m/\W/ ) { - $expr =~ s/(?{$1}"/eg; - } - else { - $expr = "\$set->{$expr}"; - } - my ( $sub, $err ); - my $quoted = quotemeta($expr); - eval qq{ - \$sub = sub { - my (\$set, \$cur, \$pre) = \@_; - my \$val = eval { $expr }; - if ( \$EVAL_ERROR && \$config{debug}->{val} ) { - \$EVAL_ERROR =~ s/ at \\(eval.*//s; - die "\$EVAL_ERROR in expression $quoted"; - } - return \$val; - } - }; - if ( $EVAL_ERROR ) { - if ( $config{debug}->{val} ) { - die $EVAL_ERROR; - } - $EVAL_ERROR =~ s/ at \(eval.*$//; - $sub = sub { return $EVAL_ERROR }; - $err = $EVAL_ERROR; - } - return ( $sub, $err ); -} - -# finish {{{3 -# This is a subroutine because it's called from a key to quit the program. -sub finish { - save_config(); - ReadMode('normal') unless $opts{n}; - print "\n"; - exit(0); -} - -# core_dump {{{3 -sub core_dump { - my $msg = shift; - if ($config{debugfile}->{val} && $config{debug}->{val}) { - eval { - open my $file, '>>', $config{debugfile}->{val}; - if ( %vars ) { - print $file "Current variables:\n" . Dumper(\%vars); - } - close $file; - }; - } - print $msg; -} - -# load_config {{{3 -sub load_config { - - my $filename = $opts{c} || "$homepath/.innotop/innotop.ini"; - my $dirname = dirname($filename); - if ( -f $dirname && !$opts{c} ) { - # innotop got upgraded and this is the old config file. - my $answer = pause("Innotop's default config location has moved to $filename. Move old config file $dirname there now? y/n"); - if ( lc $answer eq 'y' ) { - rename($dirname, "$homepath/innotop.ini") - or die "Can't rename '$dirname': $OS_ERROR"; - mkdir($dirname) or die "Can't create directory '$dirname': $OS_ERROR"; - mkdir("$dirname/plugins") or die "Can't create directory '$dirname/plugins': $OS_ERROR"; - rename("$homepath/innotop.ini", $filename) - or die "Can't rename '$homepath/innotop.ini' to '$filename': $OS_ERROR"; - } - else { - print "\nInnotop will now exit so you can fix the config file.\n"; - exit(0); - } - } - - if ( ! -d $dirname ) { - mkdir $dirname - or die "Can't create directory '$dirname': $OS_ERROR"; - } - if ( ! -d "$dirname/plugins" ) { - mkdir "$dirname/plugins" - or die "Can't create directory '$dirname/plugins': $OS_ERROR"; - } - - if ( -f $filename ) { - open my $file, "<", $filename or die("Can't open '$filename': $OS_ERROR"); - - # Check config file version. Just ignore if either innotop or the file has - # garbage in the version number. - if ( defined(my $line = <$file>) && $VERSION =~ m/\d/ ) { - chomp $line; - if ( my ($maj, $min, $rev) = $line =~ m/^version=(\d+)\.(\d+)(?:\.(\d+))?$/ ) { - $rev ||= 0; - my $cfg_ver = sprintf('%03d-%03d-%03d', $maj, $min, $rev); - ( $maj, $min, $rev ) = $VERSION =~ m/^(\d+)\.(\d+)(?:\.(\d+))?$/; - $rev ||= 0; - my $innotop_ver = sprintf('%03d-%03d-%03d', $maj, $min, $rev); - - if ( $cfg_ver gt $innotop_ver ) { - pause("The config file is for a newer version of innotop and may not be read correctly."); - } - else { - my @ver_history = @config_versions; - while ( my ($start, $end) = splice(@ver_history, 0, 2) ) { - # If the config file is between the endpoints and innotop is greater than - # the endpoint, innotop has a newer config file format than the file. - if ( $cfg_ver ge $start && $cfg_ver lt $end && $innotop_ver ge $end ) { - my $msg = "innotop's config file format has changed. Overwrite $filename? y or n"; - if ( pause($msg) eq 'n' ) { - $config{readonly}->{val} = 1; - print "\ninnotop will not save any configuration changes you make."; - pause(); - print "\n"; - } - close $file; - return; - } - } - } - } - } - - while ( my $line = <$file> ) { - chomp $line; - next unless $line =~ m/^\[([a-z_]+)\]$/; - if ( exists $config_file_sections{$1} ) { - $config_file_sections{$1}->{reader}->($file); - } - else { - warn "Unknown config file section '$1'"; - } - } - close $file or die("Can't close $filename: $OS_ERROR"); - } - -} - -# Do some post-processing on %tbl_meta: compile src properties into func etc. -sub post_process_tbl_meta { - foreach my $table ( values %tbl_meta ) { - foreach my $col_name ( keys %{$table->{cols}} ) { - my $col_def = $table->{cols}->{$col_name}; - my ( $sub, $err ) = compile_expr($col_def->{src}); - $col_def->{func} = $sub; - } - } -} - -# load_config_plugins {{{3 -sub load_config_plugins { - my ( $file ) = @_; - - # First, find a list of all plugins that exist on disk, and get information about them. - my $dir = $config{plugin_dir}->{val}; - foreach my $p_file ( <$dir/*.pm> ) { - my ($package, $desc); - eval { - open my $p_in, "<", $p_file or die $OS_ERROR; - while ( my $line = <$p_in> ) { - chomp $line; - if ( $line =~ m/^package\s+(.*?);/ ) { - $package = $1; - } - elsif ( $line =~ m/^# description: (.*)/ ) { - $desc = $1; - } - last if $package && $desc; - } - close $p_in; - }; - if ( $package ) { - $plugins{$package} = { - file => $p_file, - desc => $desc, - class => $package, - active => 0, - }; - if ( $config{debug}->{val} && $EVAL_ERROR ) { - die $EVAL_ERROR; - } - } - } - - # Now read which ones the user has activated. Each line simply represents an active plugin. - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - next unless $line && $plugins{$line}; - - my $obj; - eval { - require $plugins{$line}->{file}; - $obj = $line->new(%pluggable_vars); - foreach my $event ( $obj->register_for_events() ) { - my $queue = $event_listener_for{$event}; - if ( $queue ) { - push @$queue, $obj; - } - } - }; - if ( $config{debug}->{val} && $EVAL_ERROR ) { - die $EVAL_ERROR; - } - if ( $obj ) { - $plugins{$line}->{active} = 1; - $plugins{$line}->{object} = $obj; - } - } -} - -# save_config_plugins {{{3 -sub save_config_plugins { - my $file = shift; - foreach my $class ( sort keys %plugins ) { - next unless $plugins{$class}->{active}; - print $file "$class\n"; - } -} - -# load_config_active_server_groups {{{3 -sub load_config_active_server_groups { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $mode, $group ) = $line =~ m/^(.*?)=(.*)$/; - next unless $mode && $group - && exists $modes{$mode} && exists $server_groups{$group}; - $modes{$mode}->{server_group} = $group; - } -} - -# save_config_active_server_groups {{{3 -sub save_config_active_server_groups { - my $file = shift; - foreach my $mode ( sort keys %modes ) { - print $file "$mode=$modes{$mode}->{server_group}\n"; - } -} - -# load_config_server_groups {{{3 -sub load_config_server_groups { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $name, $rest ) = $line =~ m/^(.*?)=(.*)$/; - next unless $name && $rest; - my @vars = unique(grep { $_ && exists $connections{$_} } split(/\s+/, $rest)); - next unless @vars; - $server_groups{$name} = \@vars; - } -} - -# save_config_server_groups {{{3 -sub save_config_server_groups { - my $file = shift; - foreach my $set ( sort keys %server_groups ) { - print $file "$set=", join(' ', @{$server_groups{$set}}), "\n"; - } -} - -# load_config_varsets {{{3 -sub load_config_varsets { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $name, $rest ) = $line =~ m/^(.*?)=(.*)$/; - next unless $name && $rest; - $var_sets{$name} = { - text => $rest, - user => 1, - }; - } -} - -# save_config_varsets {{{3 -sub save_config_varsets { - my $file = shift; - foreach my $varset ( sort keys %var_sets ) { - next unless $var_sets{$varset}->{user}; - print $file "$varset=$var_sets{$varset}->{text}\n"; - } -} - -# load_config_group_by {{{3 -sub load_config_group_by { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $tbl , $rest ) = $line =~ m/^(.*?)=(.*)$/; - next unless $tbl && exists $tbl_meta{$tbl}; - my @parts = unique(grep { exists($tbl_meta{$tbl}->{cols}->{$_}) } split(/\s+/, $rest)); - $tbl_meta{$tbl}->{group_by} = [ @parts ]; - $tbl_meta{$tbl}->{cust}->{group_by} = 1; - } -} - -# save_config_group_by {{{3 -sub save_config_group_by { - my $file = shift; - foreach my $tbl ( sort keys %tbl_meta ) { - next if $tbl_meta{$tbl}->{temp}; - next unless $tbl_meta{$tbl}->{cust}->{group_by}; - my $aref = $tbl_meta{$tbl}->{group_by}; - print $file "$tbl=", join(' ', @$aref), "\n"; - } -} - -# load_config_filters {{{3 -sub load_config_filters { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $key, $rest ) = $line =~ m/^(.+?)=(.*)$/; - next unless $key && $rest; - - my %parts = $rest =~ m/(\w+)='((?:(?!(? $sub, - text => $parts{text}, - user => 1, - name => $key, - note => 'User-defined filter', - tbls => \@tbls, - } - } -} - -# save_config_filters {{{3 -sub save_config_filters { - my $file = shift; - foreach my $key ( sort keys %filters ) { - next if !$filters{$key}->{user} || $filters{$key}->{quick}; - my $text = $filters{$key}->{text}; - $text =~ s/([\\'])/\\$1/g; - my $tbls = join(" ", @{$filters{$key}->{tbls}}); - print $file "$key=text='$text' tbls='$tbls'\n"; - } -} - -# load_config_visible_tables {{{3 -sub load_config_visible_tables { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $mode, $rest ) = $line =~ m/^(.*?)=(.*)$/; - next unless $mode && exists $modes{$mode}; - $modes{$mode}->{visible_tables} = - [ unique(grep { $_ && exists $tbl_meta{$_} } split(/\s+/, $rest)) ]; - $modes{$mode}->{cust}->{visible_tables} = 1; - } -} - -# save_config_visible_tables {{{3 -sub save_config_visible_tables { - my $file = shift; - foreach my $mode ( sort keys %modes ) { - next unless $modes{$mode}->{cust}->{visible_tables}; - my $tables = $modes{$mode}->{visible_tables}; - print $file "$mode=", join(' ', @$tables), "\n"; - } -} - -# load_config_sort_cols {{{3 -sub load_config_sort_cols { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $key , $rest ) = $line =~ m/^(.*?)=(.*)$/; - next unless $key && exists $tbl_meta{$key}; - $tbl_meta{$key}->{sort_cols} = $rest; - $tbl_meta{$key}->{cust}->{sort_cols} = 1; - $tbl_meta{$key}->{sort_func} = make_sort_func($tbl_meta{$key}); - } -} - -# save_config_sort_cols {{{3 -sub save_config_sort_cols { - my $file = shift; - foreach my $tbl ( sort keys %tbl_meta ) { - next unless $tbl_meta{$tbl}->{cust}->{sort_cols}; - my $col = $tbl_meta{$tbl}->{sort_cols}; - print $file "$tbl=$col\n"; - } -} - -# load_config_active_filters {{{3 -sub load_config_active_filters { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $tbl , $rest ) = $line =~ m/^(.*?)=(.*)$/; - next unless $tbl && exists $tbl_meta{$tbl}; - my @parts = unique(grep { exists($filters{$_}) } split(/\s+/, $rest)); - @parts = grep { grep { $tbl eq $_ } @{$filters{$_}->{tbls}} } @parts; - $tbl_meta{$tbl}->{filters} = [ @parts ]; - $tbl_meta{$tbl}->{cust}->{filters} = 1; - } -} - -# save_config_active_filters {{{3 -sub save_config_active_filters { - my $file = shift; - foreach my $tbl ( sort keys %tbl_meta ) { - next if $tbl_meta{$tbl}->{temp}; - next unless $tbl_meta{$tbl}->{cust}->{filters}; - my $aref = $tbl_meta{$tbl}->{filters}; - print $file "$tbl=", join(' ', @$aref), "\n"; - } -} - -# load_config_active_columns {{{3 -sub load_config_active_columns { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $key , $rest ) = $line =~ m/^(.*?)=(.*)$/; - next unless $key && exists $tbl_meta{$key}; - my @parts = grep { exists($tbl_meta{$key}->{cols}->{$_}) } unique split(/ /, $rest); - $tbl_meta{$key}->{visible} = [ @parts ]; - $tbl_meta{$key}->{cust}->{visible} = 1; - } -} - -# save_config_active_columns {{{3 -sub save_config_active_columns { - my $file = shift; - foreach my $tbl ( sort keys %tbl_meta ) { - next unless $tbl_meta{$tbl}->{cust}->{visible}; - my $aref = $tbl_meta{$tbl}->{visible}; - print $file "$tbl=", join(' ', @$aref), "\n"; - } -} - -# save_config_tbl_meta {{{3 -sub save_config_tbl_meta { - my $file = shift; - foreach my $tbl ( sort keys %tbl_meta ) { - foreach my $col ( keys %{$tbl_meta{$tbl}->{cols}} ) { - my $meta = $tbl_meta{$tbl}->{cols}->{$col}; - next unless $meta->{user}; - print $file "$col=", join( - " ", - map { - # Some properties (trans) are arrays, others scalars - my $val = ref($meta->{$_}) ? join(',', @{$meta->{$_}}) : $meta->{$_}; - $val =~ s/([\\'])/\\$1/g; # Escape backslashes and single quotes - "$_='$val'"; # Enclose in single quotes - } - grep { $_ ne 'func' } - keys %$meta - ), "\n"; - } - } -} - -# save_config_config {{{3 -sub save_config_config { - my $file = shift; - foreach my $key ( sort keys %config ) { - eval { - if ( $key ne 'password' || $config{savepass}->{val} ) { - print $file "# $config{$key}->{note}\n" - or die "Cannot print to file: $OS_ERROR"; - my $val = $config{$key}->{val}; - $val = '' unless defined($val); - if ( ref( $val ) eq 'ARRAY' ) { - print $file "$key=" - . join( " ", @$val ) . "\n" - or die "Cannot print to file: $OS_ERROR"; - } - elsif ( ref( $val ) eq 'HASH' ) { - print $file "$key=" - . join( " ", - map { "$_:$val->{$_}" } keys %$val - ) . "\n"; - } - else { - print $file "$key=$val\n"; - } - } - }; - if ( $EVAL_ERROR ) { print "$EVAL_ERROR in $key"; }; - } - -} - -# load_config_config {{{3 -sub load_config_config { - my ( $file ) = @_; - - # Look in the command-line parameters for things stored in the same slot. - my %cmdline = - map { $_->{c} => $opts{$_->{k}} } - grep { exists $_->{c} && exists $opts{$_->{k}} } - @opt_spec; - - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $name, $val ) = $line =~ m/^(.+?)=(.*)$/; - next unless defined $name && defined $val; - - # Values might already have been set at the command line. - $val = defined($cmdline{$name}) ? $cmdline{$name} : $val; - - # Validate the incoming values... - if ( $name && exists( $config{$name} ) ) { - if ( !$config{$name}->{pat} || $val =~ m/$config{$name}->{pat}/ ) { - $config{$name}->{val} = $val; - $config{$name}->{read} = 1; - } - } - } -} - -# load_config_tbl_meta {{{3 -sub load_config_tbl_meta { - my ( $file ) = @_; - - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - # Each tbl_meta section has all the properties defined in %col_props. - my ( $col , $rest ) = $line =~ m/^(.*?)=(.*)$/; - next unless $col; - my %parts = $rest =~ m/(\w+)='((?:(?!(?{cols}->{$col} ||= {}; - - foreach my $prop ( keys %col_props ) { - if ( !defined($parts{$prop}) ) { - die "Undefined property $prop for column $col in table $tbl"; - } - - # Un-escape escaping - $parts{$prop} =~ s/\\\\/\\/g; - $parts{$prop} =~ s/\\'/'/g; - - if ( ref $col_props{$prop} ) { - if ( $prop eq 'trans' ) { - $meta->{cols}->{$col}->{trans} - = [ unique(grep { exists $trans_funcs{$_} } split(',', $parts{$prop})) ]; - } - else { - $meta->{cols}->{$col}->{$prop} = [ split(',', $parts{$prop}) ]; - } - } - else { - $meta->{cols}->{$col}->{$prop} = $parts{$prop}; - } - } - - } -} - -# save_config {{{3 -sub save_config { - return if $config{readonly}->{val}; - # Save to a temp file first, so a crash doesn't destroy the main config file - my $newname = $opts{c} || "$homepath/.innotop/innotop.ini"; - my $filename = $newname . '_tmp'; - open my $file, "+>", $filename - or die("Can't write to $filename: $OS_ERROR"); - print $file "version=$VERSION\n"; - - foreach my $section ( @ordered_config_file_sections ) { - die "No such config file section $section" unless $config_file_sections{$section}; - print $file "\n[$section]\n\n"; - $config_file_sections{$section}->{writer}->($file); - print $file "\n[/$section]\n"; - } - - # Now clobber the main config file with the temp. - close $file or die("Can't close $filename: $OS_ERROR"); - rename($filename, $newname) or die("Can't rename $filename to $newname: $OS_ERROR"); -} - -# load_config_connections {{{3 -sub load_config_connections { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $key , $rest ) = $line =~ m/^(.*?)=(.*)$/; - next unless $key; - my %parts = $rest =~ m/(\S+?)=(\S*)/g; - my %conn = map { $_ => $parts{$_} || '' } @conn_parts; - $connections{$key} = \%conn; - } -} - -# save_config_connections {{{3 -sub save_config_connections { - my $file = shift; - foreach my $conn ( sort keys %connections ) { - my $href = $connections{$conn}; - my @keys = $href->{savepass} ? @conn_parts : grep { $_ ne 'pass' } @conn_parts; - print $file "$conn=", join(' ', map { "$_=$href->{$_}" } grep { defined $href->{$_} } @keys), "\n"; - } -} - -sub load_config_colors { - my ( $file ) = @_; - my %rule_set_for; - - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $tbl, $rule ) = $line =~ m/^(.*?)=(.*)$/; - next unless $tbl && $rule; - next unless exists $tbl_meta{$tbl}; - my %parts = $rule =~ m/(\w+)='((?:(?!(?{cols}->{$parts{col}}; - next unless $parts{op} && exists $comp_ops{$parts{op}}; - next unless defined $parts{arg}; - next unless defined $parts{color}; - my @colors = unique(grep { exists $ansicolors{$_} } split(/\W+/, $parts{color})); - next unless @colors; - - # Finally! Enough validation... - $rule_set_for{$tbl} ||= []; - push @{$rule_set_for{$tbl}}, \%parts; - } - - foreach my $tbl ( keys %rule_set_for ) { - $tbl_meta{$tbl}->{colors} = $rule_set_for{$tbl}; - $tbl_meta{$tbl}->{color_func} = make_color_func($tbl_meta{$tbl}); - $tbl_meta{$tbl}->{cust}->{colors} = 1; - } -} - -# save_config_colors {{{3 -sub save_config_colors { - my $file = shift; - foreach my $tbl ( sort keys %tbl_meta ) { - my $meta = $tbl_meta{$tbl}; - next unless $meta->{cust}->{colors}; - foreach my $rule ( @{$meta->{colors}} ) { - print $file "$tbl=", join( - ' ', - map { - my $val = $rule->{$_}; - $val =~ s/([\\'])/\\$1/g; # Escape backslashes and single quotes - "$_='$val'"; # Enclose in single quotes - } - qw(col op arg color) - ), "\n"; - } - } -} - -# load_config_active_connections {{{3 -sub load_config_active_connections { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $key , $rest ) = $line =~ m/^(.*?)=(.*)$/; - next unless $key && exists $modes{$key}; - my @parts = grep { exists $connections{$_} } split(/ /, $rest); - $modes{$key}->{connections} = [ @parts ] if exists $modes{$key}; - } -} - -# save_config_active_connections {{{3 -sub save_config_active_connections { - my $file = shift; - foreach my $mode ( sort keys %modes ) { - my @connections = get_connections($mode); - print $file "$mode=", join(' ', @connections), "\n"; - } -} - -# load_config_stmt_sleep_times {{{3 -sub load_config_stmt_sleep_times { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $key , $val ) = split('=', $line); - next unless $key && defined $val && $val =~ m/$num_regex/; - $stmt_sleep_time_for{$key} = $val; - } -} - -# save_config_stmt_sleep_times {{{3 -sub save_config_stmt_sleep_times { - my $file = shift; - foreach my $key ( sort keys %stmt_sleep_time_for ) { - print $file "$key=$stmt_sleep_time_for{$key}\n"; - } -} - -# load_config_mvs {{{3 -sub load_config_mvs { - my ( $file ) = @_; - while ( my $line = <$file> ) { - chomp $line; - next if $line =~ m/^#/; - last if $line =~ m/^\[/; - - my ( $key , $val ) = split('=', $line); - next unless $key && defined $val && $val =~ m/$num_regex/; - $mvs{$key} = $val; - } -} - -# save_config_mvs {{{3 -sub save_config_mvs { - my $file = shift; - foreach my $key ( sort keys %mvs ) { - print $file "$key=$mvs{$key}\n"; - } -} - -# edit_configuration {{{3 -sub edit_configuration { - my $key = ''; - while ( $key ne 'q' ) { - $clear_screen_sub->(); - my @display_lines = ''; - - if ( $key && $cfg_editor_action{$key} ) { - $cfg_editor_action{$key}->{func}->(); - } - - # Show help - push @display_lines, create_caption('What configuration do you want to edit?', - create_table2( - [ sort keys %cfg_editor_action ], - { map { $_ => $_ } keys %cfg_editor_action }, - { map { $_ => $cfg_editor_action{$_}->{note} } keys %cfg_editor_action }, - { sep => ' ' })); - - draw_screen(\@display_lines); - $key = pause(''); - } -} - -# edit_configuration_variables {{{3 -sub edit_configuration_variables { - $clear_screen_sub->(); - my $mode = $config{mode}->{val}; - - my %config_choices - = map { $_ => $config{$_}->{note} || '' } - # Only config values that are marked as applying to this mode. - grep { - my $key = $_; - $config{$key}->{conf} && - ( $config{$key}->{conf} eq 'ALL' - || grep { $mode eq $_ } @{$config{$key}->{conf}} ) - } keys %config; - - my $key = prompt_list( - "Enter the name of the variable you wish to configure", - '', - sub{ return keys %config_choices }, - \%config_choices); - - if ( exists($config_choices{$key}) ) { - get_config_interactive($key); - } -} - -# edit_color_rules {{{3 -sub edit_color_rules { - my ( $tbl ) = @_; - $clear_screen_sub->(); - $tbl ||= choose_visible_table(); - if ( $tbl && exists($tbl_meta{$tbl}) ) { - my $meta = $tbl_meta{$tbl}; - my @cols = ('', qw(col op arg color)); - my $info = { map { $_ => { hdr => $_, just => '-', } } @cols }; - $info->{label}->{maxw} = 30; - my $key; - my $selected_rule; - - # This loop builds a tabular view of the rules. - do { - - # Show help - if ( $key && $key eq '?' ) { - my @display_lines = ''; - push @display_lines, create_caption('Editor key mappings', - create_table2( - [ sort keys %color_editor_action ], - { map { $_ => $_ } keys %color_editor_action }, - { map { $_ => $color_editor_action{$_}->{note} } keys %color_editor_action }, - { sep => ' ' })); - draw_screen(\@display_lines); - pause(); - $key = ''; - } - else { - - # Do the action specified - $selected_rule ||= 0; - if ( $key && $color_editor_action{$key} ) { - $selected_rule = $color_editor_action{$key}->{func}->($tbl, $selected_rule); - $selected_rule ||= 0; - } - - # Build the table of rules. If the terminal has color, the selected rule - # will be highlighted; otherwise a > at the left will indicate. - my $data = $meta->{colors} || []; - foreach my $i ( 0..@$data - 1 ) { - $data->[$i]->{''} = $i == $selected_rule ? '>' : ''; - } - my @display_lines = create_table(\@cols, $info, $data); - - # Highlight selected entry - for my $i ( 0 .. $#display_lines ) { - if ( $display_lines[$i] =~ m/^>/ ) { - $display_lines[$i] = [ $display_lines[$i], 'reverse' ]; - } - } - - # Draw the screen and wait for a command. - unshift @display_lines, '', - "Editing color rules for $meta->{capt}. Press ? for help, q to " - . "quit.", ''; - draw_screen(\@display_lines); - print "\n\n", word_wrap('Rules are applied in order from top to ' - . 'bottom. The first matching rule wins and prevents the ' - . 'rest of the rules from being applied.'); - $key = pause(''); - } - } while ( $key ne 'q' ); - $meta->{color_func} = make_color_func($meta); - } -} - -# add_quick_filter {{{3 -sub add_quick_filter { - my $tbl = choose_visible_table(); - if ( $tbl && exists($tbl_meta{$tbl}) ) { - print "\n"; - my $response = prompt_list( - "Enter column name and filter text", - '', - sub { return keys %{$tbl_meta{$tbl}->{cols}} }, - () - ); - my ( $col, $text ) = split(/\s+/, $response, 2); - - # You can't filter on a nonexistent column. But if you filter on a pivoted - # table, the columns are different, so on a pivoted table, allow filtering - # on the 'name' column. - # NOTE: if a table is pivoted and un-pivoted, this will likely cause crashes. - # Currently not an issue since there's no way to toggle pivot/nopivot. - return unless $col && $text && - (exists($tbl_meta{$tbl}->{cols}->{$col}) - || ($tbl_meta{$tbl}->{pivot} && $col eq 'name')); - - my ( $sub, $err ) = compile_filter( "defined \$set->{$col} && \$set->{$col} =~ m/$text/" ); - return if !$sub || $err; - my $name = "quick_$tbl.$col"; - $filters{$name} = { - func => $sub, - text => $text, - user => 1, - quick => 1, - name => $name, - note => 'Quick-filter', - tbls => [$tbl], - }; - push @{$tbl_meta{$tbl}->{filters}}, $name; - } -} - -# clear_quick_filters {{{3 -sub clear_quick_filters { - my $tbl = choose_visible_table( - # Only tables that have quick-filters - sub { - my ( $tbl ) = @_; - return scalar grep { $filters{$_}->{quick} } @{ $tbl_meta{$tbl}->{filters} }; - } - ); - if ( $tbl && exists($tbl_meta{$tbl}) ) { - my @current = @{$tbl_meta{$tbl}->{filters}}; - @current = grep { !$filters{$_}->{quick} } @current; - $tbl_meta{$tbl}->{filters} = \@current; - } -} - -sub edit_plugins { - $clear_screen_sub->(); - - my @cols = ('', qw(class desc active)); - my $info = { map { $_ => { hdr => $_, just => '-', } } @cols }; - my @rows = map { $plugins{$_} } sort keys %plugins; - my $key; - my $selected; - - # This loop builds a tabular view of the plugins. - do { - - # Show help - if ( $key && $key eq '?' ) { - my @display_lines = ''; - push @display_lines, create_caption('Editor key mappings', - create_table2( - [ sort keys %plugin_editor_action ], - { map { $_ => $_ } keys %plugin_editor_action }, - { map { $_ => $plugin_editor_action{$_}->{note} } keys %plugin_editor_action }, - { sep => ' ' })); - draw_screen(\@display_lines); - pause(); - $key = ''; - } - - # Do the action specified - else { - $selected ||= 0; - if ( $key && $plugin_editor_action{$key} ) { - $selected = $plugin_editor_action{$key}->{func}->(\@rows, $selected); - $selected ||= 0; - } - - # Build the table of plugins. - foreach my $row ( 0.. $#rows ) { - $rows[$row]->{''} = $row eq $selected ? '>' : ' '; - } - my @display_lines = create_table(\@cols, $info, \@rows); - - # Highlight selected entry - for my $i ( 0 .. $#display_lines ) { - if ( $display_lines[$i] =~ m/^>/ ) { - $display_lines[$i] = [ $display_lines[$i], 'reverse' ]; - } - } - - # Draw the screen and wait for a command. - unshift @display_lines, '', - "Plugin Management. Press ? for help, q to quit.", ''; - draw_screen(\@display_lines); - $key = pause(''); - } - } while ( $key ne 'q' ); -} - -# edit_table {{{3 -sub edit_table { - $clear_screen_sub->(); - my ( $tbl ) = @_; - $tbl ||= choose_visible_table(); - if ( $tbl && exists($tbl_meta{$tbl}) ) { - my $meta = $tbl_meta{$tbl}; - my @cols = ('', qw(name hdr label src)); - my $info = { map { $_ => { hdr => $_, just => '-', } } @cols }; - $info->{label}->{maxw} = 30; - my $key; - my $selected_column; - - # This loop builds a tabular view of the tbl_meta's structure, showing each column - # in the entry as a row. - do { - - # Show help - if ( $key && $key eq '?' ) { - my @display_lines = ''; - push @display_lines, create_caption('Editor key mappings', - create_table2( - [ sort keys %tbl_editor_action ], - { map { $_ => $_ } keys %tbl_editor_action }, - { map { $_ => $tbl_editor_action{$_}->{note} } keys %tbl_editor_action }, - { sep => ' ' })); - draw_screen(\@display_lines); - pause(); - $key = ''; - } - else { - - # Do the action specified - $selected_column ||= $meta->{visible}->[0]; - if ( $key && $tbl_editor_action{$key} ) { - $selected_column = $tbl_editor_action{$key}->{func}->($tbl, $selected_column); - $selected_column ||= $meta->{visible}->[0]; - } - - # Build the pivoted view of the table's meta-data. If the terminal has color, - # The selected row will be highlighted; otherwise a > at the left will indicate. - my $data = []; - foreach my $row ( @{$meta->{visible}} ) { - my %hash; - @hash{ @cols } = @{$meta->{cols}->{$row}}{@cols}; - $hash{src} = '' if ref $hash{src}; - $hash{name} = $row; - $hash{''} = $row eq $selected_column ? '>' : ' '; - push @$data, \%hash; - } - my @display_lines = create_table(\@cols, $info, $data); - - # Highlight selected entry - for my $i ( 0 .. $#display_lines ) { - if ( $display_lines[$i] =~ m/^>/ ) { - $display_lines[$i] = [ $display_lines[$i], 'reverse' ]; - } - } - - # Draw the screen and wait for a command. - unshift @display_lines, '', - "Editing table definition for $meta->{capt}. Press ? for help, q to quit.", ''; - draw_screen(\@display_lines, { clear => 1 }); - $key = pause(''); - } - } while ( $key ne 'q' ); - } -} - -# choose_mode_tables {{{3 -# Choose which table(s), and in what order, to display in a given mode. -sub choose_mode_tables { - my $mode = $config{mode}->{val}; - my @tbls = @{$modes{$mode}->{visible_tables}}; - my $new = prompt_list( - "Choose tables to display", - join(' ', @tbls), - sub { return @{$modes{$mode}->{tables}} }, - { map { $_ => $tbl_meta{$_}->{capt} } @{$modes{$mode}->{tables}} } - ); - $modes{$mode}->{visible_tables} = - [ unique(grep { $_ && exists $tbl_meta{$_} } split(/\s+/, $new)) ]; - $modes{$mode}->{cust}->{visible_tables} = 1; -} - -# choose_visible_table {{{3 -sub choose_visible_table { - my ( $grep_cond ) = @_; - my $mode = $config{mode}->{val}; - my @tbls - = grep { $grep_cond ? $grep_cond->($_) : 1 } - @{$modes{$mode}->{visible_tables}}; - my $tbl = $tbls[0]; - if ( @tbls > 1 ) { - $tbl = prompt_list( - "Choose a table", - '', - sub { return @tbls }, - { map { $_ => $tbl_meta{$_}->{capt} } @tbls } - ); - } - return $tbl; -} - -sub toggle_aggregate { - my ( $tbl ) = @_; - $tbl ||= choose_visible_table(); - return unless $tbl && exists $tbl_meta{$tbl}; - my $meta = $tbl_meta{$tbl}; - $meta->{aggregate} ^= 1; -} - -sub choose_filters { - my ( $tbl ) = @_; - $tbl ||= choose_visible_table(); - return unless $tbl && exists $tbl_meta{$tbl}; - my $meta = $tbl_meta{$tbl}; - $clear_screen_sub->(); - - print "Choose filters for $meta->{capt}:\n"; - - my $ini = join(' ', @{$meta->{filters}}); - my $val = prompt_list( - 'Choose filters', - $ini, - sub { return keys %filters }, - { - map { $_ => $filters{$_}->{note} } - grep { grep { $tbl eq $_ } @{$filters{$_}->{tbls}} } - keys %filters - } - ); - - my @choices = unique(split(/\s+/, $val)); - foreach my $new ( grep { !exists($filters{$_}) } @choices ) { - my $answer = prompt("There is no filter called '$new'. Create it?", undef, 'y'); - if ( $answer eq 'y' ) { - create_new_filter($new, $tbl); - } - } - @choices = grep { exists $filters{$_} } @choices; - @choices = grep { grep { $tbl eq $_ } @{$filters{$_}->{tbls}} } @choices; - $meta->{filters} = [ @choices ]; - $meta->{cust}->{filters} = 1; -} - -sub choose_group_cols { - my ( $tbl ) = @_; - $tbl ||= choose_visible_table(); - return unless $tbl && exists $tbl_meta{$tbl}; - $clear_screen_sub->(); - my $meta = $tbl_meta{$tbl}; - my $curr = join(', ', @{$meta->{group_by}}); - my $val = prompt_list( - 'Group-by columns', - $curr, - sub { return keys %{$meta->{cols}} }, - { map { $_ => $meta->{cols}->{$_}->{label} } keys %{$meta->{cols}} }); - if ( $curr ne $val ) { - $meta->{group_by} = [ grep { exists $meta->{cols}->{$_} } $val =~ m/(\w+)/g ]; - $meta->{cust}->{group_by} = 1; - } -} - -sub choose_sort_cols { - my ( $tbl ) = @_; - $tbl ||= choose_visible_table(); - return unless $tbl && exists $tbl_meta{$tbl}; - $clear_screen_sub->(); - my $meta = $tbl_meta{$tbl}; - - my ( $cols, $hints ); - if ( $meta->{pivot} ) { - $cols = sub { qw(name set_0) }; - $hints = { name => 'name', set_0 => 'set_0' }; - } - else { - $cols = sub { return keys %{$meta->{cols}} }; - $hints = { map { $_ => $meta->{cols}->{$_}->{label} } keys %{$meta->{cols}} }; - } - - my $val = prompt_list( - 'Sort columns (reverse sort with -col)', - $meta->{sort_cols}, - $cols, - $hints ); - if ( $meta->{sort_cols} ne $val ) { - $meta->{sort_cols} = $val; - $meta->{cust}->{sort_cols} = 1; - $tbl_meta{$tbl}->{sort_func} = make_sort_func($tbl_meta{$tbl}); - } -} - -# create_new_filter {{{3 -sub create_new_filter { - my ( $filter, $tbl ) = @_; - $clear_screen_sub->(); - - if ( !$filter || $filter =~ m/\W/ ) { - print word_wrap("Choose a name for the filter. This name is not displayed, and is only used " - . "for internal reference. It can only contain lowercase letters, numbers, and underscores."); - print "\n\n"; - do { - $filter = prompt("Enter filter name"); - } while ( !$filter || $filter =~ m/\W/ ); - } - - my $completion = sub { keys %{$tbl_meta{$tbl}->{cols}} }; - my ( $err, $sub, $body ); - do { - $clear_screen_sub->(); - print word_wrap("A filter is a Perl subroutine that accepts a hashref of columns " - . "called \$set, and returns a true value if the filter accepts the row. Example:\n" - . " \$set->{active_secs} > 5\n" - . "will only allow rows if their active_secs column is greater than 5."); - print "\n\n"; - if ( $err ) { - print "There's an error in your filter expression: $err\n\n"; - } - $body = prompt("Enter subroutine body", undef, undef, $completion); - ( $sub, $err ) = compile_filter($body); - } while ( $err ); - - $filters{$filter} = { - func => $sub, - text => $body, - user => 1, - name => $filter, - note => 'User-defined filter', - tbls => [$tbl], - }; -} - -# get_config_interactive {{{3 -sub get_config_interactive { - my $key = shift; - $clear_screen_sub->(); - - # Print help first. - print "Enter a new value for '$key' ($config{$key}->{note}).\n"; - - my $current = ref($config{$key}->{val}) ? join(" ", @{$config{$key}->{val}}) : $config{$key}->{val}; - - my $new_value = prompt('Enter a value', $config{$key}->{pat}, $current); - $config{$key}->{val} = $new_value; -} - -sub edit_current_var_set { - my $mode = $config{mode}->{val}; - my $name = $config{"${mode}_set"}->{val}; - my $variables = $var_sets{$name}->{text}; - - my $new = $variables; - do { - $clear_screen_sub->(); - $new = prompt("Enter variables for $name", undef, $variables); - } until ( $new ); - - if ( $new ne $variables ) { - @{$var_sets{$name}}{qw(text user)} = ( $new, 1); - } -} - - -sub choose_var_set { - my ( $key ) = @_; - $clear_screen_sub->(); - - my $new_value = prompt_list( - 'Choose a set of values to display, or enter the name of a new one', - $config{$key}->{val}, - sub { return keys %var_sets }, - { map { $_ => $var_sets{$_}->{text} } keys %var_sets }); - - if ( !exists $var_sets{$new_value} ) { - add_new_var_set($new_value); - } - - $config{$key}->{val} = $new_value if exists $var_sets{$new_value}; -} - -sub switch_var_set { - my ( $cfg_var, $dir ) = @_; - my @var_sets = sort keys %var_sets; - my $cur = $config{$cfg_var}->{val}; - my $pos = grep { $_ lt $cur } @var_sets; - my $newpos = ($pos + $dir) % @var_sets; - $config{$cfg_var}->{val} = $var_sets[$newpos]; - $clear_screen_sub->(); -} - -# Online configuration and prompting functions {{{2 - -# edit_stmt_sleep_times {{{3 -sub edit_stmt_sleep_times { - $clear_screen_sub->(); - my $stmt = prompt_list('Specify a statement', '', sub { return sort keys %stmt_maker_for }); - return unless $stmt && exists $stmt_maker_for{$stmt}; - $clear_screen_sub->(); - my $curr_val = $stmt_sleep_time_for{$stmt} || 0; - my $new_val = prompt('Specify a sleep delay after calling this SQL', $num_regex, $curr_val); - if ( $new_val ) { - $stmt_sleep_time_for{$stmt} = $new_val; - } - else { - delete $stmt_sleep_time_for{$stmt}; - } -} - -# edit_server_groups {{{3 -# Choose which server connections are in a server group. First choose a group, -# then choose which connections are in it. -sub edit_server_groups { - $clear_screen_sub->(); - my $mode = $config{mode}->{val}; - my $group = $modes{$mode}->{server_group}; - my %curr = %server_groups; - my $new = choose_or_create_server_group($group, 'to edit'); - $clear_screen_sub->(); - if ( exists $curr{$new} ) { - # Don't do this step if the user just created a new server group, - # because part of that process was to choose connections. - my $cxns = join(' ', @{$server_groups{$new}}); - my @conns = choose_or_create_connection($cxns, 'for this group'); - $server_groups{$new} = \@conns; - } -} - -# choose_server_groups {{{3 -sub choose_server_groups { - $clear_screen_sub->(); - my $mode = $config{mode}->{val}; - my $group = $modes{$mode}->{server_group}; - my $new = choose_or_create_server_group($group, 'for this mode'); - $modes{$mode}->{server_group} = $new if exists $server_groups{$new}; -} - -sub choose_or_create_server_group { - my ( $group, $prompt ) = @_; - my $new = ''; - - my @available = sort keys %server_groups; - - if ( @available ) { - print "You can enter the name of a new group to create it.\n"; - - $new = prompt_list( - "Choose a server group $prompt", - $group, - sub { return @available }, - { map { $_ => join(' ', @{$server_groups{$_}}) } @available }); - - $new =~ s/\s.*//; - - if ( !exists $server_groups{$new} ) { - my $answer = prompt("There is no server group called '$new'. Create it?", undef, "y"); - if ( $answer eq 'y' ) { - add_new_server_group($new); - } - } - } - else { - $new = add_new_server_group(); - } - return $new; -} - -sub choose_or_create_connection { - my ( $cxns, $prompt ) = @_; - print "You can enter the name of a new connection to create it.\n"; - - my @available = sort keys %connections; - my $new_cxns = prompt_list( - "Choose connections $prompt", - $cxns, - sub { return @available }, - { map { $_ => $connections{$_}->{dsn} } @available }); - - my @new = unique(grep { !exists $connections{$_} } split(/\s+/, $new_cxns)); - foreach my $new ( @new ) { - my $answer = prompt("There is no connection called '$new'. Create it?", undef, "y"); - if ( $answer eq 'y' ) { - add_new_dsn($new); - } - } - - return unique(grep { exists $connections{$_} } split(/\s+/, $new_cxns)); -} - -# choose_servers {{{3 -sub choose_servers { - $clear_screen_sub->(); - my $mode = $config{mode}->{val}; - my $cxns = join(' ', get_connections()); - my @chosen = choose_or_create_connection($cxns, 'for this mode'); - $modes{$mode}->{connections} = \@chosen; - $modes{$mode}->{server_group} = ''; # Clear this because it overrides {connections} -} - -# display_license {{{3 -sub display_license { - $clear_screen_sub->(); - - print $innotop_license; - - pause(); -} - -# Data-retrieval functions {{{2 -# get_status_info {{{3 -# Get SHOW STATUS and SHOW VARIABLES together. -sub get_status_info { - my @cxns = @_; - if ( !$info_gotten{status}++ ) { - foreach my $cxn ( @cxns ) { - $vars{$cxn}->{$clock} ||= {}; - my $vars = $vars{$cxn}->{$clock}; - - my $sth = do_stmt($cxn, 'SHOW_STATUS') or next; - my $res = $sth->fetchall_arrayref(); - map { $vars->{$_->[0]} = $_->[1] || 0 } @$res; - - # Calculate hi-res uptime and add cxn to the hash. This duplicates get_driver_status, - # but it's most important to have consistency. - $vars->{Uptime_hires} ||= get_uptime($cxn); - $vars->{cxn} = $cxn; - - # Add SHOW VARIABLES to the hash - $sth = do_stmt($cxn, 'SHOW_VARIABLES') or next; - $res = $sth->fetchall_arrayref(); - map { $vars->{$_->[0]} = $_->[1] || 0 } @$res; - } - } -} - -# Chooses a thread for explaining, killing, etc... -# First arg is a func that can be called in grep. -sub choose_thread { - my ( $grep_cond, $prompt ) = @_; - - # Narrow the list to queries that can be explained. - my %thread_for = map { - # Eliminate innotop's own threads. - $_ => $dbhs{$_}->{dbh} ? $dbhs{$_}->{dbh}->{mysql_thread_id} : 0 - } keys %connections; - - my @candidates = grep { - $_->{id} != $thread_for{$_->{cxn}} && $grep_cond->($_) - } @current_queries; - return unless @candidates; - - # Find out which server. - my @cxns = unique map { $_->{cxn} } @candidates; - my ( $cxn ) = select_cxn('On which server', @cxns); - return unless $cxn && exists($connections{$cxn}); - - # Re-filter the list of candidates to only those on this server - @candidates = grep { $_->{cxn} eq $cxn } @candidates; - - # Find out which thread to do. - my $info; - if ( @candidates > 1 ) { - - # Sort longest-active first, then longest-idle. - my $sort_func = sub { - my ( $a, $b ) = @_; - return $a->{query} && !$b->{query} ? 1 - : $b->{query} && !$a->{query} ? -1 - : ($a->{time} || 0) <=> ($b->{time} || 0); - }; - my @threads = map { $_->{id} } reverse sort { $sort_func->($a, $b) } @candidates; - - print "\n"; - my $thread = prompt_list($prompt, - $threads[0], - sub { return @threads }); - return unless $thread && $thread =~ m/$int_regex/; - - # Find the info hash of that query on that server. - ( $info ) = grep { $thread == $_->{id} } @candidates; - } - else { - $info = $candidates[0]; - } - return $info; -} - -# analyze_query {{{3 -# Allows the user to show fulltext, explain, show optimized... -sub analyze_query { - my ( $action ) = @_; - - my $info = choose_thread( - sub { $_[0]->{query} }, - 'Select a thread to analyze', - ); - return unless $info; - - my %actions = ( - e => \&display_explain, - f => \&show_full_query, - o => \&show_optimized_query, - ); - do { - $actions{$action}->($info); - print "\n"; - $action = pause('Press e to explain, f for full query, o for optimized query'); - } while ( exists($actions{$action}) ); -} - -# inc {{{3 -# Returns the difference between two sets of variables/status/innodb stuff. -sub inc { - my ( $offset, $cxn ) = @_; - my $vars = $vars{$cxn}; - if ( $offset < 0 ) { - return $vars->{$clock}; - } - elsif ( exists $vars{$clock - $offset} && !exists $vars->{$clock - $offset - 1} ) { - return $vars->{$clock - $offset}; - } - my $cur = $vars->{$clock - $offset}; - my $pre = $vars->{$clock - $offset - 1}; - return { - # Numeric variables get subtracted, non-numeric get passed straight through. - map { - $_ => - ( (defined $cur->{$_} && $cur->{$_} =~ m/$num_regex/) - ? $cur->{$_} - ($pre->{$_} || 0) - : $cur->{$_} ) - } keys %{$cur} - }; -} - -# extract_values {{{3 -# Arguments are a set of values (which may be incremental, derived from -# current and previous), current, and previous values. -# TODO: there are a few places that don't remember prev set so can't pass it. -sub extract_values { - my ( $set, $cur, $pre, $tbl ) = @_; - - # Hook in event listeners - foreach my $listener ( @{$event_listener_for{extract_values}} ) { - $listener->extract_values($set, $cur, $pre, $tbl); - } - - my $result = {}; - my $meta = $tbl_meta{$tbl}; - my $cols = $meta->{cols}; - foreach my $key ( keys %$cols ) { - my $info = $cols->{$key} - or die "Column '$key' doesn't exist in $tbl"; - die "No func defined for '$key' in $tbl" - unless $info->{func}; - eval { - $result->{$key} = $info->{func}->($set, $cur, $pre) - }; - if ( $EVAL_ERROR ) { - if ( $config{debug}->{val} ) { - die $EVAL_ERROR; - } - $result->{$key} = $info->{num} ? 0 : ''; - } - } - return $result; -} - -# get_full_processlist {{{3 -sub get_full_processlist { - my @cxns = @_; - my @result; - foreach my $cxn ( @cxns ) { - my $stmt = do_stmt($cxn, 'PROCESSLIST') or next; - my $arr = $stmt->fetchall_arrayref({}); - push @result, map { $_->{cxn} = $cxn; $_ } @$arr; - } - return @result; -} - -# get_open_tables {{{3 -sub get_open_tables { - my @cxns = @_; - my @result; - foreach my $cxn ( @cxns ) { - my $stmt = do_stmt($cxn, 'OPEN_TABLES') or next; - my $arr = $stmt->fetchall_arrayref({}); - push @result, map { $_->{cxn} = $cxn; $_ } @$arr; - } - return @result; -} - -# get_innodb_status {{{3 -sub get_innodb_status { - my ( $cxns, $addl_sections ) = @_; - if ( !$config{skip_innodb}->{val} && !$info_gotten{innodb_status}++ ) { - - # Determine which sections need to be parsed - my %sections_required = - map { $tbl_meta{$_}->{innodb} => 1 } - grep { $_ && $tbl_meta{$_}->{innodb} } - get_visible_tables(); - - # Add in any other sections the caller requested. - foreach my $sec ( @$addl_sections ) { - $sections_required{$sec} = 1; - } - - foreach my $cxn ( @$cxns ) { - my $innodb_status_text; - - if ( $file ) { # Try to fetch status text from the file. - my @stat = stat($file); - - # Initialize the file. - if ( !$file_mtime ) { - # Initialize to 130k from the end of the file (because the limit - # on the size of innodb status is 128k even with Google's patches) - # and try to grab the last status from the file. - sysseek($file, (-128 * 1_024), 2); - } - - # Read from the file. - my $buffer; - if ( !$file_mtime || $file_mtime != $stat[9] ) { - $file_data = ''; - while ( sysread($file, $buffer, 4096) ) { - $file_data .= $buffer; - } - $file_mtime = $stat[9]; - } - - # Delete everything but the last InnoDB status text from the file. - $file_data =~ s/\A.*(?=^=====================================\n...... ........ INNODB MONITOR OUTPUT)//ms; - $innodb_status_text = $file_data; - } - - else { - my $stmt = do_stmt($cxn, 'INNODB_STATUS') or next; - $innodb_status_text = $stmt->fetchrow_hashref()->{status}; - } - - next unless $innodb_status_text - && substr($innodb_status_text, 0, 100) =~ m/INNODB MONITOR OUTPUT/; - - # Parse and merge into %vars storage - my %innodb_status = ( - $innodb_parser->get_status_hash( - $innodb_status_text, - $config{debug}->{val}, - \%sections_required, - 0, # don't parse full lock information - ) - ); - if ( !$innodb_status{IB_got_all} && $config{auto_wipe_dl}->{val} ) { - clear_deadlock($cxn); - } - - # Merge using a hash slice, which is the fastest way - $vars{$cxn}->{$clock} ||= {}; - my $hash = $vars{$cxn}->{$clock}; - @{$hash}{ keys %innodb_status } = values %innodb_status; - $hash->{cxn} = $cxn; - $hash->{Uptime_hires} ||= get_uptime($cxn); - } - } -} - -# clear_deadlock {{{3 -sub clear_deadlock { - my ( $cxn ) = @_; - return if $clearing_deadlocks++; - my $tbl = $connections{$cxn}->{dl_table}; - return unless $tbl; - - eval { - # Set up the table for creating a deadlock. - my $engine = version_ge($dbhs{$cxn}->{dbh}, '4.1.2') ? 'engine' : 'type'; - return unless do_query($cxn, "drop table if exists $tbl"); - return unless do_query($cxn, "create table $tbl(a int) $engine=innodb"); - return unless do_query($cxn, "delete from $tbl"); - return unless do_query($cxn, "insert into $tbl(a) values(0), (1)"); - return unless do_query($cxn, "commit"); # Or the children will block against the parent - - # Fork off two children to deadlock against each other. - my %children; - foreach my $child ( 0..1 ) { - my $pid = fork(); - if ( defined($pid) && $pid == 0 ) { # I am a child - deadlock_thread( $child, $tbl, $cxn ); - } - elsif ( !defined($pid) ) { - die("Unable to fork for clearing deadlocks!\n"); - } - # I already exited if I'm a child, so I'm the parent. - $children{$child} = $pid; - } - - # Wait for the children to exit. - foreach my $child ( keys %children ) { - my $pid = waitpid($children{$child}, 0); - } - - # Clean up. - do_query($cxn, "drop table $tbl"); - }; - if ( $EVAL_ERROR ) { - print $EVAL_ERROR; - pause(); - } - - $clearing_deadlocks = 0; -} - -sub get_master_logs { - my @cxns = @_; - my @result; - if ( !$info_gotten{master_logs}++ ) { - foreach my $cxn ( @cxns ) { - my $stmt = do_stmt($cxn, 'SHOW_MASTER_LOGS') or next; - push @result, @{$stmt->fetchall_arrayref({})}; - } - } - return @result; -} - -# get_master_slave_status {{{3 -sub get_master_slave_status { - my @cxns = @_; - if ( !$info_gotten{replication_status}++ ) { - foreach my $cxn ( @cxns ) { - $vars{$cxn}->{$clock} ||= {}; - my $vars = $vars{$cxn}->{$clock}; - $vars->{cxn} = $cxn; - - my $stmt = do_stmt($cxn, 'SHOW_MASTER_STATUS') or next; - my $res = $stmt->fetchall_arrayref({})->[0]; - @{$vars}{ keys %$res } = values %$res; - $stmt = do_stmt($cxn, 'SHOW_SLAVE_STATUS') or next; - $res = $stmt->fetchall_arrayref({})->[0]; - @{$vars}{ keys %$res } = values %$res; - $vars->{Uptime_hires} ||= get_uptime($cxn); - } - } -} - -sub is_func { - my ( $word ) = @_; - return defined(&$word) - || eval "my \$x= sub { $word }; 1" - || $EVAL_ERROR !~ m/^Bareword/; -} - -# Documentation {{{1 -# ############################################################################ -# I put this last as per the Dog book. -# ############################################################################ -=pod - -=head1 NAME - -innotop - MySQL and InnoDB transaction/status monitor. - -=head1 SYNOPSIS - -To monitor servers normally: - - innotop - -To monitor InnoDB status information from a file: - - innotop /var/log/mysql/mysqld.err - -To run innotop non-interactively in a pipe-and-filter configuration: - - innotop --count 5 -d 1 -n - -=head1 DESCRIPTION - -innotop monitors MySQL servers. Each of its modes shows you a different aspect -of what's happening in the server. For example, there's a mode for monitoring -replication, one for queries, and one for transactions. innotop refreshes its -data periodically, so you see an updating view. - -innotop has lots of features for power users, but you can start and run it with -virtually no configuration. If you're just getting started, see -L<"QUICK-START">. Press '?' at any time while running innotop for -context-sensitive help. - -=head1 QUICK-START - -To start innotop, open a terminal or command prompt. If you have installed -innotop on your system, you should be able to just type "innotop" and press -Enter; otherwise, you will need to change to innotop's directory and type "perl -innotop". - -The first thing innotop needs to know is how to connect to a MySQL server. You -can just enter the hostname of the server, for example "localhost" or -"127.0.0.1" if the server is on the same machine as innotop. After this innotop -will prompt you for a DSN (data source name). You should be able to just accept -the defaults by pressing Enter. - -When innotop asks you about a table to use when resetting InnoDB deadlock -information, just accept the default for now. This is an advanced feature you -can configure later (see L<"D: InnoDB Deadlocks"> for more). - -If you have a .my.cnf file with your MySQL connection defaults, innotop can read -it, and you won't need to specify a username and password if it's in that file. -Otherwise, you should answer 'y' to the next couple of prompts. - -After this, you should be connected, and innotop should show you something like -the following: - - InnoDB Txns (? for help) localhost, 01:11:19, InnoDB 10s :-), 50 QPS, - - CXN History Versions Undo Dirty Buf Used Bufs Txns MaxTxn - localhost 7 2035 0 0 0.00% 92.19% 1 07:34 - - CXN ID User Host Txn Status Time Undo Query Tex - localhost 98379 user1 webserver ACTIVE 07:34 0 SELECT `c - localhost 98450 user1 webserver ACTIVE 01:06 0 INSERT IN - localhost 97750 user1 webserver not starte 00:00 0 - localhost 98375 user1 appserver not starte 00:00 0 - -(This sample is truncated at the right so it will fit on a terminal when running -'man innotop') - -This sample comes from a quiet server with few transactions active. If your -server is busy, you'll see more output. Notice the first line on the screen, -which tells you what mode you're in and what server you're connected to. You -can change to other modes with keystrokes; press 'Q' to switch to a list of -currently running queries. - -Press the '?' key to see what keys are active in the current mode. You can -press any of these keys and innotop will either take the requested action or -prompt you for more input. If your system has Term::ReadLine support, you can -use TAB and other keys to auto-complete and edit input. - -To quit innotop, press the 'q' key. - -=head1 OPTIONS - -innotop is mostly configured via its configuration file, but some of the -configuration options can come from the command line. You can also specify a -file to monitor for InnoDB status output; see L<"MONITORING A FILE"> for more -details. - -You can negate some options by prefixing the option name with --no. For -example, --noinc (or --no-inc) negates L<"--inc">. - -=over - -=item --help - -Print a summary of command-line usage and exit. - -=item --color - -Enable or disable terminal coloring. Corresponds to the L<"color"> config file -setting. - -=item --config - -Specifies a configuration file to read. This option is non-sticky, that is to -say it does not persist to the configuration file itself. - -=item --nonint - -Enable non-interactive operation. See L<"NON-INTERACTIVE OPERATION"> for more. - -=item --count - -Refresh only the specified number of times (ticks) before exiting. Each refresh -is a pause for L<"interval"> seconds, followed by requesting data from MySQL -connections and printing it to the terminal. - -=item --delay - -Specifies the amount of time to pause between ticks (refreshes). Corresponds to -the configuration option L<"interval">. - -=item --mode - -Specifies the mode in which innotop should start. Corresponds to the -configuration option L<"mode">. - -=item --inc - -Specifies whether innotop should display absolute numbers or relative numbers -(offsets from their previous values). Corresponds to the configuration option -L<"status_inc">. - -=item --version - -Output version information and exit. - -=back - -=head1 HOTKEYS - -innotop is interactive, and you control it with key-presses. - -=over - -=item * - -Uppercase keys switch between modes. - -=item * - -Lowercase keys initiate some action within the current mode. - -=item * - -Other keys do something special like change configuration or show the -innotop license. - -=back - -Press '?' at any time to see the currently active keys and what they do. - -=head1 MODES - -Each of innotop's modes retrieves and displays a particular type of data from -the servers you're monitoring. You switch between modes with uppercase keys. -The following is a brief description of each mode, in alphabetical order. To -switch to the mode, press the key listed in front of its heading in the -following list: - -=over - -=item B: InnoDB Buffers - -This mode displays information about the InnoDB buffer pool, page statistics, -insert buffer, and adaptive hash index. The data comes from SHOW INNODB STATUS. - -This mode contains the L<"buffer_pool">, L<"page_statistics">, -L<"insert_buffers">, and L<"adaptive_hash_index"> tables by default. - -=item C: Command Summary - -This mode is similar to mytop's Command Summary mode. It shows the -L<"cmd_summary"> table, which looks something like the following: - - Command Summary (? for help) localhost, 25+07:16:43, 2.45 QPS, 3 thd, 5.0.40 - _____________________ Command Summary _____________________ - Name Value Pct Last Incr Pct - Select_scan 3244858 69.89% 2 100.00% - Select_range 1354177 29.17% 0 0.00% - Select_full_join 39479 0.85% 0 0.00% - Select_full_range_join 4097 0.09% 0 0.00% - Select_range_check 0 0.00% 0 0.00% - -The command summary table is built by extracting variables from -L<"STATUS_VARIABLES">. The variables must be numeric and must match the prefix -given by the L<"cmd_filter"> configuration variable. The variables are then -sorted by value descending and compared to the last variable, as shown above. -The percentage columns are percentage of the total of all variables in the -table, so you can see the relative weight of the variables. - -The example shows what you see if the prefix is "Select_". The default -prefix is "Com_". You can choose a prefix with the 's' key. - -It's rather like running SHOW VARIABLES LIKE "prefix%" with memory and -nice formatting. - -Values are aggregated across all servers. The Pct columns are not correctly -aggregated across multiple servers. This is a known limitation of the grouping -algorithm that may be fixed in the future. - -=item D: InnoDB Deadlocks - -This mode shows the transactions involved in the last InnoDB deadlock. A second -table shows the locks each transaction held and waited for. A deadlock is -caused by a cycle in the waits-for graph, so there should be two locks held and -one waited for unless the deadlock information is truncated. - -InnoDB puts deadlock information before some other information in the SHOW -INNODB STATUS output. If there are a lot of locks, the deadlock information can -grow very large, and there is a limit on the size of the SHOW INNODB -STATUS output. A large deadlock can fill the entire output, or even be -truncated, and prevent you from seeing other information at all. If you are -running innotop in another mode, for example T mode, and suddenly you don't see -anything, you might want to check and see if a deadlock has wiped out the data -you need. - -If it has, you can create a small deadlock to replace the large one. Use the -'w' key to 'wipe' the large deadlock with a small one. This will not work -unless you have defined a deadlock table for the connection (see L<"SERVER -CONNECTIONS">). - -You can also configure innotop to automatically detect when a large deadlock -needs to be replaced with a small one (see L<"auto_wipe_dl">). - -This mode displays the L<"deadlock_transactions"> and L<"deadlock_locks"> tables -by default. - -=item F: InnoDB Foreign Key Errors - -This mode shows the last InnoDB foreign key error information, such as the -table where it happened, when and who and what query caused it, and so on. - -InnoDB has a huge variety of foreign key error messages, and many of them are -just hard to parse. innotop doesn't always do the best job here, but there's -so much code devoted to parsing this messy, unparseable output that innotop is -likely never to be perfect in this regard. If innotop doesn't show you what -you need to see, just look at the status text directly. - -This mode displays the L<"fk_error"> table by default. - -=item I: InnoDB I/O Info - -This mode shows InnoDB's I/O statistics, including the I/O threads, pending I/O, -file I/O miscellaneous, and log statistics. It displays the L<"io_threads">, -L<"pending_io">, L<"file_io_misc">, and L<"log_statistics"> tables by default. - -=item L: Locks - -This mode shows information about current locks. At the moment only InnoDB -locks are supported, and by default you'll only see locks for which transactions -are waiting. This information comes from the TRANSACTIONS section of the InnoDB -status text. If you have a very busy server, you may have frequent lock waits; -it helps to be able to see which tables and indexes are the "hot spot" for -locks. If your server is running pretty well, this mode should show nothing. - -You can configure MySQL and innotop to monitor not only locks for which a -transaction is waiting, but those currently held, too. You can do this with the -InnoDB Lock Monitor (L). It's -not documented in the MySQL manual, but creating the lock monitor with the -following statement also affects the output of SHOW INNODB STATUS, which innotop -uses: - - CREATE TABLE innodb_lock_monitor(a int) ENGINE=INNODB; - -This causes InnoDB to print its output to the MySQL file every 16 seconds or so, -as stated in the manual, but it also makes the normal SHOW INNODB STATUS output -include lock information, which innotop can parse and display (that's the -undocumented feature). - -This means you can do what may have seemed impossible: to a limited extent -(InnoDB truncates some information in the output), you can see which transaction -holds the locks something else is waiting for. You can also enable and disable -the InnoDB Lock Monitor with the key mappings in this mode. - -This mode displays the L<"innodb_locks"> table by default. Here's a sample of -the screen when one connection is waiting for locks another connection holds: - - _________________________________ InnoDB Locks __________________________ - CXN ID Type Waiting Wait Active Mode DB Table Index - localhost 12 RECORD 1 00:10 00:10 X test t1 PRIMARY - localhost 12 TABLE 0 00:10 00:10 IX test t1 - localhost 12 RECORD 1 00:10 00:10 X test t1 PRIMARY - localhost 11 TABLE 0 00:00 00:25 IX test t1 - localhost 11 RECORD 0 00:00 00:25 X test t1 PRIMARY - -You can see the first connection, ID 12, is waiting for a lock on the PRIMARY -key on test.t1, and has been waiting for 10 seconds. The second connection -isn't waiting, because the Waiting column is 0, but it holds locks on the same -index. That tells you connection 11 is blocking connection 12. - -=item M: Master/Slave Replication Status - -This mode shows the output of SHOW SLAVE STATUS and SHOW MASTER STATUS in three -tables. The first two divide the slave's status into SQL and I/O thread status, -and the last shows master status. Filters are applied to eliminate non-slave -servers from the slave tables, and non-master servers from the master table. - -This mode displays the L<"slave_sql_status">, L<"slave_io_status">, and -L<"master_status"> tables by default. - -=item O: Open Tables - -This section comes from MySQL's SHOW OPEN TABLES command. By default it is -filtered to show tables which are in use by one or more queries, so you can -get a quick look at which tables are 'hot'. You can use this to guess which -tables might be locked implicitly. - -This mode displays the L<"open_tables"> mode by default. - -=item Q: Query List - -This mode displays the output from SHOW FULL PROCESSLIST, much like B's -query list mode. This mode does B show InnoDB-related information. This -is probably one of the most useful modes for general usage. - -There is an informative header that shows general status information about -your server. You can toggle it on and off with the 'h' key. By default, -innotop hides inactive processes and its own process. You can toggle these on -and off with the 'i' and 'a' keys. - -You can EXPLAIN a query from this mode with the 'e' key. This displays the -query's full text, the results of EXPLAIN, and in newer MySQL versions, even -the optimized query resulting from EXPLAIN EXTENDED. innotop also tries to -rewrite certain queries to make them EXPLAIN-able. For example, INSERT/SELECT -statements are rewritable. - -This mode displays the L<"q_header"> and L<"processlist"> tables by default. - -=item R: InnoDB Row Operations and Semaphores - -This mode shows InnoDB row operations, row operation miscellaneous, semaphores, -and information from the wait array. It displays the L<"row_operations">, -L<"row_operation_misc">, L<"semaphores">, and L<"wait_array"> tables by default. - -=item S: Variables & Status - -This mode calculates statistics, such as queries per second, and prints them out -in several different styles. You can show absolute values, or incremental values -between ticks. - -You can switch between the views by pressing a key. The 's' key prints a -single line each time the screen updates, in the style of B. The 'g' -key changes the view to a graph of the same numbers, sort of like B. -The 'v' key changes the view to a pivoted table of variable names on the left, -with successive updates scrolling across the screen from left to right. You can -choose how many updates to put on the screen with the L<"num_status_sets"> -configuration variable. - -Headers may be abbreviated to fit on the screen in interactive operation. You -choose which variables to display with the 'c' key, which selects from -predefined sets, or lets you create your own sets. You can edit the current set -with the 'e' key. - -This mode doesn't really display any tables like other modes. Instead, it uses -a table definition to extract and format the data, but it then transforms the -result in special ways before outputting it. It uses the L<"var_status"> table -definition for this. - -=item T: InnoDB Transactions - -This mode shows transactions from the InnoDB monitor's output, in B-like -format. This mode is the reason I wrote innotop. - -You can kill queries or processes with the 'k' and 'x' keys, and EXPLAIN a query -with the 'e' or 'f' keys. InnoDB doesn't print the full query in transactions, -so explaining may not work right if the query is truncated. - -The informational header can be toggled on and off with the 'h' key. By -default, innotop hides inactive transactions and its own transaction. You can -toggle this on and off with the 'i' and 'a' keys. - -This mode displays the L<"t_header"> and L<"innodb_transactions"> tables by -default. - -=back - -=head1 INNOTOP STATUS - -The first line innotop displays is a "status bar" of sorts. What it contains -depends on the mode you're in, and what servers you're monitoring. The first -few words are always the innotop mode, such as "InnoDB Txns" for T mode, -followed by a reminder to press '?' for help at any time. - -=head2 ONE SERVER - -The simplest case is when you're monitoring a single server. In this case, the -name of the connection is next on the status line. This is the name you gave -when you created the connection -- most likely the MySQL server's hostname. -This is followed by the server's uptime. - -If you're in an InnoDB mode, such as T or B, the next word is "InnoDB" followed -by some information about the SHOW INNODB STATUS output used to render the -screen. The first word is the number of seconds since the last SHOW INNODB -STATUS, which InnoDB uses to calculate some per-second statistics. The next is -a smiley face indicating whether the InnoDB output is truncated. If the smiley -face is a :-), all is well; there is no truncation. A :^| means the transaction -list is so long, InnoDB has only printed out some of the transactions. Finally, -a frown :-( means the output is incomplete, which is probably due to a deadlock -printing too much lock information (see L<"D: InnoDB Deadlocks">). - -The next two words indicate the server's queries per second (QPS) and how many -threads (connections) exist. Finally, the server's version number is the last -thing on the line. - -=head2 MULTIPLE SERVERS - -If you are monitoring multiple servers (see L<"SERVER CONNECTIONS">), the status -line does not show any details about individual servers. Instead, it shows the -names of the connections that are active. Again, these are connection names you -specified, which are likely to be the server's hostname. A connection that has -an error is prefixed with an exclamation point. - -If you are monitoring a group of servers (see L<"SERVER GROUPS">), the status -line shows the name of the group. If any connection in the group has an -error, the group's name is followed by the fraction of the connections that -don't have errors. - -See L<"ERROR HANDLING"> for more details about innotop's error handling. - -=head2 MONITORING A FILE - -If you give a filename on the command line, innotop will not connect to ANY -servers at all. It will watch the specified file for InnoDB status output and -use that as its data source. It will always show a single connection called -'file'. And since it can't connect to a server, it can't determine how long the -server it's monitoring has been up; so it calculates the server's uptime as time -since innotop started running. - -=head1 SERVER ADMINISTRATION - -While innotop is primarily a monitor that lets you watch and analyze your -servers, it can also send commands to servers. The most frequently useful -commands are killing queries and stopping or starting slaves. - -You can kill a connection, or in newer versions of MySQL kill a query but not a -connection, from L<"Q: Query List"> and L<"T: InnoDB Transactions"> modes. -Press 'k' to issue a KILL command, or 'x' to issue a KILL QUERY command. -innotop will prompt you for the server and/or connection ID to kill (innotop -does not prompt you if there is only one possible choice for any input). -innotop pre-selects the longest-running query, or the oldest connection. -Confirm the command with 'y'. - -In L<"M: Master/Slave Replication Status"> mode, you can start and stop slaves -with the 'a' and 'o' keys, respectively. You can send these commands to many -slaves at once. innotop fills in a default command of START SLAVE or STOP SLAVE -for you, but you can actually edit the command and send anything you wish, such -as SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1 to make the slave skip one binlog event -when it starts. - -You can also ask innotop to calculate the earliest binlog in use by any slave -and issue a PURGE MASTER LOGS on the master. Use the 'b' key for this. innotop -will prompt you for a master to run the command on, then prompt you for the -connection names of that master's slaves (there is no way for innotop to -determine this reliably itself). innotop will find the minimum binlog in use by -these slave connections and suggest it as the argument to PURGE MASTER LOGS. - -=head1 SERVER CONNECTIONS - -When you create a server connection, innotop asks you for a series of inputs, as -follows: - -=over - -=item DSN - -A DSN is a Data Source Name, which is the initial argument passed to the DBI -module for connecting to a server. It is usually of the form - - DBI:mysql:;mysql_read_default_group=mysql;host=HOSTNAME - -Since this DSN is passed to the DBD::mysql driver, you should read the driver's -documentation at L<"http://search.cpan.org/dist/DBD-mysql/lib/DBD/mysql.pm"> for -the exact details on all the options you can pass the driver in the DSN. You -can read more about DBI at L, and especially at -L. - -The mysql_read_default_group=mysql option lets the DBD driver read your MySQL -options files, such as ~/.my.cnf on UNIX-ish systems. You can use this to avoid -specifying a username or password for the connection. - -=item InnoDB Deadlock Table - -This optional item tells innotop a table name it can use to deliberately create -a small deadlock (see L<"D: InnoDB Deadlocks">). If you specify this option, -you just need to be sure the table doesn't exist, and that innotop can create -and drop the table with the InnoDB storage engine. You can safely omit or just -accept the default if you don't intend to use this. - -=item Username - -innotop will ask you if you want to specify a username. If you say 'y', it will -then prompt you for a user name. If you have a MySQL option file that specifies -your username, you don't have to specify a username. - -The username defaults to your login name on the system you're running innotop on. - -=item Password - -innotop will ask you if you want to specify a password. Like the username, the -password is optional, but there's an additional prompt that asks if you want to -save the password in the innotop configuration file. If you don't save it in -the configuration file, innotop will prompt you for a password each time it -starts. Passwords in the innotop configuration file are saved in plain text, -not encrypted in any way. - -=back - -Once you finish answering these questions, you should be connected to a server. -But innotop isn't limited to monitoring a single server; you can define many -server connections and switch between them by pressing the '@' key. See -L<"SWITCHING BETWEEN CONNECTIONS">. - -To create a new connection, press the '@' key and type the name of the new -connection, then follow the steps given above. - -=head1 SERVER GROUPS - -If you have multiple MySQL instances, you can put them into named groups, such -as 'all', 'masters', and 'slaves', which innotop can monitor all together. - -You can choose which group to monitor with the '#' key, and you can press the -TAB key to switch to the next group. If you're not currently monitoring a -group, pressing TAB selects the first group. - -To create a group, press the '#' key and type the name of your new group, then -type the names of the connections you want the group to contain. - -=head1 SWITCHING BETWEEN CONNECTIONS - -innotop lets you quickly switch which servers you're monitoring. The most basic -way is by pressing the '@' key and typing the name(s) of the connection(s) you -want to use. This setting is per-mode, so you can monitor different connections -in each mode, and innotop remembers which connections you choose. - -You can quickly switch to the 'next' connection in alphabetical order with the -'n' key. If you're monitoring a server group (see L<"SERVER GROUPS">) this will -switch to the first connection. - -You can also type many connection names, and innotop will fetch and display data -from them all. Just separate the connection names with spaces, for example -"server1 server2." Again, if you type the name of a connection that doesn't -exist, innotop will prompt you for connection information and create the -connection. - -Another way to monitor multiple connections at once is with server groups. You -can use the TAB key to switch to the 'next' group in alphabetical order, or if -you're not monitoring any groups, TAB will switch to the first group. - -innotop does not fetch data in parallel from connections, so if you are -monitoring a large group or many connections, you may notice increased delay -between ticks. - -When you monitor more than one connection, innotop's status bar changes. See -L<"INNOTOP STATUS">. - -=head1 ERROR HANDLING - -Error handling is not that important when monitoring a single connection, but is -crucial when you have many active connections. A crashed server or lost -connection should not crash innotop. As a result, innotop will continue to run -even when there is an error; it just won't display any information from the -connection that had an error. Because of this, innotop's behavior might confuse -you. It's a feature, not a bug! - -innotop does not continue to query connections that have errors, because they -may slow innotop and make it hard to use, especially if the error is a problem -connecting and causes a long time-out. Instead, innotop retries the connection -occasionally to see if the error still exists. If so, it will wait until some -point in the future. The wait time increases in ticks as the Fibonacci series, -so it tries less frequently as time passes. - -Since errors might only happen in certain modes because of the SQL commands -issued in those modes, innotop keeps track of which mode caused the error. If -you switch to a different mode, innotop will retry the connection instead of -waiting. - -By default innotop will display the problem in red text at the bottom of the -first table on the screen. You can disable this behavior with the -L<"show_cxn_errors_in_tbl"> configuration option, which is enabled by default. -If the L<"debug"> option is enabled, innotop will display the error at the -bottom of every table, not just the first. And if L<"show_cxn_errors"> is -enabled, innotop will print the error text to STDOUT as well. Error messages -might only display in the mode that caused the error, depending on the mode and -whether innotop is avoiding querying that connection. - -=head1 NON-INTERACTIVE OPERATION - -You can run innotop in non-interactive mode, in which case it is entirely -controlled from the configuration file and command-line options. To start -innotop in non-interactive mode, give the L"<--nonint"> command-line option. -This changes innotop's behavior in the following ways: - -=over - -=item * - -Certain Perl modules are not loaded. Term::Readline is not loaded, since -innotop doesn't prompt interactively. Term::ANSIColor and Win32::Console::ANSI -modules are not loaded. Term::ReadKey is still used, since innotop may have to -prompt for connection passwords when starting up. - -=item * - -innotop does not clear the screen after each tick. - -=item * - -innotop does not persist any changes to the configuration file. - -=item * - -If L<"--count"> is given and innotop is in incremental mode (see L<"status_inc"> -and L<"--inc">), innotop actually refreshes one more time than specified so it -can print incremental statistics. This suppresses output during the first -tick, so innotop may appear to hang. - -=item * - -innotop only displays the first table in each mode. This is so the output can -be easily processed with other command-line utilities such as awk and sed. To -change which tables display in each mode, see L<"TABLES">. Since L<"Q: Query -List"> mode is so important, innotop automatically disables the L<"q_header"> -table. This ensures you'll see the L<"processlist"> table, even if you have -innotop configured to show the q_header table during interactive operation. -Similarly, in L<"T: InnoDB Transactions"> mode, the L<"t_header"> table is -suppressed so you see only the L<"innodb_transactions"> table. - -=item * - -All output is tab-separated instead of being column-aligned with whitespace, and -innotop prints the full contents of each table instead of only printing one -screenful at a time. - -=item * - -innotop only prints column headers once instead of every tick (see -L<"hide_hdr">). innotop does not print table captions (see -L<"display_table_captions">). innotop ensures there are no empty lines in the -output. - -=item * - -innotop does not honor the L<"shorten"> transformation, which normally shortens -some numbers to human-readable formats. - -=item * - -innotop does not print a status line (see L<"INNOTOP STATUS">). - -=back - -=head1 CONFIGURING - -Nearly everything about innotop is configurable. Most things are possible to -change with built-in commands, but you can also edit the configuration file. - -While running innotop, press the '$' key to bring up the configuration editing -dialog. Press another key to select the type of data you want to edit: - -=over - -=item S: Statement Sleep Times - -Edits SQL statement sleep delays, which make innotop pause for the specified -amount of time after executing a statement. See L<"SQL STATEMENTS"> for a -definition of each statement and what it does. By default innotop does not -delay after any statements. - -This feature is included so you can customize the side-effects caused by -monitoring your server. You may not see any effects, but some innotop users -have noticed that certain MySQL versions under very high load with InnoDB -enabled take longer than usual to execute SHOW GLOBAL STATUS. If innotop calls -SHOW FULL PROCESSLIST immediately afterward, the processlist contains more -queries than the machine actually averages at any given moment. Configuring -innotop to pause briefly after calling SHOW GLOBAL STATUS alleviates this -effect. - -Sleep times are stored in the L<"stmt_sleep_times"> section of the configuration -file. Fractional-second sleeps are supported, subject to your hardware's -limitations. - -=item c: Edit Columns - -Starts the table editor on one of the displayed tables. See L<"TABLE EDITOR">. -An alternative way to start the table editor without entering the configuration -dialog is with the '^' key. - -=item g: General Configuration - -Starts the configuration editor to edit global and mode-specific configuration -variables (see L<"MODES">). innotop prompts you to choose a variable from among -the global and mode-specific ones depending on the current mode. - -=item k: Row-Coloring Rules - -Starts the row-coloring rules editor on one of the displayed table(s). See -L<"COLORS"> for details. - -=item p: Manage Plugins - -Starts the plugin configuration editor. See L<"PLUGINS"> for details. - -=item s: Server Groups - -Lets you create and edit server groups. See L<"SERVER GROUPS">. - -=item t: Choose Displayed Tables - -Lets you choose which tables to display in this mode. See L<"MODES"> and -L<"TABLES">. - -=back - -=head1 CONFIGURATION FILE - -innotop's default configuration file location is in $HOME/.innotop, but can be -overridden with the L<"--config"> command-line option. You can edit it by hand -safely. innotop reads the configuration file when it starts, and writes it out -again when it exits, so any changes you make while innotop is running will be -lost. - -innotop doesn't store its entire configuration in the configuration file. It -has a huge set of default configuration that it holds only in memory, and the -configuration file only overrides these defaults. When you customize a default -setting, innotop notices, and then stores the customizations into the file. -This keeps the file size down, makes it easier to edit, and makes upgrades -easier. - -A configuration file can be made read-only. See L<"readonly">. - -The configuration file is arranged into sections like an INI file. Each -section begins with [section-name] and ends with [/section-name]. Each -section's entries have a different syntax depending on the data they need to -store. You can put comments in the file; any line that begins with a # -character is a comment. innotop will not read the comments, so it won't write -them back out to the file when it exits. Comments in read-only configuration -files are still useful, though. - -The first line in the file is innotop's version number. This lets innotop -notice when the file format is not backwards-compatible, and upgrade smoothly -without destroying your customized configuration. - -The following list describes each section of the configuration file and the data -it contains: - -=over - -=item general - -The 'general' section contains global configuration variables and variables that -may be mode-specific, but don't belong in any other section. The syntax is a -simple key=value list. innotop writes a comment above each value to help you -edit the file by hand. - -=over - -=item S_func - -Controls S mode presentation (see L<"S: Variables & Status">). If g, values are -graphed; if s, values are like vmstat; if p, values are in a pivoted table. - -=item S_set - -Specifies which set of variables to display in L<"S: Variables & Status"> mode. -See L<"VARIABLE SETS">. - -=item auto_wipe_dl - -Instructs innotop to automatically wipe large deadlocks when it notices them. -When this happens you may notice a slight delay. At the next tick, you will -usually see the information that was being truncated by the large deadlock. - -=item charset - -Specifies what kind of characters to allow through the L<"no_ctrl_char"> -transformation. This keeps non-printable characters from confusing a -terminal when you monitor queries that contain binary data, such as images. - -The default is 'ascii', which considers anything outside normal ASCII to be a -control character. The other allowable values are 'unicode' and 'none'. 'none' -considers every character a control character, which can be useful for -collapsing ALL text fields in queries. - -=item cmd_filter - -This is the prefix that filters variables in L<"C: Command Summary"> mode. - -=item color - -Whether terminal coloring is permitted. - -=item cxn_timeout - -On MySQL versions 4.0.3 and newer, this variable is used to set the connection's -timeout, so MySQL doesn't close the connection if it is not used for a while. -This might happen because a connection isn't monitored in a particular mode, for -example. - -=item debug - -This option enables more verbose errors and makes innotop more strict in some -places. It can help in debugging filters and other user-defined code. It also -makes innotop write a lot of information to L<"debugfile"> when there is a -crash. - -=item debugfile - -A file to which innotop will write information when there is a crash. See -L<"FILES">. - -=item display_table_captions - -innotop displays a table caption above most tables. This variable suppresses or -shows captions on all tables globally. Some tables are configured with the -hide_caption property, which overrides this. - -=item global - -Whether to show GLOBAL variables and status. innotop only tries to do this on -servers which support the GLOBAL option to SHOW VARIABLES and SHOW STATUS. In -some MySQL versions, you need certain privileges to do this; if you don't have -them, innotop will not be able to fetch any variable and status data. This -configuration variable lets you run innotop and fetch what data you can even -without the elevated privileges. - -I can no longer find or reproduce the situation where GLOBAL wasn't allowed, but -I know there was one. - -=item graph_char - -Defines the character to use when drawing graphs in L<"S: Variables & Status"> -mode. - -=item header_highlight - -Defines how to highlight column headers. This only works if Term::ANSIColor is -available. Valid values are 'bold' and 'underline'. - -=item hide_hdr - -Hides column headers globally. - -=item interval - -The interval at which innotop will refresh its data (ticks). The interval is -implemented as a sleep time between ticks, so the true interval will vary -depending on how long it takes innotop to fetch and render data. - -This variable accepts fractions of a second. - -=item mode - -The mode in which innotop should start. Allowable arguments are the same as the -key presses that select a mode interactively. See L<"MODES">. - -=item num_digits - -How many digits to show in fractional numbers and percents. This variable's -range is between 0 and 9 and can be set directly from L<"S: Variables & Status"> -mode with the '+' and '-' keys. It is used in the L<"set_precision">, -L<"shorten">, and L<"percent"> transformations. - -=item num_status_sets - -Controls how many sets of status variables to display in pivoted L<"S: Variables -& Status"> mode. It also controls the number of old sets of variables innotop -keeps in its memory, so the larger this variable is, the more memory innotop -uses. - -=item plugin_dir - -Specifies where plugins can be found. By default, innotop stores plugins in the -'plugins' subdirectory of your innotop configuration directory. - -=item readonly - -Whether the configuration file is readonly. This cannot be set interactively, -because it would prevent itself from being written to the configuration file. - -=item show_cxn_errors - -Makes innotop print connection errors to STDOUT. See L<"ERROR HANDLING">. - -=item show_cxn_errors_in_tbl - -Makes innotop display connection errors as rows in the first table on screen. -See L<"ERROR HANDLING">. - -=item show_percent - -Adds a '%' character after the value returned by the L<"percent"> -transformation. - -=item show_statusbar - -Controls whether to show the status bar in the display. See L<"INNOTOP -STATUS">. - -=item skip_innodb - -Disables fetching SHOW INNODB STATUS, in case your server(s) do not have InnoDB -enabled and you don't want innotop to try to fetch it. This can also be useful -when you don't have the SUPER privilege, required to run SHOW INNODB STATUS. - -=item status_inc - -Whether to show absolute or incremental values for status variables. -Incremental values are calculated as an offset from the last value innotop saw -for that variable. This is a global setting, but will probably become -mode-specific at some point. Right now it is honored a bit inconsistently; some -modes don't pay attention to it. - -=back - -=item plugins - -This section holds a list of package names of active plugins. If the plugin -exists, innotop will activate it. See L<"PLUGINS"> for more information. - -=item filters - -This section holds user-defined filters (see L<"FILTERS">). Each line is in the -format filter_name=text='filter text' tbls='table list'. - -The filter text is the text of the subroutine's code. The table list is a list -of tables to which the filter can apply. By default, user-defined filters apply -to the table for which they were created, but you can manually override that by -editing the definition in the configuration file. - -=item active_filters - -This section stores which filters are active on each table. Each line is in the -format table_name=filter_list. - -=item tbl_meta - -This section stores user-defined or user-customized columns (see L<"COLUMNS">). -Each line is in the format col_name=properties, where the properties are a -name=quoted-value list. - -=item connections - -This section holds the server connections you have defined. Each line is in the -format name=properties, where the properties are a name=value list. The -properties are self-explanatory, and the only one that is treated specially is -'pass' which is only present if 'savepass' is set. See L<"SERVER CONNECTIONS">. - -=item active_connections - -This section holds a list of which connections are active in each mode. Each -line is in the format mode_name=connection_list. - -=item server_groups - -This section holds server groups. Each line is in the format -name=connection_list. See L<"SERVER GROUPS">. - -=item active_server_groups - -This section holds a list of which server group is active in each mode. Each -line is in the format mode_name=server_group. - -=item max_values_seen - -This section holds the maximum values seen for variables. This is used to scale -the graphs in L<"S: Variables & Status"> mode. Each line is in the format -name=value. - -=item active_columns - -This section holds table column lists. Each line is in the format -tbl_name=column_list. See L<"COLUMNS">. - -=item sort_cols - -This section holds the sort definition. Each line is in the format -tbl_name=column_list. If a column is prefixed with '-', that column sorts -descending. See L<"SORTING">. - -=item visible_tables - -This section defines which tables are visible in each mode. Each line is in the -format mode_name=table_list. See L<"TABLES">. - -=item varsets - -This section defines variable sets for use in L<"S: Status & Variables"> mode. -Each line is in the format name=variable_list. See L<"VARIABLE SETS">. - -=item colors - -This section defines colorization rules. Each line is in the format -tbl_name=property_list. See L<"COLORS">. - -=item stmt_sleep_times - -This section contains statement sleep times. Each line is in the format -statement_name=sleep_time. See L<"S: Statement Sleep Times">. - -=item group_by - -This section contains column lists for table group_by expressions. Each line is -in the format tbl_name=column_list. See L<"GROUPING">. - -=back - -=head1 CUSTOMIZING - -You can customize innotop a great deal. For example, you can: - -=over - -=item * - -Choose which tables to display, and in what order. - -=item * - -Choose which columns are in those tables, and create new columns. - -=item * - -Filter which rows display with built-in filters, user-defined filters, and -quick-filters. - -=item * - -Sort the rows to put important data first or group together related rows. - -=item * - -Highlight rows with color. - -=item * - -Customize the alignment, width, and formatting of columns, and apply -transformations to columns to extract parts of their values or format the values -as you wish (for example, shortening large numbers to familiar units). - -=item * - -Design your own expressions to extract and combine data as you need. This gives -you unlimited flexibility. - -=back - -All these and more are explained in the following sections. - -=head2 TABLES - -A table is what you'd expect: a collection of columns. It also has some other -properties, such as a caption. Filters, sorting rules, and colorization rules -belong to tables and are covered in later sections. - -Internally, table meta-data is defined in a data structure called %tbl_meta. -This hash holds all built-in table definitions, which contain a lot of default -instructions to innotop. The meta-data includes the caption, a list of columns -the user has customized, a list of columns, a list of visible columns, a list of -filters, color rules, a sort-column list, sort direction, and some information -about the table's data sources. Most of this is customizable via the table -editor (see L<"TABLE EDITOR">). - -You can choose which tables to show by pressing the '$' key. See L<"MODES"> and -L<"TABLES">. - -The table life-cycle is as follows: - -=over - -=item * - -Each table begins with a data source, which is an array of hashes. See below -for details on data sources. - -=item * - -Each element of the data source becomes a row in the final table. - -=item * - -For each element in the data source, innotop extracts values from the source and -creates a row. This row is another hash, which later steps will refer to as -$set. The values innotop extracts are determined by the table's columns. Each -column has an extraction subroutine, compiled from an expression (see -L<"EXPRESSIONS">). The resulting row is a hash whose keys are named the same as -the column name. - -=item * - -innotop filters the rows, removing those that don't need to be displayed. See -L<"FILTERS">. - -=item * - -innotop sorts the rows. See L<"SORTING">. - -=item * - -innotop groups the rows together, if specified. See L<"GROUPING">. - -=item * - -innotop colorizes the rows. See L<"COLORS">. - -=item * - -innotop transforms the column values in each row. See L<"TRANSFORMATIONS">. - -=item * - -innotop optionally pivots the rows (see L<"PIVOTING">), then filters and sorts -them. - -=item * - -innotop formats and justifies the rows as a table. During this step, innotop -applies further formatting to the column values, including alignment, maximum -and minimum widths. innotop also does final error checking to ensure there are -no crashes due to undefined values. innotop then adds a caption if specified, -and the table is ready to print. - -=back - -The lifecycle is slightly different if the table is pivoted, as noted above. To -clarify, if the table is pivoted, the process is extract, group, transform, -pivot, filter, sort, create. If it's not pivoted, the process is extract, -filter, sort, group, color, transform, create. This slightly convoluted process -doesn't map all that well to SQL, but pivoting complicates things pretty -thoroughly. Roughly speaking, filtering and sorting happen as late as needed to -effect the final result as you might expect, but as early as possible for -efficiency. - -Each built-in table is described below: - -=over - -=item adaptive_hash_index - -Displays data about InnoDB's adaptive hash index. Data source: -L<"STATUS_VARIABLES">. - -=item buffer_pool - -Displays data about InnoDB's buffer pool. Data source: L<"STATUS_VARIABLES">. - -=item cmd_summary - -Displays weighted status variables. Data source: L<"STATUS_VARIABLES">. - -=item deadlock_locks - -Shows which locks were held and waited for by the last detected deadlock. Data -source: L<"DEADLOCK_LOCKS">. - -=item deadlock_transactions - -Shows transactions involved in the last detected deadlock. Data source: -L<"DEADLOCK_TRANSACTIONS">. - -=item explain - -Shows the output of EXPLAIN. Data source: L<"EXPLAIN">. - -=item file_io_misc - -Displays data about InnoDB's file and I/O operations. Data source: -L<"STATUS_VARIABLES">. - -=item fk_error - -Displays various data about InnoDB's last foreign key error. Data source: -L<"STATUS_VARIABLES">. - -=item innodb_locks - -Displays InnoDB locks. Data source: L<"INNODB_LOCKS">. - -=item innodb_transactions - -Displays data about InnoDB's current transactions. Data source: -L<"INNODB_TRANSACTIONS">. - -=item insert_buffers - -Displays data about InnoDB's insert buffer. Data source: L<"STATUS_VARIABLES">. - -=item io_threads - -Displays data about InnoDB's I/O threads. Data source: L<"IO_THREADS">. - -=item log_statistics - -Displays data about InnoDB's logging system. Data source: L<"STATUS_VARIABLES">. - -=item master_status - -Displays replication master status. Data source: L<"STATUS_VARIABLES">. - -=item open_tables - -Displays open tables. Data source: L<"OPEN_TABLES">. - -=item page_statistics - -Displays InnoDB page statistics. Data source: L<"STATUS_VARIABLES">. - -=item pending_io - -Displays InnoDB pending I/O operations. Data source: L<"STATUS_VARIABLES">. - -=item processlist - -Displays current MySQL processes (threads/connections). Data source: -L<"PROCESSLIST">. - -=item q_header - -Displays various status values. Data source: L<"STATUS_VARIABLES">. - -=item row_operation_misc - -Displays data about InnoDB's row operations. Data source: -L<"STATUS_VARIABLES">. - -=item row_operations - -Displays data about InnoDB's row operations. Data source: -L<"STATUS_VARIABLES">. - -=item semaphores - -Displays data about InnoDB's semaphores and mutexes. Data source: -L<"STATUS_VARIABLES">. - -=item slave_io_status - -Displays data about the slave I/O thread. Data source: -L<"STATUS_VARIABLES">. - -=item slave_sql_status - -Displays data about the slave SQL thread. Data source: L<"STATUS_VARIABLES">. - -=item t_header - -Displays various InnoDB status values. Data source: L<"STATUS_VARIABLES">. - -=item var_status - -Displays user-configurable data. Data source: L<"STATUS_VARIABLES">. - -=item wait_array - -Displays data about InnoDB's OS wait array. Data source: L<"OS_WAIT_ARRAY">. - -=back - -=head2 COLUMNS - -Columns belong to tables. You can choose a table's columns by pressing the '^' -key, which starts the L<"TABLE EDITOR"> and lets you choose and edit columns. -Pressing 'e' from within the table editor lets you edit the column's properties: - -=over - -=item * - -hdr: a column header. This appears in the first row of the table. - -=item * - -just: justification. '-' means left-justified and '' means right-justified, -just as with printf formatting codes (not a coincidence). - -=item * - -dec: whether to further align the column on the decimal point. - -=item * - -num: whether the column is numeric. This affects how values are sorted -(lexically or numerically). - -=item * - -label: a small note about the column, which appears in dialogs that help the -user choose columns. - -=item * - -src: an expression that innotop uses to extract the column's data from its -source (see L<"DATA SOURCES">). See L<"EXPRESSIONS"> for more on expressions. - -=item * - -minw: specifies a minimum display width. This helps stabilize the display, -which makes it easier to read if the data is changing frequently. - -=item * - -maxw: similar to minw. - -=item * - -trans: a list of column transformations. See L<"TRANSFORMATIONS">. - -=item * - -agg: an aggregate function. See L<"GROUPING">. The default is L<"first">. - -=item * - -aggonly: controls whether the column only shows when grouping is enabled on the -table (see L<"GROUPING">). By default, this is disabled. This means columns -will always be shown by default, whether grouping is enabled or not. If a -column's aggonly is set true, the column will appear when you toggle grouping on -the table. Several columns are set this way, such as the count column on -L<"processlist"> and L<"innodb_transactions">, so you don't see a count when the -grouping isn't enabled, but you do when it is. - -=back - -=head2 FILTERS - -Filters remove rows from the display. They behave much like a WHERE clause in -SQL. innotop has several built-in filters, which remove irrelevant information -like inactive queries, but you can define your own as well. innotop also lets -you create quick-filters, which do not get saved to the configuration file, and -are just an easy way to quickly view only some rows. - -You can enable or disable a filter on any table. Press the '%' key (mnemonic: % -looks kind of like a line being filtered between two circles) and choose which -table you want to filter, if asked. You'll then see a list of possible filters -and a list of filters currently enabled for that table. Type the names of -filters you want to apply and press Enter. - -=head3 USER-DEFINED FILTERS - -If you type a name that doesn't exist, innotop will prompt you to create the -filter. Filters are easy to create if you know Perl, and not hard if you don't. -What you're doing is creating a subroutine that returns true if the row should -be displayed. The row is a hash reference passed to your subroutine as $set. - -For example, imagine you want to filter the processlist table so you only see -queries that have been running more than five minutes. Type a new name for your -filter, and when prompted for the subroutine body, press TAB to initiate your -terminal's auto-completion. You'll see the names of the columns in the -L<"processlist"> table (innotop generally tries to help you with auto-completion -lists). You want to filter on the 'time' column. Type the text "$set->{time} > -300" to return true when the query is more than five minutes old. That's all -you need to do. - -In other words, the code you're typing is surrounded by an implicit context, -which looks like this: - - sub filter { - my ( $set ) = @_; - # YOUR CODE HERE - } - -If your filter doesn't work, or if something else suddenly behaves differently, -you might have made an error in your filter, and innotop is silently catching -the error. Try enabling L<"debug"> to make innotop throw an error instead. - -=head3 QUICK-FILTERS - -innotop's quick-filters are a shortcut to create a temporary filter that doesn't -persist when you restart innotop. To create a quick-filter, press the '/' key. -innotop will prompt you for the column name and filter text. Again, you can use -auto-completion on column names. The filter text can be just the text you want -to "search for." For example, to filter the L<"processlist"> table on queries -that refer to the products table, type '/' and then 'info product'. - -The filter text can actually be any Perl regular expression, but of course a -literal string like 'product' works fine as a regular expression. - -Behind the scenes innotop compiles the quick-filter into a specially tagged -filter that is otherwise like any other filter. It just isn't saved to the -configuration file. - -To clear quick-filters, press the '\' key and innotop will clear them all at -once. - -=head2 SORTING - -innotop has sensible built-in defaults to sort the most important rows to the -top of the table. Like anything else in innotop, you can customize how any -table is sorted. - -To start the sort dialog, start the L<"TABLE EDITOR"> with the '^' key, choose a -table if necessary, and press the 's' key. You'll see a list of columns you can -use in the sort expression and the current sort expression, if any. Enter a -list of columns by which you want to sort and press Enter. If you want to -reverse sort, prefix the column name with a minus sign. For example, if you -want to sort by column a ascending, then column b descending, type 'a -b'. You -can also explicitly add a + in front of columns you want to sort ascending, but -it's not required. - -Some modes have keys mapped to open this dialog directly, and to quickly reverse -sort direction. Press '?' as usual to see which keys are mapped in any mode. - -=head2 GROUPING - -innotop can group, or aggregate, rows together (I use the terms -interchangeably). This is quite similar to an SQL GROUP BY clause. You can -specify to group on certain columns, or if you don't specify any, the entire set -of rows is treated as one group. This is quite like SQL so far, but unlike SQL, -you can also select un-grouped columns. innotop actually aggregates every -column. If you don't explicitly specify a grouping function, the default is -'first'. This is basically a convenience so you don't have to specify an -aggregate function for every column you want in the result. - -You can quickly toggle grouping on a table with the '=' key, which toggles its -aggregate property. This property doesn't persist to the config file. - -The columns by which the table is grouped are specified in its group_by -property. When you turn grouping on, innotop places the group_by columns at the -far left of the table, even if they're not supposed to be visible. The rest of -the visible columns appear in order after them. - -Two tables have default group_by lists and a count column built in: -L<"processlist"> and L<"innodb_transactions">. The grouping is by connection -and status, so you can quickly see how many queries or transactions are in a -given status on each server you're monitoring. The time columns are aggregated -as a sum; other columns are left at the default 'first' aggregation. - -By default, the table shown in L<"S: Variables & Status"> mode also uses -grouping so you can monitor variables and status across many servers. The -default aggregation function in this mode is 'avg'. - -Valid grouping functions are defined in the %agg_funcs hash. They include - -=over - -=item first - -Returns the first element in the group. - -=item count - -Returns the number of elements in the group, including undefined elements, much -like SQL's COUNT(*). - -=item avg - -Returns the average of defined elements in the group. - -=item sum - -Returns the sum of elements in the group. - -=back - -Here's an example of grouping at work. Suppose you have a very busy server with -hundreds of open connections, and you want to see how many connections are in -what status. Using the built-in grouping rules, you can press 'Q' to enter -L<"Q: Query List"> mode. Press '=' to toggle grouping (if necessary, select the -L<"processlist"> table when prompted). - -Your display might now look like the following: - - Query List (? for help) localhost, 32:33, 0.11 QPS, 1 thd, 5.0.38-log - - CXN Cmd Cnt ID User Host Time Query - localhost Query 49 12933 webusr localhost 19:38 SELECT * FROM - localhost Sending Da 23 2383 webusr localhost 12:43 SELECT col1, - localhost Sleep 120 140 webusr localhost 5:18:12 - localhost Statistics 12 19213 webusr localhost 01:19 SELECT * FROM - -That's actually quite a worrisome picture. You've got a lot of idle connections -(Sleep), and some connections executing queries (Query and Sending Data). -That's okay, but you also have a lot in Statistics status, collectively spending -over a minute. That means the query optimizer is having a really hard time -optimizing your statements. Something is wrong; it should normally take -milliseconds to optimize queries. You might not have seen this pattern if you -didn't look at your connections in aggregate. (This is a made-up example, but -it can happen in real life). - -=head2 PIVOTING - -innotop can pivot a table for more compact display, similar to a Pivot Table in -a spreadsheet (also known as a crosstab). Pivoting a table makes columns into -rows. Assume you start with this table: - - foo bar - === === - 1 3 - 2 4 - -After pivoting, the table will look like this: - - name set0 set1 - ==== ==== ==== - foo 1 2 - bar 3 4 - -To get reasonable results, you might need to group as well as pivoting. -innotop currently does this for L<"S: Variables & Status"> mode. - -=head2 COLORS - -By default, innotop highlights rows with color so you can see at a glance which -rows are more important. You can customize the colorization rules and add your -own to any table. Open the table editor with the '^' key, choose a table if -needed, and press 'o' to open the color editor dialog. - -The color editor dialog displays the rules applied to the table, in the order -they are evaluated. Each row is evaluated against each rule to see if the rule -matches the row; if it does, the row gets the specified color, and no further -rules are evaluated. The rules look like the following: - - state eq Locked black on_red - cmd eq Sleep white - user eq system user white - cmd eq Connect white - cmd eq Binlog Dump white - time > 600 red - time > 120 yellow - time > 60 green - time > 30 cyan - -This is the default rule set for the L<"processlist"> table. In order of -priority, these rules make locked queries black on a red background, "gray out" -connections from replication and sleeping queries, and make queries turn from -cyan to red as they run longer. - -(For some reason, the ANSI color code "white" is actually a light gray. Your -terminal's display may vary; experiment to find colors you like). - -You can use keystrokes to move the rules up and down, which re-orders their -priority. You can also delete rules and add new ones. If you add a new rule, -innotop prompts you for the column, an operator for the comparison, a value -against which to compare the column, and a color to assign if the rule matches. -There is auto-completion and prompting at each step. - -The value in the third step needs to be correctly quoted. innotop does not try -to quote the value because it doesn't know whether it should treat the value as -a string or a number. If you want to compare the column against a string, as -for example in the first rule above, you should enter 'Locked' surrounded by -quotes. If you get an error message about a bareword, you probably should have -quoted something. - -=head2 EXPRESSIONS - -Expressions are at the core of how innotop works, and are what enables you to -extend innotop as you wish. Recall the table lifecycle explained in -L<"TABLES">. Expressions are used in the earliest step, where it extracts -values from a data source to form rows. - -It does this by calling a subroutine for each column, passing it the source data -set, a set of current values, and a set of previous values. These are all -needed so the subroutine can calculate things like the difference between this -tick and the previous tick. - -The subroutines that extract the data from the set are compiled from -expressions. This gives significantly more power than just naming the values to -fill the columns, because it allows the column's value to be calculated from -whatever data is necessary, but avoids the need to write complicated and lengthy -Perl code. - -innotop begins with a string of text that can look as simple as a value's name -or as complicated as a full-fledged Perl expression. It looks at each -'bareword' token in the string and decides whether it's supposed to be a key -into the $set hash. A bareword is an unquoted value that isn't already -surrounded by code-ish things like dollar signs or curly brackets. If innotop -decides that the bareword isn't a function or other valid Perl code, it converts -it into a hash access. After the whole string is processed, innotop compiles a -subroutine, like this: - - sub compute_column_value { - my ( $set, $cur, $pre ) = @_; - my $val = # EXPANDED STRING GOES HERE - return $val; - } - -Here's a concrete example, taken from the header table L<"q_header"> in L<"Q: -Query List"> mode. This expression calculates the qps, or Queries Per Second, -column's values, from the values returned by SHOW STATUS: - - Questions/Uptime_hires - -innotop decides both words are barewords, and transforms this expression into -the following Perl code: - - $set->{Questions}/$set->{Uptime_hires} - -When surrounded by the rest of the subroutine's code, this is executable Perl -that calculates a high-resolution queries-per-second value. - -The arguments to the subroutine are named $set, $cur, and $pre. In most cases, -$set and $cur will be the same values. However, if L<"status_inc"> is set, $cur -will not be the same as $set, because $set will already contain values that are -the incremental difference between $cur and $pre. - -Every column in innotop is computed by subroutines compiled in the same fashion. -There is no difference between innotop's built-in columns and user-defined -columns. This keeps things consistent and predictable. - -=head2 TRANSFORMATIONS - -Transformations change how a value is rendered. For example, they can take a -number of seconds and display it in H:M:S format. The following transformations -are defined: - -=over - -=item commify - -Adds commas to large numbers every three decimal places. - -=item dulint_to_int - -Accepts two unsigned integers and converts them into a single longlong. This is -useful for certain operations with InnoDB, which uses two integers as -transaction identifiers, for example. - -=item no_ctrl_char - -Removes quoted control characters from the value. This is affected by the -L<"charset"> configuration variable. - -This transformation only operates within quoted strings, for example, values to -a SET clause in an UPDATE statement. It will not alter the UPDATE statement, -but will collapse the quoted string to [BINARY] or [TEXT], depending on the -charset. - -=item percent - -Converts a number to a percentage by multiplying it by two, formatting it with -L<"num_digits"> digits after the decimal point, and optionally adding a percent -sign (see L<"show_percent">). - -=item secs_to_time - -Formats a number of seconds as time in days+hours:minutes:seconds format. - -=item set_precision - -Formats numbers with L<"num_digits"> number of digits after the decimal point. - -=item shorten - -Formats a number as a unit of 1024 (k/M/G/T) and with L<"num_digits"> number of -digits after the decimal point. - -=back - -=head2 TABLE EDITOR - -The innotop table editor lets you customize tables with keystrokes. You start -the table editor with the '^' key. If there's more than one table on the -screen, it will prompt you to choose one of them. Once you do, innotop will -show you something like this: - - Editing table definition for Buffer Pool. Press ? for help, q to quit. - - name hdr label src - cxn CXN Connection from which cxn - buf_pool_size Size Buffer pool size IB_bp_buf_poo - buf_free Free Bufs Buffers free in the b IB_bp_buf_fre - pages_total Pages Pages total IB_bp_pages_t - pages_modified Dirty Pages Pages modified (dirty IB_bp_pages_m - buf_pool_hit_rate Hit Rate Buffer pool hit rate IB_bp_buf_poo - total_mem_alloc Memory Total memory allocate IB_bp_total_m - add_pool_alloc Add'l Pool Additonal pool alloca IB_bp_add_poo - -The first line shows which table you're editing, and reminds you again to press -'?' for a list of key mappings. The rest is a tabular representation of the -table's columns, because that's likely what you're trying to edit. However, you -can edit more than just the table's columns; this screen can start the filter -editor, color rule editor, and more. - -Each row in the display shows a single column in the table you're editing, along -with a couple of its properties such as its header and source expression (see -L<"EXPRESSIONS">). - -The key mappings are Vim-style, as in many other places. Pressing 'j' and 'k' -moves the highlight up or down. You can then (d)elete or (e)dit the highlighted -column. You can also (a)dd a column to the table. This actually just activates -one of the columns already defined for the table; it prompts you to choose from -among the columns available but not currently displayed. Finally, you can -re-order the columns with the '+' and '-' keys. - -You can do more than just edit the columns with the table editor, you can also -edit other properties, such as the table's sort expression and group-by -expression. Press '?' to see the full list, of course. - -If you want to really customize and create your own column, as opposed to just -activating a built-in one that's not currently displayed, press the (n)ew key, -and innotop will prompt you for the information it needs: - -=over - -=item * - -The column name: this needs to be a word without any funny characters, e.g. just -letters, numbers and underscores. - -=item * - -The column header: this is the label that appears at the top of the column, in -the table header. This can have spaces and funny characters, but be careful not -to make it too wide and waste space on-screen. - -=item * - -The column's data source: this is an expression that determines what data from -the source (see L<"TABLES">) innotop will put into the column. This can just be -the name of an item in the source, or it can be a more complex expression, as -described in L<"EXPRESSIONS">. - -=back - -Once you've entered the required data, your table has a new column. There is no -difference between this column and the built-in ones; it can have all the same -properties and behaviors. innotop will write the column's definition to the -configuration file, so it will persist across sessions. - -Here's an example: suppose you want to track how many times your slaves have -retried transactions. According to the MySQL manual, the -Slave_retried_transactions status variable gives you that data: "The total -number of times since startup that the replication slave SQL thread has retried -transactions. This variable was added in version 5.0.4." This is appropriate to -add to the L<"slave_sql_status"> table. - -To add the column, switch to the replication-monitoring mode with the 'M' key, -and press the '^' key to start the table editor. When prompted, choose -slave_sql_status as the table, then press 'n' to create the column. Type -'retries' as the column name, 'Retries' as the column header, and -'Slave_retried_transactions' as the source. Now the column is created, and you -see the table editor screen again. Press 'q' to exit the table editor, and -you'll see your column at the end of the table. - -=head1 VARIABLE SETS - -Variable sets are used in L<"S: Variables & Status"> mode to define more easily -what variables you want to monitor. Behind the scenes they are compiled to a -list of expressions, and then into a column list so they can be treated just -like columns in any other table, in terms of data extraction and -transformations. However, you're protected from the tedious details by a syntax -that ought to feel very natural to you: a SQL SELECT list. - -The data source for variable sets, and indeed the entire S mode, is the -combination of SHOW STATUS, SHOW VARIABLES, and SHOW INNODB STATUS. Imagine -that you had a huge table with one column per variable returned from those -statements. That's the data source for variable sets. You can now query this -data source just like you'd expect. For example: - - Questions, Uptime, Questions/Uptime as QPS - -Behind the scenes innotop will split that variable set into three expressions, -compile them and turn them into a table definition, then extract as usual. This -becomes a "variable set," or a "list of variables you want to monitor." - -innotop lets you name and save your variable sets, and writes them to the -configuration file. You can choose which variable set you want to see with the -'c' key, or activate the next and previous sets with the '>' and '<' keys. -There are many built-in variable sets as well, which should give you a good -start for creating your own. Press 'e' to edit the current variable set, or -just to see how it's defined. To create a new one, just press 'c' and type its -name. - -You may want to use some of the functions listed in L<"TRANSFORMATIONS"> to help -format the results. In particular, L<"set_precision"> is often useful to limit -the number of digits you see. Extending the above example, here's how: - - Questions, Uptime, set_precision(Questions/Uptime) as QPS - -Actually, this still needs a little more work. If your L<"interval"> is less -than one second, you might be dividing by zero because Uptime is incremental in -this mode by default. Instead, use Uptime_hires: - - Questions, Uptime, set_precision(Questions/Uptime_hires) as QPS - -This example is simple, but it shows how easy it is to choose which variables -you want to monitor. - -=head1 PLUGINS - -innotop has a simple but powerful plugin mechanism by which you can extend -or modify its existing functionality, and add new functionality. innotop's -plugin functionality is event-based: plugins register themselves to be called -when events happen. They then have a chance to influence the event. - -An innotop plugin is a Perl module placed in innotop's L<"plugin_dir"> -directory. On UNIX systems, you can place a symbolic link to the module instead -of putting the actual file there. innotop automatically discovers the file. If -there is a corresponding entry in the L<"plugins"> configuration file section, -innotop loads and activates the plugin. - -The module must conform to innotop's plugin interface. Additionally, the source -code of the module must be written in such a way that innotop can inspect the -file and determine the package name and description. - -=head2 Package Source Convention - -innotop inspects the plugin module's source to determine the Perl package name. -It looks for a line of the form "package Foo;" and if found, considers the -plugin's package name to be Foo. Of course the package name can be a valid Perl -package name, with double semicolons and so on. - -It also looks for a description in the source code, to make the plugin editor -more human-friendly. The description is a comment line of the form "# -description: Foo", where "Foo" is the text innotop will consider to be the -plugin's description. - -=head2 Plugin Interface - -The innotop plugin interface is quite simple: innotop expects the plugin to be -an object-oriented module it can call certain methods on. The methods are - -=over - -=item new(%variables) - -This is the plugin's constructor. It is passed a hash of innotop's variables, -which it can manipulate (see L<"Plugin Variables">). It must return a reference -to the newly created plugin object. - -At construction time, innotop has only loaded the general configuration and -created the default built-in variables with their default contents (which is -quite a lot). Therefore, the state of the program is exactly as in the innotop -source code, plus the configuration variables from the L<"general"> section in -the config file. - -If your plugin manipulates the variables, it is changing global data, which is -shared by innotop and all plugins. Plugins are loaded in the order they're -listed in the config file. Your plugin may load before or after another plugin, -so there is a potential for conflict or interaction between plugins if they -modify data other plugins use or modify. - -=item register_for_events() - -This method must return a list of events in which the plugin is interested, if -any. See L<"Plugin Events"> for the defined events. If the plugin returns an -event that's not defined, the event is ignored. - -=item event handlers - -The plugin must implement a method named the same as each event for which it has -registered. In other words, if the plugin returns qw(foo bar) from -register_for_events(), it must have foo() and bar() methods. These methods are -callbacks for the events. See L<"Plugin Events"> for more details about each -event. - -=back - -=head2 Plugin Variables - -The plugin's constructor is passed a hash of innotop's variables, which it can -manipulate. It is probably a good idea if the plugin object saves a copy of it -for later use. The variables are defined in the innotop variable -%pluggable_vars, and are as follows: - -=over - -=item action_for - -A hashref of key mappings. These are innotop's global hot-keys. - -=item agg_funcs - -A hashref of functions that can be used for grouping. See L<"GROUPING">. - -=item config - -The global configuration hash. - -=item connections - -A hashref of connection specifications. These are just specifications of how to -connect to a server. - -=item dbhs - -A hashref of innotop's database connections. These are actual DBI connection -objects. - -=item filters - -A hashref of filters applied to table rows. See L<"FILTERS"> for more. - -=item modes - -A hashref of modes. See L<"MODES"> for more. - -=item server_groups - -A hashref of server groups. See L<"SERVER GROUPS">. - -=item tbl_meta - -A hashref of innotop's table meta-data, with one entry per table (see -L<"TABLES"> for more information). - -=item trans_funcs - -A hashref of transformation functions. See L<"TRANSFORMATIONS">. - -=item var_sets - -A hashref of variable sets. See L<"VARIABLE SETS">. - -=back - -=head2 Plugin Events - -Each event is defined somewhere in the innotop source code. When innotop runs -that code, it executes the callback function for each plugin that expressed its -interest in the event. innotop passes some data for each event. The events are -defined in the %event_listener_for variable, and are as follows: - -=over - -=item extract_values($set, $cur, $pre, $tbl) - -This event occurs inside the function that extracts values from a data source. -The arguments are the set of values, the current values, the previous values, -and the table name. - -=item set_to_tbl - -Events are defined at many places in this subroutine, which is responsible for -turning an arrayref of hashrefs into an arrayref of lines that can be printed to -the screen. The events all pass the same data: an arrayref of rows and the name -of the table being created. The events are set_to_tbl_pre_filter, -set_to_tbl_pre_sort,set_to_tbl_pre_group, set_to_tbl_pre_colorize, -set_to_tbl_pre_transform, set_to_tbl_pre_pivot, set_to_tbl_pre_create, -set_to_tbl_post_create. - -=item draw_screen($lines) - -This event occurs inside the subroutine that prints the lines to the screen. -$lines is an arrayref of strings. - -=back - -=head2 Simple Plugin Example - -The easiest way to explain the plugin functionality is probably with a simple -example. The following module adds a column to the beginning of every table and -sets its value to 1. - - use strict; - use warnings FATAL => 'all'; - - package Innotop::Plugin::Example; - # description: Adds an 'example' column to every table - - sub new { - my ( $class, %vars ) = @_; - # Store reference to innotop's variables in $self - my $self = bless { %vars }, $class; - - # Design the example column - my $col = { - hdr => 'Example', - just => '', - dec => 0, - num => 1, - label => 'Example', - src => 'example', # Get data from this column in the data source - tbl => '', - trans => [], - }; - - # Add the column to every table. - my $tbl_meta = $vars{tbl_meta}; - foreach my $tbl ( values %$tbl_meta ) { - # Add the column to the list of defined columns - $tbl->{cols}->{example} = $col; - # Add the column to the list of visible columns - unshift @{$tbl->{visible}}, 'example'; - } - - # Be sure to return a reference to the object. - return $self; - } - - # I'd like to be called when a data set is being rendered into a table, please. - sub register_for_events { - my ( $self ) = @_; - return qw(set_to_tbl_pre_filter); - } - - # This method will be called when the event fires. - sub set_to_tbl_pre_filter { - my ( $self, $rows, $tbl ) = @_; - # Set the example column's data source to the value 1. - foreach my $row ( @$rows ) { - $row->{example} = 1; - } - } - - 1; - -=head2 Plugin Editor - -The plugin editor lets you view the plugins innotop discovered and activate or -deactivate them. Start the editor by pressing $ to start the configuration -editor from any mode. Press the 'p' key to start the plugin editor. You'll see -a list of plugins innotop discovered. You can use the 'j' and 'k' keys to move -the highlight to the desired one, then press the * key to toggle it active or -inactive. Exit the editor and restart innotop for the changes to take effect. - -=head1 SQL STATEMENTS - -innotop uses a limited set of SQL statements to retrieve data from MySQL for -display. The statements are customized depending on the server version against -which they are executed; for example, on MySQL 5 and newer, INNODB_STATUS -executes "SHOW ENGINE INNODB STATUS", while on earlier versions it executes -"SHOW INNODB STATUS". The statements are as follows: - - Statement SQL executed - =================== =============================== - INNODB_STATUS SHOW [ENGINE] INNODB STATUS - KILL_CONNECTION KILL - KILL_QUERY KILL QUERY - OPEN_TABLES SHOW OPEN TABLES - PROCESSLIST SHOW FULL PROCESSLIST - SHOW_MASTER_LOGS SHOW MASTER LOGS - SHOW_MASTER_STATUS SHOW MASTER STATUS - SHOW_SLAVE_STATUS SHOW SLAVE STATUS - SHOW_STATUS SHOW [GLOBAL] STATUS - SHOW_VARIABLES SHOW [GLOBAL] VARIABLES - -=head1 DATA SOURCES - -Each time innotop extracts values to create a table (see L<"EXPRESSIONS"> and -L<"TABLES">), it does so from a particular data source. Largely because of the -complex data extracted from SHOW INNODB STATUS, this is slightly messy. SHOW -INNODB STATUS contains a mixture of single values and repeated values that form -nested data sets. - -Whenever innotop fetches data from MySQL, it adds two extra bits to each set: -cxn and Uptime_hires. cxn is the name of the connection from which the data -came. Uptime_hires is a high-resolution version of the server's Uptime status -variable, which is important if your L<"interval"> setting is sub-second. - -Here are the kinds of data sources from which data is extracted: - -=over - -=item STATUS_VARIABLES - -This is the broadest category, into which the most kinds of data fall. It -begins with the combination of SHOW STATUS and SHOW VARIABLES, but other sources -may be included as needed, for example, SHOW MASTER STATUS and SHOW SLAVE -STATUS, as well as many of the non-repeated values from SHOW INNODB STATUS. - -=item DEADLOCK_LOCKS - -This data is extracted from the transaction list in the LATEST DETECTED DEADLOCK -section of SHOW INNODB STATUS. It is nested two levels deep: transactions, then -locks. - -=item DEADLOCK_TRANSACTIONS - -This data is from the transaction list in the LATEST DETECTED DEADLOCK -section of SHOW INNODB STATUS. It is nested one level deep. - -=item EXPLAIN - -This data is from the result set returned by EXPLAIN. - -=item INNODB_TRANSACTIONS - -This data is from the TRANSACTIONS section of SHOW INNODB STATUS. - -=item IO_THREADS - -This data is from the list of threads in the the FILE I/O section of SHOW INNODB -STATUS. - -=item INNODB_LOCKS - -This data is from the TRANSACTIONS section of SHOW INNODB STATUS and is nested -two levels deep. - -=item OPEN_TABLES - -This data is from SHOW OPEN TABLES. - -=item PROCESSLIST - -This data is from SHOW FULL PROCESSLIST. - -=item OS_WAIT_ARRAY - -This data is from the SEMAPHORES section of SHOW INNODB STATUS and is nested one -level deep. It comes from the lines that look like this: - - --Thread 1568861104 has waited at btr0cur.c line 424 .... - -=back - -=head1 MYSQL PRIVILEGES - -=over - -=item * - -You must connect to MySQL as a user who has the SUPER privilege for many of the -functions. - -=item * - -If you don't have the SUPER privilege, you can still run some functions, but you -won't necessarily see all the same data. - -=item * - -You need the PROCESS privilege to see the list of currently running queries in Q -mode. - -=item * - -You need special privileges to start and stop slave servers. - -=item * - -You need appropriate privileges to create and drop the deadlock tables if needed -(see L<"SERVER CONNECTIONS">). - -=back - -=head1 SYSTEM REQUIREMENTS - -You need Perl to run innotop, of course. You also need a few Perl modules: DBI, -DBD::mysql, Term::ReadKey, and Time::HiRes. These should be included with most -Perl distributions, but in case they are not, I recommend using versions -distributed with your operating system or Perl distribution, not from CPAN. -Term::ReadKey in particular has been known to cause problems if installed from -CPAN. - -If you have Term::ANSIColor, innotop will use it to format headers more readably -and compactly. (Under Microsoft Windows, you also need Win32::Console::ANSI for -terminal formatting codes to be honored). If you install Term::ReadLine, -preferably Term::ReadLine::Gnu, you'll get nice auto-completion support. - -I run innotop on Gentoo GNU/Linux, Debian and Ubuntu, and I've had feedback from -people successfully running it on Red Hat, CentOS, Solaris, and Mac OSX. I -don't see any reason why it won't work on other UNIX-ish operating systems, but -I don't know for sure. It also runs on Windows under ActivePerl without -problem. - -I use innotop on MySQL versions 3.23.58, 4.0.27, 4.1.0, 4.1.22, 5.0.26, 5.1.15, -and 5.2.3. If it doesn't run correctly for you, that is a bug and I hope you -report it. - -=head1 FILES - -$HOMEDIR/.innotop is used to store configuration information. Files include the -configuration file innotop.ini, the core_dump file which contains verbose error -messages if L<"debug"> is enabled, and the plugins/ subdirectory. - -=head1 GLOSSARY OF TERMS - -=over - -=item tick - -A tick is a refresh event, when innotop re-fetches data from connections and -displays it. - -=back - -=head1 ACKNOWLEDGEMENTS - -I'm grateful to the following people for various reasons, and hope I haven't -forgotten to include anyone: - -Allen K. Smith, -Aurimas Mikalauskas, -Bartosz Fenski, -Brian Miezejewski, -Christian Hammers, -Cyril Scetbon, -Dane Miller, -David Multer, -Dr. Frank Ullrich, -Giuseppe Maxia, -Google.com Site Reliability Engineers, -Jan Pieter Kunst, -Jari Aalto, -Jay Pipes, -Jeremy Zawodny, -Johan Idren, -Kristian Kohntopp, -Lenz Grimmer, -Maciej Dobrzanski, -Michiel Betel, -MySQL AB, -Paul McCullagh, -Sebastien Estienne, -Sourceforge.net, -Steven Kreuzer, -The Gentoo MySQL Team, -Trevor Price, -Yaar Schnitman, -and probably more people I've neglected to include. - -(If I misspelled your name, it's probably because I'm afraid of putting -international characters into this documentation; earlier versions of Perl might -not be able to compile it then). - -=head1 COPYRIGHT, LICENSE AND WARRANTY - -This program is copyright (c) 2006 Baron Schwartz. -Feedback and improvements are welcome. - -THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - -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; OR the Perl Artistic License. On UNIX and similar -systems, you can issue `man perlgpl' or `man perlartistic' to read these -licenses. - -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., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA. - -Execute innotop and press '!' to see this information at any time. - -=head1 AUTHOR - -Baron Schwartz. - -=head1 BUGS - -You can report bugs, ask for improvements, and get other help and support at -L. There are mailing lists, forums, -a bug tracker, etc. Please use these instead of contacting me directly, as it -makes my job easier and benefits others if the discussions are permanent and -public. Of course, if you need to contact me in private, please do. - -=cut diff --git a/storage/xtradb/build/debian/additions/innotop/innotop.1 b/storage/xtradb/build/debian/additions/innotop/innotop.1 deleted file mode 100644 index ef708c3974c..00000000000 --- a/storage/xtradb/build/debian/additions/innotop/innotop.1 +++ /dev/null @@ -1,2086 +0,0 @@ -.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sh \" Subsection heading -.br -.if t .Sp -.ne 5 -.PP -\fB\\$1\fR -.PP -.. -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. \*(C+ will -.\" give a nicer C++. Capital omega is used to do unbreakable dashes and -.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, -.\" nothing in troff, for use with C<>. -.tr \(*W- -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -'br\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -'br\} -.\" -.\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.if \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. nr % 0 -. rr F -.\} -.\" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.hy 0 -.if n .na -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "INNOTOP 1p" -.TH INNOTOP 1p "2007-11-09" "perl v5.8.8" "User Contributed Perl Documentation" -.SH "NAME" -innotop \- MySQL and InnoDB transaction/status monitor. -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -To monitor servers normally: -.PP -.Vb 1 -\& innotop -.Ve -.PP -To monitor InnoDB status information from a file: -.PP -.Vb 1 -\& innotop /var/log/mysql/mysqld.err -.Ve -.PP -To run innotop non-interactively in a pipe-and-filter configuration: -.PP -.Vb 1 -\& innotop \-\-count 5 \-d 1 \-n -.Ve -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -innotop monitors MySQL servers. Each of its modes shows you a different aspect -of what's happening in the server. For example, there's a mode for monitoring -replication, one for queries, and one for transactions. innotop refreshes its -data periodically, so you see an updating view. -.PP -innotop has lots of features for power users, but you can start and run it with -virtually no configuration. If you're just getting started, see -\&\*(L"\s-1QUICK\-START\s0\*(R". Press '?' at any time while running innotop for -context-sensitive help. -.SH "QUICK-START" -.IX Header "QUICK-START" -To start innotop, open a terminal or command prompt. If you have installed -innotop on your system, you should be able to just type \*(L"innotop\*(R" and press -Enter; otherwise, you will need to change to innotop's directory and type \*(L"perl -innotop\*(R". -.PP -The first thing innotop needs to know is how to connect to a MySQL server. You -can just enter the hostname of the server, for example \*(L"localhost\*(R" or -\&\*(L"127.0.0.1\*(R" if the server is on the same machine as innotop. After this innotop -will prompt you for a \s-1DSN\s0 (data source name). You should be able to just accept -the defaults by pressing Enter. -.PP -When innotop asks you about a table to use when resetting InnoDB deadlock -information, just accept the default for now. This is an advanced feature you -can configure later (see \*(L"D: InnoDB Deadlocks\*(R" for more). -.PP -If you have a .my.cnf file with your MySQL connection defaults, innotop can read -it, and you won't need to specify a username and password if it's in that file. -Otherwise, you should answer 'y' to the next couple of prompts. -.PP -After this, you should be connected, and innotop should show you something like -the following: -.PP -.Vb 1 -\& InnoDB Txns (? for help) localhost, 01:11:19, InnoDB 10s :\-), 50 QPS, -.Ve -.PP -.Vb 2 -\& CXN History Versions Undo Dirty Buf Used Bufs Txns MaxTxn -\& localhost 7 2035 0 0 0.00% 92.19% 1 07:34 -.Ve -.PP -.Vb 5 -\& CXN ID User Host Txn Status Time Undo Query Tex -\& localhost 98379 user1 webserver ACTIVE 07:34 0 SELECT `c -\& localhost 98450 user1 webserver ACTIVE 01:06 0 INSERT IN -\& localhost 97750 user1 webserver not starte 00:00 0 -\& localhost 98375 user1 appserver not starte 00:00 0 -.Ve -.PP -(This sample is truncated at the right so it will fit on a terminal when running -\&'man innotop') -.PP -This sample comes from a quiet server with few transactions active. If your -server is busy, you'll see more output. Notice the first line on the screen, -which tells you what mode you're in and what server you're connected to. You -can change to other modes with keystrokes; press 'Q' to switch to a list of -currently running queries. -.PP -Press the '?' key to see what keys are active in the current mode. You can -press any of these keys and innotop will either take the requested action or -prompt you for more input. If your system has Term::ReadLine support, you can -use \s-1TAB\s0 and other keys to auto-complete and edit input. -.PP -To quit innotop, press the 'q' key. -.SH "OPTIONS" -.IX Header "OPTIONS" -innotop is mostly configured via its configuration file, but some of the -configuration options can come from the command line. You can also specify a -file to monitor for InnoDB status output; see \*(L"\s-1MONITORING\s0 A \s-1FILE\s0\*(R" for more -details. -.PP -You can negate some options by prefixing the option name with \-\-no. For -example, \-\-noinc (or \-\-no\-inc) negates \*(L"\-\-inc\*(R". -.IP "\-\-help" 4 -.IX Item "--help" -Print a summary of command-line usage and exit. -.IP "\-\-color" 4 -.IX Item "--color" -Enable or disable terminal coloring. Corresponds to the \*(L"color\*(R" config file -setting. -.IP "\-\-config" 4 -.IX Item "--config" -Specifies a configuration file to read. This option is non\-sticky, that is to -say it does not persist to the configuration file itself. -.IP "\-\-nonint" 4 -.IX Item "--nonint" -Enable non-interactive operation. See \*(L"\s-1NON\-INTERACTIVE\s0 \s-1OPERATION\s0\*(R" for more. -.IP "\-\-count" 4 -.IX Item "--count" -Refresh only the specified number of times (ticks) before exiting. Each refresh -is a pause for \*(L"interval\*(R" seconds, followed by requesting data from MySQL -connections and printing it to the terminal. -.IP "\-\-delay" 4 -.IX Item "--delay" -Specifies the amount of time to pause between ticks (refreshes). Corresponds to -the configuration option \*(L"interval\*(R". -.IP "\-\-mode" 4 -.IX Item "--mode" -Specifies the mode in which innotop should start. Corresponds to the -configuration option \*(L"mode\*(R". -.IP "\-\-inc" 4 -.IX Item "--inc" -Specifies whether innotop should display absolute numbers or relative numbers -(offsets from their previous values). Corresponds to the configuration option -\&\*(L"status_inc\*(R". -.IP "\-\-version" 4 -.IX Item "--version" -Output version information and exit. -.SH "HOTKEYS" -.IX Header "HOTKEYS" -innotop is interactive, and you control it with key\-presses. -.IP "\(bu" 4 -Uppercase keys switch between modes. -.IP "\(bu" 4 -Lowercase keys initiate some action within the current mode. -.IP "\(bu" 4 -Other keys do something special like change configuration or show the -innotop license. -.PP -Press '?' at any time to see the currently active keys and what they do. -.SH "MODES" -.IX Header "MODES" -Each of innotop's modes retrieves and displays a particular type of data from -the servers you're monitoring. You switch between modes with uppercase keys. -The following is a brief description of each mode, in alphabetical order. To -switch to the mode, press the key listed in front of its heading in the -following list: -.IP "B: InnoDB Buffers" 4 -.IX Item "B: InnoDB Buffers" -This mode displays information about the InnoDB buffer pool, page statistics, -insert buffer, and adaptive hash index. The data comes from \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. -.Sp -This mode contains the \*(L"buffer_pool\*(R", \*(L"page_statistics\*(R", -\&\*(L"insert_buffers\*(R", and \*(L"adaptive_hash_index\*(R" tables by default. -.IP "C: Command Summary" 4 -.IX Item "C: Command Summary" -This mode is similar to mytop's Command Summary mode. It shows the -\&\*(L"cmd_summary\*(R" table, which looks something like the following: -.Sp -.Vb 8 -\& Command Summary (? for help) localhost, 25+07:16:43, 2.45 QPS, 3 thd, 5.0.40 -\& _____________________ Command Summary _____________________ -\& Name Value Pct Last Incr Pct -\& Select_scan 3244858 69.89% 2 100.00% -\& Select_range 1354177 29.17% 0 0.00% -\& Select_full_join 39479 0.85% 0 0.00% -\& Select_full_range_join 4097 0.09% 0 0.00% -\& Select_range_check 0 0.00% 0 0.00% -.Ve -.Sp -The command summary table is built by extracting variables from -\&\*(L"\s-1STATUS_VARIABLES\s0\*(R". The variables must be numeric and must match the prefix -given by the \*(L"cmd_filter\*(R" configuration variable. The variables are then -sorted by value descending and compared to the last variable, as shown above. -The percentage columns are percentage of the total of all variables in the -table, so you can see the relative weight of the variables. -.Sp -The example shows what you see if the prefix is \*(L"Select_\*(R". The default -prefix is \*(L"Com_\*(R". You can choose a prefix with the 's' key. -.Sp -It's rather like running \s-1SHOW\s0 \s-1VARIABLES\s0 \s-1LIKE\s0 \*(L"prefix%\*(R" with memory and -nice formatting. -.Sp -Values are aggregated across all servers. The Pct columns are not correctly -aggregated across multiple servers. This is a known limitation of the grouping -algorithm that may be fixed in the future. -.IP "D: InnoDB Deadlocks" 4 -.IX Item "D: InnoDB Deadlocks" -This mode shows the transactions involved in the last InnoDB deadlock. A second -table shows the locks each transaction held and waited for. A deadlock is -caused by a cycle in the waits-for graph, so there should be two locks held and -one waited for unless the deadlock information is truncated. -.Sp -InnoDB puts deadlock information before some other information in the \s-1SHOW\s0 -\&\s-1INNODB\s0 \s-1STATUS\s0 output. If there are a lot of locks, the deadlock information can -grow very large, and there is a limit on the size of the \s-1SHOW\s0 \s-1INNODB\s0 -\&\s-1STATUS\s0 output. A large deadlock can fill the entire output, or even be -truncated, and prevent you from seeing other information at all. If you are -running innotop in another mode, for example T mode, and suddenly you don't see -anything, you might want to check and see if a deadlock has wiped out the data -you need. -.Sp -If it has, you can create a small deadlock to replace the large one. Use the -\&'w' key to 'wipe' the large deadlock with a small one. This will not work -unless you have defined a deadlock table for the connection (see \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R"). -.Sp -You can also configure innotop to automatically detect when a large deadlock -needs to be replaced with a small one (see \*(L"auto_wipe_dl\*(R"). -.Sp -This mode displays the \*(L"deadlock_transactions\*(R" and \*(L"deadlock_locks\*(R" tables -by default. -.IP "F: InnoDB Foreign Key Errors" 4 -.IX Item "F: InnoDB Foreign Key Errors" -This mode shows the last InnoDB foreign key error information, such as the -table where it happened, when and who and what query caused it, and so on. -.Sp -InnoDB has a huge variety of foreign key error messages, and many of them are -just hard to parse. innotop doesn't always do the best job here, but there's -so much code devoted to parsing this messy, unparseable output that innotop is -likely never to be perfect in this regard. If innotop doesn't show you what -you need to see, just look at the status text directly. -.Sp -This mode displays the \*(L"fk_error\*(R" table by default. -.IP "I: InnoDB I/O Info" 4 -.IX Item "I: InnoDB I/O Info" -This mode shows InnoDB's I/O statistics, including the I/O threads, pending I/O, -file I/O miscellaneous, and log statistics. It displays the \*(L"io_threads\*(R", -\&\*(L"pending_io\*(R", \*(L"file_io_misc\*(R", and \*(L"log_statistics\*(R" tables by default. -.IP "L: Locks" 4 -.IX Item "L: Locks" -This mode shows information about current locks. At the moment only InnoDB -locks are supported, and by default you'll only see locks for which transactions -are waiting. This information comes from the \s-1TRANSACTIONS\s0 section of the InnoDB -status text. If you have a very busy server, you may have frequent lock waits; -it helps to be able to see which tables and indexes are the \*(L"hot spot\*(R" for -locks. If your server is running pretty well, this mode should show nothing. -.Sp -You can configure MySQL and innotop to monitor not only locks for which a -transaction is waiting, but those currently held, too. You can do this with the -InnoDB Lock Monitor (). It's -not documented in the MySQL manual, but creating the lock monitor with the -following statement also affects the output of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0, which innotop -uses: -.Sp -.Vb 1 -\& CREATE TABLE innodb_lock_monitor(a int) ENGINE=INNODB; -.Ve -.Sp -This causes InnoDB to print its output to the MySQL file every 16 seconds or so, -as stated in the manual, but it also makes the normal \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 output -include lock information, which innotop can parse and display (that's the -undocumented feature). -.Sp -This means you can do what may have seemed impossible: to a limited extent -(InnoDB truncates some information in the output), you can see which transaction -holds the locks something else is waiting for. You can also enable and disable -the InnoDB Lock Monitor with the key mappings in this mode. -.Sp -This mode displays the \*(L"innodb_locks\*(R" table by default. Here's a sample of -the screen when one connection is waiting for locks another connection holds: -.Sp -.Vb 7 -\& _________________________________ InnoDB Locks __________________________ -\& CXN ID Type Waiting Wait Active Mode DB Table Index -\& localhost 12 RECORD 1 00:10 00:10 X test t1 PRIMARY -\& localhost 12 TABLE 0 00:10 00:10 IX test t1 -\& localhost 12 RECORD 1 00:10 00:10 X test t1 PRIMARY -\& localhost 11 TABLE 0 00:00 00:25 IX test t1 -\& localhost 11 RECORD 0 00:00 00:25 X test t1 PRIMARY -.Ve -.Sp -You can see the first connection, \s-1ID\s0 12, is waiting for a lock on the \s-1PRIMARY\s0 -key on test.t1, and has been waiting for 10 seconds. The second connection -isn't waiting, because the Waiting column is 0, but it holds locks on the same -index. That tells you connection 11 is blocking connection 12. -.IP "M: Master/Slave Replication Status" 4 -.IX Item "M: Master/Slave Replication Status" -This mode shows the output of \s-1SHOW\s0 \s-1SLAVE\s0 \s-1STATUS\s0 and \s-1SHOW\s0 \s-1MASTER\s0 \s-1STATUS\s0 in three -tables. The first two divide the slave's status into \s-1SQL\s0 and I/O thread status, -and the last shows master status. Filters are applied to eliminate non-slave -servers from the slave tables, and non-master servers from the master table. -.Sp -This mode displays the \*(L"slave_sql_status\*(R", \*(L"slave_io_status\*(R", and -\&\*(L"master_status\*(R" tables by default. -.IP "O: Open Tables" 4 -.IX Item "O: Open Tables" -This section comes from MySQL's \s-1SHOW\s0 \s-1OPEN\s0 \s-1TABLES\s0 command. By default it is -filtered to show tables which are in use by one or more queries, so you can -get a quick look at which tables are 'hot'. You can use this to guess which -tables might be locked implicitly. -.Sp -This mode displays the \*(L"open_tables\*(R" mode by default. -.IP "Q: Query List" 4 -.IX Item "Q: Query List" -This mode displays the output from \s-1SHOW\s0 \s-1FULL\s0 \s-1PROCESSLIST\s0, much like \fBmytop\fR's -query list mode. This mode does \fBnot\fR show InnoDB-related information. This -is probably one of the most useful modes for general usage. -.Sp -There is an informative header that shows general status information about -your server. You can toggle it on and off with the 'h' key. By default, -innotop hides inactive processes and its own process. You can toggle these on -and off with the 'i' and 'a' keys. -.Sp -You can \s-1EXPLAIN\s0 a query from this mode with the 'e' key. This displays the -query's full text, the results of \s-1EXPLAIN\s0, and in newer MySQL versions, even -the optimized query resulting from \s-1EXPLAIN\s0 \s-1EXTENDED\s0. innotop also tries to -rewrite certain queries to make them EXPLAIN\-able. For example, \s-1INSERT/SELECT\s0 -statements are rewritable. -.Sp -This mode displays the \*(L"q_header\*(R" and \*(L"processlist\*(R" tables by default. -.IP "R: InnoDB Row Operations and Semaphores" 4 -.IX Item "R: InnoDB Row Operations and Semaphores" -This mode shows InnoDB row operations, row operation miscellaneous, semaphores, -and information from the wait array. It displays the \*(L"row_operations\*(R", -\&\*(L"row_operation_misc\*(R", \*(L"semaphores\*(R", and \*(L"wait_array\*(R" tables by default. -.IP "S: Variables & Status" 4 -.IX Item "S: Variables & Status" -This mode calculates statistics, such as queries per second, and prints them out -in several different styles. You can show absolute values, or incremental values -between ticks. -.Sp -You can switch between the views by pressing a key. The 's' key prints a -single line each time the screen updates, in the style of \fBvmstat\fR. The 'g' -key changes the view to a graph of the same numbers, sort of like \fBtload\fR. -The 'v' key changes the view to a pivoted table of variable names on the left, -with successive updates scrolling across the screen from left to right. You can -choose how many updates to put on the screen with the \*(L"num_status_sets\*(R" -configuration variable. -.Sp -Headers may be abbreviated to fit on the screen in interactive operation. You -choose which variables to display with the 'c' key, which selects from -predefined sets, or lets you create your own sets. You can edit the current set -with the 'e' key. -.Sp -This mode doesn't really display any tables like other modes. Instead, it uses -a table definition to extract and format the data, but it then transforms the -result in special ways before outputting it. It uses the \*(L"var_status\*(R" table -definition for this. -.IP "T: InnoDB Transactions" 4 -.IX Item "T: InnoDB Transactions" -This mode shows transactions from the InnoDB monitor's output, in \fBtop\fR\-like -format. This mode is the reason I wrote innotop. -.Sp -You can kill queries or processes with the 'k' and 'x' keys, and \s-1EXPLAIN\s0 a query -with the 'e' or 'f' keys. InnoDB doesn't print the full query in transactions, -so explaining may not work right if the query is truncated. -.Sp -The informational header can be toggled on and off with the 'h' key. By -default, innotop hides inactive transactions and its own transaction. You can -toggle this on and off with the 'i' and 'a' keys. -.Sp -This mode displays the \*(L"t_header\*(R" and \*(L"innodb_transactions\*(R" tables by -default. -.SH "INNOTOP STATUS" -.IX Header "INNOTOP STATUS" -The first line innotop displays is a \*(L"status bar\*(R" of sorts. What it contains -depends on the mode you're in, and what servers you're monitoring. The first -few words are always the innotop mode, such as \*(L"InnoDB Txns\*(R" for T mode, -followed by a reminder to press '?' for help at any time. -.Sh "\s-1ONE\s0 \s-1SERVER\s0" -.IX Subsection "ONE SERVER" -The simplest case is when you're monitoring a single server. In this case, the -name of the connection is next on the status line. This is the name you gave -when you created the connection \*(-- most likely the MySQL server's hostname. -This is followed by the server's uptime. -.PP -If you're in an InnoDB mode, such as T or B, the next word is \*(L"InnoDB\*(R" followed -by some information about the \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 output used to render the -screen. The first word is the number of seconds since the last \s-1SHOW\s0 \s-1INNODB\s0 -\&\s-1STATUS\s0, which InnoDB uses to calculate some per-second statistics. The next is -a smiley face indicating whether the InnoDB output is truncated. If the smiley -face is a :\-), all is well; there is no truncation. A :^| means the transaction -list is so long, InnoDB has only printed out some of the transactions. Finally, -a frown :\-( means the output is incomplete, which is probably due to a deadlock -printing too much lock information (see \*(L"D: InnoDB Deadlocks\*(R"). -.PP -The next two words indicate the server's queries per second (\s-1QPS\s0) and how many -threads (connections) exist. Finally, the server's version number is the last -thing on the line. -.Sh "\s-1MULTIPLE\s0 \s-1SERVERS\s0" -.IX Subsection "MULTIPLE SERVERS" -If you are monitoring multiple servers (see \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R"), the status -line does not show any details about individual servers. Instead, it shows the -names of the connections that are active. Again, these are connection names you -specified, which are likely to be the server's hostname. A connection that has -an error is prefixed with an exclamation point. -.PP -If you are monitoring a group of servers (see \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R"), the status -line shows the name of the group. If any connection in the group has an -error, the group's name is followed by the fraction of the connections that -don't have errors. -.PP -See \*(L"\s-1ERROR\s0 \s-1HANDLING\s0\*(R" for more details about innotop's error handling. -.Sh "\s-1MONITORING\s0 A \s-1FILE\s0" -.IX Subsection "MONITORING A FILE" -If you give a filename on the command line, innotop will not connect to \s-1ANY\s0 -servers at all. It will watch the specified file for InnoDB status output and -use that as its data source. It will always show a single connection called -\&'file'. And since it can't connect to a server, it can't determine how long the -server it's monitoring has been up; so it calculates the server's uptime as time -since innotop started running. -.SH "SERVER ADMINISTRATION" -.IX Header "SERVER ADMINISTRATION" -While innotop is primarily a monitor that lets you watch and analyze your -servers, it can also send commands to servers. The most frequently useful -commands are killing queries and stopping or starting slaves. -.PP -You can kill a connection, or in newer versions of MySQL kill a query but not a -connection, from \*(L"Q: Query List\*(R" and \*(L"T: InnoDB Transactions\*(R" modes. -Press 'k' to issue a \s-1KILL\s0 command, or 'x' to issue a \s-1KILL\s0 \s-1QUERY\s0 command. -innotop will prompt you for the server and/or connection \s-1ID\s0 to kill (innotop -does not prompt you if there is only one possible choice for any input). -innotop pre-selects the longest-running query, or the oldest connection. -Confirm the command with 'y'. -.PP -In \*(L"M: Master/Slave Replication Status\*(R" mode, you can start and stop slaves -with the 'a' and 'o' keys, respectively. You can send these commands to many -slaves at once. innotop fills in a default command of \s-1START\s0 \s-1SLAVE\s0 or \s-1STOP\s0 \s-1SLAVE\s0 -for you, but you can actually edit the command and send anything you wish, such -as \s-1SET\s0 \s-1GLOBAL\s0 SQL_SLAVE_SKIP_COUNTER=1 to make the slave skip one binlog event -when it starts. -.PP -You can also ask innotop to calculate the earliest binlog in use by any slave -and issue a \s-1PURGE\s0 \s-1MASTER\s0 \s-1LOGS\s0 on the master. Use the 'b' key for this. innotop -will prompt you for a master to run the command on, then prompt you for the -connection names of that master's slaves (there is no way for innotop to -determine this reliably itself). innotop will find the minimum binlog in use by -these slave connections and suggest it as the argument to \s-1PURGE\s0 \s-1MASTER\s0 \s-1LOGS\s0. -.SH "SERVER CONNECTIONS" -.IX Header "SERVER CONNECTIONS" -When you create a server connection, innotop asks you for a series of inputs, as -follows: -.IP "\s-1DSN\s0" 4 -.IX Item "DSN" -A \s-1DSN\s0 is a Data Source Name, which is the initial argument passed to the \s-1DBI\s0 -module for connecting to a server. It is usually of the form -.Sp -.Vb 1 -\& DBI:mysql:;mysql_read_default_group=mysql;host=HOSTNAME -.Ve -.Sp -Since this \s-1DSN\s0 is passed to the DBD::mysql driver, you should read the driver's -documentation at \*(L"http://search.cpan.org/dist/DBD\-mysql/lib/DBD/mysql.pm\*(R" for -the exact details on all the options you can pass the driver in the \s-1DSN\s0. You -can read more about \s-1DBI\s0 at , and especially at -. -.Sp -The mysql_read_default_group=mysql option lets the \s-1DBD\s0 driver read your MySQL -options files, such as ~/.my.cnf on UNIX-ish systems. You can use this to avoid -specifying a username or password for the connection. -.IP "InnoDB Deadlock Table" 4 -.IX Item "InnoDB Deadlock Table" -This optional item tells innotop a table name it can use to deliberately create -a small deadlock (see \*(L"D: InnoDB Deadlocks\*(R"). If you specify this option, -you just need to be sure the table doesn't exist, and that innotop can create -and drop the table with the InnoDB storage engine. You can safely omit or just -accept the default if you don't intend to use this. -.IP "Username" 4 -.IX Item "Username" -innotop will ask you if you want to specify a username. If you say 'y', it will -then prompt you for a user name. If you have a MySQL option file that specifies -your username, you don't have to specify a username. -.Sp -The username defaults to your login name on the system you're running innotop on. -.IP "Password" 4 -.IX Item "Password" -innotop will ask you if you want to specify a password. Like the username, the -password is optional, but there's an additional prompt that asks if you want to -save the password in the innotop configuration file. If you don't save it in -the configuration file, innotop will prompt you for a password each time it -starts. Passwords in the innotop configuration file are saved in plain text, -not encrypted in any way. -.PP -Once you finish answering these questions, you should be connected to a server. -But innotop isn't limited to monitoring a single server; you can define many -server connections and switch between them by pressing the '@' key. See -\&\*(L"\s-1SWITCHING\s0 \s-1BETWEEN\s0 \s-1CONNECTIONS\s0\*(R". -.PP -To create a new connection, press the '@' key and type the name of the new -connection, then follow the steps given above. -.SH "SERVER GROUPS" -.IX Header "SERVER GROUPS" -If you have multiple MySQL instances, you can put them into named groups, such -as 'all', 'masters', and 'slaves', which innotop can monitor all together. -.PP -You can choose which group to monitor with the '#' key, and you can press the -\&\s-1TAB\s0 key to switch to the next group. If you're not currently monitoring a -group, pressing \s-1TAB\s0 selects the first group. -.PP -To create a group, press the '#' key and type the name of your new group, then -type the names of the connections you want the group to contain. -.SH "SWITCHING BETWEEN CONNECTIONS" -.IX Header "SWITCHING BETWEEN CONNECTIONS" -innotop lets you quickly switch which servers you're monitoring. The most basic -way is by pressing the '@' key and typing the name(s) of the connection(s) you -want to use. This setting is per\-mode, so you can monitor different connections -in each mode, and innotop remembers which connections you choose. -.PP -You can quickly switch to the 'next' connection in alphabetical order with the -\&'n' key. If you're monitoring a server group (see \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R") this will -switch to the first connection. -.PP -You can also type many connection names, and innotop will fetch and display data -from them all. Just separate the connection names with spaces, for example -\&\*(L"server1 server2.\*(R" Again, if you type the name of a connection that doesn't -exist, innotop will prompt you for connection information and create the -connection. -.PP -Another way to monitor multiple connections at once is with server groups. You -can use the \s-1TAB\s0 key to switch to the 'next' group in alphabetical order, or if -you're not monitoring any groups, \s-1TAB\s0 will switch to the first group. -.PP -innotop does not fetch data in parallel from connections, so if you are -monitoring a large group or many connections, you may notice increased delay -between ticks. -.PP -When you monitor more than one connection, innotop's status bar changes. See -\&\*(L"\s-1INNOTOP\s0 \s-1STATUS\s0\*(R". -.SH "ERROR HANDLING" -.IX Header "ERROR HANDLING" -Error handling is not that important when monitoring a single connection, but is -crucial when you have many active connections. A crashed server or lost -connection should not crash innotop. As a result, innotop will continue to run -even when there is an error; it just won't display any information from the -connection that had an error. Because of this, innotop's behavior might confuse -you. It's a feature, not a bug! -.PP -innotop does not continue to query connections that have errors, because they -may slow innotop and make it hard to use, especially if the error is a problem -connecting and causes a long time\-out. Instead, innotop retries the connection -occasionally to see if the error still exists. If so, it will wait until some -point in the future. The wait time increases in ticks as the Fibonacci series, -so it tries less frequently as time passes. -.PP -Since errors might only happen in certain modes because of the \s-1SQL\s0 commands -issued in those modes, innotop keeps track of which mode caused the error. If -you switch to a different mode, innotop will retry the connection instead of -waiting. -.PP -By default innotop will display the problem in red text at the bottom of the -first table on the screen. You can disable this behavior with the -\&\*(L"show_cxn_errors_in_tbl\*(R" configuration option, which is enabled by default. -If the \*(L"debug\*(R" option is enabled, innotop will display the error at the -bottom of every table, not just the first. And if \*(L"show_cxn_errors\*(R" is -enabled, innotop will print the error text to \s-1STDOUT\s0 as well. Error messages -might only display in the mode that caused the error, depending on the mode and -whether innotop is avoiding querying that connection. -.SH "NON-INTERACTIVE OPERATION" -.IX Header "NON-INTERACTIVE OPERATION" -You can run innotop in non-interactive mode, in which case it is entirely -controlled from the configuration file and command-line options. To start -innotop in non-interactive mode, give the L\*(L"<\-\-nonint\*(R"> command-line option. -This changes innotop's behavior in the following ways: -.IP "\(bu" 4 -Certain Perl modules are not loaded. Term::Readline is not loaded, since -innotop doesn't prompt interactively. Term::ANSIColor and Win32::Console::ANSI -modules are not loaded. Term::ReadKey is still used, since innotop may have to -prompt for connection passwords when starting up. -.IP "\(bu" 4 -innotop does not clear the screen after each tick. -.IP "\(bu" 4 -innotop does not persist any changes to the configuration file. -.IP "\(bu" 4 -If \*(L"\-\-count\*(R" is given and innotop is in incremental mode (see \*(L"status_inc\*(R" -and \*(L"\-\-inc\*(R"), innotop actually refreshes one more time than specified so it -can print incremental statistics. This suppresses output during the first -tick, so innotop may appear to hang. -.IP "\(bu" 4 -innotop only displays the first table in each mode. This is so the output can -be easily processed with other command-line utilities such as awk and sed. To -change which tables display in each mode, see \*(L"\s-1TABLES\s0\*(R". Since \*(L"Q: Query List\*(R" mode is so important, innotop automatically disables the \*(L"q_header\*(R" -table. This ensures you'll see the \*(L"processlist\*(R" table, even if you have -innotop configured to show the q_header table during interactive operation. -Similarly, in \*(L"T: InnoDB Transactions\*(R" mode, the \*(L"t_header\*(R" table is -suppressed so you see only the \*(L"innodb_transactions\*(R" table. -.IP "\(bu" 4 -All output is tab-separated instead of being column-aligned with whitespace, and -innotop prints the full contents of each table instead of only printing one -screenful at a time. -.IP "\(bu" 4 -innotop only prints column headers once instead of every tick (see -\&\*(L"hide_hdr\*(R"). innotop does not print table captions (see -\&\*(L"display_table_captions\*(R"). innotop ensures there are no empty lines in the -output. -.IP "\(bu" 4 -innotop does not honor the \*(L"shorten\*(R" transformation, which normally shortens -some numbers to human-readable formats. -.IP "\(bu" 4 -innotop does not print a status line (see \*(L"\s-1INNOTOP\s0 \s-1STATUS\s0\*(R"). -.SH "CONFIGURING" -.IX Header "CONFIGURING" -Nearly everything about innotop is configurable. Most things are possible to -change with built-in commands, but you can also edit the configuration file. -.PP -While running innotop, press the '$' key to bring up the configuration editing -dialog. Press another key to select the type of data you want to edit: -.IP "S: Statement Sleep Times" 4 -.IX Item "S: Statement Sleep Times" -Edits \s-1SQL\s0 statement sleep delays, which make innotop pause for the specified -amount of time after executing a statement. See \*(L"\s-1SQL\s0 \s-1STATEMENTS\s0\*(R" for a -definition of each statement and what it does. By default innotop does not -delay after any statements. -.Sp -This feature is included so you can customize the side-effects caused by -monitoring your server. You may not see any effects, but some innotop users -have noticed that certain MySQL versions under very high load with InnoDB -enabled take longer than usual to execute \s-1SHOW\s0 \s-1GLOBAL\s0 \s-1STATUS\s0. If innotop calls -\&\s-1SHOW\s0 \s-1FULL\s0 \s-1PROCESSLIST\s0 immediately afterward, the processlist contains more -queries than the machine actually averages at any given moment. Configuring -innotop to pause briefly after calling \s-1SHOW\s0 \s-1GLOBAL\s0 \s-1STATUS\s0 alleviates this -effect. -.Sp -Sleep times are stored in the \*(L"stmt_sleep_times\*(R" section of the configuration -file. Fractional-second sleeps are supported, subject to your hardware's -limitations. -.IP "c: Edit Columns" 4 -.IX Item "c: Edit Columns" -Starts the table editor on one of the displayed tables. See \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R". -An alternative way to start the table editor without entering the configuration -dialog is with the '^' key. -.IP "g: General Configuration" 4 -.IX Item "g: General Configuration" -Starts the configuration editor to edit global and mode-specific configuration -variables (see \*(L"\s-1MODES\s0\*(R"). innotop prompts you to choose a variable from among -the global and mode-specific ones depending on the current mode. -.IP "k: Row-Coloring Rules" 4 -.IX Item "k: Row-Coloring Rules" -Starts the row-coloring rules editor on one of the displayed table(s). See -\&\*(L"\s-1COLORS\s0\*(R" for details. -.IP "p: Manage Plugins" 4 -.IX Item "p: Manage Plugins" -Starts the plugin configuration editor. See \*(L"\s-1PLUGINS\s0\*(R" for details. -.IP "s: Server Groups" 4 -.IX Item "s: Server Groups" -Lets you create and edit server groups. See \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R". -.IP "t: Choose Displayed Tables" 4 -.IX Item "t: Choose Displayed Tables" -Lets you choose which tables to display in this mode. See \*(L"\s-1MODES\s0\*(R" and -\&\*(L"\s-1TABLES\s0\*(R". -.SH "CONFIGURATION FILE" -.IX Header "CONFIGURATION FILE" -innotop's default configuration file location is in \f(CW$HOME\fR/.innotop, but can be -overridden with the \*(L"\-\-config\*(R" command-line option. You can edit it by hand -safely. innotop reads the configuration file when it starts, and writes it out -again when it exits, so any changes you make while innotop is running will be -lost. -.PP -innotop doesn't store its entire configuration in the configuration file. It -has a huge set of default configuration that it holds only in memory, and the -configuration file only overrides these defaults. When you customize a default -setting, innotop notices, and then stores the customizations into the file. -This keeps the file size down, makes it easier to edit, and makes upgrades -easier. -.PP -A configuration file can be made read\-only. See \*(L"readonly\*(R". -.PP -The configuration file is arranged into sections like an \s-1INI\s0 file. Each -section begins with [section\-name] and ends with [/section\-name]. Each -section's entries have a different syntax depending on the data they need to -store. You can put comments in the file; any line that begins with a # -character is a comment. innotop will not read the comments, so it won't write -them back out to the file when it exits. Comments in read-only configuration -files are still useful, though. -.PP -The first line in the file is innotop's version number. This lets innotop -notice when the file format is not backwards\-compatible, and upgrade smoothly -without destroying your customized configuration. -.PP -The following list describes each section of the configuration file and the data -it contains: -.IP "general" 4 -.IX Item "general" -The 'general' section contains global configuration variables and variables that -may be mode\-specific, but don't belong in any other section. The syntax is a -simple key=value list. innotop writes a comment above each value to help you -edit the file by hand. -.RS 4 -.IP "S_func" 4 -.IX Item "S_func" -Controls S mode presentation (see \*(L"S: Variables & Status\*(R"). If g, values are -graphed; if s, values are like vmstat; if p, values are in a pivoted table. -.IP "S_set" 4 -.IX Item "S_set" -Specifies which set of variables to display in \*(L"S: Variables & Status\*(R" mode. -See \*(L"\s-1VARIABLE\s0 \s-1SETS\s0\*(R". -.IP "auto_wipe_dl" 4 -.IX Item "auto_wipe_dl" -Instructs innotop to automatically wipe large deadlocks when it notices them. -When this happens you may notice a slight delay. At the next tick, you will -usually see the information that was being truncated by the large deadlock. -.IP "charset" 4 -.IX Item "charset" -Specifies what kind of characters to allow through the \*(L"no_ctrl_char\*(R" -transformation. This keeps non-printable characters from confusing a -terminal when you monitor queries that contain binary data, such as images. -.Sp -The default is 'ascii', which considers anything outside normal \s-1ASCII\s0 to be a -control character. The other allowable values are 'unicode' and 'none'. 'none' -considers every character a control character, which can be useful for -collapsing \s-1ALL\s0 text fields in queries. -.IP "cmd_filter" 4 -.IX Item "cmd_filter" -This is the prefix that filters variables in \*(L"C: Command Summary\*(R" mode. -.IP "color" 4 -.IX Item "color" -Whether terminal coloring is permitted. -.IP "cxn_timeout" 4 -.IX Item "cxn_timeout" -On MySQL versions 4.0.3 and newer, this variable is used to set the connection's -timeout, so MySQL doesn't close the connection if it is not used for a while. -This might happen because a connection isn't monitored in a particular mode, for -example. -.IP "debug" 4 -.IX Item "debug" -This option enables more verbose errors and makes innotop more strict in some -places. It can help in debugging filters and other user-defined code. It also -makes innotop write a lot of information to \*(L"debugfile\*(R" when there is a -crash. -.IP "debugfile" 4 -.IX Item "debugfile" -A file to which innotop will write information when there is a crash. See -\&\*(L"\s-1FILES\s0\*(R". -.IP "display_table_captions" 4 -.IX Item "display_table_captions" -innotop displays a table caption above most tables. This variable suppresses or -shows captions on all tables globally. Some tables are configured with the -hide_caption property, which overrides this. -.IP "global" 4 -.IX Item "global" -Whether to show \s-1GLOBAL\s0 variables and status. innotop only tries to do this on -servers which support the \s-1GLOBAL\s0 option to \s-1SHOW\s0 \s-1VARIABLES\s0 and \s-1SHOW\s0 \s-1STATUS\s0. In -some MySQL versions, you need certain privileges to do this; if you don't have -them, innotop will not be able to fetch any variable and status data. This -configuration variable lets you run innotop and fetch what data you can even -without the elevated privileges. -.Sp -I can no longer find or reproduce the situation where \s-1GLOBAL\s0 wasn't allowed, but -I know there was one. -.IP "graph_char" 4 -.IX Item "graph_char" -Defines the character to use when drawing graphs in \*(L"S: Variables & Status\*(R" -mode. -.IP "header_highlight" 4 -.IX Item "header_highlight" -Defines how to highlight column headers. This only works if Term::ANSIColor is -available. Valid values are 'bold' and 'underline'. -.IP "hide_hdr" 4 -.IX Item "hide_hdr" -Hides column headers globally. -.IP "interval" 4 -.IX Item "interval" -The interval at which innotop will refresh its data (ticks). The interval is -implemented as a sleep time between ticks, so the true interval will vary -depending on how long it takes innotop to fetch and render data. -.Sp -This variable accepts fractions of a second. -.IP "mode" 4 -.IX Item "mode" -The mode in which innotop should start. Allowable arguments are the same as the -key presses that select a mode interactively. See \*(L"\s-1MODES\s0\*(R". -.IP "num_digits" 4 -.IX Item "num_digits" -How many digits to show in fractional numbers and percents. This variable's -range is between 0 and 9 and can be set directly from \*(L"S: Variables & Status\*(R" -mode with the '+' and '\-' keys. It is used in the \*(L"set_precision\*(R", -\&\*(L"shorten\*(R", and \*(L"percent\*(R" transformations. -.IP "num_status_sets" 4 -.IX Item "num_status_sets" -Controls how many sets of status variables to display in pivoted \*(L"S: Variables & Status\*(R" mode. It also controls the number of old sets of variables innotop -keeps in its memory, so the larger this variable is, the more memory innotop -uses. -.IP "plugin_dir" 4 -.IX Item "plugin_dir" -Specifies where plugins can be found. By default, innotop stores plugins in the -\&'plugins' subdirectory of your innotop configuration directory. -.IP "readonly" 4 -.IX Item "readonly" -Whether the configuration file is readonly. This cannot be set interactively, -because it would prevent itself from being written to the configuration file. -.IP "show_cxn_errors" 4 -.IX Item "show_cxn_errors" -Makes innotop print connection errors to \s-1STDOUT\s0. See \*(L"\s-1ERROR\s0 \s-1HANDLING\s0\*(R". -.IP "show_cxn_errors_in_tbl" 4 -.IX Item "show_cxn_errors_in_tbl" -Makes innotop display connection errors as rows in the first table on screen. -See \*(L"\s-1ERROR\s0 \s-1HANDLING\s0\*(R". -.IP "show_percent" 4 -.IX Item "show_percent" -Adds a '%' character after the value returned by the \*(L"percent\*(R" -transformation. -.IP "show_statusbar" 4 -.IX Item "show_statusbar" -Controls whether to show the status bar in the display. See \*(L"\s-1INNOTOP\s0 \s-1STATUS\s0\*(R". -.IP "skip_innodb" 4 -.IX Item "skip_innodb" -Disables fetching \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0, in case your server(s) do not have InnoDB -enabled and you don't want innotop to try to fetch it. This can also be useful -when you don't have the \s-1SUPER\s0 privilege, required to run \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. -.IP "status_inc" 4 -.IX Item "status_inc" -Whether to show absolute or incremental values for status variables. -Incremental values are calculated as an offset from the last value innotop saw -for that variable. This is a global setting, but will probably become -mode-specific at some point. Right now it is honored a bit inconsistently; some -modes don't pay attention to it. -.RE -.RS 4 -.RE -.IP "plugins" 4 -.IX Item "plugins" -This section holds a list of package names of active plugins. If the plugin -exists, innotop will activate it. See \*(L"\s-1PLUGINS\s0\*(R" for more information. -.IP "filters" 4 -.IX Item "filters" -This section holds user-defined filters (see \*(L"\s-1FILTERS\s0\*(R"). Each line is in the -format filter_name=text='filter text' tbls='table list'. -.Sp -The filter text is the text of the subroutine's code. The table list is a list -of tables to which the filter can apply. By default, user-defined filters apply -to the table for which they were created, but you can manually override that by -editing the definition in the configuration file. -.IP "active_filters" 4 -.IX Item "active_filters" -This section stores which filters are active on each table. Each line is in the -format table_name=filter_list. -.IP "tbl_meta" 4 -.IX Item "tbl_meta" -This section stores user-defined or user-customized columns (see \*(L"\s-1COLUMNS\s0\*(R"). -Each line is in the format col_name=properties, where the properties are a -name=quoted\-value list. -.IP "connections" 4 -.IX Item "connections" -This section holds the server connections you have defined. Each line is in the -format name=properties, where the properties are a name=value list. The -properties are self\-explanatory, and the only one that is treated specially is -\&'pass' which is only present if 'savepass' is set. See \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R". -.IP "active_connections" 4 -.IX Item "active_connections" -This section holds a list of which connections are active in each mode. Each -line is in the format mode_name=connection_list. -.IP "server_groups" 4 -.IX Item "server_groups" -This section holds server groups. Each line is in the format -name=connection_list. See \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R". -.IP "active_server_groups" 4 -.IX Item "active_server_groups" -This section holds a list of which server group is active in each mode. Each -line is in the format mode_name=server_group. -.IP "max_values_seen" 4 -.IX Item "max_values_seen" -This section holds the maximum values seen for variables. This is used to scale -the graphs in \*(L"S: Variables & Status\*(R" mode. Each line is in the format -name=value. -.IP "active_columns" 4 -.IX Item "active_columns" -This section holds table column lists. Each line is in the format -tbl_name=column_list. See \*(L"\s-1COLUMNS\s0\*(R". -.IP "sort_cols" 4 -.IX Item "sort_cols" -This section holds the sort definition. Each line is in the format -tbl_name=column_list. If a column is prefixed with '\-', that column sorts -descending. See \*(L"\s-1SORTING\s0\*(R". -.IP "visible_tables" 4 -.IX Item "visible_tables" -This section defines which tables are visible in each mode. Each line is in the -format mode_name=table_list. See \*(L"\s-1TABLES\s0\*(R". -.IP "varsets" 4 -.IX Item "varsets" -This section defines variable sets for use in \*(L"S: Status & Variables\*(R" mode. -Each line is in the format name=variable_list. See \*(L"\s-1VARIABLE\s0 \s-1SETS\s0\*(R". -.IP "colors" 4 -.IX Item "colors" -This section defines colorization rules. Each line is in the format -tbl_name=property_list. See \*(L"\s-1COLORS\s0\*(R". -.IP "stmt_sleep_times" 4 -.IX Item "stmt_sleep_times" -This section contains statement sleep times. Each line is in the format -statement_name=sleep_time. See \*(L"S: Statement Sleep Times\*(R". -.IP "group_by" 4 -.IX Item "group_by" -This section contains column lists for table group_by expressions. Each line is -in the format tbl_name=column_list. See \*(L"\s-1GROUPING\s0\*(R". -.SH "CUSTOMIZING" -.IX Header "CUSTOMIZING" -You can customize innotop a great deal. For example, you can: -.IP "\(bu" 4 -Choose which tables to display, and in what order. -.IP "\(bu" 4 -Choose which columns are in those tables, and create new columns. -.IP "\(bu" 4 -Filter which rows display with built-in filters, user-defined filters, and -quick\-filters. -.IP "\(bu" 4 -Sort the rows to put important data first or group together related rows. -.IP "\(bu" 4 -Highlight rows with color. -.IP "\(bu" 4 -Customize the alignment, width, and formatting of columns, and apply -transformations to columns to extract parts of their values or format the values -as you wish (for example, shortening large numbers to familiar units). -.IP "\(bu" 4 -Design your own expressions to extract and combine data as you need. This gives -you unlimited flexibility. -.PP -All these and more are explained in the following sections. -.Sh "\s-1TABLES\s0" -.IX Subsection "TABLES" -A table is what you'd expect: a collection of columns. It also has some other -properties, such as a caption. Filters, sorting rules, and colorization rules -belong to tables and are covered in later sections. -.PP -Internally, table meta-data is defined in a data structure called \f(CW%tbl_meta\fR. -This hash holds all built-in table definitions, which contain a lot of default -instructions to innotop. The meta-data includes the caption, a list of columns -the user has customized, a list of columns, a list of visible columns, a list of -filters, color rules, a sort-column list, sort direction, and some information -about the table's data sources. Most of this is customizable via the table -editor (see \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R"). -.PP -You can choose which tables to show by pressing the '$' key. See \*(L"\s-1MODES\s0\*(R" and -\&\*(L"\s-1TABLES\s0\*(R". -.PP -The table life-cycle is as follows: -.IP "\(bu" 4 -Each table begins with a data source, which is an array of hashes. See below -for details on data sources. -.IP "\(bu" 4 -Each element of the data source becomes a row in the final table. -.IP "\(bu" 4 -For each element in the data source, innotop extracts values from the source and -creates a row. This row is another hash, which later steps will refer to as -\&\f(CW$set\fR. The values innotop extracts are determined by the table's columns. Each -column has an extraction subroutine, compiled from an expression (see -\&\*(L"\s-1EXPRESSIONS\s0\*(R"). The resulting row is a hash whose keys are named the same as -the column name. -.IP "\(bu" 4 -innotop filters the rows, removing those that don't need to be displayed. See -\&\*(L"\s-1FILTERS\s0\*(R". -.IP "\(bu" 4 -innotop sorts the rows. See \*(L"\s-1SORTING\s0\*(R". -.IP "\(bu" 4 -innotop groups the rows together, if specified. See \*(L"\s-1GROUPING\s0\*(R". -.IP "\(bu" 4 -innotop colorizes the rows. See \*(L"\s-1COLORS\s0\*(R". -.IP "\(bu" 4 -innotop transforms the column values in each row. See \*(L"\s-1TRANSFORMATIONS\s0\*(R". -.IP "\(bu" 4 -innotop optionally pivots the rows (see \*(L"\s-1PIVOTING\s0\*(R"), then filters and sorts -them. -.IP "\(bu" 4 -innotop formats and justifies the rows as a table. During this step, innotop -applies further formatting to the column values, including alignment, maximum -and minimum widths. innotop also does final error checking to ensure there are -no crashes due to undefined values. innotop then adds a caption if specified, -and the table is ready to print. -.PP -The lifecycle is slightly different if the table is pivoted, as noted above. To -clarify, if the table is pivoted, the process is extract, group, transform, -pivot, filter, sort, create. If it's not pivoted, the process is extract, -filter, sort, group, color, transform, create. This slightly convoluted process -doesn't map all that well to \s-1SQL\s0, but pivoting complicates things pretty -thoroughly. Roughly speaking, filtering and sorting happen as late as needed to -effect the final result as you might expect, but as early as possible for -efficiency. -.PP -Each built-in table is described below: -.IP "adaptive_hash_index" 4 -.IX Item "adaptive_hash_index" -Displays data about InnoDB's adaptive hash index. Data source: -\&\*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "buffer_pool" 4 -.IX Item "buffer_pool" -Displays data about InnoDB's buffer pool. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "cmd_summary" 4 -.IX Item "cmd_summary" -Displays weighted status variables. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "deadlock_locks" 4 -.IX Item "deadlock_locks" -Shows which locks were held and waited for by the last detected deadlock. Data -source: \*(L"\s-1DEADLOCK_LOCKS\s0\*(R". -.IP "deadlock_transactions" 4 -.IX Item "deadlock_transactions" -Shows transactions involved in the last detected deadlock. Data source: -\&\*(L"\s-1DEADLOCK_TRANSACTIONS\s0\*(R". -.IP "explain" 4 -.IX Item "explain" -Shows the output of \s-1EXPLAIN\s0. Data source: \*(L"\s-1EXPLAIN\s0\*(R". -.IP "file_io_misc" 4 -.IX Item "file_io_misc" -Displays data about InnoDB's file and I/O operations. Data source: -\&\*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "fk_error" 4 -.IX Item "fk_error" -Displays various data about InnoDB's last foreign key error. Data source: -\&\*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "innodb_locks" 4 -.IX Item "innodb_locks" -Displays InnoDB locks. Data source: \*(L"\s-1INNODB_LOCKS\s0\*(R". -.IP "innodb_transactions" 4 -.IX Item "innodb_transactions" -Displays data about InnoDB's current transactions. Data source: -\&\*(L"\s-1INNODB_TRANSACTIONS\s0\*(R". -.IP "insert_buffers" 4 -.IX Item "insert_buffers" -Displays data about InnoDB's insert buffer. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "io_threads" 4 -.IX Item "io_threads" -Displays data about InnoDB's I/O threads. Data source: \*(L"\s-1IO_THREADS\s0\*(R". -.IP "log_statistics" 4 -.IX Item "log_statistics" -Displays data about InnoDB's logging system. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "master_status" 4 -.IX Item "master_status" -Displays replication master status. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "open_tables" 4 -.IX Item "open_tables" -Displays open tables. Data source: \*(L"\s-1OPEN_TABLES\s0\*(R". -.IP "page_statistics" 4 -.IX Item "page_statistics" -Displays InnoDB page statistics. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "pending_io" 4 -.IX Item "pending_io" -Displays InnoDB pending I/O operations. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "processlist" 4 -.IX Item "processlist" -Displays current MySQL processes (threads/connections). Data source: -\&\*(L"\s-1PROCESSLIST\s0\*(R". -.IP "q_header" 4 -.IX Item "q_header" -Displays various status values. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "row_operation_misc" 4 -.IX Item "row_operation_misc" -Displays data about InnoDB's row operations. Data source: -\&\*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "row_operations" 4 -.IX Item "row_operations" -Displays data about InnoDB's row operations. Data source: -\&\*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "semaphores" 4 -.IX Item "semaphores" -Displays data about InnoDB's semaphores and mutexes. Data source: -\&\*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "slave_io_status" 4 -.IX Item "slave_io_status" -Displays data about the slave I/O thread. Data source: -\&\*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "slave_sql_status" 4 -.IX Item "slave_sql_status" -Displays data about the slave \s-1SQL\s0 thread. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "t_header" 4 -.IX Item "t_header" -Displays various InnoDB status values. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "var_status" 4 -.IX Item "var_status" -Displays user-configurable data. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R". -.IP "wait_array" 4 -.IX Item "wait_array" -Displays data about InnoDB's \s-1OS\s0 wait array. Data source: \*(L"\s-1OS_WAIT_ARRAY\s0\*(R". -.Sh "\s-1COLUMNS\s0" -.IX Subsection "COLUMNS" -Columns belong to tables. You can choose a table's columns by pressing the '^' -key, which starts the \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R" and lets you choose and edit columns. -Pressing 'e' from within the table editor lets you edit the column's properties: -.IP "\(bu" 4 -hdr: a column header. This appears in the first row of the table. -.IP "\(bu" 4 -just: justification. '\-' means left-justified and '' means right\-justified, -just as with printf formatting codes (not a coincidence). -.IP "\(bu" 4 -dec: whether to further align the column on the decimal point. -.IP "\(bu" 4 -num: whether the column is numeric. This affects how values are sorted -(lexically or numerically). -.IP "\(bu" 4 -label: a small note about the column, which appears in dialogs that help the -user choose columns. -.IP "\(bu" 4 -src: an expression that innotop uses to extract the column's data from its -source (see \*(L"\s-1DATA\s0 \s-1SOURCES\s0\*(R"). See \*(L"\s-1EXPRESSIONS\s0\*(R" for more on expressions. -.IP "\(bu" 4 -minw: specifies a minimum display width. This helps stabilize the display, -which makes it easier to read if the data is changing frequently. -.IP "\(bu" 4 -maxw: similar to minw. -.IP "\(bu" 4 -trans: a list of column transformations. See \*(L"\s-1TRANSFORMATIONS\s0\*(R". -.IP "\(bu" 4 -agg: an aggregate function. See \*(L"\s-1GROUPING\s0\*(R". The default is \*(L"first\*(R". -.IP "\(bu" 4 -aggonly: controls whether the column only shows when grouping is enabled on the -table (see \*(L"\s-1GROUPING\s0\*(R"). By default, this is disabled. This means columns -will always be shown by default, whether grouping is enabled or not. If a -column's aggonly is set true, the column will appear when you toggle grouping on -the table. Several columns are set this way, such as the count column on -\&\*(L"processlist\*(R" and \*(L"innodb_transactions\*(R", so you don't see a count when the -grouping isn't enabled, but you do when it is. -.Sh "\s-1FILTERS\s0" -.IX Subsection "FILTERS" -Filters remove rows from the display. They behave much like a \s-1WHERE\s0 clause in -\&\s-1SQL\s0. innotop has several built-in filters, which remove irrelevant information -like inactive queries, but you can define your own as well. innotop also lets -you create quick\-filters, which do not get saved to the configuration file, and -are just an easy way to quickly view only some rows. -.PP -You can enable or disable a filter on any table. Press the '%' key (mnemonic: % -looks kind of like a line being filtered between two circles) and choose which -table you want to filter, if asked. You'll then see a list of possible filters -and a list of filters currently enabled for that table. Type the names of -filters you want to apply and press Enter. -.PP -\fIUSER-DEFINED \s-1FILTERS\s0\fR -.IX Subsection "USER-DEFINED FILTERS" -.PP -If you type a name that doesn't exist, innotop will prompt you to create the -filter. Filters are easy to create if you know Perl, and not hard if you don't. -What you're doing is creating a subroutine that returns true if the row should -be displayed. The row is a hash reference passed to your subroutine as \f(CW$set\fR. -.PP -For example, imagine you want to filter the processlist table so you only see -queries that have been running more than five minutes. Type a new name for your -filter, and when prompted for the subroutine body, press \s-1TAB\s0 to initiate your -terminal's auto\-completion. You'll see the names of the columns in the -\&\*(L"processlist\*(R" table (innotop generally tries to help you with auto-completion -lists). You want to filter on the 'time' column. Type the text \*(L"$set\->{time} > -300\*(R" to return true when the query is more than five minutes old. That's all -you need to do. -.PP -In other words, the code you're typing is surrounded by an implicit context, -which looks like this: -.PP -.Vb 4 -\& sub filter { -\& my ( $set ) = @_; -\& # YOUR CODE HERE -\& } -.Ve -.PP -If your filter doesn't work, or if something else suddenly behaves differently, -you might have made an error in your filter, and innotop is silently catching -the error. Try enabling \*(L"debug\*(R" to make innotop throw an error instead. -.PP -\fIQUICK-FILTERS\fR -.IX Subsection "QUICK-FILTERS" -.PP -innotop's quick-filters are a shortcut to create a temporary filter that doesn't -persist when you restart innotop. To create a quick\-filter, press the '/' key. -innotop will prompt you for the column name and filter text. Again, you can use -auto-completion on column names. The filter text can be just the text you want -to \*(L"search for.\*(R" For example, to filter the \*(L"processlist\*(R" table on queries -that refer to the products table, type '/' and then 'info product'. -.PP -The filter text can actually be any Perl regular expression, but of course a -literal string like 'product' works fine as a regular expression. -.PP -Behind the scenes innotop compiles the quick-filter into a specially tagged -filter that is otherwise like any other filter. It just isn't saved to the -configuration file. -.PP -To clear quick\-filters, press the '\e' key and innotop will clear them all at -once. -.Sh "\s-1SORTING\s0" -.IX Subsection "SORTING" -innotop has sensible built-in defaults to sort the most important rows to the -top of the table. Like anything else in innotop, you can customize how any -table is sorted. -.PP -To start the sort dialog, start the \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R" with the '^' key, choose a -table if necessary, and press the 's' key. You'll see a list of columns you can -use in the sort expression and the current sort expression, if any. Enter a -list of columns by which you want to sort and press Enter. If you want to -reverse sort, prefix the column name with a minus sign. For example, if you -want to sort by column a ascending, then column b descending, type 'a \-b'. You -can also explicitly add a + in front of columns you want to sort ascending, but -it's not required. -.PP -Some modes have keys mapped to open this dialog directly, and to quickly reverse -sort direction. Press '?' as usual to see which keys are mapped in any mode. -.Sh "\s-1GROUPING\s0" -.IX Subsection "GROUPING" -innotop can group, or aggregate, rows together (I use the terms -interchangeably). This is quite similar to an \s-1SQL\s0 \s-1GROUP\s0 \s-1BY\s0 clause. You can -specify to group on certain columns, or if you don't specify any, the entire set -of rows is treated as one group. This is quite like \s-1SQL\s0 so far, but unlike \s-1SQL\s0, -you can also select un-grouped columns. innotop actually aggregates every -column. If you don't explicitly specify a grouping function, the default is -\&'first'. This is basically a convenience so you don't have to specify an -aggregate function for every column you want in the result. -.PP -You can quickly toggle grouping on a table with the '=' key, which toggles its -aggregate property. This property doesn't persist to the config file. -.PP -The columns by which the table is grouped are specified in its group_by -property. When you turn grouping on, innotop places the group_by columns at the -far left of the table, even if they're not supposed to be visible. The rest of -the visible columns appear in order after them. -.PP -Two tables have default group_by lists and a count column built in: -\&\*(L"processlist\*(R" and \*(L"innodb_transactions\*(R". The grouping is by connection -and status, so you can quickly see how many queries or transactions are in a -given status on each server you're monitoring. The time columns are aggregated -as a sum; other columns are left at the default 'first' aggregation. -.PP -By default, the table shown in \*(L"S: Variables & Status\*(R" mode also uses -grouping so you can monitor variables and status across many servers. The -default aggregation function in this mode is 'avg'. -.PP -Valid grouping functions are defined in the \f(CW%agg_funcs\fR hash. They include -.IP "first" 4 -.IX Item "first" -Returns the first element in the group. -.IP "count" 4 -.IX Item "count" -Returns the number of elements in the group, including undefined elements, much -like \s-1SQL\s0's \s-1COUNT\s0(*). -.IP "avg" 4 -.IX Item "avg" -Returns the average of defined elements in the group. -.IP "sum" 4 -.IX Item "sum" -Returns the sum of elements in the group. -.PP -Here's an example of grouping at work. Suppose you have a very busy server with -hundreds of open connections, and you want to see how many connections are in -what status. Using the built-in grouping rules, you can press 'Q' to enter -\&\*(L"Q: Query List\*(R" mode. Press '=' to toggle grouping (if necessary, select the -\&\*(L"processlist\*(R" table when prompted). -.PP -Your display might now look like the following: -.PP -.Vb 1 -\& Query List (? for help) localhost, 32:33, 0.11 QPS, 1 thd, 5.0.38\-log -.Ve -.PP -.Vb 5 -\& CXN Cmd Cnt ID User Host Time Query -\& localhost Query 49 12933 webusr localhost 19:38 SELECT * FROM -\& localhost Sending Da 23 2383 webusr localhost 12:43 SELECT col1, -\& localhost Sleep 120 140 webusr localhost 5:18:12 -\& localhost Statistics 12 19213 webusr localhost 01:19 SELECT * FROM -.Ve -.PP -That's actually quite a worrisome picture. You've got a lot of idle connections -(Sleep), and some connections executing queries (Query and Sending Data). -That's okay, but you also have a lot in Statistics status, collectively spending -over a minute. That means the query optimizer is having a really hard time -optimizing your statements. Something is wrong; it should normally take -milliseconds to optimize queries. You might not have seen this pattern if you -didn't look at your connections in aggregate. (This is a made-up example, but -it can happen in real life). -.Sh "\s-1PIVOTING\s0" -.IX Subsection "PIVOTING" -innotop can pivot a table for more compact display, similar to a Pivot Table in -a spreadsheet (also known as a crosstab). Pivoting a table makes columns into -rows. Assume you start with this table: -.PP -.Vb 4 -\& foo bar -\& === === -\& 1 3 -\& 2 4 -.Ve -.PP -After pivoting, the table will look like this: -.PP -.Vb 4 -\& name set0 set1 -\& ==== ==== ==== -\& foo 1 2 -\& bar 3 4 -.Ve -.PP -To get reasonable results, you might need to group as well as pivoting. -innotop currently does this for \*(L"S: Variables & Status\*(R" mode. -.Sh "\s-1COLORS\s0" -.IX Subsection "COLORS" -By default, innotop highlights rows with color so you can see at a glance which -rows are more important. You can customize the colorization rules and add your -own to any table. Open the table editor with the '^' key, choose a table if -needed, and press 'o' to open the color editor dialog. -.PP -The color editor dialog displays the rules applied to the table, in the order -they are evaluated. Each row is evaluated against each rule to see if the rule -matches the row; if it does, the row gets the specified color, and no further -rules are evaluated. The rules look like the following: -.PP -.Vb 9 -\& state eq Locked black on_red -\& cmd eq Sleep white -\& user eq system user white -\& cmd eq Connect white -\& cmd eq Binlog Dump white -\& time > 600 red -\& time > 120 yellow -\& time > 60 green -\& time > 30 cyan -.Ve -.PP -This is the default rule set for the \*(L"processlist\*(R" table. In order of -priority, these rules make locked queries black on a red background, \*(L"gray out\*(R" -connections from replication and sleeping queries, and make queries turn from -cyan to red as they run longer. -.PP -(For some reason, the \s-1ANSI\s0 color code \*(L"white\*(R" is actually a light gray. Your -terminal's display may vary; experiment to find colors you like). -.PP -You can use keystrokes to move the rules up and down, which re-orders their -priority. You can also delete rules and add new ones. If you add a new rule, -innotop prompts you for the column, an operator for the comparison, a value -against which to compare the column, and a color to assign if the rule matches. -There is auto-completion and prompting at each step. -.PP -The value in the third step needs to be correctly quoted. innotop does not try -to quote the value because it doesn't know whether it should treat the value as -a string or a number. If you want to compare the column against a string, as -for example in the first rule above, you should enter 'Locked' surrounded by -quotes. If you get an error message about a bareword, you probably should have -quoted something. -.Sh "\s-1EXPRESSIONS\s0" -.IX Subsection "EXPRESSIONS" -Expressions are at the core of how innotop works, and are what enables you to -extend innotop as you wish. Recall the table lifecycle explained in -\&\*(L"\s-1TABLES\s0\*(R". Expressions are used in the earliest step, where it extracts -values from a data source to form rows. -.PP -It does this by calling a subroutine for each column, passing it the source data -set, a set of current values, and a set of previous values. These are all -needed so the subroutine can calculate things like the difference between this -tick and the previous tick. -.PP -The subroutines that extract the data from the set are compiled from -expressions. This gives significantly more power than just naming the values to -fill the columns, because it allows the column's value to be calculated from -whatever data is necessary, but avoids the need to write complicated and lengthy -Perl code. -.PP -innotop begins with a string of text that can look as simple as a value's name -or as complicated as a full-fledged Perl expression. It looks at each -\&'bareword' token in the string and decides whether it's supposed to be a key -into the \f(CW$set\fR hash. A bareword is an unquoted value that isn't already -surrounded by code-ish things like dollar signs or curly brackets. If innotop -decides that the bareword isn't a function or other valid Perl code, it converts -it into a hash access. After the whole string is processed, innotop compiles a -subroutine, like this: -.PP -.Vb 5 -\& sub compute_column_value { -\& my ( $set, $cur, $pre ) = @_; -\& my $val = # EXPANDED STRING GOES HERE -\& return $val; -\& } -.Ve -.PP -Here's a concrete example, taken from the header table \*(L"q_header\*(R" in \*(L"Q: Query List\*(R" mode. This expression calculates the qps, or Queries Per Second, -column's values, from the values returned by \s-1SHOW\s0 \s-1STATUS:\s0 -.PP -.Vb 1 -\& Questions/Uptime_hires -.Ve -.PP -innotop decides both words are barewords, and transforms this expression into -the following Perl code: -.PP -.Vb 1 -\& $set\->{Questions}/$set\->{Uptime_hires} -.Ve -.PP -When surrounded by the rest of the subroutine's code, this is executable Perl -that calculates a high-resolution queries-per-second value. -.PP -The arguments to the subroutine are named \f(CW$set\fR, \f(CW$cur\fR, and \f(CW$pre\fR. In most cases, -\&\f(CW$set\fR and \f(CW$cur\fR will be the same values. However, if \*(L"status_inc\*(R" is set, \f(CW$cur\fR -will not be the same as \f(CW$set\fR, because \f(CW$set\fR will already contain values that are -the incremental difference between \f(CW$cur\fR and \f(CW$pre\fR. -.PP -Every column in innotop is computed by subroutines compiled in the same fashion. -There is no difference between innotop's built-in columns and user-defined -columns. This keeps things consistent and predictable. -.Sh "\s-1TRANSFORMATIONS\s0" -.IX Subsection "TRANSFORMATIONS" -Transformations change how a value is rendered. For example, they can take a -number of seconds and display it in H:M:S format. The following transformations -are defined: -.IP "commify" 4 -.IX Item "commify" -Adds commas to large numbers every three decimal places. -.IP "dulint_to_int" 4 -.IX Item "dulint_to_int" -Accepts two unsigned integers and converts them into a single longlong. This is -useful for certain operations with InnoDB, which uses two integers as -transaction identifiers, for example. -.IP "no_ctrl_char" 4 -.IX Item "no_ctrl_char" -Removes quoted control characters from the value. This is affected by the -\&\*(L"charset\*(R" configuration variable. -.Sp -This transformation only operates within quoted strings, for example, values to -a \s-1SET\s0 clause in an \s-1UPDATE\s0 statement. It will not alter the \s-1UPDATE\s0 statement, -but will collapse the quoted string to [\s-1BINARY\s0] or [\s-1TEXT\s0], depending on the -charset. -.IP "percent" 4 -.IX Item "percent" -Converts a number to a percentage by multiplying it by two, formatting it with -\&\*(L"num_digits\*(R" digits after the decimal point, and optionally adding a percent -sign (see \*(L"show_percent\*(R"). -.IP "secs_to_time" 4 -.IX Item "secs_to_time" -Formats a number of seconds as time in days+hours:minutes:seconds format. -.IP "set_precision" 4 -.IX Item "set_precision" -Formats numbers with \*(L"num_digits\*(R" number of digits after the decimal point. -.IP "shorten" 4 -.IX Item "shorten" -Formats a number as a unit of 1024 (k/M/G/T) and with \*(L"num_digits\*(R" number of -digits after the decimal point. -.Sh "\s-1TABLE\s0 \s-1EDITOR\s0" -.IX Subsection "TABLE EDITOR" -The innotop table editor lets you customize tables with keystrokes. You start -the table editor with the '^' key. If there's more than one table on the -screen, it will prompt you to choose one of them. Once you do, innotop will -show you something like this: -.PP -.Vb 1 -\& Editing table definition for Buffer Pool. Press ? for help, q to quit. -.Ve -.PP -.Vb 9 -\& name hdr label src -\& cxn CXN Connection from which cxn -\& buf_pool_size Size Buffer pool size IB_bp_buf_poo -\& buf_free Free Bufs Buffers free in the b IB_bp_buf_fre -\& pages_total Pages Pages total IB_bp_pages_t -\& pages_modified Dirty Pages Pages modified (dirty IB_bp_pages_m -\& buf_pool_hit_rate Hit Rate Buffer pool hit rate IB_bp_buf_poo -\& total_mem_alloc Memory Total memory allocate IB_bp_total_m -\& add_pool_alloc Add\(aql Pool Additonal pool alloca IB_bp_add_poo -.Ve -.PP -The first line shows which table you're editing, and reminds you again to press -\&'?' for a list of key mappings. The rest is a tabular representation of the -table's columns, because that's likely what you're trying to edit. However, you -can edit more than just the table's columns; this screen can start the filter -editor, color rule editor, and more. -.PP -Each row in the display shows a single column in the table you're editing, along -with a couple of its properties such as its header and source expression (see -\&\*(L"\s-1EXPRESSIONS\s0\*(R"). -.PP -The key mappings are Vim\-style, as in many other places. Pressing 'j' and 'k' -moves the highlight up or down. You can then (d)elete or (e)dit the highlighted -column. You can also (a)dd a column to the table. This actually just activates -one of the columns already defined for the table; it prompts you to choose from -among the columns available but not currently displayed. Finally, you can -re-order the columns with the '+' and '\-' keys. -.PP -You can do more than just edit the columns with the table editor, you can also -edit other properties, such as the table's sort expression and group-by -expression. Press '?' to see the full list, of course. -.PP -If you want to really customize and create your own column, as opposed to just -activating a built-in one that's not currently displayed, press the (n)ew key, -and innotop will prompt you for the information it needs: -.IP "\(bu" 4 -The column name: this needs to be a word without any funny characters, e.g. just -letters, numbers and underscores. -.IP "\(bu" 4 -The column header: this is the label that appears at the top of the column, in -the table header. This can have spaces and funny characters, but be careful not -to make it too wide and waste space on\-screen. -.IP "\(bu" 4 -The column's data source: this is an expression that determines what data from -the source (see \*(L"\s-1TABLES\s0\*(R") innotop will put into the column. This can just be -the name of an item in the source, or it can be a more complex expression, as -described in \*(L"\s-1EXPRESSIONS\s0\*(R". -.PP -Once you've entered the required data, your table has a new column. There is no -difference between this column and the built-in ones; it can have all the same -properties and behaviors. innotop will write the column's definition to the -configuration file, so it will persist across sessions. -.PP -Here's an example: suppose you want to track how many times your slaves have -retried transactions. According to the MySQL manual, the -Slave_retried_transactions status variable gives you that data: \*(L"The total -number of times since startup that the replication slave \s-1SQL\s0 thread has retried -transactions. This variable was added in version 5.0.4.\*(R" This is appropriate to -add to the \*(L"slave_sql_status\*(R" table. -.PP -To add the column, switch to the replication-monitoring mode with the 'M' key, -and press the '^' key to start the table editor. When prompted, choose -slave_sql_status as the table, then press 'n' to create the column. Type -\&'retries' as the column name, 'Retries' as the column header, and -\&'Slave_retried_transactions' as the source. Now the column is created, and you -see the table editor screen again. Press 'q' to exit the table editor, and -you'll see your column at the end of the table. -.SH "VARIABLE SETS" -.IX Header "VARIABLE SETS" -Variable sets are used in \*(L"S: Variables & Status\*(R" mode to define more easily -what variables you want to monitor. Behind the scenes they are compiled to a -list of expressions, and then into a column list so they can be treated just -like columns in any other table, in terms of data extraction and -transformations. However, you're protected from the tedious details by a syntax -that ought to feel very natural to you: a \s-1SQL\s0 \s-1SELECT\s0 list. -.PP -The data source for variable sets, and indeed the entire S mode, is the -combination of \s-1SHOW\s0 \s-1STATUS\s0, \s-1SHOW\s0 \s-1VARIABLES\s0, and \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. Imagine -that you had a huge table with one column per variable returned from those -statements. That's the data source for variable sets. You can now query this -data source just like you'd expect. For example: -.PP -.Vb 1 -\& Questions, Uptime, Questions/Uptime as QPS -.Ve -.PP -Behind the scenes innotop will split that variable set into three expressions, -compile them and turn them into a table definition, then extract as usual. This -becomes a \*(L"variable set,\*(R" or a \*(L"list of variables you want to monitor.\*(R" -.PP -innotop lets you name and save your variable sets, and writes them to the -configuration file. You can choose which variable set you want to see with the -\&'c' key, or activate the next and previous sets with the '>' and '<' keys. -There are many built-in variable sets as well, which should give you a good -start for creating your own. Press 'e' to edit the current variable set, or -just to see how it's defined. To create a new one, just press 'c' and type its -name. -.PP -You may want to use some of the functions listed in \*(L"\s-1TRANSFORMATIONS\s0\*(R" to help -format the results. In particular, \*(L"set_precision\*(R" is often useful to limit -the number of digits you see. Extending the above example, here's how: -.PP -.Vb 1 -\& Questions, Uptime, set_precision(Questions/Uptime) as QPS -.Ve -.PP -Actually, this still needs a little more work. If your \*(L"interval\*(R" is less -than one second, you might be dividing by zero because Uptime is incremental in -this mode by default. Instead, use Uptime_hires: -.PP -.Vb 1 -\& Questions, Uptime, set_precision(Questions/Uptime_hires) as QPS -.Ve -.PP -This example is simple, but it shows how easy it is to choose which variables -you want to monitor. -.SH "PLUGINS" -.IX Header "PLUGINS" -innotop has a simple but powerful plugin mechanism by which you can extend -or modify its existing functionality, and add new functionality. innotop's -plugin functionality is event\-based: plugins register themselves to be called -when events happen. They then have a chance to influence the event. -.PP -An innotop plugin is a Perl module placed in innotop's \*(L"plugin_dir\*(R" -directory. On \s-1UNIX\s0 systems, you can place a symbolic link to the module instead -of putting the actual file there. innotop automatically discovers the file. If -there is a corresponding entry in the \*(L"plugins\*(R" configuration file section, -innotop loads and activates the plugin. -.PP -The module must conform to innotop's plugin interface. Additionally, the source -code of the module must be written in such a way that innotop can inspect the -file and determine the package name and description. -.Sh "Package Source Convention" -.IX Subsection "Package Source Convention" -innotop inspects the plugin module's source to determine the Perl package name. -It looks for a line of the form \*(L"package Foo;\*(R" and if found, considers the -plugin's package name to be Foo. Of course the package name can be a valid Perl -package name, with double semicolons and so on. -.PP -It also looks for a description in the source code, to make the plugin editor -more human\-friendly. The description is a comment line of the form \*(L"# -description: Foo\*(R", where \*(L"Foo\*(R" is the text innotop will consider to be the -plugin's description. -.Sh "Plugin Interface" -.IX Subsection "Plugin Interface" -The innotop plugin interface is quite simple: innotop expects the plugin to be -an object-oriented module it can call certain methods on. The methods are -.IP "new(%variables)" 4 -.IX Item "new(%variables)" -This is the plugin's constructor. It is passed a hash of innotop's variables, -which it can manipulate (see \*(L"Plugin Variables\*(R"). It must return a reference -to the newly created plugin object. -.Sp -At construction time, innotop has only loaded the general configuration and -created the default built-in variables with their default contents (which is -quite a lot). Therefore, the state of the program is exactly as in the innotop -source code, plus the configuration variables from the \*(L"general\*(R" section in -the config file. -.Sp -If your plugin manipulates the variables, it is changing global data, which is -shared by innotop and all plugins. Plugins are loaded in the order they're -listed in the config file. Your plugin may load before or after another plugin, -so there is a potential for conflict or interaction between plugins if they -modify data other plugins use or modify. -.IP "\fIregister_for_events()\fR" 4 -.IX Item "register_for_events()" -This method must return a list of events in which the plugin is interested, if -any. See \*(L"Plugin Events\*(R" for the defined events. If the plugin returns an -event that's not defined, the event is ignored. -.IP "event handlers" 4 -.IX Item "event handlers" -The plugin must implement a method named the same as each event for which it has -registered. In other words, if the plugin returns qw(foo bar) from -\&\fIregister_for_events()\fR, it must have \fIfoo()\fR and \fIbar()\fR methods. These methods are -callbacks for the events. See \*(L"Plugin Events\*(R" for more details about each -event. -.Sh "Plugin Variables" -.IX Subsection "Plugin Variables" -The plugin's constructor is passed a hash of innotop's variables, which it can -manipulate. It is probably a good idea if the plugin object saves a copy of it -for later use. The variables are defined in the innotop variable -\&\f(CW%pluggable_vars\fR, and are as follows: -.IP "action_for" 4 -.IX Item "action_for" -A hashref of key mappings. These are innotop's global hot\-keys. -.IP "agg_funcs" 4 -.IX Item "agg_funcs" -A hashref of functions that can be used for grouping. See \*(L"\s-1GROUPING\s0\*(R". -.IP "config" 4 -.IX Item "config" -The global configuration hash. -.IP "connections" 4 -.IX Item "connections" -A hashref of connection specifications. These are just specifications of how to -connect to a server. -.IP "dbhs" 4 -.IX Item "dbhs" -A hashref of innotop's database connections. These are actual \s-1DBI\s0 connection -objects. -.IP "filters" 4 -.IX Item "filters" -A hashref of filters applied to table rows. See \*(L"\s-1FILTERS\s0\*(R" for more. -.IP "modes" 4 -.IX Item "modes" -A hashref of modes. See \*(L"\s-1MODES\s0\*(R" for more. -.IP "server_groups" 4 -.IX Item "server_groups" -A hashref of server groups. See \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R". -.IP "tbl_meta" 4 -.IX Item "tbl_meta" -A hashref of innotop's table meta\-data, with one entry per table (see -\&\*(L"\s-1TABLES\s0\*(R" for more information). -.IP "trans_funcs" 4 -.IX Item "trans_funcs" -A hashref of transformation functions. See \*(L"\s-1TRANSFORMATIONS\s0\*(R". -.IP "var_sets" 4 -.IX Item "var_sets" -A hashref of variable sets. See \*(L"\s-1VARIABLE\s0 \s-1SETS\s0\*(R". -.Sh "Plugin Events" -.IX Subsection "Plugin Events" -Each event is defined somewhere in the innotop source code. When innotop runs -that code, it executes the callback function for each plugin that expressed its -interest in the event. innotop passes some data for each event. The events are -defined in the \f(CW%event_listener_for\fR variable, and are as follows: -.ie n .IP "extract_values($set, $cur\fR, \f(CW$pre\fR, \f(CW$tbl)" 4 -.el .IP "extract_values($set, \f(CW$cur\fR, \f(CW$pre\fR, \f(CW$tbl\fR)" 4 -.IX Item "extract_values($set, $cur, $pre, $tbl)" -This event occurs inside the function that extracts values from a data source. -The arguments are the set of values, the current values, the previous values, -and the table name. -.IP "set_to_tbl" 4 -.IX Item "set_to_tbl" -Events are defined at many places in this subroutine, which is responsible for -turning an arrayref of hashrefs into an arrayref of lines that can be printed to -the screen. The events all pass the same data: an arrayref of rows and the name -of the table being created. The events are set_to_tbl_pre_filter, -set_to_tbl_pre_sort,set_to_tbl_pre_group, set_to_tbl_pre_colorize, -set_to_tbl_pre_transform, set_to_tbl_pre_pivot, set_to_tbl_pre_create, -set_to_tbl_post_create. -.IP "draw_screen($lines)" 4 -.IX Item "draw_screen($lines)" -This event occurs inside the subroutine that prints the lines to the screen. -\&\f(CW$lines\fR is an arrayref of strings. -.Sh "Simple Plugin Example" -.IX Subsection "Simple Plugin Example" -The easiest way to explain the plugin functionality is probably with a simple -example. The following module adds a column to the beginning of every table and -sets its value to 1. -.PP -.Vb 2 -\& use strict; -\& use warnings FATAL => \(aqall\(aq; -.Ve -.PP -.Vb 2 -\& package Innotop::Plugin::Example; -\& # description: Adds an \(aqexample\(aq column to every table -.Ve -.PP -.Vb 4 -\& sub new { -\& my ( $class, %vars ) = @_; -\& # Store reference to innotop\(aqs variables in $self -\& my $self = bless { %vars }, $class; -.Ve -.PP -.Vb 11 -\& # Design the example column -\& my $col = { -\& hdr => \(aqExample\(aq, -\& just => \(aq\(aq, -\& dec => 0, -\& num => 1, -\& label => \(aqExample\(aq, -\& src => \(aqexample\(aq, # Get data from this column in the data source -\& tbl => \(aq\(aq, -\& trans => [], -\& }; -.Ve -.PP -.Vb 8 -\& # Add the column to every table. -\& my $tbl_meta = $vars{tbl_meta}; -\& foreach my $tbl ( values %$tbl_meta ) { -\& # Add the column to the list of defined columns -\& $tbl\->{cols}\->{example} = $col; -\& # Add the column to the list of visible columns -\& unshift @{$tbl\->{visible}}, \(aqexample\(aq; -\& } -.Ve -.PP -.Vb 3 -\& # Be sure to return a reference to the object. -\& return $self; -\& } -.Ve -.PP -.Vb 5 -\& # I\(aqd like to be called when a data set is being rendered into a table, please. -\& sub register_for_events { -\& my ( $self ) = @_; -\& return qw(set_to_tbl_pre_filter); -\& } -.Ve -.PP -.Vb 8 -\& # This method will be called when the event fires. -\& sub set_to_tbl_pre_filter { -\& my ( $self, $rows, $tbl ) = @_; -\& # Set the example column\(aqs data source to the value 1. -\& foreach my $row ( @$rows ) { -\& $row\->{example} = 1; -\& } -\& } -.Ve -.PP -.Vb 1 -\& 1; -.Ve -.Sh "Plugin Editor" -.IX Subsection "Plugin Editor" -The plugin editor lets you view the plugins innotop discovered and activate or -deactivate them. Start the editor by pressing $ to start the configuration -editor from any mode. Press the 'p' key to start the plugin editor. You'll see -a list of plugins innotop discovered. You can use the 'j' and 'k' keys to move -the highlight to the desired one, then press the * key to toggle it active or -inactive. Exit the editor and restart innotop for the changes to take effect. -.SH "SQL STATEMENTS" -.IX Header "SQL STATEMENTS" -innotop uses a limited set of \s-1SQL\s0 statements to retrieve data from MySQL for -display. The statements are customized depending on the server version against -which they are executed; for example, on MySQL 5 and newer, \s-1INNODB_STATUS\s0 -executes \*(L"\s-1SHOW\s0 \s-1ENGINE\s0 \s-1INNODB\s0 \s-1STATUS\s0\*(R", while on earlier versions it executes -\&\*(L"\s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0\*(R". The statements are as follows: -.PP -.Vb 12 -\& Statement SQL executed -\& =================== =============================== -\& INNODB_STATUS SHOW [ENGINE] INNODB STATUS -\& KILL_CONNECTION KILL -\& KILL_QUERY KILL QUERY -\& OPEN_TABLES SHOW OPEN TABLES -\& PROCESSLIST SHOW FULL PROCESSLIST -\& SHOW_MASTER_LOGS SHOW MASTER LOGS -\& SHOW_MASTER_STATUS SHOW MASTER STATUS -\& SHOW_SLAVE_STATUS SHOW SLAVE STATUS -\& SHOW_STATUS SHOW [GLOBAL] STATUS -\& SHOW_VARIABLES SHOW [GLOBAL] VARIABLES -.Ve -.SH "DATA SOURCES" -.IX Header "DATA SOURCES" -Each time innotop extracts values to create a table (see \*(L"\s-1EXPRESSIONS\s0\*(R" and -\&\*(L"\s-1TABLES\s0\*(R"), it does so from a particular data source. Largely because of the -complex data extracted from \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0, this is slightly messy. \s-1SHOW\s0 -\&\s-1INNODB\s0 \s-1STATUS\s0 contains a mixture of single values and repeated values that form -nested data sets. -.PP -Whenever innotop fetches data from MySQL, it adds two extra bits to each set: -cxn and Uptime_hires. cxn is the name of the connection from which the data -came. Uptime_hires is a high-resolution version of the server's Uptime status -variable, which is important if your \*(L"interval\*(R" setting is sub\-second. -.PP -Here are the kinds of data sources from which data is extracted: -.IP "\s-1STATUS_VARIABLES\s0" 4 -.IX Item "STATUS_VARIABLES" -This is the broadest category, into which the most kinds of data fall. It -begins with the combination of \s-1SHOW\s0 \s-1STATUS\s0 and \s-1SHOW\s0 \s-1VARIABLES\s0, but other sources -may be included as needed, for example, \s-1SHOW\s0 \s-1MASTER\s0 \s-1STATUS\s0 and \s-1SHOW\s0 \s-1SLAVE\s0 -\&\s-1STATUS\s0, as well as many of the non-repeated values from \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. -.IP "\s-1DEADLOCK_LOCKS\s0" 4 -.IX Item "DEADLOCK_LOCKS" -This data is extracted from the transaction list in the \s-1LATEST\s0 \s-1DETECTED\s0 \s-1DEADLOCK\s0 -section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. It is nested two levels deep: transactions, then -locks. -.IP "\s-1DEADLOCK_TRANSACTIONS\s0" 4 -.IX Item "DEADLOCK_TRANSACTIONS" -This data is from the transaction list in the \s-1LATEST\s0 \s-1DETECTED\s0 \s-1DEADLOCK\s0 -section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. It is nested one level deep. -.IP "\s-1EXPLAIN\s0" 4 -.IX Item "EXPLAIN" -This data is from the result set returned by \s-1EXPLAIN\s0. -.IP "\s-1INNODB_TRANSACTIONS\s0" 4 -.IX Item "INNODB_TRANSACTIONS" -This data is from the \s-1TRANSACTIONS\s0 section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. -.IP "\s-1IO_THREADS\s0" 4 -.IX Item "IO_THREADS" -This data is from the list of threads in the the \s-1FILE\s0 I/O section of \s-1SHOW\s0 \s-1INNODB\s0 -\&\s-1STATUS\s0. -.IP "\s-1INNODB_LOCKS\s0" 4 -.IX Item "INNODB_LOCKS" -This data is from the \s-1TRANSACTIONS\s0 section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 and is nested -two levels deep. -.IP "\s-1OPEN_TABLES\s0" 4 -.IX Item "OPEN_TABLES" -This data is from \s-1SHOW\s0 \s-1OPEN\s0 \s-1TABLES\s0. -.IP "\s-1PROCESSLIST\s0" 4 -.IX Item "PROCESSLIST" -This data is from \s-1SHOW\s0 \s-1FULL\s0 \s-1PROCESSLIST\s0. -.IP "\s-1OS_WAIT_ARRAY\s0" 4 -.IX Item "OS_WAIT_ARRAY" -This data is from the \s-1SEMAPHORES\s0 section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 and is nested one -level deep. It comes from the lines that look like this: -.Sp -.Vb 1 -\& \-\-Thread 1568861104 has waited at btr0cur.c line 424 .... -.Ve -.SH "MYSQL PRIVILEGES" -.IX Header "MYSQL PRIVILEGES" -.IP "\(bu" 4 -You must connect to MySQL as a user who has the \s-1SUPER\s0 privilege for many of the -functions. -.IP "\(bu" 4 -If you don't have the \s-1SUPER\s0 privilege, you can still run some functions, but you -won't necessarily see all the same data. -.IP "\(bu" 4 -You need the \s-1PROCESS\s0 privilege to see the list of currently running queries in Q -mode. -.IP "\(bu" 4 -You need special privileges to start and stop slave servers. -.IP "\(bu" 4 -You need appropriate privileges to create and drop the deadlock tables if needed -(see \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R"). -.SH "SYSTEM REQUIREMENTS" -.IX Header "SYSTEM REQUIREMENTS" -You need Perl to run innotop, of course. You also need a few Perl modules: \s-1DBI\s0, -DBD::mysql, Term::ReadKey, and Time::HiRes. These should be included with most -Perl distributions, but in case they are not, I recommend using versions -distributed with your operating system or Perl distribution, not from \s-1CPAN\s0. -Term::ReadKey in particular has been known to cause problems if installed from -\&\s-1CPAN\s0. -.PP -If you have Term::ANSIColor, innotop will use it to format headers more readably -and compactly. (Under Microsoft Windows, you also need Win32::Console::ANSI for -terminal formatting codes to be honored). If you install Term::ReadLine, -preferably Term::ReadLine::Gnu, you'll get nice auto-completion support. -.PP -I run innotop on Gentoo GNU/Linux, Debian and Ubuntu, and I've had feedback from -people successfully running it on Red Hat, CentOS, Solaris, and Mac \s-1OSX\s0. I -don't see any reason why it won't work on other UNIX-ish operating systems, but -I don't know for sure. It also runs on Windows under ActivePerl without -problem. -.PP -I use innotop on MySQL versions 3.23.58, 4.0.27, 4.1.0, 4.1.22, 5.0.26, 5.1.15, -and 5.2.3. If it doesn't run correctly for you, that is a bug and I hope you -report it. -.SH "FILES" -.IX Header "FILES" -$HOMEDIR/.innotop is used to store configuration information. Files include the -configuration file innotop.ini, the core_dump file which contains verbose error -messages if \*(L"debug\*(R" is enabled, and the plugins/ subdirectory. -.SH "GLOSSARY OF TERMS" -.IX Header "GLOSSARY OF TERMS" -.IP "tick" 4 -.IX Item "tick" -A tick is a refresh event, when innotop re-fetches data from connections and -displays it. -.SH "ACKNOWLEDGEMENTS" -.IX Header "ACKNOWLEDGEMENTS" -I'm grateful to the following people for various reasons, and hope I haven't -forgotten to include anyone: -.PP -Allen K. Smith, -Aurimas Mikalauskas, -Bartosz Fenski, -Brian Miezejewski, -Christian Hammers, -Cyril Scetbon, -Dane Miller, -David Multer, -Dr. Frank Ullrich, -Giuseppe Maxia, -Google.com Site Reliability Engineers, -Jan Pieter Kunst, -Jari Aalto, -Jay Pipes, -Jeremy Zawodny, -Johan Idren, -Kristian Kohntopp, -Lenz Grimmer, -Maciej Dobrzanski, -Michiel Betel, -MySQL \s-1AB\s0, -Paul McCullagh, -Sebastien Estienne, -Sourceforge.net, -Steven Kreuzer, -The Gentoo MySQL Team, -Trevor Price, -Yaar Schnitman, -and probably more people I've neglected to include. -.PP -(If I misspelled your name, it's probably because I'm afraid of putting -international characters into this documentation; earlier versions of Perl might -not be able to compile it then). -.SH "COPYRIGHT, LICENSE AND WARRANTY" -.IX Header "COPYRIGHT, LICENSE AND WARRANTY" -This program is copyright (c) 2006 Baron Schwartz. -Feedback and improvements are welcome. -.PP -\&\s-1THIS\s0 \s-1PROGRAM\s0 \s-1IS\s0 \s-1PROVIDED\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R" \s-1AND\s0 \s-1WITHOUT\s0 \s-1ANY\s0 \s-1EXPRESS\s0 \s-1OR\s0 \s-1IMPLIED\s0 -\&\s-1WARRANTIES\s0, \s-1INCLUDING\s0, \s-1WITHOUT\s0 \s-1LIMITATION\s0, \s-1THE\s0 \s-1IMPLIED\s0 \s-1WARRANTIES\s0 \s-1OF\s0 -\&\s-1MERCHANTIBILITY\s0 \s-1AND\s0 \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. -.PP -This program is free software; you can redistribute it and/or modify it under -the terms of the \s-1GNU\s0 General Public License as published by the Free Software -Foundation, version 2; \s-1OR\s0 the Perl Artistic License. On \s-1UNIX\s0 and similar -systems, you can issue `man perlgpl' or `man perlartistic' to read these -licenses. -.PP -You should have received a copy of the \s-1GNU\s0 General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, \s-1MA\s0 02111\-1307 \s-1USA\s0. -.PP -Execute innotop and press '!' to see this information at any time. -.SH "AUTHOR" -.IX Header "AUTHOR" -Baron Schwartz. -.SH "BUGS" -.IX Header "BUGS" -You can report bugs, ask for improvements, and get other help and support at -. There are mailing lists, forums, -a bug tracker, etc. Please use these instead of contacting me directly, as it -makes my job easier and benefits others if the discussions are permanent and -public. Of course, if you need to contact me in private, please do. diff --git a/storage/xtradb/build/debian/additions/msql2mysql.1 b/storage/xtradb/build/debian/additions/msql2mysql.1 deleted file mode 100644 index 8fe05e7415d..00000000000 --- a/storage/xtradb/build/debian/additions/msql2mysql.1 +++ /dev/null @@ -1,16 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -msql2mysql \- MySQL importer for msql style data. -.SH SYNOPSIS -msql2mysql [options] -.SH DESCRIPTION -This program imports old msql database files. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/my.cnf b/storage/xtradb/build/debian/additions/my.cnf deleted file mode 100644 index 997523b9c2f..00000000000 --- a/storage/xtradb/build/debian/additions/my.cnf +++ /dev/null @@ -1,129 +0,0 @@ -# -# The MySQL database server configuration file. -# -# You can copy this to one of: -# - "/etc/mysql/my.cnf" to set global options, -# - "~/.my.cnf" to set user-specific options. -# -# One can use all long options that the program supports. -# Run program with --help to get a list of available options and with -# --print-defaults to see which it would actually understand and use. -# -# For explanations see -# http://dev.mysql.com/doc/mysql/en/server-system-variables.html - -# This will be passed to all mysql clients -# It has been reported that passwords should be enclosed with ticks/quotes -# escpecially if they contain "#" chars... -# Remember to edit /etc/mysql/debian.cnf when changing the socket location. -[client] -port = 3306 -socket = /var/run/mysqld/mysqld.sock - -# Here is entries for some specific programs -# The following values assume you have at least 32M ram - -# This was formally known as [safe_mysqld]. Both versions are currently parsed. -[mysqld_safe] -socket = /var/run/mysqld/mysqld.sock -nice = 0 - -[mysqld] -# -# * Basic Settings -# -user = mysql -pid-file = /var/run/mysqld/mysqld.pid -socket = /var/run/mysqld/mysqld.sock -port = 3306 -basedir = /usr -datadir = /var/lib/mysql -tmpdir = /tmp -language = /usr/share/mysql/english -skip-external-locking -# -# For compatibility to other Debian packages that still use -# libmysqlclient10 and libmysqlclient12. -old_passwords = 1 -# -# Instead of skip-networking the default is now to listen only on -# localhost which is more compatible and is not less secure. -bind-address = 127.0.0.1 -# -# * Fine Tuning -# -key_buffer = 16M -max_allowed_packet = 16M -thread_stack = 128K -thread_cache_size = 8 -# This replaces the startup script and checks MyISAM tables if needed -# the first time they are touched -myisam-recover = BACKUP -#max_connections = 100 -#table_cache = 64 -#thread_concurrency = 10 -# -# * Query Cache Configuration -# -query_cache_limit = 1M -query_cache_size = 16M -# -# * Logging and Replication -# -# Both location gets rotated by the cronjob. -# Be aware that this log type is a performance killer. -# As of 5.1 you can enable the at runtime! -#log_type = FILE -#general_log = /var/log/mysql/mysql.log -# -# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf. -# -# Here you can see queries with especially long duration -#log_slow_queries = /var/log/mysql/mysql-slow.log -#long_query_time = 2 -#log-queries-not-using-indexes -# -# The following can be used as easy to replay backup logs or for replication. -# note: if you are setting up a replication slave, see README.Debian about -# other settings you may need to change. -#server-id = 1 -#log_bin = /var/log/mysql/mysql-bin.log -expire_logs_days = 10 -max_binlog_size = 100M -#binlog_do_db = include_database_name -#binlog_ignore_db = include_database_name -# -# * InnoDB -# -# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. -# Read the manual for more InnoDB related options. There are many! -# -# * Security Features -# -# Read the manual, too, if you want chroot! -# chroot = /var/lib/mysql/ -# -# For generating SSL certificates I recommend the OpenSSL GUI "tinyca". -# -# ssl-ca=/etc/mysql/cacert.pem -# ssl-cert=/etc/mysql/server-cert.pem -# ssl-key=/etc/mysql/server-key.pem - - - -[mysqldump] -quick -quote-names -max_allowed_packet = 16M - -[mysql] -#no-auto-rehash # faster start of mysql but no tab completition - -[isamchk] -key_buffer = 16M - -# -# * IMPORTANT: Additional settings that can override those from this file! -# The files must end with '.cnf', otherwise they'll be ignored. -# -!includedir /etc/mysql/conf.d/ diff --git a/storage/xtradb/build/debian/additions/my_print_defaults.1 b/storage/xtradb/build/debian/additions/my_print_defaults.1 deleted file mode 100644 index ebef4157016..00000000000 --- a/storage/xtradb/build/debian/additions/my_print_defaults.1 +++ /dev/null @@ -1,16 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -my_print_defaults \- MySQL helper script that prints defaults. -.SH SYNOPSIS -my_print_defaults [options] -.SH DESCRIPTION -Prints all arguments that is give to some program using the default files. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/myisam_ftdump.1 b/storage/xtradb/build/debian/additions/myisam_ftdump.1 deleted file mode 100644 index e2de358efcc..00000000000 --- a/storage/xtradb/build/debian/additions/myisam_ftdump.1 +++ /dev/null @@ -1,16 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -myisam_ftdump \- Dumps full text tables. -.SH SYNOPSIS -myisam_ftdump [options] -.SH DESCRIPTION -Dumps information and contents of full text tables. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/myisamchk.1 b/storage/xtradb/build/debian/additions/myisamchk.1 deleted file mode 100644 index fe7f34961e0..00000000000 --- a/storage/xtradb/build/debian/additions/myisamchk.1 +++ /dev/null @@ -1,17 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -myisamchk \- Checks MySQL myisam type databases. -.SH SYNOPSIS -myisamchk [options] -.SH DESCRIPTION -Description, check and repair of ISAM tables. -Used without options all tables on the command will be checked for errors - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/myisamlog.1 b/storage/xtradb/build/debian/additions/myisamlog.1 deleted file mode 100644 index 959d547df94..00000000000 --- a/storage/xtradb/build/debian/additions/myisamlog.1 +++ /dev/null @@ -1,16 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -myisamlog \- MySQL helper script. -.SH SYNOPSIS -myisamlog [options] -.SH DESCRIPTION -Function unknown. Mail to ch@debian.org. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/myisampack.1 b/storage/xtradb/build/debian/additions/myisampack.1 deleted file mode 100644 index 93168304a17..00000000000 --- a/storage/xtradb/build/debian/additions/myisampack.1 +++ /dev/null @@ -1,19 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -myisampack \- Compresses MySQL database files. -.SH SYNOPSIS -myisampack [options] -.SH DESCRIPTION -Pack a MyISAM-table to take much less space. -Keys are not updated, you must run myisamchk -rq on the datafile -afterwards to update the keys. -You should give the .MYI file as the filename argument. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysql-server.lintian-overrides b/storage/xtradb/build/debian/additions/mysql-server.lintian-overrides deleted file mode 100644 index ae589c2472e..00000000000 --- a/storage/xtradb/build/debian/additions/mysql-server.lintian-overrides +++ /dev/null @@ -1,2 +0,0 @@ -W: mysql-dfsg source: maintainer-script-lacks-debhelper-token debian/percona-xtradb-server.postinst -W: percona-xtradb-server: possible-bashism-in-maintainer-script postinst:68 'p{("a".."z","A".."Z",0..9)[int(rand(62))]}' diff --git a/storage/xtradb/build/debian/additions/mysql_config.1 b/storage/xtradb/build/debian/additions/mysql_config.1 deleted file mode 100644 index 88095e22b9e..00000000000 --- a/storage/xtradb/build/debian/additions/mysql_config.1 +++ /dev/null @@ -1,17 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysqlconfig \- MySQL compile settings. -.SH SYNOPSIS -mysqlconfig [options] -.SH DESCRIPTION -This program is only useful for people who want to compile agains -libmysqlclient. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysql_convert_table_format.1 b/storage/xtradb/build/debian/additions/mysql_convert_table_format.1 deleted file mode 100644 index 3c23581df43..00000000000 --- a/storage/xtradb/build/debian/additions/mysql_convert_table_format.1 +++ /dev/null @@ -1,17 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysql_convert_table_format \- MySQL table converter. -.SH SYNOPSIS -mysql_convert_table_format [options] -.SH DESCRIPTION -Conversion of a MySQL tables to other table types. -If no tables has been specifed, all tables in the database will be converted. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysql_find_rows.1 b/storage/xtradb/build/debian/additions/mysql_find_rows.1 deleted file mode 100644 index 35a70b1f960..00000000000 --- a/storage/xtradb/build/debian/additions/mysql_find_rows.1 +++ /dev/null @@ -1,18 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysql_find_rows \- MySQL shell skript for searching in update logs. -.SH SYNOPSIS -mysql_find_rows [options] -.SH DESCRIPTION -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. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysql_fix_extensions.1 b/storage/xtradb/build/debian/additions/mysql_fix_extensions.1 deleted file mode 100644 index 3f0a028ca3f..00000000000 --- a/storage/xtradb/build/debian/additions/mysql_fix_extensions.1 +++ /dev/null @@ -1,18 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysql_fix_extensions \- Corrects MySQL database file names. -.SH SYNOPSIS -mysql_fix_extensions -.SH DESCRIPTION -Makes .frm lowercase and .MYI/MYD/ISM/ISD uppercase -useful when datafiles are copied from windows. -Does not work with RAID, with InnoDB or BDB tables. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (8) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysql_install_db.1 b/storage/xtradb/build/debian/additions/mysql_install_db.1 deleted file mode 100644 index 11f1f2967a2..00000000000 --- a/storage/xtradb/build/debian/additions/mysql_install_db.1 +++ /dev/null @@ -1,16 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysql_install_db \- MySQL helper program. -.SH SYNOPSIS -mysql_install_db [options] -.SH DESCRIPTION -This program is normally not needed by any user. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysql_secure_installation.1 b/storage/xtradb/build/debian/additions/mysql_secure_installation.1 deleted file mode 100644 index d65b7f5d09d..00000000000 --- a/storage/xtradb/build/debian/additions/mysql_secure_installation.1 +++ /dev/null @@ -1,17 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysql_secure_installation \- Secures the MySQL access control lists. -.SH SYNOPSIS -mysql_secure_installation [options] -.SH DESCRIPTION -This interactive programm suggests changes like removing anonymous users that -are supposed to make your installation more secure. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (8) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysql_setpermission.1 b/storage/xtradb/build/debian/additions/mysql_setpermission.1 deleted file mode 100644 index 77167e0d58f..00000000000 --- a/storage/xtradb/build/debian/additions/mysql_setpermission.1 +++ /dev/null @@ -1,23 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysql_setpermission \- Adds MySQL users or changes passwords. -.SH SYNOPSIS -mysql_setpermission [options] -.SH DESCRIPTION -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. - -The permission setter first reads your .my.cnf file in your Home -directory if it exists. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysql_tableinfo.1 b/storage/xtradb/build/debian/additions/mysql_tableinfo.1 deleted file mode 100644 index 1de4f5d5943..00000000000 --- a/storage/xtradb/build/debian/additions/mysql_tableinfo.1 +++ /dev/null @@ -1,322 +0,0 @@ -.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 -.\" -.\" Standard preamble: -.\" ======================================================================== -.de Sh \" Subsection heading -.br -.if t .Sp -.ne 5 -.PP -\fB\\$1\fR -.PP -.. -.de Sp \" Vertical space (when we can't use .PP) -.if t .sp .5v -.if n .sp -.. -.de Vb \" Begin verbatim text -.ft CW -.nf -.ne \\$1 -.. -.de Ve \" End verbatim text -.ft R -.fi -.. -.\" Set up some character translations and predefined strings. \*(-- will -.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left -.\" double quote, and \*(R" will give a right double quote. | will give a -.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to -.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' -.\" expand to `' in nroff, nothing in troff, for use with C<>. -.tr \(*W-|\(bv\*(Tr -.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' -.ie n \{\ -. ds -- \(*W- -. ds PI pi -. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch -. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch -. ds L" "" -. ds R" "" -. ds C` "" -. ds C' "" -'br\} -.el\{\ -. ds -- \|\(em\| -. ds PI \(*p -. ds L" `` -. ds R" '' -'br\} -.\" -.\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index -.\" entries marked with X<> in POD. Of course, you'll have to process the -.\" output yourself in some meaningful fashion. -.if \nF \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" -.. -. nr % 0 -. rr F -.\} -.\" -.\" For nroff, turn off justification. Always turn off hyphenation; it makes -.\" way too many mistakes in technical documents. -.hy 0 -.if n .na -.\" -.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). -.\" Fear. Run. Save yourself. No user-serviceable parts. -. \" fudge factors for nroff and troff -.if n \{\ -. ds #H 0 -. ds #V .8m -. ds #F .3m -. ds #[ \f1 -. ds #] \fP -.\} -.if t \{\ -. ds #H ((1u-(\\\\n(.fu%2u))*.13m) -. ds #V .6m -. ds #F 0 -. ds #[ \& -. ds #] \& -.\} -. \" simple accents for nroff and troff -.if n \{\ -. ds ' \& -. ds ` \& -. ds ^ \& -. ds , \& -. ds ~ ~ -. ds / -.\} -.if t \{\ -. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" -. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' -. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' -. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' -. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' -. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' -.\} -. \" troff and (daisy-wheel) nroff accents -.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' -.ds 8 \h'\*(#H'\(*b\h'-\*(#H' -.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] -.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' -.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' -.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] -.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] -.ds ae a\h'-(\w'a'u*4/10)'e -.ds Ae A\h'-(\w'A'u*4/10)'E -. \" corrections for vroff -.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' -.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' -. \" for low resolution devices (crt and lpr) -.if \n(.H>23 .if \n(.V>19 \ -\{\ -. ds : e -. ds 8 ss -. ds o a -. ds d- d\h'-1'\(ga -. ds D- D\h'-1'\(hy -. ds th \o'bp' -. ds Th \o'LP' -. ds ae ae -. ds Ae AE -.\} -.rm #[ #] #H #V #F C -.\" ======================================================================== -.\" -.IX Title "MYSQL_TABLEINFO 1" -.TH MYSQL_TABLEINFO 1 "2003-04-05" "perl v5.8.0" "User Contributed Perl Documentation" -.SH "NAME" -mysql_tableinfo \- creates and populates information tables with -the output of SHOW DATABASES, SHOW TABLES (or SHOW TABLE STATUS), -SHOW COLUMNS and SHOW INDEX. -.PP -This is version 1.1. -.SH "SYNOPSIS" -.IX Header "SYNOPSIS" -.Vb 1 -\& mysql_tableinfo [OPTIONS] database_to_write [database_like_wild] [table_like_wild] -.Ve -.PP -.Vb 2 -\& Do not backquote (``) database_to_write, -\& and do not quote ('') database_like_wild or table_like_wild -.Ve -.PP -.Vb 1 -\& Examples: -.Ve -.PP -.Vb 1 -\& mysql_tableinfo info -.Ve -.PP -.Vb 1 -\& mysql_tableinfo info this_db -.Ve -.PP -.Vb 1 -\& mysql_tableinfo info %a% b% -.Ve -.PP -.Vb 1 -\& mysql_tableinfo info --clear-only -.Ve -.PP -.Vb 1 -\& mysql_tableinfo info --col --idx --table-status -.Ve -.SH "DESCRIPTION" -.IX Header "DESCRIPTION" -mysql_tableinfo asks a MySQL server information about its -databases, tables, table columns and index, and stores this -in tables called `db`, `tbl` (or `tbl_status`), `col`, `idx` -(with an optional prefix specified with \-\-prefix). -After that, you can query these information tables, for example -to build your admin scripts with \s-1SQL\s0 queries, like -.PP -\&\s-1SELECT\s0 \s-1CONCAT\s0(\*(L"\s-1CHECK\s0 \s-1TABLE\s0 \*(R",`database`,\*(L".\*(R",`table`,\*(L" \s-1EXTENDED\s0;\*(R") -\&\s-1FROM\s0 info.tbl \s-1WHERE\s0 ... ; -.PP -as people usually do with some other \s-1RDBMS\s0 -(note: to increase the speed of your queries on the info tables, -you may add some index on them). -.PP -The database_like_wild and table_like_wild instructs the program -to gather information only about databases and tables -whose names match these patterns. If the info -tables already exist, their rows matching the patterns are simply -deleted and replaced by the new ones. That is, -old rows not matching the patterns are not touched. -If the database_like_wild and table_like_wild arguments -are not specified on the command-line they default to \*(L"%\*(R". -.PP -The program : -.PP -\&\- does \s-1CREATE\s0 \s-1DATABASE\s0 \s-1IF\s0 \s-1NOT\s0 \s-1EXISTS\s0 database_to_write -where database_to_write is the database name specified on the command\-line. -.PP -\&\- does \s-1CREATE\s0 \s-1TABLE\s0 \s-1IF\s0 \s-1NOT\s0 \s-1EXISTS\s0 database_to_write.`db` -.PP -\&\- fills database_to_write.`db` with the output of -\&\s-1SHOW\s0 \s-1DATABASES\s0 \s-1LIKE\s0 database_like_wild -.PP -\&\- does \s-1CREATE\s0 \s-1TABLE\s0 \s-1IF\s0 \s-1NOT\s0 \s-1EXISTS\s0 database_to_write.`tbl` -(respectively database_to_write.`tbl_status` -if the \-\-tbl\-status option is on) -.PP -\&\- for every found database, -fills database_to_write.`tbl` (respectively database_to_write.`tbl_status`) -with the output of -\&\s-1SHOW\s0 \s-1TABLES\s0 \s-1FROM\s0 found_db \s-1LIKE\s0 table_like_wild -(respectively \s-1SHOW\s0 \s-1TABLE\s0 \s-1STATUS\s0 \s-1FROM\s0 found_db \s-1LIKE\s0 table_like_wild) -.PP -\&\- if the \-\-col option is on, - * does \s-1CREATE\s0 \s-1TABLE\s0 \s-1IF\s0 \s-1NOT\s0 \s-1EXISTS\s0 database_to_write.`col` - * for every found table, - fills database_to_write.`col` with the output of - \s-1SHOW\s0 \s-1COLUMNS\s0 \s-1FROM\s0 found_tbl \s-1FROM\s0 found_db -.PP -\&\- if the \-\-idx option is on, - * does \s-1CREATE\s0 \s-1TABLE\s0 \s-1IF\s0 \s-1NOT\s0 \s-1EXISTS\s0 database_to_write.`idx` - * for every found table, - fills database_to_write.`idx` with the output of - \s-1SHOW\s0 \s-1INDEX\s0 \s-1FROM\s0 found_tbl \s-1FROM\s0 found_db -.PP -Some options may modify this general scheme (see below). -.PP -As mentioned, the contents of the info tables are the output of -\&\s-1SHOW\s0 commands. In fact the contents are slightly more complete : -.PP -\&\- the `tbl` (or `tbl_status`) info table - has an extra column which contains the database name, -.PP -\&\- the `col` info table - has an extra column which contains the table name, - and an extra column which contains, for each described column, - the number of this column in the table owning it (this extra column - is called `Seq_in_table`). `Seq_in_table` makes it possible for you - to retrieve your columns in sorted order, when you are querying - the `col` table. -.PP -\&\- the `index` info table - has an extra column which contains the database name. -.PP -Caution: info tables contain certain columns (e.g. -Database, Table, Null...) whose names, as they are MySQL reserved words, -need to be backquoted (`...`) when used in \s-1SQL\s0 statements. -.PP -Caution: as information fetching and info tables filling happen at the -same time, info tables may contain inaccurate information about -themselves. -.SH "OPTIONS" -.IX Header "OPTIONS" -.IP "\-\-clear" 4 -.IX Item "--clear" -Does \s-1DROP\s0 \s-1TABLE\s0 on the info tables (only those that the program is -going to fill, for example if you do not use \-\-col it won't drop -the `col` table) and processes normally. Does not drop database_to_write. -.IP "\-\-clear\-only" 4 -.IX Item "--clear-only" -Same as \-\-clear but exits after the DROPs. -.IP "\-\-col" 4 -.IX Item "--col" -Adds columns information (into table `col`). -.IP "\-\-idx" 4 -.IX Item "--idx" -Adds index information (into table `idx`). -.IP "\-\-prefix prefix" 4 -.IX Item "--prefix prefix" -The info tables are named from the concatenation of prefix and, -respectively, db, tbl (or tbl_status), col, idx. Do not quote ('') -or backquote (``) prefix. -.IP "\-q, \-\-quiet" 4 -.IX Item "-q, --quiet" -Does not warn you about what the script is going to do (\s-1DROP\s0 \s-1TABLE\s0 etc) -and does not ask for a confirmation before starting. -.IP "\-\-tbl\-status" 4 -.IX Item "--tbl-status" -Instead of using \s-1SHOW\s0 \s-1TABLES\s0, uses \s-1SHOW\s0 \s-1TABLE\s0 \s-1STATUS\s0 -(much more complete information, but slower). -.IP "\-\-help" 4 -.IX Item "--help" -Display helpscreen and exit -.IP "\-u, \-\-user=#" 4 -.IX Item "-u, --user=#" -user for database login if not current user. Give a user -who has sufficient privileges (\s-1CREATE\s0, ...). -.IP "\-p, \-\-password=# (INSECURE)" 4 -.IX Item "-p, --password=# (INSECURE)" -password to use when connecting to server. -WARNING: Providing a password on command line is insecure as it is visible through /proc to anyone for a short time. -.IP "\-h, \-\-host=#" 4 -.IX Item "-h, --host=#" -host to connect to -.IP "\-P, \-\-port=#" 4 -.IX Item "-P, --port=#" -port to use when connecting to server -.IP "\-S, \-\-socket=#" 4 -.IX Item "-S, --socket=#" -\&\s-1UNIX\s0 domain socket to use when connecting to server -.SH "WARRANTY" -.IX Header "WARRANTY" -This software is free and comes without warranty of any kind. You -should never trust backup software without studying the code yourself. -Study the code inside this script and only rely on it if \fIyou\fR believe -that it does the right thing for you. -.Sp -Patches adding bug fixes, documentation and new features are welcome. -.SH "TO DO" -.IX Header "TO DO" -Use extended inserts to be faster (for servers with many databases -or tables). But to do that, must care about net\-buffer\-length. -.SH "AUTHOR" -.IX Header "AUTHOR" -2002\-06\-18 Guilhem Bichot (guilhem.bichot@mines\-paris.org) -.Sp -And all the authors of mysqlhotcopy, which served as a model for -the structure of the program. diff --git a/storage/xtradb/build/debian/additions/mysql_waitpid.1 b/storage/xtradb/build/debian/additions/mysql_waitpid.1 deleted file mode 100644 index f6877865ba8..00000000000 --- a/storage/xtradb/build/debian/additions/mysql_waitpid.1 +++ /dev/null @@ -1,20 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysql_waitpid \- Waits a specified amount of seconds for a PID to terminate. -.SH SYNOPSIS -mysql_waitpid [options] -.SH DESCRIPTION -Description: Waits for a program, which program id is #pid, to -terminate within #time seconds. If the program terminates within -this time, or if the #pid no longer exists, value 0 is returned. -Otherwise 1 is returned. Both #pid and #time must be positive -integer arguments. - -See mysql_waitpid for options. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysqlbinlog.1 b/storage/xtradb/build/debian/additions/mysqlbinlog.1 deleted file mode 100644 index fcdf2a083f4..00000000000 --- a/storage/xtradb/build/debian/additions/mysqlbinlog.1 +++ /dev/null @@ -1,17 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysqlbinlog \- Dumps MySQL binary logs. -.SH SYNOPSIS -mysqlbinlog [options] -.SH DESCRIPTION -Dumps a MySQL binary log in a format usable for viewing or for pipeing to -the mysql command line client - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysqlbug.1 b/storage/xtradb/build/debian/additions/mysqlbug.1 deleted file mode 100644 index 133330dd897..00000000000 --- a/storage/xtradb/build/debian/additions/mysqlbug.1 +++ /dev/null @@ -1,14 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysqlbug \- MySQL bug reporting tool. -.SH SYNOPSIS -mysqlbug [options] -.SH DESCRIPTION -Interactive bug reporting tool. Use reportbug on Debian systems. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysqlcheck.1 b/storage/xtradb/build/debian/additions/mysqlcheck.1 deleted file mode 100644 index b36ba2d1eb1..00000000000 --- a/storage/xtradb/build/debian/additions/mysqlcheck.1 +++ /dev/null @@ -1,28 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysqlcheck \- MySQL program for repairing, checking and optimizing tables. -.SH SYNOPSIS -mysqlcheck | mysqlanalyze | mysqloptimize [options] -.SH DESCRIPTION -This program can be used to CHECK (-c,-m,-C), REPAIR (-r), ANALYZE (-a) -or OPTIMIZE (-o) tables. Some of the options (like -e or -q) can be -used same time. It works on MyISAM and in some cases on BDB tables. -Please consult the MySQL manual for latest information about the -above. The options -c,-r,-a and -o are exclusive to each other, which -means that the last option will be used, if several was specified. - -The option -c will be used by default, if none was specified. You -can change the default behavior by making a symbolic link, or -copying this file somewhere with another name, the alternatives are: -mysqlrepair: The default option will be -r -mysqlanalyze: The default option will be -a -mysqloptimize: The default option will be -o - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (8) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysqld_safe_syslog.cnf b/storage/xtradb/build/debian/additions/mysqld_safe_syslog.cnf deleted file mode 100644 index 3b0445d6bd8..00000000000 --- a/storage/xtradb/build/debian/additions/mysqld_safe_syslog.cnf +++ /dev/null @@ -1,2 +0,0 @@ -[mysqld_safe] -syslog diff --git a/storage/xtradb/build/debian/additions/mysqldumpslow.1 b/storage/xtradb/build/debian/additions/mysqldumpslow.1 deleted file mode 100644 index 0431ef04cbb..00000000000 --- a/storage/xtradb/build/debian/additions/mysqldumpslow.1 +++ /dev/null @@ -1,50 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysqldumpslow \- Parse and summarize the MySQL slow query log. -.SH SYNOPSIS -mysqldumpslow [options] -.SH DESCRIPTION -This program parses and summarizes a 'slow query log'. - -.TP -\fB\-v\fR -verbose -.TP -\fB\-d\fR -debug -.TP -\fB\-s=WORD\fR -what to sort by (t, at, l, al, r, ar etc) -.TP -\fB\-r\fR -reverse the sort order (largest last instead of first) -.TP -\fB\-t=NUMBER\fR -just show the top n queries -.TP -\fB\-a\fR -don't abstract all numbers to N and strings to 'S' -.TP -\fB\-n=NUMBER\fR -abstract numbers with at least n digits within names -.TP -\fB\-g=WORD\fR -grep: only consider stmts that include this string -.TP -\fB\-h=WORD\fR -hostname of db server for *-slow.log filename (can be wildcard) -.TP -\fB\-i=WORD\fR -name of server instance (if using mysql.server startup script) -.TP -\fB\-l\fR -don't subtract lock time from total time - -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers based on -the commends in the code. - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysqlimport.1 b/storage/xtradb/build/debian/additions/mysqlimport.1 deleted file mode 100644 index 9007307a328..00000000000 --- a/storage/xtradb/build/debian/additions/mysqlimport.1 +++ /dev/null @@ -1,20 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysqlimport \- Imports text files with MySQL database queries. -.SH SYNOPSIS -mysqlimport [options] -.SH DESCRIPTION -Loads tables from text files in various formats. The base name of the -text file must be the name of the table that should be used. -If one uses sockets to connect to the MySQL server, the server will open and -read the text file directly. In other cases the client will open the text -file. The SQL command 'LOAD DATA INFILE' is used to import the rows. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/mysqlmanager.1 b/storage/xtradb/build/debian/additions/mysqlmanager.1 deleted file mode 100644 index ebb69adbd09..00000000000 --- a/storage/xtradb/build/debian/additions/mysqlmanager.1 +++ /dev/null @@ -1,49 +0,0 @@ -.TH mysql 1 "March 2005" "MySQL 4.1" "MySQL database" -.SH NAME -mysqlmanager \- Manages instances of MySQL server. -.SH SYNOPSIS -.B mysqlmanager -[\fIOPTIONS\fR] -.SH DESCRIPTION -Manages instances of MySQL server. -.TP -\-?, \fB\-\-help\fR -Display this help and exit. -.TP -\fB\-P\fR, \fB\-\-port=\fR# -Port number to listen on. -.TP -\fB\-l\fR, \fB\-\-log\fR=\fIname\fR -Path to log file. -.TP -\fB\-b\fR, \fB\-\-bind\-address=\fR# -Address to listen on. -.HP -\fB\-B\fR, \fB\-\-tcp\-backlog=\fR# Size of TCP/IP listen queue. -.HP -\fB\-g\fR, \fB\-\-greeting\fR=\fIname\fR Set greeting on connect. -.TP -\fB\-m\fR, \fB\-\-max\-command\-len=\fR# -Maximum command length. -.TP -\fB\-d\fR, \fB\-\-one\-thread\fR -Use one thread ( for debugging). -.TP -\fB\-C\fR, \fB\-\-connect\-retries=\fR# -Number of attempts to establish MySQL connection. -.TP -\fB\-p\fR, \fB\-\-password\-file\fR=\fIname\fR -Password file for manager. -.HP -\fB\-f\fR, \fB\-\-pid\-file\fR=\fIname\fR Pid file to use. -.TP -\fB\-V\fR, \fB\-\-version\fR -Output version information and exit. -.SH "SEE ALSO" -The full documentation for -.B mysqlmanager -is available in the package mysql-doc-4.1 or on the MySQL -homepage www.mysql.com. -.SH AUTHOR -This manpage was created by Christian Hammers -using help2man. diff --git a/storage/xtradb/build/debian/additions/mysqlreport b/storage/xtradb/build/debian/additions/mysqlreport deleted file mode 100644 index 402a5be835d..00000000000 --- a/storage/xtradb/build/debian/additions/mysqlreport +++ /dev/null @@ -1,1298 +0,0 @@ -#!/usr/bin/perl -w - -# mysqlreport v3.5 Apr 16 2008 -# http://hackmysql.com/mysqlreport - -# mysqlreport makes an easy-to-read report of important MySQL status values. -# Copyright 2006-2008 Daniel Nichter -# -# 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; either version 2 -# of the License, or (at your option) any later version. -# -# 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. -# -# The GNU General Public License is available at: -# http://www.gnu.org/copyleft/gpl.html - -use strict; -use File::Temp qw(tempfile); -use DBI; -use Getopt::Long; -eval { require Term::ReadKey; }; -my $RK = ($@ ? 0 : 1); - -sub have_op; - -my $WIN = ($^O eq 'MSWin32' ? 1 : 0); -my %op; -my %mycnf; # ~/.my.cnf -my ($tmpfile_fh, $tmpfile); -my ($stat_name, $stat_val, $stat_label); -my $MySQL_version; -my (%stats, %vars); # SHOW STATUS, SHOW VARIABLES -my (%DMS_vals, %Com_vals, %ib_vals); -my ($dbh, $query); -my ($questions, $key_read_ratio, $key_write_ratio, $dms, $slow_query_t); -my ($key_cache_block_size, $key_buffer_used, $key_buffer_usage); -my ($qc_mem_used, $qc_hi_r, $qc_ip_r); # Query Cache -my $have_innodb_vals; -my ($ib_bp_used, $ib_bp_total, $ib_bp_read_ratio); -my ($relative_live, $relative_infiles); -my $real_uptime; -my (%stats_present, %stats_past); # For relative reports - -GetOptions ( - \%op, - "user=s", - "password:s", - "host=s", - "port=s", - "socket=s", - "no-mycnf", - "infile|in=s", - "outfile=s", - "flush-status", - "email=s", - "r|relative:i", - "c|report-count=i", - "detach", - "help|?", - "debug" -); - -show_help_and_exit() if $op{'help'}; - -get_user_mycnf() unless $op{'no-mycnf'}; - -# Command line options override ~/.my.cnf -$mycnf{'host'} = $op{'host'} if have_op 'host'; -$mycnf{'port'} = $op{'port'} if have_op 'port'; -$mycnf{'socket'} = $op{'socket'} if have_op 'socket'; -$mycnf{'user'} = $op{'user'} if have_op 'user'; - -$mycnf{'user'} ||= $ENV{'USER'}; - -if(exists $op{'password'}) -{ - if($op{'password'} eq '') # Prompt for password - { - Term::ReadKey::ReadMode(2) if $RK; - print "Password for database user $mycnf{'user'}: "; - chomp($mycnf{'pass'} = ); - Term::ReadKey::ReadMode(0), print "\n" if $RK; - } - else { $mycnf{'pass'} = $op{'password'}; } # Use password given on command line -} - -$op{'com'} ||= 3; -$op{'c'} ||= 1; # Used in collect_reports() if --r given integer value - -$relative_live = 0; -$relative_infiles = 0; - -if(defined $op{'r'}) -{ - if($op{r}) { $relative_live = 1; } # if -r was given an integer value - else { $relative_infiles = 1; } -} - -# The report is written to a tmp file first. -# Later it will be moved to $op{'outfile'} or emailed $op{'email'} if needed. -($tmpfile_fh, $tmpfile) = tempfile() or die "Cannot open temporary file for writing: $!\n"; - -if($op{'detach'}) -{ - $SIG{'TERM'} = 'sig_handler'; - - if(fork()) - { - print "mysqlreport has forked and detached.\n"; - print "While running detached, mysqlreport writes reports to '$tmpfile'.\n"; - - exit; - } - - open(STDIN, " $tmpfile") or die "Cannot dup STDOUT: $!\n"; - open(STDERR, "> $tmpfile") or die "Cannot dup STDERR: $!\n"; -} - -select $tmpfile_fh; -$| = 1 if ($op{'detach'} || $relative_live); - -print "tmp file: $tmpfile\n" if $op{debug}; - -# Connect to MySQL -if(!$op{'infile'} && !$relative_infiles) -{ - connect_to_MySQL(); -} - -$have_innodb_vals = 1; # This might be set to 0 later in get_MySQL_version() - -if(defined $op{'r'}) -{ - if($relative_live) - { - print STDERR "mysqlreport is writing relative reports to '$tmpfile'.\n" unless $op{'detach'}; - get_MySQL_version(); - collect_reports(); - } - - if($relative_infiles) { read_relative_infiles(); } -} -else -{ - if(!$op{'infile'}) - { - get_MySQL_version(); - get_vals(); - get_vars(); - } - else - { - read_infile($op{'infile'}); - } - - get_Com_values(); - - set_myisam_vals(); - set_ib_vals() if $have_innodb_vals; - - write_report(); -} - -exit_tasks_and_cleanup(); - -exit; - -# -# Subroutines -# -sub show_help_and_exit -{ - print <<"HELP"; -mysqlreport v3.5 Apr 16 2008 -mysqlreport makes an easy-to-read report of important MySQL status values. - -Command line options (abbreviations work): - --user USER Connect to MySQL as USER - --password PASS Use PASS or prompt for MySQL user's password - --host ADDRESS Connect to MySQL at ADDRESS - --port PORT Connect to MySQL at PORT - --socket SOCKET Connect to MySQL at SOCKET - --no-mycnf Don't read ~/.my.cnf - --infile FILE Read status values from FILE instead of MySQL - --outfile FILE Write report to FILE - --email ADDRESS Email report to ADDRESS (doesn't work on Windows) - --flush-status Issue FLUSH STATUS; after getting current values - --relative X Generate relative reports. If X is an integer, - reports are live from the MySQL server X seconds apart. - If X is a list of infiles (file1 file2 etc.), - reports are generated from the infiles in the order - that they are given. - --report-count N Collect N number of live relative reports (default 1) - --detach Fork and detach from terminal (run in background) - --help Prints this - --debug Print debugging information - -Visit http://hackmysql.com/mysqlreport for more information. -HELP - - exit; -} - -sub get_user_mycnf -{ - print "get_user_mycnf\n" if $op{debug}; - - return if $WIN; - open MYCNF, "$ENV{HOME}/.my.cnf" or return; - while() - { - if(/^(.+?)\s*=\s*"?(.+?)"?\s*$/) - { - $mycnf{$1} = $2; - print "get_user_mycnf: read '$1 = $2'\n" if $op{debug}; - } - } - $mycnf{'pass'} ||= $mycnf{'password'} if exists $mycnf{'password'}; - close MYCNF; -} - -sub connect_to_MySQL -{ - print "connect_to_MySQL\n" if $op{debug}; - - my $dsn; - - if($mycnf{'socket'} && -S $mycnf{'socket'}) - { - $dsn = "DBI:mysql:mysql_socket=$mycnf{socket}"; - } - elsif($mycnf{'host'}) - { - $dsn = "DBI:mysql:host=$mycnf{host}" . ($mycnf{port} ? ";port=$mycnf{port}" : ""); - } - else - { - $dsn = "DBI:mysql:host=localhost"; - } - - print "connect_to_MySQL: DBI DSN: $dsn\n" if $op{debug}; - - $dbh = DBI->connect($dsn, $mycnf{'user'}, $mycnf{'pass'}) or die; -} - -sub collect_reports -{ - print "collect_reports\n" if $op{debug}; - - my $i; - - get_vals(); - get_vars(); - - get_Com_values(); - - %stats_past = %stats; - - set_myisam_vals(); - set_ib_vals() if $have_innodb_vals; - - print "#\n# Beginning report, 0 0:0:0\n#\n"; - - write_report(); - - for($i = 0; $i < $op{'c'}; $i++) - { - $dbh->disconnect(); - - sleep($op{'r'}); - - connect_to_MySQL(); - - print "\n#\n# Interval report " , $i + 1 , ", +", sec_to_dhms(($i + 1) * $op{'r'}), "\n#\n"; - - get_vals(); - - write_relative_report(); - } -} - -sub read_relative_infiles -{ - print "read_relative_infiles\n" if $op{debug}; - - my $slurp; # Used to check infiles for multiple sets of status values - my $n_stats; # Number of multiple sets of status values in an infile - my $infile; - my $report_n; # Report number - - $report_n = 1; - - foreach $infile (@ARGV) - { - # Read all of infile into $slurp - open INFILE, "< $infile" or warn and next; - $slurp = do { local $/; }; - close INFILE; - - $n_stats = 0; - - # Count number of status value sets - $n_stats++ while $slurp =~ /Aborted_clients/g; - - print "read_relative_infiles: found $n_stats sets of status values in file '$infile'\n" - if $op{debug}; - - if($n_stats == 1) - { - read_infile($infile); - relative_infile_report($report_n++); - } - - if($n_stats > 1) - { - my @tmpfile_fh; - my @tmpfile_name; - my $i; - my $stat_n; # Status value set number - - # Create a tmp file for each set of status values - for($i = 0; $i < $n_stats; $i++) - { - my ($fh, $name) = tempfile() - or die "read_relative_infiles: cannot open temporary file for writing: $!\n"; - - push(@tmpfile_fh, $fh); - push(@tmpfile_name, $name); - - print "read_relative_infiles: created tmp file '$name' for set $i\n" if $op{debug}; - } - - $i = 0; - $stat_n = 0; - - select $tmpfile_fh[$i]; - - # Read infile again and copy each set of status values to seperate tmp files - open INFILE, "< $infile" or warn and next; - while() - { - next if /^\+/; - next if /^$/; - - # The infile must begin with the system variable values. - # Therefore, the first occurance of Aborted_clients indicates the beginning - # of the first set of status values if no sets have occured yet ($stat_n == 0). - # In this case, the following status values are printed to the current fh, - # along with the system variable values read thus far, until Aborted_clients - # occurs again. Then begins the second and subsequent sets of status values. - - if(/Aborted_clients/) - { - print and next if $stat_n++ == 0; - select $tmpfile_fh[++$i]; - } - - print; - } - close INFILE; - - # Re-select the main tmp file into which the reports are being written. - select $tmpfile_fh; - - for($i = 0; $i < $n_stats; $i++) - { - close $tmpfile_fh[$i]; - - print "read_relative_infiles: reading set $i tmp file '$tmpfile_name[$i]'\n" - if $op{debug}; - - read_infile($tmpfile_name[$i]); - relative_infile_report($report_n++); - - if($WIN) { `del $tmpfile_name[$i]`; } - else { `rm -f $tmpfile_name[$i]`; } - - print "read_relative_infiles: deleted set $i tmp file '$tmpfile_name[$i]'\n" - if $op{debug}; - } - - } # if($n_stats > 1) - } # foreach $infile (@files) -} - -sub relative_infile_report -{ - print "relative_infile_report\n" if $op{debug}; - - my $report_n = shift; - - if($report_n == 1) - { - get_Com_values(); - - %stats_past = %stats; - - set_myisam_vals(); - set_ib_vals() if $have_innodb_vals; - - print "#\n# Beginning report, 0 0:0:0\n#\n"; - - write_report(); - } - else - { - print "\n#\n# Interval report ", $report_n - 1, ", +", - sec_to_dhms($stats{Uptime} - $stats_past{Uptime}), - "\n#\n"; - - write_relative_report(); - } -} - -sub get_vals -{ - print "get_vals\n" if $op{debug}; - - my @row; - - # Get status values - if($MySQL_version >= 50002) - { - $query = $dbh->prepare("SHOW GLOBAL STATUS;"); - } - else - { - $query = $dbh->prepare("SHOW STATUS;"); - } - $query->execute(); - while(@row = $query->fetchrow_array()) { $stats{$row[0]} = $row[1]; } - - $real_uptime = $stats{'Uptime'}; -} - -sub get_vars -{ - print "get_vars\n" if $op{debug}; - - my @row; - - # Get server system variables - $query = $dbh->prepare("SHOW VARIABLES;"); - $query->execute(); - while(@row = $query->fetchrow_array()) { $vars{$row[0]} = $row[1]; } - - # table_cache was renamed to table_open_cache in MySQL 5.1.3 - if($MySQL_version >= 50103) - { - $vars{'table_cache'} = $vars{'table_open_cache'}; - } -} - -sub read_infile -{ - print "read_infile\n" if $op{debug}; - - my $infile = shift; - - # Default required system variable values if not set in INFILE. - # As of mysqlreport v3.5 the direct output from SHOW VARIABLES; - # can be put into INFILE instead. See http://hackmysql.com/mysqlreportdoc - # for details. - $vars{'version'} = "0.0.0" if !exists $vars{'version'}; - $vars{'table_cache'} = 64 if !exists $vars{'table_cache'}; - $vars{'max_connections'} = 100 if !exists $vars{'max_connections'}; - $vars{'key_buffer_size'} = 8388600 if !exists $vars{'key_buffer_size'}; # 8M - $vars{'thread_cache_size'} = 0 if !exists $vars{'thread_cache_size'}; - $vars{'tmp_table_size'} = 0 if !exists $vars{'tmp_table_size'}; - $vars{'long_query_time'} = '?' if !exists $vars{'long_query_time'}; - $vars{'log_slow_queries'} = '?' if !exists $vars{'log_slow_queries'}; - - # One should also add: - # key_cache_block_size - # query_cache_size - # to INFILE if needed. - - open INFILE, "< $infile" or die "Cannot open INFILE '$infile': $!\n"; - - while() - { - last if !defined $_; - - next if /^\+/; # skip divider lines - next if /^$/; # skip blank lines - - next until /(Aborted_clients|back_log|=)/; - - if($1 eq 'Aborted_clients') # status values - { - print "read_infile: start stats\n" if $op{debug}; - - while($_) - { - chomp; - if(/([A-Za-z_]+)[\s\t|]+(\d+)/) - { - $stats{$1} = $2; - print "read_infile: save $1 = $2\n" if $op{debug}; - } - else { print "read_infile: ignore '$_'\n" if $op{debug}; } - - last if $1 eq 'Uptime'; # exit while() if end of status values - $_ = ; # otherwise, read next line of status values - } - } - elsif($1 eq 'back_log') # system variable values - { - print "read_infile: start vars\n" if $op{debug}; - - while($_) - { - chomp; - if(/([A-Za-z_]+)[\s\t|]+([\w\.\-]+)/) # This will exclude some vars - { # like pid_file which we don't need - $vars{$1} = $2; - print "read_infile: save $1 = $2\n" if $op{debug}; - } - else { print "read_infile: ignore '$_'\n" if $op{debug}; } - - last if $1 eq 'wait_timeout'; # exit while() if end of vars - $_ = ; # otherwise, read next line of vars - } - } - elsif($1 eq '=') # old style, manually added system variable values - { - print "read_infile: start old vars\n" if $op{debug}; - - while($_ && $_ =~ /=/) - { - chomp; - if(/^\s*(\w+)\s*=\s*([0-9.]+)(M*)\s*$/) # e.g.: key_buffer_size = 128M - { - $vars{$1} = ($3 ? $2 * 1024 * 1024 : $2); - print "read_infile: read '$_' as $1 = $vars{$1}\n" if $op{debug}; - } - else { print "read_infile: ignore '$_'\n" if $op{debug}; } - - $_ = ; # otherwise, read next line of old vars - } - - redo; - } - else - { - print "read_infile: unrecognized line: '$_'\n" if $op{debug}; - } - } - - close INFILE; - - $real_uptime = $stats{'Uptime'}; - - $vars{'table_cache'} = $vars{'table_open_cache'} if exists $vars{'table_open_cache'}; - - get_MySQL_version(); -} - -sub get_MySQL_version -{ - print "get_MySQL_version\n" if $op{debug}; - - return if $MySQL_version; - - my ($major, $minor, $patch); - - if($op{'infile'} || $relative_infiles) - { - ($major, $minor, $patch) = ($vars{'version'} =~ /(\d{1,2})\.(\d{1,2})\.(\d{1,2})/); - } - else - { - my @row; - - $query = $dbh->prepare("SHOW VARIABLES LIKE 'version';"); - $query->execute(); - @row = $query->fetchrow_array(); - ($major, $minor, $patch) = ($row[1] =~ /(\d{1,2})\.(\d{1,2})\.(\d{1,2})/); - } - - $MySQL_version = sprintf("%d%02d%02d", $major, $minor, $patch); - - # Innodb_ status values were added in 5.0.2 - if($MySQL_version < 50002) - { - $have_innodb_vals = 0; - print "get_MySQL_version: no InnoDB reports because MySQL version is older than 5.0.2\n" if $op{debug}; - } -} - -sub set_myisam_vals -{ - print "set_myisam_vals\n" if $op{debug}; - - $questions = $stats{'Questions'}; - - $key_read_ratio = sprintf "%.2f", - ($stats{'Key_read_requests'} ? - 100 - ($stats{'Key_reads'} / $stats{'Key_read_requests'}) * 100 : - 0); - - $key_write_ratio = sprintf "%.2f", - ($stats{'Key_write_requests'} ? - 100 - ($stats{'Key_writes'} / $stats{'Key_write_requests'}) * 100 : - 0); - - $key_cache_block_size = (defined $vars{'key_cache_block_size'} ? - $vars{'key_cache_block_size'} : - 1024); - - $key_buffer_used = $stats{'Key_blocks_used'} * $key_cache_block_size; - - if(defined $stats{'Key_blocks_unused'}) # MySQL 4.1.2+ - { - $key_buffer_usage = $vars{'key_buffer_size'} - - ($stats{'Key_blocks_unused'} * $key_cache_block_size); - } - else { $key_buffer_usage = -1; } - - # Data Manipulation Statements: http://dev.mysql.com/doc/refman/5.0/en/data-manipulation.html - %DMS_vals = - ( - SELECT => $stats{'Com_select'}, - INSERT => $stats{'Com_insert'} + $stats{'Com_insert_select'}, - REPLACE => $stats{'Com_replace'} + $stats{'Com_replace_select'}, - UPDATE => $stats{'Com_update'} + - (exists $stats{'Com_update_multi'} ? $stats{'Com_update_multi'} : 0), - DELETE => $stats{'Com_delete'} + - (exists $stats{'Com_delete_multi'} ? $stats{'Com_delete_multi'} : 0) - ); - - $dms = $DMS_vals{SELECT} + $DMS_vals{INSERT} + $DMS_vals{REPLACE} + $DMS_vals{UPDATE} + $DMS_vals{DELETE}; - - $slow_query_t = format_u_time($vars{long_query_time}); - -} - -sub set_ib_vals -{ - print "set_ib_vals\n" if $op{debug}; - - $ib_bp_used = ($stats{'Innodb_buffer_pool_pages_total'} - - $stats{'Innodb_buffer_pool_pages_free'}) * - $stats{'Innodb_page_size'}; - - $ib_bp_total = $stats{'Innodb_buffer_pool_pages_total'} * $stats{'Innodb_page_size'}; - - $ib_bp_read_ratio = sprintf "%.2f", - ($stats{'Innodb_buffer_pool_read_requests'} ? - 100 - ($stats{'Innodb_buffer_pool_reads'} / - $stats{'Innodb_buffer_pool_read_requests'}) * 100 : - 0); -} - -sub write_relative_report -{ - print "write_relative_report\n" if $op{debug}; - - %stats_present = %stats; - - for(keys %stats) - { - if($stats_past{$_} =~ /\d+/) - { - if($stats_present{$_} >= $stats_past{$_}) # Avoid negative values - { - $stats{$_} = $stats_present{$_} - $stats_past{$_}; - } - } - } - - # These values are either "at present" or "high water marks". - # Therefore, it is more logical to not relativize these values. - # Doing otherwise causes strange and misleading values. - $stats{'Key_blocks_used'} = $stats_present{'Key_blocks_used'}; - $stats{'Open_tables'} = $stats_present{'Open_tables'}; - $stats{'Max_used_connections'} = $stats_present{'Max_used_connections'}; - $stats{'Threads_running'} = $stats_present{'Threads_running'}; - $stats{'Threads_connected'} = $stats_present{'Threads_connected'}; - $stats{'Threads_cached'} = $stats_present{'Threads_cached'}; - $stats{'Qcache_free_blocks'} = $stats_present{'Qcache_free_blocks'}; - $stats{'Qcache_total_blocks'} = $stats_present{'Qcache_total_blocks'}; - $stats{'Qcache_free_memory'} = $stats_present{'Qcache_free_memory'}; - if($have_innodb_vals) - { - $stats{'Innodb_page_size'} = $stats_present{'Innodb_page_size'}; - $stats{'Innodb_buffer_pool_pages_data'} = $stats_present{'Innodb_buffer_pool_pages_data'}; - $stats{'Innodb_buffer_pool_pages_dirty'} = $stats_present{'Innodb_buffer_pool_pages_dirty'}; - $stats{'Innodb_buffer_pool_pages_free'} = $stats_present{'Innodb_buffer_pool_pages_free'}; - $stats{'Innodb_buffer_pool_pages_latched'} = $stats_present{'Innodb_buffer_pool_pages_latched'}; - $stats{'Innodb_buffer_pool_pages_misc'} = $stats_present{'Innodb_buffer_pool_pages_misc'}; - $stats{'Innodb_buffer_pool_pages_total'} = $stats_present{'Innodb_buffer_pool_pages_total'}; - $stats{'Innodb_data_pending_fsyncs'} = $stats_present{'Innodb_data_pending_fsyncs'}; - $stats{'Innodb_data_pending_reads'} = $stats_present{'Innodb_data_pending_reads'}; - $stats{'Innodb_data_pending_writes'} = $stats_present{'Innodb_data_pending_writes'}; - - # Innodb_row_lock_ values were added in MySQL 5.0.3 - if($MySQL_version >= 50003) - { - $stats{'Innodb_row_lock_current_waits'} = $stats_present{'Innodb_row_lock_current_waits'}; - $stats{'Innodb_row_lock_time_avg'} = $stats_present{'Innodb_row_lock_time_avg'}; - $stats{'Innodb_row_lock_time_max'} = $stats_present{'Innodb_row_lock_time_max'}; - } - } - - get_Com_values(); - - %stats_past = %stats_present; - - set_myisam_vals(); - set_ib_vals() if $have_innodb_vals; - - write_report(); -} - -sub write_report -{ - print "write_report\n" if $op{debug}; - - $~ = 'MYSQL_TIME', write; - $~ = 'KEY_BUFF_MAX', write; - if($key_buffer_usage != -1) { $~ = 'KEY_BUFF_USAGE', write } - $~ = 'KEY_RATIOS', write; - write_DTQ(); - $~ = 'SLOW_DMS', write; - write_DMS(); - write_Com(); - $~ = 'SAS', write; - write_qcache(); - $~ = 'REPORT_END', write; - $~ = 'TAB', write; - - write_InnoDB() if $have_innodb_vals; -} - -sub sec_to_dhms # Seconds to days hours:minutes:seconds -{ - my $s = shift; - my ($d, $h, $m) = (0, 0, 0); - - return '0 0:0:0' if $s <= 0; - - if($s >= 86400) - { - $d = int $s / 86400; - $s -= $d * 86400; - } - - if($s >= 3600) - { - $h = int $s / 3600; - $s -= $h * 3600; - } - - $m = int $s / 60; - $s -= $m * 60; - - return "$d $h:$m:$s"; -} - -sub make_short -{ - my ($number, $kb, $d) = @_; - my $n = 0; - my $short; - - $d ||= 2; - - if($kb) { while ($number > 1023) { $number /= 1024; $n++; }; } - else { while ($number > 999) { $number /= 1000; $n++; }; } - - $short = sprintf "%.${d}f%s", $number, ('','k','M','G','T')[$n]; - if($short =~ /^(.+)\.(00)$/) { return $1; } # 12.00 -> 12 but not 12.00k -> 12k - - return $short; -} - -# What began as a simple but great idea has become the new standard: -# long_query_time in microseconds. For MySQL 5.1.21+ and 6.0.4+ this -# is now standard. For 4.1 and 5.0 patches, the architects of this -# idea provide: http://www.mysqlperformanceblog.com/mysql-patches/ -# Relevant notes in MySQL manual: -# http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html -# http://dev.mysql.com/doc/refman/6.0/en/slow-query-log.html -# -# The format_u_time sub simply beautifies long_query_time. - -sub format_u_time # format microsecond (µ) time value -{ - # 0.000000 - 0.000999 = 0 - 999 µ - # 0.001000 - 0.999999 = 1 ms - 999.999 ms - # 1.000000 - n.nnnnnn = 1 s - n.nnnnn s - - my $t = shift; - my $f; # formatted µ time - my $u = chr(($WIN ? 230 : 181)); - - $t = 0 if $t < 0; - - if($t > 0 && $t <= 0.000999) - { - $f = ($t * 1000000) . " $u"; - } - elsif($t >= 0.001000 && $t <= 0.999999) - { - $f = ($t * 1000) . ' ms'; - } - elsif($t >= 1) - { - $f = ($t * 1) . ' s'; # * 1 to remove insignificant zeros - } - else - { - $f = 0; # $t should = 0 at this point - } - - return $f; -} - -sub perc # Percentage -{ - my($is, $of) = @_; - $is = 0 if (not defined $is); - return sprintf "%.2f", ($is * 100) / ($of ||= 1); -} - -sub t # Time average per second -{ - my $val = shift; - return 0 if !$val; - return(make_short($val / $stats{'Uptime'}, 0, 1)); -} - -sub email_report # Email given report to $op{'email'} -{ - print "email_report\n" if $op{debug}; - - return if $WIN; - - my $report = shift; - - open SENDMAIL, "|/usr/sbin/sendmail -t"; - print SENDMAIL "From: mysqlreport\n"; - print SENDMAIL "To: $op{email}\n"; - print SENDMAIL "Subject: MySQL status report on " . ($mycnf{'host'} || 'localhost') . "\n\n"; - print SENDMAIL `cat $report`; - close SENDMAIL; -} - -sub cat_report # Print given report to screen -{ - print "cat_report\n" if $op{debug}; - - my $report = shift; - my @report; - - open REPORT, "< $report"; - @report = ; - close REPORT; - print @report; -} - -sub get_Com_values -{ - print "get_Com_values\n" if $op{debug}; - - %Com_vals = (); - - # Make copy of just the Com_ values - for(keys %stats) - { - if(grep /^Com_/, $_ and $stats{$_} > 0) - { - /^Com_(.*)/; - $Com_vals{$1} = $stats{$_}; - } - } - - # Remove DMS values - delete $Com_vals{'select'}; - delete $Com_vals{'insert'}; - delete $Com_vals{'insert_select'}; - delete $Com_vals{'replace'}; - delete $Com_vals{'replace_select'}; - delete $Com_vals{'update'}; - delete $Com_vals{'update_multi'} if exists $Com_vals{'update_multi'}; - delete $Com_vals{'delete'}; - delete $Com_vals{'delete_multi'} if exists $Com_vals{'delete_multi'}; -} - -sub write_DTQ # Write DTQ report in descending order by values -{ - print "write_DTQ\n" if $op{debug}; - - $~ = 'DTQ'; - - my %DTQ; - my $first = 1; - - # Total Com values - $stat_val = 0; - for(values %Com_vals) { $stat_val += $_; } - $DTQ{'Com_'} = $stat_val; - - $DTQ{'DMS'} = $dms; - $DTQ{'QC Hits'} = $stats{'Qcache_hits'} if $stats{'Qcache_hits'} != 0; - $DTQ{'COM_QUIT'} = int (($stats{'Connections'} - 2) - ($stats{'Aborted_clients'} / 2)); - - $stat_val = 0; - for(values %DTQ) { $stat_val += $_; } - if($questions != $stat_val) - { - $DTQ{($questions > $stat_val ? '+Unknown' : '-Unknown')} = abs $questions - $stat_val; - } - - for(sort { $DTQ{$b} <=> $DTQ{$a} } keys(%DTQ)) - { - if($first) { $stat_label = '%Total:'; $first = 0; } - else { $stat_label = ''; } - - $stat_name = $_; - $stat_val = $DTQ{$_}; - write; - } -} - -sub write_DMS # Write DMS report in descending order by values -{ - print "write_DMS\n" if $op{debug}; - - $~ = 'DMS'; - - for(sort { $DMS_vals{$b} <=> $DMS_vals{$a} } keys(%DMS_vals)) - { - $stat_name = $_; - $stat_val = $DMS_vals{$_}; - write; - } -} - -sub write_Com # Write COM report in descending order by values -{ - print "write_Com\n" if $op{debug}; - - my $i = $op{'com'}; - - $~ = 'COM_1'; - - # Total Com values and write first line of COM report - $stat_label = '%Total:' unless $op{'dtq'}; - $stat_val = 0; - for(values %Com_vals) { $stat_val += $_; } - write; - - $~ = 'COM_2'; - - # Sort remaining Com values, print only the top $op{'com'} number of values - for(sort { $Com_vals{$b} <=> $Com_vals{$a} } keys(%Com_vals)) - { - $stat_name = $_; - $stat_val = $Com_vals{$_}; - write; - - last if !(--$i); - } -} - -sub write_qcache -{ - print "write_qcache\n" if $op{debug}; - - # Query cache was added in 4.0.1, but have_query_cache was added in 4.0.2, - # ergo this method is slightly more reliable - return if not exists $vars{'query_cache_size'}; - return if $vars{'query_cache_size'} == 0; - - $qc_mem_used = $vars{'query_cache_size'} - $stats{'Qcache_free_memory'}; - $qc_hi_r = sprintf "%.2f", $stats{'Qcache_hits'} / ($stats{'Qcache_inserts'} ||= 1); - $qc_ip_r = sprintf "%.2f", $stats{'Qcache_inserts'} / ($stats{'Qcache_lowmem_prunes'} ||= 1); - - $~ = 'QCACHE'; - write; -} - -sub write_InnoDB -{ - print "write_InnoDB\n" if $op{debug}; - - return if not defined $stats{'Innodb_page_size'}; - - $stats{'Innodb_buffer_pool_pages_latched'} = 0 if not defined $stats{'Innodb_buffer_pool_pages_latched'}; - - $~ = 'IB'; - write; - - # Innodb_row_lock_ values were added in MySQL 5.0.3 - if($MySQL_version >= 50003) - { - $~ = 'IB_LOCK'; - write; - } - - # Data, Pages, Rows - $~ = 'IB_DPR'; - write; -} - -sub have_op -{ - my $key = shift; - return 1 if (exists $op{$key} && $op{$key} ne ''); - return 0; -} - -sub sig_handler -{ - print "\nReceived signal at " , scalar localtime , "\n"; - exit_tasks_and_cleanup(); - exit; -} - -sub exit_tasks_and_cleanup -{ - print "exit_tasks_and_cleanup\n" if $op{debug}; - - close $tmpfile_fh; - select STDOUT unless $op{'detach'}; - - email_report($tmpfile) if $op{'email'}; - - cat_report($tmpfile) unless $op{'detach'}; - - if($op{'outfile'}) - { - if($WIN) { `move $tmpfile $op{outfile}`; } - else { `mv $tmpfile $op{outfile}`; } - } - else - { - if($WIN) { `del $tmpfile`; } - else { `rm -f $tmpfile`; } - } - - if(!$op{'infile'} && !$relative_infiles) - { - if($op{'flush-status'}) - { - $query = $dbh->prepare("FLUSH STATUS;"); - $query->execute(); - } - - $query->finish(); - $dbh->disconnect(); - } -} - -# -# Formats -# - -format MYSQL_TIME = -MySQL @<<<<<<<<<<<<<<<< uptime @<<<<<<<<<<< @>>>>>>>>>>>>>>>>>>>>>>>> -$vars{'version'}, sec_to_dhms($real_uptime), (($op{infile} || $relative_infiles) ? '' : scalar localtime) -. - -format KEY_BUFF_MAX = - -__ Key _________________________________________________________________ -Buffer used @>>>>>> of @>>>>>> %Used: @>>>>> -make_short($key_buffer_used, 1), make_short($vars{'key_buffer_size'}, 1), perc($key_buffer_used, $vars{'key_buffer_size'}) -. - -format KEY_BUFF_USAGE = - Current @>>>>>> %Usage: @>>>>> -make_short($key_buffer_usage, 1), perc($key_buffer_usage, $vars{'key_buffer_size'}) -. - -format KEY_RATIOS = -Write hit @>>>>>% -$key_write_ratio -Read hit @>>>>>% -$key_read_ratio - -__ Questions ___________________________________________________________ -Total @>>>>>>>> @>>>>>/s -make_short($questions), t($questions) -. - -format DTQ = - @<<<<<<< @>>>>>>>> @>>>>>/s @>>>>>> @>>>>> -$stat_name, make_short($stat_val), t($stat_val), $stat_label, perc($stat_val, $questions) -. - -format SLOW_DMS = -Slow @<<<<<<< @>>>>>> @>>>>>/s @>>>>> %DMS: @>>>>> Log: @>> -$slow_query_t, make_short($stats{'Slow_queries'}), t($stats{'Slow_queries'}), perc($stats{'Slow_queries'}, $questions), perc($stats{'Slow_queries'}, $dms), $vars{'log_slow_queries'} -DMS @>>>>>>>> @>>>>>/s @>>>>> -make_short($dms), t($dms), perc($dms, $questions) -. - -format DMS = - @<<<<<<< @>>>>>>>> @>>>>>/s @>>>>> @>>>>> -$stat_name, make_short($stat_val), t($stat_val), perc($stat_val, $questions), perc($stat_val, $dms) -. - -format COM_1 = -Com_ @>>>>>>>> @>>>>>/s @>>>>> -make_short($stat_val), t($stat_val), perc($stat_val, $questions) -. - -format COM_2 = - @<<<<<<<<<< @>>>>>> @>>>>>/s @>>>>> -$stat_name, make_short($stat_val), t($stat_val), perc($stat_val, $questions) -. - -format SAS = - -__ SELECT and Sort _____________________________________________________ -Scan @>>>>>> @>>>>/s %SELECT: @>>>>> -make_short($stats{'Select_scan'}), t($stats{'Select_scan'}), perc($stats{'Select_scan'}, $stats{'Com_select'}) -Range @>>>>>> @>>>>/s @>>>>> -make_short($stats{'Select_range'}), t($stats{'Select_range'}), perc($stats{'Select_range'}, $stats{'Com_select'}) -Full join @>>>>>> @>>>>/s @>>>>> -make_short($stats{'Select_full_join'}), t($stats{'Select_full_join'}), perc($stats{'Select_full_join'}, $stats{'Com_select'}) -Range check @>>>>>> @>>>>/s @>>>>> -make_short($stats{'Select_range_check'}), t($stats{'Select_range_check'}), perc($stats{'Select_range_check'}, $stats{'Com_select'}) -Full rng join @>>>>>> @>>>>/s @>>>>> -make_short($stats{'Select_full_range_join'}), t($stats{'Select_full_range_join'}), perc($stats{'Select_full_range_join'}, $stats{'Com_select'}) -Sort scan @>>>>>> @>>>>/s -make_short($stats{'Sort_scan'}), t($stats{'Sort_scan'}) -Sort range @>>>>>> @>>>>/s -make_short($stats{'Sort_range'}), t($stats{'Sort_range'}) -Sort mrg pass @>>>>>> @>>>>/s -make_short($stats{'Sort_merge_passes'}), t($stats{'Sort_merge_passes'}) -. - -format QCACHE = - -__ Query Cache _________________________________________________________ -Memory usage @>>>>>> of @>>>>>> %Used: @>>>>> -make_short($qc_mem_used, 1), make_short($vars{'query_cache_size'}, 1), perc($qc_mem_used, $vars{'query_cache_size'}) -Block Fragmnt @>>>>>% -perc($stats{'Qcache_free_blocks'}, $stats{'Qcache_total_blocks'}) -Hits @>>>>>> @>>>>/s -make_short($stats{'Qcache_hits'}), t($stats{'Qcache_hits'}) -Inserts @>>>>>> @>>>>/s -make_short($stats{'Qcache_inserts'}), t($stats{'Qcache_inserts'}) -Insrt:Prune @>>>>>>:1 @>>>>/s -make_short($qc_ip_r), t($stats{'Qcache_inserts'} - $stats{'Qcache_lowmem_prunes'}) -Hit:Insert @>>>>>>:1 -$qc_hi_r, t($qc_hi_r) -. - -# Not really the end... -format REPORT_END = - -__ Table Locks _________________________________________________________ -Waited @>>>>>>>> @>>>>>/s %Total: @>>>>> -make_short($stats{'Table_locks_waited'}), t($stats{'Table_locks_waited'}), perc($stats{'Table_locks_waited'}, $stats{'Table_locks_waited'} + $stats{'Table_locks_immediate'}); -Immediate @>>>>>>>> @>>>>>/s -make_short($stats{'Table_locks_immediate'}), t($stats{'Table_locks_immediate'}) - -__ Tables ______________________________________________________________ -Open @>>>>>>>> of @>>> %Cache: @>>>>> -$stats{'Open_tables'}, $vars{'table_cache'}, perc($stats{'Open_tables'}, $vars{'table_cache'}) -Opened @>>>>>>>> @>>>>>/s -make_short($stats{'Opened_tables'}), t($stats{'Opened_tables'}) - -__ Connections _________________________________________________________ -Max used @>>>>>>>> of @>>> %Max: @>>>>> -$stats{'Max_used_connections'}, $vars{'max_connections'}, perc($stats{'Max_used_connections'}, $vars{'max_connections'}) -Total @>>>>>>>> @>>>>>/s -make_short($stats{'Connections'}), t($stats{'Connections'}) - -__ Created Temp ________________________________________________________ -Disk table @>>>>>>>> @>>>>>/s -make_short($stats{'Created_tmp_disk_tables'}), t($stats{'Created_tmp_disk_tables'}) -Table @>>>>>>>> @>>>>>/s Size: @>>>>> -make_short($stats{'Created_tmp_tables'}), t($stats{'Created_tmp_tables'}), make_short($vars{'tmp_table_size'}, 1, 1) -File @>>>>>>>> @>>>>>/s -make_short($stats{'Created_tmp_files'}), t($stats{'Created_tmp_files'}) -. - -format TAB = - -__ Threads _____________________________________________________________ -Running @>>>>>>>> of @>>> -$stats{'Threads_running'}, $stats{'Threads_connected'} -Cached @>>>>>>>> of @>>> %Hit: @>>>>> -$stats{'Threads_cached'}, $vars{'thread_cache_size'}, make_short(100 - perc($stats{'Threads_created'}, $stats{'Connections'})) -Created @>>>>>>>> @>>>>>/s -make_short($stats{'Threads_created'}), t($stats{'Threads_created'}) -Slow @>>>>>>>> @>>>>>/s -$stats{'Slow_launch_threads'}, t($stats{'Slow_launch_threads'}) - -__ Aborted _____________________________________________________________ -Clients @>>>>>>>> @>>>>>/s -make_short($stats{'Aborted_clients'}), t($stats{'Aborted_clients'}) -Connects @>>>>>>>> @>>>>>/s -make_short($stats{'Aborted_connects'}), t($stats{'Aborted_connects'}) - -__ Bytes _______________________________________________________________ -Sent @>>>>>>>> @>>>>>/s -make_short($stats{'Bytes_sent'}), t($stats{'Bytes_sent'}) -Received @>>>>>>>> @>>>>>/s -make_short($stats{'Bytes_received'}), t($stats{'Bytes_received'}) -. - -format IB = - -__ InnoDB Buffer Pool __________________________________________________ -Usage @>>>>>> of @>>>>>> %Used: @>>>>> -make_short($ib_bp_used, 1), make_short($ib_bp_total, 1), perc($ib_bp_used, $ib_bp_total) -Read hit @>>>>>% -$ib_bp_read_ratio; -Pages - Free @>>>>>>>> %Total: @>>>>> -make_short($stats{'Innodb_buffer_pool_pages_free'}), perc($stats{'Innodb_buffer_pool_pages_free'}, $stats{'Innodb_buffer_pool_pages_total'}) - Data @>>>>>>>> @>>>>> %Drty: @>>>>> -make_short($stats{'Innodb_buffer_pool_pages_data'}), perc($stats{'Innodb_buffer_pool_pages_data'}, $stats{'Innodb_buffer_pool_pages_total'}), perc($stats{'Innodb_buffer_pool_pages_dirty'}, $stats{'Innodb_buffer_pool_pages_data'}) - Misc @>>>>>>>> @>>>>> - $stats{'Innodb_buffer_pool_pages_misc'}, perc($stats{'Innodb_buffer_pool_pages_misc'}, $stats{'Innodb_buffer_pool_pages_total'}) - Latched @>>>>>>>> @>>>>> -$stats{'Innodb_buffer_pool_pages_latched'}, perc($stats{'Innodb_buffer_pool_pages_latched'}, $stats{'Innodb_buffer_pool_pages_total'}) -Reads @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_buffer_pool_read_requests'}), t($stats{'Innodb_buffer_pool_read_requests'}) - From file @>>>>>>>> @>>>>>/s @>>>>> -make_short($stats{'Innodb_buffer_pool_reads'}), t($stats{'Innodb_buffer_pool_reads'}), perc($stats{'Innodb_buffer_pool_reads'}, $stats{'Innodb_buffer_pool_read_requests'}) - Ahead Rnd @>>>>>>>> @>>>>>/s -$stats{'Innodb_buffer_pool_read_ahead_rnd'}, t($stats{'Innodb_buffer_pool_read_ahead_rnd'}) - Ahead Sql @>>>>>>>> @>>>>>/s -$stats{'Innodb_buffer_pool_read_ahead_seq'}, t($stats{'Innodb_buffer_pool_read_ahead_seq'}) -Writes @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_buffer_pool_write_requests'}), t($stats{'Innodb_buffer_pool_write_requests'}) -Flushes @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_buffer_pool_pages_flushed'}), t($stats{'Innodb_buffer_pool_pages_flushed'}) -Wait Free @>>>>>>>> @>>>>>/s -$stats{'Innodb_buffer_pool_wait_free'}, t($stats{'Innodb_buffer_pool_wait_free'}) -. - -format IB_LOCK = - -__ InnoDB Lock _________________________________________________________ -Waits @>>>>>>>> @>>>>>/s -$stats{'Innodb_row_lock_waits'}, t($stats{'Innodb_row_lock_waits'}) -Current @>>>>>>>> -$stats{'Innodb_row_lock_current_waits'} -Time acquiring - Total @>>>>>>>> ms -$stats{'Innodb_row_lock_time'} - Average @>>>>>>>> ms -$stats{'Innodb_row_lock_time_avg'} - Max @>>>>>>>> ms -$stats{'Innodb_row_lock_time_max'} -. - -format IB_DPR = - -__ InnoDB Data, Pages, Rows ____________________________________________ -Data - Reads @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_data_reads'}), t($stats{'Innodb_data_reads'}) - Writes @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_data_writes'}), t($stats{'Innodb_data_writes'}) - fsync @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_data_fsyncs'}), t($stats{'Innodb_data_fsyncs'}) - Pending - Reads @>>>>>>>> -$stats{'Innodb_data_pending_reads'}, t($stats{'Innodb_data_pending_reads'}) - Writes @>>>>>>>> -$stats{'Innodb_data_pending_writes'}, t($stats{'Innodb_data_pending_writes'}) - fsync @>>>>>>>> -$stats{'Innodb_data_pending_fsyncs'}, t($stats{'Innodb_data_pending_fsyncs'}) - -Pages - Created @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_pages_created'}), t($stats{'Innodb_pages_created'}) - Read @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_pages_read'}), t($stats{'Innodb_pages_read'}) - Written @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_pages_written'}), t($stats{'Innodb_pages_written'}) - -Rows - Deleted @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_rows_deleted'}), t($stats{'Innodb_rows_deleted'}) - Inserted @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_rows_inserted'}), t($stats{'Innodb_rows_inserted'}) - Read @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_rows_read'}), t($stats{'Innodb_rows_read'}) - Updated @>>>>>>>> @>>>>>/s -make_short($stats{'Innodb_rows_updated'}), t($stats{'Innodb_rows_updated'}) -. diff --git a/storage/xtradb/build/debian/additions/mysqlreport.1 b/storage/xtradb/build/debian/additions/mysqlreport.1 deleted file mode 100644 index 5ae6b9e3b92..00000000000 --- a/storage/xtradb/build/debian/additions/mysqlreport.1 +++ /dev/null @@ -1,180 +0,0 @@ -.TH "mysqlreport" "1" "2.5 2006-09-01 (docrev 2006-05-19)" "Daniel Nichter" "MYSQL" -.SH "NAME" -.LP -mysqlreport \- Makes a friendly report of important MySQL status values -.SH "SYNTAX" -.LP -mysqlreport [\fIoptions\fP] -.SH "DESCRIPTION" -.LP -mysqlreport makes a friendly report of important MySQL status values. Actually, -it makes a friendly report of nearly every status value from SHOW STATUS. -Unlike SHOW STATUS which simply dumps over 100 values to screen in one long -list, mysqlreport interprets and formats the values and presents the basic -values and many more inferred values in a human\-readable format. Numerous -example reports are available at the mysqlreport web page at -http://hackmysql.com/mysqlreport. - -The benefit of mysqlreport is that it allows you to very quickly see a wide -array of performance indicators for your MySQL server which would otherwise -need to be calculated by hand from all the various SHOW STATUS values. For -example, the Index Read Ratio is an important value but it's not present in -SHOW STATUS; it's an inferred value (the ratio of Key_reads to -Key_read_requests). - -This documentation outlines all the command line options in mysqlreport, most -of which control which reports are printed. This document does not address -how to interpret these reports; that topic is covered in the document Guide -To Understanding mysqlreport at http://hackmysql.com/mysqlreportguide. - -.SH "OPTIONS" -Technically, command line options are in the form \-\-option, but \-option works -too. All options can be abbreviated if the abbreviation is unique. For example, -option \-\-host can be abbreviated \-\-ho but not \-\-h because \-\-h is ambiguous: it -could mean \-\-host or \-\-help. - -.LP - -.TP -\fB\-\-help\fR -Output help information and exit. - -.TP -\fB\-\-user USER\fR - -.TP -\fB\-\-password\fR -As of version 2.3 \-\-password can take the password on the -command line like "\-\-password FOO". Using \-\-password -alone without giving a password on the command line -causes mysqlreport to prompt for a password. - -.TP -\fB\-\-host ADDRESS\fR - -.TP -\fB\-\-port PORT\fR - -.TP -\fB\-\-socket SOCKET\fR - -.TP -\fB\-\-no\-mycnf\fR -\-\-no\-mycnf makes mysqlreport not read ~/.my.cnf which it does by default -otherwise. \-\-user and \-\-password always override values from ~/.my.cnf. - -.TP -\fB\-\-dtq\fR -Print Distribution of Total Queries (DTQ) report (under -Total in Questions report). Queries (or Questions) can -be divided into four main areas: DMS (see \-\-dms below), -Com_ (see \-\-com below), COM_QUIT (see COM_QUIT and -Questions at http://hackmysql.com/com_quit), and -Unknown. \-\-dtq lists the number of queries in each of -these areas in descending order. - -.TP -\fB\-\-dms\fR -Print Data Manipulation Statements (DMS) report (under -DMS in Questions report). DMS are those from the MySQL -manual section 13.2. Data Manipulation Statements. -(Currently, mysqlreport considers only SELECT, INSERT, -REPLACE, UPDATE, and DELETE.) Each DMS is listed in -descending order by count. - -.TP -\fB\-\-com N\fR -Print top N number of non\-DMS Com_ status values in -descending order (after DMS in Questions report). If N -is not given, default is 3. Such non\-DMS Com_ values -include Com_change_db, Com_show_tables, Com_rollback, -etc. - -.TP -\fB\-\-sas\fR -Print report for Select_ and Sort_ status values (after -Questions report). See MySQL Select and Sort Status -Variables at http://hackmysql.com/selectandsort. - -.TP -\fB\-\-tab\fR -Print Threads, Aborted, and Bytes status reports (after -Created temp report). As of mysqlreport v2.3 the -Threads report reports on all Threads_ status values. - -.TP -\fB\-\-qcache\fR -Print Query Cache report. -.TP -\fB\-\-all\fR -Equivalent to "\-\-dtq \-\-dms \-\-com 3 \-\-sas \-\-qcache". -(Notice \-\-tab is not invoked by \-\-all.) - -.TP -\fB\-\-infile FILE\fR -Instead of getting SHOW STATUS values from MySQL, read -values from FILE. FILE is often a copy of the output of -SHOW STATUS including formatting characters (|, +, \-). -mysqlreport expects FILE to have the format -" value number " where value is only alpha and -underscore characters (A\-Z and _) and number is a -positive integer. Anything before, between, or after -value and number is ignored. mysqlreport also needs -the following MySQL server variables: version, -table_cache, max_connections, key_buffer_size, -query_cache_size. These values can be specified in -INFILE in the format "name = value" where name is one -of the aforementioned server variables and value is a -positive integer with or without a trailing M and -possible periods (for version). For example, to specify -an 18M key_buffer_size: key_buffer_size = 18M. Or, a -256 table_cache: table_cache = 256. The M implies -Megabytes not million, so 18M means 18,874,368 not -18,000,000. If these server variables are not specified -the following defaults are used (respectively) which -may cause strange values to be reported: 0.0.0, 64, -100, 8M, 0. - -.TP -\fB\-\-outfile FILE\fR -After printing the report to screen, print the report -to FILE too. Internally, mysqlreport always writes the -report to a temp file first: /tmp/mysqlreport.PID on -*nix, c:\mysqlreport.PID on Windows (PID is the -script's process ID). Then it prints the temp file to -screen. Then if \-\-outfile is specified, the temp file -is copied to OUTFILE. After \-\-email (below), the temp -file is deleted. - -.TP -\fB\-\-email ADDRESS\fR -After printing the report to screen, email the report -to ADDRESS. This option requires sendmail in -/usr/sbin/, therefore it does not work on Windows. -/usr/sbin/sendmail can be a sym link to qmail, for -example, or any MTA that emulates sendmail's \-t -command line option and operation. The FROM: field is -"mysqlreport", SUBJECT: is "MySQL status report". - -.TP -\fB\-\-flush\-status\fR -Execute a "FLUSH STATUS;" after generating the reports. -If you do not have permissions in MySQL to do this an -error from DBD::mysql::st will be printed after the -reports. - -.SH "AUTHORS" -.LP -Daniel Nichter - -If mysqlreport breaks, send me a message from -http://hackmysql.com/feedback -with the error. - -.SH "SEE ALSO" -.LP -mytop(1) -.LP -The comprehensive Guide To Understanding mysqlreport at -http://hackmysql.com/mysqlreportguide. - diff --git a/storage/xtradb/build/debian/additions/mysqltest.1 b/storage/xtradb/build/debian/additions/mysqltest.1 deleted file mode 100644 index 3469765fe3b..00000000000 --- a/storage/xtradb/build/debian/additions/mysqltest.1 +++ /dev/null @@ -1,16 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -mysqltest \- Regressiontest program for MySQL. -.SH SYNOPSIS -mysqltest [options] -.SH DESCRIPTION -Runs a test against the mysql server and compares output with a results file. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/pack_isam.1 b/storage/xtradb/build/debian/additions/pack_isam.1 deleted file mode 100644 index cad153eedee..00000000000 --- a/storage/xtradb/build/debian/additions/pack_isam.1 +++ /dev/null @@ -1,19 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -myisampack \- Compresses MySQL database files. -.SH SYNOPSIS -myisampack [options] -.SH DESCRIPTION -Pack a ISAM-table to take much smaller space -Keys are not updated, so you must run isamchk -rq on any table -that has keys after you have compressed it -You should give the .ISM file as the filename argument - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/resolve_stack_dump.1 b/storage/xtradb/build/debian/additions/resolve_stack_dump.1 deleted file mode 100644 index 2a1e2770275..00000000000 --- a/storage/xtradb/build/debian/additions/resolve_stack_dump.1 +++ /dev/null @@ -1,16 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -resolve_stack_dump \- MySQL helper program for reporting bugs. -.SH SYNOPSIS -resolve_stack_dump [options] -.SH DESCRIPTION -Resolve numeric stack strace dump into symbols. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/additions/resolveip.1 b/storage/xtradb/build/debian/additions/resolveip.1 deleted file mode 100644 index 7aa9439394d..00000000000 --- a/storage/xtradb/build/debian/additions/resolveip.1 +++ /dev/null @@ -1,16 +0,0 @@ -.TH mysql 1 "17 March 2003" "MySQL 3.23" "MySQL database" -.SH NAME -resolveip \- MySQL helper program to retrive IP addresses. -.SH SYNOPSIS -resolveip [options] -.SH DESCRIPTION -Get hostname based on IP-address or IP-address based on hostname. - -For more information start the program with '--help'. -.SH "SEE ALSO" -mysql (1), mysqld (1) -.SH AUTHOR -This manpage was written by Christian Hammers . - -MySQL is available at http://www.mysql.com/. -.\" end of man page diff --git a/storage/xtradb/build/debian/changelog b/storage/xtradb/build/debian/changelog deleted file mode 100644 index 6dc9b561634..00000000000 --- a/storage/xtradb/build/debian/changelog +++ /dev/null @@ -1,4186 +0,0 @@ -percona-xtradb-dfsg-5.1 (5.1.36-1) experimental; urgency=low - - [TODO] - * Link libmysqlclient.so to libmysqlclient_r.so to help applications - like Apache where some modules, like libaprutil, want to use the thread - safe library and some, like PHP, do not. As the client library just copies - data between client and server, we do not expect significant performance - losses. (thanks to Stefan Fritsch). Closes: #450535 - - Add the following to libmysqlclient16.links: - usr/lib/libmysqlclient_r.so.16.0.0 usr/lib/libmysqlclient.so.16.0.0 - - * Ex-maintainer upload :) - * New upstream release. - * SECURITY: Upstream fix for "mysql client does not escape strings in - --html mode." (CVE-2008-4456) Closes: #526254 - * Upstream fixes REPEAT() function. Closes: #447028 - * Upstream fixes problems when mixing ORDER and GROUP BY. Closes: #470854 - * There were many innodb fixes in the last two years, probably - also for this unreproducible crash. CLoses: #447713 - * Removed amd64 specific -fPIC compiler option that was introduced - especially for building the NDB cluster module which is no longer - part of this package (thanks to Modestas Vainius). Closes: #508406 - * Put /etc/mysql/conf.d to mysql-server-5.1.dirs (thanks to Alexander - Gerasiov). Closes: #515145 - * Fixed mysql-test suite by adding 50_mysql-test__db_test.dpatch. - It now passes 100% of the tests again. Also Closes: #533999 - * Preinst now prevents Installation if NDB configuration is detected. - * Applied Ubuntu patch that fixes privilege bootstrapping in postinst - (thanks to Mathias Gug). Closes: #535492 - * Applied Ubuntu patch that sets the debconf prio for the root password - question to high and prevents it from being asked on 5.0 -> 5.1 upgrades - (thanks to Mathias Gug). Closes: #535500 - * Removed the check for ISAM tables as the only supported upgrade path is - from lenny's MySQL-5.0. - * Added /etc/mysql/conf.d/mysqld_safe_syslog.cnf which enables mysqld_safe - to pipe all mysqld output into the syslog. The reason for not letting dpkg - handle it via a normal config file change was that my.cnf is usually - heavily tuned by the admin so the setting would go lost too easily. - * Updated mysqlreport to version 3.5 (including two minor patches by me). - - -- Christian Hammers Wed, 01 Jul 2009 20:54:58 +0200 - -mysql-dfsg-5.1 (5.1.34-1) experimental; urgency=low - - * New upstream release. - - -- Norbert Tretkowski Mon, 20 Apr 2009 20:23:10 +0200 - -mysql-dfsg-5.1 (5.1.33-2) experimental; urgency=low - - * Remove no longer active developers from uploaders field. - * Drop workaround for upgrades from MySQL 3.23, not necessary any more. - - -- Norbert Tretkowski Tue, 07 Apr 2009 11:23:25 +0200 - -mysql-dfsg-5.1 (5.1.33-1) experimental; urgency=low - - * New upstream release. - - -- Norbert Tretkowski Thu, 02 Apr 2009 21:12:23 +0200 - -mysql-dfsg-5.1 (5.1.32-1) experimental; urgency=low - - * New upstream release. - - -- Norbert Tretkowski Fri, 06 Mar 2009 18:48:23 +0100 - -mysql-dfsg-5.1 (5.1.31-2) experimental; urgency=low - - * Update SSL certificates, and re-enable SSL related tests when running - the testsuite. - - -- Norbert Tretkowski Tue, 10 Feb 2009 16:08:42 +0100 - -mysql-dfsg-5.1 (5.1.31-1) experimental; urgency=low - - * New upstream release. - - -- Norbert Tretkowski Sun, 08 Feb 2009 17:07:11 +0100 - -mysql-dfsg-5.1 (5.1.30-2) experimental; urgency=low - - * Drop MySQL Cluster support, it's deprecated since 5.1.24-RC. - * Fix FTBFS if build twice in a row. (closes: #487091) - - -- Norbert Tretkowski Fri, 05 Dec 2008 21:04:55 +0100 - -mysql-dfsg-5.1 (5.1.30-1) experimental; urgency=low - - * New upstream release. - - -- Norbert Tretkowski Thu, 27 Nov 2008 09:09:55 +0100 - -mysql-dfsg-5.1 (5.1.29rc-1) experimental; urgency=low - - * New upstream release. - - -- Norbert Tretkowski Mon, 27 Oct 2008 20:00:43 +0100 - -mysql-dfsg-5.1 (5.1.26rc-1) experimental; urgency=low - - * New upstream release. - - -- Norbert Tretkowski Mon, 14 Jul 2008 21:46:59 +0200 - -mysql-dfsg-5.1 (5.1.25rc-1) experimental; urgency=low - - * New upstream release. - - -- Norbert Tretkowski Sat, 21 Jun 2008 13:55:02 +0200 - -mysql-dfsg-5.1 (5.1.24rc-1) experimental; urgency=low - - * New upstream release. - * Ignore errors in testsuite on ia64 and s390. - - -- Norbert Tretkowski Wed, 16 Apr 2008 22:03:44 +0200 - -mysql-dfsg-5.1 (5.1.23rc-1) experimental; urgency=low - - * New upstream release. - - [ Christian Hammers ] - * Add PIC support for NDB libraries on amd64 (thanks to Monty Taylor). - * Add extra information when aborting due to a detected downgrade (thanks to - Raphael Pinson). - * Move libndbclient.so.3 to its own package as it now has a version != 0 - (thanks to Raphael Pinson for reminding me). - - [ Monty Taylor ] - * Remove 85_ndb__staticlib.dpatch since we have a libndbclient package now. - * Add myself to the uploaders so that I don't get complaints about package - signing. - * Add libndbclient-dev package to go with libndbclient3. - - [ Norbert Tretkowski ] - * Update patches: - + 41_scripts__mysql_install_db.sh__no_test.dpatch - * Drop patches: - + 70_upstream_debian__configure.dpatch - + 71_upstream_debian__Makefile.in.dpatch - + 99_TEMP_minmax.dpatch - * Remove Adam Conrad from uploaders on his request. Thanks for your work in - the past! - * Ignore errors in testsuite on amd64 and i386. - - -- Norbert Tretkowski Fri, 29 Feb 2008 10:38:27 +0100 - -mysql-dfsg-5.1 (5.1.22rc-1) experimental; urgency=low - - * New upstream version. - * Let mysql-server-5.1 pre-depend on debconf as it uses it in the preinst. - * Fixed mysql-client-5.1 menu entry for upcoming menu policy 1.4. - - -- Christian Hammers Tue, 02 Oct 2007 22:45:37 +0200 - -mysql-dfsg-5.1 (5.1.21beta-1) experimental; urgency=low - - * My "Greetings from FrOSCon!" release. - * New upstream version. - * libmysqlclient.so.15 has been superseded by libmysqlclient.so.16. - * Renamed libmysqlclient15-dev to libmysqlclient-dev but added an empty - package libmysqlclient15-dev to ease the transition for packages with - a versioned build-dep to libmysqlclient15-dev which is something that - currently does not work with "Provides:". - * Synced with 5.0 branch up to subversion release r909. - * Commented out most of the compile conditionals in the hope that - all architectures can be build the same way. - * Added a lot of new binaries and manpages. - * Switched to plugin based engines. - - -- Christian Hammers Sat, 25 Aug 2007 14:24:40 +0200 - -mysql-dfsg-5.1 (5.1.19beta-1) experimental; urgency=low - - * New upstream release. - - -- Christian Hammers Mon, 11 Jun 2007 23:18:35 +0200 - -mysql-dfsg-5.1 (5.1.16beta-4) experimental; urgency=high - - * Merged with 5.0 r850: - * SECURITY: - In some previous versions mysql_install_db was not idempotent and did - always create passwordless root accounts although it should only on - initial installs (thanks to Olaf van der Spek). Closes: #418672 - * Added check for passwordless root accounts to debian-start. - * As MySQL-5.0 is, at least currently, incompatible with Kernel 2.4 the - installation is aborted for such old kernels. Debian Etch does not - support them anyway according to the release notes but this might be - unexpected and many production servers still have self build ones - installed (thanks to Marc-Christian Petersen). See: #416841 - * Adjusted TeX build-deps to texlive. - * Added innotop. - * Changed maintainer email address to - pkg-mysql-commits@lists.alioth.debian.org - - -- Christian Hammers Thu, 19 Apr 2007 19:29:29 +0200 - -mysql-dfsg-5.1 (5.1.16beta-3) experimental; urgency=low - - * Merged with 5.0 r837: - * Activated the blackhole engine as it's needed for replicating partition - designs (thanks to Cyril SCETBON). - * Fixed segfault on i486 systems without cpuid instruction (thanks to - Lennart Sorensen). Closes: #410474 - * Only use of the non-essential debconf package in postrm if it is - still installed (thanks to Michael Ablassmeier). Closes: #416838 - - -- Christian Hammers Sun, 18 Mar 2007 21:48:11 +0100 - -mysql-dfsg-5.1 (5.1.16beta-2) experimental; urgency=low - - * Merged with 5.0 r818: - * Fixed FTBFS on Sparc introduced with the "make -j" trick in - 5.0.32-8 (thanks to Frank Lichtenheld). Closes: #415026 - - -- Christian Hammers Sun, 18 Mar 2007 21:20:11 +0100 - -mysql-dfsg-5.1 (5.1.16beta-1) experimental; urgency=low - - * New upstream release. - * SECURITY: Using an INFORMATION_SCHEMA table with ORDER BY in a subquery - could cause a server crash (CVE-2007-1420). - * Added temporary patch 90_TEMP_sqlparse-ifdef to avoid build problems. - * Merged with 5.0 r809: - * Updated mysqlreport to latest upstream (and patched --help usage - message and "return if qcache_size==0"). - * Merged with 5.0 r798: - * Adapt MAKE_J to use the -j option with the number of available - processors. (thanks to Raphael Pinson). - * Merged with 5.0 r758: - * Changed minimum required version in dh_makeshlibs to 5.0.27-1 as - 5.0.26 had an ABI breakage in it! - This is the cause for Perl programs crashing with the following error: - Transactions not supported by database at /usr/lib/perl5/DBI.pm line 672 - * Added some more comments to the default my.cnf. - * Added support for /etc/mysql/conf.d/. - * The debian-start script that runs on every server start now first upgrades - the system tables (if neccessary) and then check them as it sometimes did - not work the other way around (e.g. for MediaWiki). The script now uses - mysql_update instead of mysql_update_script as recommended. See: 409780 - - -- Christian Hammers Fri, 2 Mar 2007 01:00:55 +0100 - -mysql-dfsg-5.1 (5.1.15beta-1) experimental; urgency=low - - * New upstream release. - [Monty Taylor] - * Removed patches/25_mysys__default.c - fixed upstream. - * Removed patches/26_client__mysql_upgrade.c - fixed upstream. - * Removed patches/29_scripts__mysqlbug.sh - fixed upstream. - * Removed patches/39_scripts__mysqld_safe.sh__port_dir - fixed upstream. - * Removed patches/42_scripts__mysqldumpslow__slowdir - fixed upstream. - * Removed patches/45_warn-CLI-passwords - fixed upstream. - * Removed patches/89_ndb__records.dpatch - fixed upstream. - * Removed patches/86_ndbapi_tc_selection.dpatch - fixed upstream. - [Christian Hammers] - * Synced with 5.0.32-4. - * mysql-server-5.0 pre-depends on adduser now and has --disabled-login - explicitly added to be on the safe side (thanks to the puiparts team). - Closes: #408362 - * Corrections the terminology regarding NDB in the comments of all config - files and init scripts (thanks to Geert Vanderkelen of MySQL). - - -- Christian Hammers Wed, 7 Feb 2007 11:34:52 -0200 - -mysql-dfsg-5.1 (5.1.14beta-2) experimental; urgency=low - - [Christian Hammers] - * Readded 85_ndb__staticlib.dpatch with slight modifications. - * Backported debian-start scripts from 5.0. - [Monty Taylor] - * Now build-depends on bison. - * Updated to standards 3.7.2. - * Removed references to comp_err. - * build-depend on automake1.9 to match upstream - * Merged runlevel changes from 5.0. - * Added 26_client__mysql_upgrade.c.dpatch to fix a segfault in mysql_upgrade - when using a password. It's been fixed upstream in 5.1.15. - * Moved BDB check to sanity_checks() and added a note about deprecation. - * Use my_print_defaults instead of mysqld --print-defaults - * Changed NDB Data and Management node startup seqence. Prevented both - from restarting on upgrade to address rolling upgrade issues. - * Added a "start-initial" option to the Data Node init script to support - initial node starts. - * Added 86_ndbapi_tc_selection.dpatch to fix a bug that causes a segfault - when using the NdbApi. http://bugs.mysql.com/bug.php?id=24914 - Fixed in 5.1.15 - * Added 89_ndb__records.dpatch to fix - http://bugs.mysql.com/bug.php?id=25567, which causes a table scan per - table per query. - - -- Christian Hammers Wed, 31 Jan 2007 01:17:35 +0100 - -mysql-dfsg-5.1 (5.1.14beta-1) experimental; urgency=low - - * New upstream. - * Removed references to mysql_explain_log - * Changed context for patch to mysqld_multi.1 - * Removed 70_kfreebsd.dpatch - applied to upstream - * Removed 87_ps_Hurd - applied to upstream - * Replaced --without-readline to --with-libedit to configure options, as - --without-readline doesn't seem to do the right thing anymore. - - -- Monty Taylor Wed, 10 Jan 2007 12:59:55 -0800 - -mysql-dfsg-5.1 (5.1.11beta-1) experimental; urgency=low - - * Starting new 5.1 branch! - * FIXME: Following patch couldn't be applied: - ## 85_ndb__staticlib.dpatch by - * FIXME: Following patch couldn't be applied: - ## 86_PATH_MAX.dpatch - - -- Christian Hammers Sat, 29 Jul 2006 11:35:42 +0200 - -mysql-dfsg-5.0 (5.0.51a-19) UNRELEASED; urgency=low - - * New patch 50_fix_mysqldump2.dpatch from 5.0.60 to fix dumping databases - from mysql 4.0 server. (closes: #507789) - * Don't create a guest account during bootstrap. (closes: #463704) - - -- Norbert Tretkowski Thu, 04 Dec 2008 23:07:19 +0100 - -mysql-dfsg-5.0 (5.0.51a-18) testing-proposed-updates; urgency=high - - * SECURITY: - Fix for CVE-2008-4098: Inadequate validation of paths used in DATA - DIRECTORY and INDEX DIRECTORY clauses of CREATE TABLE statements enabled - attackers to write to tables in other databases to which they could not - ordinarily have access. - - -- Devin Carraway Tue, 25 Nov 2008 05:38:45 +0000 - -mysql-dfsg-5.0 (5.0.51a-17) testing-proposed-updates; urgency=low - - * Don't use commented out passwords from debian.cnf. (closes: #453820) - * Update watch file to recognize releases > 5.0.45. - - -- Norbert Tretkowski Sun, 02 Nov 2008 13:31:32 +0100 - -mysql-dfsg-5.0 (5.0.51a-16) unstable; urgency=low - - * New patch 60_rpl_test_failure.dpatch from 5.0.54 to fix a race condition - with the rpl_packet test in some cases. (closes: #501413) - - -- Norbert Tretkowski Thu, 09 Oct 2008 08:50:43 +0200 - -mysql-dfsg-5.0 (5.0.51a-15) unstable; urgency=high - - * SECURITY: - Fix for CVE-2008-3963: An empty bit-string literal (b'') caused a server - crash. Now the value is parsed as an empty bit value (which is treated as - an empty string in string context or 0 in numeric context). - (closes: #498362) - - -- Norbert Tretkowski Sun, 14 Sep 2008 18:27:46 +0200 - -mysql-dfsg-5.0 (5.0.51a-14) unstable; urgency=low - - * Update debconf translations: - - Swedish, from Martin Bagge. (closes: #491688) - - Netherlands, from Thijs Kinkhorst. (closes: #492723) - - -- Norbert Tretkowski Sun, 07 Sep 2008 20:18:31 +0200 - -mysql-dfsg-5.0 (5.0.51a-13) unstable; urgency=medium - - * New patch 59_fix_relay_logs_corruption.dpatch from 5.0.56 to fix - corruption in relay logs. (closes: #463515) - - -- Norbert Tretkowski Wed, 03 Sep 2008 09:13:46 +0200 - -mysql-dfsg-5.0 (5.0.51a-12) unstable; urgency=low - - * Disable rpl_ndb_innodb_trans test when running the testsuite, fails - randomly on i386. (closes: #494238) - - -- Norbert Tretkowski Sat, 09 Aug 2008 15:56:45 +0200 - -mysql-dfsg-5.0 (5.0.51a-11) unstable; urgency=low - - * Disable innodb_handler test when running the testsuite, fails randomly - on s390. (closes: #491363) - - -- Norbert Tretkowski Wed, 23 Jul 2008 08:34:51 +0200 - -mysql-dfsg-5.0 (5.0.51a-10) unstable; urgency=high - - * Merge testing-security upload to finally fix CVE-2008-2079, thanks to - Devin Carraway and Steffen Joeris. (closes: #480292) - * New patch 58_disable-ndb-backup-print.dpatch from 5.0.54 to disable - ndb_backup_print, ndb_alter_table and ndb_replace tests when running the - testsuite. (closes: #474893) - * Reenable error handling in testsuite on i386, disabling it was just a - workaround for the problem which is now fixed with the above patch. - * Update debconf translations: - - Vietnamese, from Clytie Siddall. (closes: #486443) - - Spanish, from Javier Fernández-Sanguino Peña. (closes: #488740) - - Slovak, from helix84. (closes: #489266) - * Make lintian happy: - - Fix build-dependency on -1 revision. - - Fix deprecated chown usage. - - Fix spelling error in description. - - -- Norbert Tretkowski Tue, 15 Jul 2008 19:37:35 +0200 - -mysql-dfsg-5.0 (5.0.51a-9+lenny2) testing-security; urgency=high - - * Non-maintainer upload by the security team. - * Correct error number in symlink.test to avoid FTBFS on some archs. - - -- Steffen Joeris Sun, 13 Jul 2008 11:44:57 +0000 - -mysql-dfsg-5.0 (5.0.51a-9+lenny1) testing-security; urgency=high - - * Non-maintainer upload by the security team. - * Correct and expand 92_SECURITY_CVE-2008-2079.dpatch to cover all symlinks - and check the output of fn_format(). (closes: #480292) - Fixes: CVE-2008-2079 - - -- Steffen Joeris Sat, 12 Jul 2008 05:30:39 +0000 - -mysql-dfsg-5.0 (5.0.51a-9) unstable; urgency=low - - * Ignore errors in testsuite on i386. (workaround for #474893) - - -- Norbert Tretkowski Wed, 25 Jun 2008 15:07:03 +0200 - -mysql-dfsg-5.0 (5.0.51a-8) unstable; urgency=low - - * New patch 80_fix_user_setup_on_localhost.dpatch from Daniel Hahler to fix - a duplicate key error when install MySQL server on a host with hostname - localhost. (closes: #478319) - * Really fix build on non-linux systems, this time without producing a build - error on some architectures. (closes: #485971) - * Update debconf translations: - - French, from Christian Perrier. (closes: #478553) - - German, from Alwin Meschede. (closes: #478672) - - Italian, from Luca Monducci. (closes: #479363) - - Czech, from Miroslav Kure. (closes: #480924) - - Galician, from Jacobo Tarrio. (closes: #480965) - - Basque, from Piarres Beobide. (closes: #481840) - - Swedish, from Martin Bagge. (closes: #482466, #486307) - - Turkish, from Mert Dirik. (closes: #484704) - - Russian, from Yuri Kozlov. (closes: #486149) - - Finnish, from Esko Arajärvi. (closes: #486554) - - Portuguese, from Miguel Figueiredo. (closes: #486709) - - Romanian, from Eddy PetriÈ™or. (closes: #486944) - - Japanese, from Hideki Yamane. (closes: #487270) - - -- Norbert Tretkowski Sat, 21 Jun 2008 19:20:48 +0200 - -mysql-dfsg-5.0 (5.0.51a-7) unstable; urgency=high - - [ Norbert Tretkowski ] - * SECURITY: - Fix for CVE-2008-2079: It was possible to circumvent privileges through - the creation of MyISAM tables employing the DATA DIRECTORY and INDEX - DIRECTORY options to overwrite existing table files in the MySQL data - directory. Use of the MySQL data directory in DATA DIRECTORY and INDEX - DIRECTORY is now disallowed. Patch from openSUSE 11.0, thanks to Michal - Marek. (closes: #480292) - * Fix build on non-linux systems, like hurd-i386. (closes: #480362) - * Include symlinks for mysqlcheck. (closes: #480647) - - [ Monty Taylor ] - * Remove ndb_cpcd, as it is only for the NDB test suite and not useful as a - public program. - * Fix debian-start.inc.sh for table names with characters needing quotes. - Thanks Felix Rublack! (closes: #480525, #481154, #481303, #484012) - * Delete mysql-common.README.Debian. Nothing in it was relevant, and the - useful information is in mysql-server anyway. (closes: #480940) - * Remove a spurious HOME= in logrotate script. - - -- Norbert Tretkowski Thu, 05 Jun 2008 11:49:45 +0200 - -mysql-dfsg-5.0 (5.0.51a-6) unstable; urgency=low - - * Fix debian-start.inc.sh to not print the row counts of the tables - queried. (closes: #478256, #479697) - - -- Monty Taylor Wed, 14 May 2008 00:47:46 -0700 - -mysql-dfsg-5.0 (5.0.51a-5) unstable; urgency=medium - - * New patch 57_fix_mysql_replication.dpatch from 5.0.54 to fix directory for - relay logs when using replication. - - -- Norbert Tretkowski Sun, 27 Apr 2008 13:55:04 +0200 - -mysql-dfsg-5.0 (5.0.51a-4) unstable; urgency=low - - [ Monty Taylor ] - * Remove build of ndb docs, since they are not installed. Removed build deps - on TeX and doxygen since that's all they were there for. - * Replace script in check_for_crashed_tables with a myisam-recover option - and a script to trigger a check of those tables. (thanks HarrisonF and - kolbe) - * Replace direct calls to test suite with calls to the make targets used by - the MySQL build and qa teams for releases. - * Add --skip-ndbcluster to the postinst bootstrap command. It's really a - workaround for a bug in 5.1, but it's probably a good idea anyway since we - certainly don't need cluster to spin up, and if people have enabled - cluster in their my.cnf file, there could be postinst issues if cluster - isn't running. - * Remove reference to configure options that no longer exist. - * Add myself to uploaders. - - [ Norbert Tretkowski ] - * New patch 56_fix_order_by.dpatch from Ubuntu to fix ORDER BY not working - with GROUP BY. (closes: #471737) - * Add note about filename extensions in the /etc/mysql/conf.d/ directory in - my.cnf. (closes: #461759) - * Confirm password on install, patch from Nicolas Valcárcel. - (closes: #471887) - * Remove Adam Conrad from uploaders on his request. Thanks for your work in - the past! - * Use lsb_release to detect distribution. - - -- Norbert Tretkowski Sat, 05 Apr 2008 21:51:43 +0200 - -mysql-dfsg-5.0 (5.0.51a-3) unstable; urgency=low - - * Disable patch 60_raise-max-keylength.dpatch in default build, but still - ship it in the source package. - - -- Norbert Tretkowski Sun, 17 Feb 2008 18:54:42 +0100 - -mysql-dfsg-5.0 (5.0.51a-2) unstable; urgency=low - - * Replace 54_ssl-client-support.dpatch added in 5.0.51-2 with patch from - upstream. - * Ignore errors in testsuite on powerpc. - - -- Norbert Tretkowski Sun, 17 Feb 2008 12:42:58 +0100 - -mysql-dfsg-5.0 (5.0.51a-1) unstable; urgency=low - - [ Norbert Tretkowski ] - * New upstream security hotfix release. Low priority upload anyway because - 5.0.51-3 already contained all security fixes. - * Remove patches: - + debian/patches/51_mysqlcheck-result.dpatch - + debian/patches/92_SECURITY_CVE-2007-6303.dpatch - + debian/patches/93_SECURITY_CVE-2007-6304.dpatch - + debian/patches/94_SECURITY_CVE-2008-0226+0227.dpatch - * Add recommendation on libhtml-template-perl to -server package, used by - ndb_size. (closes: #462265) - * New patch 60_raise-max-keylength.dpatch to raise the maximum key length to - 4005 bytes or 1335 UTF-8 characters. (closes: #463137) - * New patch 51_sort-order.dpatch from 5.0.52 to fix incorrect order when - using range conditions on 2 tables or more. - * Support DEB_BUILD_OPTIONS option 'nocheck' to skip tests. - * Update mysqlreport to 3.4a release. - - [ Luk Claes ] - * Updated Japanese debconf translation. (closes: #462158) - - -- Norbert Tretkowski Wed, 06 Feb 2008 11:57:45 +0100 - -mysql-dfsg-5.0 (5.0.51-3) unstable; urgency=high - - * SECURITY: - Fix for CVE-2008-0226 and CVE-2008-0227: Three vulnerabilities in yaSSL - versions 1.7.5 and earlier were discovered that could lead to a server - crash or execution of unauthorized code. The exploit requires a server - with yaSSL enabled and TCP/IP connections enabled, but does not require - valid MySQL account credentials. The exploit does not apply to OpenSSL. - (closes: #460873) - * Fix LSB header in init scripts (patch from Petter Reinholdtsen). - (closes: #458798) - * Run testsuite on all archs, but ignore errors on alpha, arm, armel, hppa, - mipsel and sparc. (closes: #460402) - - -- Norbert Tretkowski Wed, 23 Jan 2008 11:37:11 +0100 - -mysql-dfsg-5.0 (5.0.51-2) unstable; urgency=low - - [ Monty Taylor ] - * Added --with-system-type to set the version_compile_os field. - * Cleaned up some lintian warnings. - * Removed 43_scripts__mysql_update__password.dpatch since we don't use - mysql_upgrade_shell anymore and use mysql_upgrade instead. - * Removed 88_mctype_attrib.dpatch, http://bugs.mysql.com/bug.php?id=25118 is - closed with http://lists.mysql.com/commits/24337 - * Added mysql-community/mysql-enterprise virtual packages in provides and - conflicts to ease transitions between versions. - - [ Norbert Tretkowski ] - * Add -fPIC to CFLAGS to allow other packages to be built against - libmysqld.a on amd64. (closes: #457915) - * New patch 55_testsuite-2008.dpatch to fix FTBFS in testsuite. - (closes: #458695) - * New patch 54_ssl-client-support.dpatch to fix SSL client support. - * Don't run testsuite on alpha, arm, hppa, mipsel and sparc. - - -- Norbert Tretkowski Wed, 02 Jan 2008 18:40:04 +0100 - -mysql-dfsg-5.0 (5.0.51-1) unstable; urgency=low - - * New upstream release. - + Fix a crash in mysql_client_test due to gcc 4.x optimizations. - (closes: #452558) - * Update patches: - + debian/patches/41_scripts__mysql_install_db.sh__no_test.dpatch - + debian/patches/89_ndb__staticlib.dpatch - * Run testsuite after build. - * Re-add manpages, they are licensed under GPL now and redistribution is - permitted. - * Drop linux-libc-dev build-dependency, it's now being pulled by libc-dev - which is build-essential. (closes: #431018) - * Remove old optimizations for MySQL 3.23.x, they are no longer required. - (closes: #436552) - * Don't fail when upgrading mysql-common if $datadir is empty or not defined - (patch from Edward Allcutt). (closes: #453127) - * New patch from 5.0.52 to fix mysqldump because 'null' is shown as type of - fields for view with bad definer. (closes: #454227) - * New patch from 5.0.52 to fix mysqlcheck test result. - * New patch from 5.0.52 to fix wrong optimization in ndb code when building - with gcc 4.2.x. - * New patch from 5.0.54 to fix wrong number output due to integer overflow - when building with gcc 4.2.x. - * New Finnish debconf translation from Esko Arajärvi. (closes: #448776) - * Update Basque debconf translation from Aitor Ibañez. (closes: #456193) - * Add Vcs-* and Homepage fields to source stanza in control file. - * Update mysqlreport to 3.2 release. - * Let mysql-server-5.0 pre-depend on debconf, because it's preinst is using - it. - * Drop menu item for innotop. - - -- Norbert Tretkowski Fri, 14 Dec 2007 09:59:36 +0100 - -mysql-dfsg-5.0 (5.0.45-5) unstable; urgency=high - - * SECURITY: - Fix for CVE-2007-6303: ALTER VIEW retained the original DEFINER value, - even when altered by another user, which could allow that user to gain the - access rights of the view. Now ALTER VIEW is allowed only to the original - definer or users with the SUPER privilege. (closes: #455737) - * SECURITY: - Fix for CVE-2007-6304: When using a FEDERATED table, the local server can - be forced to crash if the remote server returns a result with fewer columns - than expected. - - -- Norbert Tretkowski Wed, 12 Dec 2007 20:23:43 +0100 - -mysql-dfsg-5.0 (5.0.45-4) unstable; urgency=high - - * SECURITY: - Fix for CVE-2007-5969: Using RENAME TABLE against a table with explicit - DATA DIRECTORY and INDEX DIRECTORY options can be used to overwrite system - table information by replacing the file to which the symlink points. - (closes: #455010) - - -- Norbert Tretkowski Sun, 09 Dec 2007 12:29:54 +0100 - -mysql-dfsg-5.0 (5.0.45-3) unstable; urgency=high - - * SECURITY: - Fix for CVE-2007-5925: The convert_search_mode_to_innobase function in - ha_innodb.cc in the InnoDB engine in MySQL 5.1.23-BK and earlier allows - remote authenticated users to cause a denial of service (database crash) - via a certain CONTAINS operation on an indexed column, which triggers an - assertion error. (closes: #451235) - - -- Norbert Tretkowski Thu, 15 Nov 2007 18:40:11 +0100 - -mysql-dfsg-5.0 (5.0.45-2) unstable; urgency=low - - * Package is now team-maintained. (closes: #421026) - - [ Sean Finney ] - * New/updated debconf translations: - - Spanish, from Javier Fernández-Sanguino Peña (closes: #426442). - - German, from Alwin Meschede (closes: #426545). - - Danish, from Claus Hindsgaul (closes: #426783). - - French, from Christian Perrier (closes: #430944). - * Add Recommends on libterm-readkey-perl for mysql-client-5.0 package, used - by mysqlreport add-on to mask password entry (closes: #438375). - - [ Norbert Tretkowski ] - * Add myself to uploaders. - * Suggest usage of an update statement on the user table to change the mysql - root user password instead using mysqladmin, to catch all root users from - all hosts. (closes: #435744) - * Remove informations about a crash in the server during flush-logs when - having expire_logs_days enabled but log-bin not, this bug was fixed in - 5.0.32 already. (closes: #368547) - * Disable log_bin option in default config file and add a note to the NEWS - file. (closes: #349661) - * Fix FTBFS if build twice in a row. (closes: #442684) - * Remove check for buggy options from init script. - * Update innotop to 1.6.0 release. - * Add mysqlreport and innotop to mysql-client description. - * Use shorter server version string. - - -- Norbert Tretkowski Wed, 14 Nov 2007 20:00:06 +0100 - -mysql-dfsg-5.0 (5.0.45-1) unstable; urgency=low - - * New upstream release. - - [sean finney] - * removed patches that are incorporated into the latest release: - - 70_cpuid_on_i486.dpatch - - 91_SECURITY_CVE-2007-2691_alter-drop - * new patch 90_upstreamdebiandir.dpatch to keep a few lingering references - to the upstream ./debian dir out of the build, at least until we find - a nice way to collaborate on sharing the directory. - * updated CRUFT list to fix double-build breakage (closes: #424590). - * add conditional build-deps for linux-libc-dev to fix FTBFS for - non-linux arch's (closes: #431018). - * added notes to my.cnf and README.Debian about setting tmpdir when - configuring a replication slave. thanks to Rudy Gevaert for pointing - this out (closes: #431825). - - -- sean finney Tue, 17 Jul 2007 23:50:33 +0200 - -mysql-dfsg-5.0 (5.0.41a-1) unstable; urgency=high - - [sean finney] - * SECURITY: - Fix for CVE-2007-2691: DROP/RENAME TABLE statements (closes: #424778). - [Christian Hammers] - * Removed all manpages from the source (therefore the "41a") as they - are not licensed under the GPL and redistribution is not permitted - (thanks to Mathias Gug). Closes: #430018 - * Added linux-libc-dev to the build-depends as else an illegal dependency to - asm/atomic.h is generated in /usr/include/mysql/my_global.h. Closes: 424276 - [Christian Perrier] - * Debconf templates and debian/control reviewed by the debian-l10n- - english team as part of the Smith review project. Closes: #419974 - * Debconf translation updates: - - French. Closes: #422187 - - Galician. Closes: #420118 - - Italian. Closes: #421349 - - Brazilian Portuguese. Closes: #421516 - - Arabic. Closes: #421751 - - Czech. Closes: #421766 - - Portuguese. Closes: #422428 - - -- Christian Hammers Sun, 24 Jun 2007 21:12:42 +0200 - -mysql-dfsg-5.0 (5.0.41-2) unstable; urgency=low - - * the previous "translation changes" inadvertently introduced unrelated - changes in the package control file. - - -- sean finney Sun, 13 May 2007 12:32:45 +0200 - -mysql-dfsg-5.0 (5.0.41-1) unstable; urgency=low - - * New upstream release - [sean finney] - * Bump the priority of the debconf prompt for the root password to high, to - ensure the question shows up in a default installation (closes: #418672). - * Debconf templates and debian/control reviewed by the debian-l10n- - english team as part of the Smith review project. Closes: #419974 - * Debconf translation updates: - - French. Closes: #422187 - - Galician. Closes: #420118 - - Italian. Closes: #421349 - - Brazilian Portuguese. Closes: #421516 - - Arabic. Closes: #421751 - - Czech. Closes: #421766 - - Portuguese. Closes: #422428 - * massaged the local PATH_MAX patch. - * removed temp sql parsing patch which has been incorporated upstream - * upstream no longer includes the mysql_create_system_tables command, - so removed our local patches for it. - * the following issues may have been fixed in a previous version of - mysql-server-5.0, but the exact version is not clear so they will be - marked as fixed in this version. - * lots of NDB-related fixes, including those related to problems with - AUTO_INCREMENT (closes: #310878). - * fix for "connections remaining in sleep state" (closes: #318011). - * fix for "denies queries randomly" (closes: #399602). - * problems indexing on char() binary fields were ISAM specific, which is - no longer supported (closes: #326698). - * fix for problems with "complicated joins" (closes: 348682). - * fix for problems with "flushing logs, server crash" (closes: #348682). - * fix for AUTO_INCREMENT and duplicate keys (closes: #416145). - * fix for "DROP FUNCTIONS doesn't work" (closes: #290670). - - -- sean finney Sat, 12 May 2007 12:10:20 +0200 - -mysql-dfsg-5.0 (5.0.38-3) unstable; urgency=low - - * Added innotop. - * Changed maintainer email address to - pkg-mysql-commits@lists.alioth.debian.org - - -- Christian Hammers Thu, 19 Apr 2007 19:21:15 +0200 - -mysql-dfsg-5.0 (5.0.38-2) unstable; urgency=high - - * SECURITY: - In some previous versions mysql_install_db was not idempotent and did - always create passwordless root accounts although it should only on - initial installs (thanks to Olaf van der Spek). Closes: #418672 - * Added check for passwordless root accounts to debian-start. - * As MySQL-5.0 is, at least currently, incompatible with Kernel 2.4 the - installation is aborted for such old kernels. Debian Etch does not support - them anyway according to the release notes but this might be unexpected - and many production servers still have self build ones installed (thanks - to Marc-Christian Petersen). See: #416841 - * Adjusted TeX build-deps to texlive. - - -- Christian Hammers Tue, 17 Apr 2007 01:00:41 +0200 - -mysql-dfsg-5.0 (5.0.38-1) unstable; urgency=low - - * New upstream release. - * Activated the blackhole engine as it's needed for replicating partition - designs (thanks to Cyril SCETBON). - * Fixed segfault on i486 systems without cpuid instruction (thanks to - Lennart Sorensen). Closes: #410474 - * Only use of the non-essential debconf package in postrm if it is still - installed (thanks to Michael Ablassmeier). Closes: #416838 - - -- Christian Hammers Thu, 5 Apr 2007 22:43:41 +0200 - -mysql-dfsg-5.0 (5.0.36-1) unstable; urgency=low - - * New upstream release. - Closes: #400460, #408159, #408533 - - -- Christian Hammers Thu, 22 Mar 2007 22:16:31 +0100 - -mysql-dfsg-5.0 (5.0.32-10) unstable; urgency=high - - * Really fixed FTBFS on Sparc introduced with the "make -j" trick in - 5.0.32-8 (thanks to Frank Lichtenheld). Closes: #415026 - - -- Christian Hammers Sun, 18 Mar 2007 20:52:33 +0100 - -mysql-dfsg-5.0 (5.0.32-9) unstable; urgency=high - - * Fixed FTBFS on Sparc introduced with the "make -j" trick in 5.0.32-8 - (thanks to Frank Lichtenheld). Closes: #415026 - - -- Christian Hammers Tue, 15 Mar 2007 18:55:42 +0100 - -mysql-dfsg-5.0 (5.0.32-8) unstable; urgency=high - - [Sean Finney] - * SECURITY: - - CVE-2007-1420: Single Row Subselect DoS. Specially crafted subselect - queries could crash the mysql server. Patch backported from upstream - changeset 19685 (46_CVE-2007-1420_subselect_dos.dpatch) - closes: #414790. - [Christian Hammers] - * Adapt MAKE_J to use the -j option with the number of available processors. - (thanks to Raphael Pinson). - * Updated mysqlreport to latest upstream (and patched --help usage message - and "return if qcache_size==0"). - - -- sean finney Wed, 14 Mar 2007 20:19:08 +0100 - -mysql-dfsg-5.0 (5.0.32-7) unstable; urgency=low - - * Updated French Debconf translation (thanks to Christian Perrier). - Closes: #411330 - * Updated Danish Debconf translation (thanks to Claus Hindsgaul). - Closes: #411328 - * Updated Portuguese Debconf translation (thanks to "Traduz"). - Closes: #411339 - * Updated Czech Debconf translation (thanks to Miroslav Kure). - Closes: #411341 - * Added Norwegian Debconf translation (thanks to Bjorn Steensrud). - Closes: #411345 - * Updated Spanish Debconf translation (thanks to Javier Fernandez-Sanguino - Pena). Closes: #411347 - * Updated Japanese Debconf translation (thanks to Hideki Yamane). - Closes: #411368 - * Updated Swedish Debconf translation (thanks to Andreas Henriksson). - Closes: #411370 - * Updated Italian Debconf translation (thanks to Luca Monducci). - Closes: #411377 - * Updated Galician Debconf translation (thanks to Jacobo Tarrio). - Closes: #411379 - * Updated Russian Debconf translation (thanks to Yuriy Talakan). - Closes: #411442 - * Updated Basque Debconf translation (thanks to Piarres Beobide). - Closes: #411457 - * Updated German Debconf translation (thanks to Alwin Meschede). - Closes: #411480 - * Updated Dutch Debconf translation (thanks to Thijs Kinkhorst). - * Updated Brazilian Portuguese translation (thanks to Andre Luis Lopes). - Closes: #411536 - * Updated Romanian Debconf translation (thanks to Stan Ioan-Eugen). - Closes: #411764 - - -- Christian Hammers Fri, 16 Feb 2007 23:20:42 +0100 - -mysql-dfsg-5.0 (5.0.32-6) unstable; urgency=low - - * Changed wording in Debconf templates to better fit to the graphical - interface (thanks to Frank Kuester). Closes: #411165 - * Lintian suggested style changes to some other Debconf questions. - * Removed accidently stdout output from init script. - - -- Christian Hammers Fri, 16 Feb 2007 20:29:18 +0100 - -mysql-dfsg-5.0 (5.0.32-5) unstable; urgency=medium - - * Backported upstream patch for a bug that crashed the server when using - certain join/group/limit combinations. - Users of the Joomla CMS seemed to be affected by this. Closes: #403721 - * The debian-start script that runs on every server start now first upgrades - the system tables (if neccessary) and then check them as it sometimes did - not work the other way around (e.g. for MediaWiki). The script now uses - mysql_update instead of mysql_update_script as recommended. Closes: 409780 - * Remove the Debconf generated config file in postrm. - - -- Christian Hammers Thu, 15 Feb 2007 04:47:04 +0100 - -mysql-dfsg-5.0 (5.0.32-4) unstable; urgency=high - - [Christian Hammers] - * Changed minimum required version in dh_makeshlibs to 5.0.27-1 as - 5.0.26 had an ABI breakage in it! - This is the cause for Perl programs crashing with the following error: - "Transactions not supported by database at /usr/lib/perl5/DBI.pm line 672" - * The old_passwords setting that is set according to a Debconf question is - now written to /etc/mysql/conf.d/old_passwords.cnf instead directly to the - conffile /etc/mysql/my.cnf which would be fobidden by policy (thanks to - Robert Bihlmeyer). Closes: #409750 - * Added some more comments to the default my.cnf. - [Monty Taylor] - * Added bison to build dependencies. - * Added a "start-initial" option to the Data Node init script to support - initial node starts. - * Changed NDB Data and Management node startup seqence. Prevented both from - restarting on upgrade to address rolling upgrade issues. - * Updated build-depends to depend on automake1.9 instead of automake1.8 - to match what upstream uses. - - -- Christian Hammers Wed, 31 Jan 2007 01:14:09 +0100 - -mysql-dfsg-5.0 (5.0.32-3) unstable; urgency=high - - * mysql-server-5.0 pre-depends on adduser now and has --disabled-login - explicitly added to be on the safe side (thanks to the puiparts team). - Closes: #408362 - * Corrections the terminology regarding NDB in the comments of all config - files and init scripts (thanks to Geert Vanderkelen of MySQL). - * Updated Swedish Debconf translation (thanks to Andreas Henriksson). - Closes: #407859 - * Updated Czech Debconf translation (thanks to Miroslav Kure). - Closes: #407809 - - -- Christian Hammers Thu, 11 Jan 2007 11:18:47 +0100 - -mysql-dfsg-5.0 (5.0.32-2) unstable; urgency=high - - * The last upload suffered from a regression that made NDB totally - unusable and caused a dependency to libmysqlclient15-dev in the - mysql-server-5.0 package. The relevant 85_* patch was re-added again. - Closes: #406435 - * Added lintian-overrides for an error that does not affect our packages. - There are now only warnings and not errors left. - - -- Christian Hammers Tue, 9 Jan 2007 23:55:10 +0100 - -mysql-dfsg-5.0 (5.0.32-1) unstable; urgency=high - - * New upstream version. - * SECURITY: mysql_fix_privilege_tables.sql altered the - table_privs.table_priv column to contain too few privileges, causing - loss of the CREATE VIEW and SHOW VIEW privileges. (MySQL Bug#20589) - * SECURITY (DoS): ALTER TABLE statements that performed both RENAME TO - and {ENABLE|DISABLE} KEYS operations caused a server crash. (MySQL - Bug#24089) - * SECURITY (DoS): LAST_DAY('0000-00-00') could cause a server crash. - (MySQL Bug#23653) - * SECURITY (DoS): Using EXPLAIN caused a server crash for queries that - selected from INFORMATION_SCHEMA in a subquery in the FROM clause. - (MySQL Bug#22413) - * SECURITY (DoS): Invalidating the query cache (e.g. when using stored procedures) - caused a server crash for INSERT INTO ... SELECT statements that - selected from a view. (MySQL Bug#20045) - * Using mysql_upgrade with a password crashed the server. Closes: #406229 - * yaSSL crashed on pre-Pentium Intel and Cyrix CPUs. (MySQL Bug#21765) - Closes: #383759 - * Lots of small fixes to the NDB cluster storage engine. - * Updated Japanese Debconf template (thanks to Hideki Yamane). - Closes: #405793 - * Fixed comment regarding "mycheck" in debian-start (thanks to - Enrico Zini). Closes: #405787 - - -- Christian Hammers Sat, 6 Jan 2007 14:26:20 +0100 - -mysql-dfsg-5.0 (5.0.30-3) unstable; urgency=low - - * Updated Brazilian Debconf translation (thanks to Andre Luis Lopes). - Closes: #403821 - * Added Romanian Debconf translation (thanks to Stan Ioan-Eugen). - Closes: #403943 - * Updated Spanish Debconf translation (thanks to Javier Fernandez-Sanguino - Pena). Closes: #404084 - * Updated Galician Debconf translation (thanks to Jacobo Tarrio). - Closes: #404318 - * Updated Dutch Debconf translation (thanks to Vincent Zweije). - Closes: #404566 - * Updated Danish Debconf translation (thanks to Claus Hindsgaul). - Closes: #405018 - - -- Christian Hammers Thu, 21 Dec 2006 21:35:09 +0100 - -mysql-dfsg-5.0 (5.0.30-2) unstable; urgency=high - - * Fixed upstream regression in header files that lead to FTBFS for - mysql-admin, mysql-query-browser and probably other pacakges. - (thanks to Andreas Henriksson). Closes: #403081, #403082 - * Fixed some upstream scripts by replacing /etc by /etc/mysql (thanks to - Julien Antony). Closes: #401083 - * Updated French Debconf translation (thanks to Christian Perrier). - Closes: #401434 - * Added Spanish Debconf translation (thanks to Javier Fernandez-Sanguino - Pena). Closes: #401953 - * Marked a Debconf question that is just a dummy and only internally - used as not-needing-translation. Closes: #403163 - * Fixed mysqlslowdump patch to not remove the usage() function (thanks - to Monty Tailor). - - -- Christian Hammers Sun, 3 Dec 2006 19:20:10 +0100 - -mysql-dfsg-5.0 (5.0.30-1) unstable; urgency=low - - * New upstream version (switch to the MySQL Enterprise branch). - * Upstream bugfix for the Innodb performance bug: - "Very poor performance with multiple queries running - concurrently (Bug#15815)". - * Upstream bugfix for a possible server crash: - "Selecting from a MERGE table could result in a server crash if the - underlying tables had fewer indexes than the MERGE table itself - (Bug#22937)" - * Upstream bugfies for *lot* of NDB problems. - * Upstream bugfix for Innodb optimizer bug. Closes: #397597 - * Updated Italian Debconf translation (thanks to Luca Monducci). - Closes: #401305 - * Updated debian/watch file to MySQL Enterprise branch. - - -- Christian Hammers Sat, 2 Dec 2006 16:36:38 +0100 - -mysql-dfsg-5.0 (5.0.27-2) unstable; urgency=medium - - * Disabled YaSSL x86 assembler as it was reported to crash applications - like pam-mysql or proftpd-mysql which are linked against libmysqlclient - on i486 and Cyrix (i586) CPUs. Closes: #385147 - * Adjusted mysql-server-4.1 priority to extra and section to oldlibs - according to the ftp masters overrides. - * Updated German Debconf translation (thanks to Alwin Meschede). - Closes: #400809 - - -- Christian Hammers Wed, 22 Nov 2006 13:36:31 +0100 - -mysql-dfsg-5.0 (5.0.27-1) unstable; urgency=medium - - * New upstream version (but no codechange, the only difference to 5.0.26 - was a patch to the ABI change which Debian already included. - * When dist-upgrading from mysql-server-4.1/sarge dpkg does not longer - ask unnecessary "config file has changed" questions regarding - /etc/init.d/mysql, /etc/logrotate.d/mysql-server and - /etc/mysql/debian-start just because these files previously belonged - to mysql-server-4.1 and not to mysql-server-5.0. - To archive this mysql-server-5.0 now pre-depends on mysql-common which - provides current versions of those files. - * The automatic run mysql_upgrade now works with non-standard datadir - settings, too (thanks to Benjami Villoslada). Closes: #394607 - * Debconf now asks if the old_passwords option is really needed. - * Improved explanations of the old_passwords variable in my.cnf. - * Removed possibly leftover cron script from MySQL-4.1 (thanks to - Mario Oyorzabal Salgado). Closes: #390889 - * Postrm ignores failed "userdel mysql". - * Updated Danish Debconf translation (thanks to Claus Hindsgaul). - Closes: #398784 - * Added Euskarian Debconf translation (thanks to Piarres Beobide). - Closes: #399045 - * Updated Japanese Debconf translation (thanks to Hideki Yamane). - Closes: #399074 - * Updated German Debconf translation (thanks to Alwin Meschede). - Closes: #399087 - * New Portuguese debconf translations from Miguel Figueiredo. - Closes: #398186 - - -- Christian Hammers Tue, 7 Nov 2006 21:26:25 +0100 - -mysql-dfsg-5.0 (5.0.26-3) unstable; urgency=high - - [sean finney] - * Fix for the deadly ISAM trap. Now during upgrades we will do our - very best to convert pre-existing ISAM format tables using the - binaries from the previous package. Success is not guaranteed, but - this is probably as good as it gets. Note that this also necessitates - re-introducing an (empty transitional) mysql-server-4.1 package. - Closes: #354544, #354850 - * Remove a couple spurious and wrongly placed WARNING statements from - 45_warn-CLI-passwords.dpatch. thanks to Dan Jacobsen for pointing these - out. Closes: #394262 - - -- sean finney Fri, 03 Nov 2006 18:34:46 +0100 - -mysql-dfsg-5.0 (5.0.26-2) unstable; urgency=high - - * Fixed FTBFS for Alpha by applying an upstream patch (thanks to Falk - Hueffner). Closes: #395921 - - -- Christian Hammers Sat, 28 Oct 2006 20:13:46 +0200 - -mysql-dfsg-5.0 (5.0.26-1) unstable; urgency=high - - * SECURITY: - This combined release of 5.0.25 and 5.0.26 fixes lot of possible server - crashs so it should get into Etch. Quoting the changelog (bug numbers are - bugs.mysql.com ones): - - character_set_results can be NULL to signify no conversion, but some - code did not check for NULL, resulting in a server crash. (Bug#21913) - - Using cursors with READ COMMITTED isolation level could cause InnoDB to - crash. (Bug#19834) - - Some prepared statements caused a server crash when executed a second - time. (Bug#21166) - - When DROP DATABASE or SHOW OPEN TABLES was issued while concurrently - issuing DROP TABLE (or RENAME TABLE, CREATE TABLE LIKE or any other - statement that required a name lock) in another connection, the server - crashed. (Bug#21216) - - Use of zero-length variable names caused a server crash. (Bug#20908) - - For InnoDB tables, the server could crash when executing NOT IN () - subqueries. (Bug#21077) - - Repeated DROP TABLE statements in a stored procedure could sometimes - cause the server to crash. (Bug#19399) - - Performing an INSERT on a view that was defined using a SELECT that - specified a collation and a column alias caused the server to crash - (Bug#21086). - - A query of the form shown here caused the server to crash. (Bug#21007) - - NDB Cluster: Some queries involving joins on very large NDB tables could - crash the MySQL server. (Bug#21059) - - The character set was not being properly initialized for CAST() with a - type like CHAR(2) BINARY, which resulted in incorrect results or even a - server crash. (Bug#17903) - - For certain queries, the server incorrectly resolved a reference to an - aggregate function and crashed. (Bug#20868) - - The server crashed when using the range access method to execut a - subquery with a ORDER BY DESC clause. (Bug#20869) - - Triggers on tables in the mysql database caused a server crash. Triggers - for tables in this database now are disallowed. (Bug#18361) - - Using SELECT on a corrupt MyISAM table using the dynamic record format - could cause a server crash. (Bug#19835) - - Use of MIN() or MAX() with GROUP BY on a ucs2 column could cause a - server crash. (Bug#20076) - - Selecting from a MERGE table could result in a server crash if the - underlying tables had fewer indexes than the MERGE table itself. - (Bug#21617, Bug#22937) - - * New upstream release. - - This bug would cause trouble for Sarge->Etch upgrades, it was supposed to - have been fixed in 5.0.16 but that apparently did not fix the whole - problem: - Using tables from MySQL 4.x in MySQL 5.x, in particular those with VARCHAR - fields and using INSERT DELAYED to update data in the table would result in - either data corruption or a server crash. (Bug#16611, Bug#16218, Bug#17294) - Closes: #386337 - - Fixes data corruption as an automatic client reconnect used to set - the wrong character set. Closes: #365050 - - Fixes an undefined ulong type in an include file. Closes: #389102 - - Fixes wrong output format when using Unicode characters. Closes: #355302 - - Fixes mysql_upgrade when using a password. Closes: #371841 - - [Christian Hammers] - * Removed --sysconfdir from debian/rules as it puts /etc/mysql/ at the - end of the my.cnf search patch thus overriding $HOME/my.cnf - (thanks to Christoph Biedl). Closes: #394992 - * The provided patch from bug #385947 was wrong, the variable is called - BLOCKSIZE not BLOCK_SIZE according to "strings `which df`" (thanks to - Bruno Muller). Closes: #385947 - - [sean finney] - * new dutch debconf translations from Vincent Zweije (closes: #392809). - * new japanese debconf translations from Hideki Yamane (closes: #391625). - * new italian debconf translations from Luca Monducci (closes: #391741). - * new french debconf translations from Christian Perrier (closes: #393334). - * ran debconf-updatepo to merge the fuzzies into svn. - * massage the following patches so they continue to apply cleanly: - - 44_scripts__mysql_config__libs.dpatch to cleanly apply. - - 45_warn-CLI-passwords.dpatch - - 96_TEMP__libmysqlclient_ssl_symbols.dpatch (note, this patch might - no longer be needed, but is retained "just in case" after massaging it) - * the following patches have been incorporated upstream: - - 70_kfreebsd.dpatch - - 80_hurd_mach.dpatch - - 87_ps_Hurd.dpatch - - 90_TEMP__client__mysql_upgrade__O_EXEC.dpatch - - 91_TEMP__client__mysql_upgrade__password.dpatch - - 92_TEMP__client__mysql_upgrade__defaultgroups.dpatch - - 94_TEMP__CVE-2006-4227.dpatch - - 95_TEMP__CVE-2006-4226.dpatch - * the udf_example.cc has disappeared from the source code, but there's - a udf_example.c which seems to be a good example to use instead :) - * update documentation in the configuration to no longer reference - using my.cnf in the DATADIR, as it's never been the recommended - method for debian systems and hasn't worked since 5.0 was released - anyway (closes: #393868). - - -- Christian Hammers Wed, 25 Oct 2006 19:54:04 +0200 - -mysql-dfsg-5.0 (5.0.24a-9) unstable; urgency=medium - - * Having expire_logs_days enabled but log-bin not crashes the server. Using - both or none of those options is safe. To prevent this happening during the - nightly log rotation via /etc/logrotate.d/mysql the initscript checks for - malicious combination of options. See: #368547 - * The Sarge package "mysql-server" which used to include the mysqld daemon - may still be in unselected-configured state (i.e. after a remove but not - purge) in which case its now obsolete cronscript has to be moved away - (thanks to Charles Lepple). Closes: #385669 - * Updated Danish Debconf translation (thanks to Claus Hindsgaul). - Closes: #390315 - * Updated Frensh Debconf translation (thanks to Christian Perrier). - Closes: #390980 - - -- Christian Hammers Tue, 3 Oct 2006 14:55:31 +0200 - -mysql-dfsg-5.0 (5.0.24a-8) unstable; urgency=low - - * (broken upload) - - -- Christian Hammers Tue, 3 Oct 2006 14:55:31 +0200 - -mysql-dfsg-5.0 (5.0.24a-7) unstable; urgency=low - - * Stopped mysql_config from announcing unnecessary library dependencies - which until now cause "NEEDED" dependencies in the "readelf -d" output - of libraries who only depend on libmysqlclient.so (thanks to Michal - Cihar). Closes: #390692 - - -- Christian Hammers Sun, 1 Oct 2006 23:59:43 +0200 - -mysql-dfsg-5.0 (5.0.24a-6) unstable; urgency=low - - [sean finney] - * finally add support for setting a root password at install. - while this is not a random password as requested in one bug - report, we believe it is the best solution and provides a - means to set a random password via preseeding if it's really - desired (Closes: #316127, #298295). - - -- sean finney Sun, 01 Oct 2006 23:34:30 +0200 - -mysql-dfsg-5.0 (5.0.24a-5) unstable; urgency=low - - * Added ${shlibs:Depends} to debian/control section libmysqlclient-dev as it - contains the experimental /usr/lib/mysql/libndbclient.so.0.0.0. - * Bumped standards version to 3.7.2. - * Added LSB info section to init scripts. - * Rephrased Debconf templates as suggested by lintian. - * Added benchmark suite in /usr/share/mysql/sql-bench/. - * The mysql.timezone* tables are now filled by the postinst script (thanks - to Mark Sheppard). Closes: #388491 - * Moved Debconf install notes to README.Debian. Displaying them with - medium priority was a bug anyway. Closes: #388941 - * Replaced /usr/bin/mysql_upgrade by /usr/bin/mysql_upgrade_shell in - /etc/mysql/debian-start.sh as it works without errors (thanks to Javier - Kohen). Closes: #389443 - - -- Christian Hammers Wed, 20 Sep 2006 15:01:42 +0200 - -mysql-dfsg-5.0 (5.0.24a-4) unstable; urgency=high - - * libmysqlclient.so.15 from 5.0.24 accidentaly exports some symbols that are - historically exported by OpenSSL's libcrypto.so. This bug was supposed to - be fixed in 5.0.24a bug according to the mysql bug tracking system will - only be fixed in 5.0.25 so I backported the patch. People already reported - crashing apps due to this (thanks to Duncan Simpson). See also: #385348 - Closes: #388262 - * Fixed BLOCKSIZE to BLOCK_SIZE in initscript (thanks to Bruno Muller). - Closes: #385947 - * Added hint to "--extended-insert=0" to mysqldump manpage (thanks to Martin - Schulze). - * Documented the meaning of "NDB" in README.Debian (thanks to Dan Jacobson). - Closes: #386274 - * Added patch to build on hurd-i386 (thanks to Cyril Brulebois). Closes: #387369 - * Fixed debian-start script to work together with the recend LSB modifications in - the initscript (thanks to wens). Closes: #387481 - * Reverted tmpdir change in my.cnf back to /tmp to comply with FHS (thanks - to Alessandro Valente). Closes: #382778 - * Added logcheck filter rule (thanks to Paul Wise). Closes: #381043 - * I will definetly not disable InnoDB but added a note to the default my.cnf - that disabling it saves about 100MB virtual memory (thanks to Olivier - Berger). Closes: #384399 - * Added thread_cache_size=8 to default my.cnf as this variable seems to have - a negligible memory footprint but can improve performance when lots of - threads connect simultaneously as often seen on web servers. - - -- Christian Hammers Mon, 4 Sep 2006 00:21:50 +0200 - -mysql-dfsg-5.0 (5.0.24a-3) unstable; urgency=low - - * Fixed potential tempfile problem in the newly added mysqlreport script. - - -- Christian Hammers Sun, 3 Sep 2006 23:17:24 +0200 - -mysql-dfsg-5.0 (5.0.24a-2) unstable; urgency=low - - * Added "mysqlreport" (GPL'ed) from hackmysql.com. - * Temporarily disabled expire_days option as it causes the server - to crash. See #368547 - * Made output of init scripts LSB compliant (thanks to David Haerdeman). - Closes: #385874 - - -- Christian Hammers Sun, 3 Sep 2006 19:06:53 +0200 - -mysql-dfsg-5.0 (5.0.24a-1) unstable; urgency=high - - * New upstream version. - * The shared library in the 5.0.24 upstream release accidently exported - some symbols that are also exported by the OpenSSL libraries (notably - BN_bin2bn) causing unexpected behaviour in applications using these - functions (thanks to Peter Cernak). Closes: #385348 - * Added note about possible crash on certain i486 clone CPUs. - * Made recipient address of startup mysqlcheck output configurable - (thanks to Mattias Guns). Closes: #385119 - - -- Christian Hammers Mon, 28 Aug 2006 01:22:12 +0200 - -mysql-dfsg-5.0 (5.0.24-3) unstable; urgency=high - - * SECURITY: - CVE-2006-4226: - When run on case-sensitive filesystems, MySQL allows remote - authenticated users to create or access a database when the database - name differs only in case from a database for which they have - permissions. - CVE-2006-4227: - MySQL evaluates arguments of suid routines in the security context of - the routine's definer instead of the routine's caller, which allows - remote authenticated users to gain privileges through a routine that - has been made available using GRANT EXECUTE. - Thanks to Stefan Fritsch for reporting. Closes: #384798 - - -- Christian Hammers Sat, 26 Aug 2006 04:55:17 +0200 - -mysql-dfsg-5.0 (5.0.24-2) unstable; urgency=high - - * 5.0.24-1 introduced an ABI incompatibility, which this patch reverts. - Programs compiled against 5.0.24-1 are not compatible with any other - version and needs a rebuild. - This bug already caused a lot of segfaults and crashes in various - programs. Thanks to Chad MILLER from MySQL for quickly providing a patch. - The shlibdeps version has been increased to 5.0.24-2. - Closes: #384047, #384221, #383700 - - -- Christian Hammers Fri, 25 Aug 2006 21:47:35 +0200 - -mysql-dfsg-5.0 (5.0.24-1) unstable; urgency=high - - * SECURITY: Upstream fixes a security bug which allows a user to continue - accessing a table using a MERGE TABLE after the right to direct access to - the database has been revoked (CVE-2006-4031, MySQL bug #15195). - (Well they did not exactly fixed it, they documented the behaviour and - allow the admin to disable merge table alltogether...). Closes: #380271 - * SECURITY: Applied patch that fixes a possibly insecure filehandling - in the recently added mysql_upgrade binary file (MySQL bug #10320). - * New upstream version. - - Fixes nasty MySQL bug #19618 that leads to crashes when using - "SELECT ... WHERE ... not in (1, -1)" (e.g. vbulletin was affected). - - Fixes upstream bug #16803 so that linking ~/.mysql_history to /dev/null - now has the desired effect of having no history. - * Really fixed the runlevels. Closes: #377651 - * Added patch for broken upstream handling of "host=" to mysql_upgrade.c. - * Adjusted /etc/mysql/debian-start to new mysql_upgrade.c - - -- Christian Hammers Tue, 8 Aug 2006 00:44:13 +0200 - -mysql-dfsg-5.0 (5.0.22-5) unstable; urgency=low - - * Added further line to the logcheck ignore files (thanks to Paul Wise). - Closes: #381038 - - -- Christian Hammers Wed, 2 Aug 2006 00:28:50 +0200 - -mysql-dfsg-5.0 (5.0.22-4) unstable; urgency=low - - * Upstream fixes a bug in the (never released) version 5.0.23 which could - maybe used to crash the server if the mysqlmanager daemon is in use - which is not yet the default in Debian. (CVE-2006-3486 *DISPUTED*) - * Changed runlevel priority of mysqld from 20 to 19 so that it gets started - before apache and proftpd etc. which might depend on an already running - database server (thanks to Martin Gruner). Closes: #377651 - * Added patch which sets PATH_MAX in ndb (thanks to Cyril Brulebois). - Closes: #378949 - * Activated YaSSL as licence issues are settled according to: - http://bugs.mysql.com/?id=16755. This also closes the FTBFS bug - regarding OpenSSL as it is discouraged to use now. Closes: #368639 - * Removed SSL-MINI-HOWTO as the official documentation is good enough now. - * mysql_upgrade no longer gives --password on the commandline which would - be insecure (thanks to Dean Gaudet). Closes: #379199 - * Adjusted debian/patches/45* to make consecutive builds in the same source - tree possible (thanks to Bob Tanner). Closes: #368661 - * mysql-server-5.0 is now suggesting tinyca as yaSSL is enabled and tinyca - was found to be really cool :) - * Moved tempdir from /tmp to /var/tmp as it will more likely have enough - free space as /tmp is often on the root partition and /var or at least - /var/tmp is on a bigger one. - - -- Christian Hammers Mon, 10 Jul 2006 23:30:26 +0200 - -mysql-dfsg-5.0 (5.0.22-3) unstable; urgency=low - - * Added patch for MySQL bug #19618: "select x from x - where x not in(1,-1)" may crash the server" (thanks to - Ruben Puettmann). - - -- Christian Hammers Fri, 9 Jun 2006 01:41:44 +0200 - -mysql-dfsg-5.0 (5.0.22-2) unstable; urgency=high - - * Fixed debian-sys-maint related bug in postinst (thanks to - Jean-Christophe Dubacq). Closes: #369970 - * The last upload was a security patch (which I did not know as I - uploaded before the announcement came). I now added the CVE id for - reference and set urgency to high as the last entry did not. - - -- Christian Hammers Wed, 31 May 2006 01:04:11 +0200 - -mysql-dfsg-5.0 (5.0.22-1) unstable; urgency=low - - * SECURITY: This upstream release fixes an SQL-injection with multibyte - encoding problem. (CVE-2006-2753) - * New upstream release. - * Upstream fixes REPAIR TABLE problem. Closes: #354300 - * Upstream fixes problem that empty strings in varchar and text columns - are displayed as NULL. Closes: #368663 - - -- Christian Hammers Tue, 30 May 2006 23:43:24 +0200 - -mysql-dfsg-5.0 (5.0.21-4) unstable; urgency=low - - * Added "BLOCKSIZE=" to the diskfree check (thanks to Farzad FARID). - Closes: #367027, #367083 - * Further fixed mysql_upgrade upstream script (thanks to Andreas Pakulat) - Closes: #366155 - * Adjusted the /proc test in debian/rules from /proc/1 to /proc/self - to make building on grsec systems possible (thanks to K. Rosenegger). - Closes: #366824 - * Updated Russion Debconf translation (thanks to Yuriy Talakan). - Closes: #367141 - * Updated Czech Debconf translation (thanks to Kiroslav Kure). - Closes: #367160 - * Updated Galician Debconf translation (thanks to Jacobo Tarrio). - Closes: #367384 - * Updated Swedish Debconf translation (thanks to Daniel Nylander). - Closes: #368186 - - -- Christian Hammers Wed, 10 May 2006 08:45:42 +0200 - -mysql-dfsg-5.0 (5.0.21-3) unstable; urgency=low - - * Fixed FTBFS problem which was caused by a patch that modifies Makefile.am - as well as Makefile.in and was not deteced because my desktop was fast - enough to patch both files within the same second and so fooled automake. - (thanks to Blars Blarson for notifying me). Closes: #366534 - - -- Christian Hammers Sat, 6 May 2006 19:03:58 +0200 - -mysql-dfsg-5.0 (5.0.21-2) unstable; urgency=low - - * Fixed bug in postinst that did not correctly rewrite - /etc/mysql/debian.cnf (thanks to Daniel Leidert). - Closes: #365433, #366155 - - -- Christian Hammers Thu, 4 May 2006 02:37:03 +0200 - -mysql-dfsg-5.0 (5.0.21-1) unstable; urgency=high - - * SECURITY: New upstream release with some security relevant bugfixes: - * "Buffer over-read in check_connection with usernames lacking a - trailing null byte" (CVE-2006-1516) - * "Anonymous Login Handshake - Information Leakage" (CVE-2006-1517) - * "COM_TABLE_DUMP Information Leakage and Arbitrary command execution" - (CVE-2006-1518) - Closes: #365938, #365939 - * Added diskfree check to the init script (thanks to Tim Baverstock). - Closes: #365460 - * First amd64 upload! - - -- Christian Hammers Sat, 29 Apr 2006 04:31:27 +0200 - -mysql-dfsg-5.0 (5.0.20a-2) unstable; urgency=low - - * The new mysql-upgrade which is started from /etc/mysql/debian-start - does now use the debian-sys-maint user for authentication (thanks to - Philipp). Closes: #364991 - * Wrote patch debian/patches/43* which adds a password option to - mysql_update. See MySQL bug #19400. - * Added "Provides: libmysqlclient-dev" to libmysqlclient15-dev as I saw no - obvious reasons against it (problems should be documented in - debian/README.Maintainer!) (thanks to Olaf van der Spek). Closes: #364899 - * Updated Netherlands debconf translation (thanks to Vincent Zweije) - Closes: #364464 - * Updated French debconf translation (thanks to Christian Perrier) - Closes: #364401 - * Updated Danish debconf translation (thanks to Claus Hindsgaul) - Closes: #365135 - - -- Christian Hammers Wed, 26 Apr 2006 01:14:53 +0200 - -mysql-dfsg-5.0 (5.0.20a-1) unstable; urgency=low - - * New upstream release. - * Added the new mysql_upgrade script and added it to - /etc/mysql/debian-start (thanks to Alessandro Polverini). - The script is currently very noise that is a known bug and will be - fixed in the next release! - Closes: #363458 - * No longer creates the "test" database. This actuallay had been tried - to archive before (at least patches) exists but apparently was not the - case in the last versions (thanks to Olaf van der Spek). Closes: #362126 - * Reformatted libmysqlclient15off.NEWS.Debian to changelog format - (thanks to Peter Palfrader). Closes: #363062 - - -- Christian Hammers Sat, 15 Apr 2006 13:05:22 +0200 - -mysql-dfsg-5.0 (5.0.20-1) unstable; urgency=high - - * Upstream contains a fix for a nasty bug (MySQL#18153) that users - already experienced and that caused corrupted triggers after - REPAIR/OPTIMIZE/ALTER TABLE statements. - (thanks to Jerome Despatis for pointing out) - * Added patch for the "updates on multiple tables is buggy after - upgrading from 4.1 to 5.0" problem which MySQL has been committed - for the upcoming 5.0.21 release. Closes #352704 - * Added Netherlands debconf translation (thanks to Vincent Zweije). - Closes: #360443 - * Added Galician debconf translation (thanks to Jacobo Tarrio). - Closes: #361257 - - -- Christian Hammers Fri, 7 Apr 2006 00:00:43 +0200 - -mysql-dfsg-5.0 (5.0.19-3) unstable; urgency=high - - [ Christian Hammers ] - * Fixed libmysqlclient15.README.Debian regarding package name changes - (thanks to Leppo). - * Moved libheap.a etc. back to /usr/lib/mysql/ as their names are just - too generic. Closes: #353924 - [ Sean Finney ] - * updated danish debconf translation, thanks to Claus Hindsgaul - (closes: #357424). - [ Adam Conrad ] - * Send stderr from 'find' in preinst to /dev/null to tidy up chatter. - * Backport patch for CVE-2006-0903 from the upcoming release to resolve - a log bypass vulnerability when using non-binary logs (closes: #359701) - - -- Adam Conrad Tue, 4 Apr 2006 15:23:18 +1000 - -mysql-dfsg-5.0 (5.0.19-2) unstable; urgency=medium - - * New upstream release. - * Renamed package libmysqlclient15 to libmysqlclient15off due to - binary incompatible changes. - See /usr/share/doc/libmysqlclient15off/README.Debian - * Updated Czech debconf translation (thanks to Miroslav Kure). - Closes: #356503 - * Updated French debconf translation (thanks to Christian Perrier). - Closes: #356332 - * Improved README.Debian (thanks to Olaf van der Spek). Closes: #355702 - * Fixed 5.0.18-8 changelog by saying in which package the NEWS.Debian - file is (thanks to Ross Boylan). Closes: #355978 - - -- Christian Hammers Fri, 17 Mar 2006 02:32:19 +0100 - -mysql-dfsg-5.0 (5.0.19-1) experimental; urgency=medium - - * New upstream release. - * SECURITY: CVE-2006-3081: A bug where str_to_date(1,NULL) lead to a - server crash has been fixed. - (this note has been added subsequently for reference) - * Renamed package libmysqlclient15 to libmysqlclient15off. - See /usr/share/doc/libmysqlclient15off/NEWS.Debian - * Updated Czech debconf translation (thanks to Miroslav Kure). - Closes: #356503 - * Updated French debconf translation (thanks to Christian Perrier). - Closes: #356332 - * Improved README.Debian (thanks to Olaf van der Spek). Closes: #355702 - * Fixed 5.0.18-8 changelog by saying in which package the NEWS.Debian - file is (thanks to Ross Boylan). Closes: #355978 - - -- Christian Hammers Tue, 14 Mar 2006 22:56:13 +0100 - -mysql-dfsg-5.0 (5.0.18-9) unstable; urgency=medium - - [ Christian Hammers ] - * When using apt-get the check for left-over ISAM tables can abort the - installation of mysql-server-5.0 but not prevent the mysql-server-4.1 - package from getting removed. The only thing I can do is reflect this - in the Debconf notice that is shown and suggest to reinstall - mysql-server-4.1 for converting. See: #354850 - * Suggests removing of /etc/cron.daily/mysql-server in last NEWS message - (thanks to Mourad De Clerck). Closes: #354111 - * Added versioned symbols for kfreebsd and Hurd, too (thanks to Aurelien - Jarno and Michael Bank). Closes: #353971 - * Added versioned symbols for kfreebsd, too (thanks to Aurelien Jarno). - Closes: #353971 - [ Adam Conrad ] - * Add 39_scripts__mysqld_safe.sh__port_dir.dpatch to ensure that the - permissions on /var/run/mysqld are always correct, even on a tmpfs. - - -- Christian Hammers Mon, 6 Mar 2006 21:42:13 +0100 - -mysql-dfsg-5.0 (5.0.18-8) unstable; urgency=low - - * The rotation of the binary logs is now configured via - expire-logs-days in /etc/mysql/my.cnf and handled completely - by the server and no longer in configured in debian-log-rotate.conf - and handled by a cron job. Thanks to David Johnson. - See /usr/share/doc/mysql-server-5.0/NEWS.Debian - * Ran aspell over some files in debian/ and learned a lot :) - * debian/rules: Added check if versioned symbols are really there. - * Updated SSL-MINI-HOWTO. - * Updated copyright (removed the parts regarding the now removed - BerkeleyDB table handler and mysql-doc package). - * Relocated a variable in preinst (thanks to Michael Heldebrant). - Closes: #349258, #352587, #351216 - * Updated Danish debconf translation (thanks to Claus Hindsgaul). - Closes: #349013 - * Updated Swedish debconf translation (thanks to Daniel Nylander). - Closes: #349522 - * Updated French debconf translation (thanks to Christian Perrier). - Closes: #349592 - * Fixed typo in README.Debian (thanks to Vincent Ricard). - * Prolonged waiting time for mysqld in the init script. Closes: #352070 - - -- Christian Hammers Mon, 23 Jan 2006 23:13:46 +0100 - -mysql-dfsg-5.0 (5.0.18-7) unstable; urgency=low - - * Made mailx in debian-start.inc.sh optional and changed the dependency on it - on it to a mere recommendation. Closes: #316297 - * the previous FTBFS patches for GNU/Hurd inadvertently led to configure - being regenerating, losing a couple trivial things like our versioned - symbols patch, causing many nasty problems (closes: #348854). - - -- sean finney Fri, 20 Jan 2006 20:59:27 +0100 - -mysql-dfsg-5.0 (5.0.18-6) unstable; urgency=low - - * Added version comment (thanks to Daniel van Eeden). - * Added two patches to build on GNU/Hurd (thanks to Michael Bank). - Closes: #348182 - * Abort upgrade if old and now unsupported ISAM tables are present - (thanks to David Coe). Closes: #345895 - - -- Christian Hammers Tue, 17 Jan 2006 19:25:59 +0100 - -mysql-dfsg-5.0 (5.0.18-5) unstable; urgency=low - - * Bump shlibdeps for libmysqlclient15 to (>= 5.0.15-1), which was - the first non-beta release from upstream, as well as being shortly - after we broke the ABI in Debian by introducing versioned symbols. - - -- Adam Conrad Fri, 13 Jan 2006 13:18:03 +1100 - -mysql-dfsg-5.0 (5.0.18-4) unstable; urgency=low - - * Munge our dependencies further to smooth upgrades even more, noting - that we really need 5.0 to conflict with 4.1, and stealing a page from - the book of mysql-common, it doesn't hurt to hint package managers in - the direction of "hey, this stuff is a complete replacement for 4.1" - * Change the description of mysql-server and mysql-client to remove the - references to it being "transition", and instead point out that it's - the way to get the "current best version" of each package installed. - - -- Adam Conrad Wed, 11 Jan 2006 11:39:45 +1100 - -mysql-dfsg-5.0 (5.0.18-3) unstable; urgency=low - - * Make the mysql-{client,server}-5.0 conflict against mysql-{client,server} - versioned, so they can be installed side-by-side and upgrade properly. - * Add myself to Uploaders; since I have access to the alioth repository. - - -- Adam Conrad Tue, 10 Jan 2006 19:15:48 +1100 - -mysql-dfsg-5.0 (5.0.18-2) unstable; urgency=low - - * Removed the transitional package that forced an upgrade from - mysql-server-4.1 to mysql-server-5.0 as I was convinced that - having a general "mysql-server" package with adjusted dependencies - is enough (thanks to Adam Conrad). - * Updated logcheck.ignore files (thanks to Jamie McCarthy). Closes: #340193 - - -- Christian Hammers Mon, 9 Jan 2006 21:54:53 +0100 - -mysql-dfsg-5.0 (5.0.18-1) unstable; urgency=low - - * New upstream version. - * Added empty transitional packages that force an upgrade from the - server and client packages that have been present in Sarge. - * Fixed SSL-MINI-HOWTO (thanks to Jonas Smedegaard). Closes: #340589 - - -- Christian Hammers Mon, 2 Jan 2006 21:17:51 +0100 - -mysql-dfsg-5.0 (5.0.17-1) unstable; urgency=low - - * Never released as Debian package. - - -- Christian Hammers Thu, 22 Dec 2005 07:49:52 +0100 - -mysql-dfsg-5.0 (5.0.16-1) unstable; urgency=low - - * New upstream version. - * Removed the error logs from the logrotate script as Debian does - not use them anymore. Closes: #339628 - - -- Christian Hammers Tue, 22 Nov 2005 01:19:11 +0100 - -mysql-dfsg-5.0 (5.0.15-2) unstable; urgency=medium - - * Added 14_configure__gcc-atomic.h.diff to fix FTBFS on m68k - (thanks to Stephen R Marenka). Closes: #337082 - * Removed dynamic linking against libstdc++ as it was not really - needed (thanks to Adam Conrad). Closes: #328613 - * Fixed the "/var/lib/mysql is a symlink" workaround that accidently - left a stalled symlink (thanks to Thomas Lamy). Closes: #336759 - * As the init script cannot distinguish between a broken startup and - one that just takes very long the "failed" message now says - "or took more than 6s" (thanks to Olaf van der Spek). Closes: #335547 - - -- Christian Hammers Thu, 3 Nov 2005 22:00:15 +0100 - -mysql-dfsg-5.0 (5.0.15-1) unstable; urgency=low - - * New upstream version. 5.0 has finally been declared STABLE! - * Added small patch to debian/rules that fixed sporadic build errors - where stdout and stderr were piped together, got mixed up and broke - * Added --with-big-tables to ./configure (thanks to tj.trevelyan). - Closes: #333090 - * Added capability to parse "-rc" to debian/watch. - * Fixed cronscript (thanks to Andrew Deason). Closes: #335244 - * Added Swedish debconf translation (thanks to Daniel Nylander). - Closes: #333670 - * Added comment to README.Debian regarding applications that manually - set new-style passwords... Closes: #334444 - * Sean Finney: - - Fix duplicate reference to [-e|--extended-insert]. Closes: #334957 - - Fix default behavior for mysqldumpslow. Closes: #334517 - - Reference documentation issue in mysql manpage. Closes: #335219 - - -- Christian Hammers Fri, 30 Sep 2005 00:10:39 +0200 - -mysql-dfsg-5.0 (5.0.13rc-1) unstable; urgency=low - - * New upstream release. Now "release-candidate"! - * Removed any dynamic link dependencies to libndbclient.so.0 which - is due to its version only distributed as a static library. - * Sean Finney: - - FTBFS fix related to stripping rpath in debian/rules - - -- Christian Hammers Mon, 26 Sep 2005 22:09:26 +0200 - -mysql-dfsg-5.0 (5.0.12beta-5) unstable; urgency=low - - * The recent FTBFS were probably result of a timing bug in the - debian/patches/75_*.dpatch file where Makefile.in got patched just - before the Makefile.shared which it depended on. For that reason - only some of the autobuilders failed. Closes: #330149 - * Fixed chrpath removal (option -k had to be added). - * Corrected debconf dependency as requested by Joey Hess. - - -- Christian Hammers Mon, 26 Sep 2005 18:37:07 +0200 - -mysql-dfsg-5.0 (5.0.12beta-4) unstable; urgency=low - - * Removed experimental shared library libndbclient.so.0.0.0 as it - is doomed to cause trouble as long as it is present in both MySQL 4.1 - and 5.0 without real soname and its own package. We still have - libndbclient.a for developers. (thanks to Adam Conrad and - mediaforest.net). Closes: #329772 - - -- Christian Hammers Fri, 23 Sep 2005 12:36:48 +0200 - -mysql-dfsg-5.0 (5.0.12beta-3) unstable; urgency=medium - - * Symbol versioning support! wooooohoooooo! - (thanks to Steve Langasek) Closes: #236288 - * Moved libndbcclient.so.0 to the -dev package as it is provided by - libmysqlclient14 and -15 which must be installable simultaneously. - * Removed mysql-*-doc suggestions. - - -- Christian Hammers Tue, 20 Sep 2005 00:07:03 +0200 - -mysql-dfsg-5.0 (5.0.12beta-2) unstable; urgency=low - - * Added patch to build on GNU/kFreeBSD (thanks to Aurelien Jarno). - Closes: #327702 - * Added patch that was already been present on the 4.1 branch which - makes the "status" command of the init script more sensible - (thanks to Stephen Gildea). Closes: #311836 - * Added Vietnamese Debconf translation (thanks to Clytie Siddal). - Closes: #313006 - * Updated German Debconf translation (thanks to Jens Seidel). - Closes: #313957 - * Corrected commends in example debian-log-rotate.conf. The default is - unlike the mysql-sever-4.1 package which needed to stay backwards - compatible now 2 to avoid filling up the disk endlessly. - * Fixed watch file to be "-beta" aware. - - -- Christian Hammers Thu, 15 Sep 2005 20:50:19 +0200 - -mysql-dfsg-5.0 (5.0.12beta-1) unstable; urgency=medium - - * Christian Hammers: - - New upstream release. - - Changed build-dep to libreadline5-dev as requested by Matthias Klose. - Closes: #326316 - - Applied fix for changed output format of SHOW MASTER LOGS for - binary log rotation (thanks to Martin Krueger). Closes: #326427, #326427 - - Removed explicit setting of $PATH as I saw no sense in it and - it introduced a bug (thanks to Quim Calpe). Closes: #326769 - - Removed PID file creation from /etc/init.d/mysql-ndb as it does - not work with this daemon (thanks to Quim Calpe). - - Updated French Debconf translation (thanks to Christian Perrier). - Closes: #324805 - - Moved conflicts line in debian/control from libmysqlclient15 to - libmysqlclient15-dev and removed some pre-sarge conflicts as - suggested by Adam Majer. Closes: #324623 - * Sean Finney: - - For posterity, CAN-2005-2558 has been fixed since 5.0.7beta. - - -- Christian Hammers Thu, 15 Sep 2005 19:58:22 +0200 - -mysql-dfsg-5.0 (5.0.11beta-3) unstable; urgency=low - - * Temporarily build only with -O2 to circumvent gcc internal errors - (thanks to Matthias Klose). Related to: #321165 - - -- Christian Hammers Thu, 18 Aug 2005 15:44:04 +0200 - -mysql-dfsg-5.0 (5.0.11beta-2) unstable; urgency=low - - * Fixed README.Debian regarding the status of mysql-doc. - * Added "set +e" around chgrp in mysql-server-5.0.preinst to - not fail on .journal files (thanks to Christophe Nowicki). - Closes: #318435 - - -- Christian Hammers Sun, 14 Aug 2005 18:02:08 +0200 - -mysql-dfsg-5.0 (5.0.11beta-1) unstable; urgency=low - - * New upstream version. - * Added Danish Debconf translations (thanks to Claus Hindsgaul). - Closes: #322384 - * Updated Czech Debconf translations (thanks to Miroslav Kure). - Closes: #321765 - - -- Christian Hammers Sat, 13 Aug 2005 11:56:15 +0000 - -mysql-dfsg-5.0 (5.0.10beta-1) unstable; urgency=low - - * New upstream release. - * Christian Hammers: - - Added check for mounted /proc to debian/rules. - * Sean Finney: - - fix for fix_mysql_privilege_tables/mysql_fix_privilege_tables typo - in mysql-server-5.0's README.Debian (see #319838). - - -- Christian Hammers Sun, 31 Jul 2005 00:30:45 +0200 - -mysql-dfsg-5.0 (5.0.7beta-1) unstable; urgency=low - - * Second try for new upstream release. - * Renamed mysql-common-5.0 to mysql-common as future libmysqlclient16 - from e.g. MySQL-5.1 would else introduce mysql-common-5.1 which makes - a simultanous installation of libmysqlclient14 impossible as that - depends on either mysql-common or mysql-common-5.0 but not on future - versions. Thus we decided to always let the newest MySQL version - provide mysql-common. - * Added ${misc:Depends} as suggested by debhelper manpage. - * Raised standard in control file to 3.6.2. - * Removed DH_COMPAT from rules in faviour of debian/compat. - * Checkes for presence of init script before executing it in preinst. - Referres: 315959 - * Added 60_includes_mysys.h__gcc40.dpatch for GCC-4.0 compatibility. - - -- Christian Hammers Wed, 29 Jun 2005 00:39:05 +0200 - -mysql-dfsg-5.0 (5.0.5beta-1) unstable; urgency=low - - * New major release! Still beta so be carefull... - * Added federated storage engine. - - -- Christian Hammers Wed, 8 Jun 2005 19:29:45 +0200 - -mysql-dfsg-4.1 (4.1.12-1) unstable; urgency=low - - * Christian Hammers: - - New upstream release. - - Disabled BerkeleyDB finally. It has been obsoleted by InnoDB. - * Sean Finney: - - Updated French translation from Christian Perrier (Closes: #310526). - - Updated Japanese translation from Hideki Yamane (Closes: #310263). - - Updated Russian translation from Yuriy Talakan (Closes: #310197). - - -- Christian Hammers Sat, 4 Jun 2005 05:49:11 +0200 - -mysql-dfsg-4.1 (4.1.11a-4) unstable; urgency=high - - * Fixed FTBFS problem which was caused due to the fact that last uploads - BerkeleyDB patch was tried to applied on all architectures and not only - on those where BerkeleyDB is actually beeing built. Closes: #310296 - - -- Christian Hammers Mon, 23 May 2005 00:54:51 +0200 - -mysql-dfsg-4.1 (4.1.11a-3) unstable; urgency=high - - * Added patch from Piotr Roszatycki to compile the bundled db3 library - that is needed for the BerkeleyDB support with versioned symbols so - that mysqld no longer crashes when it gets linked together with the - Debian db3 version which happens when e.g. using libnss-db. - Closes: #308966 - - -- Christian Hammers Thu, 19 May 2005 01:41:14 +0200 - -mysql-dfsg-4.1 (4.1.11a-2) unstable; urgency=high - - * Okay, the hackery with /var/lib/dpkg/info/mysql-server.list will not - stand and is removed from the preinst of mysql-server. - * New workaround for the symlink problem that does not involve mucking - with dpkg's file lists is storing the symlinks in a temporary location - across upgrades. - As this sometimes fails since apt-get does not always call new.preinst - before old.postrm, some remarks were added to README.Debian and the - Debconf installation notes to minimize the inconvinience this causes. - - -- sean finney Sun, 15 May 2005 10:25:31 -0400 - -mysql-dfsg-4.1 (4.1.11a-1) unstable; urgency=high - - * Added the "a" to the version number to be able to upload a new - .orig.tar.gz file which now has the non-free Docs/ directory removed - as this has been forgotten in the 4.1.11 release (thanks to Goeran - Weinholt). Closes: #308691 - * The Woody package listed /var/lib/mysql and /var/log/mysql in its - /var/lib/dpkg/info/mysql-server.list. These directories are often - replaced by symlinks to data partitions which triggers a dpkg bug - that causes these symlinks to be removed on upgrades. The new preinst - prevents this by removing the two lines from the .list file - (thanks to Andreas Barth and Jamin W. Collins). See dpkg bug #287978. - * Updated French Debconf translation (thanks to Christian Perrier). - Closes: #308353 - - -- Christian Hammers Thu, 12 May 2005 21:52:46 +0200 - -mysql-dfsg-4.1 (4.1.11-3) unstable; urgency=high - - * The "do you want to remove /var/lib/mysql when purging the package" flag - from old versions is removed once this package is beeing installed so - that purging an old Woody mysql-server package while having a - mysql-server-4.1 package installed can no longer lead to the removal of - all databases. Additionaly clarified the wording of this versions Debconf - template and added a check that skips this purge in the postrm script - if another mysql-server* package has /usr/sbin/mysqld installed. - (thanks to Adrian Bunk for spotting that problem) Closes: #307473 - * Cronfile was not beeing installed as the filename was not in the - correct format for "dh_installcron --name" (thanks to Tomislav - Gountchev). Closes: #302712 - - -- Christian Hammers Sat, 23 Apr 2005 22:55:15 +0200 - -mysql-dfsg-4.1 (4.1.11-2) unstable; urgency=low - - * Sean Finney: - - don't freak out if we can't remove /etc/mysql during purge. - - debian/rules clean works again. - * Christian Hammers: - - Fixed typo in README.Debian (thanks to Joerg Rieger). Closes: #304897 - - Completely removed the passwordless test user as it was not only - insecure but also lead to irritations as MySQL checks first the - permissions of this user and then those of a password having one. - See bug report from Hilko Bengen for details. Closes: #301741 - - -- Christian Hammers Sat, 16 Apr 2005 15:55:00 +0200 - -mysql-dfsg-4.1 (4.1.11-1) unstable; urgency=low - - * New upstream version. - * Upstream fix for charset/collation problem. Closes: #282256 - * Upstream fix for subselect crash. Closes: #297687 - * Corrected minor issue in Debconf template regarding skip-networking - (thanks to Isaac Clerencia). Closes: #303417 - * Made dependency to gawk unnecessary (thanks to Zoran Dzelajlija). - Closes: #302284 - * Removed obsolete 50_innodb_mixlen.dpatch. - * Removed obsolete 51_CAN-2004-0957_db_grant_underscore.dpatch. - - -- Christian Hammers Fri, 8 Apr 2005 00:23:53 +0200 - -mysql-dfsg-4.1 (4.1.10a-7) unstable; urgency=low - - * Sean Finney: - - fix for the mysteriously disappeared cronjob. thanks to - Peter Palfrader for pointing out this omission. - (closes: #302712). - - -- sean finney Sat, 02 Apr 2005 16:54:13 -0500 - -mysql-dfsg-4.1 (4.1.10a-6) unstable; urgency=high - - * Sean Finney: - - the previous upload did not completely address the issue. this one - should do so. d'oh. - - -- sean finney Thu, 31 Mar 2005 03:35:50 +0000 - -mysql-dfsg-4.1 (4.1.10a-5) unstable; urgency=high - - * Sean Finney: - - the following security issue is addressed in this upload: - CAN-2004-0957 (grant privilege escalation on tables with underscores) - thanks to sergei at mysql for all his help with this. - - -- sean finney Wed, 30 Mar 2005 21:19:26 -0500 - -mysql-dfsg-4.1 (4.1.10a-4) unstable; urgency=low - - * Sean Finney: - - FTBFS fix for amd64/gcc-4.0. Thanks to Andreas Jochens - for reporting this (closes: #301807). - - ANSI-compatible quoting fix in daily cron job. thanks to - Karl Hammar for pointing out the problem in - the 4.0 branch. - - Added myself as a co-maintainer in the control file (closes: #295312). - - -- sean finney Tue, 29 Mar 2005 18:54:42 -0500 - -mysql-dfsg-4.1 (4.1.10a-3) unstable; urgency=low - - * BerkeleyDB is now disabled by default as its use is discouraged by MySQL. - * Added embedded server libraries as they finally do compile. - They are currently in libmysqlclient-dev as they are still - experimental and only available as .a library (thanks to Keith Packard). - Closes: #297062 - * Fixed obsolete "tail" syntax (thanks to Sven Mueller). Closes: #301413 - * Added CAN numbers for the latest security bugfix upload. - * Updated manpage of mysqlmanager (thanks to Justin Pryzby). Closes: #299844 - * Added comments to default configuration. - - -- Christian Hammers Sun, 20 Mar 2005 17:40:18 +0100 - -mysql-dfsg-4.1 (4.1.10a-2) unstable; urgency=low - - * Disabled "--with-mysqld-ldflags=-all-static" as it causes sig11 crashes - if LDAP is used for groups in /etc/nsswitch.conf. Confirmed by Sean Finney - and Daniel Dehennin. Closes: #299382 - - -- Christian Hammers Mon, 14 Mar 2005 03:01:03 +0100 - -mysql-dfsg-4.1 (4.1.10a-1) unstable; urgency=high - - * SECURITY: - - The following security related updates are addressed: - CAN-2005-0711 (temporary file creation with "CREATE TEMPORARY TABLE") - CAN-2005-0709 (arbitrary library injection in udf_init()) - CAN-2005-0710 (arbitrary code execution via "CREATE FUNCTION") - Closes: #299029, #299031, #299065 - * New Upstream Release. - - Fixes some server crash conditions. - - Upstream includes fix for TMPDIR overriding my.cnf tmpdir setting - Closes: #294347 - - Fixes InnoDB error message. Closes: #298875 - - Fixes resouce limiting. Closes: #285044 - * Improved checking whether or not the server is alive in the init script - which should make it possible to run several mysqld instances in - different chroot environments. Closes: #297772 - * Fixed cron script name as dots are not allowed (thanks to Michel - v/d Ven). Closes: #298447 - * Added -O3 and --with-mysqld-ldflags=-all-static as MySQL recommends to - build the server binary statically in order to gain about 13% more - performance (thanks to Marcin Kowalski). - * Added patch to let mysqld_safe react to signals (thanks to Erich - Schubert). Closes: #208364 - * (Thanks to Sean Finney for doing a great share of work for this release!) - - -- Christian Hammers Thu, 3 Mar 2005 02:36:39 +0100 - -mysql-dfsg-4.1 (4.1.10-4) unstable; urgency=medium - - * Fixed bug that prevented MySQL from starting after upgrades. - Closes: #297198, #296403 - * Added comment about logging to syslog to the default my.cnf - and the logrotate script (thanks to Ryszard Lach). Closes: #295507 - - -- Christian Hammers Thu, 3 Mar 2005 00:28:02 +0100 - -mysql-dfsg-4.1 (4.1.10-3) unstable; urgency=low - - * Sean Finney: Cronjobs now exit silently when the server package - has been removed but not purged (thanks to Vineet Kumar). - Closes: #297404 - * Fixed comments of /etc/mysql/debian-log-rotate.conf (thanks to - Philip Ross). Closes: #297467 - * Made mysqld_safe reacting sane on signals (thanks to Erich Schubert). - Closes: #208364 - - -- Christian Hammers Tue, 1 Mar 2005 19:44:34 +0100 - -mysql-dfsg-4.1 (4.1.10-2) unstable; urgency=low - - * Converted to dpatch. - * debian/ is now maintained via Subversion on svn.debian.org. - - -- Christian Hammers Tue, 1 Mar 2005 02:16:36 +0100 - -mysql-dfsg-4.1 (4.1.10-1) unstable; urgency=low - - * New upstream version. - * Upstream fixed memleak bug. Closes: #205587 - * Added debian/copyright.more for personal reference. - * Lowered default query cache size as suggested by Arjen from MySQL. - * Switched from log to log-bin as suggested by Arjen from MySQL. - * Fixed typo in my.cnf (thanks to Sebastian Feltel). Closes: #295247 - * Replaced --defaults-extra-file by --defaults-file in Debian scripts - as former lets password/host etc be overwriteable by /root/.my.cnf. - Added socket to /etc/mysql/debian.cnf to let it work. (thanks to - SATOH Fumiyasu). Closes: #295170 - - -- Christian Hammers Tue, 15 Feb 2005 23:47:02 +0100 - -mysql-dfsg-4.1 (4.1.9-4) unstable; urgency=low - - * Improved the way mysqld is started and registered with update-rc.d - in cases where the admin modifies the runlevel configuration. - Most notably removed the debconf question whether or not mysql should - start on when booting. Closes: #274264 - * Renamed configuration option old-passwords to the more preferred - naming convention old_passwords. Same for some others (thanks to - Patrice Pawlak). Closes: #293983 - - -- Christian Hammers Tue, 8 Feb 2005 02:21:18 +0100 - -mysql-dfsg-4.1 (4.1.9-3) unstable; urgency=low - - * Renamed ca_ES.po to ca.po to reach a broader audience (thanks to - Christian Perrier). Closes: #293786 - * Expicitly disabled mysqlfs support as it has never been enabled by - configure during the autodetection but fails due to broken upstream - code when users try to build the package theirselves while having - liborbit-dev installed which triggers the mysqlfs autodetection - (thanks to Max Kellermann). Closes: #293431 - * Added dependencies to gawk as one script does not work with original-awk - (thanks to Petr Ferschmann). Closes: #291634 - - -- Christian Hammers Sun, 6 Feb 2005 23:33:11 +0100 - -mysql-dfsg-4.1 (4.1.9-2) unstable; urgency=high - - * SECURITY: - For historical reasons /usr/share/mysql/ was owned and writable by - the user "mysql". This is a security problem as some scripts that - are run by root are in this directory and could be modified and used - by a malicious user who already has mysql privileges to gain full root - rights (thanks to Matt Brubeck). Closes: #293345 - * Changed "skip-networking" to "bind-address 127.0.0.1" which is more - compatible and not less secure but maybe even more, as less people enable - networking for all interfaces (thanks to Arjen Lentz). - * Enabled InnoDB by default as recommended by Arjen Lentz from MySQL. - * Added remarks about hosts.allow to README.Debian (thanks to David - Chappell). Closes: #291300 - * mysql-server-4.1 now provides mysql-server (thanks to Paul van den Berg). - Closes: #287735 - - -- Christian Hammers Wed, 2 Feb 2005 23:31:55 +0100 - -mysql-dfsg-4.1 (4.1.9-1) unstable; urgency=low - - * New upstream version. - * mysql-client-4.1 now provides "mysql-client" so that packages depending - on mysql-client (ca. 40) can now be used with MySQL-4.1, too. - - -- Christian Hammers Sun, 23 Jan 2005 22:52:48 +0100 - -mysql-dfsg-4.1 (4.1.8a-6) unstable; urgency=high - - * SECURITY: - Javier Fernandez-Sanguino Pena from the Debian Security Audit Project - discovered a temporary file vulnerability in the mysqlaccess script of - MySQL that could allow an unprivileged user to let root overwrite - arbitrary files via a symlink attack and could also could unveil the - contents of a temporary file which might contain sensitive information. - (CAN-2005-0004, http://lists.mysql.com/internals/20600) Closes: #291122 - - -- Christian Hammers Tue, 18 Jan 2005 23:11:48 +0100 - -mysql-dfsg-4.1 (4.1.8a-5) unstable; urgency=medium - - * Fixed important upstream bug that causes from_unixtime(0) to return - NULL instead of "1970-01-01 00:00:00" which fails on NOT NULL columns. - Closes: #287792 - * Fixes upstream bug in mysql_list_fields() . Closes: #282486 - * Fixes bug that lead to double rotated logfiles when mysql-server 4.0 - was previously installed (thanks to Olaf van der Spek). Closes: #289851 - * Fixed typo in README.Debian (thanks to Mark Nipper). Closes: #289131 - * Changed max_allowed_packet in my.cnf to 16M as in 4.0.x (thanks to - Olaf van der Spek). Closes: #289840 - * Updated French debconf translation (thanks to Christian Perrier). - Closes: #287955 - - -- Christian Hammers Thu, 13 Jan 2005 01:29:05 +0100 - -mysql-dfsg-4.1 (4.1.8a-4) unstable; urgency=low - - * Broken patch again :-( - - -- Christian Hammers Sun, 9 Jan 2005 23:47:55 +0100 - -mysql-dfsg-4.1 (4.1.8a-3) unstable; urgency=low - - * The mutex patch was a bit too x86 centric. This broke the alpha build. - - -- Christian Hammers Sun, 9 Jan 2005 14:18:49 +0100 - -mysql-dfsg-4.1 (4.1.8a-2) unstable; urgency=medium - - * Some Makefiles that were patched by me got overwritten by the GNU - autotools, probably because I also patched ./configure. Fixed now, - the critical mutex patch is now back in again. Closes: #286961 - * Added patch to make MySQL compile on ARM (thanks to Adam Majer). - Closes: #285071 - - -- Christian Hammers Thu, 6 Jan 2005 09:30:13 +0100 - -mysql-dfsg-4.1 (4.1.8a-1) unstable; urgency=medium - - * Upstream 4.1.8 had some problems in their GNU Autotools files so they - released 4.1.8a. Debian's 4.1.8 was fixed by running autoreconf but this - again overwrote MySQL changes to ltmain.sh which are supposed to fix some - problems on uncommon architectures (maybe the FTBFS on alpha, arm, m68k - and sparc?). - * libmysqlclient_r.so.14 from 4.1.8-3 also missed a link dependency to - libz which lead to unresolved symbols visible with "ldd -r" (thanks - to Laurent Bonnaud). Closes: #287573 - - -- Christian Hammers Wed, 29 Dec 2004 14:26:33 +0100 - -mysql-dfsg-4.1 (4.1.8-3) unstable; urgency=low - - * Fixed checking for error messages by forcing english language - output by adding LC_ALL=C to debian-start (thanks to Rene - Konasz) Closes: #285709 - * Fixed bashisms in Debian scripts. Closes: #286863 - * Updated Japanese Debconf translation (thanks to Hideki Yamane). - Closes: #287003 - * Improved 4.0 to 4.1 upgrade if /var/lib/mysql is a symlink - (thanks to Thomas Lamy). Closes: #286560 - * Added patch for FTBFS problem where no LinuxThreads can be found. - I don't know if this still applies but it should not hurt. - The patch is debian/patches/configure__AMD64-LinuxThreads-vs-NPTL.diff - - -- Christian Hammers Sun, 26 Dec 2004 14:04:20 +0100 - -mysql-dfsg-4.1 (4.1.8-2) unstable; urgency=low - - * If /var/lib/mysql is a symlink then it is kept as such. - * Added the old-passwords option to the default my.cnf to stay - compatible to clients that are still compiled to libmysqlclient10 - and libmysqlclient12 for licence reasons. - * Adjusted tetex build-deps to ease backporting (thanks to Norbert - Tretkowski from backports.org). - - -- Christian Hammers Tue, 21 Dec 2004 01:00:27 +0100 - -mysql-dfsg-4.1 (4.1.8-1) unstable; urgency=medium - - * New upstream version. Closes: #286175 - * Added conflict to libmysqlclient-dev (thanks to Adam Majer). - Closes: #286538 - * Added debconf-updatepo to debian/rules:clean. - * Updated Japanese Debconf translation (thanks to Hideki Yamane). - Closes: #285107 - * Updated French Debconf translation (thanks to Christian Perrier). - Closes: #285977 - * Renamed cz.po to cs.po (thanks to Miroslav Kure). Closes: #285438 - * Aplied patch for changed server notice to debian-start (thanks to - Adam Majer). Closes: #286035 - * Changed nice value in default my.cnf as nohup changed its behaviour - (thanks to Dariush Pietrzak). Closes: #285446 - * Increased verbosity of preinst script in cases where it cannot stop - a running server (thanks to Jan Minar). Closes: #285982 - * Splitted the code parts of /etc/mysql/debian-start to - /usr/share/mysql/debian-start.inc.sh (thanks to Jan Minar). - Closes: #285988 - - -- Christian Hammers Mon, 20 Dec 2004 00:33:21 +0100 - -mysql-dfsg-4.1 (4.1.7-4) unstable; urgency=medium - - * Removed OpenSSL support. - After a short discussion with MySQL, I decided to drop OpenSSL support as - 1. MySQL started shipping their binaries without it, too and do not - seem to support it in favour of using a different library somewhen. - 2. MySQL did not adjust their licence to grant permission to link - against OpenSSL. - 3. Even if they did, third parties who use libmysqlclient.so often - do not realise licencing problems or even do not want OpenSSL. - (thanks to Jordi Mallach and the responders to MySQL bug #6924) - Closes: #283786 - * debian/control: Improved depends and conflicts to mysql-4.0. - - -- Christian Hammers Thu, 2 Dec 2004 22:02:28 +0100 - -mysql-dfsg-4.1 (4.1.7-3) unstable; urgency=low - - * Raised version to make it higher as the one in experimental. - - -- Christian Hammers Wed, 1 Dec 2004 21:09:20 +0100 - -mysql-dfsg-4.1 (4.1.7-2) unstable; urgency=low - - * Patched scripts/mysql_install_db so that it no longer creates a - passwordless test database during installation (thanks to Patrick - Schnorbus). Closes: #281158 - * Added Czech debconf translation (thanks to Miroslav Kure). - Closes: #283222 - - -- Christian Hammers Wed, 1 Dec 2004 01:29:31 +0100 - -mysql-dfsg-4.1 (4.1.7-1) unstable; urgency=low - - * New upstream branch! - * Adjusted debian/control to make this package suitable to get parallel - to version 4.0.x into unstable and sarge. The package names are - different so that "mysql-server" still defaults to the rock-stable - 4.0 instead to this announced-to-be-stable 4.1. - * Added --with-mutex=i86/gcc-assemler to the Berkeley-DB configure - to prevent the use of NPLT threads when compiling under kernel 2.6 - because the binaries are else not runable on kernel 2.4 hosts. - Closes: #278638, #274598 - - -- Christian Hammers Sun, 31 Oct 2004 20:15:03 +0100 - -mysql-dfsg (4.1.6-1) experimental; urgency=low - - * New upstream version. - * Fixed symlinks in libmysqlclient-dev package. Closes: #277028 - * This time I did not update the libtool files as they were pretty - up to date and I want to have a shorter diff file. - - -- Christian Hammers Wed, 20 Oct 2004 00:07:58 +0200 - -mysql-dfsg (4.1.5-3) experimental; urgency=low - - * debian/postinst: mysql_install_db changed parameter from --IN-RPM - to --rpm which caused problems during installs. Closes: #276320 - - -- Christian Hammers Sat, 16 Oct 2004 20:36:46 +0200 - -mysql-dfsg (4.1.5-2) experimental; urgency=low - - * Activated support for ndb clustering (thanks to Kevin M. Rosenberg). - Closes: #275109 - - -- Christian Hammers Wed, 6 Oct 2004 01:58:00 +0200 - -mysql-dfsg (4.1.5-1) experimental; urgency=low - - * WARNING: - The upstream branch 4.1 is still considered BETA. - The Debian packages for 4.1 were done without big testing. If you miss - a new functionality or binary, contact me and I check add the relevant - configure option or include the program. - * New MAJOR upstream version. - Thanks to the great demand here's now the first MySQL 4.1 experimental - release. FEEDBACK IS WELCOME. - * 4.0->4.1 notes: - - debian/patches/alpha.diff could not be applied, I fix that later - - debian/patches/scripts__mysql_install_db.sh.diff was obsolete - - debian/patches/scripts__Makefile.in was neccessary due to a dependency - to the removed non-free Docs/ directory. Upstream has been contacted. - - Build-Deps: += automake1.7 - - debian/rules: embedded servers examples did not compile, removed - - -- Christian Hammers Sun, 26 Sep 2004 19:46:47 +0200 - -mysql-dfsg (4.0.21-3) unstable; urgency=low - - * Upstream tried to fix a security bug in mysqlhotcopy and broke it :-) - Applied a patch (see debian/patches) from Martin Pitt. Closes: #271632 - * Between 4.0.20 and 4.0.21 the Debian specific changes in - /usr/bin/mysqld_safe that piped the error log to syslog got lost - and are now back again. - * Fixed capitalization in debconf headings. - * Changed wording of the initscript status message to make heartbeat - happier. Closes: #271591 - - -- Christian Hammers Fri, 17 Sep 2004 18:42:25 +0200 - -mysql-dfsg (4.0.21-2) unstable; urgency=medium - - * The dependencies between mysql-client and libmysqlclient12 were - too loose, when upgrading only the client this can lead to non working - binaries due to relocation errors (thanks to Dominic Cleal). - Closes: #271803 - * Fixed typo in mysqldump.1 manpage (thanks to Nicolas Francois). - Closes: #271334 - - -- Christian Hammers Wed, 15 Sep 2004 15:38:11 +0200 - -mysql-dfsg (4.0.21-1) unstable; urgency=high - - * SECURITY: - This upstream version fixes some security problems that might at least - allow a DoS attack on the server. - * Fixed an old bug in concurrent accesses to `MERGE' tables (even - one `MERGE' table and `MyISAM' tables), that could've resulted in - a crash or hang of the server. (Bug #2408) - * Fixed bug in privilege checking where, under some conditions, one - was able to grant privileges on the database, he has no privileges - on. (Bug #3933) - * Fixed crash in `MATCH ... AGAINST()' on a phrase search operator - with a missing closing double quote. (Bug #3870) - * Fixed potential memory overrun in `mysql_real_connect()' (which - required a compromised DNS server and certain operating systems). - (Bug #4017) - * New upstream version. - * Fixes bug that made x="foo" in WHERE sometimes the same as x="foo ". - Closes: #211618 - * Updated Japanese Debconf translation (thanks to Hideki Yamane). - Closes: #271097 - - -- Christian Hammers Sat, 11 Sep 2004 23:15:44 +0200 - -mysql-dfsg (4.0.20-14) unstable; urgency=low - - * Dave Rolsky spottet that -DBIG_JOINS was not properly enabled. - It allowes joining 64 instead of an 32 tables to join. - - -- Christian Hammers Thu, 9 Sep 2004 20:24:02 +0200 - -mysql-dfsg (4.0.20-13) unstable; urgency=medium - - * Fixed a bug in the initscript which caused the check for not properly - closed i.e. corrupt tables that is executed when the server starts - not to run in background as supposed. - Although the check does not repair anything on servers with several - thousand tables the script was reported to take some minutes which - is quite annoying. (Thanks to Jakob Goldbach). Closes: #270800 - - -- Christian Hammers Thu, 9 Sep 2004 17:11:05 +0200 - -mysql-dfsg (4.0.20-12) unstable; urgency=medium - - * Filter messages regarding table handles that do not support CHECK TABLE - in the script that checks for corrupted tables on every start which lead - to unnecessary mails (thanks to David Everly). Closes: #269811 - * Added a note to the corrupt-table-check mail which notes that a - false-positive is reported in the case that immediately after starting - the server a client starts using a table (thanks to Uwe Kappe). - Closes: #269985 - * Added "quote-names" as default to the [mysqldump] section in - /etc/mysql/my.cnf as too many users stumble over dump files that - could not be read in again due to the valid use of reserved words - as table names. This has also be done by upstream in 4.1.1 and has - no known drawbacks. Closes: #269865 - * Binary logs can now be rotated as well. Defaults to off, though, for - compatibilty reasons (thanks to Mark Ferlatte). Closes: #94230, #269110 - * The mysql user "debian-sys-maint" now gets all possible rights which - makes binary logging possible and helps other package maintainer who - wants to use it to create package specific databases and users. - * Added example how to change daemon nice level via /etc/mysql/my.cnf - * Updated French debconf translations (thanks to Christian Perrier). - Closes: #265811 - * Renamed options in the default config file that still had old names - (thanks to Yves Kreis). Closes: #266445 - * Fixed spelling in debconf note. - * Added -l and -L to dh_shlibdeps. - - -- Christian Hammers Fri, 3 Sep 2004 20:10:46 +0200 - -mysql-dfsg (4.0.20-11) unstable; urgency=high - - * SECURITY - This version fixes a security flaw in mysqlhotcopy which created - temporary files in /tmp which had predictable filenames and such - could be used for a tempfile run attack. - The issue has been recorded as CAN-2004-0457. - - -- Christian Hammers Sat, 14 Aug 2004 18:27:19 +0200 - -mysql-dfsg (4.0.20-10) unstable; urgency=low - - * MySQL finally updated their copyright page and installed v1.5 of - the "Free/Libre and Open Source Software License (FLOSS) - Exception" - which will hopefully end the license hell they created by putting the - client libraries under GPL instead of LGPL which conflicts with PHP and - other software that used to link against MySQL. - The license text is not yet in any release MySQL version but visible - on their web site and copied into the debian/copyright file. - Special thanks to Zak Greant and the debian-legal list - for helping to solve this release critical problem. - Closes: #242449 - * Updated Brazil debconf translation (thanks to Andre Luis Lopes). - Closes: #264233 - * Updated Japanese debconf translation (thanks to Hideki Yamane). - Closes: #264620 - * Fixed minor typo in debconf description (thanks to TROJETTE Mohammed - Adnene). Closes: #264840 - * Improved init and preinst script which now detects stalled servers which - do no longer communicate but are present in the process list (thanks to - Henrik Johansson). Closes: #263215 - - -- Christian Hammers Mon, 9 Aug 2004 19:44:28 +0200 - -mysql-dfsg (4.0.20-9) unstable; urgency=medium - - * Partly reverted the last patch which gave the mysql-user - "debian-sys-maint" more rights as there are old versions of MySQL which - have fewer privlige columns. Now only those are set (thanks to Alan Tam). - Closes: #263111 - - -- Christian Hammers Tue, 3 Aug 2004 13:03:02 +0200 - -mysql-dfsg (4.0.20-8) unstable; urgency=low - - * The mysqlcheck that is started from the initscript will now be - backgrounded because it might else prevent the boot process to continue. - It also now notifies root by mail and syslog if a table is corrupt. - * The "debian-sys-maint" MySQL user now has almost full rights so that other - packages might use this account to create databases and user (thanks to - Andreas Barth). Closes: #262541 - * Added paranoid rules for logcheck. - - -- Christian Hammers Sun, 1 Aug 2004 21:00:55 +0200 - -mysql-dfsg (4.0.20-8) unstable; urgency=low - - * Upload stalled. Not released. - - -- Christian Hammers Sun, 1 Aug 2004 20:27:55 +0200 - -mysql-dfsg (4.0.20-7) unstable; urgency=medium - - * Solved the upstream bug that error messages of the server are written - in a file that is then rotated away leaving mysqld logging effectively - to /dev/null. It now logs to a /usr/bin/logger process which puts the - messages into the syslog. - Modified files: /etc/init.d/mysql, /usr/bin/mysqld_safe and the - logchecker files. Closes: #254070 - * The initscript does no longer call mysqlcheck directly but via - /etc/mysql/debian-start which is a user customizable config script. - * Splitted the debconf "install and update notes" and only show them - when it is appropriate (thanks to Steve Langasek). Closes: #240515 - * Added NEWS.Debian. - * Added hint to -DBIG_ROWS, which is currently not used, to README.Debian. - * Corrected typo in myisampack manpage (thanks to Marc Lehmann). - Closes: #207090 - * Added Catalan debconf translation (thanks to Aleix Badia i Bosch). - Closes: #236651 - - -- Christian Hammers Wed, 28 Jul 2004 01:41:51 +0200 - -mysql-dfsg (4.0.20-6) unstable; urgency=low - - * The build arch detected by configure was "pc-linux-gnu (i686)" - instead of "pc-linux-gnu (i386)". Was no problem AFAIK but - Adam Majer asked me to explicitly change it to i386. Closes: #261382 - * Removed some unused shell scripts from /usr/share/mysql. - * Added lintian overrides. - * Removed rpath by using chrpath. - - -- Christian Hammers Mon, 26 Jul 2004 00:17:12 +0200 - -mysql-dfsg (4.0.20-5) unstable; urgency=medium - - * The mysqlcheck in the init script is only called when the server - is really alive. Also, the mysql-user 'debian-sys-maint' now has - global select rights (thanks to Nathan Poznick). Closes: #261130 - * Moved the debconf question whether to remove the databases or not - from mysql-server.config to mysql-server.postrm so that it shows - up on purge time and not months earlier (thanks to Wouter Verhelst). - Closes: #251838 - - -- Christian Hammers Fri, 23 Jul 2004 22:41:13 +0200 - -mysql-dfsg (4.0.20-4) unstable; urgency=low - - * Added a "mysqlcheck -A --fast" to the 'start' section of the - init script to help admins detect corrupt tables after a server crash. - Currently it exists with an error message but leaves the server - running. Feedback appreciated! - * Made postinst script more robust by calling db_stop earlier and - so prevent pipe-deadlocks. - * Fixed minor typos in initscript (thanks to "C.Y.M."). Closes: 259518 - * Added the undocumented "-DBIG_JOINS" that MySQL apparently uses in - their MAX binaries. It enables 62 instead of 30 tables in a "join". - (thanks to Dave Rolsky). Closes: #260843 - * Added a "df --portability /var/lib/mysql/." check to the preinst - script as users experienced hard to kill hanging mysqlds in such - a situation (thanks to Vaidas Pilkauskas). Closes: #260306 - - -- Christian Hammers Fri, 23 Jul 2004 00:51:32 +0200 - -mysql-dfsg (4.0.20-3) unstable; urgency=low - - * Improved tolerance if the init script has been deleted (thanks to - Leonid Shulov for spotting the problem). - * Minor wording changes to README.Debian generalizing /root/ by $HOME - (thanks to Santiago Vila). Closes: #257725 - * Added Japanese debconf translation (thanks to Hideki Yamane). - Closes: #256485 - * Fixed commend in my.cnf regarding logfile directory (thanks to Jayen - Ashar). Closes: #253434 - * Correted "ease to" by "ease of" in package description (thanks to - Johannes Berg). Closes: #253510 - - -- Christian Hammers Fri, 9 Jul 2004 00:57:42 +0200 - -mysql-dfsg (4.0.20-2) unstable; urgency=low - - * Removed RPM .spec file from the included documentation as it is pretty - useless (thanks to Loic Minier). - * Added turkish debconf translation (thanks to Recai Oktas). Closes: #252802 - - -- Christian Hammers Sun, 6 Jun 2004 14:48:26 +0200 - -mysql-dfsg (4.0.20-1) unstable; urgency=low - - * New upstream version. - - -- Christian Hammers Mon, 31 May 2004 23:36:39 +0200 - -mysql-dfsg (4.0.18-8) unstable; urgency=low - - * Updated french translation (thanks to Christian Perrier). Closes: #246789 - - -- Christian Hammers Tue, 4 May 2004 23:26:54 +0200 - -mysql-dfsg (4.0.18-7) unstable; urgency=low - - * Added CVE ids for the recent security fixes. - 4.0.18-4 is CAN-2004-0381 (mysqlbug) and - 4.0.18-6 is CAN-2004-0388 (mysql_multi) - - -- Christian Hammers Mon, 19 Apr 2004 18:32:03 +0200 - -mysql-dfsg (4.0.18-6) unstable; urgency=medium - - * SECURITY: - Fixed minor tempfile-run security problem in mysqld_multi. - Unprivileged users could create symlinks to files which were then - unknowingly overwritten by run when this script gets executed. - Upstream informed. Thanks to Martin Schulze for finding this. - - -- Christian Hammers Wed, 7 Apr 2004 01:28:22 +0200 - -mysql-dfsg (4.0.18-5) unstable; urgency=low - - * Little improvements in debian scripts for last upload. - * Added check to logrotate script for the case that a mysql - server is running but not be accessible with the username and - password from /etc/mysql/debian.conf (thanks to Jeffrey W. Baker). - Closes: 239421 - - -- Christian Hammers Sun, 4 Apr 2004 15:27:40 +0200 - -mysql-dfsg (4.0.18-4) unstable; urgency=medium - - * SECURITY: - Aplied fix for unprobable tempfile-symlink security problem in - mysqlbug reported by Shaun Colley on bugtraq on 2004-03-24. - * Updated french debconf translation (thanks to Christian Perrier). - Closes: #236878 - * Updated portugesian debconf translation (thanks to Nuno Senica). - Closes: #239168 - * Updated german debconf translation (thanks to Alwin Meschede). - Closes: #241749 - * Improved debconf template regarding fix_privileges_tables (thanks - to Matt Zimmermann for suggestions). Closes: #219400 - * Improved README.Debian regarding to password settings (thanks to - Yann Dirson). Closes: #241328 - - -- Christian Hammers Sat, 3 Apr 2004 19:52:15 +0200 - -mysql-dfsg (4.0.18-3) unstable; urgency=medium - - * Added Build-Depend to po-debconf to let it build everywhere. - - -- Christian Hammers Wed, 31 Mar 2004 23:43:33 +0200 - -mysql-dfsg (4.0.18-2) unstable; urgency=low - - * Added a "2>/dev/null" to a "which" command as there are two - "which" versions in Debian of which one needs it. Closes: #235363 - - -- Christian Hammers Tue, 2 Mar 2004 23:31:28 +0100 - -mysql-dfsg (4.0.18-1) unstable; urgency=low - - * New upstream version. - * Should now compile and run on ia64 (thanks to Thorsten Werner and - David Mosberger-Tang). Closes: #226863 #228834 - * Converted init scripts to invoce-rc.d (thanks to Erich Schubert). - Closes: 232118 - * Secondlast upload changed logfile location. Closes: #182655 - * Updated Brasilian translation (thanks to Andre Luis Lopes). Closes: - #219847 - - -- Christian Hammers Tue, 17 Feb 2004 23:44:58 +0100 - -mysql-dfsg (4.0.17-2) unstable; urgency=low - - * Improved manpage for mysqldumpslow.1 (thanks to Anthony DeRobertis). - Closes: #231039 - * Improved stopping of crashed daemons in init script (thanks to - Matthias Urlichs). Closes: #230327 - - -- Christian Hammers Mon, 9 Feb 2004 21:54:29 +0100 - -mysql-dfsg (4.0.17-1) unstable; urgency=low - - * Made logging into /var/log/mysql/ the default. Closes: #225206 - - * New upstream version. Closes: #225028 - * Turned on a 25MB query cache by default (thanks to Cyril Bouthors). - Closes: #226789 - * Updated russian translation (thanks to Ilgiz Kalmetev). Closes: #219263 - * Upstream fixes the problem that AND was not commutative (thanks for - Iain D Broadfoot for mentioning). Closes: #227927 - * Fixed minor typo in my.cnf comments (thanks to James Renken). - Closes: #221496 - * Better documents regex. Closes: #214952 - * Fixed minor germanism in debconf template (thanks to Marc Haber). - Closes: #224148 - * Added explaining comment to my.cnf regarding quoted passwords - (Thanks to Patrick von der Hagen). Closes: #224906 - * Changed "find -exec" to "find -print0 | xargs -0" in preinst to - speed it up. Thanks to Cyril Bouthors. Closes: #220229 - - -- Christian Hammers Sun, 18 Jan 2004 16:16:25 +0100 - -mysql-dfsg (4.0.16-2) unstable; urgency=low - - * Tried to repair undefined weak symbols by adding a little Makefile - patch. Closes: #215973 - - -- Christian Hammers Mon, 27 Oct 2003 22:52:10 +0100 - -mysql-dfsg (4.0.16-1) unstable; urgency=low - - * New upstream release. - (Mostly little memory problems and other bugfixes it seems) - * Replaced "." by ":" in chown calls to comply with the env setting - "_POSIX2_VERSION=2000112" (thanks to Robert Luberda). Closes: #217399 - * Adjusted syntax in my.cnf to 4.x standard (thanks to Guillaume Plessis). - Closes: #217273 - * Improved README.Debian password instructions (thanks to Levi Waldron). - Closes: #215046 - * Improved NIS warning debconf-template (thanks to Jeff Breidenbach). - Closes: #215791 - * Explicitly added libssl-dev to the libmysqlclient-dev package as it - is needed for mysql_config and the libmysqlclient package only depends - on libssl which has no unnumbered .so version (thanks to Simon Peter - and Davor Ocelic). Closes: #214436, #216162 - * Added "-lwrap" to "mysql_config --libmysqld-libs" and filed it as - upstream bug #1650 (thanks to Noah Levitt). Closes: #214636 - - -- Christian Hammers Sat, 25 Oct 2003 01:09:27 +0200 - -mysql-dfsg (4.0.15a-1) unstable; urgency=low - - * Same package as 4.0.15-2 but I could not convince the Debian - installer to move the packages out of incoming. - - -- Christian Hammers Tue, 7 Oct 2003 15:10:26 +0200 - -mysql-dfsg (4.0.15-2) unstable; urgency=low - - * Updated package description (thanks to Adrian Bunk). Closes: #210988 - * Fixed small typos in manpages (thanks to Nicolas Francois). - Closes: #211983 - * More updates to package description (thanks to Matthias Lutz/ddtp). - Closes: #213456 - * Updated standards to 3.6.1. - * Closes "new 4.0.15 available" bug. Closes: #213349 - * Updated README.Debian with notes regarding the MySQL manual section - "2.4 Post-installation Setup and Testing" (thanks to Daniel B.). - Closes: #210841 - - -- Christian Hammers Fri, 3 Oct 2003 15:59:39 +0200 - -mysql-dfsg (4.0.15-1) unstable; urgency=high - - * SECURITY: - Users who are able to use the "ALTER TABLE" command on the "mysql" - database may be able to exploit this vulnerability to gain a shell with - the privileges of the mysql server (usually running as the 'mysql' user). - Closes: #210403 - * Fixes small description typos (thanks to Oscar Jarkvik). - * Updated Brazilian Portuguese debconf translation. (thanks to Andre Luis - Lopes). Closes: 208030 - * Replaced depricated '.' by ':' in chown (thanks to Matt Zimmerman). - * Fixed manpage typo (thanks to Marc Lehmann). Closes: #207090 - - -- Christian Hammers Fri, 3 Oct 2003 15:59:35 +0200 - -mysql-dfsg (4.0.14-1) unstable; urgency=low - - * New upstream version. - - -- Christian Hammers Sun, 24 Aug 2003 16:40:36 +0200 - -mysql-dfsg (4.0.13-3) unstable; urgency=low - - * Now start mysqld as default unless you choose not when configurig - with debconf priority low. So packages depending on the server when - installing can access it. Thanks Matt Zimmermann (Closes: #200277) - * Made mysql-server de-installable if the config and database files were - removed by hand before. Thanks to Ard van Breemen (Closes: #200304) - - -- Christian Hammers Tue, 8 Jul 2003 22:30:40 +0200 - -mysql-dfsg (4.0.13-2) unstable; urgency=low - - * Added "nice" option for mysqld_safe to give mysqld a different priority. - Submitted to upstream as MySQL Bug #627. Closes: #192087 - * Fixed possible unbound variable in init script. Closes: #194621 - * Fixed french debconf translation (thx Christian Perrier) Closes: #194739 - * Get rid of automake1.5 (for Eric Dorland). - - -- Christian Hammers Wed, 11 Jun 2003 18:58:32 +0200 - -mysql-dfsg (4.0.13-1) unstable; urgency=medium - - * New upstream version. - !!! Fixes a very bad natural join bug which justifies the urgency=medium. - !!! http://bugs.mysql.com/bug.php?id=291 - * Fixed mysql_fix_privileges manpage (Frederic Briere) Closes: #191776 - * preinst: "which" is more chatty normal executable than as builtin. - (Thanks to David B Harris). Closes: #188659 - - -- Christian Hammers Tue, 6 May 2003 22:03:45 +0200 - -mysql-dfsg (4.0.12-3) unstable; urgency=medium - - * Reincluded new way of creating my debian-sys-maint user from - an old release from experimental. Now works again with old - and new privilege table format. (Thanks to Vincent Danjean - for spotting the problem) Closes: #188201 - * Reincluded hurd build dependency fix from 3.23 branch. - (Thanks to Robert Millan). Closes: #185929 - * Fixed soname in libmysqlclient-dev. Closes: #188160 - * Remove /var/log/mysql/ when purging the package. Closes: #188064 - * Removed /usr/share/doc/mysql/ from mysql-server. Closes: #188066 - * Let group "adm" be able to read logfiles. Closes: #188067 - * Do not call usermod on every upgrade. Closes: #188248 - (Thanks to Philippe Troin for the last three) - * Fixed mysql-server.preinst so that it works on shells where - which is a builtin, too. (Thanks to Erich Schubert) Closes: #181525 - - -- Christian Hammers Fri, 11 Apr 2003 11:32:45 +0200 - -mysql-dfsg (4.0.12-2) unstable; urgency=low - - * - * NEW MAJOR UPSTREAM RELEASE: - * - MySQL 4 has finally been declared as 'stable'. Hurray! Read changelogs. - Thanks to all testers, esp. Jose Luis Tallon, of the versions - that were in the "experimental" section before. - * Modified postinst script to run mysql_fix_privileges on every update. - IMPORTANT: Please report if this breaks anything, it is not supposed to. - * Wrote a SSL-MINI-HOWTO.txt! - * Added zlib1g-dev to libmysqlclient12-dev. Closes: 186656 - * Changed section of libmysqlclient12-dev to libdevel. - * Added even more selfwritten manpages. - * Fixed typos. - - -- Christian Hammers Sun, 6 Apr 2003 13:47:32 +0200 - -mysql-dfsg (4.0.10.gamma-1) experimental; urgency=low - - * New upstream version. - * They merged some of my patches from debian/patches. Whoa! - * This release should fix the error-logfile problem where mysqld - keeps the error.log open while logrotate removes it. - - -- Christian Hammers Wed, 12 Feb 2003 22:39:48 +0100 - -mysql-dfsg (4.0.9.gamma-1) experimental; urgency=low - - * New upstream version. - * Updated the GNU autoconf files to make building on MIPS work. - See bug #176829. - - -- Christian Hammers Wed, 29 Jan 2003 22:07:44 +0100 - -mysql-dfsg (4.0.8.gamma-1) experimental; urgency=low - - * New upstream release. - * Improved logging of init script. Closes: #174790 - * We have now libmysqlclient.so.12 instead of .11. - - -- Christian Hammers Thu, 9 Jan 2003 20:14:11 +0100 - -mysql-dfsg (4.0.7.gamma-1) experimental; urgency=high - - * SECURITY: This version fixes an upstream security release that is only - present in the 4.x branch which is currently only in the - experimental distribution and therefore will not get a DSA. - * New upstream release. - - -- Christian Hammers Sat, 28 Dec 2002 15:51:39 +0100 - -mysql-dfsg (4.0.6.gamma-2) experimental; urgency=low - - * Added --system to addgroup. Closes: #173866 - - -- Christian Hammers Sat, 21 Dec 2002 15:28:26 +0100 - -mysql-dfsg (4.0.6.gamma-1) experimental; urgency=low - - * New upstream version. Now Gamma! - * There are no longer changes to the .orig.tar.gz neccessary to make diff - happy. docs/ has still to be deleted, although, as it is non-free. - * Incorporated patches from unstable. - * Added mysqlmanager and a couple of other new scripts. - * Enabled libmysqld embedded server library. - * Enabled SSL and Virtual-IO support. - (CORBA based MySQL-FS seems to be not existing..) - - -- Christian Hammers Fri, 20 Dec 2002 22:30:51 +0100 - -mysql-dfsg (4.0.5a.beta-3) experimental; urgency=low - - * Modified postinst to work with old and new mysql.user table format - and fixed spelling typo in postinst. Thanks to Roger Aich. - * Updated config.{guess,sub} to make the mipsel porters happy. - Thanks to Ryan Murray. Closes: #173553 - - -- Christian Hammers Wed, 18 Dec 2002 15:56:34 +0100 - -mysql-dfsg (4.0.5a.beta-2) experimental; urgency=low - - * Upstream removed option "--skip-gemini". So did I. Closes: 173142 - - -- Christian Hammers Tue, 17 Dec 2002 10:35:49 +0100 - -mysql-dfsg (4.0.5a.beta-1) experimental; urgency=low - - * First 4.x experimental package due to continuous user requests :-) - Please test and report! - * upstream: safe_mysqld has been renamed to mysqld_safe - * upstream: new library soname version libmysqlclient.so.11 - * Renamed libmysqlclientXX-dev to libmysqlclient-dev as I don't plan to - support more than one development environment and this makes the - dependencies easier. - * FIXME: Skipped parts of the debian/patches/alpha patch as the global.h - is not existing. - * FIXME: How to get rid this? Old ltconfig patch already applied. - "lintian: binary-or-shlib-defines-rpath ./usr/bin/mysql /usr/lib/mysql" - - -- Christian Hammers Sun, 1 Dec 2002 18:32:32 +0100 - -mysql-dfsg (3.23.53-4) unstable; urgency=medium - - * Fixed errno.h problem. Closes: #168533, #168535 - - -- Christian Hammers Sun, 10 Nov 2002 18:32:08 +0100 - -mysql-dfsg (3.23.53-3) unstable; urgency=medium - - * Changed automake build-dep to unversioned automake1.4. Closes: #166391 - * Fixed description. Closes: #167270 - (Thanks to Soren Boll Overgaard) - - -- Christian Hammers Tue, 5 Nov 2002 01:25:01 +0100 - -mysql-dfsg (3.23.53-2) unstable; urgency=low - - * Reverted user creation in init scripts. Closes: #166432 - (Thanks to Birzan George Cristian) - - -- Christian Hammers Thu, 31 Oct 2002 15:36:25 +0100 - -mysql-dfsg (3.23.53-1) unstable; urgency=low - - * New upstream release. - - -- Christian Hammers Thu, 24 Oct 2002 23:04:16 +0200 - -mysql-dfsg (3.23.52-3) unstable; urgency=low - - * Substituted the first-install 'debian-sys-maint' user creation by - something ANSI SQL compliant. Closes: #163497 - (Thanks to Karl Hammar) - * Tightend dependency to debhelper (>= 4.0.12) to be sure that - debconf-utils gets installed, too, as I use dh_installdebconf. - * Fixed upstream manpage bug in mysqldump.1. Closes: #159779 - (Thanks to Colin Watson) - * Added comment about MIN_WORD_LEN to mysql-server.README.Debian - (Thanks to Philipp Dreimann) - * Added a dependency for zlib1g-dev to libmysqlclient10-dev. - (Thanks to Jordi Mallach) - - -- Christian Hammers Sun, 15 Sep 2002 17:14:44 +0200 - -mysql-dfsg (3.23.52-2) unstable; urgency=low - - * Fixed typo in preinst scripts. - * Removed bashism in init script. - * Fixed ambiguous debconf example. Closes: #158884 - - -- Christian Hammers Fri, 30 Aug 2002 00:51:29 +0200 - -mysql-dfsg (3.23.52-1) unstable; urgency=low - - * New upstream version. Closes: #157731 - * Clearified the meaning of the debian-sys-maint special user in the - README.Debian file. Closes: #153702 - * Wrote some words regarding the skip-networking in README.Debian. - Closes: #157038 - * Added dependency to passwd. - * Fixes typo and unnecessarily complication in is_mysql_alive(). - * Added check for /etc/mysql/my.cnf in init script. - - -- Christian Hammers Tue, 27 Aug 2002 01:53:32 +0200 - -mysql-dfsg (3.23.51-4) unstable; urgency=low - - * Added a compressed "nm mysqld" output to allow people to trace - core dumps with /usr/bin/resolve_stack_dump as suggested in the - INSTALL-SOURCE file. Thanks to atudor@labs.agilent.com for the hint. - - -- Christian Hammers Wed, 24 Jul 2002 20:44:55 +0200 - -mysql-dfsg (3.23.51-3) unstable; urgency=low - - * Corrected copyright file: the MySQL client library is licenced under - the LGPL-2 not the GPL. From version 4.x it actually will be GPL this - is why parts of http://www.mysql.com/ already say so. Closes: #153591 - * Corrected german translation. - Thanks to Roland Rosenfeld . Closes: #151903 - - -- Christian Hammers Thu, 11 Jul 2002 20:32:28 +0200 - -mysql-dfsg (3.23.51-2) unstable; urgency=low - - * Improved NIS tolerance in preinst script. - - -- Christian Hammers Sun, 7 Jul 2002 04:43:28 +0200 - -mysql-dfsg (3.23.51-1) unstable; urgency=medium - - * New upstream version. - * I applied a patch that fixes a binary imcompatibility in - the shared libary libmysqlclient.so.10 between 3.23.50 and - some versions earlier. Upstream has been contacted and asked - for clarification. Closes: #149952 - * Added support for NIS i.e. it shows a warning and fails if the - needed 'mysql' user does not exists but works if it does. - Closes: #143282, #147869 - * Substituted $0 in init scripts by something really weird so that - "./S20mysql restart" works now, too. (BTW: S20? install file-rc!!!) - Closes: #148658 - * Now postinst works even if /etc/init.d/mysql is removed. Closes: #151021 - * Decided to leave "set +x" in postinst but wrote comment. Closes: #151022 - - -- Christian Hammers Sun, 7 Jul 2002 04:43:25 +0200 - -mysql-dfsg (3.23.50-1) unstable; urgency=medium - - * New upstream version. - Fixes a very annoying and important bug that lets all mysql programs - including perl scripts etc. segfault when using the read_default_group() - function. 3.23.50 is currently a pre-release and expected to be released - next week. I plan to propose it for woody as soon as its stability has - been proven. The following bug reports are all regarding this issue. - Closes: #144960, #145322, #136798, #138143, - - -- Christian Hammers Sat, 18 May 2002 21:14:01 +0200 - -mysql-dfsg (3.23.49x-1) unstable; urgency=low - - * I had to split the package to seperate the manual as it is not GPL - like the rest of the software and docs but under a license that - e.g. forbids selling printed versions. - . - The upstream authors were contacted a while ago but did not like to - change the situation. - . - The names of the resulting packages have not changed as the manual - already was in a seperate mysql-doc package due to it's size. - The source packages are now splitted from one "mysql" to - "mysql-dfsg" in main and "mysql-nonfree" in non-free. - * No code change! - The "x" at the end of the version number ist just to be able to - upload a new source package. ("a" was already taken by upstream - for their binary upload correction) - - -- Christian Hammers Wed, 8 May 2002 02:01:41 +0200 - -mysql (3.23.49-8) unstable; urgency=low - - * Substituted $0 in init script to let e.g. "/etc# ./init.d/mysql restart" - works, too. Closes: #141555 - - -- Christian Hammers Sun, 7 Apr 2002 15:00:44 +0200 - -mysql (3.23.49-7) unstable; urgency=low - - * The Makefiles are totally broken for the --enable-local-infile - option. I now patched libmysql/libmysql.c#mysql_init() manually. - Closes: #138347 - - -- Christian Hammers Fri, 29 Mar 2002 23:55:15 +0100 - -mysql (3.23.49-6) unstable; urgency=low - - * Moved mysqlcheck from server to client package. Closes: #139799 - * Added manpage for mysqlhotcopy. Regarding: #87097 - * Added 'sharedscripts' directive to the logrotate script. - * Replaced grep by /usr/bin/getent to let the group/user checking work - on NIS/LDAP systems, too. Closes: #115677, #101529 - - -- Christian Hammers Fri, 22 Mar 2002 22:40:51 +0100 - -mysql (3.23.49-5) unstable; urgency=low - - * Added skip-innodb to default my.cnf. - * Enabled --enable-local-infile, it seems to be a new option that - defaults to disable a formerly enabled feaure. Closes: #137115 - - -- Christian Hammers Sat, 16 Mar 2002 00:29:10 +0100 - -mysql (3.23.49-4) unstable; urgency=medium - - * Recompiled against fixed libz. - - * Enabled --enable-local-infile, it seems to be a new option that - defaults to disable a formerly enabled feaure. Closes: #137115 - * Fixed README.compile_on_potato. Closes: #136529 - * Now a ext3 .jounal file in /var/lib/mysql does not prevent the - installation (happens when creating a jounal on an already mounted - partition). Closes: #137146 - - -- Christian Hammers Wed, 13 Mar 2002 13:34:24 +0100 - -mysql (3.23.49-3) unstable; urgency=low - - * Added Russian translation. Closes: #135846 - * Fixed installation of .info documents. Closes: #135030 - - -- Christian Hammers Wed, 27 Feb 2002 23:36:35 +0100 - -mysql (3.23.49-2) unstable; urgency=low - - * Updated french translation and split template files. Closes: #134754 - * Fixed a small debian.cnf related bug in mysql-server.postinst. - - -- Christian Hammers Tue, 19 Feb 2002 23:13:58 +0100 - -mysql (3.23.49-1) unstable; urgency=low - - * New upstream release. - (Mainly InnoDB related fixes) - * Exported a $HOME variable in the scripts so that /root/.my.cnf - is not read anymore. This will avoid problems when admins put - only passwords but no usernames in this file. Closes: #132048 - * New debian-sys-maint password algorithm (now ~96bit :-)) Closes: #133863 - * Recreating debian-sys-main pwd on every install to help people who - accidently delete user or password files... - * Added /var/log/mysql so that user can put the binary logs in there as - mysql cannot write the .001 etc files itself in /var/log which is - owned by root. - - -- Christian Hammers Thu, 14 Feb 2002 22:17:45 +0100 - -mysql (3.23.47-6) unstable; urgency=low - - * Dropped a sentence about the new debian-sys-maint user in the - debconf note and updated the README.Debian. Related: #132048 - * Added more french translation. Closes: #132390 - - -- Christian Hammers Wed, 6 Feb 2002 09:41:29 +0100 - -mysql (3.23.47-5) unstable; urgency=low - - * Fixed grammar error in template. Closes: #132238 - * Really fixed typo in logrotate script. Closes: #131711 - - -- Christian Hammers Tue, 5 Feb 2002 14:20:08 +0100 - -mysql (3.23.47-4) unstable; urgency=medium - - * Fixes typo in postinst that let init script fail. Closes: #131743 - * Fixed bashism bug that failed on ash. Closes: #131697 - * Fixed typo in logrotate script. Closes: #131711 - - -- Christian Hammers Thu, 31 Jan 2002 23:58:46 +0100 - -mysql (3.23.47-3) unstable; urgency=low - - * Added new Debian specific mysql user called 'debian-sys-maint' which - is used for pinging the server status, flushing the logs or shutting - down the server in maintenance scripts. The credentials of this user - are stored in the UID0-only readable file /etc/mysql/debian.cnf. - Closes: #129887, #130326, #99274 - * Fixed unintended server startup at boottime. Closes: #122676, #130105 - * New upstream fixes command line parsing bug: Closes: #128473 - * Fixed manpage headers to let apropos work: Closes: #119122 - * Added "status" options for /etc/init.d/mysql. Closes: #129020 - - -- Christian Hammers Sun, 27 Jan 2002 19:46:11 +0100 - -mysql (3.23.47-2) unstable; urgency=low - - * Enhanced init scripts by using mysqladmin instead of kill $pid. - Thanks to Aaron Brick. - - -- Christian Hammers Fri, 18 Jan 2002 01:42:23 +0100 - -mysql (3.23.47-1) unstable; urgency=low - - * New upstream release. - * Updated brazilian translation of debconf descriptions. Closes: #123332 - - -- Christian Hammers Sun, 6 Jan 2002 21:11:17 +0100 - -mysql (3.23.46-3) unstable; urgency=low - - * Fixed bug in postinst where a script was accidently called with - "bash -c