diff -r fe944d2c6e1f innobase/btr/btr0btr.c --- a/innobase/btr/btr0btr.c Mon Nov 10 19:47:27 2008 -0800 +++ b/innobase/btr/btr0btr.c Mon Nov 10 19:48:24 2008 -0800 @@ -2989,3 +2989,11 @@ return(TRUE); } + +dulint +btr_page_get_index_id_noninline( +/*============*/ + page_t* page) /* in: index page */ +{ + return btr_page_get_index_id(page); +} diff -r fe944d2c6e1f innobase/buf/buf0buf.c --- a/innobase/buf/buf0buf.c Mon Nov 10 19:47:27 2008 -0800 +++ b/innobase/buf/buf0buf.c Mon Nov 10 19:48:24 2008 -0800 @@ -2629,3 +2629,13 @@ buf_block_print(block); } +buf_block_t* +buf_pool_get_nth_block_no_inline( +/*===================*/ + /* out: pointer to block */ + buf_pool_t* buf_pool,/* in: buf_pool */ + ulint i) /* in: index of the block */{ + +return buf_pool_get_nth_block(buf_pool, i); + +} diff -r fe944d2c6e1f innobase/include/btr0btr.h --- a/innobase/include/btr0btr.h Mon Nov 10 19:47:27 2008 -0800 +++ b/innobase/include/btr0btr.h Mon Nov 10 19:48:24 2008 -0800 @@ -69,6 +69,12 @@ UNIV_INLINE dulint btr_page_get_index_id( +/*==================*/ + /* out: index id */ + page_t* page); /* in: index page */ + +dulint +btr_page_get_index_id_noninline( /*==================*/ /* out: index id */ page_t* page); /* in: index page */ diff -r fe944d2c6e1f innobase/include/buf0buf.h --- a/innobase/include/buf0buf.h Mon Nov 10 19:47:27 2008 -0800 +++ b/innobase/include/buf0buf.h Mon Nov 10 19:48:24 2008 -0800 @@ -703,6 +703,8 @@ buf_get_free_list_len(void); /*=======================*/ +void buf_pool_dump(void); +buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i); /* The buffer control block structure */ diff -r fe944d2c6e1f innobase/include/page0page.h --- a/innobase/include/page0page.h Mon Nov 10 19:47:27 2008 -0800 +++ b/innobase/include/page0page.h Mon Nov 10 19:48:24 2008 -0800 @@ -260,6 +260,12 @@ /*============*/ /* out: number of user records */ page_t* page); /* in: index page */ + +ulint +page_get_n_recs_noninline( +/*============*/ + /* out: number of user records */ + page_t* page); /* in: index page */ /******************************************************************* Returns the number of records before the given record in chain. The number includes infimum and supremum records. */ @@ -519,6 +525,12 @@ UNIV_INLINE ulint page_get_data_size( +/*===============*/ + /* out: data in bytes */ + page_t* page); /* in: index page */ + +ulint +page_get_data_size_noninline( /*===============*/ /* out: data in bytes */ page_t* page); /* in: index page */ diff -r fe944d2c6e1f innobase/page/page0page.c --- a/innobase/page/page0page.c Mon Nov 10 19:47:27 2008 -0800 +++ b/innobase/page/page0page.c Mon Nov 10 19:48:24 2008 -0800 @@ -1994,3 +1994,25 @@ page_cur_move_to_next(&cur); } } + +ulint +page_get_n_recs_noninline( +/*============*/ + /* out: number of user records */ + page_t* page) /* in: index page */ +{ + return page_get_n_recs(page); +} + + +ulint +page_get_data_size_noninline( +/*============*/ + /* out: number of user records */ + page_t* page) /* in: index page */ +{ + return page_get_data_size(page); +} + + + diff -r fe944d2c6e1f mysql-test/r/information_schema.result --- a/mysql-test/r/information_schema.result Mon Nov 10 19:47:27 2008 -0800 +++ b/mysql-test/r/information_schema.result Mon Nov 10 19:48:25 2008 -0800 @@ -42,6 +42,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY COLUMNS COLUMN_PRIVILEGES +INNODB_BUFFER_POOL_CONTENT INDEX_STATISTICS KEY_COLUMN_USAGE PROCESSLIST @@ -741,7 +742,7 @@ CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1; CREATE VIEW a2 AS SELECT t_CRASHME FROM a1; count(*) -107 +108 drop view a2, a1; drop table t_crashme; select table_schema,table_name, column_name from @@ -802,6 +803,7 @@ TABLE_NAME COLUMN_NAME PRIVILEGES COLUMNS TABLE_NAME select COLUMN_PRIVILEGES TABLE_NAME select +INNODB_BUFFER_POOL_CONTENT TABLE_NAME select INDEX_STATISTICS TABLE_NAME select KEY_COLUMN_USAGE TABLE_NAME select STATISTICS TABLE_NAME select @@ -815,7 +817,7 @@ flush privileges; SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA; table_schema count(*) -information_schema 22 +information_schema 23 mysql 17 create table t1 (i int, j int); create trigger trg1 before insert on t1 for each row @@ -1206,6 +1208,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME COLUMNS TABLE_SCHEMA COLUMN_PRIVILEGES TABLE_SCHEMA +INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA INDEX_STATISTICS TABLE_SCHEMA KEY_COLUMN_USAGE CONSTRAINT_SCHEMA PROCESSLIST ID @@ -1243,6 +1246,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME COLUMNS TABLE_SCHEMA COLUMN_PRIVILEGES TABLE_SCHEMA +INNODB_BUFFER_POOL_CONTENT TABLE_SCHEMA INDEX_STATISTICS TABLE_SCHEMA KEY_COLUMN_USAGE CONSTRAINT_SCHEMA PROCESSLIST ID @@ -1332,6 +1336,7 @@ COLUMNS information_schema.COLUMNS 1 COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1 INDEX_STATISTICS information_schema.INDEX_STATISTICS 1 +INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1 KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1 PROCESSLIST information_schema.PROCESSLIST 1 PROFILING information_schema.PROFILING 1 diff -r fe944d2c6e1f mysql-test/r/information_schema_db.result --- a/mysql-test/r/information_schema_db.result Mon Nov 10 19:47:27 2008 -0800 +++ b/mysql-test/r/information_schema_db.result Mon Nov 10 19:48:25 2008 -0800 @@ -11,6 +11,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY COLUMNS COLUMN_PRIVILEGES +INNODB_BUFFER_POOL_CONTENT INDEX_STATISTICS KEY_COLUMN_USAGE PROCESSLIST diff -r fe944d2c6e1f mysql-test/r/mysqlshow.result --- a/mysql-test/r/mysqlshow.result Mon Nov 10 19:47:27 2008 -0800 +++ b/mysql-test/r/mysqlshow.result Mon Nov 10 19:48:25 2008 -0800 @@ -85,6 +85,7 @@ | COLLATION_CHARACTER_SET_APPLICABILITY | | COLUMNS | | COLUMN_PRIVILEGES | +| INNODB_BUFFER_POOL_CONTENT | | INDEX_STATISTICS | | KEY_COLUMN_USAGE | | PROCESSLIST | @@ -112,6 +113,7 @@ | COLLATION_CHARACTER_SET_APPLICABILITY | | COLUMNS | | COLUMN_PRIVILEGES | +| INNODB_BUFFER_POOL_CONTENT | | INDEX_STATISTICS | | KEY_COLUMN_USAGE | | PROCESSLIST | diff -r fe944d2c6e1f patch_info/innodb_show_bp.info --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patch_info/innodb_show_bp.info Mon Nov 10 19:48:25 2008 -0800 @@ -0,0 +1,6 @@ +File=innodb_show_bp.patch +Name=show innodb buffer pool content +Version=1.0 +Author=Percona +License=GPL +Comment= diff -r fe944d2c6e1f sql/ha_innodb.cc --- a/sql/ha_innodb.cc Mon Nov 10 19:47:27 2008 -0800 +++ b/sql/ha_innodb.cc Mon Nov 10 19:48:25 2008 -0800 @@ -128,10 +128,12 @@ #include "../innobase/include/lock0lock.h" #include "../innobase/include/dict0crea.h" #include "../innobase/include/btr0cur.h" +#include "../innobase/include/buf0buf.h" #include "../innobase/include/btr0btr.h" #include "../innobase/include/fsp0fsp.h" #include "../innobase/include/sync0sync.h" #include "../innobase/include/fil0fil.h" +#include "../innobase/include/page0page.h" #include "../innobase/include/trx0xa.h" } @@ -6483,6 +6485,116 @@ DBUG_RETURN(FALSE); } +bool +innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables) +{ + ulint size; + ulint i; + dulint id; + ulint n_found; + buf_frame_t* frame; + dict_index_t* index; + buf_block_t* block; + + char *p; + char db_name_raw[NAME_LEN*5+1]; + char table_name_raw[NAME_LEN*5+1]; + + DBUG_ENTER("innodb_I_S_buffer_pool_content"); + + + size = buf_pool->curr_size; + + n_found = 0; + + TABLE *table= tables->table; + + + //buf_pool_dump(); + + + for (i = 0; i < size; i++) { + block = buf_pool_get_nth_block_no_inline(buf_pool, i); + frame = block->frame; + if (fil_page_get_type(frame)==0) continue; + + char page_type[64]; + + switch(fil_page_get_type(frame)) + { + case FIL_PAGE_INDEX: + strcpy(page_type, "index"); + break; + case FIL_PAGE_UNDO_LOG: + strcpy(page_type, "undo_log"); + break; + case FIL_PAGE_INODE: + strcpy(page_type, "inode"); + break; + case FIL_PAGE_IBUF_FREE_LIST: + strcpy(page_type, "ibuf_free_list"); + break; + default: + sprintf(page_type, "unknown", fil_page_get_type(frame)); + } + + table->field[0]->store((longlong)i, TRUE); + table->field[1]->store((longlong)block->space, TRUE); + table->field[2]->store((longlong)block->offset, TRUE); + table->field[3]->store((longlong)page_get_n_recs_noninline(block->frame), TRUE); + table->field[4]->store( ( fil_page_get_type(frame) == FIL_PAGE_INDEX ) ? (longlong)page_get_data_size_noninline(block->frame):0, TRUE); + table->field[5]->store((longlong)block->flush_type, TRUE); + table->field[6]->store((longlong)block->buf_fix_count, TRUE); + table->field[7]->store((longlong)block->LRU_position, TRUE); + table->field[8]->store((longlong)fil_page_get_type(frame), TRUE); + + table->field[9]->store(page_type, strlen(page_type), system_charset_info); + + //fprintf(stderr, "block N %d, space %d, offset %d, records %d, datasize %d, page_type %s, flush_type %d, buf_fix_count %d, LRU_position %d", i, block->space, block->offset, page_get_n_recs_noninline(block->frame), page_get_data_size_noninline(block->frame), page_type,block->flush_type, block->buf_fix_count, block->LRU_position); + + // flush_type, buf_fix_count, LRU_position + + if (fil_page_get_type(frame) == FIL_PAGE_INDEX) { + + id = btr_page_get_index_id_noninline(frame); + index = dict_index_get_if_in_cache(id); + if (index) { + table->field[10]->store(index->name, strlen(index->name), system_charset_info); + // fprintf(stderr, " index %s, table %s", index->name, index->table_name); + + if((p = strchr(index->table_name, '/'))) + { + strncpy(db_name_raw, index->table_name, p-index->table_name); + db_name_raw[p-index->table_name] = 0; + table->field[11]->store(db_name_raw, strlen(db_name_raw), system_charset_info); + p++; + } else { + table->field[11]->store(NULL, 0, system_charset_info); + p = (char *)index->table_name; + } + strcpy(table_name_raw, p); + + table->field[12]->store(table_name_raw, strlen(table_name_raw), system_charset_info); + } else { + table->field[10]->store(NULL, 0, system_charset_info); + table->field[11]->store(NULL, 0, system_charset_info); + table->field[12]->store(NULL, 0, system_charset_info); + } + }else{ + table->field[10]->store(NULL, 0, system_charset_info); + table->field[11]->store(NULL, 0, system_charset_info); + table->field[12]->store(NULL, 0, system_charset_info); + } + //fprintf(stderr, "\n"); + if (schema_table_store_record(thd, table)) + { + DBUG_RETURN(1); + } + } + + DBUG_RETURN(0); +} + /**************************************************************************** Implements the SHOW MUTEX STATUS command. . */ diff -r fe944d2c6e1f sql/ha_innodb.h --- a/sql/ha_innodb.h Mon Nov 10 19:47:27 2008 -0800 +++ b/sql/ha_innodb.h Mon Nov 10 19:48:25 2008 -0800 @@ -263,6 +263,7 @@ int innobase_drop_database(char *path); bool innodb_show_status(THD* thd); +bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables); bool innodb_mutex_show_status(THD* thd); void innodb_export_status(void); diff -r fe944d2c6e1f sql/sql_parse.cc --- a/sql/sql_parse.cc Mon Nov 10 19:47:27 2008 -0800 +++ b/sql/sql_parse.cc Mon Nov 10 19:48:25 2008 -0800 @@ -2926,6 +2926,7 @@ case SCH_COLUMN_PRIVILEGES: case SCH_TABLE_CONSTRAINTS: case SCH_KEY_COLUMN_USAGE: + case SCH_INNODB_I_S_BUFFER_POOL_CONTENT: default: break; } diff -r fe944d2c6e1f sql/sql_show.cc --- a/sql/sql_show.cc Mon Nov 10 19:47:27 2008 -0800 +++ b/sql/sql_show.cc Mon Nov 10 19:48:25 2008 -0800 @@ -27,6 +27,10 @@ #ifdef HAVE_BERKELEY_DB #include "ha_berkeley.h" // For berkeley_show_logs +#endif + +#ifdef HAVE_INNOBASE_DB +#include "ha_innodb.h" #endif #ifndef NO_EMBEDDED_ACCESS_CHECKS @@ -4042,6 +4046,19 @@ DBUG_RETURN(res); } +int fill_innodb_bp_content(THD *thd, TABLE_LIST *tables, COND *cond) +{ + DBUG_ENTER("fill_innodb_bp_content"); + int res= 0; + + /* deny access to non-superusers */ + if (check_global_access(thd, PROCESS_ACL)) { + DBUG_RETURN(0); + } + + innodb_I_S_buffer_pool_content(thd, tables); + DBUG_RETURN(res); +} /* Find schema_tables elment by name @@ -4951,6 +4962,24 @@ }; +ST_FIELD_INFO innodb_bp_content_fields_info[]= +{ + {"BLOCK_NUM", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Block_num"}, + {"SPACE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Space"}, + {"OFFSET", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Offset"}, + {"RECORDS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Records"}, + {"DATASIZE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Datasize"}, + {"FLUSH_TYPE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Flush_type"}, + {"FIX_COUNT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Fix_count"}, + {"LRU_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "LRU_position"}, + {"PAGE_TYPE_ID", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Page_type_id"}, + {"PAGE_TYPE", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Page_type"}, + {"INDEX_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Index_name"}, + {"TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_schem"}, + {"TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, "Table_name"}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} +}; + /* Description of ST_FIELD_INFO in table.h */ @@ -4969,6 +4998,8 @@ get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0}, {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table, fill_schema_column_privileges, 0, 0, -1, -1, 0}, + {"INNODB_BUFFER_POOL_CONTENT", innodb_bp_content_fields_info, create_schema_table, + fill_innodb_bp_content, 0, 0, -1, -1, 0}, {"INDEX_STATISTICS", index_stats_fields_info, create_schema_table, fill_schema_index_stats, make_old_format, 0, -1, -1, 0}, {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table, diff -r fe944d2c6e1f sql/table.h --- a/sql/table.h Mon Nov 10 19:47:27 2008 -0800 +++ b/sql/table.h Mon Nov 10 19:48:25 2008 -0800 @@ -375,6 +375,7 @@ SCH_COLLATION_CHARACTER_SET_APPLICABILITY, SCH_COLUMNS, SCH_COLUMN_PRIVILEGES, + SCH_INNODB_I_S_BUFFER_POOL_CONTENT, SCH_INDEX_STATS, SCH_KEY_COLUMN_USAGE, SCH_OPEN_TABLES,