Commit 217b8115 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-12188 information schema - errors populating fail to free memory, unlock mutexes

Given the OK macro used in innodb does a DBUG_RETURN(1) on expression failure
the innodb implementation has a number of errors in i_s.cc.

We introduce a new macro BREAK_IF that replaces some use of the OK macro.
Also, do some other cleanup detailed below.

When invoking Field::store() on integers, always pass the parameter
is_unsigned=true to avoid an unnecessary conversion to double.

i_s_fts_deleted_generic_fill(), i_s_fts_config_fill():
Use the BREAK_IF macro instead of OK.

i_s_fts_index_cache_fill_one_index(), i_s_fts_index_table_fill_one_index():
Add a parameter for conv_string, and let the caller allocate that buffer.

i_s_fts_index_cache_fill(): Check the return status of
i_s_fts_index_cache_fill_one_index().

i_s_fts_index_table_fill(): Check the return status of
i_s_fts_index_table_fill_one_index().

i_s_fts_index_table_fill_one_fetch(): Always let the caller invoke
i_s_fts_index_table_free_one_fetch().

i_s_innodb_buffer_page_fill(), i_s_innodb_buf_page_lru_fill():
Do release dict_sys->mutex if filling the buffers fails.

i_s_innodb_buf_page_lru_fill(): Also display the value
INFORMATION_SCHEMA.INNODB_BUFFER_PAGE.PAGE_IO_FIX='IO_PIN'
when a block is in that state. Remove the unnecessary variable 'heap'.
parent 8417252b
/***************************************************************************** /*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -143,6 +144,7 @@ struct buf_page_info_t{ ...@@ -143,6 +144,7 @@ struct buf_page_info_t{
if ((expr) != 0) { \ if ((expr) != 0) { \
DBUG_RETURN(1); \ DBUG_RETURN(1); \
} }
#define BREAK_IF(expr) if ((expr)) break
#define RETURN_IF_INNODB_NOT_STARTED(plugin_name) \ #define RETURN_IF_INNODB_NOT_STARTED(plugin_name) \
do { \ do { \
...@@ -2994,14 +2996,16 @@ i_s_fts_deleted_generic_fill( ...@@ -2994,14 +2996,16 @@ i_s_fts_deleted_generic_fill(
fields = table->field; fields = table->field;
int ret = 0;
for (ulint j = 0; j < ib_vector_size(deleted->doc_ids); ++j) { for (ulint j = 0; j < ib_vector_size(deleted->doc_ids); ++j) {
doc_id_t doc_id; doc_id_t doc_id;
doc_id = *(doc_id_t*) ib_vector_get_const(deleted->doc_ids, j); doc_id = *(doc_id_t*) ib_vector_get_const(deleted->doc_ids, j);
OK(fields[I_S_FTS_DOC_ID]->store((longlong) doc_id, true)); BREAK_IF(ret = fields[I_S_FTS_DOC_ID]->store(doc_id, true));
OK(schema_table_store_record(thd, table)); BREAK_IF(ret = schema_table_store_record(thd, table));
} }
trx_free_for_background(trx); trx_free_for_background(trx);
...@@ -3012,7 +3016,7 @@ i_s_fts_deleted_generic_fill( ...@@ -3012,7 +3016,7 @@ i_s_fts_deleted_generic_fill(
rw_lock_s_unlock(&dict_operation_lock); rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(ret);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -3252,13 +3256,13 @@ i_s_fts_index_cache_fill_one_index( ...@@ -3252,13 +3256,13 @@ i_s_fts_index_cache_fill_one_index(
/*===============================*/ /*===============================*/
fts_index_cache_t* index_cache, /*!< in: FTS index cache */ fts_index_cache_t* index_cache, /*!< in: FTS index cache */
THD* thd, /*!< in: thread */ THD* thd, /*!< in: thread */
fts_string_t* conv_str, /*!< in/out: buffer */
TABLE_LIST* tables) /*!< in/out: tables to fill */ TABLE_LIST* tables) /*!< in/out: tables to fill */
{ {
TABLE* table = (TABLE*) tables->table; TABLE* table = (TABLE*) tables->table;
Field** fields; Field** fields;
CHARSET_INFO* index_charset; CHARSET_INFO* index_charset;
const ib_rbt_node_t* rbt_node; const ib_rbt_node_t* rbt_node;
fts_string_t conv_str;
uint dummy_errors; uint dummy_errors;
char* word_str; char* word_str;
...@@ -3267,10 +3271,9 @@ i_s_fts_index_cache_fill_one_index( ...@@ -3267,10 +3271,9 @@ i_s_fts_index_cache_fill_one_index(
fields = table->field; fields = table->field;
index_charset = index_cache->charset; index_charset = index_cache->charset;
conv_str.f_len = system_charset_info->mbmaxlen conv_str->f_n_char = 0;
* FTS_MAX_WORD_LEN_IN_CHAR;
conv_str.f_str = static_cast<byte*>(ut_malloc(conv_str.f_len)); int ret = 0;
conv_str.f_n_char = 0;
/* Go through each word in the index cache */ /* Go through each word in the index cache */
for (rbt_node = rbt_first(index_cache->words); for (rbt_node = rbt_first(index_cache->words);
...@@ -3282,16 +3285,16 @@ i_s_fts_index_cache_fill_one_index( ...@@ -3282,16 +3285,16 @@ i_s_fts_index_cache_fill_one_index(
/* Convert word from index charset to system_charset_info */ /* Convert word from index charset to system_charset_info */
if (index_charset->cset != system_charset_info->cset) { if (index_charset->cset != system_charset_info->cset) {
conv_str.f_n_char = my_convert( conv_str->f_n_char = my_convert(
reinterpret_cast<char*>(conv_str.f_str), reinterpret_cast<char*>(conv_str->f_str),
static_cast<uint32>(conv_str.f_len), static_cast<uint32>(conv_str->f_len),
system_charset_info, system_charset_info,
reinterpret_cast<char*>(word->text.f_str), reinterpret_cast<char*>(word->text.f_str),
static_cast<uint32>(word->text.f_len), static_cast<uint32>(word->text.f_len),
index_charset, &dummy_errors); index_charset, &dummy_errors);
ut_ad(conv_str.f_n_char <= conv_str.f_len); ut_ad(conv_str->f_n_char <= conv_str->f_len);
conv_str.f_str[conv_str.f_n_char] = 0; conv_str->f_str[conv_str->f_n_char] = 0;
word_str = reinterpret_cast<char*>(conv_str.f_str); word_str = reinterpret_cast<char*>(conv_str->f_str);
} else { } else {
word_str = reinterpret_cast<char*>(word->text.f_str); word_str = reinterpret_cast<char*>(word->text.f_str);
} }
...@@ -3349,9 +3352,7 @@ i_s_fts_index_cache_fill_one_index( ...@@ -3349,9 +3352,7 @@ i_s_fts_index_cache_fill_one_index(
} }
} }
ut_free(conv_str.f_str); DBUG_RETURN(ret);
DBUG_RETURN(0);
} }
/*******************************************************************//** /*******************************************************************//**
Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHED Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHED
...@@ -3395,18 +3396,27 @@ i_s_fts_index_cache_fill( ...@@ -3395,18 +3396,27 @@ i_s_fts_index_cache_fill(
ut_a(cache); ut_a(cache);
int ret = 0;
fts_string_t conv_str;
conv_str.f_len = system_charset_info->mbmaxlen
* FTS_MAX_WORD_LEN_IN_CHAR;
conv_str.f_str = static_cast<byte*>(ut_malloc(conv_str.f_len));
for (ulint i = 0; i < ib_vector_size(cache->indexes); i++) { for (ulint i = 0; i < ib_vector_size(cache->indexes); i++) {
fts_index_cache_t* index_cache; fts_index_cache_t* index_cache;
index_cache = static_cast<fts_index_cache_t*> ( index_cache = static_cast<fts_index_cache_t*> (
ib_vector_get(cache->indexes, i)); ib_vector_get(cache->indexes, i));
i_s_fts_index_cache_fill_one_index(index_cache, thd, tables); BREAK_IF(ret = i_s_fts_index_cache_fill_one_index(
index_cache, thd, &conv_str, tables));
} }
ut_free(conv_str.f_str);
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, FALSE, FALSE);
DBUG_RETURN(0); DBUG_RETURN(ret);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -3710,8 +3720,6 @@ i_s_fts_index_table_fill_one_fetch( ...@@ -3710,8 +3720,6 @@ i_s_fts_index_table_fill_one_fetch(
} }
} }
i_s_fts_index_table_free_one_fetch(words);
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
...@@ -3725,13 +3733,13 @@ i_s_fts_index_table_fill_one_index( ...@@ -3725,13 +3733,13 @@ i_s_fts_index_table_fill_one_index(
/*===============================*/ /*===============================*/
dict_index_t* index, /*!< in: FTS index */ dict_index_t* index, /*!< in: FTS index */
THD* thd, /*!< in: thread */ THD* thd, /*!< in: thread */
fts_string_t* conv_str, /*!< in/out: buffer */
TABLE_LIST* tables) /*!< in/out: tables to fill */ TABLE_LIST* tables) /*!< in/out: tables to fill */
{ {
ib_vector_t* words; ib_vector_t* words;
mem_heap_t* heap; mem_heap_t* heap;
fts_string_t word; fts_string_t word;
CHARSET_INFO* index_charset; CHARSET_INFO* index_charset;
fts_string_t conv_str;
dberr_t error; dberr_t error;
int ret = 0; int ret = 0;
...@@ -3748,10 +3756,6 @@ i_s_fts_index_table_fill_one_index( ...@@ -3748,10 +3756,6 @@ i_s_fts_index_table_fill_one_index(
word.f_n_char = 0; word.f_n_char = 0;
index_charset = fts_index_get_charset(index); index_charset = fts_index_get_charset(index);
conv_str.f_len = system_charset_info->mbmaxlen
* FTS_MAX_WORD_LEN_IN_CHAR;
conv_str.f_str = static_cast<byte*>(ut_malloc(conv_str.f_len));
conv_str.f_n_char = 0;
/* Iterate through each auxiliary table as described in /* Iterate through each auxiliary table as described in
fts_index_selector */ fts_index_selector */
...@@ -3785,17 +3789,17 @@ i_s_fts_index_table_fill_one_index( ...@@ -3785,17 +3789,17 @@ i_s_fts_index_table_fill_one_index(
/* Fill into tables */ /* Fill into tables */
ret = i_s_fts_index_table_fill_one_fetch( ret = i_s_fts_index_table_fill_one_fetch(
index_charset, thd, tables, words, &conv_str, has_more); index_charset, thd, tables, words, conv_str,
has_more);
i_s_fts_index_table_free_one_fetch(words);
if (ret != 0) { if (ret != 0) {
i_s_fts_index_table_free_one_fetch(words);
goto func_exit; goto func_exit;
} }
} while (has_more); } while (has_more);
} }
func_exit: func_exit:
ut_free(conv_str.f_str);
mem_heap_free(heap); mem_heap_free(heap);
DBUG_RETURN(ret); DBUG_RETURN(ret);
...@@ -3837,10 +3841,17 @@ i_s_fts_index_table_fill( ...@@ -3837,10 +3841,17 @@ i_s_fts_index_table_fill(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
int ret = 0;
fts_string_t conv_str;
conv_str.f_len = system_charset_info->mbmaxlen
* FTS_MAX_WORD_LEN_IN_CHAR;
conv_str.f_str = static_cast<byte*>(ut_malloc(conv_str.f_len));
for (index = dict_table_get_first_index(user_table); for (index = dict_table_get_first_index(user_table);
index; index = dict_table_get_next_index(index)) { index; index = dict_table_get_next_index(index)) {
if (index->type & DICT_FTS) { if (index->type & DICT_FTS) {
i_s_fts_index_table_fill_one_index(index, thd, tables); BREAK_IF(ret = i_s_fts_index_table_fill_one_index(
index, thd, &conv_str, tables));
} }
} }
...@@ -3848,7 +3859,9 @@ i_s_fts_index_table_fill( ...@@ -3848,7 +3859,9 @@ i_s_fts_index_table_fill(
rw_lock_s_unlock(&dict_operation_lock); rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); ut_free(conv_str.f_str);
DBUG_RETURN(ret);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -4014,6 +4027,8 @@ i_s_fts_config_fill( ...@@ -4014,6 +4027,8 @@ i_s_fts_config_fill(
DBUG_ASSERT(!dict_index_is_online_ddl(index)); DBUG_ASSERT(!dict_index_is_online_ddl(index));
} }
int ret = 0;
while (fts_config_key[i]) { while (fts_config_key[i]) {
fts_string_t value; fts_string_t value;
char* key_name; char* key_name;
...@@ -4038,13 +4053,14 @@ i_s_fts_config_fill( ...@@ -4038,13 +4053,14 @@ i_s_fts_config_fill(
ut_free(key_name); ut_free(key_name);
} }
OK(field_store_string( BREAK_IF(ret = field_store_string(
fields[FTS_CONFIG_KEY], fts_config_key[i])); fields[FTS_CONFIG_KEY], fts_config_key[i]));
OK(field_store_string( BREAK_IF(ret = field_store_string(
fields[FTS_CONFIG_VALUE], (const char*) value.f_str)); fields[FTS_CONFIG_VALUE],
reinterpret_cast<const char*>(value.f_str)));
OK(schema_table_store_record(thd, table)); BREAK_IF(ret = schema_table_store_record(thd, table));
i++; i++;
} }
...@@ -4057,7 +4073,7 @@ i_s_fts_config_fill( ...@@ -4057,7 +4073,7 @@ i_s_fts_config_fill(
rw_lock_s_unlock(&dict_operation_lock); rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(ret);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -4895,34 +4911,29 @@ i_s_innodb_buffer_page_fill( ...@@ -4895,34 +4911,29 @@ i_s_innodb_buffer_page_fill(
state_str = NULL; state_str = NULL;
OK(fields[IDX_BUFFER_POOL_ID]->store( OK(fields[IDX_BUFFER_POOL_ID]->store(
static_cast<double>(page_info->pool_id))); page_info->pool_id, true));
OK(fields[IDX_BUFFER_BLOCK_ID]->store( OK(fields[IDX_BUFFER_BLOCK_ID]->store(
static_cast<double>(page_info->block_id))); page_info->block_id, true));
OK(fields[IDX_BUFFER_PAGE_SPACE]->store( OK(fields[IDX_BUFFER_PAGE_SPACE]->store(
static_cast<double>(page_info->space_id))); page_info->space_id, true));
OK(fields[IDX_BUFFER_PAGE_NUM]->store( OK(fields[IDX_BUFFER_PAGE_NUM]->store(
static_cast<double>(page_info->page_num))); page_info->page_num, true));
OK(field_store_string( OK(field_store_string(
fields[IDX_BUFFER_PAGE_TYPE], fields[IDX_BUFFER_PAGE_TYPE],
i_s_page_type[page_info->page_type].type_str)); i_s_page_type[page_info->page_type].type_str));
OK(fields[IDX_BUFFER_PAGE_FLUSH_TYPE]->store( OK(fields[IDX_BUFFER_PAGE_FLUSH_TYPE]->store(
page_info->flush_type)); page_info->flush_type, true));
OK(fields[IDX_BUFFER_PAGE_FIX_COUNT]->store( OK(fields[IDX_BUFFER_PAGE_FIX_COUNT]->store(
page_info->fix_count)); page_info->fix_count, true));
if (page_info->hashed) { OK(field_store_string(fields[IDX_BUFFER_PAGE_HASHED],
OK(field_store_string( page_info->hashed ? "YES" : "NO"));
fields[IDX_BUFFER_PAGE_HASHED], "YES"));
} else {
OK(field_store_string(
fields[IDX_BUFFER_PAGE_HASHED], "NO"));
}
OK(fields[IDX_BUFFER_PAGE_NEWEST_MOD]->store( OK(fields[IDX_BUFFER_PAGE_NEWEST_MOD]->store(
(longlong) page_info->newest_mod, true)); (longlong) page_info->newest_mod, true));
...@@ -4931,7 +4942,7 @@ i_s_innodb_buffer_page_fill( ...@@ -4931,7 +4942,7 @@ i_s_innodb_buffer_page_fill(
(longlong) page_info->oldest_mod, true)); (longlong) page_info->oldest_mod, true));
OK(fields[IDX_BUFFER_PAGE_ACCESS_TIME]->store( OK(fields[IDX_BUFFER_PAGE_ACCESS_TIME]->store(
page_info->access_time)); page_info->access_time, true));
fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_null(); fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_null();
...@@ -4940,44 +4951,48 @@ i_s_innodb_buffer_page_fill( ...@@ -4940,44 +4951,48 @@ i_s_innodb_buffer_page_fill(
/* If this is an index page, fetch the index name /* If this is an index page, fetch the index name
and table name */ and table name */
if (page_info->page_type == I_S_PAGE_TYPE_INDEX) { if (page_info->page_type == I_S_PAGE_TYPE_INDEX) {
const dict_index_t* index; bool ret = false;
mutex_enter(&dict_sys->mutex); mutex_enter(&dict_sys->mutex);
index = dict_index_get_if_in_cache_low(
page_info->index_id);
if (index) {
if (const dict_index_t* index =
dict_index_get_if_in_cache_low(
page_info->index_id)) {
table_name_end = innobase_convert_name( table_name_end = innobase_convert_name(
table_name, sizeof(table_name), table_name, sizeof(table_name),
index->table_name, index->table_name,
strlen(index->table_name), strlen(index->table_name),
thd, TRUE); thd, TRUE);
OK(fields[IDX_BUFFER_PAGE_TABLE_NAME]->store( ret = fields[IDX_BUFFER_PAGE_TABLE_NAME]
table_name, ->store(table_name,
static_cast<uint>(table_name_end - table_name), static_cast<uint>(
system_charset_info)); table_name_end
fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_notnull(); - table_name),
system_charset_info)
OK(field_store_index_name( || field_store_index_name(
fields[IDX_BUFFER_PAGE_INDEX_NAME], fields
index->name)); [IDX_BUFFER_PAGE_INDEX_NAME],
index->name);
} }
mutex_exit(&dict_sys->mutex); mutex_exit(&dict_sys->mutex);
OK(ret);
fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_notnull();
} }
OK(fields[IDX_BUFFER_PAGE_NUM_RECS]->store( OK(fields[IDX_BUFFER_PAGE_NUM_RECS]->store(
page_info->num_recs)); page_info->num_recs, true));
OK(fields[IDX_BUFFER_PAGE_DATA_SIZE]->store( OK(fields[IDX_BUFFER_PAGE_DATA_SIZE]->store(
page_info->data_size)); page_info->data_size, true));
OK(fields[IDX_BUFFER_PAGE_ZIP_SIZE]->store( OK(fields[IDX_BUFFER_PAGE_ZIP_SIZE]->store(
page_info->zip_ssize page_info->zip_ssize
? (UNIV_ZIP_SIZE_MIN >> 1) << page_info->zip_ssize ? (UNIV_ZIP_SIZE_MIN >> 1) << page_info->zip_ssize
: 0)); : 0, true));
#if BUF_PAGE_STATE_BITS > 3 #if BUF_PAGE_STATE_BITS > 3
# error "BUF_PAGE_STATE_BITS > 3, please ensure that all 1<<BUF_PAGE_STATE_BITS values are checked for" # error "BUF_PAGE_STATE_BITS > 3, please ensure that all 1<<BUF_PAGE_STATE_BITS values are checked for"
...@@ -5015,32 +5030,29 @@ i_s_innodb_buffer_page_fill( ...@@ -5015,32 +5030,29 @@ i_s_innodb_buffer_page_fill(
switch (page_info->io_fix) { switch (page_info->io_fix) {
case BUF_IO_NONE: case BUF_IO_NONE:
OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX], state_str = "IO_NONE";
"IO_NONE"));
break; break;
case BUF_IO_READ: case BUF_IO_READ:
OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX], state_str = "IO_READ";
"IO_READ"));
break; break;
case BUF_IO_WRITE: case BUF_IO_WRITE:
OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX], state_str = "IO_WRITE";
"IO_WRITE"));
break; break;
case BUF_IO_PIN: case BUF_IO_PIN:
OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX], state_str = "IO_PIN";
"IO_PIN"));
break; break;
} }
OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX],
state_str));
OK(field_store_string(fields[IDX_BUFFER_PAGE_IS_OLD], OK(field_store_string(fields[IDX_BUFFER_PAGE_IS_OLD],
(page_info->is_old) ? "YES" : "NO")); (page_info->is_old) ? "YES" : "NO"));
OK(fields[IDX_BUFFER_PAGE_FREE_CLOCK]->store( OK(fields[IDX_BUFFER_PAGE_FREE_CLOCK]->store(
page_info->freed_page_clock)); page_info->freed_page_clock));
if (schema_table_store_record(thd, table)) { OK(schema_table_store_record(thd, table));
DBUG_RETURN(1);
}
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -5584,17 +5596,10 @@ i_s_innodb_buf_page_lru_fill( ...@@ -5584,17 +5596,10 @@ i_s_innodb_buf_page_lru_fill(
ulint num_page) /*!< in: number of page info ulint num_page) /*!< in: number of page info
cached */ cached */
{ {
TABLE* table;
Field** fields;
mem_heap_t* heap;
DBUG_ENTER("i_s_innodb_buf_page_lru_fill"); DBUG_ENTER("i_s_innodb_buf_page_lru_fill");
table = tables->table; TABLE* table = tables->table;
Field** fields = table->field;
fields = table->field;
heap = mem_heap_create(1000);
/* Iterate through the cached array and fill the I_S table rows */ /* Iterate through the cached array and fill the I_S table rows */
for (ulint i = 0; i < num_page; i++) { for (ulint i = 0; i < num_page; i++) {
...@@ -5609,43 +5614,37 @@ i_s_innodb_buf_page_lru_fill( ...@@ -5609,43 +5614,37 @@ i_s_innodb_buf_page_lru_fill(
page_info = info_array + i; page_info = info_array + i;
OK(fields[IDX_BUF_LRU_POOL_ID]->store( OK(fields[IDX_BUF_LRU_POOL_ID]->store(
static_cast<double>(page_info->pool_id))); page_info->pool_id, true));
OK(fields[IDX_BUF_LRU_POS]->store( OK(fields[IDX_BUF_LRU_POS]->store(
static_cast<double>(page_info->block_id))); page_info->block_id, true));
OK(fields[IDX_BUF_LRU_PAGE_SPACE]->store( OK(fields[IDX_BUF_LRU_PAGE_SPACE]->store(
static_cast<double>(page_info->space_id))); page_info->space_id, true));
OK(fields[IDX_BUF_LRU_PAGE_NUM]->store( OK(fields[IDX_BUF_LRU_PAGE_NUM]->store(
static_cast<double>(page_info->page_num))); page_info->page_num, true));
OK(field_store_string( OK(field_store_string(
fields[IDX_BUF_LRU_PAGE_TYPE], fields[IDX_BUF_LRU_PAGE_TYPE],
i_s_page_type[page_info->page_type].type_str)); i_s_page_type[page_info->page_type].type_str));
OK(fields[IDX_BUF_LRU_PAGE_FLUSH_TYPE]->store( OK(fields[IDX_BUF_LRU_PAGE_FLUSH_TYPE]->store(
static_cast<double>(page_info->flush_type))); page_info->flush_type, true));
OK(fields[IDX_BUF_LRU_PAGE_FIX_COUNT]->store( OK(fields[IDX_BUF_LRU_PAGE_FIX_COUNT]->store(
static_cast<double>(page_info->fix_count))); page_info->fix_count, true));
if (page_info->hashed) { OK(field_store_string(fields[IDX_BUF_LRU_PAGE_HASHED],
OK(field_store_string( page_info->hashed ? "YES" : "NO"));
fields[IDX_BUF_LRU_PAGE_HASHED], "YES"));
} else {
OK(field_store_string(
fields[IDX_BUF_LRU_PAGE_HASHED], "NO"));
}
OK(fields[IDX_BUF_LRU_PAGE_NEWEST_MOD]->store( OK(fields[IDX_BUF_LRU_PAGE_NEWEST_MOD]->store(
page_info->newest_mod, true)); page_info->newest_mod, true));
OK(fields[IDX_BUF_LRU_PAGE_OLDEST_MOD]->store( OK(fields[IDX_BUF_LRU_PAGE_OLDEST_MOD]->store(
page_info->oldest_mod, true)); page_info->oldest_mod, true));
OK(fields[IDX_BUF_LRU_PAGE_ACCESS_TIME]->store( OK(fields[IDX_BUF_LRU_PAGE_ACCESS_TIME]->store(
page_info->access_time)); page_info->access_time, true));
fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_null(); fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_null();
...@@ -5654,43 +5653,47 @@ i_s_innodb_buf_page_lru_fill( ...@@ -5654,43 +5653,47 @@ i_s_innodb_buf_page_lru_fill(
/* If this is an index page, fetch the index name /* If this is an index page, fetch the index name
and table name */ and table name */
if (page_info->page_type == I_S_PAGE_TYPE_INDEX) { if (page_info->page_type == I_S_PAGE_TYPE_INDEX) {
const dict_index_t* index; bool ret = false;
mutex_enter(&dict_sys->mutex); mutex_enter(&dict_sys->mutex);
index = dict_index_get_if_in_cache_low(
page_info->index_id);
if (index) {
if (const dict_index_t* index =
dict_index_get_if_in_cache_low(
page_info->index_id)) {
table_name_end = innobase_convert_name( table_name_end = innobase_convert_name(
table_name, sizeof(table_name), table_name, sizeof(table_name),
index->table_name, index->table_name,
strlen(index->table_name), strlen(index->table_name),
thd, TRUE); thd, TRUE);
OK(fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->store( ret = fields[IDX_BUF_LRU_PAGE_TABLE_NAME]
table_name, ->store(table_name,
static_cast<uint>(table_name_end - table_name), static_cast<uint>(
system_charset_info)); table_name_end
fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_notnull(); - table_name),
system_charset_info)
OK(field_store_index_name( || field_store_index_name(
fields[IDX_BUF_LRU_PAGE_INDEX_NAME], fields
index->name)); [IDX_BUF_LRU_PAGE_INDEX_NAME],
index->name);
} }
mutex_exit(&dict_sys->mutex); mutex_exit(&dict_sys->mutex);
OK(ret);
fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_notnull();
} }
OK(fields[IDX_BUF_LRU_PAGE_NUM_RECS]->store( OK(fields[IDX_BUF_LRU_PAGE_NUM_RECS]->store(
page_info->num_recs)); page_info->num_recs, true));
OK(fields[IDX_BUF_LRU_PAGE_DATA_SIZE]->store( OK(fields[IDX_BUF_LRU_PAGE_DATA_SIZE]->store(
page_info->data_size)); page_info->data_size, true));
OK(fields[IDX_BUF_LRU_PAGE_ZIP_SIZE]->store( OK(fields[IDX_BUF_LRU_PAGE_ZIP_SIZE]->store(
page_info->zip_ssize ? page_info->zip_ssize
512 << page_info->zip_ssize : 0)); ? 512 << page_info->zip_ssize : 0, true));
state = static_cast<enum buf_page_state>(page_info->page_state); state = static_cast<enum buf_page_state>(page_info->page_state);
...@@ -5719,35 +5722,31 @@ i_s_innodb_buf_page_lru_fill( ...@@ -5719,35 +5722,31 @@ i_s_innodb_buf_page_lru_fill(
switch (page_info->io_fix) { switch (page_info->io_fix) {
case BUF_IO_NONE: case BUF_IO_NONE:
OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX], state_str = "IO_NONE";
"IO_NONE"));
break; break;
case BUF_IO_READ: case BUF_IO_READ:
OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX], state_str = "IO_READ";
"IO_READ"));
break; break;
case BUF_IO_WRITE: case BUF_IO_WRITE:
OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX], state_str = "IO_WRITE";
"IO_WRITE")); break;
case BUF_IO_PIN:
state_str = "IO_PIN";
break; break;
} }
OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX],
state_str));
OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IS_OLD], OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IS_OLD],
(page_info->is_old) ? "YES" : "NO")); page_info->is_old ? "YES" : "NO"));
OK(fields[IDX_BUF_LRU_PAGE_FREE_CLOCK]->store( OK(fields[IDX_BUF_LRU_PAGE_FREE_CLOCK]->store(
page_info->freed_page_clock)); page_info->freed_page_clock, true));
if (schema_table_store_record(thd, table)) { OK(schema_table_store_record(thd, table));
mem_heap_free(heap);
DBUG_RETURN(1);
}
mem_heap_empty(heap);
} }
mem_heap_free(heap);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -155,6 +156,7 @@ struct buf_page_info_t{ ...@@ -155,6 +156,7 @@ struct buf_page_info_t{
if ((expr) != 0) { \ if ((expr) != 0) { \
DBUG_RETURN(1); \ DBUG_RETURN(1); \
} }
#define BREAK_IF(expr) if ((expr)) break
#define RETURN_IF_INNODB_NOT_STARTED(plugin_name) \ #define RETURN_IF_INNODB_NOT_STARTED(plugin_name) \
do { \ do { \
...@@ -2989,14 +2991,16 @@ i_s_fts_deleted_generic_fill( ...@@ -2989,14 +2991,16 @@ i_s_fts_deleted_generic_fill(
fields = table->field; fields = table->field;
int ret = 0;
for (ulint j = 0; j < ib_vector_size(deleted->doc_ids); ++j) { for (ulint j = 0; j < ib_vector_size(deleted->doc_ids); ++j) {
doc_id_t doc_id; doc_id_t doc_id;
doc_id = *(doc_id_t*) ib_vector_get_const(deleted->doc_ids, j); doc_id = *(doc_id_t*) ib_vector_get_const(deleted->doc_ids, j);
OK(fields[I_S_FTS_DOC_ID]->store((longlong) doc_id, true)); BREAK_IF(ret = fields[I_S_FTS_DOC_ID]->store(doc_id, true));
OK(schema_table_store_record(thd, table)); BREAK_IF(ret = schema_table_store_record(thd, table));
} }
trx_free_for_background(trx); trx_free_for_background(trx);
...@@ -3007,7 +3011,7 @@ i_s_fts_deleted_generic_fill( ...@@ -3007,7 +3011,7 @@ i_s_fts_deleted_generic_fill(
rw_lock_s_unlock(&dict_operation_lock); rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(ret);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -3245,13 +3249,13 @@ i_s_fts_index_cache_fill_one_index( ...@@ -3245,13 +3249,13 @@ i_s_fts_index_cache_fill_one_index(
/*===============================*/ /*===============================*/
fts_index_cache_t* index_cache, /*!< in: FTS index cache */ fts_index_cache_t* index_cache, /*!< in: FTS index cache */
THD* thd, /*!< in: thread */ THD* thd, /*!< in: thread */
fts_string_t* conv_str, /*!< in/out: buffer */
TABLE_LIST* tables) /*!< in/out: tables to fill */ TABLE_LIST* tables) /*!< in/out: tables to fill */
{ {
TABLE* table = (TABLE*) tables->table; TABLE* table = (TABLE*) tables->table;
Field** fields; Field** fields;
CHARSET_INFO* index_charset; CHARSET_INFO* index_charset;
const ib_rbt_node_t* rbt_node; const ib_rbt_node_t* rbt_node;
fts_string_t conv_str;
uint dummy_errors; uint dummy_errors;
char* word_str; char* word_str;
...@@ -3260,10 +3264,9 @@ i_s_fts_index_cache_fill_one_index( ...@@ -3260,10 +3264,9 @@ i_s_fts_index_cache_fill_one_index(
fields = table->field; fields = table->field;
index_charset = index_cache->charset; index_charset = index_cache->charset;
conv_str.f_len = system_charset_info->mbmaxlen conv_str->f_n_char = 0;
* FTS_MAX_WORD_LEN_IN_CHAR;
conv_str.f_str = static_cast<byte*>(ut_malloc(conv_str.f_len)); int ret = 0;
conv_str.f_n_char = 0;
/* Go through each word in the index cache */ /* Go through each word in the index cache */
for (rbt_node = rbt_first(index_cache->words); for (rbt_node = rbt_first(index_cache->words);
...@@ -3275,16 +3278,16 @@ i_s_fts_index_cache_fill_one_index( ...@@ -3275,16 +3278,16 @@ i_s_fts_index_cache_fill_one_index(
/* Convert word from index charset to system_charset_info */ /* Convert word from index charset to system_charset_info */
if (index_charset->cset != system_charset_info->cset) { if (index_charset->cset != system_charset_info->cset) {
conv_str.f_n_char = my_convert( conv_str->f_n_char = my_convert(
reinterpret_cast<char*>(conv_str.f_str), reinterpret_cast<char*>(conv_str->f_str),
static_cast<uint32>(conv_str.f_len), static_cast<uint32>(conv_str->f_len),
system_charset_info, system_charset_info,
reinterpret_cast<char*>(word->text.f_str), reinterpret_cast<char*>(word->text.f_str),
static_cast<uint32>(word->text.f_len), static_cast<uint32>(word->text.f_len),
index_charset, &dummy_errors); index_charset, &dummy_errors);
ut_ad(conv_str.f_n_char <= conv_str.f_len); ut_ad(conv_str->f_n_char <= conv_str->f_len);
conv_str.f_str[conv_str.f_n_char] = 0; conv_str->f_str[conv_str->f_n_char] = 0;
word_str = reinterpret_cast<char*>(conv_str.f_str); word_str = reinterpret_cast<char*>(conv_str->f_str);
} else { } else {
word_str = reinterpret_cast<char*>(word->text.f_str); word_str = reinterpret_cast<char*>(word->text.f_str);
} }
...@@ -3342,9 +3345,7 @@ i_s_fts_index_cache_fill_one_index( ...@@ -3342,9 +3345,7 @@ i_s_fts_index_cache_fill_one_index(
} }
} }
ut_free(conv_str.f_str); DBUG_RETURN(ret);
DBUG_RETURN(0);
} }
/*******************************************************************//** /*******************************************************************//**
Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHED Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHED
...@@ -3388,18 +3389,27 @@ i_s_fts_index_cache_fill( ...@@ -3388,18 +3389,27 @@ i_s_fts_index_cache_fill(
ut_a(cache); ut_a(cache);
int ret = 0;
fts_string_t conv_str;
conv_str.f_len = system_charset_info->mbmaxlen
* FTS_MAX_WORD_LEN_IN_CHAR;
conv_str.f_str = static_cast<byte*>(ut_malloc(conv_str.f_len));
for (ulint i = 0; i < ib_vector_size(cache->indexes); i++) { for (ulint i = 0; i < ib_vector_size(cache->indexes); i++) {
fts_index_cache_t* index_cache; fts_index_cache_t* index_cache;
index_cache = static_cast<fts_index_cache_t*> ( index_cache = static_cast<fts_index_cache_t*> (
ib_vector_get(cache->indexes, i)); ib_vector_get(cache->indexes, i));
i_s_fts_index_cache_fill_one_index(index_cache, thd, tables); BREAK_IF(ret = i_s_fts_index_cache_fill_one_index(
index_cache, thd, &conv_str, tables));
} }
ut_free(conv_str.f_str);
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, FALSE, FALSE);
DBUG_RETURN(0); DBUG_RETURN(ret);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -3702,8 +3712,6 @@ i_s_fts_index_table_fill_one_fetch( ...@@ -3702,8 +3712,6 @@ i_s_fts_index_table_fill_one_fetch(
} }
} }
i_s_fts_index_table_free_one_fetch(words);
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
...@@ -3717,13 +3725,13 @@ i_s_fts_index_table_fill_one_index( ...@@ -3717,13 +3725,13 @@ i_s_fts_index_table_fill_one_index(
/*===============================*/ /*===============================*/
dict_index_t* index, /*!< in: FTS index */ dict_index_t* index, /*!< in: FTS index */
THD* thd, /*!< in: thread */ THD* thd, /*!< in: thread */
fts_string_t* conv_str, /*!< in/out: buffer */
TABLE_LIST* tables) /*!< in/out: tables to fill */ TABLE_LIST* tables) /*!< in/out: tables to fill */
{ {
ib_vector_t* words; ib_vector_t* words;
mem_heap_t* heap; mem_heap_t* heap;
fts_string_t word; fts_string_t word;
CHARSET_INFO* index_charset; CHARSET_INFO* index_charset;
fts_string_t conv_str;
dberr_t error; dberr_t error;
int ret = 0; int ret = 0;
...@@ -3740,10 +3748,6 @@ i_s_fts_index_table_fill_one_index( ...@@ -3740,10 +3748,6 @@ i_s_fts_index_table_fill_one_index(
word.f_n_char = 0; word.f_n_char = 0;
index_charset = fts_index_get_charset(index); index_charset = fts_index_get_charset(index);
conv_str.f_len = system_charset_info->mbmaxlen
* FTS_MAX_WORD_LEN_IN_CHAR;
conv_str.f_str = static_cast<byte*>(ut_malloc(conv_str.f_len));
conv_str.f_n_char = 0;
/* Iterate through each auxiliary table as described in /* Iterate through each auxiliary table as described in
fts_index_selector */ fts_index_selector */
...@@ -3777,17 +3781,17 @@ i_s_fts_index_table_fill_one_index( ...@@ -3777,17 +3781,17 @@ i_s_fts_index_table_fill_one_index(
/* Fill into tables */ /* Fill into tables */
ret = i_s_fts_index_table_fill_one_fetch( ret = i_s_fts_index_table_fill_one_fetch(
index_charset, thd, tables, words, &conv_str, has_more); index_charset, thd, tables, words, conv_str,
has_more);
i_s_fts_index_table_free_one_fetch(words);
if (ret != 0) { if (ret != 0) {
i_s_fts_index_table_free_one_fetch(words);
goto func_exit; goto func_exit;
} }
} while (has_more); } while (has_more);
} }
func_exit: func_exit:
ut_free(conv_str.f_str);
mem_heap_free(heap); mem_heap_free(heap);
DBUG_RETURN(ret); DBUG_RETURN(ret);
...@@ -3829,10 +3833,17 @@ i_s_fts_index_table_fill( ...@@ -3829,10 +3833,17 @@ i_s_fts_index_table_fill(
DBUG_RETURN(0); DBUG_RETURN(0);
} }
int ret = 0;
fts_string_t conv_str;
conv_str.f_len = system_charset_info->mbmaxlen
* FTS_MAX_WORD_LEN_IN_CHAR;
conv_str.f_str = static_cast<byte*>(ut_malloc(conv_str.f_len));
for (index = dict_table_get_first_index(user_table); for (index = dict_table_get_first_index(user_table);
index; index = dict_table_get_next_index(index)) { index; index = dict_table_get_next_index(index)) {
if (index->type & DICT_FTS) { if (index->type & DICT_FTS) {
i_s_fts_index_table_fill_one_index(index, thd, tables); BREAK_IF(ret = i_s_fts_index_table_fill_one_index(
index, thd, &conv_str, tables));
} }
} }
...@@ -3840,7 +3851,9 @@ i_s_fts_index_table_fill( ...@@ -3840,7 +3851,9 @@ i_s_fts_index_table_fill(
rw_lock_s_unlock(&dict_operation_lock); rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); ut_free(conv_str.f_str);
DBUG_RETURN(ret);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -4005,6 +4018,8 @@ i_s_fts_config_fill( ...@@ -4005,6 +4018,8 @@ i_s_fts_config_fill(
DBUG_ASSERT(!dict_index_is_online_ddl(index)); DBUG_ASSERT(!dict_index_is_online_ddl(index));
} }
int ret = 0;
while (fts_config_key[i]) { while (fts_config_key[i]) {
fts_string_t value; fts_string_t value;
char* key_name; char* key_name;
...@@ -4029,13 +4044,14 @@ i_s_fts_config_fill( ...@@ -4029,13 +4044,14 @@ i_s_fts_config_fill(
ut_free(key_name); ut_free(key_name);
} }
OK(field_store_string( BREAK_IF(ret = field_store_string(
fields[FTS_CONFIG_KEY], fts_config_key[i])); fields[FTS_CONFIG_KEY], fts_config_key[i]));
OK(field_store_string( BREAK_IF(ret = field_store_string(
fields[FTS_CONFIG_VALUE], (const char*) value.f_str)); fields[FTS_CONFIG_VALUE],
reinterpret_cast<const char*>(value.f_str)));
OK(schema_table_store_record(thd, table)); BREAK_IF(ret = schema_table_store_record(thd, table));
i++; i++;
} }
...@@ -4048,7 +4064,7 @@ i_s_fts_config_fill( ...@@ -4048,7 +4064,7 @@ i_s_fts_config_fill(
rw_lock_s_unlock(&dict_operation_lock); rw_lock_s_unlock(&dict_operation_lock);
DBUG_RETURN(0); DBUG_RETURN(ret);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -4883,34 +4899,29 @@ i_s_innodb_buffer_page_fill( ...@@ -4883,34 +4899,29 @@ i_s_innodb_buffer_page_fill(
state_str = NULL; state_str = NULL;
OK(fields[IDX_BUFFER_POOL_ID]->store( OK(fields[IDX_BUFFER_POOL_ID]->store(
static_cast<double>(page_info->pool_id))); page_info->pool_id, true));
OK(fields[IDX_BUFFER_BLOCK_ID]->store( OK(fields[IDX_BUFFER_BLOCK_ID]->store(
static_cast<double>(page_info->block_id))); page_info->block_id, true));
OK(fields[IDX_BUFFER_PAGE_SPACE]->store( OK(fields[IDX_BUFFER_PAGE_SPACE]->store(
static_cast<double>(page_info->space_id))); page_info->space_id, true));
OK(fields[IDX_BUFFER_PAGE_NUM]->store( OK(fields[IDX_BUFFER_PAGE_NUM]->store(
static_cast<double>(page_info->page_num))); page_info->page_num, true));
OK(field_store_string( OK(field_store_string(
fields[IDX_BUFFER_PAGE_TYPE], fields[IDX_BUFFER_PAGE_TYPE],
i_s_page_type[page_info->page_type].type_str)); i_s_page_type[page_info->page_type].type_str));
OK(fields[IDX_BUFFER_PAGE_FLUSH_TYPE]->store( OK(fields[IDX_BUFFER_PAGE_FLUSH_TYPE]->store(
page_info->flush_type)); page_info->flush_type, true));
OK(fields[IDX_BUFFER_PAGE_FIX_COUNT]->store( OK(fields[IDX_BUFFER_PAGE_FIX_COUNT]->store(
page_info->fix_count)); page_info->fix_count, true));
if (page_info->hashed) { OK(field_store_string(fields[IDX_BUFFER_PAGE_HASHED],
OK(field_store_string( page_info->hashed ? "YES" : "NO"));
fields[IDX_BUFFER_PAGE_HASHED], "YES"));
} else {
OK(field_store_string(
fields[IDX_BUFFER_PAGE_HASHED], "NO"));
}
OK(fields[IDX_BUFFER_PAGE_NEWEST_MOD]->store( OK(fields[IDX_BUFFER_PAGE_NEWEST_MOD]->store(
(longlong) page_info->newest_mod, true)); (longlong) page_info->newest_mod, true));
...@@ -4919,7 +4930,7 @@ i_s_innodb_buffer_page_fill( ...@@ -4919,7 +4930,7 @@ i_s_innodb_buffer_page_fill(
(longlong) page_info->oldest_mod, true)); (longlong) page_info->oldest_mod, true));
OK(fields[IDX_BUFFER_PAGE_ACCESS_TIME]->store( OK(fields[IDX_BUFFER_PAGE_ACCESS_TIME]->store(
page_info->access_time)); page_info->access_time, true));
fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_null(); fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_null();
...@@ -4928,44 +4939,48 @@ i_s_innodb_buffer_page_fill( ...@@ -4928,44 +4939,48 @@ i_s_innodb_buffer_page_fill(
/* If this is an index page, fetch the index name /* If this is an index page, fetch the index name
and table name */ and table name */
if (page_info->page_type == I_S_PAGE_TYPE_INDEX) { if (page_info->page_type == I_S_PAGE_TYPE_INDEX) {
const dict_index_t* index; bool ret = false;
mutex_enter(&dict_sys->mutex); mutex_enter(&dict_sys->mutex);
index = dict_index_get_if_in_cache_low(
page_info->index_id);
if (index) {
if (const dict_index_t* index =
dict_index_get_if_in_cache_low(
page_info->index_id)) {
table_name_end = innobase_convert_name( table_name_end = innobase_convert_name(
table_name, sizeof(table_name), table_name, sizeof(table_name),
index->table_name, index->table_name,
strlen(index->table_name), strlen(index->table_name),
thd, TRUE); thd, TRUE);
OK(fields[IDX_BUFFER_PAGE_TABLE_NAME]->store( ret = fields[IDX_BUFFER_PAGE_TABLE_NAME]
table_name, ->store(table_name,
static_cast<uint>(table_name_end - table_name), static_cast<uint>(
system_charset_info)); table_name_end
fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_notnull(); - table_name),
system_charset_info)
OK(field_store_index_name( || field_store_index_name(
fields[IDX_BUFFER_PAGE_INDEX_NAME], fields
index->name)); [IDX_BUFFER_PAGE_INDEX_NAME],
index->name);
} }
mutex_exit(&dict_sys->mutex); mutex_exit(&dict_sys->mutex);
OK(ret);
fields[IDX_BUFFER_PAGE_TABLE_NAME]->set_notnull();
} }
OK(fields[IDX_BUFFER_PAGE_NUM_RECS]->store( OK(fields[IDX_BUFFER_PAGE_NUM_RECS]->store(
page_info->num_recs)); page_info->num_recs, true));
OK(fields[IDX_BUFFER_PAGE_DATA_SIZE]->store( OK(fields[IDX_BUFFER_PAGE_DATA_SIZE]->store(
page_info->data_size)); page_info->data_size, true));
OK(fields[IDX_BUFFER_PAGE_ZIP_SIZE]->store( OK(fields[IDX_BUFFER_PAGE_ZIP_SIZE]->store(
page_info->zip_ssize page_info->zip_ssize
? (UNIV_ZIP_SIZE_MIN >> 1) << page_info->zip_ssize ? (UNIV_ZIP_SIZE_MIN >> 1) << page_info->zip_ssize
: 0)); : 0, true));
#if BUF_PAGE_STATE_BITS > 3 #if BUF_PAGE_STATE_BITS > 3
# error "BUF_PAGE_STATE_BITS > 3, please ensure that all 1<<BUF_PAGE_STATE_BITS values are checked for" # error "BUF_PAGE_STATE_BITS > 3, please ensure that all 1<<BUF_PAGE_STATE_BITS values are checked for"
...@@ -5003,32 +5018,29 @@ i_s_innodb_buffer_page_fill( ...@@ -5003,32 +5018,29 @@ i_s_innodb_buffer_page_fill(
switch (page_info->io_fix) { switch (page_info->io_fix) {
case BUF_IO_NONE: case BUF_IO_NONE:
OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX], state_str = "IO_NONE";
"IO_NONE"));
break; break;
case BUF_IO_READ: case BUF_IO_READ:
OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX], state_str = "IO_READ";
"IO_READ"));
break; break;
case BUF_IO_WRITE: case BUF_IO_WRITE:
OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX], state_str = "IO_WRITE";
"IO_WRITE"));
break; break;
case BUF_IO_PIN: case BUF_IO_PIN:
OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX], state_str = "IO_PIN";
"IO_PIN"));
break; break;
} }
OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX],
state_str));
OK(field_store_string(fields[IDX_BUFFER_PAGE_IS_OLD], OK(field_store_string(fields[IDX_BUFFER_PAGE_IS_OLD],
(page_info->is_old) ? "YES" : "NO")); (page_info->is_old) ? "YES" : "NO"));
OK(fields[IDX_BUFFER_PAGE_FREE_CLOCK]->store( OK(fields[IDX_BUFFER_PAGE_FREE_CLOCK]->store(
page_info->freed_page_clock)); page_info->freed_page_clock));
if (schema_table_store_record(thd, table)) { OK(schema_table_store_record(thd, table));
DBUG_RETURN(1);
}
} }
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -5569,17 +5581,10 @@ i_s_innodb_buf_page_lru_fill( ...@@ -5569,17 +5581,10 @@ i_s_innodb_buf_page_lru_fill(
ulint num_page) /*!< in: number of page info ulint num_page) /*!< in: number of page info
cached */ cached */
{ {
TABLE* table;
Field** fields;
mem_heap_t* heap;
DBUG_ENTER("i_s_innodb_buf_page_lru_fill"); DBUG_ENTER("i_s_innodb_buf_page_lru_fill");
table = tables->table; TABLE* table = tables->table;
Field** fields = table->field;
fields = table->field;
heap = mem_heap_create(1000);
/* Iterate through the cached array and fill the I_S table rows */ /* Iterate through the cached array and fill the I_S table rows */
for (ulint i = 0; i < num_page; i++) { for (ulint i = 0; i < num_page; i++) {
...@@ -5594,43 +5599,37 @@ i_s_innodb_buf_page_lru_fill( ...@@ -5594,43 +5599,37 @@ i_s_innodb_buf_page_lru_fill(
page_info = info_array + i; page_info = info_array + i;
OK(fields[IDX_BUF_LRU_POOL_ID]->store( OK(fields[IDX_BUF_LRU_POOL_ID]->store(
static_cast<double>(page_info->pool_id))); page_info->pool_id, true));
OK(fields[IDX_BUF_LRU_POS]->store( OK(fields[IDX_BUF_LRU_POS]->store(
static_cast<double>(page_info->block_id))); page_info->block_id, true));
OK(fields[IDX_BUF_LRU_PAGE_SPACE]->store( OK(fields[IDX_BUF_LRU_PAGE_SPACE]->store(
static_cast<double>(page_info->space_id))); page_info->space_id, true));
OK(fields[IDX_BUF_LRU_PAGE_NUM]->store( OK(fields[IDX_BUF_LRU_PAGE_NUM]->store(
static_cast<double>(page_info->page_num))); page_info->page_num, true));
OK(field_store_string( OK(field_store_string(
fields[IDX_BUF_LRU_PAGE_TYPE], fields[IDX_BUF_LRU_PAGE_TYPE],
i_s_page_type[page_info->page_type].type_str)); i_s_page_type[page_info->page_type].type_str));
OK(fields[IDX_BUF_LRU_PAGE_FLUSH_TYPE]->store( OK(fields[IDX_BUF_LRU_PAGE_FLUSH_TYPE]->store(
static_cast<double>(page_info->flush_type))); page_info->flush_type, true));
OK(fields[IDX_BUF_LRU_PAGE_FIX_COUNT]->store( OK(fields[IDX_BUF_LRU_PAGE_FIX_COUNT]->store(
static_cast<double>(page_info->fix_count))); page_info->fix_count, true));
if (page_info->hashed) { OK(field_store_string(fields[IDX_BUF_LRU_PAGE_HASHED],
OK(field_store_string( page_info->hashed ? "YES" : "NO"));
fields[IDX_BUF_LRU_PAGE_HASHED], "YES"));
} else {
OK(field_store_string(
fields[IDX_BUF_LRU_PAGE_HASHED], "NO"));
}
OK(fields[IDX_BUF_LRU_PAGE_NEWEST_MOD]->store( OK(fields[IDX_BUF_LRU_PAGE_NEWEST_MOD]->store(
page_info->newest_mod, true)); page_info->newest_mod, true));
OK(fields[IDX_BUF_LRU_PAGE_OLDEST_MOD]->store( OK(fields[IDX_BUF_LRU_PAGE_OLDEST_MOD]->store(
page_info->oldest_mod, true)); page_info->oldest_mod, true));
OK(fields[IDX_BUF_LRU_PAGE_ACCESS_TIME]->store( OK(fields[IDX_BUF_LRU_PAGE_ACCESS_TIME]->store(
page_info->access_time)); page_info->access_time, true));
fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_null(); fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_null();
...@@ -5639,43 +5638,47 @@ i_s_innodb_buf_page_lru_fill( ...@@ -5639,43 +5638,47 @@ i_s_innodb_buf_page_lru_fill(
/* If this is an index page, fetch the index name /* If this is an index page, fetch the index name
and table name */ and table name */
if (page_info->page_type == I_S_PAGE_TYPE_INDEX) { if (page_info->page_type == I_S_PAGE_TYPE_INDEX) {
const dict_index_t* index; bool ret = false;
mutex_enter(&dict_sys->mutex); mutex_enter(&dict_sys->mutex);
index = dict_index_get_if_in_cache_low(
page_info->index_id);
if (index) {
if (const dict_index_t* index =
dict_index_get_if_in_cache_low(
page_info->index_id)) {
table_name_end = innobase_convert_name( table_name_end = innobase_convert_name(
table_name, sizeof(table_name), table_name, sizeof(table_name),
index->table_name, index->table_name,
strlen(index->table_name), strlen(index->table_name),
thd, TRUE); thd, TRUE);
OK(fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->store( ret = fields[IDX_BUF_LRU_PAGE_TABLE_NAME]
table_name, ->store(table_name,
static_cast<uint>(table_name_end - table_name), static_cast<uint>(
system_charset_info)); table_name_end
fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_notnull(); - table_name),
system_charset_info)
OK(field_store_index_name( || field_store_index_name(
fields[IDX_BUF_LRU_PAGE_INDEX_NAME], fields
index->name)); [IDX_BUF_LRU_PAGE_INDEX_NAME],
index->name);
} }
mutex_exit(&dict_sys->mutex); mutex_exit(&dict_sys->mutex);
OK(ret);
fields[IDX_BUF_LRU_PAGE_TABLE_NAME]->set_notnull();
} }
OK(fields[IDX_BUF_LRU_PAGE_NUM_RECS]->store( OK(fields[IDX_BUF_LRU_PAGE_NUM_RECS]->store(
page_info->num_recs)); page_info->num_recs, true));
OK(fields[IDX_BUF_LRU_PAGE_DATA_SIZE]->store( OK(fields[IDX_BUF_LRU_PAGE_DATA_SIZE]->store(
page_info->data_size)); page_info->data_size, true));
OK(fields[IDX_BUF_LRU_PAGE_ZIP_SIZE]->store( OK(fields[IDX_BUF_LRU_PAGE_ZIP_SIZE]->store(
page_info->zip_ssize ? page_info->zip_ssize
512 << page_info->zip_ssize : 0)); ? 512 << page_info->zip_ssize : 0, true));
state = static_cast<enum buf_page_state>(page_info->page_state); state = static_cast<enum buf_page_state>(page_info->page_state);
...@@ -5704,35 +5707,31 @@ i_s_innodb_buf_page_lru_fill( ...@@ -5704,35 +5707,31 @@ i_s_innodb_buf_page_lru_fill(
switch (page_info->io_fix) { switch (page_info->io_fix) {
case BUF_IO_NONE: case BUF_IO_NONE:
OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX], state_str = "IO_NONE";
"IO_NONE"));
break; break;
case BUF_IO_READ: case BUF_IO_READ:
OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX], state_str = "IO_READ";
"IO_READ"));
break; break;
case BUF_IO_WRITE: case BUF_IO_WRITE:
OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX], state_str = "IO_WRITE";
"IO_WRITE")); break;
case BUF_IO_PIN:
state_str = "IO_PIN";
break; break;
} }
OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX],
state_str));
OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IS_OLD], OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IS_OLD],
(page_info->is_old) ? "YES" : "NO")); page_info->is_old ? "YES" : "NO"));
OK(fields[IDX_BUF_LRU_PAGE_FREE_CLOCK]->store( OK(fields[IDX_BUF_LRU_PAGE_FREE_CLOCK]->store(
page_info->freed_page_clock)); page_info->freed_page_clock, true));
if (schema_table_store_record(thd, table)) {
mem_heap_free(heap);
DBUG_RETURN(1);
}
mem_heap_empty(heap); OK(schema_table_store_record(thd, table));
} }
mem_heap_free(heap);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment