diff options
Diffstat (limited to 'storage/innobase')
61 files changed, 1884 insertions, 4155 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index d6eff63b360..67e0bfdd8b9 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -1507,7 +1507,7 @@ btr_page_reorganize_low( } if (page_zip - && !page_zip_compress(page_zip, page, index, z_level, mtr)) { + && !page_zip_compress(block, index, z_level, mtr)) { /* Restore the old page and exit. */ #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG @@ -1951,7 +1951,7 @@ btr_root_raise_and_insert( ut_a(new_page_zip); /* Copy the page byte for byte. */ - page_zip_copy_recs(new_page_zip, new_page, + page_zip_copy_recs(new_block, root_page_zip, root, index, mtr); /* Update the lock table and possible hash index. */ @@ -3063,7 +3063,7 @@ insert_empty: as appropriate. Deleting will always succeed. */ ut_a(new_page_zip); - page_zip_copy_recs(new_page_zip, new_page, + page_zip_copy_recs(new_block, page_zip, page, cursor->index, mtr); page_delete_rec_list_end(move_limit - page + new_page, new_block, cursor->index, @@ -3106,7 +3106,7 @@ insert_empty: as appropriate. Deleting will always succeed. */ ut_a(new_page_zip); - page_zip_copy_recs(new_page_zip, new_page, + page_zip_copy_recs(new_block, page_zip, page, cursor->index, mtr); page_delete_rec_list_start(move_limit - page + new_page, new_block, @@ -3396,7 +3396,6 @@ btr_lift_page_up( mtr_t* mtr) /*!< in: mtr */ { buf_block_t* father_block; - page_t* father_page; ulint page_level; page_zip_des_t* father_page_zip; page_t* page = buf_block_get_frame(block); @@ -3433,7 +3432,6 @@ btr_lift_page_up( } father_block = btr_cur_get_block(&cursor); father_page_zip = buf_block_get_page_zip(father_block); - father_page = buf_block_get_frame(father_block); n_blocks = 0; @@ -3481,7 +3479,6 @@ btr_lift_page_up( father_block = blocks[0]; father_page_zip = buf_block_get_page_zip(father_block); - father_page = buf_block_get_frame(father_block); } mem_heap_free(heap); @@ -3516,7 +3513,7 @@ btr_lift_page_up( ut_a(page_zip); /* Copy the page byte for byte. */ - page_zip_copy_recs(father_page_zip, father_page, + page_zip_copy_recs(father_block, page_zip, page, index, mtr); /* Update the lock table and possible hash index. */ @@ -3569,7 +3566,7 @@ btr_lift_page_up( && !index->table->is_temporary()) { ibuf_reset_free_bits(father_block); } - ut_ad(page_validate(father_page, index)); + ut_ad(page_validate(father_block->frame, index)); ut_ad(btr_check_node_ptr(index, father_block, mtr)); return(lift_father_up ? block_orig : father_block); diff --git a/storage/innobase/btr/btr0bulk.cc b/storage/innobase/btr/btr0bulk.cc index 6123fafcbac..af5041caebe 100644 --- a/storage/innobase/btr/btr0bulk.cc +++ b/storage/innobase/btr/btr0bulk.cc @@ -373,8 +373,7 @@ PageBulk::compress() { ut_ad(m_page_zip != NULL); - return(page_zip_compress(m_page_zip, m_page, m_index, - page_zip_level, &m_mtr)); + return page_zip_compress(m_block, m_index, page_zip_level, &m_mtr); } /** Get node pointer diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index d9af896e5c0..ae13e5790d5 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1580,6 +1580,7 @@ buf_block_init( block->page.io_fix = BUF_IO_NONE; block->page.flush_observer = NULL; block->page.encrypted = false; + block->page.init_on_flush = false; block->page.real_size = 0; block->page.write_size = 0; block->modify_clock = 0; @@ -3156,7 +3157,7 @@ calc_buf_pool_size: " dictionary."; } - /* normalize ibuf->max_size */ + /* normalize ibuf.max_size */ ibuf_max_size_update(srv_change_buffer_max_size); if (srv_buf_pool_old_size != srv_buf_pool_size) { @@ -5545,6 +5546,7 @@ buf_page_init_for_read( bpage->state = BUF_BLOCK_ZIP_PAGE; bpage->id = page_id; bpage->flush_observer = NULL; + bpage->init_on_flush = false; ut_d(bpage->in_page_hash = FALSE); ut_d(bpage->in_zip_hash = FALSE); @@ -7006,7 +7008,7 @@ void buf_stats_get_pool_info( /*====================*/ buf_pool_t* buf_pool, /*!< in: buffer pool */ - ulint pool_id, /*!< in: buffer pool ID */ + uint pool_id, /*!< in: buffer pool ID */ buf_pool_info_t* all_pool_info) /*!< in/out: buffer pool info to fill */ { @@ -7235,7 +7237,6 @@ 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; @@ -7255,7 +7256,7 @@ buf_print_io( ut_zalloc_nokey(sizeof *pool_info)); } - for (i = 0; i < srv_buf_pool_instances; i++) { + for (uint i = 0; i < srv_buf_pool_instances; i++) { buf_pool_t* buf_pool; buf_pool = buf_pool_from_array(i); @@ -7282,8 +7283,8 @@ buf_print_io( "INDIVIDUAL BUFFER POOL INFO\n" "----------------------\n", file); - for (i = 0; i < srv_buf_pool_instances; i++) { - fprintf(file, "---BUFFER POOL " ULINTPF "\n", i); + for (uint i = 0; i < srv_buf_pool_instances; i++) { + fprintf(file, "---BUFFER POOL %u\n", i); buf_print_io_instance(&pool_info[i], file); } } diff --git a/storage/innobase/buf/buf0checksum.cc b/storage/innobase/buf/buf0checksum.cc index 2b2a74dd736..e98dc18452e 100644 --- a/storage/innobase/buf/buf0checksum.cc +++ b/storage/innobase/buf/buf0checksum.cc @@ -33,11 +33,8 @@ Created Aug 11, 2011 Vasil Dimov #include "srv0srv.h" #endif /* !UNIV_INNOCHECKSUM */ -/** the macro MYSQL_SYSVAR_ENUM() requires "long unsigned int" and if we -use srv_checksum_algorithm_t here then we get a compiler error: -ha_innodb.cc:12251: error: cannot convert 'srv_checksum_algorithm_t*' to - 'long unsigned int*' in initialization */ -ulong srv_checksum_algorithm = SRV_CHECKSUM_ALGORITHM_INNODB; +/** the value of innodb_checksum_algorithm */ +ulong srv_checksum_algorithm; /** Calculate the CRC32 checksum of a page. The value is stored to the page when it is written to a file and also checked for a match when reading from diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 65febb14a76..658d023c9c7 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -63,7 +63,7 @@ static const ulint buf_flush_wait_flushed_sleep_time = 10000; #include <my_service_manager.h> /** Number of pages flushed through non flush_list flushes. */ -static ulint buf_lru_flush_page_count = 0; +ulint buf_lru_flush_page_count; /** Flag indicating if the page_cleaner is in active state. This flag is set to TRUE by the page_cleaner thread when it is spawned and is set @@ -1040,7 +1040,10 @@ buf_flush_write_block_low( ut_ad(space->purpose == FIL_TYPE_TABLESPACE || space->atomic_write_supported); - if (!space->use_doublewrite()) { + const bool use_doublewrite = !bpage->init_on_flush + && space->use_doublewrite(); + + if (!use_doublewrite) { ulint type = IORequest::WRITE | IORequest::DO_NOT_WAKE; IORequest request(type, bpage); @@ -1081,7 +1084,7 @@ buf_flush_write_block_low( #endif /* true means we want to evict this page from the LRU list as well. */ - buf_page_io_complete(bpage, space->use_doublewrite(), true); + buf_page_io_complete(bpage, use_doublewrite, true); ut_ad(err == DB_SUCCESS); } diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index 0f67584fe4d..e2e93e2d0bb 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -703,12 +703,6 @@ buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf) ulint ibuf_mode = ibuf ? BUF_READ_IBUF_PAGES_ONLY : BUF_READ_ANY_PAGE; - /* Since Windows XP seems to schedule the i/o handler thread - very eagerly, and consequently it does not wait for the - full read batch to be posted, we use special heuristics here */ - - os_aio_simulated_put_read_threads_to_sleep(); - for (i = low; i < high; i++) { /* It is only sensible to do read-ahead in the non-sync aio mode: hence FALSE as the first parameter */ diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index bb80c7ca423..fea537166f9 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -6139,7 +6139,7 @@ void dict_sys_t::close() if (dict_foreign_err_file) { - fclose(dict_foreign_err_file); + my_fclose(dict_foreign_err_file, MYF(MY_WME)); dict_foreign_err_file = NULL; } @@ -6455,25 +6455,6 @@ dict_tf_to_row_format_string( return(0); } -/** Calculate the used memory occupied by the data dictionary -table and index objects. -@return number of bytes occupied. */ -UNIV_INTERN -ulint -dict_sys_get_size() -{ - /* No mutex; this is a very crude approximation anyway */ - ulint size = UT_LIST_GET_LEN(dict_sys.table_LRU) - + UT_LIST_GET_LEN(dict_sys.table_non_LRU); - size *= sizeof(dict_table_t) - + sizeof(dict_index_t) * 2 - + (sizeof(dict_col_t) + sizeof(dict_field_t)) * 10 - + sizeof(dict_field_t) * 5 /* total number of key fields */ - + 200; /* arbitrary, covering names and overhead */ - - return size; -} - /** Look for any dictionary objects that are found in the given tablespace. @param[in] space_id Tablespace ID to search for. @return true if tablespace is empty. */ diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index 0552145ab07..4adf886118b 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -675,18 +675,13 @@ dict_process_sys_tablespaces( /*=========================*/ mem_heap_t* heap, /*!< in/out: heap memory */ const rec_t* rec, /*!< in: current SYS_TABLESPACES rec */ - ulint* space, /*!< out: space id */ + uint32_t* space, /*!< out: tablespace identifier */ const char** name, /*!< out: tablespace name */ ulint* flags) /*!< out: tablespace flags */ { ulint len; const byte* field; - /* Initialize the output values */ - *space = ULINT_UNDEFINED; - *name = NULL; - *flags = ULINT_UNDEFINED; - if (rec_get_deleted_flag(rec, 0)) { return("delete-marked record in SYS_TABLESPACES"); } @@ -741,7 +736,7 @@ dict_process_sys_datafiles( /*=======================*/ mem_heap_t* heap, /*!< in/out: heap memory */ const rec_t* rec, /*!< in: current SYS_DATAFILES rec */ - ulint* space, /*!< out: space id */ + uint32_t* space, /*!< out: space id */ const char** path) /*!< out: datafile paths */ { ulint len; diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index bc032ed6aa0..b46a5d33843 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -4374,7 +4374,7 @@ fil_aio_wait( fil_node_complete_io(node, type); const fil_type_t purpose = node->space->purpose; const ulint space_id= node->space->id; - const bool dblwr = node->space->use_doublewrite(); + bool dblwr = node->space->use_doublewrite(); mutex_exit(&fil_system.mutex); @@ -4423,6 +4423,10 @@ fil_aio_wait( } ulint offset = bpage->id.page_no(); + if (dblwr && bpage->init_on_flush) { + bpage->init_on_flush = false; + dblwr = false; + } dberr_t err = buf_page_io_complete(bpage, dblwr); if (err == DB_SUCCESS) { return; diff --git a/storage/innobase/fts/fts0blex.cc b/storage/innobase/fts/fts0blex.cc index 2f66e9740aa..6a2b42025a0 100644 --- a/storage/innobase/fts/fts0blex.cc +++ b/storage/innobase/fts/fts0blex.cc @@ -478,7 +478,7 @@ struct yy_buffer_state */ #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) + : 0) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ diff --git a/storage/innobase/gis/gis0rtree.cc b/storage/innobase/gis/gis0rtree.cc index 44facb59f4b..30faf719e7d 100644 --- a/storage/innobase/gis/gis0rtree.cc +++ b/storage/innobase/gis/gis0rtree.cc @@ -922,7 +922,7 @@ rtr_split_page_move_rec_list( if (new_page_zip) { mtr_set_log_mode(mtr, log_mode); - if (!page_zip_compress(new_page_zip, new_page, index, + if (!page_zip_compress(new_block, index, page_zip_level, mtr)) { ulint ret_pos; @@ -1130,7 +1130,7 @@ func_start: as appropriate. Deleting will always succeed. */ ut_a(new_page_zip); - page_zip_copy_recs(new_page_zip, new_page, + page_zip_copy_recs(new_block, page_zip, page, cursor->index, mtr); page_cursor = btr_cur_get_page_cur(cursor); @@ -1243,7 +1243,7 @@ func_start: For compressed pages, page_cur_tuple_insert() will have attempted this already. */ if (rec == NULL) { - if (!page_cur_get_page_zip(page_cursor) + if (!is_page_cur_get_page_zip(page_cursor) && btr_page_reorganize(page_cursor, cursor->index, mtr)) { rec = page_cur_tuple_insert(page_cursor, tuple, cursor->index, offsets, diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index 888cbe3e81f..7bb880aecc2 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -1694,7 +1694,7 @@ rtr_cur_search_with_match( and the table is a compressed table, try to avoid first page as much as possible, as there will be problem when update MIN_REC rec in compress table */ - if (buf_block_get_page_zip(block) + if (is_buf_block_get_page_zip(block) && !page_has_prev(page) && page_get_n_recs(page) >= 2) { diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index abe860fea86..9f4c04741b6 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -202,8 +202,6 @@ static char* innobase_server_stopword_table; values */ static my_bool innobase_use_atomic_writes; -static my_bool innobase_use_checksums; -static my_bool innobase_locks_unsafe_for_binlog; static my_bool innobase_rollback_on_timeout; static my_bool innobase_create_status_file; my_bool innobase_stats_on_metadata; @@ -863,7 +861,7 @@ innodb_tmpdir_validate( Maps a MySQL trx isolation level code to the InnoDB isolation level code @return InnoDB isolation level */ static inline -ulint +uint innobase_map_isolation_level( /*=========================*/ enum_tx_isolation iso); /*!< in: MySQL isolation level code */ @@ -945,6 +943,14 @@ static MYSQL_THDVAR_STR(tmpdir, innodb_tmpdir_validate, NULL, NULL); static SHOW_VAR innodb_status_variables[]= { +#ifdef BTR_CUR_HASH_ADAPT + {"adaptive_hash_hash_searches", &btr_cur_n_sea, SHOW_SIZE_T}, + {"adaptive_hash_non_hash_searches", &btr_cur_n_non_sea, SHOW_SIZE_T}, +#endif + {"background_log_sync", &srv_log_writes_and_flush, SHOW_SIZE_T}, +#if defined(LINUX_NATIVE_AIO) + {"buffered_aio_submitted", &srv_stats.buffered_aio_submitted, SHOW_SIZE_T}, +#endif {"buffer_pool_dump_status", (char*) &export_vars.innodb_buffer_pool_dump_status, SHOW_CHAR}, {"buffer_pool_load_status", @@ -954,236 +960,212 @@ static SHOW_VAR innodb_status_variables[]= { {"buffer_pool_load_incomplete", &export_vars.innodb_buffer_pool_load_incomplete, SHOW_BOOL}, {"buffer_pool_pages_data", - (char*) &export_vars.innodb_buffer_pool_pages_data, SHOW_LONG}, + &export_vars.innodb_buffer_pool_pages_data, SHOW_SIZE_T}, {"buffer_pool_bytes_data", - (char*) &export_vars.innodb_buffer_pool_bytes_data, SHOW_LONG}, + &export_vars.innodb_buffer_pool_bytes_data, SHOW_SIZE_T}, {"buffer_pool_pages_dirty", - (char*) &export_vars.innodb_buffer_pool_pages_dirty, SHOW_LONG}, + &export_vars.innodb_buffer_pool_pages_dirty, SHOW_SIZE_T}, {"buffer_pool_bytes_dirty", - (char*) &export_vars.innodb_buffer_pool_bytes_dirty, SHOW_LONG}, + &export_vars.innodb_buffer_pool_bytes_dirty, SHOW_SIZE_T}, {"buffer_pool_pages_flushed", - (char*) &export_vars.innodb_buffer_pool_pages_flushed, SHOW_LONG}, + &export_vars.innodb_buffer_pool_pages_flushed, SHOW_SIZE_T}, {"buffer_pool_pages_free", - (char*) &export_vars.innodb_buffer_pool_pages_free, SHOW_LONG}, + &export_vars.innodb_buffer_pool_pages_free, SHOW_SIZE_T}, #ifdef UNIV_DEBUG {"buffer_pool_pages_latched", - (char*) &export_vars.innodb_buffer_pool_pages_latched, SHOW_LONG}, + &export_vars.innodb_buffer_pool_pages_latched, SHOW_SIZE_T}, #endif /* UNIV_DEBUG */ + {"buffer_pool_pages_made_not_young", + &export_vars.innodb_buffer_pool_pages_made_not_young, SHOW_SIZE_T}, + {"buffer_pool_pages_made_young", + &export_vars.innodb_buffer_pool_pages_made_young, SHOW_SIZE_T}, {"buffer_pool_pages_misc", - (char*) &export_vars.innodb_buffer_pool_pages_misc, SHOW_LONG}, + &export_vars.innodb_buffer_pool_pages_misc, SHOW_SIZE_T}, + {"buffer_pool_pages_old", + &export_vars.innodb_buffer_pool_pages_old, SHOW_SIZE_T}, {"buffer_pool_pages_total", - (char*) &export_vars.innodb_buffer_pool_pages_total, SHOW_LONG}, + &export_vars.innodb_buffer_pool_pages_total, SHOW_SIZE_T}, + {"buffer_pool_pages_LRU_flushed", &buf_lru_flush_page_count, SHOW_SIZE_T}, {"buffer_pool_read_ahead_rnd", - (char*) &export_vars.innodb_buffer_pool_read_ahead_rnd, SHOW_LONG}, + &export_vars.innodb_buffer_pool_read_ahead_rnd, SHOW_SIZE_T}, {"buffer_pool_read_ahead", - (char*) &export_vars.innodb_buffer_pool_read_ahead, SHOW_LONG}, + &export_vars.innodb_buffer_pool_read_ahead, SHOW_SIZE_T}, {"buffer_pool_read_ahead_evicted", - (char*) &export_vars.innodb_buffer_pool_read_ahead_evicted, SHOW_LONG}, + &export_vars.innodb_buffer_pool_read_ahead_evicted, SHOW_SIZE_T}, {"buffer_pool_read_requests", - (char*) &export_vars.innodb_buffer_pool_read_requests, SHOW_LONG}, + &export_vars.innodb_buffer_pool_read_requests, SHOW_SIZE_T}, {"buffer_pool_reads", - (char*) &export_vars.innodb_buffer_pool_reads, SHOW_LONG}, + &export_vars.innodb_buffer_pool_reads, SHOW_SIZE_T}, {"buffer_pool_wait_free", - (char*) &export_vars.innodb_buffer_pool_wait_free, SHOW_LONG}, + &export_vars.innodb_buffer_pool_wait_free, SHOW_SIZE_T}, {"buffer_pool_write_requests", - (char*) &export_vars.innodb_buffer_pool_write_requests, SHOW_LONG}, - {"data_fsyncs", - (char*) &export_vars.innodb_data_fsyncs, SHOW_LONG}, - {"data_pending_fsyncs", - (char*) &export_vars.innodb_data_pending_fsyncs, SHOW_LONG}, - {"data_pending_reads", - (char*) &export_vars.innodb_data_pending_reads, SHOW_LONG}, - {"data_pending_writes", - (char*) &export_vars.innodb_data_pending_writes, SHOW_LONG}, - {"data_read", - (char*) &export_vars.innodb_data_read, SHOW_LONG}, - {"data_reads", - (char*) &export_vars.innodb_data_reads, SHOW_LONG}, - {"data_writes", - (char*) &export_vars.innodb_data_writes, SHOW_LONG}, - {"data_written", - (char*) &export_vars.innodb_data_written, SHOW_LONG}, - {"dblwr_pages_written", - (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG}, - {"dblwr_writes", - (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG}, - {"log_waits", - (char*) &export_vars.innodb_log_waits, SHOW_LONG}, - {"log_write_requests", - (char*) &export_vars.innodb_log_write_requests, SHOW_LONG}, - {"log_writes", - (char*) &export_vars.innodb_log_writes, SHOW_LONG}, - {"os_log_fsyncs", - (char*) &export_vars.innodb_os_log_fsyncs, SHOW_LONG}, - {"os_log_pending_fsyncs", - (char*) &export_vars.innodb_os_log_pending_fsyncs, SHOW_LONG}, - {"os_log_pending_writes", - (char*) &export_vars.innodb_os_log_pending_writes, SHOW_LONG}, - {"os_log_written", - (char*) &export_vars.innodb_os_log_written, SHOW_LONGLONG}, - {"page_size", - (char*) &export_vars.innodb_page_size, SHOW_LONG}, - {"pages_created", - (char*) &export_vars.innodb_pages_created, SHOW_LONG}, - {"pages_read", - (char*) &export_vars.innodb_pages_read, SHOW_LONG}, - {"pages_written", - (char*) &export_vars.innodb_pages_written, SHOW_LONG}, - {"row_lock_current_waits", - (char*) &export_vars.innodb_row_lock_current_waits, SHOW_LONG}, - {"row_lock_time", - (char*) &export_vars.innodb_row_lock_time, SHOW_LONGLONG}, - {"row_lock_time_avg", - (char*) &export_vars.innodb_row_lock_time_avg, SHOW_LONG}, - {"row_lock_time_max", - (char*) &export_vars.innodb_row_lock_time_max, SHOW_LONG}, - {"row_lock_waits", - (char*) &export_vars.innodb_row_lock_waits, SHOW_LONG}, - {"rows_deleted", - (char*) &export_vars.innodb_rows_deleted, SHOW_LONG}, - {"rows_inserted", - (char*) &export_vars.innodb_rows_inserted, SHOW_LONG}, - {"rows_read", - (char*) &export_vars.innodb_rows_read, SHOW_LONG}, - {"rows_updated", - (char*) &export_vars.innodb_rows_updated, SHOW_LONG}, - {"system_rows_deleted", - (char*) &export_vars.innodb_system_rows_deleted, SHOW_LONG}, - {"system_rows_inserted", - (char*) &export_vars.innodb_system_rows_inserted, SHOW_LONG}, - {"system_rows_read", - (char*) &export_vars.innodb_system_rows_read, SHOW_LONG}, - {"system_rows_updated", - (char*) &export_vars.innodb_system_rows_updated, SHOW_LONG}, - {"num_open_files", - (char*) &export_vars.innodb_num_open_files, SHOW_LONG}, - {"truncated_status_writes", - (char*) &export_vars.innodb_truncated_status_writes, SHOW_LONG}, - {"available_undo_logs", - (char*) &export_vars.innodb_available_undo_logs, SHOW_LONG}, - {"undo_truncations", - (char*) &export_vars.innodb_undo_truncations, SHOW_LONG}, + &export_vars.innodb_buffer_pool_write_requests, SHOW_SIZE_T}, + {"checkpoint_age", &export_vars.innodb_checkpoint_age, SHOW_SIZE_T}, + {"checkpoint_max_age", &export_vars.innodb_checkpoint_max_age, SHOW_SIZE_T}, + {"data_fsyncs", &export_vars.innodb_data_fsyncs, SHOW_SIZE_T}, + {"data_pending_fsyncs", &export_vars.innodb_data_pending_fsyncs,SHOW_SIZE_T}, + {"data_pending_reads", &export_vars.innodb_data_pending_reads, SHOW_SIZE_T}, + {"data_pending_writes", &export_vars.innodb_data_pending_writes,SHOW_SIZE_T}, + {"data_read", &export_vars.innodb_data_read, SHOW_SIZE_T}, + {"data_reads", &export_vars.innodb_data_reads, SHOW_SIZE_T}, + {"data_writes", &export_vars.innodb_data_writes, SHOW_SIZE_T}, + {"data_written", &export_vars.innodb_data_written, SHOW_SIZE_T}, + {"dblwr_pages_written", &export_vars.innodb_dblwr_pages_written,SHOW_SIZE_T}, + {"dblwr_writes", &export_vars.innodb_dblwr_writes, SHOW_SIZE_T}, + {"deadlocks", &srv_stats.lock_deadlock_count, SHOW_SIZE_T}, + {"history_list_length", &export_vars.innodb_history_list_length,SHOW_SIZE_T}, + {"ibuf_discarded_delete_marks", &ibuf.n_discarded_ops[IBUF_OP_DELETE_MARK], + SHOW_SIZE_T}, + {"ibuf_discarded_deletes", &ibuf.n_discarded_ops[IBUF_OP_DELETE], + SHOW_SIZE_T}, + {"ibuf_discarded_inserts", &ibuf.n_discarded_ops[IBUF_OP_INSERT], + SHOW_SIZE_T}, + {"ibuf_free_list", &ibuf.free_list_len, SHOW_SIZE_T}, + {"ibuf_merged_delete_marks", &ibuf.n_merged_ops[IBUF_OP_DELETE_MARK], + SHOW_SIZE_T}, + {"ibuf_merged_deletes", &ibuf.n_merged_ops[IBUF_OP_DELETE], SHOW_SIZE_T}, + {"ibuf_merged_inserts", &ibuf.n_merged_ops[IBUF_OP_INSERT], SHOW_SIZE_T}, + {"ibuf_merges", &ibuf.n_merges, SHOW_SIZE_T}, + {"ibuf_segment_size", &ibuf.seg_size, SHOW_SIZE_T}, + {"ibuf_size", &ibuf.size, SHOW_SIZE_T}, + {"log_waits", &export_vars.innodb_log_waits, SHOW_SIZE_T}, + {"log_write_requests", &export_vars.innodb_log_write_requests, SHOW_SIZE_T}, + {"log_writes", &export_vars.innodb_log_writes, SHOW_SIZE_T}, + {"lsn_current", &export_vars.innodb_lsn_current, SHOW_ULONGLONG}, + {"lsn_flushed", &export_vars.innodb_lsn_flushed, SHOW_ULONGLONG}, + {"lsn_last_checkpoint", &export_vars.innodb_lsn_last_checkpoint, + SHOW_ULONGLONG}, + {"master_thread_active_loops", &srv_main_active_loops, SHOW_SIZE_T}, + {"master_thread_idle_loops", &srv_main_idle_loops, SHOW_SIZE_T}, + {"max_trx_id", &export_vars.innodb_max_trx_id, SHOW_ULONGLONG}, +#ifdef BTR_CUR_HASH_ADAPT + {"mem_adaptive_hash", &export_vars.innodb_mem_adaptive_hash, SHOW_SIZE_T}, +#endif + {"mem_dictionary", &export_vars.innodb_mem_dictionary, SHOW_SIZE_T}, + {"os_log_fsyncs", &export_vars.innodb_os_log_fsyncs, SHOW_SIZE_T}, + {"os_log_pending_fsyncs", &export_vars.innodb_os_log_pending_fsyncs, + SHOW_SIZE_T}, + {"os_log_pending_writes", &export_vars.innodb_os_log_pending_writes, + SHOW_SIZE_T}, + {"os_log_written", &export_vars.innodb_os_log_written, SHOW_SIZE_T}, + {"page_size", &srv_page_size, SHOW_ULONG}, + {"pages_created", &export_vars.innodb_pages_created, SHOW_SIZE_T}, + {"pages_read", &export_vars.innodb_pages_read, SHOW_SIZE_T}, + {"pages_written", &export_vars.innodb_pages_written, SHOW_SIZE_T}, + {"row_lock_current_waits", &export_vars.innodb_row_lock_current_waits, + SHOW_SIZE_T}, + {"row_lock_time", &export_vars.innodb_row_lock_time, SHOW_LONGLONG}, + {"row_lock_time_avg", &export_vars.innodb_row_lock_time_avg, SHOW_SIZE_T}, + {"row_lock_time_max", &export_vars.innodb_row_lock_time_max, SHOW_SIZE_T}, + {"row_lock_waits", &export_vars.innodb_row_lock_waits, SHOW_SIZE_T}, + {"rows_deleted", &export_vars.innodb_rows_deleted, SHOW_SIZE_T}, + {"rows_inserted", &export_vars.innodb_rows_inserted, SHOW_SIZE_T}, + {"rows_read", &export_vars.innodb_rows_read, SHOW_SIZE_T}, + {"rows_updated", &export_vars.innodb_rows_updated, SHOW_SIZE_T}, + {"system_rows_deleted", &export_vars.innodb_system_rows_deleted,SHOW_SIZE_T}, + {"system_rows_inserted", &export_vars.innodb_system_rows_inserted, + SHOW_SIZE_T}, + {"system_rows_read", &export_vars.innodb_system_rows_read, SHOW_SIZE_T}, + {"system_rows_updated", &export_vars.innodb_system_rows_updated, + SHOW_SIZE_T}, + {"num_open_files", &export_vars.innodb_num_open_files, SHOW_SIZE_T}, + {"truncated_status_writes", &export_vars.innodb_truncated_status_writes, + SHOW_SIZE_T}, + {"available_undo_logs", &srv_available_undo_logs, SHOW_ULONG}, + {"undo_truncations", &export_vars.innodb_undo_truncations, SHOW_ULONG}, /* Status variables for page compression */ {"page_compression_saved", - (char*) &export_vars.innodb_page_compression_saved, SHOW_LONGLONG}, + &export_vars.innodb_page_compression_saved, SHOW_LONGLONG}, {"num_index_pages_written", - (char*) &export_vars.innodb_index_pages_written, SHOW_LONGLONG}, + &export_vars.innodb_index_pages_written, SHOW_LONGLONG}, {"num_non_index_pages_written", - (char*) &export_vars.innodb_non_index_pages_written, SHOW_LONGLONG}, + &export_vars.innodb_non_index_pages_written, SHOW_LONGLONG}, {"num_pages_page_compressed", - (char*) &export_vars.innodb_pages_page_compressed, SHOW_LONGLONG}, + &export_vars.innodb_pages_page_compressed, SHOW_LONGLONG}, {"num_page_compressed_trim_op", - (char*) &export_vars.innodb_page_compressed_trim_op, SHOW_LONGLONG}, + &export_vars.innodb_page_compressed_trim_op, SHOW_LONGLONG}, {"num_pages_page_decompressed", - (char*) &export_vars.innodb_pages_page_decompressed, SHOW_LONGLONG}, + &export_vars.innodb_pages_page_decompressed, SHOW_LONGLONG}, {"num_pages_page_compression_error", - (char*) &export_vars.innodb_pages_page_compression_error, SHOW_LONGLONG}, + &export_vars.innodb_pages_page_compression_error, SHOW_LONGLONG}, {"num_pages_encrypted", - (char*) &export_vars.innodb_pages_encrypted, SHOW_LONGLONG}, + &export_vars.innodb_pages_encrypted, SHOW_LONGLONG}, {"num_pages_decrypted", - (char*) &export_vars.innodb_pages_decrypted, SHOW_LONGLONG}, - {"have_lz4", - (char*) &innodb_have_lz4, SHOW_BOOL}, - {"have_lzo", - (char*) &innodb_have_lzo, SHOW_BOOL}, - {"have_lzma", - (char*) &innodb_have_lzma, SHOW_BOOL}, - {"have_bzip2", - (char*) &innodb_have_bzip2, SHOW_BOOL}, - {"have_snappy", - (char*) &innodb_have_snappy, SHOW_BOOL}, - {"have_punch_hole", - (char*) &innodb_have_punch_hole, SHOW_BOOL}, + &export_vars.innodb_pages_decrypted, SHOW_LONGLONG}, + {"have_lz4", &innodb_have_lz4, SHOW_BOOL}, + {"have_lzo", &innodb_have_lzo, SHOW_BOOL}, + {"have_lzma", &innodb_have_lzma, SHOW_BOOL}, + {"have_bzip2", &innodb_have_bzip2, SHOW_BOOL}, + {"have_snappy", &innodb_have_snappy, SHOW_BOOL}, + {"have_punch_hole", &innodb_have_punch_hole, SHOW_BOOL}, /* Defragmentation */ {"defragment_compression_failures", - (char*) &export_vars.innodb_defragment_compression_failures, SHOW_LONG}, - {"defragment_failures", - (char*) &export_vars.innodb_defragment_failures, SHOW_LONG}, - {"defragment_count", - (char*) &export_vars.innodb_defragment_count, SHOW_LONG}, + &export_vars.innodb_defragment_compression_failures, SHOW_SIZE_T}, + {"defragment_failures", &export_vars.innodb_defragment_failures,SHOW_SIZE_T}, + {"defragment_count", &export_vars.innodb_defragment_count, SHOW_SIZE_T}, {"instant_alter_column", - (char*) &export_vars.innodb_instant_alter_column, SHOW_LONG}, + &export_vars.innodb_instant_alter_column, SHOW_ULONG}, /* Online alter table status variables */ {"onlineddl_rowlog_rows", - (char*) &export_vars.innodb_onlineddl_rowlog_rows, SHOW_LONG}, + &export_vars.innodb_onlineddl_rowlog_rows, SHOW_SIZE_T}, {"onlineddl_rowlog_pct_used", - (char*) &export_vars.innodb_onlineddl_rowlog_pct_used, SHOW_LONG}, + &export_vars.innodb_onlineddl_rowlog_pct_used, SHOW_SIZE_T}, {"onlineddl_pct_progress", - (char*) &export_vars.innodb_onlineddl_pct_progress, SHOW_LONG}, + &export_vars.innodb_onlineddl_pct_progress, SHOW_SIZE_T}, /* Times secondary index lookup triggered cluster lookup and times prefix optimization avoided triggering cluster lookup */ {"secondary_index_triggered_cluster_reads", - (char*) &export_vars.innodb_sec_rec_cluster_reads, SHOW_LONG}, + &export_vars.innodb_sec_rec_cluster_reads, SHOW_SIZE_T}, {"secondary_index_triggered_cluster_reads_avoided", - (char*) &export_vars.innodb_sec_rec_cluster_reads_avoided, SHOW_LONG}, + &export_vars.innodb_sec_rec_cluster_reads_avoided, SHOW_SIZE_T}, /* Encryption */ {"encryption_rotation_pages_read_from_cache", - (char*) &export_vars.innodb_encryption_rotation_pages_read_from_cache, - SHOW_LONG}, + &export_vars.innodb_encryption_rotation_pages_read_from_cache, SHOW_SIZE_T}, {"encryption_rotation_pages_read_from_disk", - (char*) &export_vars.innodb_encryption_rotation_pages_read_from_disk, - SHOW_LONG}, + &export_vars.innodb_encryption_rotation_pages_read_from_disk, SHOW_SIZE_T}, {"encryption_rotation_pages_modified", - (char*) &export_vars.innodb_encryption_rotation_pages_modified, - SHOW_LONG}, + &export_vars.innodb_encryption_rotation_pages_modified, SHOW_SIZE_T}, {"encryption_rotation_pages_flushed", - (char*) &export_vars.innodb_encryption_rotation_pages_flushed, - SHOW_LONG}, + &export_vars.innodb_encryption_rotation_pages_flushed, SHOW_SIZE_T}, {"encryption_rotation_estimated_iops", - (char*) &export_vars.innodb_encryption_rotation_estimated_iops, - SHOW_LONG}, + &export_vars.innodb_encryption_rotation_estimated_iops, SHOW_SIZE_T}, {"encryption_key_rotation_list_length", - (char*)&export_vars.innodb_key_rotation_list_length, - SHOW_LONGLONG}, + &export_vars.innodb_key_rotation_list_length, SHOW_LONGLONG}, {"encryption_n_merge_blocks_encrypted", - (char*)&export_vars.innodb_n_merge_blocks_encrypted, - SHOW_LONGLONG}, + &export_vars.innodb_n_merge_blocks_encrypted, SHOW_LONGLONG}, {"encryption_n_merge_blocks_decrypted", - (char*)&export_vars.innodb_n_merge_blocks_decrypted, - SHOW_LONGLONG}, + &export_vars.innodb_n_merge_blocks_decrypted, SHOW_LONGLONG}, {"encryption_n_rowlog_blocks_encrypted", - (char*)&export_vars.innodb_n_rowlog_blocks_encrypted, - SHOW_LONGLONG}, + &export_vars.innodb_n_rowlog_blocks_encrypted, SHOW_LONGLONG}, {"encryption_n_rowlog_blocks_decrypted", - (char*)&export_vars.innodb_n_rowlog_blocks_decrypted, - SHOW_LONGLONG}, + &export_vars.innodb_n_rowlog_blocks_decrypted, SHOW_LONGLONG}, {"encryption_n_temp_blocks_encrypted", - (char*)&export_vars.innodb_n_temp_blocks_encrypted, - SHOW_LONGLONG}, + &export_vars.innodb_n_temp_blocks_encrypted, SHOW_LONGLONG}, {"encryption_n_temp_blocks_decrypted", - (char*)&export_vars.innodb_n_temp_blocks_decrypted, - SHOW_LONGLONG}, + &export_vars.innodb_n_temp_blocks_decrypted, SHOW_LONGLONG}, /* scrubing */ {"scrub_background_page_reorganizations", - (char*) &export_vars.innodb_scrub_page_reorganizations, - SHOW_LONG}, - {"scrub_background_page_splits", - (char*) &export_vars.innodb_scrub_page_splits, - SHOW_LONG}, + &export_vars.innodb_scrub_page_reorganizations, SHOW_SIZE_T}, + {"scrub_background_page_splits", &export_vars.innodb_scrub_page_splits, + SHOW_SIZE_T}, {"scrub_background_page_split_failures_underflow", - (char*) &export_vars.innodb_scrub_page_split_failures_underflow, - SHOW_LONG}, + &export_vars.innodb_scrub_page_split_failures_underflow, SHOW_SIZE_T}, {"scrub_background_page_split_failures_out_of_filespace", - (char*) &export_vars.innodb_scrub_page_split_failures_out_of_filespace, - SHOW_LONG}, + &export_vars.innodb_scrub_page_split_failures_out_of_filespace,SHOW_SIZE_T}, {"scrub_background_page_split_failures_missing_index", - (char*) &export_vars.innodb_scrub_page_split_failures_missing_index, - SHOW_LONG}, + &export_vars.innodb_scrub_page_split_failures_missing_index, SHOW_SIZE_T}, {"scrub_background_page_split_failures_unknown", - (char*) &export_vars.innodb_scrub_page_split_failures_unknown, - SHOW_LONG}, - {"scrub_log", - (char*) &export_vars.innodb_scrub_log, + &export_vars.innodb_scrub_page_split_failures_unknown, SHOW_SIZE_T}, + {"scrub_log", &export_vars.innodb_scrub_log, SHOW_LONGLONG}, + {"encryption_num_key_requests", &export_vars.innodb_encryption_key_requests, SHOW_LONGLONG}, - {"encryption_num_key_requests", - (char*) &export_vars.innodb_encryption_key_requests, SHOW_LONGLONG}, {NullS, NullS, SHOW_LONG} }; @@ -2346,96 +2328,6 @@ static bool is_mysql_datadir_path(const char *path) TRUE)); } -static int mysql_tmpfile_path(const char *path, const char *prefix) -{ - DBUG_ASSERT(path != NULL); - DBUG_ASSERT((strlen(path) + strlen(prefix)) <= FN_REFLEN); - - char filename[FN_REFLEN]; - File fd = create_temp_file(filename, path, prefix, O_BINARY | O_SEQUENTIAL, - MYF(MY_WME | MY_TEMPORARY)); - return fd; -} - -/** Creates a temporary file in the location specified by the parameter -path. If the path is NULL, then it will be created in tmpdir. -@param[in] path location for creating temporary file -@return temporary file descriptor, or < 0 on error */ -os_file_t -innobase_mysql_tmpfile( - const char* path) -{ -#ifdef WITH_INNODB_DISALLOW_WRITES - os_event_wait(srv_allow_writes_event); -#endif /* WITH_INNODB_DISALLOW_WRITES */ - File fd; - - DBUG_EXECUTE_IF( - "innobase_tmpfile_creation_failure", - return(OS_FILE_CLOSED); - ); - - if (path == NULL) { - fd = mysql_tmpfile("ib"); - } else { - fd = mysql_tmpfile_path(path, "ib"); - } - - if (fd < 0) - return OS_FILE_CLOSED; - - /* Copy the file descriptor, so that the additional resources - allocated by create_temp_file() can be freed by invoking - my_close(). - - Because the file descriptor returned by this function - will be passed to fdopen(), it will be closed by invoking - fclose(), which in turn will invoke close() instead of - my_close(). */ - -#ifdef _WIN32 - /* Note that on Windows, the integer returned by mysql_tmpfile - has no relation to C runtime file descriptor. Here, we need - to call my_get_osfhandle to get the HANDLE and then convert it - to C runtime filedescriptor. */ - - HANDLE hFile = my_get_osfhandle(fd); - HANDLE hDup; - BOOL bOK = DuplicateHandle( - GetCurrentProcess(), - hFile, GetCurrentProcess(), - &hDup, 0, FALSE, DUPLICATE_SAME_ACCESS); - my_close(fd, MYF(MY_WME)); - - if (!bOK) { - my_osmaperr(GetLastError()); - goto error; - } - return hDup; -#else -#ifdef F_DUPFD_CLOEXEC - int fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0); -#else - int fd2 = dup(fd); -#endif - my_close(fd, MYF(MY_WME)); - if (fd2 < 0) { - set_my_errno(errno); - goto error; - } - return fd2; -#endif - -error: - char errbuf[MYSYS_STRERROR_SIZE]; - - my_error(EE_OUT_OF_FILERESOURCES, - MYF(0), - "ib*", errno, - my_strerror(errbuf, sizeof(errbuf), errno)); - return (OS_FILE_CLOSED); -} - /*********************************************************************//** Wrapper around MySQL's copy_and_convert function. @return number of bytes copied to 'to' */ @@ -3553,46 +3445,6 @@ static int innodb_init_abort() DBUG_RETURN(1); } -/** Update log_checksum_algorithm_ptr with a pointer to the function -corresponding to whether checksums are enabled. -@param[in,out] thd client session, or NULL if at startup -@param[in] check whether redo log block checksums are enabled -@return whether redo log block checksums are enabled */ -static inline -bool -innodb_log_checksums_func_update(THD* thd, bool check) -{ - static const char msg[] = "innodb_encrypt_log implies" - " innodb_log_checksums"; - - ut_ad(!thd == !srv_was_started); - - if (!check) { - check = srv_encrypt_log; - if (!check) { - } else if (thd) { - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - HA_ERR_UNSUPPORTED, msg); - } else { - sql_print_warning(msg); - } - } - - if (thd) { - log_mutex_enter(); - log_checksum_algorithm_ptr = check - ? log_block_calc_checksum_crc32 - : log_block_calc_checksum_none; - log_mutex_exit(); - } else { - log_checksum_algorithm_ptr = check - ? log_block_calc_checksum_crc32 - : log_block_calc_checksum_none; - } - - return(check); -} - /****************************************************************//** Gives the file extension of an InnoDB single-table tablespace. */ static const char* ha_innobase_exts[] = { @@ -3690,6 +3542,17 @@ static void innodb_buffer_pool_size_init() innobase_buffer_pool_size = srv_buf_pool_size; } +/** Deprecated parameter with no effect */ +static my_bool innodb_log_checksums; +/** Deprecation message for innodb_log_checksums */ +static const char* innodb_log_checksums_deprecated += "The parameter innodb_log_checksums is deprecated and has no effect."; +/** Deprecated parameter with no effect */ +static ulong innodb_undo_logs; +/** Deprecation message for innodb_undo_logs */ +static const char* innodb_undo_logs_deprecated += "The parameter innodb_undo_logs is deprecated and has no effect."; + /** Initialize, validate and normalize the InnoDB startup parameters. @return failure code @retval 0 on success @@ -3997,26 +3860,18 @@ static int innodb_init_params() srv_buf_pool_size = ulint(innobase_buffer_pool_size); - if (!innobase_use_checksums) { - ib::warn() << "Setting innodb_checksums to OFF is DEPRECATED." - " This option may be removed in future releases. You" - " should set innodb_checksum_algorithm=NONE instead."; - srv_checksum_algorithm = SRV_CHECKSUM_ALGORITHM_NONE; + if (UNIV_UNLIKELY(!innodb_log_checksums)) { + sql_print_warning(innodb_log_checksums_deprecated); + innodb_log_checksums = TRUE; } - innodb_log_checksums = innodb_log_checksums_func_update( - NULL, innodb_log_checksums); + if (UNIV_UNLIKELY(innodb_undo_logs != TRX_SYS_N_RSEGS)) { + sql_print_warning(innodb_undo_logs_deprecated); + innodb_undo_logs = TRX_SYS_N_RSEGS; + } row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout; - srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog; - if (innobase_locks_unsafe_for_binlog) { - ib::warn() << "Using innodb_locks_unsafe_for_binlog is" - " DEPRECATED. This option may be removed in future" - " releases. Please use READ COMMITTED transaction" - " isolation level instead; " << SET_TRANSACTION_MSG; - } - if (innobase_open_files < 10) { innobase_open_files = 300; if (srv_file_per_table && tc_size > 300 && tc_size < open_files_limit) { @@ -4135,7 +3990,6 @@ static int innodb_init(void* p) handlerton* innobase_hton= static_cast<handlerton*>(p); innodb_hton_ptr = innobase_hton; - innobase_hton->state = SHOW_OPTION_YES; innobase_hton->db_type = DB_TYPE_INNODB; innobase_hton->savepoint_offset = sizeof(trx_named_savept_t); innobase_hton->close_connection = innobase_close_connection; @@ -9010,7 +8864,7 @@ ha_innobase::delete_all_rows() /**********************************************************************//** Removes a new lock set on a row, if it was not read optimistically. This can be called after a row has been read in the processing of an UPDATE or a DELETE -query, if the option innodb_locks_unsafe_for_binlog is set. */ +query. */ void ha_innobase::unlock_row(void) @@ -9026,11 +8880,8 @@ ha_innobase::unlock_row(void) switch (m_prebuilt->row_read_type) { case ROW_READ_WITH_LOCKS: - if (!srv_locks_unsafe_for_binlog - && m_prebuilt->trx->isolation_level - > TRX_ISO_READ_COMMITTED) { + if (m_prebuilt->trx->isolation_level > TRX_ISO_READ_COMMITTED) break; - } /* fall through */ case ROW_READ_TRY_SEMI_CONSISTENT: row_unlock_for_mysql(m_prebuilt, FALSE); @@ -9053,28 +8904,16 @@ ha_innobase::was_semi_consistent_read(void) } /* See handler.h and row0mysql.h for docs on this function. */ - -void -ha_innobase::try_semi_consistent_read(bool yes) -/*===========================================*/ +void ha_innobase::try_semi_consistent_read(bool yes) { - ut_a(m_prebuilt->trx == thd_to_trx(ha_thd())); - + ut_ad(m_prebuilt->trx == thd_to_trx(ha_thd())); /* Row read type is set to semi consistent read if this was - requested by the MySQL and either innodb_locks_unsafe_for_binlog - option is used or this session is using READ COMMITTED isolation - level. */ - - if (yes - && (srv_locks_unsafe_for_binlog - || m_prebuilt->trx->isolation_level - <= TRX_ISO_READ_COMMITTED)) { - - m_prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT; - - } else { - m_prebuilt->row_read_type = ROW_READ_WITH_LOCKS; - } + requested by the SQL layer and the transaction isolation level is + READ UNCOMMITTED or READ COMMITTED. */ + m_prebuilt->row_read_type = yes + && m_prebuilt->trx->isolation_level <= TRX_ISO_READ_COMMITTED + ? ROW_READ_TRY_SEMI_CONSISTENT + : ROW_READ_WITH_LOCKS; } /******************************************************************//** @@ -9880,7 +9719,7 @@ ha_innobase::ft_init_ext( buf_tmp_used = innobase_convert_string( buf_tmp, sizeof(buf_tmp) - 1, - &my_charset_utf8_general_ci, + &my_charset_utf8mb3_general_ci, query, query_len, (CHARSET_INFO*) char_set, &num_errors); @@ -14447,7 +14286,6 @@ ha_innobase::check( ulint n_rows; ulint n_rows_in_table = ULINT_UNDEFINED; bool is_ok = true; - ulint old_isolation_level; dberr_t ret; DBUG_ENTER("ha_innobase::check"); @@ -14510,7 +14348,7 @@ ha_innobase::check( DBUG_RETURN(HA_ADMIN_CORRUPT); } - old_isolation_level = m_prebuilt->trx->isolation_level; + uint old_isolation_level = m_prebuilt->trx->isolation_level; /* We must run the index record counts at an isolation level >= READ COMMITTED, because a dirty read can see a wrong number @@ -15306,7 +15144,7 @@ ha_innobase::start_stmt( Maps a MySQL trx isolation level code to the InnoDB isolation level code @return InnoDB isolation level */ static inline -ulint +uint innobase_map_isolation_level( /*=========================*/ enum_tx_isolation iso) /*!< in: MySQL isolation level code */ @@ -16217,9 +16055,7 @@ ha_innobase::store_lock( if (sql_command == SQLCOM_CHECKSUM || sql_command == SQLCOM_CREATE_SEQUENCE || (sql_command == SQLCOM_ANALYZE && lock_type == TL_READ) - || ((srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) - && trx->isolation_level != TRX_ISO_SERIALIZABLE + || (trx->isolation_level <= TRX_ISO_READ_COMMITTED && (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT) && (sql_command == SQLCOM_INSERT_SELECT @@ -16228,10 +16064,8 @@ ha_innobase::store_lock( || sql_command == SQLCOM_CREATE_SEQUENCE || sql_command == SQLCOM_CREATE_TABLE))) { - /* If we either have innobase_locks_unsafe_for_binlog - option set or this session is using READ COMMITTED - isolation level and isolation level of the transaction - is not set to serializable and MySQL is doing + /* If the transaction isolation level is + READ UNCOMMITTED or READ COMMITTED and we are executing INSERT INTO...SELECT or REPLACE INTO...SELECT or UPDATE ... = (SELECT ...) or CREATE ... SELECT... without FOR UPDATE or IN SHARE @@ -17326,32 +17160,6 @@ func_exit: goto func_exit; } #endif // UNIV_DEBUG -/*************************************************************//** -Just emit a warning that the usage of the variable is deprecated. -@return 0 */ -static -void -innodb_stats_sample_pages_update( -/*=============================*/ - THD* thd, /*!< in: thread handle */ - st_mysql_sys_var*, void*, - const void* save) /*!< in: immediate result - from check function */ -{ - - const char* STATS_SAMPLE_PAGES_DEPRECATED_MSG = - "Using innodb_stats_sample_pages is deprecated and" - " the variable may be removed in future releases." - " Please use innodb_stats_transient_sample_pages instead."; - - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, - HA_ERR_WRONG_COMMAND, STATS_SAMPLE_PAGES_DEPRECATED_MSG); - - ib::warn() << STATS_SAMPLE_PAGES_DEPRECATED_MSG; - - srv_stats_transient_sample_pages = - *static_cast<const unsigned long long*>(save); -} /****************************************************************//** Update the monitor counter according to the "set_option", turn @@ -18407,17 +18215,24 @@ innodb_encrypt_tables_update(THD*, st_mysql_sys_var*, void*, const void* save) mysql_mutex_lock(&LOCK_global_system_variables); } -/** Update the innodb_log_checksums parameter. -@param[in,out] thd client connection -@param[out] var_ptr current value -@param[in] save immediate result from check function */ -static -void -innodb_log_checksums_update(THD* thd, st_mysql_sys_var*, void* var_ptr, - const void* save) +/** Issue a deprecation warning for SET GLOBAL innodb_log_checksums. +@param[in,out] thd client connection */ +static void +innodb_log_checksums_warn(THD* thd, st_mysql_sys_var*, void*, const void*) { - *static_cast<my_bool*>(var_ptr) = innodb_log_checksums_func_update( - thd, *static_cast<const my_bool*>(save)); + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + HA_ERR_UNSUPPORTED, + innodb_log_checksums_deprecated); +} + +/** Issue a deprecation warning for SET GLOBAL innodb_undo_logs. +@param[in,out] thd client connection */ +static void +innodb_undo_logs_warn(THD* thd, st_mysql_sys_var*, void*, const void*) +{ + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + HA_ERR_UNSUPPORTED, + innodb_undo_logs_deprecated); } static SHOW_VAR innodb_status_variables_export[]= { @@ -18611,21 +18426,16 @@ static MYSQL_SYSVAR_ENUM(checksum_algorithm, srv_checksum_algorithm, " Files updated when this option is set to crc32 or strict_crc32 will" " not be readable by MariaDB versions older than 10.0.4;" " new files created with full_crc32 are readable by MariaDB 10.4.3+", - NULL, NULL, SRV_CHECKSUM_ALGORITHM_CRC32, + NULL, NULL, SRV_CHECKSUM_ALGORITHM_FULL_CRC32, &innodb_checksum_algorithm_typelib); +/** Description of deprecated and ignored parameters */ +static const char* innodb_deprecated_ignored += "Deprecated parameter with no effect."; + static MYSQL_SYSVAR_BOOL(log_checksums, innodb_log_checksums, PLUGIN_VAR_RQCMDARG, - "Whether to compute and require checksums for InnoDB redo log blocks", - NULL, innodb_log_checksums_update, TRUE); - -static MYSQL_SYSVAR_BOOL(checksums, innobase_use_checksums, - PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, - "DEPRECATED. Use innodb_checksum_algorithm=NONE instead of setting" - " this to OFF." - " Enable InnoDB checksums validation (enabled by default)." - " Disable with --skip-innodb-checksums.", - NULL, NULL, TRUE); + innodb_deprecated_ignored, NULL, innodb_log_checksums_warn, TRUE); static MYSQL_SYSVAR_STR(data_home_dir, innobase_data_home_dir, PLUGIN_VAR_READONLY, @@ -18768,23 +18578,16 @@ static MYSQL_SYSVAR_ENUM(flush_method, innodb_flush_method, static MYSQL_SYSVAR_STR(file_format, innodb_file_format, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, - "Deprecated parameter with no effect.", NULL, NULL, NULL); + innodb_deprecated_ignored, NULL, NULL, NULL); static MYSQL_SYSVAR_STR(large_prefix, innodb_large_prefix, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, - "Deprecated parameter with no effect.", NULL, NULL, NULL); + innodb_deprecated_ignored, NULL, NULL, NULL); static MYSQL_SYSVAR_BOOL(force_load_corrupted, srv_load_corrupted, PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, "Force InnoDB to load metadata of corrupted table.", NULL, NULL, FALSE); -static MYSQL_SYSVAR_BOOL(locks_unsafe_for_binlog, innobase_locks_unsafe_for_binlog, - PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, - "DEPRECATED. This option may be removed in future releases." - " Please use READ COMMITTED transaction isolation level instead." - " Force InnoDB to not use next-key locking, to use only row-level locking.", - NULL, NULL, FALSE); - static MYSQL_SYSVAR_STR(log_group_home_dir, srv_log_group_home_dir, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "Path to InnoDB log files.", NULL, NULL, NULL); @@ -18866,11 +18669,6 @@ static MYSQL_SYSVAR_BOOL(stats_on_metadata, innobase_stats_on_metadata, " SHOW TABLE STATUS for tables that use transient statistics (off by default)", NULL, NULL, FALSE); -static MYSQL_SYSVAR_ULONGLONG(stats_sample_pages, srv_stats_transient_sample_pages, - PLUGIN_VAR_RQCMDARG, - "Deprecated, use innodb_stats_transient_sample_pages instead", - NULL, innodb_stats_sample_pages_update, 8, 1, ~0ULL, 0); - static MYSQL_SYSVAR_ULONGLONG(stats_transient_sample_pages, srv_stats_transient_sample_pages, PLUGIN_VAR_RQCMDARG, @@ -19353,13 +19151,10 @@ static MYSQL_SYSVAR_ULONG(undo_tablespaces, srv_undo_tablespaces, 0L, /* Minimum value */ TRX_SYS_MAX_UNDO_SPACES, 0); /* Maximum value */ -static MYSQL_SYSVAR_ULONG(undo_logs, srv_undo_logs, +static MYSQL_SYSVAR_ULONG(undo_logs, innodb_undo_logs, PLUGIN_VAR_OPCMDARG, - "Number of undo logs to use.", - NULL, NULL, - TRX_SYS_N_RSEGS, /* Default setting */ - 1, /* Minimum value */ - TRX_SYS_N_RSEGS, 0); /* Maximum value */ + innodb_deprecated_ignored, NULL, innodb_undo_logs_warn, + TRX_SYS_N_RSEGS, 0, TRX_SYS_N_RSEGS, 0); static MYSQL_SYSVAR_ULONGLONG(max_undo_log_size, srv_max_undo_log_size, PLUGIN_VAR_OPCMDARG, @@ -19380,15 +19175,6 @@ static MYSQL_SYSVAR_BOOL(undo_log_truncate, srv_undo_log_truncate, "Enable or Disable Truncate of UNDO tablespace.", NULL, NULL, FALSE); -/* Alias for innodb_undo_logs, this config variable is deprecated. */ -static MYSQL_SYSVAR_ULONG(rollback_segments, srv_undo_logs, - PLUGIN_VAR_OPCMDARG, - "Number of undo logs to use (deprecated).", - NULL, NULL, - TRX_SYS_N_RSEGS, /* Default setting */ - 1, /* Minimum value */ - TRX_SYS_N_RSEGS, 0); /* Maximum value */ - static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "The AUTOINC lock modes supported by InnoDB:" @@ -19815,7 +19601,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(flush_neighbors), MYSQL_SYSVAR(checksum_algorithm), MYSQL_SYSVAR(log_checksums), - MYSQL_SYSVAR(checksums), MYSQL_SYSVAR(commit_concurrency), MYSQL_SYSVAR(concurrency_tickets), MYSQL_SYSVAR(compression_level), @@ -19846,7 +19631,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(large_prefix), /* deprecated in MariaDB 10.2; no effect */ MYSQL_SYSVAR(force_load_corrupted), MYSQL_SYSVAR(lock_schedule_algorithm), - MYSQL_SYSVAR(locks_unsafe_for_binlog), MYSQL_SYSVAR(lock_wait_timeout), MYSQL_SYSVAR(deadlock_detect), MYSQL_SYSVAR(page_size), @@ -19876,7 +19660,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(ft_user_stopword_table), MYSQL_SYSVAR(disable_sort_file_cache), MYSQL_SYSVAR(stats_on_metadata), - MYSQL_SYSVAR(stats_sample_pages), MYSQL_SYSVAR(stats_transient_sample_pages), MYSQL_SYSVAR(stats_persistent), MYSQL_SYSVAR(stats_persistent_sample_pages), @@ -19947,7 +19730,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(max_undo_log_size), MYSQL_SYSVAR(purge_rseg_truncate_frequency), MYSQL_SYSVAR(undo_log_truncate), - MYSQL_SYSVAR(rollback_segments), MYSQL_SYSVAR(undo_directory), MYSQL_SYSVAR(undo_tablespaces), MYSQL_SYSVAR(sync_array_size), diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 5698346b279..0b7e117e04b 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -265,241 +265,101 @@ field_store_string( return field->store(str, uint(strlen(str)), system_charset_info); } -/*******************************************************************//** -Auxiliary function to store ulint value in MYSQL_TYPE_LONGLONG field. -If the value is ULINT_UNDEFINED then the field is set to NULL. -@return 0 on success */ -int -field_store_ulint( -/*==============*/ - Field* field, /*!< in/out: target field for storage */ - ulint n) /*!< in: value to store */ -{ - int ret; - - if (n != ULINT_UNDEFINED) { - - ret = field->store(longlong(n), true); - field->set_notnull(); - } else { - - ret = 0; /* success */ - field->set_null(); - } - - return(ret); -} - #ifdef BTR_CUR_HASH_ADAPT # define I_S_AHI 1 /* Include the IS_HASHED column */ #else # define I_S_AHI 0 /* Omit the IS_HASHED column */ #endif +static const LEX_CSTRING isolation_level_values[] = +{ + { STRING_WITH_LEN("READ UNCOMMITTED") }, + { STRING_WITH_LEN("READ COMMITTED") }, + { STRING_WITH_LEN("REPEATABLE READ") }, + { STRING_WITH_LEN("SERIALIZABLE") } +}; + +static TypelibBuffer<4> isolation_level_values_typelib(isolation_level_values); + +namespace Show { + /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_trx */ static ST_FIELD_INFO innodb_trx_fields_info[] = { #define IDX_TRX_ID 0 - {STRUCT_FLD(field_name, "trx_id"), - STRUCT_FLD(field_length, TRX_ID_MAX_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_id", ULonglong(), NOT_NULL), #define IDX_TRX_STATE 1 - {STRUCT_FLD(field_name, "trx_state"), - STRUCT_FLD(field_length, TRX_QUE_STATE_STR_MAX_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_state", Varchar(TRX_QUE_STATE_STR_MAX_LEN + 1), NOT_NULL), #define IDX_TRX_STARTED 2 - {STRUCT_FLD(field_name, "trx_started"), - STRUCT_FLD(field_length, 0), - STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_started", Datetime(0), NOT_NULL), #define IDX_TRX_REQUESTED_LOCK_ID 3 - {STRUCT_FLD(field_name, "trx_requested_lock_id"), - STRUCT_FLD(field_length, TRX_I_S_LOCK_ID_MAX_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_requested_lock_id", + Varchar(TRX_I_S_LOCK_ID_MAX_LEN + 1), NULLABLE), #define IDX_TRX_WAIT_STARTED 4 - {STRUCT_FLD(field_name, "trx_wait_started"), - STRUCT_FLD(field_length, 0), - STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_wait_started", Datetime(0), NULLABLE), #define IDX_TRX_WEIGHT 5 - {STRUCT_FLD(field_name, "trx_weight"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_weight", ULonglong(), NOT_NULL), #define IDX_TRX_MYSQL_THREAD_ID 6 - {STRUCT_FLD(field_name, "trx_mysql_thread_id"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_mysql_thread_id", ULonglong(), NOT_NULL), #define IDX_TRX_QUERY 7 - {STRUCT_FLD(field_name, "trx_query"), - STRUCT_FLD(field_length, TRX_I_S_TRX_QUERY_MAX_LEN), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_query", Varchar(TRX_I_S_TRX_QUERY_MAX_LEN), NULLABLE), #define IDX_TRX_OPERATION_STATE 8 - {STRUCT_FLD(field_name, "trx_operation_state"), - STRUCT_FLD(field_length, TRX_I_S_TRX_OP_STATE_MAX_LEN), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_operation_state", Varchar(64), NULLABLE), #define IDX_TRX_TABLES_IN_USE 9 - {STRUCT_FLD(field_name, "trx_tables_in_use"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_tables_in_use", ULonglong(), NOT_NULL), #define IDX_TRX_TABLES_LOCKED 10 - {STRUCT_FLD(field_name, "trx_tables_locked"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_tables_locked", ULonglong(), NOT_NULL), #define IDX_TRX_LOCK_STRUCTS 11 - {STRUCT_FLD(field_name, "trx_lock_structs"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_lock_structs", ULonglong(), NOT_NULL), #define IDX_TRX_LOCK_MEMORY_BYTES 12 - {STRUCT_FLD(field_name, "trx_lock_memory_bytes"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_lock_memory_bytes", ULonglong(), NOT_NULL), #define IDX_TRX_ROWS_LOCKED 13 - {STRUCT_FLD(field_name, "trx_rows_locked"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TRX_ROWS_MODIFIED 14 - {STRUCT_FLD(field_name, "trx_rows_modified"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_rows_locked", ULonglong(), NOT_NULL), + +#define IDX_TRX_ROWS_MODIFIED 14 + Column("trx_rows_modified", ULonglong(), NOT_NULL), #define IDX_TRX_CONNCURRENCY_TICKETS 15 - {STRUCT_FLD(field_name, "trx_concurrency_tickets"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_concurrency_tickets", ULonglong(), NOT_NULL), #define IDX_TRX_ISOLATION_LEVEL 16 - {STRUCT_FLD(field_name, "trx_isolation_level"), - STRUCT_FLD(field_length, TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_isolation_level", + Enum(&isolation_level_values_typelib), NOT_NULL), #define IDX_TRX_UNIQUE_CHECKS 17 - {STRUCT_FLD(field_name, "trx_unique_checks"), - STRUCT_FLD(field_length, 1), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 1), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_unique_checks", SLong(1), NOT_NULL), #define IDX_TRX_FOREIGN_KEY_CHECKS 18 - {STRUCT_FLD(field_name, "trx_foreign_key_checks"), - STRUCT_FLD(field_length, 1), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 1), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_foreign_key_checks", SLong(1), NOT_NULL), #define IDX_TRX_LAST_FOREIGN_KEY_ERROR 19 - {STRUCT_FLD(field_name, "trx_last_foreign_key_error"), - STRUCT_FLD(field_length, TRX_I_S_TRX_FK_ERROR_MAX_LEN), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_last_foreign_key_error", + Varchar(TRX_I_S_TRX_FK_ERROR_MAX_LEN),NULLABLE), #define IDX_TRX_READ_ONLY 20 - {STRUCT_FLD(field_name, "trx_is_read_only"), - STRUCT_FLD(field_length, 1), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("trx_is_read_only", SLong(1), NOT_NULL), #define IDX_TRX_AUTOCOMMIT_NON_LOCKING 21 - {STRUCT_FLD(field_name, "trx_autocommit_non_locking"), - STRUCT_FLD(field_length, 1), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("trx_autocommit_non_locking", SLong(1), NOT_NULL), + + CEnd() }; +} // namespace Show + /*******************************************************************//** Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_trx table with it. @@ -528,15 +388,13 @@ fill_innodb_trx_from_cache( for (i = 0; i < rows_num; i++) { i_s_trx_row_t* row; - char trx_id[TRX_ID_MAX_LEN + 1]; row = (i_s_trx_row_t*) trx_i_s_cache_get_nth_row( cache, I_S_INNODB_TRX, i); /* trx_id */ - snprintf(trx_id, sizeof(trx_id), TRX_ID_FMT, row->trx_id); - OK(field_store_string(fields[IDX_TRX_ID], trx_id)); + OK(fields[IDX_TRX_ID]->store(row->trx_id, true)); /* trx_state */ OK(field_store_string(fields[IDX_TRX_STATE], @@ -620,8 +478,8 @@ fill_innodb_trx_from_cache( row->trx_concurrency_tickets, true)); /* trx_isolation_level */ - OK(field_store_string(fields[IDX_TRX_ISOLATION_LEVEL], - row->trx_isolation_level)); + OK(fields[IDX_TRX_ISOLATION_LEVEL]->store( + 1 + row->trx_isolation_level, true)); /* trx_unique_checks */ OK(fields[IDX_TRX_UNIQUE_CHECKS]->store( @@ -641,8 +499,7 @@ fill_innodb_trx_from_cache( /* trx_is_autocommit_non_locking */ OK(fields[IDX_TRX_AUTOCOMMIT_NON_LOCKING]->store( - (longlong) row->trx_is_autocommit_non_locking, - true)); + row->trx_is_autocommit_non_locking, true)); OK(schema_table_store_record(thd, table)); } @@ -665,7 +522,7 @@ innodb_trx_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_trx_fields_info; + schema->fields_info = Show::innodb_trx_fields_info; schema->fill_table = trx_i_s_common_fill_table; DBUG_RETURN(0); @@ -725,102 +582,65 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_trx = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +static const LEX_CSTRING lock_mode_values[] = +{ + { STRING_WITH_LEN("S") }, + { STRING_WITH_LEN("S,GAP") }, + { STRING_WITH_LEN("X") }, + { STRING_WITH_LEN("X,GAP") }, + { STRING_WITH_LEN("IS") }, + { STRING_WITH_LEN("IS,GAP") }, + { STRING_WITH_LEN("IX") }, + { STRING_WITH_LEN("IX,GAP") }, + { STRING_WITH_LEN("AUTO_INC") } +}; + +static TypelibBuffer<9> lock_mode_values_typelib(lock_mode_values); + +static const LEX_CSTRING lock_type_values[] = +{ + { STRING_WITH_LEN("RECORD") }, + { STRING_WITH_LEN("TABLE") } +}; + +static TypelibBuffer<2> lock_type_values_typelib(lock_type_values); + +namespace Show { /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_locks */ static ST_FIELD_INFO innodb_locks_fields_info[] = { #define IDX_LOCK_ID 0 - {STRUCT_FLD(field_name, "lock_id"), - STRUCT_FLD(field_length, TRX_I_S_LOCK_ID_MAX_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("lock_id", Varchar(TRX_I_S_LOCK_ID_MAX_LEN + 1), NOT_NULL), #define IDX_LOCK_TRX_ID 1 - {STRUCT_FLD(field_name, "lock_trx_id"), - STRUCT_FLD(field_length, TRX_ID_MAX_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("lock_trx_id", ULonglong(), NOT_NULL), #define IDX_LOCK_MODE 2 - {STRUCT_FLD(field_name, "lock_mode"), - /* S[,GAP] X[,GAP] IS[,GAP] IX[,GAP] AUTO_INC UNKNOWN */ - STRUCT_FLD(field_length, 32), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("lock_mode", Enum(&lock_mode_values_typelib), NOT_NULL), #define IDX_LOCK_TYPE 3 - {STRUCT_FLD(field_name, "lock_type"), - STRUCT_FLD(field_length, 32 /* RECORD|TABLE|UNKNOWN */), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("lock_type", Enum(&lock_type_values_typelib), NOT_NULL), #define IDX_LOCK_TABLE 4 - {STRUCT_FLD(field_name, "lock_table"), - STRUCT_FLD(field_length, 1024), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("lock_table", Varchar(1024), NOT_NULL), #define IDX_LOCK_INDEX 5 - {STRUCT_FLD(field_name, "lock_index"), - STRUCT_FLD(field_length, 1024), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("lock_index", Varchar(1024), NULLABLE), #define IDX_LOCK_SPACE 6 - {STRUCT_FLD(field_name, "lock_space"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("lock_space", ULong(), NULLABLE), #define IDX_LOCK_PAGE 7 - {STRUCT_FLD(field_name, "lock_page"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("lock_page", ULong(), NULLABLE), #define IDX_LOCK_REC 8 - {STRUCT_FLD(field_name, "lock_rec"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("lock_rec", ULong(), NULLABLE), #define IDX_LOCK_DATA 9 - {STRUCT_FLD(field_name, "lock_data"), - STRUCT_FLD(field_length, TRX_I_S_LOCK_DATA_MAX_LEN), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("lock_data", Varchar(TRX_I_S_LOCK_DATA_MAX_LEN), NULLABLE), + CEnd() }; +} // namespace Show /*******************************************************************//** Read data from cache buffer and fill the INFORMATION_SCHEMA.innodb_locks @@ -852,8 +672,6 @@ fill_innodb_locks_from_cache( char buf[MAX_FULL_NAME_LEN + 1]; const char* bufend; - char lock_trx_id[TRX_ID_MAX_LEN + 1]; - row = (i_s_locks_row_t*) trx_i_s_cache_get_nth_row( cache, I_S_INNODB_LOCKS, i); @@ -864,17 +682,14 @@ fill_innodb_locks_from_cache( lock_id)); /* lock_trx_id */ - snprintf(lock_trx_id, sizeof(lock_trx_id), - TRX_ID_FMT, row->lock_trx_id); - OK(field_store_string(fields[IDX_LOCK_TRX_ID], lock_trx_id)); + OK(fields[IDX_LOCK_TRX_ID]->store(row->lock_trx_id, true)); /* lock_mode */ - OK(field_store_string(fields[IDX_LOCK_MODE], - row->lock_mode)); + OK(fields[IDX_LOCK_MODE]->store(row->lock_mode, true)); /* lock_type */ - OK(field_store_string(fields[IDX_LOCK_TYPE], - row->lock_type)); + OK(fields[IDX_LOCK_TYPE]->store( + row->lock_index ? 1 : 2, true)); /* lock_table */ bufend = innobase_convert_name(buf, sizeof(buf), @@ -884,25 +699,27 @@ fill_innodb_locks_from_cache( OK(fields[IDX_LOCK_TABLE]->store( buf, uint(bufend - buf), system_charset_info)); - /* lock_index */ - OK(field_store_string(fields[IDX_LOCK_INDEX], - row->lock_index)); - - /* lock_space */ - OK(field_store_ulint(fields[IDX_LOCK_SPACE], - row->lock_space)); - - /* lock_page */ - OK(field_store_ulint(fields[IDX_LOCK_PAGE], - row->lock_page)); - - /* lock_rec */ - OK(field_store_ulint(fields[IDX_LOCK_REC], - row->lock_rec)); - - /* lock_data */ - OK(field_store_string(fields[IDX_LOCK_DATA], - row->lock_data)); + if (row->lock_index) { + /* record lock */ + OK(field_store_string(fields[IDX_LOCK_INDEX], + row->lock_index)); + OK(fields[IDX_LOCK_SPACE]->store( + row->lock_space, true)); + fields[IDX_LOCK_SPACE]->set_notnull(); + OK(fields[IDX_LOCK_PAGE]->store( + row->lock_page, true)); + fields[IDX_LOCK_PAGE]->set_notnull(); + OK(fields[IDX_LOCK_REC]->store( + row->lock_rec, true)); + fields[IDX_LOCK_REC]->set_notnull(); + OK(field_store_string(fields[IDX_LOCK_DATA], + row->lock_data)); + } else { + fields[IDX_LOCK_INDEX]->set_null(); + fields[IDX_LOCK_SPACE]->set_null(); + fields[IDX_LOCK_REC]->set_null(); + fields[IDX_LOCK_DATA]->set_null(); + } OK(schema_table_store_record(thd, table)); } @@ -925,7 +742,7 @@ innodb_locks_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_locks_fields_info; + schema->fields_info = Show::innodb_locks_fields_info; schema->fill_table = trx_i_s_common_fill_table; DBUG_RETURN(0); @@ -980,47 +797,25 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_locks = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; + +namespace Show { /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_lock_waits */ static ST_FIELD_INFO innodb_lock_waits_fields_info[] = { #define IDX_REQUESTING_TRX_ID 0 - {STRUCT_FLD(field_name, "requesting_trx_id"), - STRUCT_FLD(field_length, TRX_ID_MAX_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("requesting_trx_id", ULonglong(), NOT_NULL), #define IDX_REQUESTED_LOCK_ID 1 - {STRUCT_FLD(field_name, "requested_lock_id"), - STRUCT_FLD(field_length, TRX_I_S_LOCK_ID_MAX_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("requested_lock_id", Varchar(TRX_I_S_LOCK_ID_MAX_LEN + 1), NOT_NULL), #define IDX_BLOCKING_TRX_ID 2 - {STRUCT_FLD(field_name, "blocking_trx_id"), - STRUCT_FLD(field_length, TRX_ID_MAX_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("blocking_trx_id", ULonglong(), NOT_NULL), #define IDX_BLOCKING_LOCK_ID 3 - {STRUCT_FLD(field_name, "blocking_lock_id"), - STRUCT_FLD(field_length, TRX_I_S_LOCK_ID_MAX_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("blocking_lock_id", Varchar(TRX_I_S_LOCK_ID_MAX_LEN + 1), NOT_NULL), + CEnd() }; +} // namespace Show /*******************************************************************//** Read data from cache buffer and fill the @@ -1052,18 +847,13 @@ fill_innodb_lock_waits_from_cache( i_s_lock_waits_row_t* row; - char requesting_trx_id[TRX_ID_MAX_LEN + 1]; - char blocking_trx_id[TRX_ID_MAX_LEN + 1]; - row = (i_s_lock_waits_row_t*) trx_i_s_cache_get_nth_row( cache, I_S_INNODB_LOCK_WAITS, i); /* requesting_trx_id */ - snprintf(requesting_trx_id, sizeof(requesting_trx_id), - TRX_ID_FMT, row->requested_lock_row->lock_trx_id); - OK(field_store_string(fields[IDX_REQUESTING_TRX_ID], - requesting_trx_id)); + OK(fields[IDX_REQUESTING_TRX_ID]->store( + row->requested_lock_row->lock_trx_id, true)); /* requested_lock_id */ OK(field_store_string( @@ -1074,10 +864,8 @@ fill_innodb_lock_waits_from_cache( sizeof(requested_lock_id)))); /* blocking_trx_id */ - snprintf(blocking_trx_id, sizeof(blocking_trx_id), - TRX_ID_FMT, row->blocking_lock_row->lock_trx_id); - OK(field_store_string(fields[IDX_BLOCKING_TRX_ID], - blocking_trx_id)); + OK(fields[IDX_BLOCKING_TRX_ID]->store( + row->blocking_lock_row->lock_trx_id, true)); /* blocking_lock_id */ OK(field_store_string( @@ -1108,7 +896,7 @@ innodb_lock_waits_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_lock_waits_fields_info; + schema->fields_info = Show::innodb_lock_waits_fields_info; schema->fill_table = trx_i_s_common_fill_table; DBUG_RETURN(0); @@ -1262,62 +1050,22 @@ trx_i_s_common_fill_table( #endif } +namespace Show { /* Fields of the dynamic table information_schema.innodb_cmp. */ static ST_FIELD_INFO i_s_cmp_fields_info[] = { - {STRUCT_FLD(field_name, "page_size"), - STRUCT_FLD(field_length, 5), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Compressed Page Size"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "compress_ops"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Total Number of Compressions"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "compress_ops_ok"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Total Number of" - " Successful Compressions"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "compress_time"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Total Duration of Compressions," - " in Seconds"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "uncompress_ops"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Total Number of Decompressions"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "uncompress_time"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Total Duration of Decompressions," - " in Seconds"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("page_size", SLong(5),NOT_NULL, "Compressed Page Size"), + Column("compress_ops", SLong(), NOT_NULL, "Total Number of Compressions"), + Column("compress_ops_ok",SLong(), NOT_NULL, "Total Number of " + "Successful Compressions"), + Column("compress_time", SLong(), NOT_NULL, "Total Duration of " + "Compressions, in Seconds"), + Column("uncompress_ops", SLong(), NOT_NULL, "Total Number of Decompressions"), + Column("uncompress_time",SLong(), NOT_NULL, "Total Duration of " + "Decompressions, in Seconds"), + CEnd(), }; +} // namespace Show /*******************************************************************//** @@ -1418,7 +1166,7 @@ i_s_cmp_init( DBUG_ENTER("i_s_cmp_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_cmp_fields_info; + schema->fields_info = Show::i_s_cmp_fields_info; schema->fill_table = i_s_cmp_fill; DBUG_RETURN(0); @@ -1436,7 +1184,7 @@ i_s_cmp_reset_init( DBUG_ENTER("i_s_cmp_reset_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_cmp_fields_info; + schema->fields_info = Show::i_s_cmp_fields_info; schema->fill_table = i_s_cmp_reset_fill; DBUG_RETURN(0); @@ -1541,86 +1289,42 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_cmp_reset = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; + +namespace Show { /* Fields of the dynamic tables information_schema.innodb_cmp_per_index and information_schema.innodb_cmp_per_index_reset. */ static ST_FIELD_INFO i_s_cmp_per_index_fields_info[] = { #define IDX_DATABASE_NAME 0 - {STRUCT_FLD(field_name, "database_name"), - STRUCT_FLD(field_length, 192), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define IDX_TABLE_NAME 1 - {STRUCT_FLD(field_name, "table_name"), - STRUCT_FLD(field_length, 192), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("database_name", Varchar(NAME_CHAR_LEN), NOT_NULL), + +#define IDX_TABLE_NAME 1 /* FIXME: this is in my_charset_filename! */ + Column("table_name", Varchar(NAME_CHAR_LEN), NOT_NULL), #define IDX_INDEX_NAME 2 - {STRUCT_FLD(field_name, "index_name"), - STRUCT_FLD(field_length, 192), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("index_name", Varchar(NAME_CHAR_LEN), NOT_NULL), #define IDX_COMPRESS_OPS 3 - {STRUCT_FLD(field_name, "compress_ops"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("compress_ops", SLong(), NOT_NULL), #define IDX_COMPRESS_OPS_OK 4 - {STRUCT_FLD(field_name, "compress_ops_ok"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("compress_ops_ok", SLong(), NOT_NULL), #define IDX_COMPRESS_TIME 5 - {STRUCT_FLD(field_name, "compress_time"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("compress_time", SLong(), NOT_NULL), #define IDX_UNCOMPRESS_OPS 6 - {STRUCT_FLD(field_name, "uncompress_ops"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("uncompress_ops", SLong(), NOT_NULL), #define IDX_UNCOMPRESS_TIME 7 - {STRUCT_FLD(field_name, "uncompress_time"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("uncompress_time", SLong(), NOT_NULL), + + CEnd() }; +} // namespace Show + /*******************************************************************//** Fill the dynamic table information_schema.innodb_cmp_per_index or @@ -1768,7 +1472,7 @@ i_s_cmp_per_index_init( DBUG_ENTER("i_s_cmp_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_cmp_per_index_fields_info; + schema->fields_info = Show::i_s_cmp_per_index_fields_info; schema->fill_table = i_s_cmp_per_index_fill; DBUG_RETURN(0); @@ -1786,7 +1490,7 @@ i_s_cmp_per_index_reset_init( DBUG_ENTER("i_s_cmp_reset_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_cmp_per_index_fields_info; + schema->fields_info = Show::i_s_cmp_per_index_fields_info; schema->fill_table = i_s_cmp_per_index_reset_fill; DBUG_RETURN(0); @@ -1891,60 +1595,21 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_cmp_per_index_reset = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; + +namespace Show { /* Fields of the dynamic table information_schema.innodb_cmpmem. */ static ST_FIELD_INFO i_s_cmpmem_fields_info[] = { - {STRUCT_FLD(field_name, "page_size"), - STRUCT_FLD(field_length, 5), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Buddy Block Size"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "buffer_pool_instance"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Buffer Pool Id"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "pages_used"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Currently in Use"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "pages_free"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Currently Available"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "relocation_ops"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Total Number of Relocations"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - {STRUCT_FLD(field_name, "relocation_time"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, "Total Duration of Relocations," - " in Seconds"), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("page_size", SLong(5), NOT_NULL, "Buddy Block Size"), + Column("buffer_pool_instance", SLong(), NOT_NULL, "Buffer Pool Id"), + Column("pages_used", SLong(), NOT_NULL, "Currently in Use"), + Column("pages_free", SLong(), NOT_NULL, "Currently Available"), + Column("relocation_ops", SLonglong(), NOT_NULL, "Total Number of Relocations"), + Column("relocation_time", SLong(), NOT_NULL, "Total Duration of Relocations," + " in Seconds"), + CEnd() }; +} // namespace Show /*******************************************************************//** Fill the dynamic table information_schema.innodb_cmpmem or @@ -2065,7 +1730,7 @@ i_s_cmpmem_init( DBUG_ENTER("i_s_cmpmem_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_cmpmem_fields_info; + schema->fields_info = Show::i_s_cmpmem_fields_info; schema->fill_table = i_s_cmpmem_fill; DBUG_RETURN(0); @@ -2083,7 +1748,7 @@ i_s_cmpmem_reset_init( DBUG_ENTER("i_s_cmpmem_reset_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_cmpmem_fields_info; + schema->fields_info = Show::i_s_cmpmem_fields_info; schema->fill_table = i_s_cmpmem_reset_fill; DBUG_RETURN(0); @@ -2188,164 +1853,75 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_cmpmem_reset = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; + +static const LEX_CSTRING metric_type_values[] = +{ + { STRING_WITH_LEN("value") }, + { STRING_WITH_LEN("status_counter") }, + { STRING_WITH_LEN("set_owner") }, + { STRING_WITH_LEN("set_member") }, + { STRING_WITH_LEN("counter") } +}; + +static TypelibBuffer<5> metric_type_values_typelib(metric_type_values); + +namespace Show { /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_metrics */ static ST_FIELD_INFO innodb_metrics_fields_info[] = { #define METRIC_NAME 0 - {STRUCT_FLD(field_name, "NAME"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NAME", Varchar(NAME_LEN + 1), NOT_NULL), #define METRIC_SUBSYS 1 - {STRUCT_FLD(field_name, "SUBSYSTEM"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("SUBSYSTEM", Varchar(NAME_LEN + 1), NOT_NULL), #define METRIC_VALUE_START 2 - {STRUCT_FLD(field_name, "COUNT"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("COUNT", SLonglong(), NOT_NULL), #define METRIC_MAX_VALUE_START 3 - {STRUCT_FLD(field_name, "MAX_COUNT"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("MAX_COUNT", SLonglong(), NULLABLE), #define METRIC_MIN_VALUE_START 4 - {STRUCT_FLD(field_name, "MIN_COUNT"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("MIN_COUNT", SLonglong(), NULLABLE), #define METRIC_AVG_VALUE_START 5 - {STRUCT_FLD(field_name, "AVG_COUNT"), - STRUCT_FLD(field_length, MAX_FLOAT_STR_LENGTH), - STRUCT_FLD(field_type, MYSQL_TYPE_FLOAT), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("AVG_COUNT", Float(MAX_FLOAT_STR_LENGTH), NULLABLE), #define METRIC_VALUE_RESET 6 - {STRUCT_FLD(field_name, "COUNT_RESET"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("COUNT_RESET", SLonglong(), NOT_NULL), #define METRIC_MAX_VALUE_RESET 7 - {STRUCT_FLD(field_name, "MAX_COUNT_RESET"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("MAX_COUNT_RESET", SLonglong(), NULLABLE), #define METRIC_MIN_VALUE_RESET 8 - {STRUCT_FLD(field_name, "MIN_COUNT_RESET"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("MIN_COUNT_RESET", SLonglong(), NULLABLE), #define METRIC_AVG_VALUE_RESET 9 - {STRUCT_FLD(field_name, "AVG_COUNT_RESET"), - STRUCT_FLD(field_length, MAX_FLOAT_STR_LENGTH), - STRUCT_FLD(field_type, MYSQL_TYPE_FLOAT), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("AVG_COUNT_RESET", Float(MAX_FLOAT_STR_LENGTH), NULLABLE), #define METRIC_START_TIME 10 - {STRUCT_FLD(field_name, "TIME_ENABLED"), - STRUCT_FLD(field_length, 0), - STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TIME_ENABLED", Datetime(0), NULLABLE), #define METRIC_STOP_TIME 11 - {STRUCT_FLD(field_name, "TIME_DISABLED"), - STRUCT_FLD(field_length, 0), - STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TIME_DISABLED", Datetime(0), NULLABLE), #define METRIC_TIME_ELAPSED 12 - {STRUCT_FLD(field_name, "TIME_ELAPSED"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TIME_ELAPSED", SLonglong(), NULLABLE), #define METRIC_RESET_TIME 13 - {STRUCT_FLD(field_name, "TIME_RESET"), - STRUCT_FLD(field_length, 0), - STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TIME_RESET", Datetime(0), NULLABLE), #define METRIC_STATUS 14 - {STRUCT_FLD(field_name, "STATUS"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("ENABLED", SLong(1), NOT_NULL), #define METRIC_TYPE 15 - {STRUCT_FLD(field_name, "TYPE"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TYPE", Enum(&metric_type_values_typelib), NOT_NULL), #define METRIC_DESC 16 - {STRUCT_FLD(field_name, "COMMENT"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("COMMENT", Varchar(NAME_LEN + 1), NOT_NULL), + CEnd() }; +} // namespace Show /**********************************************************************//** Fill the information schema metrics table. @@ -2562,7 +2138,6 @@ i_s_metrics_fill( fields[METRIC_AVG_VALUE_RESET]->set_null(); } - if (MONITOR_IS_ON(count)) { /* If monitor is on, the stop time will set to NULL */ fields[METRIC_STOP_TIME]->set_null(); @@ -2579,9 +2154,7 @@ i_s_metrics_fill( fields[METRIC_RESET_TIME]->set_null(); } - /* Display the monitor status as "enabled" */ - OK(field_store_string(fields[METRIC_STATUS], - "enabled")); + OK(fields[METRIC_STATUS]->store(1, true)); } else { if (MONITOR_FIELD(count, mon_stop_time)) { OK(field_store_time_t(fields[METRIC_STOP_TIME], @@ -2593,27 +2166,25 @@ i_s_metrics_fill( fields[METRIC_RESET_TIME]->set_null(); - OK(field_store_string(fields[METRIC_STATUS], - "disabled")); + OK(fields[METRIC_STATUS]->store(0, true)); } + uint metric_type; + if (monitor_info->monitor_type & MONITOR_DISPLAY_CURRENT) { - OK(field_store_string(fields[METRIC_TYPE], - "value")); + metric_type = 1; /* "value" */ } else if (monitor_info->monitor_type & MONITOR_EXISTING) { - OK(field_store_string(fields[METRIC_TYPE], - "status_counter")); + metric_type = 2; /* "status_counter" */ } else if (monitor_info->monitor_type & MONITOR_SET_OWNER) { - OK(field_store_string(fields[METRIC_TYPE], - "set_owner")); - } else if ( monitor_info->monitor_type & MONITOR_SET_MEMBER) { - OK(field_store_string(fields[METRIC_TYPE], - "set_member")); + metric_type = 3; /* "set_owner" */ + } else if (monitor_info->monitor_type & MONITOR_SET_MEMBER) { + metric_type = 4; /* "set_member" */ } else { - OK(field_store_string(fields[METRIC_TYPE], - "counter")); + metric_type = 5; /* "counter" */ } + OK(fields[METRIC_TYPE]->store(metric_type, true)); + OK(schema_table_store_record(thd, table_to_fill)); } @@ -2657,7 +2228,7 @@ innodb_metrics_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_metrics_fields_info; + schema->fields_info = Show::innodb_metrics_fields_info; schema->fill_table = i_s_metrics_fill_table; DBUG_RETURN(0); @@ -2711,20 +2282,16 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_metrics = STRUCT_FLD(version_info, INNODB_VERSION_STR), STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; + +namespace Show { /* Fields of the dynamic table INFORMATION_SCHEMA.innodb_ft_default_stopword */ static ST_FIELD_INFO i_s_stopword_fields_info[] = { #define STOPWORD_VALUE 0 - {STRUCT_FLD(field_name, "value"), - STRUCT_FLD(field_length, TRX_ID_MAX_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("value", Varchar(TRX_ID_MAX_LEN + 1), NOT_NULL), + CEnd() }; +} // namespace Show /*******************************************************************//** Fill the dynamic table information_schema.innodb_ft_default_stopword. @@ -2770,7 +2337,7 @@ i_s_stopword_init( DBUG_ENTER("i_s_stopword_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_stopword_fields_info; + schema->fields_info = Show::i_s_stopword_fields_info; schema->fill_table = i_s_stopword_fill; DBUG_RETURN(0); @@ -2825,21 +2392,16 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_ft_default_stopword = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_FT_DELETED INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED */ static ST_FIELD_INFO i_s_fts_doc_fields_info[] = { #define I_S_FTS_DOC_ID 0 - {STRUCT_FLD(field_name, "DOC_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("DOC_ID", ULonglong(), NOT_NULL), + CEnd() }; +} // namespace Show /*******************************************************************//** Fill the dynamic table INFORMATION_SCHEMA.INNODB_FT_DELETED or @@ -2949,7 +2511,7 @@ i_s_fts_deleted_init( DBUG_ENTER("i_s_fts_deleted_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_fts_doc_fields_info; + schema->fields_info = Show::i_s_fts_doc_fields_info; schema->fill_table = i_s_fts_deleted_fill; DBUG_RETURN(0); @@ -3032,7 +2594,7 @@ i_s_fts_being_deleted_init( DBUG_ENTER("i_s_fts_deleted_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_fts_doc_fields_info; + schema->fields_info = Show::i_s_fts_doc_fields_info; schema->fill_table = i_s_fts_being_deleted_fill; DBUG_RETURN(0); @@ -3087,66 +2649,32 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_ft_being_deleted = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; + +namespace Show { /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHED and INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE */ static ST_FIELD_INFO i_s_fts_index_fields_info[] = { #define I_S_FTS_WORD 0 - {STRUCT_FLD(field_name, "WORD"), - STRUCT_FLD(field_length, FTS_MAX_WORD_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("WORD", Varchar(FTS_MAX_WORD_LEN + 1), NOT_NULL), #define I_S_FTS_FIRST_DOC_ID 1 - {STRUCT_FLD(field_name, "FIRST_DOC_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FIRST_DOC_ID", ULonglong(), NOT_NULL), #define I_S_FTS_LAST_DOC_ID 2 - {STRUCT_FLD(field_name, "LAST_DOC_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("LAST_DOC_ID", ULonglong(), NOT_NULL), #define I_S_FTS_DOC_COUNT 3 - {STRUCT_FLD(field_name, "DOC_COUNT"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("DOC_COUNT", ULonglong(), NOT_NULL), #define I_S_FTS_ILIST_DOC_ID 4 - {STRUCT_FLD(field_name, "DOC_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("DOC_ID", ULonglong(), NOT_NULL), #define I_S_FTS_ILIST_DOC_POS 5 - {STRUCT_FLD(field_name, "POSITION"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("POSITION", ULonglong(), NOT_NULL), + CEnd() }; +} // namespace Show /*******************************************************************//** Go through the Doc Node and its ilist, fill the dynamic table @@ -3333,7 +2861,7 @@ i_s_fts_index_cache_init( DBUG_ENTER("i_s_fts_index_cache_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_fts_index_fields_info; + schema->fields_info = Show::i_s_fts_index_fields_info; schema->fill_table = i_s_fts_index_cache_fill; DBUG_RETURN(0); @@ -3773,7 +3301,7 @@ i_s_fts_index_table_init( DBUG_ENTER("i_s_fts_index_table_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_fts_index_fields_info; + schema->fields_info = Show::i_s_fts_index_fields_info; schema->fill_table = i_s_fts_index_table_fill; DBUG_RETURN(0); @@ -3828,29 +3356,20 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_ft_index_table = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; + +namespace Show { /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_FT_CONFIG */ static ST_FIELD_INFO i_s_fts_config_fields_info[] = { #define FTS_CONFIG_KEY 0 - {STRUCT_FLD(field_name, "KEY"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("KEY", Varchar(NAME_LEN + 1), NOT_NULL), #define FTS_CONFIG_VALUE 1 - {STRUCT_FLD(field_name, "VALUE"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("VALUE", Varchar(NAME_LEN + 1), NOT_NULL), + + CEnd() }; +} // namespace Show static const char* fts_config_key[] = { FTS_OPTIMIZE_LIMIT_IN_SECS, @@ -3981,7 +3500,7 @@ i_s_fts_config_init( DBUG_ENTER("i_s_fts_config_init"); ST_SCHEMA_TABLE* schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = i_s_fts_config_fields_info; + schema->fields_info = Show::i_s_fts_config_fields_info; schema->fill_table = i_s_fts_config_fill; DBUG_RETURN(0); @@ -4036,299 +3555,109 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_ft_config = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /* Fields of the dynamic table INNODB_BUFFER_POOL_STATS. */ static ST_FIELD_INFO i_s_innodb_buffer_stats_fields_info[] = { #define IDX_BUF_STATS_POOL_ID 0 - {STRUCT_FLD(field_name, "POOL_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("POOL_ID", ULong(), NOT_NULL), #define IDX_BUF_STATS_POOL_SIZE 1 - {STRUCT_FLD(field_name, "POOL_SIZE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("POOL_SIZE", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_FREE_BUFFERS 2 - {STRUCT_FLD(field_name, "FREE_BUFFERS"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FREE_BUFFERS", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_LRU_LEN 3 - {STRUCT_FLD(field_name, "DATABASE_PAGES"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("DATABASE_PAGES", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_OLD_LRU_LEN 4 - {STRUCT_FLD(field_name, "OLD_DATABASE_PAGES"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("OLD_DATABASE_PAGES", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_FLUSH_LIST_LEN 5 - {STRUCT_FLD(field_name, "MODIFIED_DATABASE_PAGES"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("MODIFIED_DATABASE_PAGES", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_PENDING_ZIP 6 - {STRUCT_FLD(field_name, "PENDING_DECOMPRESS"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PENDING_DECOMPRESS", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_PENDING_READ 7 - {STRUCT_FLD(field_name, "PENDING_READS"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PENDING_READS",ULonglong(), NOT_NULL), #define IDX_BUF_STATS_FLUSH_LRU 8 - {STRUCT_FLD(field_name, "PENDING_FLUSH_LRU"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PENDING_FLUSH_LRU",ULonglong(), NOT_NULL), #define IDX_BUF_STATS_FLUSH_LIST 9 - {STRUCT_FLD(field_name, "PENDING_FLUSH_LIST"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PENDING_FLUSH_LIST", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_PAGE_YOUNG 10 - {STRUCT_FLD(field_name, "PAGES_MADE_YOUNG"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGES_MADE_YOUNG",ULonglong(), NOT_NULL), #define IDX_BUF_STATS_PAGE_NOT_YOUNG 11 - {STRUCT_FLD(field_name, "PAGES_NOT_MADE_YOUNG"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGES_NOT_MADE_YOUNG",ULonglong(), NOT_NULL), #define IDX_BUF_STATS_PAGE_YOUNG_RATE 12 - {STRUCT_FLD(field_name, "PAGES_MADE_YOUNG_RATE"), - STRUCT_FLD(field_length, MAX_FLOAT_STR_LENGTH), - STRUCT_FLD(field_type, MYSQL_TYPE_FLOAT), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGES_MADE_YOUNG_RATE", Float(MAX_FLOAT_STR_LENGTH), NOT_NULL), #define IDX_BUF_STATS_PAGE_NOT_YOUNG_RATE 13 - {STRUCT_FLD(field_name, "PAGES_MADE_NOT_YOUNG_RATE"), - STRUCT_FLD(field_length, MAX_FLOAT_STR_LENGTH), - STRUCT_FLD(field_type, MYSQL_TYPE_FLOAT), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGES_MADE_NOT_YOUNG_RATE", Float(MAX_FLOAT_STR_LENGTH), NOT_NULL), #define IDX_BUF_STATS_PAGE_READ 14 - {STRUCT_FLD(field_name, "NUMBER_PAGES_READ"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NUMBER_PAGES_READ",ULonglong(), NOT_NULL), #define IDX_BUF_STATS_PAGE_CREATED 15 - {STRUCT_FLD(field_name, "NUMBER_PAGES_CREATED"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NUMBER_PAGES_CREATED",ULonglong(), NOT_NULL), #define IDX_BUF_STATS_PAGE_WRITTEN 16 - {STRUCT_FLD(field_name, "NUMBER_PAGES_WRITTEN"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NUMBER_PAGES_WRITTEN",ULonglong(), NOT_NULL), #define IDX_BUF_STATS_PAGE_READ_RATE 17 - {STRUCT_FLD(field_name, "PAGES_READ_RATE"), - STRUCT_FLD(field_length, MAX_FLOAT_STR_LENGTH), - STRUCT_FLD(field_type, MYSQL_TYPE_FLOAT), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGES_READ_RATE", Float(MAX_FLOAT_STR_LENGTH), NOT_NULL), #define IDX_BUF_STATS_PAGE_CREATE_RATE 18 - {STRUCT_FLD(field_name, "PAGES_CREATE_RATE"), - STRUCT_FLD(field_length, MAX_FLOAT_STR_LENGTH), - STRUCT_FLD(field_type, MYSQL_TYPE_FLOAT), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGES_CREATE_RATE", Float(MAX_FLOAT_STR_LENGTH), NOT_NULL), #define IDX_BUF_STATS_PAGE_WRITTEN_RATE 19 - {STRUCT_FLD(field_name, "PAGES_WRITTEN_RATE"), - STRUCT_FLD(field_length, MAX_FLOAT_STR_LENGTH), - STRUCT_FLD(field_type, MYSQL_TYPE_FLOAT), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGES_WRITTEN_RATE",Float(MAX_FLOAT_STR_LENGTH), NOT_NULL), #define IDX_BUF_STATS_GET 20 - {STRUCT_FLD(field_name, "NUMBER_PAGES_GET"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NUMBER_PAGES_GET", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_HIT_RATE 21 - {STRUCT_FLD(field_name, "HIT_RATE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("HIT_RATE", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_MADE_YOUNG_PCT 22 - {STRUCT_FLD(field_name, "YOUNG_MAKE_PER_THOUSAND_GETS"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("YOUNG_MAKE_PER_THOUSAND_GETS", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_NOT_MADE_YOUNG_PCT 23 - {STRUCT_FLD(field_name, "NOT_YOUNG_MAKE_PER_THOUSAND_GETS"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NOT_YOUNG_MAKE_PER_THOUSAND_GETS", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_READ_AHREAD 24 - {STRUCT_FLD(field_name, "NUMBER_PAGES_READ_AHEAD"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NUMBER_PAGES_READ_AHEAD", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_READ_AHEAD_EVICTED 25 - {STRUCT_FLD(field_name, "NUMBER_READ_AHEAD_EVICTED"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NUMBER_READ_AHEAD_EVICTED", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_READ_AHEAD_RATE 26 - {STRUCT_FLD(field_name, "READ_AHEAD_RATE"), - STRUCT_FLD(field_length, MAX_FLOAT_STR_LENGTH), - STRUCT_FLD(field_type, MYSQL_TYPE_FLOAT), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("READ_AHEAD_RATE", Float(MAX_FLOAT_STR_LENGTH), NOT_NULL), #define IDX_BUF_STATS_READ_AHEAD_EVICT_RATE 27 - {STRUCT_FLD(field_name, "READ_AHEAD_EVICTED_RATE"), - STRUCT_FLD(field_length, MAX_FLOAT_STR_LENGTH), - STRUCT_FLD(field_type, MYSQL_TYPE_FLOAT), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("READ_AHEAD_EVICTED_RATE",Float(MAX_FLOAT_STR_LENGTH), NOT_NULL), #define IDX_BUF_STATS_LRU_IO_SUM 28 - {STRUCT_FLD(field_name, "LRU_IO_TOTAL"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("LRU_IO_TOTAL", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_LRU_IO_CUR 29 - {STRUCT_FLD(field_name, "LRU_IO_CURRENT"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("LRU_IO_CURRENT", ULonglong(), NOT_NULL), #define IDX_BUF_STATS_UNZIP_SUM 30 - {STRUCT_FLD(field_name, "UNCOMPRESS_TOTAL"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("UNCOMPRESS_TOTAL",ULonglong(), NOT_NULL), #define IDX_BUF_STATS_UNZIP_CUR 31 - {STRUCT_FLD(field_name, "UNCOMPRESS_CURRENT"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("UNCOMPRESS_CURRENT", ULonglong(), NOT_NULL), + + CEnd() }; +} // namespace Show /*******************************************************************//** Fill Information Schema table INNODB_BUFFER_POOL_STATS for a particular @@ -4492,7 +3821,7 @@ i_s_innodb_buffer_stats_fill_table( srv_buf_pool_instances * sizeof *pool_info); /* Walk through each buffer pool */ - for (ulint i = 0; i < srv_buf_pool_instances; i++) { + for (uint i = 0; i < srv_buf_pool_instances; i++) { buf_pool_t* buf_pool; buf_pool = buf_pool_from_array(i); @@ -4528,7 +3857,7 @@ i_s_innodb_buffer_pool_stats_init( schema = reinterpret_cast<ST_SCHEMA_TABLE*>(p); - schema->fields_info = i_s_innodb_buffer_stats_fields_info; + schema->fields_info = Show::i_s_innodb_buffer_stats_fields_info; schema->fill_table = i_s_innodb_buffer_stats_fill_table; DBUG_RETURN(0); @@ -4583,193 +3912,98 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_buffer_stats = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +/** These must correspond to the last values of buf_page_state */ +static const LEX_CSTRING page_state_values[] = +{ + { STRING_WITH_LEN("NOT_USED") }, + { STRING_WITH_LEN("READY_FOR_USE") }, + { STRING_WITH_LEN("FILE_PAGE") }, + { STRING_WITH_LEN("MEMORY") }, + { STRING_WITH_LEN("REMOVE_HASH") } +}; + +static const TypelibBuffer<5> page_state_values_typelib(page_state_values); + +static const LEX_CSTRING io_values[] = +{ + { STRING_WITH_LEN("IO_NONE") }, + { STRING_WITH_LEN("IO_READ") }, + { STRING_WITH_LEN("IO_WRITE") }, + { STRING_WITH_LEN("IO_PIN") } +}; + + +static TypelibBuffer<4> io_values_typelib(io_values); + +namespace Show { /* Fields of the dynamic table INNODB_BUFFER_POOL_PAGE. */ static ST_FIELD_INFO i_s_innodb_buffer_page_fields_info[] = { #define IDX_BUFFER_POOL_ID 0 - {STRUCT_FLD(field_name, "POOL_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("POOL_ID", ULong(), NOT_NULL), #define IDX_BUFFER_BLOCK_ID 1 - {STRUCT_FLD(field_name, "BLOCK_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("BLOCK_ID", ULonglong(), NOT_NULL), #define IDX_BUFFER_PAGE_SPACE 2 - {STRUCT_FLD(field_name, "SPACE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("SPACE", ULong(), NOT_NULL), #define IDX_BUFFER_PAGE_NUM 3 - {STRUCT_FLD(field_name, "PAGE_NUMBER"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGE_NUMBER", ULong(), NOT_NULL), #define IDX_BUFFER_PAGE_TYPE 4 - {STRUCT_FLD(field_name, "PAGE_TYPE"), - STRUCT_FLD(field_length, 64), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGE_TYPE", Varchar(64), NULLABLE), #define IDX_BUFFER_PAGE_FLUSH_TYPE 5 - {STRUCT_FLD(field_name, "FLUSH_TYPE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FLUSH_TYPE", ULong(), NOT_NULL), #define IDX_BUFFER_PAGE_FIX_COUNT 6 - {STRUCT_FLD(field_name, "FIX_COUNT"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FIX_COUNT", ULong(), NOT_NULL), #ifdef BTR_CUR_HASH_ADAPT #define IDX_BUFFER_PAGE_HASHED 7 - {STRUCT_FLD(field_name, "IS_HASHED"), - STRUCT_FLD(field_length, 3), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("IS_HASHED", SLong(1), NOT_NULL), #endif /* BTR_CUR_HASH_ADAPT */ #define IDX_BUFFER_PAGE_NEWEST_MOD 7 + I_S_AHI - {STRUCT_FLD(field_name, "NEWEST_MODIFICATION"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NEWEST_MODIFICATION", ULonglong(), NOT_NULL), #define IDX_BUFFER_PAGE_OLDEST_MOD 8 + I_S_AHI - {STRUCT_FLD(field_name, "OLDEST_MODIFICATION"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("OLDEST_MODIFICATION", ULonglong(), NOT_NULL), #define IDX_BUFFER_PAGE_ACCESS_TIME 9 + I_S_AHI - {STRUCT_FLD(field_name, "ACCESS_TIME"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("ACCESS_TIME", ULonglong(), NOT_NULL), #define IDX_BUFFER_PAGE_TABLE_NAME 10 + I_S_AHI - {STRUCT_FLD(field_name, "TABLE_NAME"), - STRUCT_FLD(field_length, 1024), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TABLE_NAME", Varchar(1024), NULLABLE), #define IDX_BUFFER_PAGE_INDEX_NAME 11 + I_S_AHI - {STRUCT_FLD(field_name, "INDEX_NAME"), - STRUCT_FLD(field_length, 1024), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("INDEX_NAME", Varchar(NAME_CHAR_LEN), NULLABLE), #define IDX_BUFFER_PAGE_NUM_RECS 12 + I_S_AHI - {STRUCT_FLD(field_name, "NUMBER_RECORDS"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NUMBER_RECORDS", ULonglong(), NOT_NULL), #define IDX_BUFFER_PAGE_DATA_SIZE 13 + I_S_AHI - {STRUCT_FLD(field_name, "DATA_SIZE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("DATA_SIZE", ULonglong(), NOT_NULL), #define IDX_BUFFER_PAGE_ZIP_SIZE 14 + I_S_AHI - {STRUCT_FLD(field_name, "COMPRESSED_SIZE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("COMPRESSED_SIZE", ULonglong(), NOT_NULL), #define IDX_BUFFER_PAGE_STATE 15 + I_S_AHI - {STRUCT_FLD(field_name, "PAGE_STATE"), - STRUCT_FLD(field_length, 64), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGE_STATE", Enum(&page_state_values_typelib), NOT_NULL), #define IDX_BUFFER_PAGE_IO_FIX 16 + I_S_AHI - {STRUCT_FLD(field_name, "IO_FIX"), - STRUCT_FLD(field_length, 64), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("IO_FIX", Enum(&io_values_typelib), NOT_NULL), #define IDX_BUFFER_PAGE_IS_OLD 17 + I_S_AHI - {STRUCT_FLD(field_name, "IS_OLD"), - STRUCT_FLD(field_length, 3), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("IS_OLD", SLong(1), NOT_NULL), #define IDX_BUFFER_PAGE_FREE_CLOCK 18 + I_S_AHI - {STRUCT_FLD(field_name, "FREE_PAGE_CLOCK"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("FREE_PAGE_CLOCK", ULonglong(), NOT_NULL), + + CEnd() }; +} // namespace Show /*******************************************************************//** Fill Information Schema table INNODB_BUFFER_PAGE with information @@ -4802,13 +4036,9 @@ i_s_innodb_buffer_page_fill( const buf_page_info_t* page_info; char table_name[MAX_FULL_NAME_LEN + 1]; const char* table_name_end = NULL; - const char* state_str; - enum buf_page_state state; page_info = info_array + i; - state_str = NULL; - OK(fields[IDX_BUFFER_POOL_ID]->store( page_info->pool_id, true)); @@ -4832,8 +4062,8 @@ i_s_innodb_buffer_page_fill( page_info->fix_count, true)); #ifdef BTR_CUR_HASH_ADAPT - OK(field_store_string(fields[IDX_BUFFER_PAGE_HASHED], - page_info->hashed ? "YES" : "NO")); + OK(fields[IDX_BUFFER_PAGE_HASHED]->store( + page_info->hashed, true)); #endif /* BTR_CUR_HASH_ADAPT */ OK(fields[IDX_BUFFER_PAGE_NEWEST_MOD]->store( @@ -4902,57 +4132,20 @@ i_s_innodb_buffer_page_fill( ? (UNIV_ZIP_SIZE_MIN >> 1) << page_info->zip_ssize : 0, true)); compile_time_assert(BUF_PAGE_STATE_BITS == 3); - state = static_cast<enum buf_page_state>(page_info->page_state); - switch (state) { /* First three states are for compression pages and are not states we would get as we scan pages through buffer blocks */ - case BUF_BLOCK_POOL_WATCH: - case BUF_BLOCK_ZIP_PAGE: - case BUF_BLOCK_ZIP_DIRTY: - state_str = NULL; - break; - case BUF_BLOCK_NOT_USED: - state_str = "NOT_USED"; - break; - case BUF_BLOCK_READY_FOR_USE: - state_str = "READY_FOR_USE"; - break; - case BUF_BLOCK_FILE_PAGE: - state_str = "FILE_PAGE"; - break; - case BUF_BLOCK_MEMORY: - state_str = "MEMORY"; - break; - case BUF_BLOCK_REMOVE_HASH: - state_str = "REMOVE_HASH"; - break; - }; - - OK(field_store_string(fields[IDX_BUFFER_PAGE_STATE], - state_str)); - - switch (page_info->io_fix) { - case BUF_IO_NONE: - state_str = "IO_NONE"; - break; - case BUF_IO_READ: - state_str = "IO_READ"; - break; - case BUF_IO_WRITE: - state_str = "IO_WRITE"; - break; - case BUF_IO_PIN: - state_str = "IO_PIN"; - break; - } + OK(fields[IDX_BUFFER_PAGE_STATE]->store( + page_info->page_state >= BUF_BLOCK_NOT_USED + ? page_info->page_state - (BUF_BLOCK_NOT_USED - 1) + : 0, true)); - OK(field_store_string(fields[IDX_BUFFER_PAGE_IO_FIX], - state_str)); + OK(fields[IDX_BUFFER_PAGE_IO_FIX]->store( + 1 + page_info->io_fix, true)); - OK(field_store_string(fields[IDX_BUFFER_PAGE_IS_OLD], - (page_info->is_old) ? "YES" : "NO")); + OK(fields[IDX_BUFFER_PAGE_IS_OLD]->store( + page_info->is_old, true)); OK(fields[IDX_BUFFER_PAGE_FREE_CLOCK]->store( page_info->freed_page_clock, true)); @@ -5258,7 +4451,7 @@ i_s_innodb_buffer_page_init( schema = reinterpret_cast<ST_SCHEMA_TABLE*>(p); - schema->fields_info = i_s_innodb_buffer_page_fields_info; + schema->fields_info = Show::i_s_innodb_buffer_page_fields_info; schema->fill_table = i_s_innodb_buffer_page_fill_table; DBUG_RETURN(0); @@ -5313,192 +4506,74 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_buffer_page = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { static ST_FIELD_INFO i_s_innodb_buf_page_lru_fields_info[] = { #define IDX_BUF_LRU_POOL_ID 0 - {STRUCT_FLD(field_name, "POOL_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("POOL_ID", ULong(), NOT_NULL), #define IDX_BUF_LRU_POS 1 - {STRUCT_FLD(field_name, "LRU_POSITION"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("LRU_POSITION", ULonglong(), NOT_NULL), #define IDX_BUF_LRU_PAGE_SPACE 2 - {STRUCT_FLD(field_name, "SPACE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("SPACE", ULong(), NOT_NULL), #define IDX_BUF_LRU_PAGE_NUM 3 - {STRUCT_FLD(field_name, "PAGE_NUMBER"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGE_NUMBER", ULong(), NOT_NULL), #define IDX_BUF_LRU_PAGE_TYPE 4 - {STRUCT_FLD(field_name, "PAGE_TYPE"), - STRUCT_FLD(field_length, 64), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGE_TYPE", Varchar(64), NULLABLE), #define IDX_BUF_LRU_PAGE_FLUSH_TYPE 5 - {STRUCT_FLD(field_name, "FLUSH_TYPE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FLUSH_TYPE", ULonglong(), NOT_NULL), #define IDX_BUF_LRU_PAGE_FIX_COUNT 6 - {STRUCT_FLD(field_name, "FIX_COUNT"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FIX_COUNT", ULong(), NOT_NULL), #ifdef BTR_CUR_HASH_ADAPT #define IDX_BUF_LRU_PAGE_HASHED 7 - {STRUCT_FLD(field_name, "IS_HASHED"), - STRUCT_FLD(field_length, 3), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("IS_HASHED", SLong(1), NOT_NULL), #endif /* BTR_CUR_HASH_ADAPT */ #define IDX_BUF_LRU_PAGE_NEWEST_MOD 7 + I_S_AHI - {STRUCT_FLD(field_name, "NEWEST_MODIFICATION"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NEWEST_MODIFICATION",ULonglong(), NOT_NULL), #define IDX_BUF_LRU_PAGE_OLDEST_MOD 8 + I_S_AHI - {STRUCT_FLD(field_name, "OLDEST_MODIFICATION"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("OLDEST_MODIFICATION",ULonglong(), NOT_NULL), #define IDX_BUF_LRU_PAGE_ACCESS_TIME 9 + I_S_AHI - {STRUCT_FLD(field_name, "ACCESS_TIME"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("ACCESS_TIME",ULonglong(), NOT_NULL), #define IDX_BUF_LRU_PAGE_TABLE_NAME 10 + I_S_AHI - {STRUCT_FLD(field_name, "TABLE_NAME"), - STRUCT_FLD(field_length, 1024), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TABLE_NAME", Varchar(1024), NULLABLE), #define IDX_BUF_LRU_PAGE_INDEX_NAME 11 + I_S_AHI - {STRUCT_FLD(field_name, "INDEX_NAME"), - STRUCT_FLD(field_length, 1024), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("INDEX_NAME", Varchar(NAME_CHAR_LEN), NULLABLE), #define IDX_BUF_LRU_PAGE_NUM_RECS 12 + I_S_AHI - {STRUCT_FLD(field_name, "NUMBER_RECORDS"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NUMBER_RECORDS", ULonglong(), NOT_NULL), #define IDX_BUF_LRU_PAGE_DATA_SIZE 13 + I_S_AHI - {STRUCT_FLD(field_name, "DATA_SIZE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("DATA_SIZE", ULonglong(), NOT_NULL), #define IDX_BUF_LRU_PAGE_ZIP_SIZE 14 + I_S_AHI - {STRUCT_FLD(field_name, "COMPRESSED_SIZE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("COMPRESSED_SIZE",ULonglong(), NOT_NULL), #define IDX_BUF_LRU_PAGE_STATE 15 + I_S_AHI - {STRUCT_FLD(field_name, "COMPRESSED"), - STRUCT_FLD(field_length, 3), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("COMPRESSED", SLong(1), NOT_NULL), #define IDX_BUF_LRU_PAGE_IO_FIX 16 + I_S_AHI - {STRUCT_FLD(field_name, "IO_FIX"), - STRUCT_FLD(field_length, 64), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("IO_FIX", Enum(&io_values_typelib), NOT_NULL), #define IDX_BUF_LRU_PAGE_IS_OLD 17 + I_S_AHI - {STRUCT_FLD(field_name, "IS_OLD"), - STRUCT_FLD(field_length, 3), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("IS_OLD", SLong(1), NULLABLE), #define IDX_BUF_LRU_PAGE_FREE_CLOCK 18 + I_S_AHI - {STRUCT_FLD(field_name, "FREE_PAGE_CLOCK"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("FREE_PAGE_CLOCK", ULonglong(), NOT_NULL), + + CEnd() }; +} // namespace Show /*******************************************************************//** Fill Information Schema table INNODB_BUFFER_PAGE_LRU with information @@ -5525,10 +4600,6 @@ i_s_innodb_buf_page_lru_fill( const buf_page_info_t* page_info; char table_name[MAX_FULL_NAME_LEN + 1]; const char* table_name_end = NULL; - const char* state_str; - enum buf_page_state state; - - state_str = NULL; page_info = info_array + i; @@ -5555,8 +4626,8 @@ i_s_innodb_buf_page_lru_fill( page_info->fix_count, true)); #ifdef BTR_CUR_HASH_ADAPT - OK(field_store_string(fields[IDX_BUF_LRU_PAGE_HASHED], - page_info->hashed ? "YES" : "NO")); + OK(fields[IDX_BUF_LRU_PAGE_HASHED]->store( + page_info->hashed, true)); #endif /* BTR_CUR_HASH_ADAPT */ OK(fields[IDX_BUF_LRU_PAGE_NEWEST_MOD]->store( @@ -5624,51 +4695,16 @@ i_s_innodb_buf_page_lru_fill( page_info->zip_ssize ? 512 << page_info->zip_ssize : 0, true)); - state = static_cast<enum buf_page_state>(page_info->page_state); - - switch (state) { - /* Compressed page */ - case BUF_BLOCK_ZIP_PAGE: - case BUF_BLOCK_ZIP_DIRTY: - state_str = "YES"; - break; - /* Uncompressed page */ - case BUF_BLOCK_FILE_PAGE: - state_str = "NO"; - break; - /* We should not see following states */ - case BUF_BLOCK_POOL_WATCH: - case BUF_BLOCK_READY_FOR_USE: - case BUF_BLOCK_NOT_USED: - case BUF_BLOCK_MEMORY: - case BUF_BLOCK_REMOVE_HASH: - state_str = NULL; - break; - }; - - OK(field_store_string(fields[IDX_BUF_LRU_PAGE_STATE], - state_str)); - - switch (page_info->io_fix) { - case BUF_IO_NONE: - state_str = "IO_NONE"; - break; - case BUF_IO_READ: - state_str = "IO_READ"; - break; - case BUF_IO_WRITE: - state_str = "IO_WRITE"; - break; - case BUF_IO_PIN: - state_str = "IO_PIN"; - break; - } + OK(fields[IDX_BUF_LRU_PAGE_STATE]->store( + page_info->page_state == BUF_BLOCK_ZIP_PAGE + || page_info->page_state == BUF_BLOCK_ZIP_DIRTY, + true)); - OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IO_FIX], - state_str)); + OK(fields[IDX_BUF_LRU_PAGE_IO_FIX]->store( + 1 + page_info->io_fix, true)); - OK(field_store_string(fields[IDX_BUF_LRU_PAGE_IS_OLD], - page_info->is_old ? "YES" : "NO")); + OK(fields[IDX_BUF_LRU_PAGE_IS_OLD]->store( + page_info->is_old, true)); OK(fields[IDX_BUF_LRU_PAGE_FREE_CLOCK]->store( page_info->freed_page_clock, true)); @@ -5809,7 +4845,7 @@ i_s_innodb_buffer_page_lru_init( schema = reinterpret_cast<ST_SCHEMA_TABLE*>(p); - schema->fields_info = i_s_innodb_buf_page_lru_fields_info; + schema->fields_info = Show::i_s_innodb_buf_page_lru_fields_info; schema->fill_table = i_s_innodb_buf_page_lru_fill_table; DBUG_RETURN(0); @@ -5876,84 +4912,56 @@ static int i_s_common_deinit(void*) DBUG_RETURN(0); } +static const LEX_CSTRING row_format_values[] = +{ + { STRING_WITH_LEN("Redundant") }, + { STRING_WITH_LEN("Compact") }, + { STRING_WITH_LEN("Compressed") }, + { STRING_WITH_LEN("Dynamic") } +}; + +static TypelibBuffer<4> row_format_values_typelib(row_format_values); + +static const LEX_CSTRING space_type_values[] = +{ + { STRING_WITH_LEN("Single") }, + { STRING_WITH_LEN("System") } +}; + +static TypelibBuffer<2> space_type_values_typelib(space_type_values); + +namespace Show { /** SYS_TABLES ***************************************************/ /* Fields of the dynamic table INFORMATION_SCHEMA.SYS_TABLES */ static ST_FIELD_INFO innodb_sys_tables_fields_info[] = { #define SYS_TABLES_ID 0 - {STRUCT_FLD(field_name, "TABLE_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TABLE_ID", ULonglong(), NOT_NULL), #define SYS_TABLES_NAME 1 - {STRUCT_FLD(field_name, "NAME"), - STRUCT_FLD(field_length, MAX_FULL_NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NAME", Varchar(MAX_FULL_NAME_LEN + 1), NOT_NULL), #define SYS_TABLES_FLAG 2 - {STRUCT_FLD(field_name, "FLAG"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FLAG", SLong(), NOT_NULL), #define SYS_TABLES_NUM_COLUMN 3 - {STRUCT_FLD(field_name, "N_COLS"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("N_COLS", ULong(), NOT_NULL), #define SYS_TABLES_SPACE 4 - {STRUCT_FLD(field_name, "SPACE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("SPACE", ULong(), NOT_NULL), #define SYS_TABLES_ROW_FORMAT 5 - {STRUCT_FLD(field_name, "ROW_FORMAT"), - STRUCT_FLD(field_length, 12), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("ROW_FORMAT", Enum(&row_format_values_typelib), NULLABLE), #define SYS_TABLES_ZIP_PAGE_SIZE 6 - {STRUCT_FLD(field_name, "ZIP_PAGE_SIZE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("ZIP_PAGE_SIZE", ULong(), NOT_NULL), #define SYS_TABLES_SPACE_TYPE 7 - {STRUCT_FLD(field_name, "SPACE_TYPE"), - STRUCT_FLD(field_length, 10), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("SPACE_TYPE", Enum(&space_type_values_typelib), NULLABLE), + + CEnd() }; +} // namespace Show /**********************************************************************//** Populate information_schema.innodb_sys_tables table with information @@ -6094,7 +5102,7 @@ innodb_sys_tables_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sys_tables_fields_info; + schema->fields_info = Show::innodb_sys_tables_fields_info; schema->fill_table = i_s_sys_tables_fill_table; DBUG_RETURN(0); @@ -6149,93 +5157,41 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_tables = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /** SYS_TABLESTATS ***********************************************/ /* Fields of the dynamic table INFORMATION_SCHEMA.SYS_TABLESTATS */ static ST_FIELD_INFO innodb_sys_tablestats_fields_info[] = { #define SYS_TABLESTATS_ID 0 - {STRUCT_FLD(field_name, "TABLE_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TABLE_ID", ULonglong(), NOT_NULL), #define SYS_TABLESTATS_NAME 1 - {STRUCT_FLD(field_name, "NAME"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NAME", Varchar(NAME_CHAR_LEN), NOT_NULL), #define SYS_TABLESTATS_INIT 2 - {STRUCT_FLD(field_name, "STATS_INITIALIZED"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("STATS_INITIALIZED", SLong(1), NOT_NULL), #define SYS_TABLESTATS_NROW 3 - {STRUCT_FLD(field_name, "NUM_ROWS"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NUM_ROWS", ULonglong(), NOT_NULL), #define SYS_TABLESTATS_CLUST_SIZE 4 - {STRUCT_FLD(field_name, "CLUST_INDEX_SIZE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CLUST_INDEX_SIZE", ULonglong(), NOT_NULL), #define SYS_TABLESTATS_INDEX_SIZE 5 - {STRUCT_FLD(field_name, "OTHER_INDEX_SIZE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("OTHER_INDEX_SIZE", ULonglong(), NOT_NULL), #define SYS_TABLESTATS_MODIFIED 6 - {STRUCT_FLD(field_name, "MODIFIED_COUNTER"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("MODIFIED_COUNTER", ULonglong(), NOT_NULL), #define SYS_TABLESTATS_AUTONINC 7 - {STRUCT_FLD(field_name, "AUTOINC"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("AUTOINC", ULonglong(), NOT_NULL), #define SYS_TABLESTATS_TABLE_REF_COUNT 8 - {STRUCT_FLD(field_name, "REF_COUNT"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("REF_COUNT", SLong(), NOT_NULL), + + CEnd() }; +} // namespace Show /** Populate information_schema.innodb_sys_tablestats table with information from SYS_TABLES. @@ -6265,10 +5221,9 @@ i_s_dict_fill_sys_tablestats( rw_lock_s_lock(&table->stats_latch); - if (table->stat_initialized) { - OK(field_store_string(fields[SYS_TABLESTATS_INIT], - "Initialized")); + OK(fields[SYS_TABLESTATS_INIT]->store(table->stat_initialized, true)); + if (table->stat_initialized) { OK(fields[SYS_TABLESTATS_NROW]->store(table->stat_n_rows, true)); @@ -6281,9 +5236,6 @@ i_s_dict_fill_sys_tablestats( OK(fields[SYS_TABLESTATS_MODIFIED]->store( table->stat_modified_counter, true)); } else { - OK(field_store_string(fields[SYS_TABLESTATS_INIT], - "Uninitialized")); - OK(fields[SYS_TABLESTATS_NROW]->store(0, true)); OK(fields[SYS_TABLESTATS_CLUST_SIZE]->store(0, true)); @@ -6399,7 +5351,7 @@ innodb_sys_tablestats_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sys_tablestats_fields_info; + schema->fields_info = Show::innodb_sys_tablestats_fields_info; schema->fill_table = i_s_sys_tables_fill_table_stats; DBUG_RETURN(0); @@ -6454,84 +5406,38 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_tablestats = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /** SYS_INDEXES **************************************************/ /* Fields of the dynamic table INFORMATION_SCHEMA.SYS_INDEXES */ static ST_FIELD_INFO innodb_sysindex_fields_info[] = { #define SYS_INDEX_ID 0 - {STRUCT_FLD(field_name, "INDEX_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("INDEX_ID", ULonglong(), NOT_NULL), #define SYS_INDEX_NAME 1 - {STRUCT_FLD(field_name, "NAME"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NAME", Varchar(NAME_CHAR_LEN), NOT_NULL), #define SYS_INDEX_TABLE_ID 2 - {STRUCT_FLD(field_name, "TABLE_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TABLE_ID", ULonglong(), NOT_NULL), #define SYS_INDEX_TYPE 3 - {STRUCT_FLD(field_name, "TYPE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TYPE", SLong(), NOT_NULL), #define SYS_INDEX_NUM_FIELDS 4 - {STRUCT_FLD(field_name, "N_FIELDS"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("N_FIELDS", SLong(), NOT_NULL), #define SYS_INDEX_PAGE_NO 5 - {STRUCT_FLD(field_name, "PAGE_NO"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGE_NO", SLong(), NOT_NULL), #define SYS_INDEX_SPACE 6 - {STRUCT_FLD(field_name, "SPACE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("SPACE", SLong(), NOT_NULL), #define SYS_INDEX_MERGE_THRESHOLD 7 - {STRUCT_FLD(field_name, "MERGE_THRESHOLD"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("MERGE_THRESHOLD", SLong(), NOT_NULL), + + CEnd() }; +} // namespace Show /**********************************************************************//** Function to populate the information_schema.innodb_sys_indexes table with @@ -6684,7 +5590,7 @@ innodb_sys_indexes_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sysindex_fields_info; + schema->fields_info = Show::innodb_sysindex_fields_info; schema->fill_table = i_s_sys_indexes_fill_table; DBUG_RETURN(0); @@ -6739,66 +5645,32 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_indexes = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /** SYS_COLUMNS **************************************************/ /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_SYS_COLUMNS */ static ST_FIELD_INFO innodb_sys_columns_fields_info[] = { #define SYS_COLUMN_TABLE_ID 0 - {STRUCT_FLD(field_name, "TABLE_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TABLE_ID", ULonglong(), NOT_NULL), #define SYS_COLUMN_NAME 1 - {STRUCT_FLD(field_name, "NAME"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NAME", Varchar(NAME_CHAR_LEN), NOT_NULL), #define SYS_COLUMN_POSITION 2 - {STRUCT_FLD(field_name, "POS"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("POS", ULonglong(), NOT_NULL), #define SYS_COLUMN_MTYPE 3 - {STRUCT_FLD(field_name, "MTYPE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("MTYPE", SLong(), NOT_NULL), #define SYS_COLUMN__PRTYPE 4 - {STRUCT_FLD(field_name, "PRTYPE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PRTYPE", SLong(), NOT_NULL), #define SYS_COLUMN_COLUMN_LEN 5 - {STRUCT_FLD(field_name, "LEN"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("LEN", SLong(), NOT_NULL), + + CEnd() }; +} // namespace Show /**********************************************************************//** Function to populate the information_schema.innodb_sys_columns with @@ -6930,7 +5802,7 @@ innodb_sys_columns_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sys_columns_fields_info; + schema->fields_info = Show::innodb_sys_columns_fields_info; schema->fill_table = i_s_sys_columns_fill_table; DBUG_RETURN(0); @@ -6985,39 +5857,23 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_columns = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /** SYS_VIRTUAL **************************************************/ /** Fields of the dynamic table INFORMATION_SCHEMA.INNODB_SYS_VIRTUAL */ static ST_FIELD_INFO innodb_sys_virtual_fields_info[] = { #define SYS_VIRTUAL_TABLE_ID 0 - {STRUCT_FLD(field_name, "TABLE_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("TABLE_ID", ULonglong(), NOT_NULL), #define SYS_VIRTUAL_POS 1 - {STRUCT_FLD(field_name, "POS"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("POS", ULong(), NOT_NULL), #define SYS_VIRTUAL_BASE_POS 2 - {STRUCT_FLD(field_name, "BASE_POS"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("BASE_POS", ULong(), NOT_NULL), + + CEnd() }; +} // namespace Show /** Function to populate the information_schema.innodb_sys_virtual with related information @@ -7133,7 +5989,7 @@ innodb_sys_virtual_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sys_virtual_fields_info; + schema->fields_info = Show::innodb_sys_virtual_fields_info; schema->fill_table = i_s_sys_virtual_fill_table; DBUG_RETURN(0); @@ -7187,39 +6043,25 @@ struct st_maria_plugin i_s_innodb_sys_virtual = STRUCT_FLD(version_info, INNODB_VERSION_STR), STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; + + +namespace Show { /** SYS_FIELDS ***************************************************/ /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_SYS_FIELDS */ static ST_FIELD_INFO innodb_sys_fields_fields_info[] = { #define SYS_FIELD_INDEX_ID 0 - {STRUCT_FLD(field_name, "INDEX_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("INDEX_ID", ULonglong(), NOT_NULL), #define SYS_FIELD_NAME 1 - {STRUCT_FLD(field_name, "NAME"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NAME", Varchar(NAME_CHAR_LEN), NOT_NULL), #define SYS_FIELD_POS 2 - {STRUCT_FLD(field_name, "POS"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("POS", ULong(), NOT_NULL), + + CEnd() }; +} // namespace Show /**********************************************************************//** Function to fill information_schema.innodb_sys_fields with information @@ -7342,7 +6184,7 @@ innodb_sys_fields_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sys_fields_fields_info; + schema->fields_info = Show::innodb_sys_fields_fields_info; schema->fill_table = i_s_sys_fields_fill_table; DBUG_RETURN(0); @@ -7397,57 +6239,29 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_fields = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /** SYS_FOREIGN ********************************************/ /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_SYS_FOREIGN */ static ST_FIELD_INFO innodb_sys_foreign_fields_info[] = { #define SYS_FOREIGN_ID 0 - {STRUCT_FLD(field_name, "ID"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("ID", Varchar(NAME_LEN + 1), NOT_NULL), #define SYS_FOREIGN_FOR_NAME 1 - {STRUCT_FLD(field_name, "FOR_NAME"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FOR_NAME", Varchar(NAME_LEN + 1), NOT_NULL), #define SYS_FOREIGN_REF_NAME 2 - {STRUCT_FLD(field_name, "REF_NAME"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("REF_NAME", Varchar(NAME_LEN + 1), NOT_NULL), #define SYS_FOREIGN_NUM_COL 3 - {STRUCT_FLD(field_name, "N_COLS"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("N_COLS", ULong(), NOT_NULL), #define SYS_FOREIGN_TYPE 4 - {STRUCT_FLD(field_name, "TYPE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("TYPE", ULong(), NOT_NULL), + + CEnd() }; +} // namespace Show /**********************************************************************//** Function to fill information_schema.innodb_sys_foreign with information @@ -7567,7 +6381,7 @@ innodb_sys_foreign_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sys_foreign_fields_info; + schema->fields_info = Show::innodb_sys_foreign_fields_info; schema->fill_table = i_s_sys_foreign_fill_table; DBUG_RETURN(0); @@ -7622,48 +6436,26 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_foreign = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /** SYS_FOREIGN_COLS ********************************************/ /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS */ static ST_FIELD_INFO innodb_sys_foreign_cols_fields_info[] = { #define SYS_FOREIGN_COL_ID 0 - {STRUCT_FLD(field_name, "ID"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("ID", Varchar(NAME_LEN + 1), NOT_NULL), #define SYS_FOREIGN_COL_FOR_NAME 1 - {STRUCT_FLD(field_name, "FOR_COL_NAME"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FOR_COL_NAME", Varchar(NAME_CHAR_LEN), NOT_NULL), #define SYS_FOREIGN_COL_REF_NAME 2 - {STRUCT_FLD(field_name, "REF_COL_NAME"), - STRUCT_FLD(field_length, NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("REF_COL_NAME", Varchar(NAME_CHAR_LEN), NOT_NULL), #define SYS_FOREIGN_COL_POS 3 - {STRUCT_FLD(field_name, "POS"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("POS", ULong(), NOT_NULL), + + CEnd() }; +} // namespace Show /**********************************************************************//** Function to fill information_schema.innodb_sys_foreign_cols with information @@ -7784,7 +6576,7 @@ innodb_sys_foreign_cols_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sys_foreign_cols_fields_info; + schema->fields_info = Show::innodb_sys_foreign_cols_fields_info; schema->fill_table = i_s_sys_foreign_cols_fill_table; DBUG_RETURN(0); @@ -7839,103 +6631,41 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_foreign_cols = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /** SYS_TABLESPACES ********************************************/ /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES */ static ST_FIELD_INFO innodb_sys_tablespaces_fields_info[] = { #define SYS_TABLESPACES_SPACE 0 - {STRUCT_FLD(field_name, "SPACE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("SPACE", ULong(), NOT_NULL), #define SYS_TABLESPACES_NAME 1 - {STRUCT_FLD(field_name, "NAME"), - STRUCT_FLD(field_length, MAX_FULL_NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NAME", Varchar(MAX_FULL_NAME_LEN + 1), NOT_NULL), #define SYS_TABLESPACES_FLAGS 2 - {STRUCT_FLD(field_name, "FLAG"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FLAG", ULong(), NOT_NULL), #define SYS_TABLESPACES_ROW_FORMAT 3 - {STRUCT_FLD(field_name, "ROW_FORMAT"), - STRUCT_FLD(field_length, 22), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("ROW_FORMAT", Varchar(22), NULLABLE), #define SYS_TABLESPACES_PAGE_SIZE 4 - {STRUCT_FLD(field_name, "PAGE_SIZE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("PAGE_SIZE", ULong(), NOT_NULL), #define SYS_TABLESPACES_ZIP_PAGE_SIZE 5 - {STRUCT_FLD(field_name, "ZIP_PAGE_SIZE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define SYS_TABLESPACES_SPACE_TYPE 6 - {STRUCT_FLD(field_name, "SPACE_TYPE"), - STRUCT_FLD(field_length, 10), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define SYS_TABLESPACES_FS_BLOCK_SIZE 7 - {STRUCT_FLD(field_name, "FS_BLOCK_SIZE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define SYS_TABLESPACES_FILE_SIZE 8 - {STRUCT_FLD(field_name, "FILE_SIZE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - -#define SYS_TABLESPACES_ALLOC_SIZE 9 - {STRUCT_FLD(field_name, "ALLOCATED_SIZE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("ZIP_PAGE_SIZE", ULong(), NOT_NULL), +#define SYS_TABLESPACES_FS_BLOCK_SIZE 6 + Column("FS_BLOCK_SIZE", ULong(),NOT_NULL), + +#define SYS_TABLESPACES_FILE_SIZE 7 + Column("FILE_SIZE", ULonglong(), NOT_NULL), + +#define SYS_TABLESPACES_ALLOC_SIZE 8 + Column("ALLOCATED_SIZE", ULonglong(), NOT_NULL), + + CEnd() }; +} // namespace Show /**********************************************************************//** Function to fill INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES with information @@ -7946,7 +6676,7 @@ int i_s_dict_fill_sys_tablespaces( /*==========================*/ THD* thd, /*!< in: thread */ - ulint space, /*!< in: space ID */ + uint32_t space, /*!< in: space ID */ const char* name, /*!< in: tablespace name */ ulint flags, /*!< in: tablespace flags */ TABLE* table_to_fill) /*!< in/out: fill this table */ @@ -7979,10 +6709,6 @@ i_s_dict_fill_sys_tablespaces( OK(field_store_string(fields[SYS_TABLESPACES_ROW_FORMAT], row_format)); - OK(field_store_string(fields[SYS_TABLESPACES_SPACE_TYPE], - is_system_tablespace(space) - ? "System" : "Single")); - ulint cflags = fil_space_t::is_valid_flags(flags, space) ? flags : fsp_flags_convert_from_101(flags); if (cflags == ULINT_UNDEFINED) { @@ -8098,7 +6824,7 @@ i_s_sys_tablespaces_fill_table( rec = dict_getnext_system(&pcur, &mtr)) { const char* err_msg; - ulint space; + uint32_t space; const char* name; ulint flags; @@ -8147,7 +6873,7 @@ innodb_sys_tablespaces_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sys_tablespaces_fields_info; + schema->fields_info = Show::innodb_sys_tablespaces_fields_info; schema->fill_table = i_s_sys_tablespaces_fill_table; DBUG_RETURN(0); @@ -8202,30 +6928,20 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_tablespaces = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /** SYS_DATAFILES ************************************************/ /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_SYS_DATAFILES */ static ST_FIELD_INFO innodb_sys_datafiles_fields_info[] = { #define SYS_DATAFILES_SPACE 0 - {STRUCT_FLD(field_name, "SPACE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("SPACE", ULong(), NOT_NULL), #define SYS_DATAFILES_PATH 1 - {STRUCT_FLD(field_name, "PATH"), - STRUCT_FLD(field_length, OS_FILE_MAX_PATH), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("PATH", Varchar(OS_FILE_MAX_PATH), NOT_NULL), + + CEnd() }; +} // namespace Show /**********************************************************************//** Function to fill INFORMATION_SCHEMA.INNODB_SYS_DATAFILES with information @@ -8236,7 +6952,7 @@ int i_s_dict_fill_sys_datafiles( /*========================*/ THD* thd, /*!< in: thread */ - ulint space, /*!< in: space ID */ + uint32_t space, /*!< in: space ID */ const char* path, /*!< in: absolute path */ TABLE* table_to_fill) /*!< in/out: fill this table */ { @@ -8246,7 +6962,7 @@ i_s_dict_fill_sys_datafiles( fields = table_to_fill->field; - OK(field_store_ulint(fields[SYS_DATAFILES_SPACE], space)); + OK(fields[SYS_DATAFILES_SPACE]->store(space, true)); OK(field_store_string(fields[SYS_DATAFILES_PATH], path)); @@ -8288,7 +7004,7 @@ i_s_sys_datafiles_fill_table( while (rec) { const char* err_msg; - ulint space; + uint32_t space; const char* path; /* Extract necessary information from a SYS_DATAFILES row */ @@ -8336,7 +7052,7 @@ innodb_sys_datafiles_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sys_datafiles_fields_info; + schema->fields_info = Show::innodb_sys_datafiles_fields_info; schema->fill_table = i_s_sys_datafiles_fill_table; DBUG_RETURN(0); @@ -8391,102 +7107,44 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_sys_datafiles = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; +namespace Show { /** TABLESPACES_ENCRYPTION ********************************************/ /* Fields of the table INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION */ static ST_FIELD_INFO innodb_tablespaces_encryption_fields_info[] = { #define TABLESPACES_ENCRYPTION_SPACE 0 - {STRUCT_FLD(field_name, "SPACE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("SPACE", ULong(), NOT_NULL), #define TABLESPACES_ENCRYPTION_NAME 1 - {STRUCT_FLD(field_name, "NAME"), - STRUCT_FLD(field_length, MAX_FULL_NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NAME", Varchar(MAX_FULL_NAME_LEN + 1), NULLABLE), #define TABLESPACES_ENCRYPTION_ENCRYPTION_SCHEME 2 - {STRUCT_FLD(field_name, "ENCRYPTION_SCHEME"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("ENCRYPTION_SCHEME", ULong(), NOT_NULL), #define TABLESPACES_ENCRYPTION_KEYSERVER_REQUESTS 3 - {STRUCT_FLD(field_name, "KEYSERVER_REQUESTS"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("KEYSERVER_REQUESTS", ULong(), NOT_NULL), #define TABLESPACES_ENCRYPTION_MIN_KEY_VERSION 4 - {STRUCT_FLD(field_name, "MIN_KEY_VERSION"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("MIN_KEY_VERSION", ULong(), NOT_NULL), #define TABLESPACES_ENCRYPTION_CURRENT_KEY_VERSION 5 - {STRUCT_FLD(field_name, "CURRENT_KEY_VERSION"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CURRENT_KEY_VERSION", ULong(), NOT_NULL), #define TABLESPACES_ENCRYPTION_KEY_ROTATION_PAGE_NUMBER 6 - {STRUCT_FLD(field_name, "KEY_ROTATION_PAGE_NUMBER"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("KEY_ROTATION_PAGE_NUMBER", ULonglong(), NULLABLE), #define TABLESPACES_ENCRYPTION_KEY_ROTATION_MAX_PAGE_NUMBER 7 - {STRUCT_FLD(field_name, "KEY_ROTATION_MAX_PAGE_NUMBER"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("KEY_ROTATION_MAX_PAGE_NUMBER", ULonglong(), NULLABLE), #define TABLESPACES_ENCRYPTION_CURRENT_KEY_ID 8 - {STRUCT_FLD(field_name, "CURRENT_KEY_ID"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CURRENT_KEY_ID", ULong(), NOT_NULL), #define TABLESPACES_ENCRYPTION_ROTATING_OR_FLUSHING 9 - {STRUCT_FLD(field_name, "ROTATING_OR_FLUSHING"), - STRUCT_FLD(field_length, 1), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("ROTATING_OR_FLUSHING", SLong(1), NOT_NULL), + + CEnd() }; +} // namespace Show /**********************************************************************//** Function to fill INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION @@ -8533,7 +7191,7 @@ i_s_dict_fill_tablespaces_encryption( OK(fields[TABLESPACES_ENCRYPTION_CURRENT_KEY_ID]->store( status.key_id, true)); OK(fields[TABLESPACES_ENCRYPTION_ROTATING_OR_FLUSHING]->store( - status.rotating || status.flushing, true)); + status.rotating || status.flushing, true)); if (status.rotating) { fields[TABLESPACES_ENCRYPTION_KEY_ROTATION_PAGE_NUMBER]->set_notnull(); @@ -8611,7 +7269,7 @@ innodb_tablespaces_encryption_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_tablespaces_encryption_fields_info; + schema->fields_info = Show::innodb_tablespaces_encryption_fields_info; schema->fill_table = i_s_tablespaces_encryption_fill_table; DBUG_RETURN(0); @@ -8666,93 +7324,41 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_tablespaces_encryption = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE) }; +namespace Show { /** TABLESPACES_SCRUBBING ********************************************/ /* Fields of the table INFORMATION_SCHEMA.INNODB_TABLESPACES_SCRUBBING */ static ST_FIELD_INFO innodb_tablespaces_scrubbing_fields_info[] = { #define TABLESPACES_SCRUBBING_SPACE 0 - {STRUCT_FLD(field_name, "SPACE"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("SPACE", ULonglong(), NOT_NULL), #define TABLESPACES_SCRUBBING_NAME 1 - {STRUCT_FLD(field_name, "NAME"), - STRUCT_FLD(field_length, MAX_FULL_NAME_LEN + 1), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NAME", Varchar(MAX_FULL_NAME_LEN + 1), NULLABLE), #define TABLESPACES_SCRUBBING_COMPRESSED 2 - {STRUCT_FLD(field_name, "COMPRESSED"), - STRUCT_FLD(field_length, 1), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("COMPRESSED", ULong(1), NOT_NULL), #define TABLESPACES_SCRUBBING_LAST_SCRUB_COMPLETED 3 - {STRUCT_FLD(field_name, "LAST_SCRUB_COMPLETED"), - STRUCT_FLD(field_length, 0), - STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("LAST_SCRUB_COMPLETED", Datetime(0), NULLABLE), #define TABLESPACES_SCRUBBING_CURRENT_SCRUB_STARTED 4 - {STRUCT_FLD(field_name, "CURRENT_SCRUB_STARTED"), - STRUCT_FLD(field_length, 0), - STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CURRENT_SCRUB_STARTED", Datetime(0), NULLABLE), #define TABLESPACES_SCRUBBING_CURRENT_SCRUB_ACTIVE_THREADS 5 - {STRUCT_FLD(field_name, "CURRENT_SCRUB_ACTIVE_THREADS"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED | MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CURRENT_SCRUB_ACTIVE_THREADS", ULong(), NULLABLE), #define TABLESPACES_SCRUBBING_CURRENT_SCRUB_PAGE_NUMBER 6 - {STRUCT_FLD(field_name, "CURRENT_SCRUB_PAGE_NUMBER"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CURRENT_SCRUB_PAGE_NUMBER", ULonglong(),NOT_NULL), #define TABLESPACES_SCRUBBING_CURRENT_SCRUB_MAX_PAGE_NUMBER 7 - {STRUCT_FLD(field_name, "CURRENT_SCRUB_MAX_PAGE_NUMBER"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CURRENT_SCRUB_MAX_PAGE_NUMBER", ULonglong(), NOT_NULL), #define TABLESPACES_SCRUBBING_ON_SSD 8 - {STRUCT_FLD(field_name, "ON_SSD"), - STRUCT_FLD(field_length, 1), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("ON_SSD", ULong(1), NOT_NULL), + + CEnd() }; +} // namespace Show /**********************************************************************//** Function to fill INFORMATION_SCHEMA.INNODB_TABLESPACES_SCRUBBING @@ -8885,7 +7491,7 @@ innodb_tablespaces_scrubbing_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_tablespaces_scrubbing_fields_info; + schema->fields_info = Show::innodb_tablespaces_scrubbing_fields_info; schema->fill_table = i_s_tablespaces_scrubbing_fill_table; DBUG_RETURN(0); @@ -8940,45 +7546,26 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_tablespaces_scrubbing = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE) }; +namespace Show { /** INNODB_MUTEXES *********************************************/ /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_MUTEXES */ static ST_FIELD_INFO innodb_mutexes_fields_info[] = { #define MUTEXES_NAME 0 - {STRUCT_FLD(field_name, "NAME"), - STRUCT_FLD(field_length, OS_FILE_MAX_PATH), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("NAME", Varchar(OS_FILE_MAX_PATH), NOT_NULL), + #define MUTEXES_CREATE_FILE 1 - {STRUCT_FLD(field_name, "CREATE_FILE"), - STRUCT_FLD(field_length, OS_FILE_MAX_PATH), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, 0), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CREATE_FILE", Varchar(OS_FILE_MAX_PATH), NOT_NULL), + #define MUTEXES_CREATE_LINE 2 - {STRUCT_FLD(field_name, "CREATE_LINE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CREATE_LINE", ULong(), NOT_NULL), + #define MUTEXES_OS_WAITS 3 - {STRUCT_FLD(field_name, "OS_WAITS"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("OS_WAITS", ULonglong(), NOT_NULL), + + CEnd() }; +} // namespace Show /*******************************************************************//** Function to populate INFORMATION_SCHEMA.INNODB_MUTEXES table. @@ -9044,7 +7631,7 @@ i_s_innodb_mutexes_fill_table( OK(field_store_string(fields[MUTEXES_CREATE_FILE], buf1)); OK(fields[MUTEXES_CREATE_LINE]->store(block_mutex->cline, true)); fields[MUTEXES_CREATE_LINE]->set_notnull(); - OK(field_store_ulint(fields[MUTEXES_OS_WAITS], (longlong)block_mutex_oswait_count)); + OK(fields[MUTEXES_OS_WAITS]->store((longlong)block_mutex_oswait_count), true); OK(schema_table_store_record(thd, tables->table)); } @@ -9122,7 +7709,7 @@ innodb_mutexes_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_mutexes_fields_info; + schema->fields_info = Show::innodb_mutexes_fields_info; schema->fill_table = i_s_innodb_mutexes_fill_table; DBUG_RETURN(0); @@ -9177,192 +7764,73 @@ UNIV_INTERN struct st_maria_plugin i_s_innodb_mutexes = STRUCT_FLD(maturity, MariaDB_PLUGIN_MATURITY_STABLE), }; -/** SYS_SEMAPHORE_WAITS ************************************************/ +namespace Show { /* Fields of the dynamic table INFORMATION_SCHEMA.INNODB_SYS_SEMAPHORE_WAITS */ static ST_FIELD_INFO innodb_sys_semaphore_waits_fields_info[] = { // SYS_SEMAPHORE_WAITS_THREAD_ID 0 - {STRUCT_FLD(field_name, "THREAD_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("THREAD_ID", ULonglong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_OBJECT_NAME 1 - {STRUCT_FLD(field_name, "OBJECT_NAME"), - STRUCT_FLD(field_length, OS_FILE_MAX_PATH), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("OBJECT_NAME", Varchar(OS_FILE_MAX_PATH), NULLABLE), // SYS_SEMAPHORE_WAITS_FILE 2 - {STRUCT_FLD(field_name, "FILE"), - STRUCT_FLD(field_length, OS_FILE_MAX_PATH), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("FILE", Varchar(OS_FILE_MAX_PATH), NULLABLE), // SYS_SEMAPHORE_WAITS_LINE 3 - {STRUCT_FLD(field_name, "LINE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("LINE", ULong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_WAIT_TIME 4 - {STRUCT_FLD(field_name, "WAIT_TIME"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("WAIT_TIME", ULonglong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_WAIT_OBJECT 5 - {STRUCT_FLD(field_name, "WAIT_OBJECT"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("WAIT_OBJECT", ULonglong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_WAIT_TYPE 6 - {STRUCT_FLD(field_name, "WAIT_TYPE"), - STRUCT_FLD(field_length, 16), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("WAIT_TYPE", Varchar(16), NULLABLE), // SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID 7 - {STRUCT_FLD(field_name, "HOLDER_THREAD_ID"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("HOLDER_THREAD_ID", ULonglong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_HOLDER_FILE 8 - {STRUCT_FLD(field_name, "HOLDER_FILE"), - STRUCT_FLD(field_length, OS_FILE_MAX_PATH), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("HOLDER_FILE", Varchar(OS_FILE_MAX_PATH), NULLABLE), // SYS_SEMAPHORE_WAITS_HOLDER_LINE 9 - {STRUCT_FLD(field_name, "HOLDER_LINE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("HOLDER_LINE", ULong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_CREATED_FILE 10 - {STRUCT_FLD(field_name, "CREATED_FILE"), - STRUCT_FLD(field_length, OS_FILE_MAX_PATH), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CREATED_FILE", Varchar(OS_FILE_MAX_PATH), NULLABLE), // SYS_SEMAPHORE_WAITS_CREATED_LINE 11 - {STRUCT_FLD(field_name, "CREATED_LINE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("CREATED_LINE", ULong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_WRITER_THREAD 12 - {STRUCT_FLD(field_name, "WRITER_THREAD"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("WRITER_THREAD", ULonglong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_RESERVATION_MODE 13 - {STRUCT_FLD(field_name, "RESERVATION_MODE"), - STRUCT_FLD(field_length, 16), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("RESERVATION_MODE", Varchar(16), NULLABLE), // SYS_SEMAPHORE_WAITS_READERS 14 - {STRUCT_FLD(field_name, "READERS"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("READERS", ULong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_WAITERS_FLAG 15 - {STRUCT_FLD(field_name, "WAITERS_FLAG"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("WAITERS_FLAG", ULonglong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_LOCK_WORD 16 - {STRUCT_FLD(field_name, "LOCK_WORD"), - STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("LOCK_WORD", ULonglong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_LAST_WRITER_FILE 17 - {STRUCT_FLD(field_name, "LAST_WRITER_FILE"), - STRUCT_FLD(field_length, OS_FILE_MAX_PATH), - STRUCT_FLD(field_type, MYSQL_TYPE_STRING), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_MAYBE_NULL), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("LAST_WRITER_FILE", Varchar(OS_FILE_MAX_PATH), NULLABLE), // SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE 18 - {STRUCT_FLD(field_name, "LAST_WRITER_LINE"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, + Column("LAST_WRITER_LINE", ULong(), NOT_NULL), // SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT 19 - {STRUCT_FLD(field_name, "OS_WAIT_COUNT"), - STRUCT_FLD(field_length, MY_INT32_NUM_DECIMAL_DIGITS), - STRUCT_FLD(field_type, MYSQL_TYPE_LONG), - STRUCT_FLD(value, 0), - STRUCT_FLD(field_flags, MY_I_S_UNSIGNED), - STRUCT_FLD(old_name, ""), - STRUCT_FLD(open_method, SKIP_OPEN_TABLE)}, - - END_OF_ST_FIELD_INFO + Column("OS_WAIT_COUNT", ULong(), NOT_NULL), + + CEnd() }; +} // namespace Show @@ -9381,7 +7849,7 @@ innodb_sys_semaphore_waits_init( schema = (ST_SCHEMA_TABLE*) p; - schema->fields_info = innodb_sys_semaphore_waits_fields_info; + schema->fields_info = Show::innodb_sys_semaphore_waits_fields_info; schema->fill_table = sync_arr_fill_sys_semphore_waits_table; DBUG_RETURN(0); diff --git a/storage/innobase/handler/i_s.h b/storage/innobase/handler/i_s.h index 66404dc32b4..781041bdfd4 100644 --- a/storage/innobase/handler/i_s.h +++ b/storage/innobase/handler/i_s.h @@ -136,16 +136,6 @@ HPUX aCC: HP ANSI C++ B3910B A.03.65) can't handle it. */ #define SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT 19 /*******************************************************************//** -Auxiliary function to store ulint value in MYSQL_TYPE_LONGLONG field. -If the value is ULINT_UNDEFINED then the field it set to NULL. -@return 0 on success */ -int -field_store_ulint( -/*==============*/ - Field* field, /*!< in/out: target field for storage */ - ulint n); /*!< in: value to store */ - -/*******************************************************************//** Auxiliary function to store char* value in MYSQL_TYPE_STRING field. @return 0 on success */ int diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index d33e241ae79..5ea6f7d1783 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -190,7 +190,7 @@ uint ibuf_debug; #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ /** The insert buffer control structure */ -ibuf_t* ibuf = NULL; +ibuf_t ibuf; /** @name Offsets to the per-page bits in the insert buffer bitmap */ /* @{ */ @@ -257,17 +257,17 @@ const ulint IBUF_MERGE_THRESHOLD = 4; batch, in order to merge the entries for them in the insert buffer */ const ulint IBUF_MAX_N_PAGES_MERGED = IBUF_MERGE_AREA; -/** If the combined size of the ibuf trees exceeds ibuf->max_size by this +/** If the combined size of the ibuf trees exceeds ibuf.max_size by this many pages, we start to contract it in connection to inserts there, using non-synchronous contract */ const ulint IBUF_CONTRACT_ON_INSERT_NON_SYNC = 0; -/** If the combined size of the ibuf trees exceeds ibuf->max_size by this +/** If the combined size of the ibuf trees exceeds ibuf.max_size by this many pages, we start to contract it in connection to inserts there, using synchronous contract */ const ulint IBUF_CONTRACT_ON_INSERT_SYNC = 5; -/** If the combined size of the ibuf trees exceeds ibuf->max_size by +/** If the combined size of the ibuf trees exceeds ibuf.max_size by this many pages, we start to contract it synchronous contract, but do not insert */ const ulint IBUF_CONTRACT_DO_NOT_INSERT = 10; @@ -360,7 +360,7 @@ ibuf_tree_root_get( ut_ad(ibuf_inside(mtr)); ut_ad(mutex_own(&ibuf_mutex)); - mtr_sx_lock(dict_index_get_lock(ibuf->index), mtr); + mtr_sx_lock(dict_index_get_lock(ibuf.index), mtr); /* only segment list access is exclusive each other */ block = buf_page_get( @@ -373,7 +373,7 @@ ibuf_tree_root_get( ut_ad(page_get_space_id(root) == IBUF_SPACE_ID); ut_ad(page_get_page_no(root) == FSP_IBUF_TREE_ROOT_PAGE_NO); - ut_ad(ibuf->empty == page_is_empty(root)); + ut_ad(ibuf.empty == page_is_empty(root)); return(root); } @@ -384,7 +384,7 @@ void ibuf_close(void) /*============*/ { - if (ibuf == NULL) { + if (!ibuf.index) { return; } @@ -394,13 +394,11 @@ ibuf_close(void) mutex_free(&ibuf_bitmap_mutex); - dict_table_t* ibuf_table = ibuf->index->table; - rw_lock_free(&ibuf->index->lock); - dict_mem_index_free(ibuf->index); + dict_table_t* ibuf_table = ibuf.index->table; + rw_lock_free(&ibuf.index->lock); + dict_mem_index_free(ibuf.index); dict_mem_table_free(ibuf_table); - - ut_free(ibuf); - ibuf = NULL; + ibuf.index = NULL; } /******************************************************************//** @@ -414,13 +412,13 @@ ibuf_size_update( { ut_ad(mutex_own(&ibuf_mutex)); - ibuf->free_list_len = flst_get_len(root + PAGE_HEADER + ibuf.free_list_len = flst_get_len(root + PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST); - ibuf->height = 1 + btr_page_get_level(root); + ibuf.height = 1 + btr_page_get_level(root); /* the '1 +' is the ibuf header page */ - ibuf->size = ibuf->seg_size - (1 + ibuf->free_list_len); + ibuf.size = ibuf.seg_size - (1 + ibuf.free_list_len); } /******************************************************************//** @@ -432,19 +430,28 @@ ibuf_init_at_db_start(void) /*=======================*/ { page_t* root; - mtr_t mtr; ulint n_used; page_t* header_page; - dberr_t error= DB_SUCCESS; - ibuf = static_cast<ibuf_t*>(ut_zalloc_nokey(sizeof(ibuf_t))); + ut_ad(!ibuf.index); + mtr_t mtr; + mtr.start(); + compile_time_assert(IBUF_SPACE_ID == TRX_SYS_SPACE); + compile_time_assert(IBUF_SPACE_ID == 0); + mtr_x_lock(&fil_system.sys_space->latch, &mtr); + header_page = ibuf_header_page_get(&mtr); + + if (!header_page) { + mtr.commit(); + return DB_DECRYPTION_FAILED; + } /* At startup we intialize ibuf to have a maximum of CHANGE_BUFFER_DEFAULT_SIZE in terms of percentage of the buffer pool size. Once ibuf struct is initialized this value is updated with the user supplied size by calling ibuf_max_size_update(). */ - ibuf->max_size = ((buf_pool_get_curr_size() >> srv_page_size_shift) + ibuf.max_size = ((buf_pool_get_curr_size() >> srv_page_size_shift) * CHANGE_BUFFER_DEFAULT_SIZE) / 100; mutex_create(LATCH_ID_IBUF, &ibuf_mutex); @@ -454,26 +461,14 @@ ibuf_init_at_db_start(void) mutex_create(LATCH_ID_IBUF_PESSIMISTIC_INSERT, &ibuf_pessimistic_insert_mutex); - mtr_start(&mtr); - - compile_time_assert(IBUF_SPACE_ID == TRX_SYS_SPACE); - compile_time_assert(IBUF_SPACE_ID == 0); - mtr_x_lock(&fil_system.sys_space->latch, &mtr); - mutex_enter(&ibuf_mutex); - header_page = ibuf_header_page_get(&mtr); - - if (!header_page) { - return (DB_DECRYPTION_FAILED); - } - fseg_n_reserved_pages(header_page + IBUF_HEADER + IBUF_TREE_SEG_HEADER, &n_used, &mtr); ut_ad(n_used >= 2); - ibuf->seg_size = n_used; + ibuf.seg_size = n_used; { buf_block_t* block; @@ -490,24 +485,24 @@ ibuf_init_at_db_start(void) ibuf_size_update(root); mutex_exit(&ibuf_mutex); - ibuf->empty = page_is_empty(root); + ibuf.empty = page_is_empty(root); mtr.commit(); - ibuf->index = dict_mem_index_create( + ibuf.index = dict_mem_index_create( dict_mem_table_create("innodb_change_buffer", fil_system.sys_space, 1, 0, 0, 0), "CLUST_IND", DICT_CLUSTERED | DICT_IBUF, 1); - ibuf->index->id = DICT_IBUF_ID_MIN + IBUF_SPACE_ID; - ibuf->index->n_uniq = REC_MAX_N_FIELDS; - rw_lock_create(index_tree_rw_lock_key, &ibuf->index->lock, + ibuf.index->id = DICT_IBUF_ID_MIN + IBUF_SPACE_ID; + ibuf.index->n_uniq = REC_MAX_N_FIELDS; + rw_lock_create(index_tree_rw_lock_key, &ibuf.index->lock, SYNC_IBUF_INDEX_TREE); #ifdef BTR_CUR_ADAPT - ibuf->index->search_info = btr_search_info_create(ibuf->index->heap); + ibuf.index->search_info = btr_search_info_create(ibuf.index->heap); #endif /* BTR_CUR_ADAPT */ - ibuf->index->page = FSP_IBUF_TREE_ROOT_PAGE_NO; - ut_d(ibuf->index->cached = TRUE); - return (error); + ibuf.index->page = FSP_IBUF_TREE_ROOT_PAGE_NO; + ut_d(ibuf.index->cached = TRUE); + return DB_SUCCESS; } /*********************************************************************//** @@ -521,7 +516,7 @@ ibuf_max_size_update( ulint new_size = ((buf_pool_get_curr_size() >> srv_page_size_shift) * new_val) / 100; mutex_enter(&ibuf_mutex); - ibuf->max_size = new_size; + ibuf.max_size = new_size; mutex_exit(&ibuf_mutex); } @@ -897,7 +892,7 @@ ibuf_update_free_bits_low( ulint before; ulint after; - ut_a(!buf_block_get_page_zip(block)); + ut_a(!is_buf_block_get_page_zip(block)); ut_ad(mtr->is_named_space(block->page.id.space())); before = ibuf_index_page_calc_free_bits(srv_page_size, @@ -1873,7 +1868,7 @@ static inline bool ibuf_data_enough_free_for_insert() inserts buffered for pages that we read to the buffer pool, without any risk of running out of free space in the insert buffer. */ - return(ibuf->free_list_len >= (ibuf->size / 2) + 3 * ibuf->height); + return(ibuf.free_list_len >= (ibuf.size / 2) + 3 * ibuf.height); } /*********************************************************************//** @@ -1887,7 +1882,7 @@ ibuf_data_too_much_free(void) { ut_ad(mutex_own(&ibuf_mutex)); - return(ibuf->free_list_len >= 3 + (ibuf->size / 2) + 3 * ibuf->height); + return(ibuf.free_list_len >= 3 + (ibuf.size / 2) + 3 * ibuf.height); } /*********************************************************************//** @@ -1948,8 +1943,8 @@ ibuf_add_free_page(void) mlog_write_ulint(page + FIL_PAGE_TYPE, FIL_PAGE_IBUF_FREE_LIST, MLOG_2BYTES, &mtr); - ibuf->seg_size++; - ibuf->free_list_len++; + ibuf.seg_size++; + ibuf.free_list_len++; /* Set the bit indicating that this page is now an ibuf tree page (level 2 page) */ @@ -2062,8 +2057,8 @@ ibuf_remove_free_page(void) mutex_exit(&ibuf_pessimistic_insert_mutex); - ibuf->seg_size--; - ibuf->free_list_len--; + ibuf.seg_size--; + ibuf.free_list_len--; /* Set the bit indicating that this page is no more an ibuf tree page (level 2 page) */ @@ -2403,18 +2398,18 @@ ibuf_merge_pages( position within the leaf */ bool available; - available = btr_pcur_open_at_rnd_pos(ibuf->index, BTR_SEARCH_LEAF, + available = btr_pcur_open_at_rnd_pos(ibuf.index, BTR_SEARCH_LEAF, &pcur, &mtr); /* No one should make this index unavailable when server is running */ ut_a(available); - ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf->index)); + ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf.index)); if (page_is_empty(btr_pcur_get_page(&pcur))) { /* If a B-tree page is empty, it must be the root page and the whole B-tree must be empty. InnoDB does not allow empty B-tree pages other than the root. */ - ut_ad(ibuf->empty); + ut_ad(ibuf.empty); ut_ad(page_get_space_id(btr_pcur_get_page(&pcur)) == IBUF_SPACE_ID); ut_ad(page_get_page_no(btr_pcur_get_page(&pcur)) @@ -2465,12 +2460,12 @@ ibuf_merge_space( /* Position the cursor on the first matching record. */ btr_pcur_open( - ibuf->index, tuple, PAGE_CUR_GE, BTR_SEARCH_LEAF, &pcur, + ibuf.index, tuple, PAGE_CUR_GE, BTR_SEARCH_LEAF, &pcur, &mtr); mem_heap_free(heap); - ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf->index)); + ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf.index)); ulint sum_sizes = 0; ulint pages[IBUF_MAX_N_PAGES_MERGED]; @@ -2480,7 +2475,7 @@ ibuf_merge_space( /* If a B-tree page is empty, it must be the root page and the whole B-tree must be empty. InnoDB does not allow empty B-tree pages other than the root. */ - ut_ad(ibuf->empty); + ut_ad(ibuf.empty); ut_ad(page_get_space_id(btr_pcur_get_page(&pcur)) == IBUF_SPACE_ID); ut_ad(page_get_page_no(btr_pcur_get_page(&pcur)) @@ -2530,12 +2525,12 @@ ibuf_merge( { *n_pages = 0; - /* We perform a dirty read of ibuf->empty, without latching + /* We perform a dirty read of ibuf.empty, without latching the insert buffer root page. We trust this dirty read except when a slow shutdown is being executed. During a slow shutdown, the insert buffer merge must be completed. */ - if (ibuf->empty && !srv_shutdown_state) { + if (ibuf.empty && !srv_shutdown_state) { return(0); #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG } else if (ibuf_debug) { @@ -2592,13 +2587,13 @@ ibuf_merge_in_background( mutex_enter(&ibuf_mutex); - /* If the ibuf->size is more than half the max_size + /* If the ibuf.size is more than half the max_size then we make more agreesive contraction. +1 is to avoid division by zero. */ - if (ibuf->size > ibuf->max_size / 2) { - ulint diff = ibuf->size - ibuf->max_size / 2; + if (ibuf.size > ibuf.max_size / 2) { + ulint diff = ibuf.size - ibuf.max_size / 2; n_pages += PCT_IO((diff * 100) - / (ibuf->max_size + 1)); + / (ibuf.max_size + 1)); } mutex_exit(&ibuf_mutex); @@ -2640,15 +2635,15 @@ ibuf_contract_after_insert( ulint size; ulint max_size; - /* Perform dirty reads of ibuf->size and ibuf->max_size, to - reduce ibuf_mutex contention. ibuf->max_size remains constant - after ibuf_init_at_db_start(), but ibuf->size should be - protected by ibuf_mutex. Given that ibuf->size fits in a + /* Perform dirty reads of ibuf.size and ibuf.max_size, to + reduce ibuf_mutex contention. ibuf.max_size remains constant + after ibuf_init_at_db_start(), but ibuf.size should be + protected by ibuf_mutex. Given that ibuf.size fits in a machine word, this should be OK; at worst we are doing some excessive ibuf_contract() or occasionally skipping a ibuf_contract(). */ - size = ibuf->size; - max_size = ibuf->max_size; + size = ibuf.size; + max_size = ibuf.max_size; if (size < max_size + IBUF_CONTRACT_ON_INSERT_NON_SYNC) { return; @@ -2889,7 +2884,7 @@ ibuf_get_volume_buffered( rec = btr_pcur_get_rec(pcur); page = page_align(rec); - ut_ad(page_validate(page, ibuf->index)); + ut_ad(page_validate(page, ibuf.index)); if (page_rec_is_supremum(rec)) { rec = page_rec_get_prev_const(rec); @@ -2929,7 +2924,7 @@ ibuf_get_volume_buffered( buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); prev_page = buf_block_get_frame(block); - ut_ad(page_validate(prev_page, ibuf->index)); + ut_ad(page_validate(prev_page, ibuf.index)); } #ifdef UNIV_BTR_DEBUG @@ -3001,7 +2996,7 @@ count_later: buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE); next_page = buf_block_get_frame(block); - ut_ad(page_validate(next_page, ibuf->index)); + ut_ad(page_validate(next_page, ibuf.index)); } #ifdef UNIV_BTR_DEBUG @@ -3047,14 +3042,14 @@ ibuf_update_max_tablespace_id(void) btr_pcur_t pcur; mtr_t mtr; - ut_a(!dict_table_is_comp(ibuf->index->table)); + ut_a(!dict_table_is_comp(ibuf.index->table)); ibuf_mtr_start(&mtr); btr_pcur_open_at_index_side( - false, ibuf->index, BTR_SEARCH_LEAF, &pcur, true, 0, &mtr); + false, ibuf.index, BTR_SEARCH_LEAF, &pcur, true, 0, &mtr); - ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf->index)); + ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf.index)); btr_pcur_move_to_prev(&pcur, &mtr); @@ -3185,7 +3180,7 @@ ibuf_get_entry_counter_func( { ut_ad(ibuf_inside(mtr)); ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX)); - ut_ad(page_validate(page_align(rec), ibuf->index)); + ut_ad(page_validate(page_align(rec), ibuf.index)); if (page_rec_is_supremum(rec)) { /* This is just for safety. The record should be a @@ -3285,16 +3280,16 @@ ibuf_insert_low( do_merge = FALSE; - /* Perform dirty reads of ibuf->size and ibuf->max_size, to - reduce ibuf_mutex contention. Given that ibuf->max_size and - ibuf->size fit in a machine word, this should be OK; at worst + /* Perform dirty reads of ibuf.size and ibuf.max_size, to + reduce ibuf_mutex contention. Given that ibuf.max_size and + ibuf.size fit in a machine word, this should be OK; at worst we are doing some excessive ibuf_contract() or occasionally skipping an ibuf_contract(). */ - if (ibuf->max_size == 0) { + if (ibuf.max_size == 0) { return(DB_STRONG_FAIL); } - if (ibuf->size >= ibuf->max_size + IBUF_CONTRACT_DO_NOT_INSERT) { + if (ibuf.size >= ibuf.max_size + IBUF_CONTRACT_DO_NOT_INSERT) { /* Insert buffer is now too big, contract it but do not try to insert */ @@ -3348,8 +3343,8 @@ ibuf_insert_low( ibuf_mtr_start(&mtr); - btr_pcur_open(ibuf->index, ibuf_entry, PAGE_CUR_LE, mode, &pcur, &mtr); - ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf->index)); + btr_pcur_open(ibuf.index, ibuf_entry, PAGE_CUR_LE, mode, &pcur, &mtr); + ut_ad(page_validate(btr_pcur_get_page(&pcur), ibuf.index)); /* Find out the volume of already buffered inserts for the same index page */ @@ -3488,7 +3483,7 @@ fail_exit: block = btr_cur_get_block(cursor); ut_ad(block->page.id.space() == IBUF_SPACE_ID); - /* If this is the root page, update ibuf->empty. */ + /* If this is the root page, update ibuf.empty. */ if (block->page.id.page_no() == FSP_IBUF_TREE_ROOT_PAGE_NO) { const page_t* root = buf_block_get_frame(block); @@ -3496,7 +3491,7 @@ fail_exit: ut_ad(page_get_page_no(root) == FSP_IBUF_TREE_ROOT_PAGE_NO); - ibuf->empty = page_is_empty(root); + ibuf.empty = page_is_empty(root); } } else { ut_ad(BTR_LATCH_MODE_WITHOUT_INTENTION(mode) @@ -3526,7 +3521,7 @@ fail_exit: mutex_exit(&ibuf_pessimistic_insert_mutex); ibuf_size_update(root); mutex_exit(&ibuf_mutex); - ibuf->empty = page_is_empty(root); + ibuf.empty = page_is_empty(root); block = btr_cur_get_block(cursor); ut_ad(block->page.id.space() == IBUF_SPACE_ID); @@ -3736,7 +3731,7 @@ ibuf_insert_to_index_page_low( been attempted by page_cur_tuple_insert(). Besides, per ibuf_index_page_calc_free_zip() the page should not have been recompressed or reorganized. */ - ut_ad(!buf_block_get_page_zip(block)); + ut_ad(!is_buf_block_get_page_zip(block)); /* If the record did not fit, reorganize */ @@ -4220,10 +4215,10 @@ ibuf_delete_rec( ut_ad(page_get_page_no(root) == FSP_IBUF_TREE_ROOT_PAGE_NO); - /* ibuf->empty is protected by the root page latch. + /* ibuf.empty is protected by the root page latch. Before the deletion, it had to be FALSE. */ - ut_ad(!ibuf->empty); - ibuf->empty = true; + ut_ad(!ibuf.empty); + ibuf.empty = true; } return(FALSE); @@ -4264,7 +4259,7 @@ ibuf_delete_rec( ibuf_size_update(root); mutex_exit(&ibuf_mutex); - ibuf->empty = page_is_empty(root); + ibuf.empty = page_is_empty(root); ibuf_btr_pcur_commit_specify_mtr(pcur, mtr); func_exit: @@ -4410,7 +4405,7 @@ loop: /* Position pcur in the insert buffer at the first entry for this index page */ btr_pcur_open_on_user_rec( - ibuf->index, search_tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF, + ibuf.index, search_tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF, &pcur, &mtr); if (block != NULL) { @@ -4478,7 +4473,7 @@ loop: page_update_max_trx_id(block, page_zip, max_trx_id, &mtr); - ut_ad(page_validate(page_align(rec), ibuf->index)); + ut_ad(page_validate(page_align(rec), ibuf.index)); entry = ibuf_build_entry_from_ibuf_rec( &mtr, rec, heap, &dummy_index); @@ -4626,9 +4621,9 @@ reset_bit: btr_pcur_close(&pcur); mem_heap_free(heap); - ibuf->n_merges++; - ibuf_add_ops(ibuf->n_merged_ops, mops); - ibuf_add_ops(ibuf->n_discarded_ops, dops); + ibuf.n_merges++; + ibuf_add_ops(ibuf.n_merged_ops, mops); + ibuf_add_ops(ibuf.n_discarded_ops, dops); } /*********************************************************************//** @@ -4665,7 +4660,7 @@ loop: /* Position pcur in the insert buffer at the first entry for the space */ btr_pcur_open_on_user_rec( - ibuf->index, search_tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF, + ibuf.index, search_tuple, PAGE_CUR_GE, BTR_MODIFY_LEAF, &pcur, &mtr); if (!btr_pcur_is_on_user_rec(&pcur)) { @@ -4710,7 +4705,7 @@ leave_loop: ibuf_mtr_commit(&mtr); btr_pcur_close(&pcur); - ibuf_add_ops(ibuf->n_discarded_ops, dops); + ibuf_add_ops(ibuf.n_discarded_ops, dops); mem_heap_free(heap); } @@ -4733,7 +4728,7 @@ ibuf_is_empty(void) mutex_exit(&ibuf_mutex); is_empty = page_is_empty(root); - ut_a(is_empty == ibuf->empty); + ut_a(is_empty == ibuf.empty); ibuf_mtr_commit(&mtr); return(is_empty); @@ -4751,16 +4746,16 @@ ibuf_print( fprintf(file, "Ibuf: size " ULINTPF ", free list len " ULINTPF "," " seg size " ULINTPF ", " ULINTPF " merges\n", - ibuf->size, - ibuf->free_list_len, - ibuf->seg_size, - ulint{ibuf->n_merges}); + ibuf.size, + ibuf.free_list_len, + ibuf.seg_size, + ulint{ibuf.n_merges}); fputs("merged operations:\n ", file); - ibuf_print_ops(ibuf->n_merged_ops, file); + ibuf_print_ops(ibuf.n_merged_ops, file); fputs("discarded operations:\n ", file); - ibuf_print_ops(ibuf->n_discarded_ops, file); + ibuf_print_ops(ibuf.n_discarded_ops, file); mutex_exit(&ibuf_mutex); } diff --git a/storage/innobase/include/btr0bulk.h b/storage/innobase/include/btr0bulk.h index 0fcf4a36d6b..d1a8af22d68 100644 --- a/storage/innobase/include/btr0bulk.h +++ b/storage/innobase/include/btr0bulk.h @@ -34,8 +34,6 @@ Created 03/11/2014 Shaohua Wang /** Innodb B-tree index fill factor for bulk load. */ extern uint innobase_fill_factor; -/** whether to reduce redo logging during ALTER TABLE */ -extern my_bool innodb_log_optimize_ddl; /* The proper function call sequence of PageBulk is as below: diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 647cc3d4274..70270edc95c 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -137,7 +137,7 @@ enum buf_page_state { will be used to print table IO stats */ struct buf_pool_info_t{ /* General buffer pool info */ - ulint pool_unique_id; /*!< Buffer Pool ID */ + uint pool_unique_id; /*!< Buffer Pool ID */ ulint pool_size; /*!< Buffer Pool size in pages */ ulint lru_len; /*!< Length of buf_pool->LRU */ ulint old_lru_len; /*!< buf_pool->LRU_old_len */ @@ -828,7 +828,7 @@ void buf_stats_get_pool_info( /*====================*/ buf_pool_t* buf_pool, /*!< in: buffer pool */ - ulint pool_id, /*!< in: buffer pool ID */ + uint pool_id, /*!< in: buffer pool ID */ buf_pool_info_t* all_pool_info); /*!< in/out: buffer pool info to fill */ /** Return the ratio in percents of modified pages in the buffer pool / @@ -1107,6 +1107,8 @@ Gets the compressed page descriptor corresponding to an uncompressed page if applicable. */ #define buf_block_get_page_zip(block) \ ((block)->page.zip.data ? &(block)->page.zip : NULL) +#define is_buf_block_get_page_zip(block) \ + ((block)->page.zip.data != 0) #ifdef BTR_CUR_HASH_ADAPT /** Get a buffer block from an adaptive hash index pointer. @@ -1493,6 +1495,13 @@ public: bool encrypted; /*!< page is still encrypted */ + /** whether the page will be (re)initialized at the time it will + be written to the file, that is, whether the doublewrite buffer + can be safely skipped. Protected under similar conditions as + buf_block_t::frame. Can be set while holding buf_block_t::lock + X-latch and reset during page flush, while io_fix is in effect. */ + bool init_on_flush; + ulint real_size; /*!< Real size of the page Normal pages == srv_page_size page compressed pages, payload diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h index 23d14797510..20fc7240efc 100644 --- a/storage/innobase/include/buf0flu.h +++ b/storage/innobase/include/buf0flu.h @@ -31,6 +31,9 @@ Created 11/5/1995 Heikki Tuuri #include "log0log.h" #include "buf0types.h" +/** Number of pages flushed through non flush_list flushes. */ +extern ulint buf_lru_flush_page_count; + /** Flag indicating if the page_cleaner is in active state. */ extern bool buf_page_cleaner_is_active; diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index c9def01a955..32782c27b55 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -1602,6 +1602,23 @@ public: mutex_exit(&mutex); rw_lock_x_unlock(&latch); } + + /** Estimate the used memory occupied by the data dictionary + table and index objects. + @return number of bytes occupied */ + ulint rough_size() const + { + /* No mutex; this is a very crude approximation anyway */ + ulint size = UT_LIST_GET_LEN(table_LRU) + UT_LIST_GET_LEN(table_non_LRU); + size *= sizeof(dict_table_t) + + sizeof(dict_index_t) * 2 + + (sizeof(dict_col_t) + sizeof(dict_field_t)) * 10 + + sizeof(dict_field_t) * 5 /* total number of key fields */ + + 200; /* arbitrary, covering names and overhead */ + size += (table_hash->n_cells + table_id_hash->n_cells + + temp_id_hash->n_cells) * sizeof(hash_cell_t); + return size; + } }; /** the data dictionary cache */ @@ -1823,13 +1840,6 @@ dict_table_decode_n_col( ulint* n_col, ulint* n_v_col); -/** Calculate the used memory occupied by the data dictionary -table and index objects. -@return number of bytes occupied. */ -UNIV_INTERN -ulint -dict_sys_get_size(); - /** Look for any dictionary objects that are found in the given tablespace. @param[in] space_id Tablespace ID to search for. @return true if tablespace is empty. */ diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index 8fda39b339b..5a1fe46db61 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -281,7 +281,7 @@ dict_process_sys_tablespaces( /*=========================*/ mem_heap_t* heap, /*!< in/out: heap memory */ const rec_t* rec, /*!< in: current SYS_TABLESPACES rec */ - ulint* space, /*!< out: pace id */ + uint32_t* space, /*!< out: tablespace identifier */ const char** name, /*!< out: tablespace name */ ulint* flags); /*!< out: tablespace flags */ /********************************************************************//** @@ -293,7 +293,7 @@ dict_process_sys_datafiles( /*=======================*/ mem_heap_t* heap, /*!< in/out: heap memory */ const rec_t* rec, /*!< in: current SYS_DATAFILES rec */ - ulint* space, /*!< out: pace id */ + uint32_t* space, /*!< out: tablespace identifier */ const char** path); /*!< out: datafile path */ /** Update the record for space_id in SYS_TABLESPACES to this filepath. diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 04c7f4f18d1..ea6d8e235c7 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -31,12 +31,15 @@ Created 10/25/1995 Heikki Tuuri #ifndef UNIV_INNOCHECKSUM +#include "hash0hash.h" #include "log0recv.h" #include "dict0types.h" #ifdef UNIV_LINUX # include <set> #endif +/** whether to reduce redo logging during ALTER TABLE */ +extern my_bool innodb_log_optimize_ddl; // Forward declaration extern my_bool srv_use_doublewrite_buf; extern struct buf_dblwr_t* buf_dblwr; diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h index 75c448c956d..26da55bb2ad 100644 --- a/storage/innobase/include/fsp0fsp.h +++ b/storage/innobase/include/fsp0fsp.h @@ -625,7 +625,17 @@ inline void fsp_init_file_page( ut_d(space->modify_check(*mtr)); ut_ad(space->id == block->page.id.space()); fsp_apply_init_file_page(block); - mlog_write_initial_log_record(block->frame, MLOG_INIT_FILE_PAGE2, mtr); + + if (byte* log_ptr = mlog_open(mtr, 11)) { + log_ptr = mlog_write_initial_log_record_low( + MLOG_INIT_FILE_PAGE2, + block->page.id.space(), block->page.id.page_no(), + log_ptr, mtr); + mlog_close(mtr, log_ptr); + if (!innodb_log_optimize_ddl) { + block->page.init_on_flush = true; + } + } } #ifndef UNIV_DEBUG diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h index 582ef2fda1b..146053d0f63 100644 --- a/storage/innobase/include/ibuf0ibuf.h +++ b/storage/innobase/include/ibuf0ibuf.h @@ -62,7 +62,7 @@ enum ibuf_use_t { extern ulong innodb_change_buffering; /** The insert buffer control structure */ -extern ibuf_t* ibuf; +extern ibuf_t ibuf; /* The purpose of the insert buffer is to reduce random disk access. When we wish to insert a record into a non-unique secondary index and diff --git a/storage/innobase/include/ibuf0ibuf.ic b/storage/innobase/include/ibuf0ibuf.ic index db8c122c0f7..e2170f79579 100644 --- a/storage/innobase/include/ibuf0ibuf.ic +++ b/storage/innobase/include/ibuf0ibuf.ic @@ -126,7 +126,7 @@ ibuf_should_try( decide */ { return(innodb_change_buffering - && ibuf->max_size != 0 + && ibuf.max_size != 0 && !dict_index_is_clust(index) && !dict_index_is_spatial(index) && index->table->quiesce == QUIESCE_NONE diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index 8ae0b062729..6300706a2b9 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -605,42 +605,6 @@ lock_get_type( const lock_t* lock); /*!< in: lock */ /*******************************************************************//** -Gets the trx of the lock. Non-inline version for using outside of the -lock module. -@return trx_t* */ -UNIV_INTERN -trx_t* -lock_get_trx( -/*=========*/ - const lock_t* lock); /*!< in: lock */ - -/*******************************************************************//** -Gets the id of the transaction owning a lock. -@return transaction id */ -trx_id_t -lock_get_trx_id( -/*============*/ - const lock_t* lock); /*!< in: lock */ - -/*******************************************************************//** -Gets the mode of a lock in a human readable string. -The string should not be free()'d or modified. -@return lock mode */ -const char* -lock_get_mode_str( -/*==============*/ - const lock_t* lock); /*!< in: lock */ - -/*******************************************************************//** -Gets the type of a lock in a human readable string. -The string should not be free()'d or modified. -@return lock type */ -const char* -lock_get_type_str( -/*==============*/ - const lock_t* lock); /*!< in: lock */ - -/*******************************************************************//** Gets the id of the table on which the lock is. @return id of the table */ table_id_t @@ -673,21 +637,6 @@ lock_rec_get_index_name( const lock_t* lock); /*!< in: lock */ /*******************************************************************//** -For a record lock, gets the tablespace number on which the lock is. -@return tablespace number */ -ulint -lock_rec_get_space_id( -/*==================*/ - const lock_t* lock); /*!< in: lock */ - -/*******************************************************************//** -For a record lock, gets the page number on which the lock is. -@return page number */ -ulint -lock_rec_get_page_no( -/*=================*/ - const lock_t* lock); /*!< in: lock */ -/*******************************************************************//** Check if there are any locks (table or rec) against table. @return TRUE if locks exist */ bool diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 9015d78bf67..a18684011aa 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -58,10 +58,6 @@ step which modifies the database, is started */ typedef ulint (*log_checksum_func_t)(const byte* log_block); -/** Pointer to the log checksum calculation function. Protected with -log_sys.mutex. */ -extern log_checksum_func_t log_checksum_algorithm_ptr; - /** Append a string to the log. @param[in] str string @param[in] len string length @@ -265,28 +261,10 @@ log_block_set_data_len( /*===================*/ byte* log_block, /*!< in/out: log block */ ulint len); /*!< in: data length */ -/************************************************************//** -Calculates the checksum for a log block. -@return checksum */ -UNIV_INLINE -ulint -log_block_calc_checksum( -/*====================*/ - const byte* block); /*!< in: log block */ - -/** Calculates the checksum for a log block using the CRC32 algorithm. +/** Calculate the CRC-32C checksum of a log block. @param[in] block log block @return checksum */ -UNIV_INLINE -ulint -log_block_calc_checksum_crc32( - const byte* block); - -/** Calculates the checksum for a log block using the "no-op" algorithm. -@return the calculated checksum value */ -UNIV_INLINE -ulint -log_block_calc_checksum_none(const byte*); +inline ulint log_block_calc_checksum_crc32(const byte* block); /************************************************************//** Gets a log block checksum field value. @@ -364,9 +342,6 @@ void log_refresh_stats(void); /*===================*/ -/** Whether to generate and require checksums on the redo log pages */ -extern my_bool innodb_log_checksums; - /* Values used as flags */ #define LOG_FLUSH 7652559 #define LOG_CHECKPOINT 78656949 diff --git a/storage/innobase/include/log0log.ic b/storage/innobase/include/log0log.ic index 7dfa7c0db68..7ea34d6268e 100644 --- a/storage/innobase/include/log0log.ic +++ b/storage/innobase/include/log0log.ic @@ -190,18 +190,6 @@ log_block_convert_lsn_to_no( 0xFUL, 0x3FFFFFFFUL)) + 1); } -/************************************************************//** -Calculates the checksum for a log block. -@return checksum */ -UNIV_INLINE -ulint -log_block_calc_checksum( -/*====================*/ - const byte* block) /*!< in: log block */ -{ - return(log_checksum_algorithm_ptr(block)); -} - /** Calculate the checksum for a log block using the pre-5.7.9 algorithm. @param[in] block log block @return checksum */ @@ -231,26 +219,14 @@ log_block_calc_checksum_format_0( return(sum); } -/** Calculate the checksum for a log block using the MySQL 5.7 algorithm. +/** Calculate the CRC-32C checksum of a log block. @param[in] block log block @return checksum */ -UNIV_INLINE -ulint -log_block_calc_checksum_crc32( - const byte* block) +inline ulint log_block_calc_checksum_crc32(const byte* block) { return ut_crc32(block, OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM); } -/** Calculates the checksum for a log block using the "no-op" algorithm. -@return checksum */ -UNIV_INLINE -ulint -log_block_calc_checksum_none(const byte*) -{ - return(LOG_NO_CHECKSUM_MAGIC); -} - /************************************************************//** Gets a log block checksum field value. @return checksum */ diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index 5a687b5df08..7cd05b2f755 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -29,7 +29,6 @@ Created 9/20/1997 Heikki Tuuri #include "ut0byte.h" #include "buf0types.h" -#include "hash0hash.h" #include "log0log.h" #include "mtr0types.h" @@ -48,10 +47,10 @@ dberr_t recv_find_max_checkpoint(ulint* max_field) MY_ATTRIBUTE((nonnull, warn_unused_result)); -/** Reduces recv_sys.n_addrs for the corrupted page. +/** Remove records for a corrupted page. This function should called when srv_force_recovery > 0. @param[in] page_id page id of the corrupted page */ -void recv_recover_corrupt_page(page_id_t page_id); +ATTRIBUTE_COLD void recv_recover_corrupt_page(page_id_t page_id); /** Apply any buffered redo log to a page that was just read from a data file. @param[in,out] bpage buffer pool page */ @@ -80,13 +79,13 @@ void recv_sys_var_init(void); /*===================*/ -/** Apply the hash table of stored log records to persistent data pages. +/** Apply recv_sys.pages to persistent data pages. @param[in] last_batch whether the change buffer merge will be performed as part of the operation */ void recv_apply_hashed_log_recs(bool last_batch); -/** Whether to store redo log records to the hash table */ +/** Whether to store redo log records in recv_sys.pages */ enum store_t { /** Do not store redo log records. */ STORE_NO, @@ -105,8 +104,8 @@ recv_sys.parse_start_lsn is non-zero. @return true if more data added */ bool recv_sys_add_to_parsing_buf(const byte* log_block, lsn_t scanned_lsn); -/** Parse log records from a buffer and optionally store them to a -hash table to wait merging to file pages. +/** Parse log records from a buffer and optionally store them in recv_sys.pages +to wait merging to file pages. @param[in] checkpoint_lsn the LSN of the latest checkpoint @param[in] store whether to store page operations @param[in] apply whether to apply the records @@ -144,8 +143,12 @@ struct recv_data_t{ /** Stored log record struct */ struct recv_t{ - mlog_id_t type; /*!< log record type */ - ulint len; /*!< log record body length in bytes */ + /** next record */ + recv_t* next; + /** log record body length in bytes */ + uint32_t len; + /** log record type */ + mlog_id_t type; recv_data_t* data; /*!< chain of blocks containing the log record body */ lsn_t start_lsn;/*!< start lsn of the log segment written by @@ -156,8 +159,6 @@ struct recv_t{ the mtr which generated this log record: NOTE that this is not necessarily the end lsn of this log record */ - UT_LIST_NODE_T(recv_t) - rec_list;/*!< list of log records for this page */ }; struct recv_dblwr_t { @@ -205,7 +206,7 @@ struct recv_sys_t{ lsn_t parse_start_lsn; /*!< this is the lsn from which we were able to start parsing log records and adding them to - the hash table; zero if a suitable + pages; zero if a suitable start point not found yet */ lsn_t scanned_lsn; /*!< the log data has been scanned up to this @@ -234,9 +235,38 @@ struct recv_sys_t{ time_t progress_time; mem_heap_t* heap; /*!< memory heap of log records and file addresses*/ - hash_table_t* addr_hash;/*!< hash table of file addresses of pages */ - ulint n_addrs;/*!< number of not processed hashed file - addresses in the hash table */ + + /** buffered records waiting to be applied to a page */ + struct recs_t + { + /** Recovery state */ + enum { + /** not yet processed */ + RECV_NOT_PROCESSED, + /** not processed; the page will be reinitialized */ + RECV_WILL_NOT_READ, + /** page is being read */ + RECV_BEING_READ, + /** log records are being applied on the page */ + RECV_BEING_PROCESSED + } state; + /** First log record */ + recv_t* log; + /** Last log record */ + recv_t* last; + }; + + using map = std::map<const page_id_t, recs_t, + std::less<const page_id_t>, + ut_allocator<std::pair<const page_id_t,recs_t>>>; + /** buffered records waiting to be applied to pages */ + map pages; + + /** Process a record that indicates that a tablespace is + being shrunk in size. + @param page_id first page identifier that is not in the file + @param lsn log sequence number of the shrink operation */ + inline void trim(const page_id_t page_id, lsn_t lsn); /** Undo tablespaces for which truncate has been logged (indexed by id - srv_undo_space_id_start) */ @@ -249,7 +279,7 @@ struct recv_sys_t{ recv_dblwr_t dblwr; - /** Lastly added LSN to the hash table of log records. */ + /** Last added LSN to pages. */ lsn_t last_stored_lsn; /** Initialize the redo log recovery subsystem. */ @@ -265,13 +295,12 @@ struct recv_sys_t{ /** Store a redo log record for applying. @param type record type - @param space tablespace identifier - @param page_no page number + @param page_id page identifier @param body record body @param rec_end end of record @param lsn start LSN of the mini-transaction @param end_lsn end LSN of the mini-transaction */ - inline void add(mlog_id_t type, ulint space, ulint page_no, + inline void add(mlog_id_t type, const page_id_t page_id, byte* body, byte* rec_end, lsn_t lsn, lsn_t end_lsn); @@ -301,8 +330,8 @@ otherwise. Note that this is FALSE while a background thread is rolling back incomplete transactions. */ extern volatile bool recv_recovery_on; /** If the following is TRUE, the buffer pool file pages must be invalidated -after recovery and no ibuf operations are allowed; this becomes TRUE if -the log record hash table becomes too full, and log records must be merged +after recovery and no ibuf operations are allowed; this will be set if +recv_sys.pages becomes too full, and log records must be merged to file pages already before the recovery is finished: in this case no ibuf operations are allowed, as they could modify the pages read in the buffer pool before the pages have been recovered to the up-to-date state. diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index a87ce5ec07b..324c6f7447d 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -1442,17 +1442,6 @@ os_aio_wait_until_no_pending_writes(); void os_aio_simulated_wake_handler_threads(); -#ifdef _WIN32 -/** This function can be called if one wants to post a batch of reads and -prefers an i/o-handler thread to handle them all at once later. You must -call os_aio_simulated_wake_handler_threads later to ensure the threads -are not left sleeping! */ -void -os_aio_simulated_put_read_threads_to_sleep(); -#else /* _WIN32 */ -# define os_aio_simulated_put_read_threads_to_sleep() -#endif /* _WIN32 */ - /** This is the generic AIO handler interface function. Waits for an aio operation to complete. This function is used to wait the for completed requests. The AIO array of pending requests is divided @@ -1518,15 +1507,6 @@ os_file_get_status( bool check_rw_perm, bool read_only); -/** Creates a temporary file in the location specified by the parameter -path. If the path is NULL then it will be created on --tmpdir location. -This function is defined in ha_innodb.cc. -@param[in] path location for creating temporary file -@return temporary file descriptor, or < 0 on error */ -os_file_t -innobase_mysql_tmpfile( - const char* path); - /** Set the file create umask @param[in] umask The umask to use for file creation. */ void diff --git a/storage/innobase/include/page0cur.h b/storage/innobase/include/page0cur.h index f21506d0475..d9c4261f367 100644 --- a/storage/innobase/include/page0cur.h +++ b/storage/innobase/include/page0cur.h @@ -73,6 +73,7 @@ page_cur_get_rec( # define page_cur_get_page_zip(cur) buf_block_get_page_zip((cur)->block) # define page_cur_get_rec(cur) (cur)->rec #endif /* UNIV_DEBUG */ +# define is_page_cur_get_page_zip(cur) is_buf_block_get_page_zip((cur)->block) /*********************************************************//** Sets the cursor object to point before the first user record on the page. */ diff --git a/storage/innobase/include/page0cur.ic b/storage/innobase/include/page0cur.ic index 531d6b6f777..c94b1791954 100644 --- a/storage/innobase/include/page0cur.ic +++ b/storage/innobase/include/page0cur.ic @@ -277,7 +277,7 @@ page_cur_tuple_insert( ULINT_UNDEFINED, heap); ut_ad(size == rec_offs_size(*offsets)); - if (buf_block_get_page_zip(cursor->block)) { + if (is_buf_block_get_page_zip(cursor->block)) { rec = page_cur_insert_rec_zip( cursor, index, rec, *offsets, mtr); } else { @@ -311,7 +311,7 @@ page_cur_rec_insert( ulint* offsets,/*!< in/out: rec_get_offsets(rec, index) */ mtr_t* mtr) /*!< in: mini-transaction handle, or NULL */ { - if (buf_block_get_page_zip(cursor->block)) { + if (is_buf_block_get_page_zip(cursor->block)) { return(page_cur_insert_rec_zip( cursor, index, rec, offsets, mtr)); } else { diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index 6b9c0c3d5ba..3055c039820 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -128,17 +128,12 @@ page_zip_set_alloc( void* stream, /*!< in/out: zlib stream */ mem_heap_t* heap); /*!< in: memory heap to use */ -/**********************************************************************//** -Compress a page. -@return TRUE on success, FALSE on failure; page_zip will be left -intact on failure. */ -ibool +/** Attempt to compress a ROW_FORMAT=COMPRESSED page. +@retval true on success +@retval false on failure; block->page.zip will be left intact. */ +bool page_zip_compress( -/*==============*/ - page_zip_des_t* page_zip, /*!< in: size; out: data, - n_blobs, m_start, m_end, - m_nonempty */ - const page_t* page, /*!< in: uncompressed page */ + buf_block_t* block, /*!< in/out: buffer block */ dict_index_t* index, /*!< in: index of the B-tree node */ ulint level, /*!< in: commpression level */ @@ -461,11 +456,7 @@ related to the storage of records. Also copy PAGE_MAX_TRX_ID. NOTE: The caller must update the lock table and the adaptive hash index. */ void page_zip_copy_recs( -/*===============*/ - page_zip_des_t* page_zip, /*!< out: copy of src_zip - (n_blobs, m_start, m_end, - m_nonempty, data[0..size-1]) */ - page_t* page, /*!< out: copy of src */ + buf_block_t* block, /*!< in/out: buffer block */ const page_zip_des_t* src_zip, /*!< in: compressed page */ const page_t* src, /*!< in: page */ dict_index_t* index, /*!< in: index of the B-tree */ @@ -511,19 +502,6 @@ page_zip_compress_write_log_no_data( const page_t* page, /*!< in: page that is compressed */ dict_index_t* index, /*!< in: index */ mtr_t* mtr); /*!< in: mtr */ -/**********************************************************************//** -Parses a log record of compressing an index page without the data. -@return end of log record or NULL */ -UNIV_INLINE -byte* -page_zip_parse_compress_no_data( -/*============================*/ - byte* ptr, /*!< in: buffer */ - byte* end_ptr, /*!< in: buffer end */ - page_t* page, /*!< in: uncompressed page */ - page_zip_des_t* page_zip, /*!< out: compressed page */ - dict_index_t* index) /*!< in: index */ - MY_ATTRIBUTE((nonnull(1,2))); /**********************************************************************//** Reset the counters used for filling diff --git a/storage/innobase/include/page0zip.ic b/storage/innobase/include/page0zip.ic index 5e3a1797b2a..8df7078594e 100644 --- a/storage/innobase/include/page0zip.ic +++ b/storage/innobase/include/page0zip.ic @@ -380,38 +380,6 @@ page_zip_compress_write_log_no_data( } /**********************************************************************//** -Parses a log record of compressing an index page without the data. -@return end of log record or NULL */ -UNIV_INLINE -byte* -page_zip_parse_compress_no_data( -/*============================*/ - byte* ptr, /*!< in: buffer */ - byte* end_ptr, /*!< in: buffer end */ - page_t* page, /*!< in: uncompressed page */ - page_zip_des_t* page_zip, /*!< out: compressed page */ - dict_index_t* index) /*!< in: index */ -{ - ulint level; - if (end_ptr == ptr) { - return(NULL); - } - - level = mach_read_from_1(ptr); - - /* If page compression fails then there must be something wrong - because a compress log record is logged only if the compression - was successful. Crash in this case. */ - - if (page - && !page_zip_compress(page_zip, page, index, level, NULL)) { - ut_error; - } - - return(ptr + 1); -} - -/**********************************************************************//** Reset the counters used for filling INFORMATION_SCHEMA.innodb_cmp_per_index. */ UNIV_INLINE diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index e5798f1f673..3f4bbcff455 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -271,8 +271,8 @@ row_update_for_mysql( row_prebuilt_t* prebuilt) MY_ATTRIBUTE((warn_unused_result)); -/** This can only be used when srv_locks_unsafe_for_binlog is TRUE or this -session is using a READ COMMITTED or READ UNCOMMITTED isolation level. +/** This can only be used when the current transaction is at +READ COMMITTED or READ UNCOMMITTED isolation level. Before calling this function row_search_for_mysql() must have initialized prebuilt->new_rec_locks to store the information which new record locks really were set. This function removes a newly set @@ -694,8 +694,9 @@ struct row_prebuilt_t { ulint row_read_type; /*!< ROW_READ_WITH_LOCKS if row locks should be the obtained for records under an UPDATE or DELETE cursor. - If innodb_locks_unsafe_for_binlog - is TRUE, this can be set to + At READ UNCOMMITTED or + READ COMMITTED isolation level, + this can be set to ROW_READ_TRY_SEMI_CONSISTENT, so that if the row under an UPDATE or DELETE cursor was locked by another @@ -717,8 +718,7 @@ struct row_prebuilt_t { cases; note that this breaks serializability. */ ulint new_rec_locks; /*!< normally 0; if - srv_locks_unsafe_for_binlog is - TRUE or session is using READ + the session is using READ COMMITTED or READ UNCOMMITTED isolation level, set in row_search_for_mysql() if we set a new diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 851e6081f9c..e972fffa5bf 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -90,6 +90,10 @@ struct srv_stats_t doublewrite buffer */ ulint_ctr_1_t dblwr_pages_written; +#if defined(LINUX_NATIVE_AIO) + ulint_ctr_1_t buffered_aio_submitted; +#endif + /** Store the number of write requests issued */ ulint_ctr_1_t buf_pool_write_requests; @@ -190,6 +194,9 @@ struct srv_stats_t /** Number of temporary tablespace blocks decrypted */ ulint_ctr_64_t n_temp_blocks_decrypted; + + /** Number of lock deadlocks */ + ulint_ctr_1_t lock_deadlock_count; }; extern const char* srv_main_thread_op_info; @@ -260,10 +267,6 @@ extern ulong srv_thread_sleep_delay; /** Maximum sleep delay (in micro-seconds), value of 0 disables it.*/ extern ulong srv_adaptive_max_sleep_delay; -/** Place locks to records only i.e. do not use next-key locking except -on duplicate key checking and foreign key checking */ -extern ibool srv_locks_unsafe_for_binlog; - /** Sort buffer size in index creation */ extern ulong srv_sort_buf_size; /** Maximum modification log file size for online index creation */ @@ -315,9 +318,6 @@ srv_is_undo_tablespace(ulint space_id) + srv_undo_tablespaces_open); } -/** The number of undo segments to use */ -extern ulong srv_undo_logs; - /** Maximum size of undo tablespace. */ extern unsigned long long srv_max_undo_log_size; @@ -527,6 +527,12 @@ extern uint srv_spin_wait_delay; extern ulint srv_truncated_status_writes; /** Number of initialized rollback segments for persistent undo log */ extern ulong srv_available_undo_logs; +/** Iterations of the loop bounded by 'srv_active' label. */ +extern ulint srv_main_active_loops; +/** Iterations of the loop bounded by the 'srv_idle' label. */ +extern ulint srv_main_idle_loops; +/** Log writes involving flush. */ +extern ulint srv_log_writes_and_flush; #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG extern my_bool srv_ibuf_disable_background_merge; @@ -917,14 +923,6 @@ srv_master_thread_disabled_debug_update(THD*, st_mysql_sys_var*, void*, /** Status variables to be passed to MySQL */ struct export_var_t{ - ulint innodb_data_pending_reads; /*!< Pending reads */ - ulint innodb_data_pending_writes; /*!< Pending writes */ - ulint innodb_data_pending_fsyncs; /*!< Pending fsyncs */ - ulint innodb_data_fsyncs; /*!< Number of fsyncs so far */ - ulint innodb_data_read; /*!< Data bytes read */ - ulint innodb_data_writes; /*!< I/O write requests */ - ulint innodb_data_written; /*!< Data bytes written */ - ulint innodb_data_reads; /*!< I/O read requests */ char innodb_buffer_pool_dump_status[OS_FILE_MAX_PATH + 128];/*!< Buf pool dump status */ char innodb_buffer_pool_load_status[OS_FILE_MAX_PATH + 128];/*!< Buf pool load status */ char innodb_buffer_pool_resize_status[512];/*!< Buf pool resize status */ @@ -939,6 +937,9 @@ struct export_var_t{ #ifdef UNIV_DEBUG ulint innodb_buffer_pool_pages_latched; /*!< Latched pages */ #endif /* UNIV_DEBUG */ + ulint innodb_buffer_pool_pages_made_not_young; + ulint innodb_buffer_pool_pages_made_young; + ulint innodb_buffer_pool_pages_old; ulint innodb_buffer_pool_read_requests; /*!< buf_pool->stat.n_page_gets */ ulint innodb_buffer_pool_reads; /*!< srv_buf_pool_reads */ ulint innodb_buffer_pool_wait_free; /*!< srv_buf_pool_wait_free */ @@ -947,17 +948,35 @@ struct export_var_t{ ulint innodb_buffer_pool_read_ahead_rnd;/*!< srv_read_ahead_rnd */ ulint innodb_buffer_pool_read_ahead; /*!< srv_read_ahead */ ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/ + ulint innodb_checkpoint_age; + ulint innodb_checkpoint_max_age; + ulint innodb_data_pending_reads; /*!< Pending reads */ + ulint innodb_data_pending_writes; /*!< Pending writes */ + ulint innodb_data_pending_fsyncs; /*!< Pending fsyncs */ + ulint innodb_data_fsyncs; /*!< Number of fsyncs so far */ + ulint innodb_data_read; /*!< Data bytes read */ + ulint innodb_data_writes; /*!< I/O write requests */ + ulint innodb_data_written; /*!< Data bytes written */ + ulint innodb_data_reads; /*!< I/O read requests */ ulint innodb_dblwr_pages_written; /*!< srv_dblwr_pages_written */ ulint innodb_dblwr_writes; /*!< srv_dblwr_writes */ - ibool innodb_have_atomic_builtins; /*!< HAVE_ATOMIC_BUILTINS */ + ulint innodb_deadlocks; + ulint innodb_history_list_length; ulint innodb_log_waits; /*!< srv_log_waits */ ulint innodb_log_write_requests; /*!< srv_log_write_requests */ ulint innodb_log_writes; /*!< srv_log_writes */ + lsn_t innodb_lsn_current; + lsn_t innodb_lsn_flushed; + lsn_t innodb_lsn_last_checkpoint; + trx_id_t innodb_max_trx_id; +#ifdef BTR_CUR_HASH_ADAPT + ulint innodb_mem_adaptive_hash; +#endif + ulint innodb_mem_dictionary; lsn_t innodb_os_log_written; /*!< srv_os_log_written */ ulint innodb_os_log_fsyncs; /*!< fil_n_log_flushes */ ulint innodb_os_log_pending_writes; /*!< srv_os_log_pending_writes */ ulint innodb_os_log_pending_fsyncs; /*!< fil_n_pending_log_flushes */ - ulint innodb_page_size; /*!< srv_page_size */ ulint innodb_pages_created; /*!< buf_pool->stat.n_pages_created */ ulint innodb_pages_read; /*!< buf_pool->stat.n_pages_read*/ ulint innodb_pages_written; /*!< buf_pool->stat.n_pages_written */ @@ -980,8 +999,7 @@ struct export_var_t{ ulint innodb_system_rows_deleted; /*!< srv_n_system_rows_deleted*/ ulint innodb_num_open_files; /*!< fil_system_t::n_open */ ulint innodb_truncated_status_writes; /*!< srv_truncated_status_writes */ - ulint innodb_available_undo_logs; /*!< srv_available_undo_logs - */ + /** Number of undo tablespace truncation operations */ ulong innodb_undo_truncations; ulint innodb_defragment_compression_failures; /*!< Number of diff --git a/storage/innobase/include/trx0i_s.h b/storage/innobase/include/trx0i_s.h index 65c7d321597..4eab97c0b02 100644 --- a/storage/innobase/include/trx0i_s.h +++ b/storage/innobase/include/trx0i_s.h @@ -45,17 +45,9 @@ i_s_trx_row_t::trx_query */ #define TRX_I_S_TRX_QUERY_MAX_LEN 1024 /** The maximum length of a string that can be stored in -i_s_trx_row_t::trx_operation_state */ -#define TRX_I_S_TRX_OP_STATE_MAX_LEN 64 - -/** The maximum length of a string that can be stored in i_s_trx_row_t::trx_foreign_key_error */ #define TRX_I_S_TRX_FK_ERROR_MAX_LEN 256 -/** The maximum length of a string that can be stored in -i_s_trx_row_t::trx_isolation_level */ -#define TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN 16 - /** Safely copy strings in to the INNODB_TRX table's string based columns */ #define TRX_I_S_STRING_COPY(data, field, constraint, tcache) \ @@ -94,23 +86,21 @@ struct i_s_hash_chain_t { /** This structure represents INFORMATION_SCHEMA.innodb_locks row */ struct i_s_locks_row_t { trx_id_t lock_trx_id; /*!< transaction identifier */ - const char* lock_mode; /*!< lock mode from - lock_get_mode_str() */ - const char* lock_type; /*!< lock type from - lock_get_type_str() */ const char* lock_table; /*!< table name from lock_get_table_name() */ - const char* lock_index; /*!< index name from - lock_rec_get_index_name() */ - /** Information for record locks. All these are - ULINT_UNDEFINED for table locks. */ - /* @{ */ - ulint lock_space; /*!< tablespace identifier */ - ulint lock_page; /*!< page number within the_space */ - ulint lock_rec; /*!< heap number of the record - on the page */ - const char* lock_data; /*!< (some) content of the record */ - /* @} */ + /** index name of a record lock; NULL for table locks */ + const char* lock_index; + /** tablespace identifier of the record; 0 if !lock_index */ + uint32_t lock_space; + /** page number of the record; 0 if !lock_index */ + uint32_t lock_page; + /** heap number of the record; 0 if !lock_index */ + uint16_t lock_rec; + /** lock mode corresponding to lock_mode_values_typelib */ + uint8_t lock_mode; + /** (some) content of the record, if available in the buffer pool; + NULL if !lock_index */ + const char* lock_data; /** The following are auxiliary and not included in the table */ /* @{ */ @@ -154,17 +144,17 @@ struct i_s_trx_row_t { ulint trx_concurrency_tickets; /*!< n_tickets_to_enter_innodb in trx_t */ - const char* trx_isolation_level; - /*!< isolation_level in trx_t */ - ibool trx_unique_checks; + uint trx_isolation_level; + /*!< trx_t::isolation_level */ + bool trx_unique_checks; /*!< check_unique_secondary in trx_t*/ - ibool trx_foreign_key_checks; + bool trx_foreign_key_checks; /*!< check_foreigns in trx_t */ const char* trx_foreign_key_error; /*!< detailed_error in trx_t */ - ulint trx_is_read_only; + bool trx_is_read_only; /*!< trx_t::read_only */ - ulint trx_is_autocommit_non_locking; + bool trx_is_autocommit_non_locking; /*!< trx_is_autocommit_non_locking(trx) */ }; diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 350615eee64..2245168b169 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -868,7 +868,7 @@ public: const char* op_info; /*!< English text describing the current operation, or an empty string */ - ulint isolation_level;/*!< TRX_ISO_REPEATABLE_READ, ... */ + uint isolation_level;/*!< TRX_ISO_REPEATABLE_READ, ... */ bool check_foreigns; /*!< normally TRUE, but if the user wants to suppress foreign key checks, (in table imports, for example) we diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 31380f09d0f..206dbf56257 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -446,8 +446,6 @@ typedef ib_uint64_t lsn_t; /** The 'undefined' value for a ulint */ #define ULINT_UNDEFINED ((ulint)(-1)) -#define ULONG_UNDEFINED ((ulong)(-1)) - /** The 'undefined' value for a ib_uint64_t */ #define UINT64_UNDEFINED ((ib_uint64_t)(-1)) diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 3bf7e33fe4e..9ba3a33f583 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -552,7 +552,7 @@ void lock_sys_t::close() if (!m_initialised) return; if (lock_latest_err_file != NULL) { - fclose(lock_latest_err_file); + my_fclose(lock_latest_err_file, MYF(MY_WME)); lock_latest_err_file = NULL; } @@ -2427,8 +2427,8 @@ lock_rec_inherit_to_gap( ut_ad(lock_mutex_own()); - /* If srv_locks_unsafe_for_binlog is TRUE or session is using - READ COMMITTED isolation level, we do not want locks set + /* At READ UNCOMMITTED or READ COMMITTED isolation level, + we do not want locks set by an UPDATE or a DELETE to be inherited as gap type locks. But we DO want S-locks/X-locks(taken for replace) set by a consistency constraint to be inherited also then. */ @@ -2438,11 +2438,9 @@ lock_rec_inherit_to_gap( lock = lock_rec_get_next(heap_no, lock)) { if (!lock_rec_get_insert_intention(lock) - && !((srv_locks_unsafe_for_binlog - || lock->trx->isolation_level - <= TRX_ISO_READ_COMMITTED) - && lock_get_mode(lock) == - (lock->trx->duplicates ? LOCK_S : LOCK_X))) { + && (lock->trx->isolation_level > TRX_ISO_READ_COMMITTED + || lock_get_mode(lock) != + (lock->trx->duplicates ? LOCK_S : LOCK_X))) { lock_rec_add_to_queue( LOCK_REC | LOCK_GAP | ulint(lock_get_mode(lock)), @@ -5983,71 +5981,6 @@ lock_get_trx_id( } /*******************************************************************//** -Gets the mode of a lock in a human readable string. -The string should not be free()'d or modified. -@return lock mode */ -const char* -lock_get_mode_str( -/*==============*/ - const lock_t* lock) /*!< in: lock */ -{ - ibool is_gap_lock; - - is_gap_lock = lock_get_type_low(lock) == LOCK_REC - && lock_rec_get_gap(lock); - - switch (lock_get_mode(lock)) { - case LOCK_S: - if (is_gap_lock) { - return("S,GAP"); - } else { - return("S"); - } - case LOCK_X: - if (is_gap_lock) { - return("X,GAP"); - } else { - return("X"); - } - case LOCK_IS: - if (is_gap_lock) { - return("IS,GAP"); - } else { - return("IS"); - } - case LOCK_IX: - if (is_gap_lock) { - return("IX,GAP"); - } else { - return("IX"); - } - case LOCK_AUTO_INC: - return("AUTO_INC"); - default: - return("UNKNOWN"); - } -} - -/*******************************************************************//** -Gets the type of a lock in a human readable string. -The string should not be free()'d or modified. -@return lock type */ -const char* -lock_get_type_str( -/*==============*/ - const lock_t* lock) /*!< in: lock */ -{ - switch (lock_get_type_low(lock)) { - case LOCK_REC: - return("RECORD"); - case LOCK_TABLE: - return("TABLE"); - default: - return("UNKNOWN"); - } -} - -/*******************************************************************//** Gets the table on which the lock is. @return table */ UNIV_INLINE @@ -6123,32 +6056,6 @@ lock_rec_get_index_name( return(lock->index->name); } -/*******************************************************************//** -For a record lock, gets the tablespace number on which the lock is. -@return tablespace number */ -ulint -lock_rec_get_space_id( -/*==================*/ - const lock_t* lock) /*!< in: lock */ -{ - ut_a(lock_get_type_low(lock) == LOCK_REC); - - return(lock->un_member.rec_lock.space); -} - -/*******************************************************************//** -For a record lock, gets the page number on which the lock is. -@return page number */ -ulint -lock_rec_get_page_no( -/*=================*/ - const lock_t* lock) /*!< in: lock */ -{ - ut_a(lock_get_type_low(lock) == LOCK_REC); - - return(lock->un_member.rec_lock.page_no); -} - /*********************************************************************//** Cancels a waiting lock request and releases possible other transactions waiting behind it. */ @@ -6932,6 +6839,7 @@ DeadlockChecker::check_and_resolve(const lock_t* lock, trx_t* trx) rollback_print(victim_trx, lock); MONITOR_INC(MONITOR_DEADLOCK); + srv_stats.lock_deadlock_count.inc(); break; @@ -6944,6 +6852,7 @@ DeadlockChecker::check_and_resolve(const lock_t* lock, trx_t* trx) lock_deadlock_found = true; MONITOR_INC(MONITOR_DEADLOCK); + srv_stats.lock_deadlock_count.inc(); } } while (victim_trx != NULL && victim_trx != trx); diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 0e794a865d1..e74cbf8a544 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -83,12 +83,6 @@ reduce the size of the log. /** Redo log system */ log_t log_sys; -/** Whether to generate and require checksums on the redo log pages */ -my_bool innodb_log_checksums; - -/** Pointer to the log checksum calculation function */ -log_checksum_func_t log_checksum_algorithm_ptr; - /* Next log block number to do dummy record filling if no log records written for a while */ static ulint next_lbn_to_pad = 0; @@ -609,6 +603,12 @@ void log_t::files::create(ulint n_files) lsn_offset= LOG_FILE_HDR_SIZE; } +/** Update the log block checksum. */ +inline void log_block_store_checksum(byte* block) +{ + log_block_set_checksum(block, log_block_calc_checksum_crc32(block)); +} + /******************************************************//** Writes a log file header to a log file space. */ static @@ -638,7 +638,7 @@ log_file_header_flush( LOG_HEADER_CREATOR_CURRENT); ut_ad(LOG_HEADER_CREATOR_END - LOG_HEADER_CREATOR >= sizeof LOG_HEADER_CREATOR_CURRENT); - log_block_set_checksum(buf, log_block_calc_checksum_crc32(buf)); + log_block_store_checksum(buf); dest_offset = nth_file * log_sys.log.file_size; @@ -662,19 +662,6 @@ log_file_header_flush( } /******************************************************//** -Stores a 4-byte checksum to the trailer checksum field of a log block -before writing it to a log file. This checksum is used in recovery to -check the consistency of a log block. */ -static -void -log_block_store_checksum( -/*=====================*/ - byte* block) /*!< in/out: pointer to a log block */ -{ - log_block_set_checksum(block, log_block_calc_checksum(block)); -} - -/******************************************************//** Writes a buffer to a log file. */ static void @@ -1252,7 +1239,7 @@ log_group_checkpoint(lsn_t end_lsn) srv_log_buffer_size); mach_write_to_8(buf + LOG_CHECKPOINT_END_LSN, end_lsn); - log_block_set_checksum(buf, log_block_calc_checksum_crc32(buf)); + log_block_store_checksum(buf); MONITOR_INC(MONITOR_PENDING_CHECKPOINT_WRITE); diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 52edbcf238f..9af7dbdbdd9 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -55,15 +55,13 @@ Created 9/20/1997 Heikki Tuuri #include "buf0rea.h" #include "srv0srv.h" #include "srv0start.h" -#include "trx0roll.h" -#include "row0merge.h" /** Log records are stored in the hash table in chunks at most of this size; this must be less than srv_page_size as it is stored in the buffer pool */ #define RECV_DATA_BLOCK_SIZE (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t) - REDZONE_SIZE) /** Read-ahead area in applying log records to file pages */ -#define RECV_READ_AHEAD_AREA 32 +#define RECV_READ_AHEAD_AREA 32U /** The recovery system */ recv_sys_t recv_sys; @@ -117,7 +115,6 @@ the recovery failed and the database may be corrupt. */ static lsn_t recv_max_page_lsn; #ifdef UNIV_PFS_THREAD -mysql_pfs_key_t trx_rollback_clean_thread_key; mysql_pfs_key_t recv_writer_thread_key; #endif /* UNIV_PFS_THREAD */ @@ -181,37 +178,6 @@ typedef std::map< static recv_spaces_t recv_spaces; -/** States of recv_addr_t */ -enum recv_addr_state { - /** not yet processed */ - RECV_NOT_PROCESSED, - /** not processed; the page will be reinitialized */ - RECV_WILL_NOT_READ, - /** page is being read */ - RECV_BEING_READ, - /** log records are being applied on the page */ - RECV_BEING_PROCESSED, - /** log records have been applied on the page */ - RECV_PROCESSED, - /** log records have been discarded because the tablespace - does not exist */ - RECV_DISCARDED -}; - -/** Hashed page file address struct */ -struct recv_addr_t{ - /** recovery state of the page */ - recv_addr_state state; - /** tablespace identifier */ - unsigned space:32; - /** page number */ - unsigned page_no:32; - /** list of log records for this page */ - UT_LIST_BASE_NODE_T(recv_t) rec_list; - /** hash node in the hash bucket chain */ - hash_node_t addr_hash; -}; - /** Report optimized DDL operation (without redo log), corresponding to MLOG_INDEX_LOAD. @param[in] space_id tablespace identifier @@ -253,19 +219,18 @@ private: ut_allocator<std::pair<const page_id_t, init> > > map; /** Map of page initialization operations. - FIXME: Merge this to recv_sys.addr_hash! */ + FIXME: Merge this to recv_sys.pages! */ map inits; public: /** Record that a page will be initialized by the redo log. - @param[in] space tablespace identifier - @param[in] page_no page number + @param[in] page_id page identifier @param[in] lsn log sequence number */ - void add(ulint space, ulint page_no, lsn_t lsn) + void add(const page_id_t page_id, lsn_t lsn) { ut_ad(mutex_own(&recv_sys.mutex)); const init init = { lsn, false }; std::pair<map::iterator, bool> p = inits.insert( - map::value_type(page_id_t(space, page_no), init)); + map::value_type(page_id, init)); ut_ad(!p.first->second.created); if (!p.second && p.first->second.lsn < init.lsn) { p.first->second = init; @@ -340,54 +305,43 @@ public: static mlog_init_t mlog_init; -/** Process a MLOG_CREATE2 record that indicates that a tablespace -is being shrunk in size. -@param[in] space_id tablespace identifier -@param[in] pages trimmed size of the file, in pages -@param[in] lsn log sequence number of the operation */ -static void recv_addr_trim(ulint space_id, unsigned pages, lsn_t lsn) +/** Process a record that indicates that a tablespace is +being shrunk in size. +@param page_id first page identifier that is not in the file +@param lsn log sequence number of the shrink operation */ +inline void recv_sys_t::trim(const page_id_t page_id, lsn_t lsn) { - DBUG_ENTER("recv_addr_trim"); + DBUG_ENTER("recv_sys_t::trim"); DBUG_LOG("ib_log", "discarding log beyond end of tablespace " - << page_id_t(space_id, pages) << " before LSN " << lsn); - ut_ad(mutex_own(&recv_sys.mutex)); - for (ulint i = recv_sys.addr_hash->n_cells; i--; ) { - hash_cell_t* const cell = hash_get_nth_cell( - recv_sys.addr_hash, i); - for (recv_addr_t* addr = static_cast<recv_addr_t*>(cell->node), - *next; - addr; addr = next) { - next = static_cast<recv_addr_t*>(addr->addr_hash); - - if (addr->space != space_id || addr->page_no < pages) { - continue; + << page_id << " before LSN " << lsn); + ut_ad(mutex_own(&mutex)); + for (recv_sys_t::map::iterator p = pages.lower_bound(page_id); + p != pages.end() && p->first.space() == page_id.space();) { + for (recv_t** prev = &p->second.log;;) { + if (!*prev || (*prev)->start_lsn >= lsn) { + break; } + DBUG_LOG("ib_log", "Discarding " + << get_mlog_string((*prev)->type) + << " for " << p->first << " at " + << (*prev)->start_lsn); + *prev = (*prev)->next; + } - for (recv_t* recv = UT_LIST_GET_FIRST(addr->rec_list); - recv; ) { - recv_t* n = UT_LIST_GET_NEXT(rec_list, recv); - if (recv->start_lsn < lsn) { - DBUG_PRINT("ib_log", - ("Discarding %s for" - " page %u:%u at " LSN_PF, - get_mlog_string( - recv->type), - addr->space, addr->page_no, - recv->start_lsn)); - UT_LIST_REMOVE(addr->rec_list, recv); - } - recv = n; - } + recv_sys_t::map::iterator r = p++; + + if (!r->second.log) { + pages.erase(r); } } - if (fil_space_t* space = fil_space_get(space_id)) { + if (fil_space_t* space = fil_space_get(page_id.space())) { ut_ad(UT_LIST_GET_LEN(space->chain) == 1); fil_node_t* file = UT_LIST_GET_FIRST(space->chain); ut_ad(file->is_open()); os_file_truncate(file->name, file->handle, - os_offset_t(pages) << srv_page_size_shift, - true); + os_offset_t{page_id.page_no()} + << srv_page_size_shift, true); } DBUG_VOID_RETURN; } @@ -714,11 +668,7 @@ void recv_sys_t::close() if (is_initialised()) { dblwr.pages.clear(); - - if (addr_hash) { - hash_table_free(addr_hash); - addr_hash = NULL; - } + pages.clear(); if (heap) { mem_heap_free(heap); @@ -862,8 +812,6 @@ void recv_sys_t::create() found_corrupt_fs = false; mlog_checkpoint_lsn = 0; - addr_hash = hash_create(size / 512); - n_addrs = 0; progress_time = time(NULL); recv_max_page_lsn = 0; @@ -875,12 +823,8 @@ void recv_sys_t::create() inline void recv_sys_t::empty() { ut_ad(mutex_own(&mutex)); - ut_a(n_addrs == 0); - - hash_table_free(addr_hash); + pages.clear(); mem_heap_empty(heap); - - addr_hash = hash_create(buf_pool_get_curr_size() / 512); } /** Free most recovery data structures. */ @@ -890,13 +834,12 @@ void recv_sys_t::debug_free() ut_ad(is_initialised()); mutex_enter(&mutex); - hash_table_free(addr_hash); + pages.clear(); mem_heap_free(heap); ut_free_dodump(buf, buf_size); buf = NULL; heap = NULL; - addr_hash = NULL; /* wake page cleaner up to progress */ if (!srv_read_only_mode) { @@ -968,33 +911,31 @@ fail: break; } - if (innodb_log_checksums || is_encrypted()) { - ulint crc = log_block_calc_checksum_crc32(buf); - ulint cksum = log_block_get_checksum(buf); - - DBUG_EXECUTE_IF("log_intermittent_checksum_mismatch", { - static int block_counter; - if (block_counter++ == 0) { - cksum = crc + 1; - } - }); - - if (crc != cksum) { - ib::error() << "Invalid log block checksum." - << " block: " << block_number - << " checkpoint no: " - << log_block_get_checkpoint_no(buf) - << " expected: " << crc - << " found: " << cksum; - goto fail; - } + ulint crc = log_block_calc_checksum_crc32(buf); + ulint cksum = log_block_get_checksum(buf); - if (is_encrypted() - && !log_crypt(buf, *start_lsn, - OS_FILE_LOG_BLOCK_SIZE, - LOG_DECRYPT)) { - goto fail; - } + DBUG_EXECUTE_IF("log_intermittent_checksum_mismatch", { + static int block_counter; + if (block_counter++ == 0) { + cksum = crc + 1; + } + }); + + if (crc != cksum) { + ib::error() << "Invalid log block checksum." + << " block: " << block_number + << " checkpoint no: " + << log_block_get_checkpoint_no(buf) + << " expected: " << crc + << " found: " << cksum; + goto fail; + } + + if (is_encrypted() + && !log_crypt(buf, *start_lsn, + OS_FILE_LOG_BLOCK_SIZE, + LOG_DECRYPT)) { + goto fail; } ulint dl = log_block_get_data_len(buf); @@ -1721,8 +1662,15 @@ parse_log: ut_a(!page || ((ibool)!!page_is_comp(page) == dict_table_is_comp(index->table))); - ptr = page_zip_parse_compress_no_data( - ptr, end_ptr, page, page_zip, index); + if (end_ptr == ptr) { + ptr = NULL; + break; + } + if (page && + !page_zip_compress(block, index, *ptr, NULL)) { + ut_error; + } + ptr++; } break; case MLOG_ZIP_WRITE_TRX_ID: @@ -1757,74 +1705,14 @@ parse_log: return(ptr); } -/*********************************************************************//** -Calculates the fold value of a page file address: used in inserting or -searching for a log record in the hash table. -@return folded value */ -UNIV_INLINE -ulint -recv_fold( -/*======*/ - ulint space, /*!< in: space */ - ulint page_no)/*!< in: page number */ -{ - return(ut_fold_ulint_pair(space, page_no)); -} - -/*********************************************************************//** -Calculates the hash value of a page file address: used in inserting or -searching for a log record in the hash table. -@return folded value */ -UNIV_INLINE -ulint -recv_hash( -/*======*/ - ulint space, /*!< in: space */ - ulint page_no)/*!< in: page number */ -{ - return(hash_calc_hash(recv_fold(space, page_no), recv_sys.addr_hash)); -} - -/*********************************************************************//** -Gets the hashed file address struct for a page. -@return file address struct, NULL if not found from the hash table */ -static -recv_addr_t* -recv_get_fil_addr_struct( -/*=====================*/ - ulint space, /*!< in: space id */ - ulint page_no)/*!< in: page number */ -{ - ut_ad(mutex_own(&recv_sys.mutex)); - - recv_addr_t* recv_addr; - - for (recv_addr = static_cast<recv_addr_t*>( - HASH_GET_FIRST(recv_sys.addr_hash, - recv_hash(space, page_no))); - recv_addr != 0; - recv_addr = static_cast<recv_addr_t*>( - HASH_GET_NEXT(addr_hash, recv_addr))) { - - if (recv_addr->space == space - && recv_addr->page_no == page_no) { - - return(recv_addr); - } - } - - return(NULL); -} - /** Store a redo log record for applying. @param type record type -@param space tablespace identifier -@param page_no page number +@param page_id page identifier @param body record body @param rec_end end of record @param lsn start LSN of the mini-transaction @param end_lsn end LSN of the mini-transaction */ -inline void recv_sys_t::add(mlog_id_t type, ulint space, ulint page_no, +inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id, byte* body, byte* rec_end, lsn_t lsn, lsn_t end_lsn) { @@ -1837,46 +1725,33 @@ inline void recv_sys_t::add(mlog_id_t type, ulint space, ulint page_no, ut_ad(type != MLOG_INDEX_LOAD); ut_ad(type != MLOG_TRUNCATE); - recv_t* recv= static_cast<recv_t*>(mem_heap_alloc(heap, sizeof *recv)); - - recv->type = type; - recv->len = ulint(rec_end - body); - recv->start_lsn = lsn; - recv->end_lsn = end_lsn; - - recv_addr_t* recv_addr = recv_get_fil_addr_struct(space, page_no); - - if (recv_addr == NULL) { - recv_addr = static_cast<recv_addr_t*>( - mem_heap_alloc(heap, sizeof(recv_addr_t))); - - recv_addr->space = space; - recv_addr->page_no = page_no; - recv_addr->state = RECV_NOT_PROCESSED; - - UT_LIST_INIT(recv_addr->rec_list, &recv_t::rec_list); - - HASH_INSERT(recv_addr_t, addr_hash, addr_hash, - recv_fold(space, page_no), recv_addr); - n_addrs++; - } + std::pair<map::iterator, bool> p = pages.insert( + map::value_type(page_id, recs_t{recs_t::RECV_NOT_PROCESSED, + NULL, NULL})); + recv_sys_t::recs_t& recs = p.first->second; + ut_ad(p.second == !recs.log); + ut_ad(p.second == !recs.last); + recv_data_t** prev_field; switch (type) { case MLOG_INIT_FILE_PAGE2: case MLOG_ZIP_PAGE_COMPRESS: case MLOG_INIT_FREE_PAGE: /* Ignore any earlier redo log records for this page. */ - ut_ad(recv_addr->state == RECV_NOT_PROCESSED - || recv_addr->state == RECV_WILL_NOT_READ); - recv_addr->state = RECV_WILL_NOT_READ; - mlog_init.add(space, page_no, lsn); + ut_ad(recs.state == recs_t::RECV_NOT_PROCESSED + || recs.state == recs_t::RECV_WILL_NOT_READ); + recs.state = recs_t::RECV_WILL_NOT_READ; + mlog_init.add(page_id, lsn); + recs.last = NULL; + /* fall through */ default: - break; - } + recv_t** prev = recs.last ? &recs.last->next : &recs.log; - UT_LIST_ADD_LAST(recv_addr->rec_list, recv); - - recv_data_t** prev_field = &recv->data; + *prev = recs.last = new (mem_heap_alloc(heap, sizeof(recv_t))) + recv_t{NULL, uint32_t(rec_end - body), type, NULL, + lsn, end_lsn}; + prev_field = &(*prev)->data; + } /* Store the log record body in chunks of less than srv_page_size: heap grows into the buffer pool, and bigger chunks could not @@ -1911,39 +1786,31 @@ void recv_data_copy_to_buf( /*==================*/ byte* buf, /*!< in: buffer of length at least recv->len */ - recv_t* recv) /*!< in: log record */ + const recv_t& recv) /*!< in: log record */ { - recv_data_t* recv_data; - ulint part_len; - ulint len; - - len = recv->len; - recv_data = recv->data; - - while (len > 0) { - if (len > RECV_DATA_BLOCK_SIZE) { - part_len = RECV_DATA_BLOCK_SIZE; - } else { - part_len = len; - } + const recv_data_t* recv_data = recv.data; + ulint len = recv.len; - ut_memcpy(buf, ((byte*) recv_data) + sizeof(recv_data_t), - part_len); + do { + const ulint part_len = std::min<ulint>(len, + RECV_DATA_BLOCK_SIZE); + memcpy(buf, &reinterpret_cast<const byte*>(recv_data)[ + sizeof(recv_data_t)], + part_len); + recv_data = recv_data->next; buf += part_len; len -= part_len; - - recv_data = recv_data->next; - } + } while (len); } /** Apply the hashed log records to the page, if the page lsn is less than the lsn of a log record. @param[in,out] block buffer pool page @param[in,out] mtr mini-transaction -@param[in,out] recv_addr recovery address +@param[in,out] p recovery address @param[in,out] init page initialization operation, or NULL */ static void recv_recover_page(buf_block_t* block, mtr_t& mtr, - recv_addr_t* recv_addr, + const recv_sys_t::map::iterator& p, mlog_init_t::init* init = NULL) { page_t* page; @@ -1952,19 +1819,18 @@ static void recv_recover_page(buf_block_t* block, mtr_t& mtr, ut_ad(mutex_own(&recv_sys.mutex)); ut_ad(recv_sys.apply_log_recs); ut_ad(recv_needed_recovery); - ut_ad(recv_addr->state != RECV_BEING_PROCESSED); - ut_ad(recv_addr->state != RECV_PROCESSED); ut_ad(!init || init->created); ut_ad(!init || init->lsn); + ut_ad(block->page.id == p->first); + ut_ad(p->second.state != recv_sys_t::recs_t::RECV_BEING_PROCESSED); if (UNIV_UNLIKELY(srv_print_verbose_log == 2)) { - fprintf(stderr, "Applying log to page %u:%u\n", - recv_addr->space, recv_addr->page_no); + ib::info() << "Applying log to page " << block->page.id; } DBUG_LOG("ib_log", "Applying log to page " << block->page.id); - recv_addr->state = RECV_BEING_PROCESSED; + p->second.state = recv_sys_t::recs_t::RECV_BEING_PROCESSED; mutex_exit(&recv_sys.mutex); page = block->frame; @@ -1979,11 +1845,15 @@ static void recv_recover_page(buf_block_t* block, mtr_t& mtr, bool free_page = false; lsn_t start_lsn = 0, end_lsn = 0; + ut_d(lsn_t recv_start_lsn = 0); const lsn_t init_lsn = init ? init->lsn : 0; - for (recv_t* recv = UT_LIST_GET_FIRST(recv_addr->rec_list); - recv; recv = UT_LIST_GET_NEXT(rec_list, recv)) { + for (const recv_t* recv = p->second.log; recv; recv = recv->next) { ut_ad(recv->start_lsn); + ut_ad(recv->end_lsn); + ut_ad(recv_start_lsn < recv->start_lsn); + ut_d(recv_start_lsn = recv->start_lsn); + ut_ad(end_lsn <= recv->end_lsn); end_lsn = recv->end_lsn; ut_ad(end_lsn <= log_sys.log.scanned_lsn); @@ -2008,10 +1878,10 @@ static void recv_recover_page(buf_block_t* block, mtr_t& mtr, } if (UNIV_UNLIKELY(srv_print_verbose_log == 2)) { - fprintf(stderr, "apply " LSN_PF ":" - " %d len " ULINTPF " page %u:%u\n", - recv->start_lsn, recv->type, recv->len, - recv_addr->space, recv_addr->page_no); + ib::info() << "apply " << recv->start_lsn + << ":" << recv->type + << " len " << recv->len + << " page " << block->page.id; } DBUG_LOG("ib_log", "apply " << recv->start_lsn << ": " @@ -2026,7 +1896,7 @@ static void recv_recover_page(buf_block_t* block, mtr_t& mtr, a separate buffer */ buf = static_cast<byte*> (ut_malloc_nokey(recv->len)); - recv_data_copy_to_buf(buf, recv); + recv_data_copy_to_buf(buf, *recv); } else { buf = reinterpret_cast<byte*>(recv->data) + sizeof *recv->data; @@ -2087,42 +1957,25 @@ static void recv_recover_page(buf_block_t* block, mtr_t& mtr, recv_max_page_lsn = page_lsn; } - ut_ad(recv_addr->state == RECV_BEING_PROCESSED); - recv_addr->state = RECV_PROCESSED; + ut_ad(p->second.state == recv_sys_t::recs_t::RECV_BEING_PROCESSED); + ut_ad(!recv_sys.pages.empty()); + recv_sys.pages.erase(p); - ut_a(recv_sys.n_addrs > 0); - if (ulint n = --recv_sys.n_addrs) { - if (recv_sys.report(now)) { - ib::info() << "To recover: " << n << " pages from log"; - service_manager_extend_timeout( - INNODB_EXTEND_TIMEOUT_INTERVAL, "To recover: " ULINTPF " pages from log", n); - } + if (recv_sys.report(now)) { + const ulint n = recv_sys.pages.size(); + ib::info() << "To recover: " << n << " pages from log"; + service_manager_extend_timeout( + INNODB_EXTEND_TIMEOUT_INTERVAL, "To recover: " ULINTPF " pages from log", n); } } -/** Reduces recv_sys.n_addrs for the corrupted page. +/** Remove records for a corrupted page. This function should called when srv_force_recovery > 0. @param[in] page_id page id of the corrupted page */ void recv_recover_corrupt_page(page_id_t page_id) { - ut_ad(srv_force_recovery); mutex_enter(&recv_sys.mutex); - - if (!recv_sys.apply_log_recs) { - mutex_exit(&recv_sys.mutex); - return; - } - - recv_addr_t* recv_addr = recv_get_fil_addr_struct( - page_id.space(), page_id.page_no()); - - ut_ad(recv_addr->state != RECV_WILL_NOT_READ); - - if (recv_addr->state != RECV_BEING_PROCESSED - && recv_addr->state != RECV_PROCESSED) { - recv_sys.n_addrs--; - } - + recv_sys.pages.erase(page_id); mutex_exit(&recv_sys.mutex); } @@ -2149,15 +2002,12 @@ void recv_recover_page(buf_page_t* bpage) ut_a(success); mutex_enter(&recv_sys.mutex); - if (!recv_sys.apply_log_recs) { - } else if (recv_addr_t* recv_addr = recv_get_fil_addr_struct( - bpage->id.space(), bpage->id.page_no())) { - switch (recv_addr->state) { - case RECV_BEING_PROCESSED: - case RECV_PROCESSED: - break; - default: - recv_recover_page(block, mtr, recv_addr); + if (recv_sys.apply_log_recs) { + recv_sys_t::map::iterator p = recv_sys.pages.find(bpage->id); + if (p != recv_sys.pages.end() + && p->second.state + != recv_sys_t::recs_t::RECV_BEING_PROCESSED) { + recv_recover_page(block, mtr, p); goto func_exit; } } @@ -2171,32 +2021,35 @@ func_exit: /** Reads in pages which have hashed log records, from an area around a given page number. @param[in] page_id page id */ -static void recv_read_in_area(const page_id_t page_id) +static void recv_read_in_area(page_id_t page_id) { ulint page_nos[RECV_READ_AHEAD_AREA]; - ulint page_no = page_id.page_no() - - (page_id.page_no() % RECV_READ_AHEAD_AREA); + compile_time_assert(ut_is_2pow(RECV_READ_AHEAD_AREA)); + page_id.set_page_no(ut_2pow_round(page_id.page_no(), + RECV_READ_AHEAD_AREA)); + const ulint up_limit = page_id.page_no() + RECV_READ_AHEAD_AREA; ulint* p = page_nos; - for (const ulint up_limit = page_no + RECV_READ_AHEAD_AREA; - page_no < up_limit; page_no++) { - recv_addr_t* recv_addr = recv_get_fil_addr_struct( - page_id.space(), page_no); - if (recv_addr - && recv_addr->state == RECV_NOT_PROCESSED - && !buf_page_peek(page_id_t(page_id.space(), page_no))) { - recv_addr->state = RECV_BEING_READ; - *p++ = page_no; + for (recv_sys_t::map::iterator i= recv_sys.pages.lower_bound(page_id); + i != recv_sys.pages.end() + && i->first.space() == page_id.space() + && i->first.page_no() < up_limit; i++) { + if (i->second.state == recv_sys_t::recs_t::RECV_NOT_PROCESSED + && !buf_page_peek(i->first)) { + i->second.state = recv_sys_t::recs_t::RECV_BEING_READ; + *p++ = i->first.page_no(); } } - mutex_exit(&recv_sys.mutex); - buf_read_recv_pages(FALSE, page_id.space(), page_nos, - ulint(p - page_nos)); - mutex_enter(&recv_sys.mutex); + if (p != page_nos) { + mutex_exit(&recv_sys.mutex); + buf_read_recv_pages(FALSE, page_id.space(), page_nos, + ulint(p - page_nos)); + mutex_enter(&recv_sys.mutex); + } } -/** Apply the hash table of stored log records to persistent data pages. +/** Apply recv_sys.pages to persistent data pages. @param[in] last_batch whether the change buffer merge will be performed as part of the operation */ void recv_apply_hashed_log_recs(bool last_batch) @@ -2227,163 +2080,152 @@ void recv_apply_hashed_log_recs(bool last_batch) ut_d(recv_no_log_write = recv_no_ibuf_operations); - if (ulint n = recv_sys.n_addrs) { - if (!log_sys.log.subformat && !srv_force_recovery - && srv_undo_tablespaces_open) { - ib::error() << "Recovery of separately logged" - " TRUNCATE operations is no longer supported." - " Set innodb_force_recovery=1" - " if no *trunc.log files exist"; - recv_sys.found_corrupt_log = true; - mutex_exit(&recv_sys.mutex); - return; - } + mtr_t mtr; + + if (recv_sys.pages.empty()) { + goto done; + } + if (!log_sys.log.subformat && !srv_force_recovery + && srv_undo_tablespaces_open) { + ib::error() << "Recovery of separately logged" + " TRUNCATE operations is no longer supported." + " Set innodb_force_recovery=1" + " if no *trunc.log files exist"; + recv_sys.found_corrupt_log = true; + mutex_exit(&recv_sys.mutex); + return; + } else { const char* msg = last_batch ? "Starting final batch to recover " : "Starting a batch to recover "; + const ulint n = recv_sys.pages.size(); ib::info() << msg << n << " pages from redo log."; sd_notifyf(0, "STATUS=%s" ULINTPF " pages from redo log", msg, n); } + recv_sys.apply_log_recs = true; recv_sys.apply_batch_on = true; - for (ulint id = srv_undo_tablespaces_open; id--; ) { - recv_sys_t::trunc& t = recv_sys.truncated_undo_spaces[id]; + for (ulint id = srv_undo_tablespaces_open; id--;) { + const recv_sys_t::trunc& t= recv_sys.truncated_undo_spaces[id]; if (t.lsn) { - recv_addr_trim(id + srv_undo_space_id_start, t.pages, - t.lsn); + recv_sys.trim(page_id_t(id + srv_undo_space_id_start, + t.pages), t.lsn); } } - mtr_t mtr; + for (recv_sys_t::map::iterator p = recv_sys.pages.begin(); + p != recv_sys.pages.end();) { + const page_id_t page_id = p->first; + recv_sys_t::recs_t& recs = p->second; + ut_ad(recs.log); - for (ulint i = 0; i < hash_get_n_cells(recv_sys.addr_hash); i++) { - for (recv_addr_t* recv_addr = static_cast<recv_addr_t*>( - HASH_GET_FIRST(recv_sys.addr_hash, i)); - recv_addr; - recv_addr = static_cast<recv_addr_t*>( - HASH_GET_NEXT(addr_hash, recv_addr))) { - if (!UT_LIST_GET_LEN(recv_addr->rec_list)) { + switch (recs.state) { + case recv_sys_t::recs_t::RECV_BEING_READ: + case recv_sys_t::recs_t::RECV_BEING_PROCESSED: + p++; + continue; + case recv_sys_t::recs_t::RECV_NOT_PROCESSED: + apply: + mtr.start(); + mtr.set_log_mode(MTR_LOG_NONE); + if (buf_block_t* block = buf_page_get_gen( + page_id, 0, RW_X_LATCH, NULL, + BUF_GET_IF_IN_POOL, + __FILE__, __LINE__, &mtr, NULL)) { + buf_block_dbg_add_level( + block, SYNC_NO_ORDER_CHECK); + recv_recover_page(block, mtr, p); + ut_ad(mtr.has_committed()); + } else { + mtr.commit(); + recv_read_in_area(page_id); + } + break; + case recv_sys_t::recs_t::RECV_WILL_NOT_READ: + mlog_init_t::init& i = mlog_init.last(page_id); + const lsn_t end_lsn = recs.last->end_lsn; + if (end_lsn < i.lsn) { + DBUG_LOG("ib_log", "skip log for page " + << page_id + << " LSN " << end_lsn + << " < " << i.lsn); ignore: - ut_a(recv_sys.n_addrs); - recv_sys.n_addrs--; + recv_sys_t::map::iterator r = p++; + recv_sys.pages.erase(r); continue; } - switch (recv_addr->state) { - case RECV_BEING_READ: - case RECV_BEING_PROCESSED: - case RECV_PROCESSED: - continue; - case RECV_DISCARDED: + fil_space_t* space = fil_space_acquire_for_io( + page_id.space()); + if (!space) { goto ignore; - case RECV_NOT_PROCESSED: - case RECV_WILL_NOT_READ: - break; } - const page_id_t page_id(recv_addr->space, - recv_addr->page_no); - - if (recv_addr->state == RECV_NOT_PROCESSED) { -apply: - mtr.start(); - mtr.set_log_mode(MTR_LOG_NONE); - if (buf_block_t* block = buf_page_get_gen( - page_id, 0, RW_X_LATCH, NULL, - BUF_GET_IF_IN_POOL, - __FILE__, __LINE__, &mtr, NULL)) { - buf_block_dbg_add_level( - block, SYNC_NO_ORDER_CHECK); - recv_recover_page(block, mtr, - recv_addr); - ut_ad(mtr.has_committed()); - } else { - mtr.commit(); - recv_read_in_area(page_id); - } - } else { - mlog_init_t::init& i = mlog_init.last(page_id); - const lsn_t end_lsn = UT_LIST_GET_LAST( - recv_addr->rec_list)->end_lsn; - - if (end_lsn < i.lsn) { - DBUG_LOG("ib_log", "skip log for page " - << page_id - << " LSN " << end_lsn - << " < " << i.lsn); -skip: - recv_addr->state = RECV_PROCESSED; - goto ignore; - } - - fil_space_t* space = fil_space_acquire_for_io( - recv_addr->space); - if (!space) { - goto skip; - } - - if (space->enable_lsn) { + if (space->enable_lsn) { do_read: - space->release_for_io(); - recv_addr->state = RECV_NOT_PROCESSED; - goto apply; - } - - /* Determine if a tablespace could be - for an internal table for FULLTEXT INDEX. - For those tables, no MLOG_INDEX_LOAD record - used to be written when redo logging was - disabled. Hence, we cannot optimize - away page reads when crash-upgrading - from MariaDB versions before 10.4, - because all the redo log records for - initializing and modifying the page in - the past could be older than the page - in the data file. - - The check is too broad, causing all - tables whose names start with FTS_ to - skip the optimization. */ - if ((log_sys.log.format - & ~LOG_HEADER_FORMAT_ENCRYPTED) - != LOG_HEADER_FORMAT_10_4 - && strstr(space->name, "/FTS_")) { - goto do_read; - } + space->release_for_io(); + recs.state = recv_sys_t::recs_t:: + RECV_NOT_PROCESSED; + goto apply; + } - mtr.start(); - mtr.set_log_mode(MTR_LOG_NONE); - buf_block_t* block = buf_page_create( - page_id, space->zip_size(), &mtr); - if (recv_addr->state == RECV_PROCESSED) { - /* The page happened to exist - in the buffer pool, or it was - just being read in. Before - buf_page_get_with_no_latch() - returned, all changes must have - been applied to the page already. */ - mtr.commit(); - } else { - i.created = true; - buf_block_dbg_add_level( - block, SYNC_NO_ORDER_CHECK); - mtr.x_latch_at_savepoint(0, block); - recv_recover_page(block, mtr, - recv_addr, &i); - ut_ad(mtr.has_committed()); - } + /* Determine if a tablespace could be + for an internal table for FULLTEXT INDEX. + For those tables, no MLOG_INDEX_LOAD record + used to be written when redo logging was + disabled. Hence, we cannot optimize + away page reads when crash-upgrading + from MariaDB versions before 10.4, + because all the redo log records for + initializing and modifying the page in + the past could be older than the page + in the data file. + + The check is too broad, causing all + tables whose names start with FTS_ to + skip the optimization. */ + if ((log_sys.log.format + & ~LOG_HEADER_FORMAT_ENCRYPTED) + != LOG_HEADER_FORMAT_10_4 + && strstr(space->name, "/FTS_")) { + goto do_read; + } - space->release_for_io(); + mtr.start(); + mtr.set_log_mode(MTR_LOG_NONE); + buf_block_t* block = buf_page_create( + page_id, space->zip_size(), &mtr); + p = recv_sys.pages.find(page_id); + if (p == recv_sys.pages.end()) { + /* The page happened to exist + in the buffer pool, or it was + just being read in. Before + buf_page_get_with_no_latch() + returned, all changes must have + been applied to the page already. */ + mtr.commit(); + } else { + ut_ad(&recs == &p->second); + i.created = true; + buf_block_dbg_add_level( + block, SYNC_NO_ORDER_CHECK); + mtr.x_latch_at_savepoint(0, block); + recv_recover_page(block, mtr, p, &i); + ut_ad(mtr.has_committed()); } + + space->release_for_io(); } + + p = recv_sys.pages.lower_bound(page_id); } /* Wait until all the pages have been processed */ - while (recv_sys.n_addrs != 0) { + while (!recv_sys.pages.empty()) { const bool abort = recv_sys.found_corrupt_log || recv_sys.found_corrupt_fs; @@ -2403,6 +2245,7 @@ do_read: mutex_enter(&(recv_sys.mutex)); } +done: if (!last_batch) { /* Flush all the file pages to disk and invalidate them in the buffer pool */ @@ -2789,7 +2632,7 @@ loop: /* fall through */ case STORE_YES: recv_sys.add( - type, space, page_no, body, + type, page_id_t(space, page_no), body, ptr + len, old_lsn, recv_sys.recovered_lsn); } @@ -2973,7 +2816,8 @@ corrupted_log: /* fall through */ case STORE_YES: recv_sys.add( - type, space, page_no, + type, + page_id_t(space, page_no), body, ptr + len, old_lsn, new_recovered_lsn); @@ -3283,7 +3127,6 @@ recv_group_scan_log_recs( mutex_enter(&recv_sys.mutex); recv_sys.len = 0; recv_sys.recovered_offset = 0; - recv_sys.n_addrs = 0; recv_sys.empty(); srv_start_lsn = *contiguous_lsn; recv_sys.parse_start_lsn = *contiguous_lsn; @@ -3391,35 +3234,32 @@ recv_validate_tablespace(bool rescan, bool& missing_tablespace) { dberr_t err = DB_SUCCESS; - for (ulint h = 0; h < hash_get_n_cells(recv_sys.addr_hash); h++) { - for (recv_addr_t* recv_addr = static_cast<recv_addr_t*>( - HASH_GET_FIRST(recv_sys.addr_hash, h)); - recv_addr != 0; - recv_addr = static_cast<recv_addr_t*>( - HASH_GET_NEXT(addr_hash, recv_addr))) { - - const ulint space = recv_addr->space; - - if (is_predefined_tablespace(space)) { - continue; - } + for (recv_sys_t::map::iterator p = recv_sys.pages.begin(); + p != recv_sys.pages.end();) { + ut_ad(p->second.log); + const ulint space = p->first.space(); + if (is_predefined_tablespace(space)) { +next: + p++; + continue; + } - recv_spaces_t::iterator i = recv_spaces.find(space); - ut_ad(i != recv_spaces.end()); + recv_spaces_t::iterator i = recv_spaces.find(space); + ut_ad(i != recv_spaces.end()); - switch (i->second.status) { - case file_name_t::MISSING: - err = recv_init_missing_space(err, i); - i->second.status = file_name_t::DELETED; - /* fall through */ - case file_name_t::DELETED: - recv_addr->state = RECV_DISCARDED; - /* fall through */ - case file_name_t::NORMAL: - continue; - } - ut_ad(0); + switch (i->second.status) { + case file_name_t::NORMAL: + goto next; + case file_name_t::MISSING: + err = recv_init_missing_space(err, i); + i->second.status = file_name_t::DELETED; + /* fall through */ + case file_name_t::DELETED: + recv_sys_t::map::iterator r = p++; + recv_sys.pages.erase(r); + continue; } + ut_ad(0); } if (err != DB_SUCCESS) { @@ -3572,7 +3412,7 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) const lsn_t end_lsn = mach_read_from_8( buf + LOG_CHECKPOINT_END_LSN); - ut_ad(recv_sys.n_addrs == 0); + ut_ad(recv_sys.pages.empty()); contiguous_lsn = checkpoint_lsn; switch (log_sys.log.format) { case 0: @@ -3595,7 +3435,7 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) /* Look for MLOG_CHECKPOINT. */ recv_group_scan_log_recs(checkpoint_lsn, &contiguous_lsn, false); /* The first scan should not have stored or applied any records. */ - ut_ad(recv_sys.n_addrs == 0); + ut_ad(recv_sys.pages.empty()); ut_ad(!recv_sys.found_corrupt_fs); if (srv_read_only_mode && recv_needed_recovery) { @@ -3745,7 +3585,7 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) } } } else { - ut_ad(!rescan || recv_sys.n_addrs == 0); + ut_ad(!rescan || recv_sys.pages.empty()); } if (log_sys.log.scanned_lsn < checkpoint_lsn @@ -3850,43 +3690,8 @@ recv_recovery_from_checkpoint_finish(void) /* Free up the flush_rbt. */ buf_flush_free_flush_rbt(); -} - -/********************************************************//** -Initiates the rollback of active transactions. */ -void -recv_recovery_rollback_active(void) -/*===============================*/ -{ - ut_ad(!recv_writer_thread_active); - - /* Switch latching order checks on in sync0debug.cc, if - --innodb-sync-debug=true (default) */ + /* Enable innodb_sync_debug checks */ ut_d(sync_check_enable()); - - /* We can't start any (DDL) transactions if UNDO logging - has been disabled, additionally disable ROLLBACK of recovered - user transactions. */ - if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO - && !srv_read_only_mode) { - - /* Drop partially created indexes. */ - row_merge_drop_temp_indexes(); - /* Drop garbage tables. */ - row_mysql_drop_garbage_tables(); - - /* Drop any auxiliary tables that were not dropped when the - parent table was dropped. This can happen if the parent table - was dropped but the server crashed before the auxiliary tables - were dropped. */ - fts_drop_orphaned_tables(); - - /* Rollback the uncommitted transactions which have no user - session */ - - trx_rollback_is_active = true; - os_thread_create(trx_rollback_all_recovered, 0, 0); - } } /** Find a doublewrite copy of a page. diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index ceb6c69aec8..2d04a7cddc9 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -1131,23 +1131,14 @@ os_file_create_tmpfile() { FILE* file = NULL; WAIT_ALLOW_WRITES(); - os_file_t fd = innobase_mysql_tmpfile(NULL); + File fd = mysql_tmpfile("ib"); - if (fd != OS_FILE_CLOSED) { -#ifdef _WIN32 - int crt_fd = _open_osfhandle((intptr_t)HANDLE(fd), 0); - if (crt_fd != -1) { - file = fdopen(crt_fd, "w+b"); - if (!file) { - close(crt_fd); - } - } -#else - file = fdopen(fd, "w+b"); + if (fd >= 0) { + file = my_fdopen(fd, 0, O_RDWR|O_TRUNC|O_CREAT|FILE_BINARY, + MYF(MY_WME)); if (!file) { - close(fd); + my_close(fd, MYF(MY_WME)); } -#endif } if (file == NULL) { @@ -1677,6 +1668,7 @@ LinuxAIOHandler::resubmit(Slot* slot) /* Resubmit an I/O request */ int ret = io_submit(m_array->io_ctx(m_segment), 1, &iocb); + srv_stats.buffered_aio_submitted.inc(); if (ret < -1) { errno = -ret; @@ -2041,6 +2033,7 @@ AIO::linux_dispatch(Slot* slot) io_ctx_index = (slot->pos * m_n_segments) / m_slots.size(); int ret = io_submit(m_aio_ctx[io_ctx_index], 1, &iocb); + srv_stats.buffered_aio_submitted.inc(); /* io_submit() returns number of successfully queued requests or -errno. */ @@ -2145,7 +2138,7 @@ and native aio. bool AIO::is_linux_native_aio_supported() { - int fd; + File fd; io_context_t io_ctx; char name[1000]; @@ -2158,7 +2151,7 @@ AIO::is_linux_native_aio_supported() } else if (!srv_read_only_mode) { /* Now check if tmpdir supports native aio ops. */ - fd = innobase_mysql_tmpfile(NULL); + fd = mysql_tmpfile("ib"); if (fd < 0) { ib::warn() @@ -2185,7 +2178,7 @@ AIO::is_linux_native_aio_supported() strcpy(name + dirnamelen, "ib_logfile0"); - fd = open(name, O_RDONLY | O_CLOEXEC); + fd = my_open(name, O_RDONLY | O_CLOEXEC, MYF(0)); if (fd == -1) { @@ -2223,6 +2216,7 @@ AIO::is_linux_native_aio_supported() } int err = io_submit(io_ctx, 1, &p_iocb); + srv_stats.buffered_aio_submitted.inc(); if (err >= 1) { /* Now collect the submitted IO request. */ @@ -2230,7 +2224,7 @@ AIO::is_linux_native_aio_supported() } ut_free(buf); - close(fd); + my_close(fd, MYF(MY_WME)); switch (err) { case 1: @@ -4699,48 +4693,6 @@ os_file_set_eof( return(SetEndOfFile(h)); } -/** This function can be called if one wants to post a batch of reads and -prefers an i/o-handler thread to handle them all at once later. You must -call os_aio_simulated_wake_handler_threads later to ensure the threads -are not left sleeping! */ -void -os_aio_simulated_put_read_threads_to_sleep() -{ - AIO::simulated_put_read_threads_to_sleep(); -} - -/** This function can be called if one wants to post a batch of reads and -prefers an i/o-handler thread to handle them all at once later. You must -call os_aio_simulated_wake_handler_threads later to ensure the threads -are not left sleeping! */ -void -AIO::simulated_put_read_threads_to_sleep() -{ - /* The idea of putting background IO threads to sleep is only for - Windows when using simulated AIO. Windows XP seems to schedule - background threads too eagerly to allow for coalescing during - readahead requests. */ - - if (srv_use_native_aio) { - /* We do not use simulated AIO: do nothing */ - - return; - } - - os_aio_recommend_sleep_for_read_threads = true; - - for (ulint i = 0; i < os_aio_n_segments; i++) { - AIO* array; - - get_array_and_local_segment(&array, i); - - if (array == s_reads) { - - os_event_reset(os_aio_segment_wait_events[i]); - } - } -} - #endif /* !_WIN32*/ /** Does a syncronous read or write depending upon the type specified @@ -5594,6 +5546,9 @@ AIO::AIO( ulint n, ulint segments) : +#ifdef WIN_ASYNC_IO + m_completion_port(new_completion_port()), +#endif m_slots(n), m_n_segments(segments), m_n_reserved() @@ -5601,9 +5556,6 @@ AIO::AIO( ,m_aio_ctx(), m_events(m_slots.size()) # endif /* LINUX_NATIVE_AIO */ -#ifdef WIN_ASYNC_IO - ,m_completion_port(new_completion_port()) -#endif { ut_a(n > 0); ut_a(m_n_segments > 0); diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index ded90c1c4f8..4fdfafa5d0a 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -1636,8 +1636,8 @@ page_cur_insert_rec_zip( if (!log_compressed) { if (page_zip_compress( - page_zip, page, index, - level, NULL)) { + page_cur_get_block(cursor), + index, level, NULL)) { page_cur_insert_rec_write_log( insert_rec, rec_size, cursor->rec, index, mtr); diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc index 2a345d87686..c4c5d1727ee 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -458,10 +458,9 @@ page_create_zip( handle */ { page_t* page; - page_zip_des_t* page_zip = buf_block_get_page_zip(block); ut_ad(block); - ut_ad(page_zip); + ut_ad(buf_block_get_page_zip(block)); ut_ad(dict_table_is_comp(index->table)); /* PAGE_MAX_TRX_ID or PAGE_ROOT_AUTO_INC are always 0 for @@ -484,7 +483,7 @@ page_create_zip( mach_write_to_2(PAGE_HEADER + PAGE_LEVEL + page, level); mach_write_to_8(PAGE_HEADER + PAGE_MAX_TRX_ID + page, max_trx_id); - if (!page_zip_compress(page_zip, page, index, page_zip_level, mtr)) { + if (!page_zip_compress(block, index, page_zip_level, mtr)) { /* The compression of a newly created page should always succeed. */ ut_error; @@ -705,7 +704,7 @@ page_copy_rec_list_end( if (new_page_zip) { mtr_set_log_mode(mtr, log_mode); - if (!page_zip_compress(new_page_zip, new_page, index, + if (!page_zip_compress(new_block, index, page_zip_level, mtr)) { /* Before trying to reorganize the page, store the number of preceding records on the page. */ @@ -867,7 +866,7 @@ page_copy_rec_list_start( DBUG_EXECUTE_IF("page_copy_rec_list_start_compress_fail", goto zip_reorganize;); - if (!page_zip_compress(new_page_zip, new_page, index, + if (!page_zip_compress(new_block, index, page_zip_level, mtr)) { ulint ret_pos; #ifndef DBUG_OFF diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 243f44ad118..851caddf1da 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -365,16 +365,12 @@ page_zip_dir_get( - PAGE_ZIP_DIR_SLOT_SIZE * (slot + 1))); } -/**********************************************************************//** -Write a log record of compressing an index page. */ -static -void -page_zip_compress_write_log( -/*========================*/ - const page_zip_des_t* page_zip,/*!< in: compressed page */ - const page_t* page, /*!< in: uncompressed page */ - dict_index_t* index, /*!< in: index of the B-tree node */ - mtr_t* mtr) /*!< in: mini-transaction */ +/** Write a MLOG_ZIP_PAGE_COMPRESS record of compressing an index page. +@param[in,out] block ROW_FORMAT=COMPRESSED index page +@param[in] index the index that the block belongs to +@param[in,out] mtr mini-transaction */ +static void page_zip_compress_write_log(buf_block_t* block, + dict_index_t* index, mtr_t* mtr) { byte* log_ptr; ulint trailer_size; @@ -388,6 +384,8 @@ page_zip_compress_write_log( return; } + const page_t* page = block->frame; + const page_zip_des_t* page_zip = &block->page.zip; /* Read the number of user records. */ trailer_size = ulint(page_dir_get_n_heap(page_zip->data)) - PAGE_HEAP_NO_USER_LOW; @@ -406,9 +404,10 @@ page_zip_compress_write_log( compile_time_assert(FIL_PAGE_DATA <= PAGE_DATA); ut_a(page_zip->m_end + trailer_size <= page_zip_get_size(page_zip)); - log_ptr = mlog_write_initial_log_record_fast((page_t*) page, - MLOG_ZIP_PAGE_COMPRESS, - log_ptr, mtr); + log_ptr = mlog_write_initial_log_record_low(MLOG_ZIP_PAGE_COMPRESS, + block->page.id.space(), + block->page.id.page_no(), + log_ptr, mtr); mach_write_to_2(log_ptr, ulint(page_zip->m_end - FIL_PAGE_TYPE)); log_ptr += 2; mach_write_to_2(log_ptr, trailer_size); @@ -425,6 +424,9 @@ page_zip_compress_write_log( /* Write the uncompressed trailer of the compressed page. */ mlog_catenate_string(mtr, page_zip->data + page_zip_get_size(page_zip) - trailer_size, trailer_size); + if (!innodb_log_optimize_ddl) { + block->page.init_on_flush = true; + } } /******************************************************//** @@ -1225,17 +1227,12 @@ page_zip_compress_clust( func_exit: return(err);} -/**********************************************************************//** -Compress a page. -@return TRUE on success, FALSE on failure; page_zip will be left -intact on failure. */ -ibool +/** Attempt to compress a ROW_FORMAT=COMPRESSED page. +@retval true on success +@retval false on failure; block->page.zip will be left intact. */ +bool page_zip_compress( -/*==============*/ - page_zip_des_t* page_zip, /*!< in: size; out: data, - n_blobs, m_start, m_end, - m_nonempty */ - const page_t* page, /*!< in: uncompressed page */ + buf_block_t* block, /*!< in/out: buffer block */ dict_index_t* index, /*!< in: index of the B-tree node */ ulint level, /*!< in: commpression level */ @@ -1268,6 +1265,9 @@ page_zip_compress( my_bool cmp_per_index_enabled; cmp_per_index_enabled = srv_cmp_per_index_enabled; + page_t* page = block->frame; + page_zip_des_t* page_zip = &block->page.zip; + ut_a(page_is_comp(page)); ut_a(fil_page_index_page_check(page)); ut_ad(page_simple_validate_new((page_t*) page)); @@ -1518,7 +1518,7 @@ err_exit: += time_diff; mutex_exit(&page_zip_stat_per_index_mutex); } - return(FALSE); + return false; } err = deflateEnd(&c_stream); @@ -1558,7 +1558,7 @@ err_exit: #endif /* UNIV_ZIP_DEBUG */ if (mtr) { - page_zip_compress_write_log(page_zip, page, index, mtr); + page_zip_compress_write_log(block, index, mtr); } UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); @@ -1589,7 +1589,7 @@ err_exit: dict_index_zip_success(index); } - return(TRUE); + return true; } /**********************************************************************//** @@ -4704,7 +4704,6 @@ page_zip_reorganize( mtr_t* mtr) /*!< in: mini-transaction */ { buf_pool_t* buf_pool = buf_pool_from_block(block); - page_zip_des_t* page_zip = buf_block_get_page_zip(block); page_t* page = buf_block_get_frame(block); buf_block_t* temp_block; page_t* temp_page; @@ -4715,7 +4714,8 @@ page_zip_reorganize( ut_ad(!index->table->is_temporary()); /* Note that page_zip_validate(page_zip, page, index) may fail here. */ UNIV_MEM_ASSERT_RW(page, srv_page_size); - UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); + UNIV_MEM_ASSERT_RW(buf_block_get_page_zip(block)->data, + page_zip_get_size(buf_block_get_page_zip(block))); /* Disable logging */ mtr_log_t log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE); @@ -4755,7 +4755,7 @@ page_zip_reorganize( /* Restore logging. */ mtr_set_log_mode(mtr, log_mode); - if (!page_zip_compress(page_zip, page, index, page_zip_level, mtr)) { + if (!page_zip_compress(block, index, page_zip_level, mtr)) { buf_block_free(temp_block); return(FALSE); } @@ -4773,16 +4773,15 @@ related to the storage of records. Also copy PAGE_MAX_TRX_ID. NOTE: The caller must update the lock table and the adaptive hash index. */ void page_zip_copy_recs( -/*===============*/ - page_zip_des_t* page_zip, /*!< out: copy of src_zip - (n_blobs, m_start, m_end, - m_nonempty, data[0..size-1]) */ - page_t* page, /*!< out: copy of src */ + buf_block_t* block, /*!< in/out: buffer block */ const page_zip_des_t* src_zip, /*!< in: compressed page */ const page_t* src, /*!< in: page */ dict_index_t* index, /*!< in: index of the B-tree */ mtr_t* mtr) /*!< in: mini-transaction */ { + page_t* page = block->frame; + page_zip_des_t* page_zip = &block->page.zip; + ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains_page(mtr, src, MTR_MEMO_PAGE_X_FIX)); ut_ad(!dict_index_is_ibuf(index)); @@ -4858,7 +4857,7 @@ page_zip_copy_recs( #ifdef UNIV_ZIP_DEBUG ut_a(page_zip_validate(page_zip, page, index)); #endif /* UNIV_ZIP_DEBUG */ - page_zip_compress_write_log(page_zip, page, index, mtr); + page_zip_compress_write_log(block, index, mtr); } /** Parse and optionally apply MLOG_ZIP_PAGE_COMPRESS. diff --git a/storage/innobase/pars/lexyy.cc b/storage/innobase/pars/lexyy.cc index e7f3981e0fe..16e7e47069e 100644 --- a/storage/innobase/pars/lexyy.cc +++ b/storage/innobase/pars/lexyy.cc @@ -260,7 +260,7 @@ static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) + : 0) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index e9076bfae50..45a5fee59ec 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1032,12 +1032,12 @@ exit: crypt_block[i], table->space_id); if (error != DB_SUCCESS) { - os_file_close(tmpfd[i]); + row_merge_file_destroy_low(tmpfd[i]); goto func_exit; } total_rec += merge_file[i]->n_rec; - os_file_close(tmpfd[i]); + row_merge_file_destroy_low(tmpfd[i]); } func_exit: diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 3edd39f23b1..fbb5e7543a2 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -4084,6 +4084,9 @@ pfs_os_file_t row_merge_file_create_low( const char* path) { +#ifdef WITH_INNODB_DISALLOW_WRITES + os_event_wait(srv_allow_writes_event); +#endif /* WITH_INNODB_DISALLOW_WRITES */ #ifdef UNIV_PFS_IO /* This temp file open does not go through normal file APIs, add instrumentation to register with @@ -4104,7 +4107,13 @@ row_merge_file_create_low( PSI_FILE_CREATE, path ? name : label, __FILE__, __LINE__); #endif - pfs_os_file_t fd = innobase_mysql_tmpfile(path); + DBUG_ASSERT(strlen(path) + 2 <= FN_REFLEN); + char filename[FN_REFLEN]; + File f = create_temp_file(filename, path, "ib", + O_BINARY | O_SEQUENTIAL, + MYF(MY_WME | MY_TEMPORARY)); + pfs_os_file_t fd = IF_WIN(my_get_osfhandle(f), f); + #ifdef UNIV_PFS_IO register_pfs_file_open_end(locker, fd, (fd == OS_FILE_CLOSED)?NULL:&fd); @@ -4149,7 +4158,9 @@ row_merge_file_destroy_low( const pfs_os_file_t& fd) /*!< in: merge file descriptor */ { if (fd != OS_FILE_CLOSED) { - os_file_close(fd); + int res = mysql_file_close(IF_WIN(my_win_handle2File(fd), fd), + MYF(MY_WME)); + ut_a(res != -1); } } /*********************************************************************//** diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 57886af7447..7e593d1ebec 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1978,8 +1978,8 @@ error: DBUG_RETURN(err); } -/** This can only be used when srv_locks_unsafe_for_binlog is TRUE or this -session is using a READ COMMITTED or READ UNCOMMITTED isolation level. +/** This can only be used when the current transaction is at +READ COMMITTED or READ UNCOMMITTED isolation level. Before calling this function row_search_for_mysql() must have initialized prebuilt->new_rec_locks to store the information which new record locks really were set. This function removes a newly set @@ -2002,17 +2002,8 @@ row_unlock_for_mysql( ut_ad(prebuilt != NULL); ut_ad(trx != NULL); + ut_ad(trx->isolation_level <= TRX_ISO_READ_COMMITTED); - if (UNIV_UNLIKELY - (!srv_locks_unsafe_for_binlog - && trx->isolation_level > TRX_ISO_READ_COMMITTED)) { - - ib::error() << "Calling row_unlock_for_mysql though" - " innodb_locks_unsafe_for_binlog is FALSE and this" - " session is not using READ COMMITTED isolation" - " level."; - return; - } if (dict_index_is_spatial(prebuilt->index)) { return; } diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 6c7a54ece7d..f0f1206ea82 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -963,12 +963,10 @@ row_sel_get_clust_rec( trx = thr_get_trx(thr); - /* If innodb_locks_unsafe_for_binlog option is used - or this session is using READ COMMITTED or lower isolation level + /* At READ UNCOMMITTED or READ COMMITTED isolation level we lock only the record, i.e., next-key locking is not used. */ - if (srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) { + if (trx->isolation_level <= TRX_ISO_READ_COMMITTED) { lock_type = LOCK_REC_NOT_GAP; } else { lock_type = LOCK_ORDINARY; @@ -1738,16 +1736,11 @@ rec_loop: true, ULINT_UNDEFINED, &heap); - /* If innodb_locks_unsafe_for_binlog option is used - or this session is using READ COMMITTED or lower isolation - level, we lock only the record, i.e., next-key - locking is not used. */ - if (srv_locks_unsafe_for_binlog - || trx->isolation_level - <= TRX_ISO_READ_COMMITTED) { - + /* At READ UNCOMMITTED or READ COMMITTED + isolation level, we lock only the record, + i.e., next-key locking is not used. */ + if (trx->isolation_level <= TRX_ISO_READ_COMMITTED) { if (page_rec_is_supremum(next_rec)) { - goto skip_lock; } @@ -1805,12 +1798,10 @@ skip_lock: trx = thr_get_trx(thr); - /* If innodb_locks_unsafe_for_binlog option is used - or this session is using READ COMMITTED or lower isolation level, + /* At READ UNCOMMITTED or READ COMMITTED isolation level, we lock only the record, i.e., next-key locking is not used. */ - if (srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED + if (trx->isolation_level <= TRX_ISO_READ_COMMITTED || dict_index_is_spatial(index)) { if (page_rec_is_supremum(rec)) { @@ -4197,29 +4188,18 @@ row_search_mvcc( const rec_t* result_rec = NULL; const rec_t* clust_rec; Row_sel_get_clust_rec_for_mysql row_sel_get_clust_rec_for_mysql; - dberr_t err = DB_SUCCESS; ibool unique_search = FALSE; ibool mtr_has_extra_clust_latch = FALSE; ibool moves_up = FALSE; - ibool set_also_gap_locks = TRUE; - /* if the query is a plain locking SELECT, and the isolation level - is <= TRX_ISO_READ_COMMITTED, then this is set to FALSE */ - ibool did_semi_consistent_read = FALSE; /* if the returned record was locked and we did a semi-consistent read (fetch the newest committed version), then this is set to TRUE */ ulint next_offs; ibool same_user_rec; - mtr_t mtr; - mem_heap_t* heap = NULL; - ulint offsets_[REC_OFFS_NORMAL_SIZE]; - ulint* offsets = offsets_; ibool table_lock_waited = FALSE; byte* next_buf = 0; bool spatial_search = false; - rec_offs_init(offsets_); - ut_ad(index && pcur && search_tuple); ut_a(prebuilt->magic_n == ROW_PREBUILT_ALLOCATED); ut_a(prebuilt->magic_n2 == ROW_PREBUILT_ALLOCATED); @@ -4253,8 +4233,8 @@ row_search_mvcc( && (prebuilt->read_just_key || prebuilt->m_read_virtual_key); - /* Reset the new record lock info if srv_locks_unsafe_for_binlog - is set or session is using a READ COMMITED isolation level. Then + /* Reset the new record lock info if READ UNCOMMITTED or + READ COMMITED isolation level is used. Then we are able to remove the record locks set here on an individual row. */ prebuilt->new_rec_locks = 0; @@ -4297,20 +4277,18 @@ row_search_mvcc( row_sel_dequeue_cached_row_for_mysql(buf, prebuilt); prebuilt->n_rows_fetched++; - - err = DB_SUCCESS; - goto func_exit; + trx->op_info = ""; + DBUG_RETURN(DB_SUCCESS); } if (prebuilt->fetch_cache_first > 0 && prebuilt->fetch_cache_first < MYSQL_FETCH_CACHE_SIZE) { - +early_not_found: /* The previous returned row was popped from the fetch cache, but the cache was not full at the time of the popping: no more rows can exist in the result set */ - - err = DB_RECORD_NOT_FOUND; - goto func_exit; + trx->op_info = ""; + DBUG_RETURN(DB_RECORD_NOT_FOUND); } prebuilt->n_rows_fetched++; @@ -4354,22 +4332,28 @@ row_search_mvcc( if (UNIV_UNLIKELY(direction != 0 && !prebuilt->used_in_HANDLER)) { - - err = DB_RECORD_NOT_FOUND; - goto func_exit; + goto early_not_found; } } /* We don't support sequencial scan for Rtree index, because it is no meaning to do so. */ - if (dict_index_is_spatial(index) - && !RTREE_SEARCH_MODE(mode)) { - err = DB_END_OF_INDEX; - goto func_exit; + if (dict_index_is_spatial(index) && !RTREE_SEARCH_MODE(mode)) { + trx->op_info = ""; + DBUG_RETURN(DB_END_OF_INDEX); } + /* if the query is a plain locking SELECT, and the isolation level + is <= TRX_ISO_READ_COMMITTED, then this is set to FALSE */ + bool did_semi_consistent_read = false; + mtr_t mtr; mtr.start(); + mem_heap_t* heap = NULL; + ulint offsets_[REC_OFFS_NORMAL_SIZE]; + ulint* offsets = offsets_; + rec_offs_init(offsets_); + #ifdef BTR_CUR_HASH_ADAPT /*-------------------------------------------------------------*/ /* PHASE 2: Try fast adaptive hash index search if possible */ @@ -4399,6 +4383,7 @@ row_search_mvcc( let us try a search shortcut through the hash index. */ + dberr_t err = DB_SUCCESS; switch (row_sel_try_search_shortcut_for_mysql( &rec, prebuilt, &offsets, &heap, &mtr)) { @@ -4418,9 +4403,10 @@ row_search_mvcc( case ICP_OUT_OF_RANGE: case ICP_ABORTED_BY_USER: case ICP_ERROR: - goto shortcut_mismatch; + err = DB_RECORD_NOT_FOUND; + goto shortcut_done; case ICP_MATCH: - goto shortcut_match; + goto shortcut_done; } } @@ -4443,21 +4429,19 @@ row_search_mvcc( break; } - shortcut_match: - mtr.commit(); - - /* NOTE that we do NOT store the cursor - position */ - err = DB_SUCCESS; - goto func_exit; + goto shortcut_done; case SEL_EXHAUSTED: - shortcut_mismatch: + err = DB_RECORD_NOT_FOUND; + shortcut_done: mtr.commit(); + /* NOTE that we do NOT store the cursor position */ - err = DB_RECORD_NOT_FOUND; - goto func_exit; + trx->op_info = ""; + ut_ad(!sync_check_iterate(sync_check())); + ut_ad(!did_semi_consistent_read); + DBUG_RETURN(err); case SEL_RETRY: break; @@ -4495,22 +4479,16 @@ row_search_mvcc( || prebuilt->table->no_rollback() || srv_read_only_mode); - if (trx->isolation_level <= TRX_ISO_READ_COMMITTED - && prebuilt->select_lock_type != LOCK_NONE - && trx->mysql_thd != NULL - && thd_is_select(trx->mysql_thd)) { - /* It is a plain locking SELECT and the isolation - level is low: do not lock gaps */ - - set_also_gap_locks = FALSE; - } + /* Do not lock gaps for plain SELECT + at READ UNCOMMITTED or READ COMMITTED isolation level */ + const bool set_also_gap_locks = + prebuilt->select_lock_type != LOCK_NONE + && (trx->isolation_level > TRX_ISO_READ_COMMITTED + || !thd_is_select(trx->mysql_thd)) #ifdef WITH_WSREP - else if (wsrep_thd_skip_locking(trx->mysql_thd)) { - ut_ad(!strcmp(wsrep_get_sr_table_name(), - prebuilt->table->name.m_name)); - set_also_gap_locks = FALSE; - } + && !wsrep_thd_skip_locking(trx->mysql_thd) #endif /* WITH_WSREP */ + ; /* Note that if the search mode was GE or G, then the cursor naturally moves upward (in fetch next) in alphabetical order, @@ -4531,6 +4509,8 @@ row_search_mvcc( clust_index = dict_table_get_first_index(prebuilt->table); + dberr_t err = DB_SUCCESS; + /* Do some start-of-statement preparations */ if (prebuilt->table->no_rollback()) { @@ -4599,18 +4579,9 @@ wait_table_again: pcur->btr_cur.thr = thr; if (dict_index_is_spatial(index)) { - bool need_pred_lock; - - need_pred_lock = (set_also_gap_locks - && !(srv_locks_unsafe_for_binlog - || trx->isolation_level - <= TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type - != LOCK_NONE); - if (!prebuilt->rtr_info) { prebuilt->rtr_info = rtr_create_rtr_info( - need_pred_lock, true, + set_also_gap_locks, true, btr_pcur_get_btr_cur(pcur), index); prebuilt->rtr_info->search_tuple = search_tuple; prebuilt->rtr_info->search_mode = mode; @@ -4619,7 +4590,7 @@ wait_table_again: } else { rtr_info_reinit_in_cursor( btr_pcur_get_btr_cur(pcur), - index, need_pred_lock); + index, set_also_gap_locks); prebuilt->rtr_info->search_tuple = search_tuple; prebuilt->rtr_info->search_mode = mode; } @@ -4640,11 +4611,8 @@ wait_table_again: ut_ad(page_rec_is_leaf(rec)); if (!moves_up - && !page_rec_is_supremum(rec) && set_also_gap_locks - && !(srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE + && !page_rec_is_supremum(rec) && !dict_index_is_spatial(index)) { /* Try to place a gap lock on the next index record @@ -4724,16 +4692,14 @@ rec_loop: if (page_rec_is_supremum(rec)) { if (set_also_gap_locks - && !(srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE + && trx->isolation_level > TRX_ISO_READ_COMMITTED && !dict_index_is_spatial(index)) { /* Try to place a lock on the index record */ - /* If innodb_locks_unsafe_for_binlog option is used - or this session is using a READ COMMITTED or lower isolation - level we do not lock gaps. Supremum record is really + /* If the transaction isolation level is + READ UNCOMMITTED or READ COMMITTED, + we do not lock gaps. Supremum record is really a gap and therefore we do not set locks there. */ offsets = rec_get_offsets(rec, index, offsets, true, @@ -4872,17 +4838,7 @@ wrong_offs: if (0 != cmp_dtuple_rec(search_tuple, rec, offsets)) { if (set_also_gap_locks - && !(srv_locks_unsafe_for_binlog - || trx->isolation_level - <= TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE && !dict_index_is_spatial(index)) { - - /* Try to place a gap lock on the index - record only if innodb_locks_unsafe_for_binlog - option is not set or this session is not - using a READ COMMITTED or lower isolation level. */ - err = sel_set_rec_lock( pcur, rec, index, offsets, @@ -4917,17 +4873,7 @@ wrong_offs: if (!cmp_dtuple_is_prefix_of_rec(search_tuple, rec, offsets)) { if (set_also_gap_locks - && !(srv_locks_unsafe_for_binlog - || trx->isolation_level - <= TRX_ISO_READ_COMMITTED) - && prebuilt->select_lock_type != LOCK_NONE && !dict_index_is_spatial(index)) { - - /* Try to place a gap lock on the index - record only if innodb_locks_unsafe_for_binlog - option is not set or this session is not - using a READ COMMITTED or lower isolation level. */ - err = sel_set_rec_lock( pcur, rec, index, offsets, @@ -4967,15 +4913,9 @@ wrong_offs: is a non-delete marked record, then it is enough to lock its existence with LOCK_REC_NOT_GAP. */ - /* If innodb_locks_unsafe_for_binlog option is used - or this session is using a READ COMMITED isolation - level we lock only the record, i.e., next-key locking is - not used. */ - ulint lock_type; - if (srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) { + if (trx->isolation_level <= TRX_ISO_READ_COMMITTED) { /* At READ COMMITTED or READ UNCOMMITTED isolation levels, do not lock committed delete-marked records. */ @@ -5056,9 +4996,7 @@ no_gap_lock: switch (err) { const rec_t* old_vers; case DB_SUCCESS_LOCKED_REC: - if (srv_locks_unsafe_for_binlog - || trx->isolation_level - <= TRX_ISO_READ_COMMITTED) { + if (trx->isolation_level <= TRX_ISO_READ_COMMITTED) { /* Note that a record of prebuilt->index was locked. */ prebuilt->new_rec_locks = 1; @@ -5121,7 +5059,7 @@ no_gap_lock: goto next_rec; } - did_semi_consistent_read = TRUE; + did_semi_consistent_read = true; rec = old_vers; break; case DB_RECORD_NOT_FOUND: @@ -5308,9 +5246,7 @@ requires_clust_rec: break; case DB_SUCCESS_LOCKED_REC: ut_a(clust_rec != NULL); - if (srv_locks_unsafe_for_binlog - || trx->isolation_level - <= TRX_ISO_READ_COMMITTED) { + if (trx->isolation_level <= TRX_ISO_READ_COMMITTED) { /* Note that the clustered index record was locked. */ prebuilt->new_rec_locks = 2; @@ -5326,8 +5262,7 @@ requires_clust_rec: /* The record is delete marked: we can skip it */ - if ((srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) + if (trx->isolation_level <= TRX_ISO_READ_COMMITTED && prebuilt->select_lock_type != LOCK_NONE) { /* No need to keep a lock on a delete-marked @@ -5551,7 +5486,7 @@ next_rec: == ROW_READ_DID_SEMI_CONSISTENT)) { prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT; } - did_semi_consistent_read = FALSE; + did_semi_consistent_read = false; prebuilt->new_rec_locks = 0; vrow = NULL; @@ -5650,7 +5585,7 @@ page_read_error: == ROW_READ_DID_SEMI_CONSISTENT)) { prebuilt->row_read_type = ROW_READ_TRY_SEMI_CONSISTENT; } - did_semi_consistent_read = FALSE; + did_semi_consistent_read = false; lock_table_wait: mtr.commit(); @@ -5686,8 +5621,7 @@ lock_table_wait: moves_up, &mtr); } - if ((srv_locks_unsafe_for_binlog - || trx->isolation_level <= TRX_ISO_READ_COMMITTED) + if (trx->isolation_level <= TRX_ISO_READ_COMMITTED && !same_user_rec) { /* Since we were not able to restore the cursor diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index 80beddd7f5e..8d4345d910e 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -1951,35 +1951,35 @@ srv_mon_process_existing_counter( break; case MONITOR_OVLD_IBUF_MERGE_INSERT: - value = ibuf->n_merged_ops[IBUF_OP_INSERT]; + value = ibuf.n_merged_ops[IBUF_OP_INSERT]; break; case MONITOR_OVLD_IBUF_MERGE_DELETE: - value = ibuf->n_merged_ops[IBUF_OP_DELETE_MARK]; + value = ibuf.n_merged_ops[IBUF_OP_DELETE_MARK]; break; case MONITOR_OVLD_IBUF_MERGE_PURGE: - value = ibuf->n_merged_ops[IBUF_OP_DELETE]; + value = ibuf.n_merged_ops[IBUF_OP_DELETE]; break; case MONITOR_OVLD_IBUF_MERGE_DISCARD_INSERT: - value = ibuf->n_discarded_ops[IBUF_OP_INSERT]; + value = ibuf.n_discarded_ops[IBUF_OP_INSERT]; break; case MONITOR_OVLD_IBUF_MERGE_DISCARD_DELETE: - value = ibuf->n_discarded_ops[IBUF_OP_DELETE_MARK]; + value = ibuf.n_discarded_ops[IBUF_OP_DELETE_MARK]; break; case MONITOR_OVLD_IBUF_MERGE_DISCARD_PURGE: - value = ibuf->n_discarded_ops[IBUF_OP_DELETE]; + value = ibuf.n_discarded_ops[IBUF_OP_DELETE]; break; case MONITOR_OVLD_IBUF_MERGES: - value = ibuf->n_merges; + value = ibuf.n_merges; break; case MONITOR_OVLD_IBUF_SIZE: - value = ibuf->size; + value = ibuf.size; break; case MONITOR_OVLD_SERVER_ACTIVITY: diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 6df284b1f15..7557e3ec897 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -117,9 +117,6 @@ segment). It is quite possible that some of the tablespaces doesn't host any of the rollback-segment based on configuration used. */ ulint srv_undo_tablespaces_active; -/* The number of rollback segments to use */ -ulong srv_undo_logs; - /** Rate at which UNDO records should be purged. */ ulong srv_purge_rseg_truncate_frequency; @@ -148,9 +145,6 @@ my_bool srv_file_per_table; is greater than SRV_FORCE_NO_TRX_UNDO. */ my_bool high_level_read_only; -/** Place locks to records only i.e. do not use next-key locking except -on duplicate key checking and foreign key checking */ -ibool srv_locks_unsafe_for_binlog; /** Sort buffer size in index creation */ ulong srv_sort_buf_size; /** Maximum modification log file size for online index creation */ @@ -457,13 +451,13 @@ static ulint srv_main_thread_id; /* The following counts are used by the srv_master_thread. */ /** Iterations of the loop bounded by 'srv_active' label. */ -static ulint srv_main_active_loops; +ulint srv_main_active_loops; /** Iterations of the loop bounded by the 'srv_idle' label. */ -static ulint srv_main_idle_loops; +ulint srv_main_idle_loops; /** Iterations of the loop bounded by the 'srv_shutdown' label. */ static ulint srv_main_shutdown_loops; /** Log writes involving flush. */ -static ulint srv_log_writes_and_flush; +ulint srv_log_writes_and_flush; /* This is only ever touched by the master thread. It records the time when the last flush of log file has happened. The master @@ -1321,7 +1315,7 @@ srv_printf_innodb_monitor( "Total large memory allocated " ULINTPF "\n" "Dictionary memory allocated " ULINTPF "\n", ulint{os_total_large_mem_allocated}, - dict_sys_get_size()); + dict_sys.rough_size()); buf_print_io(file); @@ -1430,6 +1424,27 @@ srv_export_innodb_status(void) btr_scrub_total_stat(&scrub_stat); } +#ifdef BTR_CUR_HASH_ADAPT + ulint mem_adaptive_hash = 0; + ut_ad(btr_search_sys->hash_tables); + for (ulong i = 0; i < btr_ahi_parts; i++) { + hash_table_t* ht = btr_search_sys->hash_tables[i]; + + ut_ad(ht); + ut_ad(ht->heap); + /* Multiple mutexes/heaps are currently never used for adaptive + hash index tables. */ + ut_ad(!ht->n_sync_obj); + ut_ad(!ht->heaps); + + mem_adaptive_hash += mem_heap_get_size(ht->heap) + + ht->n_cells * sizeof(hash_cell_t); + } + export_vars.innodb_mem_adaptive_hash = mem_adaptive_hash; +#endif + + export_vars.innodb_mem_dictionary = dict_sys.rough_size(); + mutex_enter(&srv_innodb_monitor_mutex); export_vars.innodb_data_pending_reads = @@ -1482,6 +1497,18 @@ srv_export_innodb_status(void) export_vars.innodb_buffer_pool_pages_dirty = flush_list_len; + export_vars.innodb_buffer_pool_pages_made_young + = stat.n_pages_made_young; + export_vars.innodb_buffer_pool_pages_made_not_young + = stat.n_pages_not_made_young; + + export_vars.innodb_buffer_pool_pages_old = 0; + + for (ulong i = 0; i < srv_buf_pool_instances; i++) { + export_vars.innodb_buffer_pool_pages_old += + buf_pool_from_array(i)->LRU_old_len; + } + export_vars.innodb_buffer_pool_bytes_dirty = buf_pools_list_size.flush_list_bytes; @@ -1496,13 +1523,8 @@ srv_export_innodb_status(void) export_vars.innodb_buffer_pool_pages_misc = buf_pool_get_n_pages() - LRU_len - free_len; -#ifdef HAVE_ATOMIC_BUILTINS - export_vars.innodb_have_atomic_builtins = 1; -#else - export_vars.innodb_have_atomic_builtins = 0; -#endif - - export_vars.innodb_page_size = srv_page_size; + export_vars.innodb_max_trx_id = trx_sys.get_max_trx_id(); + export_vars.innodb_history_list_length = trx_sys.rseg_history_len; export_vars.innodb_log_waits = srv_stats.log_waits; @@ -1574,7 +1596,6 @@ srv_export_innodb_status(void) export_vars.innodb_truncated_status_writes = srv_truncated_status_writes; - export_vars.innodb_available_undo_logs = srv_available_undo_logs; export_vars.innodb_page_compression_saved = srv_stats.page_compression_saved; export_vars.innodb_index_pages_written = srv_stats.index_pages_written; export_vars.innodb_non_index_pages_written = srv_stats.non_index_pages_written; @@ -1610,37 +1631,49 @@ srv_export_innodb_status(void) srv_stats.n_sec_rec_cluster_reads_avoided; if (!srv_read_only_mode) { - export_vars.innodb_encryption_rotation_pages_read_from_cache = - crypt_stat.pages_read_from_cache; - export_vars.innodb_encryption_rotation_pages_read_from_disk = - crypt_stat.pages_read_from_disk; - export_vars.innodb_encryption_rotation_pages_modified = - crypt_stat.pages_modified; - export_vars.innodb_encryption_rotation_pages_flushed = - crypt_stat.pages_flushed; - export_vars.innodb_encryption_rotation_estimated_iops = - crypt_stat.estimated_iops; - export_vars.innodb_encryption_key_requests = - srv_stats.n_key_requests; - export_vars.innodb_key_rotation_list_length = - srv_stats.key_rotation_list_length; - - export_vars.innodb_scrub_page_reorganizations = - scrub_stat.page_reorganizations; - export_vars.innodb_scrub_page_splits = - scrub_stat.page_splits; - export_vars.innodb_scrub_page_split_failures_underflow = - scrub_stat.page_split_failures_underflow; - export_vars.innodb_scrub_page_split_failures_out_of_filespace = - scrub_stat.page_split_failures_out_of_filespace; - export_vars.innodb_scrub_page_split_failures_missing_index = - scrub_stat.page_split_failures_missing_index; - export_vars.innodb_scrub_page_split_failures_unknown = - scrub_stat.page_split_failures_unknown; - export_vars.innodb_scrub_log = srv_stats.n_log_scrubs; + export_vars.innodb_encryption_rotation_pages_read_from_cache = + crypt_stat.pages_read_from_cache; + export_vars.innodb_encryption_rotation_pages_read_from_disk = + crypt_stat.pages_read_from_disk; + export_vars.innodb_encryption_rotation_pages_modified = + crypt_stat.pages_modified; + export_vars.innodb_encryption_rotation_pages_flushed = + crypt_stat.pages_flushed; + export_vars.innodb_encryption_rotation_estimated_iops = + crypt_stat.estimated_iops; + export_vars.innodb_encryption_key_requests = + srv_stats.n_key_requests; + export_vars.innodb_key_rotation_list_length = + srv_stats.key_rotation_list_length; + + export_vars.innodb_scrub_page_reorganizations = + scrub_stat.page_reorganizations; + export_vars.innodb_scrub_page_splits = + scrub_stat.page_splits; + export_vars.innodb_scrub_page_split_failures_underflow = + scrub_stat.page_split_failures_underflow; + export_vars.innodb_scrub_page_split_failures_out_of_filespace = + scrub_stat.page_split_failures_out_of_filespace; + export_vars.innodb_scrub_page_split_failures_missing_index = + scrub_stat.page_split_failures_missing_index; + export_vars.innodb_scrub_page_split_failures_unknown = + scrub_stat.page_split_failures_unknown; + export_vars.innodb_scrub_log = srv_stats.n_log_scrubs; } mutex_exit(&srv_innodb_monitor_mutex); + + log_mutex_enter(); + + export_vars.innodb_lsn_current = log_sys.lsn; + export_vars.innodb_lsn_flushed = log_sys.flushed_to_disk_lsn; + export_vars.innodb_lsn_last_checkpoint = log_sys.last_checkpoint_lsn; + export_vars.innodb_checkpoint_age = static_cast<ulint>( + log_sys.lsn - log_sys.last_checkpoint_lsn); + export_vars.innodb_checkpoint_max_age = static_cast<ulint>( + log_sys.max_checkpoint_age); + + log_mutex_exit(); } /*********************************************************************//** diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index cc21f3c1fa4..58172bccc84 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1306,7 +1306,6 @@ dberr_t srv_start(bool create_new_db) || srv_operation == SRV_OPERATION_RESTORE || srv_operation == SRV_OPERATION_RESTORE_EXPORT); - if (srv_force_recovery == SRV_FORCE_NO_LOG_REDO) { srv_read_only_mode = true; } @@ -1422,7 +1421,9 @@ dberr_t srv_start(bool create_new_db) fil_path_to_mysql_datadir, os_proc_get_number()); - srv_monitor_file = fopen(srv_monitor_file_name, "w+"); + srv_monitor_file = my_fopen(srv_monitor_file_name, + O_RDWR|O_TRUNC|O_CREAT, + MYF(MY_WME)); if (!srv_monitor_file) { ib::error() << "Unable to create " @@ -2102,10 +2103,39 @@ files_checked: return(srv_init_abort(err)); } } + } + + ut_ad(err == DB_SUCCESS); + ut_a(sum_of_new_sizes != ULINT_UNDEFINED); + + /* Create the doublewrite buffer to a new tablespace */ + if (!srv_read_only_mode && srv_force_recovery < SRV_FORCE_NO_TRX_UNDO + && !buf_dblwr_create()) { + return(srv_init_abort(DB_ERROR)); + } + /* Here the double write buffer has already been created and so + any new rollback segments will be allocated after the double + write buffer. The default segment should already exist. + We create the new segments only if it's a new database or + the database was shutdown cleanly. */ + + /* Note: When creating the extra rollback segments during an upgrade + we violate the latching order, even if the change buffer is empty. + We make an exception in sync0sync.cc and check srv_is_being_started + for that violation. It cannot create a deadlock because we are still + running in single threaded mode essentially. Only the IO threads + should be running at this stage. */ + + if (!trx_sys_create_rsegs()) { + return(srv_init_abort(DB_ERROR)); + } + + if (!create_new_db) { /* Validate a few system page types that were left - uninitialized by older versions of MySQL. */ + uninitialized before MySQL or MariaDB 5.5. */ if (!high_level_read_only) { + ut_ad(srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE); buf_block_t* block; mtr.start(); /* Bitmap page types will be reset in @@ -2133,25 +2163,33 @@ files_checked: 0, RW_X_LATCH, &mtr); fil_block_check_type(*block, FIL_PAGE_TYPE_SYS, &mtr); mtr.commit(); - } - /* Roll back any recovered data dictionary transactions, so - that the data dictionary tables will be free of any locks. - The data dictionary latch should guarantee that there is at - most one data dictionary transaction active at a time. */ - if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) { - /* If the following call is ever removed, the - first-time ha_innobase::open() must hold (or - acquire and release) a table lock that - conflicts with trx_resurrect_table_locks(), to - ensure that any recovered incomplete ALTER TABLE - will have been rolled back. Otherwise, - dict_table_t::instant could be cleared by rollback - invoking dict_index_t::clear_instant_alter() while - open table handles exist in client connections. */ - trx_rollback_recovered(false); + /* Roll back any recovered data dictionary + transactions, so that the data dictionary + tables will be free of any locks. The data + dictionary latch should guarantee that there + is at most one data dictionary transaction + active at a time. */ + if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) { + /* If the following call is ever + removed, the first-time + ha_innobase::open() must hold (or + acquire and release) a table lock that + conflicts with + trx_resurrect_table_locks(), to ensure + that any recovered incomplete ALTER + TABLE will have been rolled + back. Otherwise, dict_table_t::instant + could be cleared by rollback invoking + dict_index_t::clear_instant_alter() + while open table handles exist in + client connections. */ + trx_rollback_recovered(false); + } } + /* FIXME: Skip the following if srv_read_only_mode, + while avoiding "Allocated tablespace ID" warnings. */ if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) { /* Open or Create SYS_TABLESPACES and SYS_DATAFILES so that tablespace names and other metadata can be @@ -2178,41 +2216,24 @@ files_checked: dict_check_tablespaces_and_store_max_id(); } - if (err != DB_SUCCESS) { - return(srv_init_abort(err)); + if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO + && !srv_read_only_mode) { + /* Drop partially created indexes. */ + row_merge_drop_temp_indexes(); + /* Drop garbage tables. */ + row_mysql_drop_garbage_tables(); + + /* Drop any auxiliary tables that were not + dropped when the parent table was + dropped. This can happen if the parent table + was dropped but the server crashed before the + auxiliary tables were dropped. */ + fts_drop_orphaned_tables(); + + /* Rollback incomplete non-DDL transactions */ + trx_rollback_is_active = true; + os_thread_create(trx_rollback_all_recovered, 0, 0); } - - recv_recovery_rollback_active(); - srv_startup_is_before_trx_rollback_phase = FALSE; - } - - ut_ad(err == DB_SUCCESS); - ut_a(sum_of_new_sizes != ULINT_UNDEFINED); - - /* Create the doublewrite buffer to a new tablespace */ - if (!srv_read_only_mode && srv_force_recovery < SRV_FORCE_NO_TRX_UNDO - && !buf_dblwr_create()) { - return(srv_init_abort(DB_ERROR)); - } - - /* Here the double write buffer has already been created and so - any new rollback segments will be allocated after the double - write buffer. The default segment should already exist. - We create the new segments only if it's a new database or - the database was shutdown cleanly. */ - - /* Note: When creating the extra rollback segments during an upgrade - we violate the latching order, even if the change buffer is empty. - We make an exception in sync0sync.cc and check srv_is_being_started - for that violation. It cannot create a deadlock because we are still - running in single threaded mode essentially. Only the IO threads - should be running at this stage. */ - - ut_a(srv_undo_logs > 0); - ut_a(srv_undo_logs <= TRX_SYS_N_RSEGS); - - if (!trx_sys_create_rsegs()) { - return(srv_init_abort(DB_ERROR)); } srv_startup_is_before_trx_rollback_phase = false; @@ -2455,7 +2476,7 @@ void innodb_shutdown() srv_shutdown_all_bg_threads(); if (srv_monitor_file) { - fclose(srv_monitor_file); + my_fclose(srv_monitor_file, MYF(MY_WME)); srv_monitor_file = 0; if (srv_monitor_file_name) { unlink(srv_monitor_file_name); @@ -2464,7 +2485,7 @@ void innodb_shutdown() } if (srv_misc_tmpfile) { - fclose(srv_misc_tmpfile); + my_fclose(srv_misc_tmpfile, MYF(MY_WME)); srv_misc_tmpfile = 0; } @@ -2478,7 +2499,7 @@ void innodb_shutdown() #ifdef BTR_CUR_HASH_ADAPT ut_ad(btr_search_sys || !srv_was_started); #endif /* BTR_CUR_HASH_ADAPT */ - ut_ad(ibuf || !srv_was_started); + ut_ad(ibuf.index || !srv_was_started); if (dict_stats_event) { dict_stats_thread_deinit(); @@ -2502,9 +2523,7 @@ void innodb_shutdown() btr_search_disable(true); } #endif /* BTR_CUR_HASH_ADAPT */ - if (ibuf) { - ibuf_close(); - } + ibuf_close(); log_sys.close(); purge_sys.close(); trx_sys.close(); diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc index 6e858254ad4..b9578289504 100644 --- a/storage/innobase/sync/sync0arr.cc +++ b/storage/innobase/sync/sync0arr.cc @@ -1310,13 +1310,15 @@ sync_arr_fill_sys_semphore_waits_table( WaitMutex* mutex; type = cell->request_type; /* JAN: FIXME - OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_THREAD_ID], - (longlong)os_thread_pf(cell->thread))); + OK(fields[SYS_SEMAPHORE_WAITS_THREAD_ID]->store(, + (longlong)os_thread_pf(cell->thread), true)); */ OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_FILE], innobase_basename(cell->file))); OK(fields[SYS_SEMAPHORE_WAITS_LINE]->store(cell->line, true)); fields[SYS_SEMAPHORE_WAITS_LINE]->set_notnull(); - OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_WAIT_TIME], (ulint)difftime(time(NULL), cell->reservation_time))); + OK(fields[SYS_SEMAPHORE_WAITS_WAIT_TIME]->store( + difftime(time(NULL), + cell->reservation_time))); if (type == SYNC_MUTEX) { mutex = static_cast<WaitMutex*>(cell->latch.mutex); @@ -1324,21 +1326,21 @@ sync_arr_fill_sys_semphore_waits_table( if (mutex) { // JAN: FIXME // OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_OBJECT_NAME], mutex->cmutex_name)); - OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_WAIT_OBJECT], (longlong)mutex)); + OK(fields[SYS_SEMAPHORE_WAITS_WAIT_OBJECT]->store((longlong)mutex, true)); OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_WAIT_TYPE], "MUTEX")); - //OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID], (longlong)mutex->thread_id)); + //OK(fields[SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID]->store(mutex->thread_id, true)); //OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_HOLDER_FILE], innobase_basename(mutex->file_name))); //OK(fields[SYS_SEMAPHORE_WAITS_HOLDER_LINE]->store(mutex->line, true)); //fields[SYS_SEMAPHORE_WAITS_HOLDER_LINE]->set_notnull(); //OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_CREATED_FILE], innobase_basename(mutex->cfile_name))); //OK(fields[SYS_SEMAPHORE_WAITS_CREATED_LINE]->store(mutex->cline, true)); //fields[SYS_SEMAPHORE_WAITS_CREATED_LINE]->set_notnull(); - //OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_WAITERS_FLAG], (longlong)mutex->waiters)); - //OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_LOCK_WORD], (longlong)mutex->lock_word)); + //OK(fields[SYS_SEMAPHORE_WAITS_WAITERS_FLAG]->store(mutex->waiters, true)); + //OK(fields[SYS_SEMAPHORE_WAITS_LOCK_WORD]->store(mutex->lock_word, true)); //OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_FILE], innobase_basename(mutex->file_name))); //OK(fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE]->store(mutex->line, true)); //fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE]->set_notnull(); - //OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT], mutex->count_os_wait)); + //OK(fields[SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT]->store(mutex->count_os_wait, true)); } } else if (type == RW_LOCK_X_WAIT || type == RW_LOCK_X @@ -1351,7 +1353,7 @@ sync_arr_fill_sys_semphore_waits_table( if (rwlock) { ulint writer = rw_lock_get_writer(rwlock); - OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_WAIT_OBJECT], (longlong)rwlock)); + OK(fields[SYS_SEMAPHORE_WAITS_WAIT_OBJECT]->store((longlong)rwlock, true)); if (type == RW_LOCK_X) { OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_WAIT_TYPE], "RW_LOCK_X")); } else if (type == RW_LOCK_X_WAIT) { @@ -1365,7 +1367,7 @@ sync_arr_fill_sys_semphore_waits_table( if (writer != RW_LOCK_NOT_LOCKED) { // JAN: FIXME // OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_OBJECT_NAME], rwlock->lock_name)); - OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_WRITER_THREAD], (longlong)os_thread_pf(rwlock->writer_thread))); + OK(fields[SYS_SEMAPHORE_WAITS_WRITER_THREAD]->store(os_thread_pf(rwlock->writer_thread), true)); if (writer == RW_LOCK_X) { OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_RESERVATION_MODE], "RW_LOCK_X")); @@ -1375,19 +1377,21 @@ sync_arr_fill_sys_semphore_waits_table( OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_RESERVATION_MODE], "RW_LOCK_SX")); } - //OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID], (longlong)rwlock->thread_id)); + //OK(fields[SYS_SEMAPHORE_WAITS_HOLDER_THREAD_ID]->store(rwlock->thread_id, true)); //OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_HOLDER_FILE], innobase_basename(rwlock->file_name))); //OK(fields[SYS_SEMAPHORE_WAITS_HOLDER_LINE]->store(rwlock->line, true)); //fields[SYS_SEMAPHORE_WAITS_HOLDER_LINE]->set_notnull(); - OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_READERS], rw_lock_get_reader_count(rwlock))); - OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_WAITERS_FLAG], - rwlock->waiters.load(std::memory_order_relaxed))); - OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_LOCK_WORD], - rwlock->lock_word.load(std::memory_order_relaxed))); + OK(fields[SYS_SEMAPHORE_WAITS_READERS]->store(rw_lock_get_reader_count(rwlock), true)); + OK(fields[SYS_SEMAPHORE_WAITS_WAITERS_FLAG]->store( + rwlock->waiters.load(std::memory_order_relaxed), + true)); + OK(fields[SYS_SEMAPHORE_WAITS_LOCK_WORD]->store( + rwlock->lock_word.load(std::memory_order_relaxed), + true)); OK(field_store_string(fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_FILE], innobase_basename(rwlock->last_x_file_name))); OK(fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE]->store(rwlock->last_x_line, true)); fields[SYS_SEMAPHORE_WAITS_LAST_WRITER_LINE]->set_notnull(); - OK(field_store_ulint(fields[SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT], rwlock->count_os_wait)); + OK(fields[SYS_SEMAPHORE_WAITS_OS_WAIT_COUNT]->store(rwlock->count_os_wait, true)); } } } diff --git a/storage/innobase/trx/trx0i_s.cc b/storage/innobase/trx/trx0i_s.cc index a39fb5d2e95..ed348357556 100644 --- a/storage/innobase/trx/trx0i_s.cc +++ b/storage/innobase/trx/trx0i_s.cc @@ -178,31 +178,13 @@ INFORMATION SCHEMA tables is fetched and later retrieved by the C++ code in handler/i_s.cc. */ trx_i_s_cache_t* trx_i_s_cache = &trx_i_s_cache_static; -/*******************************************************************//** -For a record lock that is in waiting state retrieves the only bit that -is set, for a table lock returns ULINT_UNDEFINED. -@return record number within the heap */ -static -ulint -wait_lock_get_heap_no( -/*==================*/ - const lock_t* lock) /*!< in: lock */ +/** @return the heap number of a record lock +@retval 0 for table locks */ +static uint16_t wait_lock_get_heap_no(const lock_t* lock) { - ulint ret; - - switch (lock_get_type(lock)) { - case LOCK_REC: - ret = lock_rec_find_set_bit(lock); - ut_a(ret != ULINT_UNDEFINED); - break; - case LOCK_TABLE: - ret = ULINT_UNDEFINED; - break; - default: - ut_error; - } - - return(ret); + return lock_get_type(lock) == LOCK_REC + ? static_cast<uint16_t>(lock_rec_find_set_bit(lock)) + : 0; } /*******************************************************************//** @@ -404,25 +386,20 @@ i_s_locks_row_validate( /*===================*/ const i_s_locks_row_t* row) /*!< in: row to validate */ { - ut_ad(row->lock_mode != NULL); - ut_ad(row->lock_type != NULL); + ut_ad(row->lock_mode); ut_ad(row->lock_table != NULL); ut_ad(row->lock_table_id != 0); - if (row->lock_space == ULINT_UNDEFINED) { + if (!row->lock_index) { /* table lock */ - ut_ad(!strcmp("TABLE", row->lock_type)); - ut_ad(row->lock_index == NULL); - ut_ad(row->lock_data == NULL); - ut_ad(row->lock_page == ULINT_UNDEFINED); - ut_ad(row->lock_rec == ULINT_UNDEFINED); + ut_ad(!row->lock_data); + ut_ad(!row->lock_space); + ut_ad(!row->lock_page); + ut_ad(!row->lock_rec); } else { /* record lock */ - ut_ad(!strcmp("RECORD", row->lock_type)); - ut_ad(row->lock_index != NULL); /* row->lock_data == NULL if buf_page_try_get() == NULL */ - ut_ad(row->lock_page != ULINT_UNDEFINED); - ut_ad(row->lock_rec != ULINT_UNDEFINED); + ut_ad(row->lock_page); } return(TRUE); @@ -506,21 +483,7 @@ fill_trx_row( } thd_done: - s = trx->op_info; - - if (s != NULL && s[0] != '\0') { - - TRX_I_S_STRING_COPY(s, row->trx_operation_state, - TRX_I_S_TRX_OP_STATE_MAX_LEN, cache); - - if (row->trx_operation_state == NULL) { - - return(FALSE); - } - } else { - - row->trx_operation_state = NULL; - } + row->trx_operation_state = trx->op_info; row->trx_tables_in_use = trx->n_mysql_tables_in_use; @@ -540,23 +503,7 @@ thd_done: row->trx_concurrency_tickets = trx->n_tickets_to_enter_innodb; - switch (trx->isolation_level) { - case TRX_ISO_READ_UNCOMMITTED: - row->trx_isolation_level = "READ UNCOMMITTED"; - break; - case TRX_ISO_READ_COMMITTED: - row->trx_isolation_level = "READ COMMITTED"; - break; - case TRX_ISO_REPEATABLE_READ: - row->trx_isolation_level = "REPEATABLE READ"; - break; - case TRX_ISO_SERIALIZABLE: - row->trx_isolation_level = "SERIALIZABLE"; - break; - /* Should not happen as TRX_ISO_READ_COMMITTED is default */ - default: - row->trx_isolation_level = "UNKNOWN"; - } + row->trx_isolation_level = trx->isolation_level; row->trx_unique_checks = (ibool) trx->check_unique_secondary; @@ -688,8 +635,8 @@ fill_lock_data( mtr_start(&mtr); - block = buf_page_try_get(page_id_t(lock_rec_get_space_id(lock), - lock_rec_get_page_no(lock)), + block = buf_page_try_get(page_id_t(lock->un_member.rec_lock.space, + lock->un_member.rec_lock.page_no), &mtr); if (block == NULL) { @@ -753,22 +700,42 @@ fill_lock_data( /*******************************************************************//** Fills i_s_locks_row_t object. Returns its first argument. If memory can not be allocated then FALSE is returned. -@return FALSE if allocation fails */ -static -ibool -fill_locks_row( -/*===========*/ +@return false if allocation fails */ +static bool fill_locks_row( i_s_locks_row_t* row, /*!< out: result object that's filled */ const lock_t* lock, /*!< in: lock to get data from */ - ulint heap_no,/*!< in: lock's record number - or ULINT_UNDEFINED if the lock + uint16_t heap_no,/*!< in: lock's record number + or 0 if the lock is a table lock */ trx_i_s_cache_t* cache) /*!< in/out: cache into which to copy volatile strings */ { - row->lock_trx_id = lock_get_trx_id(lock); - row->lock_mode = lock_get_mode_str(lock); - row->lock_type = lock_get_type_str(lock); + row->lock_trx_id = lock->trx->id; + const auto lock_type = lock_get_type(lock); + ut_ad(lock_type == LOCK_REC || lock_type == LOCK_TABLE); + + const bool is_gap_lock = lock_type == LOCK_REC + && (lock->type_mode & LOCK_GAP); + switch (lock->type_mode & LOCK_MODE_MASK) { + case LOCK_S: + row->lock_mode = 1 + is_gap_lock; + break; + case LOCK_X: + row->lock_mode = 3 + is_gap_lock; + break; + case LOCK_IS: + row->lock_mode = 5 + is_gap_lock; + break; + case LOCK_IX: + row->lock_mode = 7 + is_gap_lock; + break; + case LOCK_AUTO_INC: + row->lock_mode = 9; + break; + default: + ut_ad(!"unknown lock mode"); + row->lock_mode = 0; + } row->lock_table = ha_storage_put_str_memlim( cache->storage, lock_get_table_name(lock).m_name, @@ -777,11 +744,10 @@ fill_locks_row( /* memory could not be allocated */ if (row->lock_table == NULL) { - return(FALSE); + return false; } - switch (lock_get_type(lock)) { - case LOCK_REC: + if (lock_type == LOCK_REC) { row->lock_index = ha_storage_put_str_memlim( cache->storage, lock_rec_get_index_name(lock), MAX_ALLOWED_FOR_STORAGE(cache)); @@ -789,32 +755,26 @@ fill_locks_row( /* memory could not be allocated */ if (row->lock_index == NULL) { - return(FALSE); + return false; } - row->lock_space = lock_rec_get_space_id(lock); - row->lock_page = lock_rec_get_page_no(lock); + row->lock_space = lock->un_member.rec_lock.space; + row->lock_page = lock->un_member.rec_lock.page_no; row->lock_rec = heap_no; if (!fill_lock_data(&row->lock_data, lock, heap_no, cache)) { /* memory could not be allocated */ - return(FALSE); + return false; } - - break; - case LOCK_TABLE: + } else { row->lock_index = NULL; - row->lock_space = ULINT_UNDEFINED; - row->lock_page = ULINT_UNDEFINED; - row->lock_rec = ULINT_UNDEFINED; + row->lock_space = 0; + row->lock_page = 0; + row->lock_rec = 0; row->lock_data = NULL; - - break; - default: - ut_error; } row->lock_table_id = lock_get_table_id(lock); @@ -822,7 +782,7 @@ fill_locks_row( row->hash_chain.value = row; ut_ad(i_s_locks_row_validate(row)); - return(TRUE); + return true; } /*******************************************************************//** @@ -876,11 +836,11 @@ fold_lock( case LOCK_REC: ut_a(heap_no != ULINT_UNDEFINED); - ret = ut_fold_ulint_pair((ulint) lock_get_trx_id(lock), - lock_rec_get_space_id(lock)); + ret = ut_fold_ulint_pair((ulint) lock->trx->id, + lock->un_member.rec_lock.space); ret = ut_fold_ulint_pair(ret, - lock_rec_get_page_no(lock)); + lock->un_member.rec_lock.page_no); ret = ut_fold_ulint_pair(ret, heap_no); @@ -923,9 +883,9 @@ locks_row_eq_lock( case LOCK_REC: ut_a(heap_no != ULINT_UNDEFINED); - return(row->lock_trx_id == lock_get_trx_id(lock) - && row->lock_space == lock_rec_get_space_id(lock) - && row->lock_page == lock_rec_get_page_no(lock) + return(row->lock_trx_id == lock->trx->id + && row->lock_space == lock->un_member.rec_lock.space + && row->lock_page == lock->un_member.rec_lock.page_no && row->lock_rec == heap_no); case LOCK_TABLE: @@ -934,7 +894,7 @@ locks_row_eq_lock( it fails. */ ut_a(heap_no == ULINT_UNDEFINED); - return(row->lock_trx_id == lock_get_trx_id(lock) + return(row->lock_trx_id == lock->trx->id && row->lock_table_id == lock_get_table_id(lock)); default: @@ -955,7 +915,7 @@ search_innodb_locks( /*================*/ trx_i_s_cache_t* cache, /*!< in: cache */ const lock_t* lock, /*!< in: lock to search for */ - ulint heap_no)/*!< in: lock's record number + uint16_t heap_no)/*!< in: lock's record number or ULINT_UNDEFINED if the lock is a table lock */ { @@ -998,8 +958,8 @@ add_lock_to_cache( /*==============*/ trx_i_s_cache_t* cache, /*!< in/out: cache */ const lock_t* lock, /*!< in: the element to add */ - ulint heap_no)/*!< in: lock's record number - or ULINT_UNDEFINED if the lock + uint16_t heap_no)/*!< in: lock's record number + or 0 if the lock is a table lock */ { i_s_locks_row_t* dst_row; @@ -1113,13 +1073,12 @@ add_trx_relevant_locks_to_cache( if (trx->lock.que_state == TRX_QUE_LOCK_WAIT) { const lock_t* curr_lock; - ulint wait_lock_heap_no; i_s_locks_row_t* blocking_lock_row; lock_queue_iterator_t iter; ut_a(trx->lock.wait_lock != NULL); - wait_lock_heap_no + uint16_t wait_lock_heap_no = wait_lock_get_heap_no(trx->lock.wait_lock); /* add the requested lock */ @@ -1523,11 +1482,11 @@ trx_i_s_create_lock_id( /* please adjust TRX_I_S_LOCK_ID_MAX_LEN if you change this */ - if (row->lock_space != ULINT_UNDEFINED) { + if (row->lock_index) { /* record lock */ res_len = snprintf(lock_id, lock_id_size, TRX_ID_FMT - ":" ULINTPF ":" ULINTPF ":" ULINTPF, + ":%u:%u:%u", row->lock_trx_id, row->lock_space, row->lock_page, row->lock_rec); } else { diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 68f9d78caa0..d7efb4c7033 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -569,7 +569,7 @@ static void trx_purge_truncate_history() return; } - while (srv_undo_log_truncate && srv_undo_logs >= 3) { + while (srv_undo_log_truncate) { if (!purge_sys.truncate.current) { const ulint threshold = ulint(srv_max_undo_log_size >> srv_page_size_shift); diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index b81b1ab3dee..9afc0071e17 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -44,6 +44,10 @@ Created 3/26/1996 Heikki Tuuri #include "trx0trx.h" #include "trx0undo.h" +#ifdef UNIV_PFS_THREAD +mysql_pfs_key_t trx_rollback_clean_thread_key; +#endif + /** true if trx_rollback_all_recovered() thread is active */ bool trx_rollback_is_active; @@ -850,7 +854,6 @@ discard: } } - /*******************************************************************//** Rollback or clean up any incomplete transactions which were encountered in crash recovery. If the transaction already was diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index bb645186b75..f41bf942b2b 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -238,16 +238,11 @@ trx_sys_create_rsegs() { /* srv_available_undo_logs reflects the number of persistent rollback segments that have been initialized in the - transaction system header page. - - srv_undo_logs determines how many of the - srv_available_undo_logs rollback segments may be used for - logging new transactions. */ + transaction system header page. */ ut_ad(srv_undo_tablespaces <= TRX_SYS_MAX_UNDO_SPACES); - ut_ad(srv_undo_logs <= TRX_SYS_N_RSEGS); - if (srv_read_only_mode) { - srv_undo_logs = srv_available_undo_logs = ULONG_UNDEFINED; + if (high_level_read_only) { + srv_available_undo_logs = 0; return(true); } @@ -262,43 +257,35 @@ trx_sys_create_rsegs() in the system tablespace. */ ut_a(srv_available_undo_logs > 0); - if (srv_force_recovery) { - /* Do not create additional rollback segments if - innodb_force_recovery has been set. */ - if (srv_undo_logs > srv_available_undo_logs) { - srv_undo_logs = srv_available_undo_logs; + for (ulint i = 0; srv_available_undo_logs < TRX_SYS_N_RSEGS; + i++, srv_available_undo_logs++) { + /* Tablespace 0 is the system tablespace. + Dedicated undo log tablespaces start from 1. */ + ulint space = srv_undo_tablespaces > 0 + ? (i % srv_undo_tablespaces) + + srv_undo_space_id_start + : TRX_SYS_SPACE; + + if (!trx_rseg_create(space)) { + ib::error() << "Unable to allocate the" + " requested innodb_undo_logs"; + return(false); } - } else { - for (ulint i = 0; srv_available_undo_logs < srv_undo_logs; - i++, srv_available_undo_logs++) { - /* Tablespace 0 is the system tablespace. - Dedicated undo log tablespaces start from 1. */ - ulint space = srv_undo_tablespaces > 0 - ? (i % srv_undo_tablespaces) - + srv_undo_space_id_start - : TRX_SYS_SPACE; - - if (!trx_rseg_create(space)) { - ib::error() << "Unable to allocate the" - " requested innodb_undo_logs"; - return(false); - } - - /* Increase the number of active undo - tablespace in case new rollback segment - assigned to new undo tablespace. */ - if (space > srv_undo_tablespaces_active) { - srv_undo_tablespaces_active++; - - ut_ad(srv_undo_tablespaces_active == space); - } + + /* Increase the number of active undo + tablespace in case new rollback segment + assigned to new undo tablespace. */ + if (space > srv_undo_tablespaces_active) { + srv_undo_tablespaces_active++; + + ut_ad(srv_undo_tablespaces_active == space); } } - ut_ad(srv_undo_logs <= srv_available_undo_logs); + ut_ad(srv_available_undo_logs == TRX_SYS_N_RSEGS); ib::info info; - info << srv_undo_logs << " out of " << srv_available_undo_logs; + info << srv_available_undo_logs; if (srv_undo_tablespaces_active) { info << " rollback segments in " << srv_undo_tablespaces_active << " undo tablespaces are active."; diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index c7045d46475..cdabaad5f53 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -817,11 +817,13 @@ evenly distributed between 0 and innodb_undo_logs-1 @retval NULL if innodb_read_only */ static trx_rseg_t* trx_assign_rseg_low() { - if (srv_read_only_mode) { - ut_ad(srv_undo_logs == ULONG_UNDEFINED); + if (high_level_read_only) { + ut_ad(!srv_available_undo_logs); return(NULL); } + ut_ad(srv_available_undo_logs == TRX_SYS_N_RSEGS); + /* The first slot is always assigned to the system tablespace. */ ut_ad(trx_sys.rseg_array[0]->space == fil_system.sys_space); @@ -834,7 +836,8 @@ static trx_rseg_t* trx_assign_rseg_low() that start modifications concurrently will write their undo log to the same rollback segment. */ static ulong rseg_slot; - ulint slot = rseg_slot++ % srv_undo_logs; + ulint slot = rseg_slot++ % TRX_SYS_N_RSEGS; + ut_d(if (trx_rseg_n_slots_debug) slot = 0); trx_rseg_t* rseg; #ifdef UNIV_DEBUG @@ -857,7 +860,8 @@ static trx_rseg_t* trx_assign_rseg_low() look_for_rollover = true; #endif /* UNIV_DEBUG */ - slot = (slot + 1) % srv_undo_logs; + ut_d(if (!trx_rseg_n_slots_debug)) + slot = (slot + 1) % TRX_SYS_N_RSEGS; if (rseg == NULL) { continue; diff --git a/storage/innobase/ut/ut0crc32.cc b/storage/innobase/ut/ut0crc32.cc index 5ccd15dd5ca..4a6447c1dcf 100644 --- a/storage/innobase/ut/ut0crc32.cc +++ b/storage/innobase/ut/ut0crc32.cc @@ -131,6 +131,28 @@ ut_crc32_func_t ut_crc32 = ut_crc32_sw; const char* ut_crc32_implementation = "Using generic crc32 instructions"; #endif +#ifdef HAVE_ARMV8_CRC +extern "C" { +uint32_t crc32c_aarch64(uint32_t crc, const unsigned char *buffer, uint64_t len); +}; +static inline +uint32_t +ut_crc32_armv8( + const byte* buf, + ulint len) +{ + return crc32c_aarch64(0, buf, len); +} +#endif + +/* For runtime check */ +#if defined(__GNUC__) && defined(__linux__) && defined(HAVE_ARMV8_CRC) +extern "C" { +unsigned int crc32c_aarch64_available(void); +}; +#endif + + #if (defined(__GNUC__) && defined(__x86_64__)) || defined(_MSC_VER) /********************************************************************//** Fetches CPU info */ @@ -544,4 +566,14 @@ ut_crc32_init() ut_crc32_implementation = "Using SSE2 crc32 instructions"; } #endif + + +#if defined(__GNUC__) && defined(__linux__) && defined(HAVE_ARMV8_CRC) + if (crc32c_aarch64_available()) { + ut_crc32 = ut_crc32_armv8; + ut_crc32_implementation = "Using Armv8 crc32 instructions"; + + } +#endif + } |