mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 13:02:28 +01:00
bf2f50d345
Bugs fixed: - Bug #20877: InnoDB data dictionary memory footprint is too big - Bug #13544: Second delete of same row in transaction illustrates non-optimal locking - Bug #20791: valgrind errors in InnoDB storage/innobase/btr/btr0btr.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r823: Minor cleanup related to Bug #20877. btr_print_recursive(): Replace tree->tree_indexes with tree->index. This should have been done in r453. univ.i: Add UNIV_BTR_PRINT. rw_lock_t: Reduce writer_is_wait_ex to a bit and move it close to other bitfields. Change the types to unsigned, in case ulint or ibool bitfields will not work. Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r837: page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE) calls. dict_index_build_node_ptr(): Correct a typo in a comment. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/btr/btr0cur.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r816: Remove more remnants of mixed indexes. Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r830: page_align(ptr): New utility function to replace ut_align_down(ptr, UNIV_PAGE_SIZE) calls. Revision r837: page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE) calls. dict_index_build_node_ptr(): Correct a typo in a comment. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/btr/btr0pcur.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r830: page_align(ptr): New utility function to replace ut_align_down(ptr, UNIV_PAGE_SIZE) calls. Revision r837: page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE) calls. dict_index_build_node_ptr(): Correct a typo in a comment. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/btr/btr0sea.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r816: Remove more remnants of mixed indexes. Revision r824: Reduce the size of btr_search_t from 13 machine words to 7. This structure is reserved for every index in the data dictionary cache. (Bug #20877) We could shrink the structure further to three 32-bit words or two 64-bit words by turning the remaining fields to bit-fields. Unfortunately, the fields are not protected by any mutex, and thus we would better keep each field aligned to a machine word. btr_search_t, buf_block_t: Rename "ulint side" to "ibool left_side". Remove BTR_SEARCH_LEFT_SIDE and BTR_SEARCH_RIGHT_SIDE, and also rename some local variables and function parameters from "ulint side" to "ibool left_side". btr_search_t: Remove the unused fields last_search, n_direction, direction, and modify_clock. Remove the unused constants BTR_SEA_NO_DIRECTION, BTR_SEA_LEFT, BTR_SEA_RIGHT, and BTR_SEA_SAME_REC. btr_search_t: Remove magic_n unless #defined UNIV_DEBUG. Turn an assertion about the magic number into a debug assertion. Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/buf/buf0buf.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r824: Reduce the size of btr_search_t from 13 machine words to 7. This structure is reserved for every index in the data dictionary cache. (Bug #20877) We could shrink the structure further to three 32-bit words or two 64-bit words by turning the remaining fields to bit-fields. Unfortunately, the fields are not protected by any mutex, and thus we would better keep each field aligned to a machine word. btr_search_t, buf_block_t: Rename "ulint side" to "ibool left_side". Remove BTR_SEARCH_LEFT_SIDE and BTR_SEARCH_RIGHT_SIDE, and also rename some local variables and function parameters from "ulint side" to "ibool left_side". btr_search_t: Remove the unused fields last_search, n_direction, direction, and modify_clock. Remove the unused constants BTR_SEA_NO_DIRECTION, BTR_SEA_LEFT, BTR_SEA_RIGHT, and BTR_SEA_SAME_REC. btr_search_t: Remove magic_n unless #defined UNIV_DEBUG. Turn an assertion about the magic number into a debug assertion. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/buf/buf0flu.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/buf/buf0lru.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/buf/buf0rea.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/data/data0data.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/data/data0type.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r816: Remove more remnants of mixed indexes. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. storage/innobase/dict/dict0boot.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r816: Remove more remnants of mixed indexes. Revision r827: Make dict_index_find_cols() always succeed. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/dict/dict0crea.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r816: Remove more remnants of mixed indexes. Revision r827: Make dict_index_find_cols() always succeed. Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r832: Add dict_table_get_col_name() in preparation for getting rid of dict_col_t::name, and use it instead of col->name everywhere. Revision r833: Tweak the bit-field definitions introduced since r813 to address Bug #20877. rw_lock_t: Do not make writer_is_wait_ex a bit-field. There are no fields yet that could be fused to the same machine word, but we play it safe, because the field writer_is_wait_ex may be modified by several threads simultaneously. Such fields should always be allocated an own machine word. dict_table_t: Change the type of all bit-fields to "unsigned". Make "space" a bit-field of 32 bits. Move name_hash and id_hash after all bit-fields, so that the bit-fields can be allocated together. Do not make autoinc_inited a bit-field, as we cannot allocate any field from the same machine word. dict_build_table_def_step(): Pass a local variable to fil_create_new_single_table_tablespace() and initialize table->space from it after the call, now that table->space is a bit-field. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/dict/dict0dict.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r816: Remove more remnants of mixed indexes. Revision r818: Remove dict_col_t::hash, dict_col_t::table, dict_sys->col_hash, and DICT_POOL_PER_COL_HASH. (Bug #20877) The col->table pointer was only needed for maintaining a hash table of all defined columns in all tables. The hash table was only looked up in dict_index_find_cols(). Removing the col->hash and col->table pointers reduces the size of a table column by two machine words (usually 8 or 16 bytes). dict_col_add_to_cache(), dict_col_reposition_in_cache(), dict_col_remove_from_cache(): Remove. These only updated dict_sys->col_hash. dict_index_find_cols(): Use a linear search instead of the hash table. The time complexity is affected, but this function is only invoked by dict_index_add_to_cache(), and we only search the columns of a single table (typically at most a few dozen) as opposed to all columns of all tables. Revision r819: dict_col_t: Reduce ord_part to one bit. dict_index_add_to_cache(): Instead of incrementing ord_part, set it. dict_index_remove_from_cache(): Do not touch ord_part. dtype_t: Reduce mbminlen from 3 to 2 bits. row_upd(): Add a UNIV_LIKELY hint around node->in_mysql_interface. Revision r820: Remove dict_col_t::clust_pos. dict_col_get_clust_pos(): Add parameter clust_index. Replace the look-up with a linear search of all columns in the clustered index. row_upd_index_replace_new_col_vals(): Compute clust_index outside the loops. Compute clust_pos outside the inner loop. row_upd_changes_ord_field_binary(), row_upd_changes_first_fields_binary(): Compute clust_index outside the loops. Declare the auxiliary variables inside the loop scope. Revision r821: dict_table_t: Rename the integer field max_row_size to the Boolean field big_rows. (Bug #20877) BIG_ROW_SIZE: Move the definition from row0sel.c to dict_table_add_to_cache(). Revision r826: The code base was reindented in r763 and automatic .emacs indentation settings introduced. Some problems were found, so from this commit on one additional indentation rule is introduced: (add-to-list 'c-offsets-alist '(arglist-intro . +)) Note that fixing some of the unfortunate line-splits done in r764 will be done in a future change. Revision r827: Make dict_index_find_cols() always succeed. Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r831: Add dict_col_get_clust_pos_noninline(), which was forgotten from r820. Revision r832: Add dict_table_get_col_name() in preparation for getting rid of dict_col_t::name, and use it instead of col->name everywhere. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r836: Remove dict_col_t::name, replace it with a packed array of column names in dict_table_t. This saves 8-15+ bytes of memory per column on 64-bit machines. Revision r837: page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE) calls. dict_index_build_node_ptr(): Correct a typo in a comment. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. Revision r845: Split long lines with [] operators better. storage/innobase/dict/dict0load.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r832: Add dict_table_get_col_name() in preparation for getting rid of dict_col_t::name, and use it instead of col->name everywhere. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/dict/dict0mem.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r818: Remove dict_col_t::hash, dict_col_t::table, dict_sys->col_hash, and DICT_POOL_PER_COL_HASH. (Bug #20877) The col->table pointer was only needed for maintaining a hash table of all defined columns in all tables. The hash table was only looked up in dict_index_find_cols(). Removing the col->hash and col->table pointers reduces the size of a table column by two machine words (usually 8 or 16 bytes). dict_col_add_to_cache(), dict_col_reposition_in_cache(), dict_col_remove_from_cache(): Remove. These only updated dict_sys->col_hash. dict_index_find_cols(): Use a linear search instead of the hash table. The time complexity is affected, but this function is only invoked by dict_index_add_to_cache(), and we only search the columns of a single table (typically at most a few dozen) as opposed to all columns of all tables. Revision r820: Remove dict_col_t::clust_pos. dict_col_get_clust_pos(): Add parameter clust_index. Replace the look-up with a linear search of all columns in the clustered index. row_upd_index_replace_new_col_vals(): Compute clust_index outside the loops. Compute clust_pos outside the inner loop. row_upd_changes_ord_field_binary(), row_upd_changes_first_fields_binary(): Compute clust_index outside the loops. Declare the auxiliary variables inside the loop scope. Revision r821: dict_table_t: Rename the integer field max_row_size to the Boolean field big_rows. (Bug #20877) BIG_ROW_SIZE: Move the definition from row0sel.c to dict_table_add_to_cache(). Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r836: Remove dict_col_t::name, replace it with a packed array of column names in dict_table_t. This saves 8-15+ bytes of memory per column on 64-bit machines. storage/innobase/eval/eval0eval.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r826: The code base was reindented in r763 and automatic .emacs indentation settings introduced. Some problems were found, so from this commit on one additional indentation rule is introduced: (add-to-list 'c-offsets-alist '(arglist-intro . +)) Note that fixing some of the unfortunate line-splits done in r764 will be done in a future change. storage/innobase/eval/eval0proc.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/fil/fil0fil.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/fsp/fsp0fsp.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. Revision r845: Split long lines with [] operators better. storage/innobase/handler/ha_innodb.cc: Applied innodb-5.1 snapshots ss799 and ss854 storage/innobase/handler/ha_innodb.h: Applied innodb-5.1 snapshots ss799 and ss854 storage/innobase/ibuf/ibuf0ibuf.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r832: Add dict_table_get_col_name() in preparation for getting rid of dict_col_t::name, and use it instead of col->name everywhere. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/include/btr0btr.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". storage/innobase/include/btr0btr.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r837: page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE) calls. dict_index_build_node_ptr(): Correct a typo in a comment. storage/innobase/include/btr0cur.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". storage/innobase/include/btr0cur.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". storage/innobase/include/btr0pcur.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r817: btr0pcur.h: Change FIXME to TODO. storage/innobase/include/btr0sea.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r824: Reduce the size of btr_search_t from 13 machine words to 7. This structure is reserved for every index in the data dictionary cache. (Bug #20877) We could shrink the structure further to three 32-bit words or two 64-bit words by turning the remaining fields to bit-fields. Unfortunately, the fields are not protected by any mutex, and thus we would better keep each field aligned to a machine word. btr_search_t, buf_block_t: Rename "ulint side" to "ibool left_side". Remove BTR_SEARCH_LEFT_SIDE and BTR_SEARCH_RIGHT_SIDE, and also rename some local variables and function parameters from "ulint side" to "ibool left_side". btr_search_t: Remove the unused fields last_search, n_direction, direction, and modify_clock. Remove the unused constants BTR_SEA_NO_DIRECTION, BTR_SEA_LEFT, BTR_SEA_RIGHT, and BTR_SEA_SAME_REC. btr_search_t: Remove magic_n unless #defined UNIV_DEBUG. Turn an assertion about the magic number into a debug assertion. storage/innobase/include/buf0buf.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r824: Reduce the size of btr_search_t from 13 machine words to 7. This structure is reserved for every index in the data dictionary cache. (Bug #20877) We could shrink the structure further to three 32-bit words or two 64-bit words by turning the remaining fields to bit-fields. Unfortunately, the fields are not protected by any mutex, and thus we would better keep each field aligned to a machine word. btr_search_t, buf_block_t: Rename "ulint side" to "ibool left_side". Remove BTR_SEARCH_LEFT_SIDE and BTR_SEARCH_RIGHT_SIDE, and also rename some local variables and function parameters from "ulint side" to "ibool left_side". btr_search_t: Remove the unused fields last_search, n_direction, direction, and modify_clock. Remove the unused constants BTR_SEA_NO_DIRECTION, BTR_SEA_LEFT, BTR_SEA_RIGHT, and BTR_SEA_SAME_REC. btr_search_t: Remove magic_n unless #defined UNIV_DEBUG. Turn an assertion about the magic number into a debug assertion. storage/innobase/include/data0data.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. storage/innobase/include/data0type.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r816: Remove more remnants of mixed indexes. Revision r819: dict_col_t: Reduce ord_part to one bit. dict_index_add_to_cache(): Instead of incrementing ord_part, set it. dict_index_remove_from_cache(): Do not touch ord_part. dtype_t: Reduce mbminlen from 3 to 2 bits. row_upd(): Add a UNIV_LIKELY hint around node->in_mysql_interface. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. storage/innobase/include/data0type.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r816: Remove more remnants of mixed indexes. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/include/dict0boot.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r816: Remove more remnants of mixed indexes. storage/innobase/include/dict0dict.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r816: Remove more remnants of mixed indexes. Revision r818: Remove dict_col_t::hash, dict_col_t::table, dict_sys->col_hash, and DICT_POOL_PER_COL_HASH. (Bug #20877) The col->table pointer was only needed for maintaining a hash table of all defined columns in all tables. The hash table was only looked up in dict_index_find_cols(). Removing the col->hash and col->table pointers reduces the size of a table column by two machine words (usually 8 or 16 bytes). dict_col_add_to_cache(), dict_col_reposition_in_cache(), dict_col_remove_from_cache(): Remove. These only updated dict_sys->col_hash. dict_index_find_cols(): Use a linear search instead of the hash table. The time complexity is affected, but this function is only invoked by dict_index_add_to_cache(), and we only search the columns of a single table (typically at most a few dozen) as opposed to all columns of all tables. Revision r820: Remove dict_col_t::clust_pos. dict_col_get_clust_pos(): Add parameter clust_index. Replace the look-up with a linear search of all columns in the clustered index. row_upd_index_replace_new_col_vals(): Compute clust_index outside the loops. Compute clust_pos outside the inner loop. row_upd_changes_ord_field_binary(), row_upd_changes_first_fields_binary(): Compute clust_index outside the loops. Declare the auxiliary variables inside the loop scope. Revision r827: Make dict_index_find_cols() always succeed. Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r831: Add dict_col_get_clust_pos_noninline(), which was forgotten from r820. Revision r832: Add dict_table_get_col_name() in preparation for getting rid of dict_col_t::name, and use it instead of col->name everywhere. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r836: Remove dict_col_t::name, replace it with a packed array of column names in dict_table_t. This saves 8-15+ bytes of memory per column on 64-bit machines. storage/innobase/include/dict0dict.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r820: Remove dict_col_t::clust_pos. dict_col_get_clust_pos(): Add parameter clust_index. Replace the look-up with a linear search of all columns in the clustered index. row_upd_index_replace_new_col_vals(): Compute clust_index outside the loops. Compute clust_pos outside the inner loop. row_upd_changes_ord_field_binary(), row_upd_changes_first_fields_binary(): Compute clust_index outside the loops. Declare the auxiliary variables inside the loop scope. Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. storage/innobase/include/dict0mem.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r815: dict_index_t: Remove tree_indexes. It should have been removed in r453 when the list in dict_tree_t was replaced with the pointer tree_index. Revision r818: Remove dict_col_t::hash, dict_col_t::table, dict_sys->col_hash, and DICT_POOL_PER_COL_HASH. (Bug #20877) The col->table pointer was only needed for maintaining a hash table of all defined columns in all tables. The hash table was only looked up in dict_index_find_cols(). Removing the col->hash and col->table pointers reduces the size of a table column by two machine words (usually 8 or 16 bytes). dict_col_add_to_cache(), dict_col_reposition_in_cache(), dict_col_remove_from_cache(): Remove. These only updated dict_sys->col_hash. dict_index_find_cols(): Use a linear search instead of the hash table. The time complexity is affected, but this function is only invoked by dict_index_add_to_cache(), and we only search the columns of a single table (typically at most a few dozen) as opposed to all columns of all tables. Revision r819: dict_col_t: Reduce ord_part to one bit. dict_index_add_to_cache(): Instead of incrementing ord_part, set it. dict_index_remove_from_cache(): Do not touch ord_part. dtype_t: Reduce mbminlen from 3 to 2 bits. row_upd(): Add a UNIV_LIKELY hint around node->in_mysql_interface. Revision r820: Remove dict_col_t::clust_pos. dict_col_get_clust_pos(): Add parameter clust_index. Replace the look-up with a linear search of all columns in the clustered index. row_upd_index_replace_new_col_vals(): Compute clust_index outside the loops. Compute clust_pos outside the inner loop. row_upd_changes_ord_field_binary(), row_upd_changes_first_fields_binary(): Compute clust_index outside the loops. Declare the auxiliary variables inside the loop scope. Revision r821: dict_table_t: Rename the integer field max_row_size to the Boolean field big_rows. (Bug #20877) BIG_ROW_SIZE: Move the definition from row0sel.c to dict_table_add_to_cache(). Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r833: Tweak the bit-field definitions introduced since r813 to address Bug #20877. rw_lock_t: Do not make writer_is_wait_ex a bit-field. There are no fields yet that could be fused to the same machine word, but we play it safe, because the field writer_is_wait_ex may be modified by several threads simultaneously. Such fields should always be allocated an own machine word. dict_table_t: Change the type of all bit-fields to "unsigned". Make "space" a bit-field of 32 bits. Move name_hash and id_hash after all bit-fields, so that the bit-fields can be allocated together. Do not make autoinc_inited a bit-field, as we cannot allocate any field from the same machine word. dict_build_table_def_step(): Pass a local variable to fil_create_new_single_table_tablespace() and initialize table->space from it after the call, now that table->space is a bit-field. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r835: Change the recently introduced ulint bit-fields to unsigned. Revision r836: Remove dict_col_t::name, replace it with a packed array of column names in dict_table_t. This saves 8-15+ bytes of memory per column on 64-bit machines. storage/innobase/include/dict0types.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". storage/innobase/include/ibuf0ibuf.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/include/page0page.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r830: page_align(ptr): New utility function to replace ut_align_down(ptr, UNIV_PAGE_SIZE) calls. Revision r837: page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE) calls. dict_index_build_node_ptr(): Correct a typo in a comment. storage/innobase/include/page0page.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r830: page_align(ptr): New utility function to replace ut_align_down(ptr, UNIV_PAGE_SIZE) calls. Revision r837: page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE) calls. dict_index_build_node_ptr(): Correct a typo in a comment. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/include/read0read.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/include/rem0cmp.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. storage/innobase/include/rem0cmp.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. storage/innobase/include/rem0rec.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. storage/innobase/include/rem0rec.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/include/rem0types.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. storage/innobase/include/row0upd.ic: Applied innodb-5.1 snapshots ss799 and ss854 Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. storage/innobase/include/sync0rw.h: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r823: Minor cleanup related to Bug #20877. btr_print_recursive(): Replace tree->tree_indexes with tree->index. This should have been done in r453. univ.i: Add UNIV_BTR_PRINT. rw_lock_t: Reduce writer_is_wait_ex to a bit and move it close to other bitfields. Change the types to unsigned, in case ulint or ibool bitfields will not work. Revision r833: Tweak the bit-field definitions introduced since r813 to address Bug #20877. rw_lock_t: Do not make writer_is_wait_ex a bit-field. There are no fields yet that could be fused to the same machine word, but we play it safe, because the field writer_is_wait_ex may be modified by several threads simultaneously. Such fields should always be allocated an own machine word. dict_table_t: Change the type of all bit-fields to "unsigned". Make "space" a bit-field of 32 bits. Move name_hash and id_hash after all bit-fields, so that the bit-fields can be allocated together. Do not make autoinc_inited a bit-field, as we cannot allocate any field from the same machine word. dict_build_table_def_step(): Pass a local variable to fil_create_new_single_table_tablespace() and initialize table->space from it after the call, now that table->space is a bit-field. storage/innobase/include/univ.i: Applied innodb-5.1 snapshots ss799 and ss854 Revision r823: Minor cleanup related to Bug #20877. btr_print_recursive(): Replace tree->tree_indexes with tree->index. This should have been done in r453. univ.i: Add UNIV_BTR_PRINT. rw_lock_t: Reduce writer_is_wait_ex to a bit and move it close to other bitfields. Change the types to unsigned, in case ulint or ibool bitfields will not work. storage/innobase/lock/lock0lock.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/log/log0log.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/log/log0recv.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/mem/mem0dbg.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/mem/mem0pool.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/mtr/mtr0log.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r832: Add dict_table_get_col_name() in preparation for getting rid of dict_col_t::name, and use it instead of col->name everywhere. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/mtr/mtr0mtr.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/os/os0file.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/os/os0thread.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/page/page0cur.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r837: page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE) calls. dict_index_build_node_ptr(): Correct a typo in a comment. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/page/page0page.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r837: page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE) calls. dict_index_build_node_ptr(): Correct a typo in a comment. storage/innobase/pars/pars0opt.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/pars/pars0pars.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r832: Add dict_table_get_col_name() in preparation for getting rid of dict_col_t::name, and use it instead of col->name everywhere. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/pars/pars0sym.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. storage/innobase/read/read0read.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/rem/rem0cmp.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/rem/rem0rec.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/row/row0ins.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/row/row0mysql.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r832: Add dict_table_get_col_name() in preparation for getting rid of dict_col_t::name, and use it instead of col->name everywhere. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/row/row0purge.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r828: Remove dict_tree_t, which should have been removed in r453. There always was a one-to-one mapping between dict_tree_t and dict_index_t. This saves 6 machine words per B-tree index in the data dictionary cache plus the memory allocation overhead. We save one mem_heap_t object per index (15 machine words). Considering the internal fragmentation of the buddy allocator in mem_area_alloc(), this should save 32 machine words per index (128 bytes on 32-bit systems and 256 bytes on 64-bit systems). (Bug #20877) struct dict_tree_struct, dict_tree_t: Remove. struct dict_index_struct: Add page and lock. dict_tree_create(): Remove. Replace the invocation with assignment to index->page and a call to rw_lock_create(&index->lock). dict_tree_free(): Remove. Replace the invocation wtih a call to rw_lock_free(&index->lock). dict_index_get_tree(): Remove. dict_tree_get_space_reserve(): Rename to dict_index_get_space_reserve() and remove the parameter, which was unused. btr_level_list_remove(): Remove the unused parameter "tree". Replace the occurrences of "tree" with "index" in names of variables, functions and data types, e.g. "dict_tree_t tree" becomes "dict_index_t index". Remove local variables "tree" or "index" of functions that needed both "tree" and "index". Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/row/row0row.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/row/row0sel.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r820: Remove dict_col_t::clust_pos. dict_col_get_clust_pos(): Add parameter clust_index. Replace the look-up with a linear search of all columns in the clustered index. row_upd_index_replace_new_col_vals(): Compute clust_index outside the loops. Compute clust_pos outside the inner loop. row_upd_changes_ord_field_binary(), row_upd_changes_first_fields_binary(): Compute clust_index outside the loops. Declare the auxiliary variables inside the loop scope. Revision r821: dict_table_t: Rename the integer field max_row_size to the Boolean field big_rows. (Bug #20877) BIG_ROW_SIZE: Move the definition from row0sel.c to dict_table_add_to_cache(). Revision r825: row_search_for_mysql(): Skip setting the next-key lock on an already delete-marked record in a clustered index where the search criteria is unique, within the same transaction (Bug #13544). Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r837: page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE) calls. dict_index_build_node_ptr(): Correct a typo in a comment. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. Revision r845: Split long lines with [] operators better. storage/innobase/row/row0uins.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/row/row0umod.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/row/row0upd.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r819: dict_col_t: Reduce ord_part to one bit. dict_index_add_to_cache(): Instead of incrementing ord_part, set it. dict_index_remove_from_cache(): Do not touch ord_part. dtype_t: Reduce mbminlen from 3 to 2 bits. row_upd(): Add a UNIV_LIKELY hint around node->in_mysql_interface. Revision r820: Remove dict_col_t::clust_pos. dict_col_get_clust_pos(): Add parameter clust_index. Replace the look-up with a linear search of all columns in the clustered index. row_upd_index_replace_new_col_vals(): Compute clust_index outside the loops. Compute clust_pos outside the inner loop. row_upd_changes_ord_field_binary(), row_upd_changes_first_fields_binary(): Compute clust_index outside the loops. Declare the auxiliary variables inside the loop scope. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. Revision r851: row_upd_sec_step(): Fix false comment. storage/innobase/row/row0vers.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/srv/srv0srv.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. Revision r832: Add dict_table_get_col_name() in preparation for getting rid of dict_col_t::name, and use it instead of col->name everywhere. Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/srv/srv0start.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/sync/sync0arr.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/sync/sync0rw.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r813: Reduce the size of the data dictionary cache. (Bug #20877) dtype_t: Remove unused field "prec", which was supposed to be used for the precision of decimal columns in stand-alone InnoDB. dtype_get_prec(): Remove. dtype_set(), dict_mem_table_add_col(): Remove parameter "prec". dtype_t: Turn all fields (mtype, prtype, len, mbminlen, mbmaxlen, len) into bit-fields. dict_table_t, dict_index_t, dict_tree_t: Omit magic_n from non-debug builds. dict_col_t: Turn ind, clust_pos, and ord_part into bit-fields. Replace the default clust_pos value ULINT_UNDEFINED with REC_MAX_N_FIELDS and replace all references to clust_pos with calls to the accessor function dict_col_get_clust_pos(). dict_field_t: Turn prefix_len and fixed_len into bit-fields. dict_tree_t: Remove pad[64]. dict_table_t: Turn the fields ibd_file_missing, tablespace_discarded, cached, flags, stat_initialized, and autoinc_inited into bit-fields. Remove does_not_fit_in_memory from non-debug builds. dict_index_t: Turn the fields trx_id_offset, n_user_defined_cols, n_uniq, n_def, n_fields, n_nullable, and cached into bit-fields. dict_foreign_struct: Turn n_fields and type into bit-fields. rw_lock_t: Turn cline, last_s_line, and last_x_line into bit-fields. Omit level unless #defined UNIV_SYNC_DEBUG. Move REC_MAX_N_FIELDS (and REC_MAX_HEAP_NO and REC_MAX_N_OWNED) from rem0rec.c to rem0types.h, as they are needed in dict0dict.ic. dict_col_get_clust_pos(): Map REC_MAX_N_FIELDS to ULINT_UNDEFINED. storage/innobase/sync/sync0sync.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/trx/trx0purge.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/trx/trx0rec.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r834: dict_col_t: Copy the fields of "dtype_t type" directly to this structure, so that all integer fields can be packed into 64 bits. (Bug #20877) dtype_t: Change the type of all bit-fields to unsigned. dict_table_get_nth_col(), dict_table_get_sys_col_noninline(), dict_table_get_sys_col(), dict_field_get_col(): Return const dict_col_t*, so that changes to dict_col_t can be detected more easily. Add const to many dict_col_t* declarations. dict_index_get_nth_type(): Replace with dict_index_get_nth_col(). dict_col_get_type(): Replace with dict_col_copy_type(). dict_col_get_min_size(), dict_col_get_max_size(), dict_col_get_fixed_size(), dict_col_get_sql_null_size(): New functions. dtype_get_at_most_n_mbchars(): Replace the parameter dtype with the parameters prtype, mbminlen, mbmaxlen. dtype_get_pad_char(), cmp_data_data(), cmp_data_data_slow(), cmp_whole_field(): Replace the dtype_t* parameter with the ulint parameters mtype, prtype. dtype_copy(): Add a const qualifier to type2 (the one being copied from). dtype_set_mblen(): Replaced with dtype_get_mblen(). dtype_get_fixed_size_low(), dtype_get_min_size_low(), dtype_get_fixed_max_low(): Replace dtype_get_fixed_size(), dtype_get_min_size(), and dtype_get_max_size(). These are used by the dict_col_get_{fixed,min,max}_size() functions. cmp_types_are_equal(): Replace with cmp_cols_are_equal(). dict_table_get_col_name(): Add a const qualifier parameter to the parameter "table". dtype_binary, dtype_binary_val: Remove. dtype_is_fixed_size(): Remove. Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/trx/trx0rseg.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/trx/trx0sys.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r829: Erase the magic number in the trx sys header using a redo-logged write; it should be redo-logged because the data structure is file-based; this patch does not fix any bug; the original erase operation was added in r781 to fix Valgrind Bug #20791 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/trx/trx0trx.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826. storage/innobase/trx/trx0undo.c: Applied innodb-5.1 snapshots ss799 and ss854 Revision r838: Revamp the line splits done in r763 and r764 that can now be done better, thanks to r826.
1431 lines
36 KiB
C
1431 lines
36 KiB
C
/******************************************************
|
|
Transaction undo log record
|
|
|
|
(c) 1996 Innobase Oy
|
|
|
|
Created 3/26/1996 Heikki Tuuri
|
|
*******************************************************/
|
|
|
|
#include "trx0rec.h"
|
|
|
|
#ifdef UNIV_NONINL
|
|
#include "trx0rec.ic"
|
|
#endif
|
|
|
|
#include "fsp0fsp.h"
|
|
#include "mach0data.h"
|
|
#include "trx0rseg.h"
|
|
#include "trx0trx.h"
|
|
#include "trx0undo.h"
|
|
#include "dict0dict.h"
|
|
#include "ut0mem.h"
|
|
#include "row0upd.h"
|
|
#include "que0que.h"
|
|
#include "trx0purge.h"
|
|
#include "row0row.h"
|
|
|
|
/*=========== UNDO LOG RECORD CREATION AND DECODING ====================*/
|
|
|
|
/**************************************************************************
|
|
Writes the mtr log entry of the inserted undo log record on the undo log
|
|
page. */
|
|
UNIV_INLINE
|
|
void
|
|
trx_undof_page_add_undo_rec_log(
|
|
/*============================*/
|
|
page_t* undo_page, /* in: undo log page */
|
|
ulint old_free, /* in: start offset of the inserted entry */
|
|
ulint new_free, /* in: end offset of the entry */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
byte* log_ptr;
|
|
const byte* log_end;
|
|
ulint len;
|
|
|
|
log_ptr = mlog_open(mtr, 11 + 13 + MLOG_BUF_MARGIN);
|
|
|
|
if (log_ptr == NULL) {
|
|
|
|
return;
|
|
}
|
|
|
|
log_end = &log_ptr[11 + 13 + MLOG_BUF_MARGIN];
|
|
log_ptr = mlog_write_initial_log_record_fast(
|
|
undo_page, MLOG_UNDO_INSERT, log_ptr, mtr);
|
|
len = new_free - old_free - 4;
|
|
|
|
mach_write_to_2(log_ptr, len);
|
|
log_ptr += 2;
|
|
|
|
if (log_ptr + len <= log_end) {
|
|
memcpy(log_ptr, undo_page + old_free + 2, len);
|
|
mlog_close(mtr, log_ptr + len);
|
|
} else {
|
|
mlog_close(mtr, log_ptr);
|
|
mlog_catenate_string(mtr, undo_page + old_free + 2, len);
|
|
}
|
|
}
|
|
|
|
/***************************************************************
|
|
Parses a redo log record of adding an undo log record. */
|
|
|
|
byte*
|
|
trx_undo_parse_add_undo_rec(
|
|
/*========================*/
|
|
/* out: end of log record or NULL */
|
|
byte* ptr, /* in: buffer */
|
|
byte* end_ptr,/* in: buffer end */
|
|
page_t* page) /* in: page or NULL */
|
|
{
|
|
ulint len;
|
|
byte* rec;
|
|
ulint first_free;
|
|
|
|
if (end_ptr < ptr + 2) {
|
|
|
|
return(NULL);
|
|
}
|
|
|
|
len = mach_read_from_2(ptr);
|
|
ptr += 2;
|
|
|
|
if (end_ptr < ptr + len) {
|
|
|
|
return(NULL);
|
|
}
|
|
|
|
if (page == NULL) {
|
|
|
|
return(ptr + len);
|
|
}
|
|
|
|
first_free = mach_read_from_2(page + TRX_UNDO_PAGE_HDR
|
|
+ TRX_UNDO_PAGE_FREE);
|
|
rec = page + first_free;
|
|
|
|
mach_write_to_2(rec, first_free + 4 + len);
|
|
mach_write_to_2(rec + 2 + len, first_free);
|
|
|
|
mach_write_to_2(page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE,
|
|
first_free + 4 + len);
|
|
ut_memcpy(rec + 2, ptr, len);
|
|
|
|
return(ptr + len);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Calculates the free space left for extending an undo log record. */
|
|
UNIV_INLINE
|
|
ulint
|
|
trx_undo_left(
|
|
/*==========*/
|
|
/* out: bytes left */
|
|
page_t* page, /* in: undo log page */
|
|
byte* ptr) /* in: pointer to page */
|
|
{
|
|
/* The '- 10' is a safety margin, in case we have some small
|
|
calculation error below */
|
|
|
|
return(UNIV_PAGE_SIZE - (ptr - page) - 10 - FIL_PAGE_DATA_END);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Reports in the undo log of an insert of a clustered index record. */
|
|
static
|
|
ulint
|
|
trx_undo_page_report_insert(
|
|
/*========================*/
|
|
/* out: offset of the inserted entry
|
|
on the page if succeed, 0 if fail */
|
|
page_t* undo_page, /* in: undo log page */
|
|
trx_t* trx, /* in: transaction */
|
|
dict_index_t* index, /* in: clustered index */
|
|
dtuple_t* clust_entry, /* in: index entry which will be
|
|
inserted to the clustered index */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint first_free;
|
|
byte* ptr;
|
|
ulint len;
|
|
dfield_t* field;
|
|
ulint flen;
|
|
ulint i;
|
|
|
|
ut_ad(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
|
|
+ TRX_UNDO_PAGE_TYPE) == TRX_UNDO_INSERT);
|
|
|
|
first_free = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
|
|
+ TRX_UNDO_PAGE_FREE);
|
|
ptr = undo_page + first_free;
|
|
|
|
ut_ad(first_free <= UNIV_PAGE_SIZE);
|
|
|
|
if (trx_undo_left(undo_page, ptr) < 30) {
|
|
|
|
/* NOTE: the value 30 must be big enough such that the general
|
|
fields written below fit on the undo log page */
|
|
|
|
return(0);
|
|
}
|
|
|
|
/* Reserve 2 bytes for the pointer to the next undo log record */
|
|
ptr += 2;
|
|
|
|
/* Store first some general parameters to the undo log */
|
|
mach_write_to_1(ptr, TRX_UNDO_INSERT_REC);
|
|
ptr++;
|
|
|
|
len = mach_dulint_write_much_compressed(ptr, trx->undo_no);
|
|
ptr += len;
|
|
|
|
len = mach_dulint_write_much_compressed(ptr, (index->table)->id);
|
|
ptr += len;
|
|
/*----------------------------------------*/
|
|
/* Store then the fields required to uniquely determine the record
|
|
to be inserted in the clustered index */
|
|
|
|
for (i = 0; i < dict_index_get_n_unique(index); i++) {
|
|
|
|
field = dtuple_get_nth_field(clust_entry, i);
|
|
|
|
flen = dfield_get_len(field);
|
|
|
|
if (trx_undo_left(undo_page, ptr) < 5) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
len = mach_write_compressed(ptr, flen);
|
|
ptr += len;
|
|
|
|
if (flen != UNIV_SQL_NULL) {
|
|
if (trx_undo_left(undo_page, ptr) < flen) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
ut_memcpy(ptr, dfield_get_data(field), flen);
|
|
ptr += flen;
|
|
}
|
|
}
|
|
|
|
if (trx_undo_left(undo_page, ptr) < 2) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
/*----------------------------------------*/
|
|
/* Write pointers to the previous and the next undo log records */
|
|
|
|
if (trx_undo_left(undo_page, ptr) < 2) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
mach_write_to_2(ptr, first_free);
|
|
ptr += 2;
|
|
|
|
mach_write_to_2(undo_page + first_free, ptr - undo_page);
|
|
|
|
mach_write_to_2(undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE,
|
|
ptr - undo_page);
|
|
|
|
/* Write the log entry to the REDO log of this change in the UNDO
|
|
log */
|
|
trx_undof_page_add_undo_rec_log(undo_page, first_free,
|
|
ptr - undo_page, mtr);
|
|
return(first_free);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Reads from an undo log record the general parameters. */
|
|
|
|
byte*
|
|
trx_undo_rec_get_pars(
|
|
/*==================*/
|
|
/* out: remaining part of undo log
|
|
record after reading these values */
|
|
trx_undo_rec_t* undo_rec, /* in: undo log record */
|
|
ulint* type, /* out: undo record type:
|
|
TRX_UNDO_INSERT_REC, ... */
|
|
ulint* cmpl_info, /* out: compiler info, relevant only
|
|
for update type records */
|
|
ibool* updated_extern, /* out: TRUE if we updated an
|
|
externally stored fild */
|
|
dulint* undo_no, /* out: undo log record number */
|
|
dulint* table_id) /* out: table id */
|
|
{
|
|
byte* ptr;
|
|
ulint len;
|
|
ulint type_cmpl;
|
|
|
|
ptr = undo_rec + 2;
|
|
|
|
type_cmpl = mach_read_from_1(ptr);
|
|
ptr++;
|
|
|
|
if (type_cmpl & TRX_UNDO_UPD_EXTERN) {
|
|
*updated_extern = TRUE;
|
|
type_cmpl -= TRX_UNDO_UPD_EXTERN;
|
|
} else {
|
|
*updated_extern = FALSE;
|
|
}
|
|
|
|
*type = type_cmpl & (TRX_UNDO_CMPL_INFO_MULT - 1);
|
|
*cmpl_info = type_cmpl / TRX_UNDO_CMPL_INFO_MULT;
|
|
|
|
*undo_no = mach_dulint_read_much_compressed(ptr);
|
|
len = mach_dulint_get_much_compressed_size(*undo_no);
|
|
ptr += len;
|
|
|
|
*table_id = mach_dulint_read_much_compressed(ptr);
|
|
len = mach_dulint_get_much_compressed_size(*table_id);
|
|
ptr += len;
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Reads from an undo log record a stored column value. */
|
|
static
|
|
byte*
|
|
trx_undo_rec_get_col_val(
|
|
/*=====================*/
|
|
/* out: remaining part of undo log record after
|
|
reading these values */
|
|
byte* ptr, /* in: pointer to remaining part of undo log record */
|
|
byte** field, /* out: pointer to stored field */
|
|
ulint* len) /* out: length of the field, or UNIV_SQL_NULL */
|
|
{
|
|
*len = mach_read_compressed(ptr);
|
|
ptr += mach_get_compressed_size(*len);
|
|
|
|
*field = ptr;
|
|
|
|
if (*len != UNIV_SQL_NULL) {
|
|
if (*len >= UNIV_EXTERN_STORAGE_FIELD) {
|
|
ptr += (*len - UNIV_EXTERN_STORAGE_FIELD);
|
|
} else {
|
|
ptr += *len;
|
|
}
|
|
}
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Builds a row reference from an undo log record. */
|
|
|
|
byte*
|
|
trx_undo_rec_get_row_ref(
|
|
/*=====================*/
|
|
/* out: pointer to remaining part of undo
|
|
record */
|
|
byte* ptr, /* in: remaining part of a copy of an undo log
|
|
record, at the start of the row reference;
|
|
NOTE that this copy of the undo log record must
|
|
be preserved as long as the row reference is
|
|
used, as we do NOT copy the data in the
|
|
record! */
|
|
dict_index_t* index, /* in: clustered index */
|
|
dtuple_t** ref, /* out, own: row reference */
|
|
mem_heap_t* heap) /* in: memory heap from which the memory
|
|
needed is allocated */
|
|
{
|
|
dfield_t* dfield;
|
|
byte* field;
|
|
ulint len;
|
|
ulint ref_len;
|
|
ulint i;
|
|
|
|
ut_ad(index && ptr && ref && heap);
|
|
ut_a(index->type & DICT_CLUSTERED);
|
|
|
|
ref_len = dict_index_get_n_unique(index);
|
|
|
|
*ref = dtuple_create(heap, ref_len);
|
|
|
|
dict_index_copy_types(*ref, index, ref_len);
|
|
|
|
for (i = 0; i < ref_len; i++) {
|
|
dfield = dtuple_get_nth_field(*ref, i);
|
|
|
|
ptr = trx_undo_rec_get_col_val(ptr, &field, &len);
|
|
|
|
dfield_set_data(dfield, field, len);
|
|
}
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Skips a row reference from an undo log record. */
|
|
|
|
byte*
|
|
trx_undo_rec_skip_row_ref(
|
|
/*======================*/
|
|
/* out: pointer to remaining part of undo
|
|
record */
|
|
byte* ptr, /* in: remaining part in update undo log
|
|
record, at the start of the row reference */
|
|
dict_index_t* index) /* in: clustered index */
|
|
{
|
|
byte* field;
|
|
ulint len;
|
|
ulint ref_len;
|
|
ulint i;
|
|
|
|
ut_ad(index && ptr);
|
|
ut_a(index->type & DICT_CLUSTERED);
|
|
|
|
ref_len = dict_index_get_n_unique(index);
|
|
|
|
for (i = 0; i < ref_len; i++) {
|
|
ptr = trx_undo_rec_get_col_val(ptr, &field, &len);
|
|
}
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Reports in the undo log of an update or delete marking of a clustered index
|
|
record. */
|
|
static
|
|
ulint
|
|
trx_undo_page_report_modify(
|
|
/*========================*/
|
|
/* out: byte offset of the inserted
|
|
undo log entry on the page if succeed,
|
|
0 if fail */
|
|
page_t* undo_page, /* in: undo log page */
|
|
trx_t* trx, /* in: transaction */
|
|
dict_index_t* index, /* in: clustered index where update or
|
|
delete marking is done */
|
|
rec_t* rec, /* in: clustered index record which
|
|
has NOT yet been modified */
|
|
const ulint* offsets, /* in: rec_get_offsets(rec, index) */
|
|
upd_t* update, /* in: update vector which tells the
|
|
columns to be updated; in the case of
|
|
a delete, this should be set to NULL */
|
|
ulint cmpl_info, /* in: compiler info on secondary
|
|
index updates */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
dict_table_t* table;
|
|
upd_field_t* upd_field;
|
|
ulint first_free;
|
|
byte* ptr;
|
|
ulint len;
|
|
byte* field;
|
|
ulint flen;
|
|
ulint pos;
|
|
dulint roll_ptr;
|
|
dulint trx_id;
|
|
ulint bits;
|
|
ulint col_no;
|
|
byte* old_ptr;
|
|
ulint type_cmpl;
|
|
byte* type_cmpl_ptr;
|
|
ulint i;
|
|
|
|
ut_a(index->type & DICT_CLUSTERED);
|
|
ut_ad(rec_offs_validate(rec, index, offsets));
|
|
ut_ad(mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
|
|
+ TRX_UNDO_PAGE_TYPE) == TRX_UNDO_UPDATE);
|
|
table = index->table;
|
|
|
|
first_free = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
|
|
+ TRX_UNDO_PAGE_FREE);
|
|
ptr = undo_page + first_free;
|
|
|
|
ut_ad(first_free <= UNIV_PAGE_SIZE);
|
|
|
|
if (trx_undo_left(undo_page, ptr) < 50) {
|
|
|
|
/* NOTE: the value 50 must be big enough so that the general
|
|
fields written below fit on the undo log page */
|
|
|
|
return(0);
|
|
}
|
|
|
|
/* Reserve 2 bytes for the pointer to the next undo log record */
|
|
ptr += 2;
|
|
|
|
/* Store first some general parameters to the undo log */
|
|
|
|
if (update) {
|
|
if (rec_get_deleted_flag(rec, dict_table_is_comp(table))) {
|
|
type_cmpl = TRX_UNDO_UPD_DEL_REC;
|
|
} else {
|
|
type_cmpl = TRX_UNDO_UPD_EXIST_REC;
|
|
}
|
|
} else {
|
|
type_cmpl = TRX_UNDO_DEL_MARK_REC;
|
|
}
|
|
|
|
type_cmpl = type_cmpl | (cmpl_info * TRX_UNDO_CMPL_INFO_MULT);
|
|
|
|
mach_write_to_1(ptr, type_cmpl);
|
|
|
|
type_cmpl_ptr = ptr;
|
|
|
|
ptr++;
|
|
len = mach_dulint_write_much_compressed(ptr, trx->undo_no);
|
|
ptr += len;
|
|
|
|
len = mach_dulint_write_much_compressed(ptr, table->id);
|
|
ptr += len;
|
|
|
|
/*----------------------------------------*/
|
|
/* Store the state of the info bits */
|
|
|
|
bits = rec_get_info_bits(rec, dict_table_is_comp(table));
|
|
mach_write_to_1(ptr, bits);
|
|
ptr += 1;
|
|
|
|
/* Store the values of the system columns */
|
|
field = rec_get_nth_field(rec, offsets,
|
|
dict_index_get_sys_col_pos(
|
|
index, DATA_TRX_ID), &len);
|
|
ut_ad(len == DATA_TRX_ID_LEN);
|
|
trx_id = trx_read_trx_id(field);
|
|
field = rec_get_nth_field(rec, offsets,
|
|
dict_index_get_sys_col_pos(
|
|
index, DATA_ROLL_PTR), &len);
|
|
ut_ad(len == DATA_ROLL_PTR_LEN);
|
|
roll_ptr = trx_read_roll_ptr(field);
|
|
|
|
len = mach_dulint_write_compressed(ptr, trx_id);
|
|
ptr += len;
|
|
|
|
len = mach_dulint_write_compressed(ptr, roll_ptr);
|
|
ptr += len;
|
|
|
|
/*----------------------------------------*/
|
|
/* Store then the fields required to uniquely determine the
|
|
record which will be modified in the clustered index */
|
|
|
|
for (i = 0; i < dict_index_get_n_unique(index); i++) {
|
|
|
|
field = rec_get_nth_field(rec, offsets, i, &flen);
|
|
|
|
if (trx_undo_left(undo_page, ptr) < 4) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
len = mach_write_compressed(ptr, flen);
|
|
ptr += len;
|
|
|
|
if (flen != UNIV_SQL_NULL) {
|
|
if (trx_undo_left(undo_page, ptr) < flen) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
ut_memcpy(ptr, field, flen);
|
|
ptr += flen;
|
|
}
|
|
}
|
|
|
|
/*----------------------------------------*/
|
|
/* Save to the undo log the old values of the columns to be updated. */
|
|
|
|
if (update) {
|
|
if (trx_undo_left(undo_page, ptr) < 5) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
len = mach_write_compressed(ptr, upd_get_n_fields(update));
|
|
ptr += len;
|
|
|
|
for (i = 0; i < upd_get_n_fields(update); i++) {
|
|
|
|
upd_field = upd_get_nth_field(update, i);
|
|
pos = upd_field->field_no;
|
|
|
|
/* Write field number to undo log */
|
|
if (trx_undo_left(undo_page, ptr) < 5) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
len = mach_write_compressed(ptr, pos);
|
|
ptr += len;
|
|
|
|
/* Save the old value of field */
|
|
field = rec_get_nth_field(rec, offsets, pos, &flen);
|
|
|
|
if (trx_undo_left(undo_page, ptr) < 5) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
if (rec_offs_nth_extern(offsets, pos)) {
|
|
/* If a field has external storage, we add
|
|
to flen the flag */
|
|
|
|
len = mach_write_compressed(
|
|
ptr,
|
|
UNIV_EXTERN_STORAGE_FIELD + flen);
|
|
|
|
/* Notify purge that it eventually has to
|
|
free the old externally stored field */
|
|
|
|
trx->update_undo->del_marks = TRUE;
|
|
|
|
*type_cmpl_ptr = *type_cmpl_ptr
|
|
| TRX_UNDO_UPD_EXTERN;
|
|
} else {
|
|
len = mach_write_compressed(ptr, flen);
|
|
}
|
|
|
|
ptr += len;
|
|
|
|
if (flen != UNIV_SQL_NULL) {
|
|
if (trx_undo_left(undo_page, ptr) < flen) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
ut_memcpy(ptr, field, flen);
|
|
ptr += flen;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*----------------------------------------*/
|
|
/* In the case of a delete marking, and also in the case of an update
|
|
where any ordering field of any index changes, store the values of all
|
|
columns which occur as ordering fields in any index. This info is used
|
|
in the purge of old versions where we use it to build and search the
|
|
delete marked index records, to look if we can remove them from the
|
|
index tree. Note that starting from 4.0.14 also externally stored
|
|
fields can be ordering in some index. But we always store at least
|
|
384 first bytes locally to the clustered index record, which means
|
|
we can construct the column prefix fields in the index from the
|
|
stored data. */
|
|
|
|
if (!update || !(cmpl_info & UPD_NODE_NO_ORD_CHANGE)) {
|
|
|
|
trx->update_undo->del_marks = TRUE;
|
|
|
|
if (trx_undo_left(undo_page, ptr) < 5) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
old_ptr = ptr;
|
|
|
|
/* Reserve 2 bytes to write the number of bytes the stored
|
|
fields take in this undo record */
|
|
|
|
ptr += 2;
|
|
|
|
for (col_no = 0; col_no < dict_table_get_n_cols(table);
|
|
col_no++) {
|
|
|
|
const dict_col_t* col
|
|
= dict_table_get_nth_col(table, col_no);
|
|
|
|
if (col->ord_part > 0) {
|
|
|
|
pos = dict_index_get_nth_col_pos(index,
|
|
col_no);
|
|
|
|
/* Write field number to undo log */
|
|
if (trx_undo_left(undo_page, ptr) < 5) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
len = mach_write_compressed(ptr, pos);
|
|
ptr += len;
|
|
|
|
/* Save the old value of field */
|
|
field = rec_get_nth_field(rec, offsets, pos,
|
|
&flen);
|
|
|
|
if (trx_undo_left(undo_page, ptr) < 5) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
len = mach_write_compressed(ptr, flen);
|
|
ptr += len;
|
|
|
|
if (flen != UNIV_SQL_NULL) {
|
|
if (trx_undo_left(undo_page, ptr)
|
|
< flen) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
ut_memcpy(ptr, field, flen);
|
|
ptr += flen;
|
|
}
|
|
}
|
|
}
|
|
|
|
mach_write_to_2(old_ptr, ptr - old_ptr);
|
|
}
|
|
|
|
/*----------------------------------------*/
|
|
/* Write pointers to the previous and the next undo log records */
|
|
if (trx_undo_left(undo_page, ptr) < 2) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
mach_write_to_2(ptr, first_free);
|
|
ptr += 2;
|
|
mach_write_to_2(undo_page + first_free, ptr - undo_page);
|
|
|
|
mach_write_to_2(undo_page + TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_FREE,
|
|
ptr - undo_page);
|
|
|
|
/* Write to the REDO log about this change in the UNDO log */
|
|
|
|
trx_undof_page_add_undo_rec_log(undo_page, first_free,
|
|
ptr - undo_page, mtr);
|
|
return(first_free);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Reads from an undo log update record the system field values of the old
|
|
version. */
|
|
|
|
byte*
|
|
trx_undo_update_rec_get_sys_cols(
|
|
/*=============================*/
|
|
/* out: remaining part of undo log
|
|
record after reading these values */
|
|
byte* ptr, /* in: remaining part of undo log
|
|
record after reading general
|
|
parameters */
|
|
dulint* trx_id, /* out: trx id */
|
|
dulint* roll_ptr, /* out: roll ptr */
|
|
ulint* info_bits) /* out: info bits state */
|
|
{
|
|
ulint len;
|
|
|
|
/* Read the state of the info bits */
|
|
*info_bits = mach_read_from_1(ptr);
|
|
ptr += 1;
|
|
|
|
/* Read the values of the system columns */
|
|
|
|
*trx_id = mach_dulint_read_compressed(ptr);
|
|
len = mach_dulint_get_compressed_size(*trx_id);
|
|
ptr += len;
|
|
|
|
*roll_ptr = mach_dulint_read_compressed(ptr);
|
|
len = mach_dulint_get_compressed_size(*roll_ptr);
|
|
ptr += len;
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Reads from an update undo log record the number of updated fields. */
|
|
UNIV_INLINE
|
|
byte*
|
|
trx_undo_update_rec_get_n_upd_fields(
|
|
/*=================================*/
|
|
/* out: remaining part of undo log record after
|
|
reading this value */
|
|
byte* ptr, /* in: pointer to remaining part of undo log record */
|
|
ulint* n) /* out: number of fields */
|
|
{
|
|
*n = mach_read_compressed(ptr);
|
|
ptr += mach_get_compressed_size(*n);
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/**************************************************************************
|
|
Reads from an update undo log record a stored field number. */
|
|
UNIV_INLINE
|
|
byte*
|
|
trx_undo_update_rec_get_field_no(
|
|
/*=============================*/
|
|
/* out: remaining part of undo log record after
|
|
reading this value */
|
|
byte* ptr, /* in: pointer to remaining part of undo log record */
|
|
ulint* field_no)/* out: field number */
|
|
{
|
|
*field_no = mach_read_compressed(ptr);
|
|
ptr += mach_get_compressed_size(*field_no);
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Builds an update vector based on a remaining part of an undo log record. */
|
|
|
|
byte*
|
|
trx_undo_update_rec_get_update(
|
|
/*===========================*/
|
|
/* out: remaining part of the record,
|
|
NULL if an error detected, which means that
|
|
the record is corrupted */
|
|
byte* ptr, /* in: remaining part in update undo log
|
|
record, after reading the row reference
|
|
NOTE that this copy of the undo log record must
|
|
be preserved as long as the update vector is
|
|
used, as we do NOT copy the data in the
|
|
record! */
|
|
dict_index_t* index, /* in: clustered index */
|
|
ulint type, /* in: TRX_UNDO_UPD_EXIST_REC,
|
|
TRX_UNDO_UPD_DEL_REC, or
|
|
TRX_UNDO_DEL_MARK_REC; in the last case,
|
|
only trx id and roll ptr fields are added to
|
|
the update vector */
|
|
dulint trx_id, /* in: transaction id from this undo record */
|
|
dulint roll_ptr,/* in: roll pointer from this undo record */
|
|
ulint info_bits,/* in: info bits from this undo record */
|
|
trx_t* trx, /* in: transaction */
|
|
mem_heap_t* heap, /* in: memory heap from which the memory
|
|
needed is allocated */
|
|
upd_t** upd) /* out, own: update vector */
|
|
{
|
|
upd_field_t* upd_field;
|
|
upd_t* update;
|
|
ulint n_fields;
|
|
byte* buf;
|
|
byte* field;
|
|
ulint len;
|
|
ulint field_no;
|
|
ulint i;
|
|
|
|
ut_a(index->type & DICT_CLUSTERED);
|
|
|
|
if (type != TRX_UNDO_DEL_MARK_REC) {
|
|
ptr = trx_undo_update_rec_get_n_upd_fields(ptr, &n_fields);
|
|
} else {
|
|
n_fields = 0;
|
|
}
|
|
|
|
update = upd_create(n_fields + 2, heap);
|
|
|
|
update->info_bits = info_bits;
|
|
|
|
/* Store first trx id and roll ptr to update vector */
|
|
|
|
upd_field = upd_get_nth_field(update, n_fields);
|
|
buf = mem_heap_alloc(heap, DATA_TRX_ID_LEN);
|
|
trx_write_trx_id(buf, trx_id);
|
|
|
|
upd_field_set_field_no(upd_field,
|
|
dict_index_get_sys_col_pos(index, DATA_TRX_ID),
|
|
index, trx);
|
|
dfield_set_data(&(upd_field->new_val), buf, DATA_TRX_ID_LEN);
|
|
|
|
upd_field = upd_get_nth_field(update, n_fields + 1);
|
|
buf = mem_heap_alloc(heap, DATA_ROLL_PTR_LEN);
|
|
trx_write_roll_ptr(buf, roll_ptr);
|
|
|
|
upd_field_set_field_no(
|
|
upd_field, dict_index_get_sys_col_pos(index, DATA_ROLL_PTR),
|
|
index, trx);
|
|
dfield_set_data(&(upd_field->new_val), buf, DATA_ROLL_PTR_LEN);
|
|
|
|
/* Store then the updated ordinary columns to the update vector */
|
|
|
|
for (i = 0; i < n_fields; i++) {
|
|
|
|
ptr = trx_undo_update_rec_get_field_no(ptr, &field_no);
|
|
|
|
if (field_no >= dict_index_get_n_fields(index)) {
|
|
fprintf(stderr,
|
|
"InnoDB: Error: trying to access"
|
|
" update undo rec field %lu in ",
|
|
(ulong) field_no);
|
|
dict_index_name_print(stderr, trx, index);
|
|
fprintf(stderr, "\n"
|
|
"InnoDB: but index has only %lu fields\n"
|
|
"InnoDB: Submit a detailed bug report"
|
|
" to http://bugs.mysql.com\n"
|
|
"InnoDB: Run also CHECK TABLE ",
|
|
(ulong) dict_index_get_n_fields(index));
|
|
ut_print_name(stderr, trx, TRUE, index->table_name);
|
|
fprintf(stderr, "\n"
|
|
"InnoDB: n_fields = %lu, i = %lu, ptr %p\n",
|
|
(ulong) n_fields, (ulong) i, ptr);
|
|
return(NULL);
|
|
}
|
|
|
|
ptr = trx_undo_rec_get_col_val(ptr, &field, &len);
|
|
|
|
upd_field = upd_get_nth_field(update, i);
|
|
|
|
upd_field_set_field_no(upd_field, field_no, index, trx);
|
|
|
|
if (len != UNIV_SQL_NULL && len >= UNIV_EXTERN_STORAGE_FIELD) {
|
|
|
|
upd_field->extern_storage = TRUE;
|
|
|
|
len -= UNIV_EXTERN_STORAGE_FIELD;
|
|
}
|
|
|
|
dfield_set_data(&(upd_field->new_val), field, len);
|
|
}
|
|
|
|
*upd = update;
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Builds a partial row from an update undo log record. It contains the
|
|
columns which occur as ordering in any index of the table. */
|
|
|
|
byte*
|
|
trx_undo_rec_get_partial_row(
|
|
/*=========================*/
|
|
/* out: pointer to remaining part of undo
|
|
record */
|
|
byte* ptr, /* in: remaining part in update undo log
|
|
record of a suitable type, at the start of
|
|
the stored index columns;
|
|
NOTE that this copy of the undo log record must
|
|
be preserved as long as the partial row is
|
|
used, as we do NOT copy the data in the
|
|
record! */
|
|
dict_index_t* index, /* in: clustered index */
|
|
dtuple_t** row, /* out, own: partial row */
|
|
mem_heap_t* heap) /* in: memory heap from which the memory
|
|
needed is allocated */
|
|
{
|
|
dfield_t* dfield;
|
|
byte* field;
|
|
ulint len;
|
|
ulint field_no;
|
|
ulint col_no;
|
|
ulint row_len;
|
|
ulint total_len;
|
|
byte* start_ptr;
|
|
ulint i;
|
|
|
|
ut_ad(index && ptr && row && heap);
|
|
|
|
row_len = dict_table_get_n_cols(index->table);
|
|
|
|
*row = dtuple_create(heap, row_len);
|
|
|
|
dict_table_copy_types(*row, index->table);
|
|
|
|
start_ptr = ptr;
|
|
|
|
total_len = mach_read_from_2(ptr);
|
|
ptr += 2;
|
|
|
|
for (i = 0;; i++) {
|
|
|
|
if (ptr == start_ptr + total_len) {
|
|
|
|
break;
|
|
}
|
|
|
|
ptr = trx_undo_update_rec_get_field_no(ptr, &field_no);
|
|
|
|
col_no = dict_index_get_nth_col_no(index, field_no);
|
|
|
|
ptr = trx_undo_rec_get_col_val(ptr, &field, &len);
|
|
|
|
dfield = dtuple_get_nth_field(*row, col_no);
|
|
|
|
dfield_set_data(dfield, field, len);
|
|
}
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/***************************************************************************
|
|
Erases the unused undo log page end. */
|
|
static
|
|
void
|
|
trx_undo_erase_page_end(
|
|
/*====================*/
|
|
page_t* undo_page, /* in: undo page whose end to erase */
|
|
mtr_t* mtr) /* in: mtr */
|
|
{
|
|
ulint first_free;
|
|
|
|
first_free = mach_read_from_2(undo_page + TRX_UNDO_PAGE_HDR
|
|
+ TRX_UNDO_PAGE_FREE);
|
|
memset(undo_page + first_free, 0xff,
|
|
(UNIV_PAGE_SIZE - FIL_PAGE_DATA_END) - first_free);
|
|
|
|
mlog_write_initial_log_record(undo_page, MLOG_UNDO_ERASE_END, mtr);
|
|
}
|
|
|
|
/***************************************************************
|
|
Parses a redo log record of erasing of an undo page end. */
|
|
|
|
byte*
|
|
trx_undo_parse_erase_page_end(
|
|
/*==========================*/
|
|
/* out: end of log record or NULL */
|
|
byte* ptr, /* in: buffer */
|
|
byte* end_ptr __attribute__((unused)), /* in: buffer end */
|
|
page_t* page, /* in: page or NULL */
|
|
mtr_t* mtr) /* in: mtr or NULL */
|
|
{
|
|
ut_ad(ptr && end_ptr);
|
|
|
|
if (page == NULL) {
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
trx_undo_erase_page_end(page, mtr);
|
|
|
|
return(ptr);
|
|
}
|
|
|
|
/***************************************************************************
|
|
Writes information to an undo log about an insert, update, or a delete marking
|
|
of a clustered index record. This information is used in a rollback of the
|
|
transaction and in consistent reads that must look to the history of this
|
|
transaction. */
|
|
|
|
ulint
|
|
trx_undo_report_row_operation(
|
|
/*==========================*/
|
|
/* out: DB_SUCCESS or error code */
|
|
ulint flags, /* in: if BTR_NO_UNDO_LOG_FLAG bit is
|
|
set, does nothing */
|
|
ulint op_type, /* in: TRX_UNDO_INSERT_OP or
|
|
TRX_UNDO_MODIFY_OP */
|
|
que_thr_t* thr, /* in: query thread */
|
|
dict_index_t* index, /* in: clustered index */
|
|
dtuple_t* clust_entry, /* in: in the case of an insert,
|
|
index entry to insert into the
|
|
clustered index, otherwise NULL */
|
|
upd_t* update, /* in: in the case of an update,
|
|
the update vector, otherwise NULL */
|
|
ulint cmpl_info, /* in: compiler info on secondary
|
|
index updates */
|
|
rec_t* rec, /* in: in case of an update or delete
|
|
marking, the record in the clustered
|
|
index, otherwise NULL */
|
|
dulint* roll_ptr) /* out: rollback pointer to the
|
|
inserted undo log record,
|
|
ut_dulint_zero if BTR_NO_UNDO_LOG
|
|
flag was specified */
|
|
{
|
|
trx_t* trx;
|
|
trx_undo_t* undo;
|
|
page_t* undo_page;
|
|
ulint offset;
|
|
ulint page_no;
|
|
ibool is_insert;
|
|
trx_rseg_t* rseg;
|
|
mtr_t mtr;
|
|
mem_heap_t* heap = NULL;
|
|
ulint offsets_[REC_OFFS_NORMAL_SIZE];
|
|
ulint* offsets = offsets_;
|
|
*offsets_ = (sizeof offsets_) / sizeof *offsets_;
|
|
|
|
ut_a(index->type & DICT_CLUSTERED);
|
|
|
|
if (flags & BTR_NO_UNDO_LOG_FLAG) {
|
|
|
|
*roll_ptr = ut_dulint_zero;
|
|
|
|
return(DB_SUCCESS);
|
|
}
|
|
|
|
ut_ad(thr);
|
|
ut_ad((op_type != TRX_UNDO_INSERT_OP)
|
|
|| (clust_entry && !update && !rec));
|
|
|
|
trx = thr_get_trx(thr);
|
|
rseg = trx->rseg;
|
|
|
|
mutex_enter(&(trx->undo_mutex));
|
|
|
|
/* If the undo log is not assigned yet, assign one */
|
|
|
|
if (op_type == TRX_UNDO_INSERT_OP) {
|
|
|
|
if (trx->insert_undo == NULL) {
|
|
|
|
trx_undo_assign_undo(trx, TRX_UNDO_INSERT);
|
|
}
|
|
|
|
undo = trx->insert_undo;
|
|
is_insert = TRUE;
|
|
} else {
|
|
ut_ad(op_type == TRX_UNDO_MODIFY_OP);
|
|
|
|
if (trx->update_undo == NULL) {
|
|
|
|
trx_undo_assign_undo(trx, TRX_UNDO_UPDATE);
|
|
|
|
}
|
|
|
|
undo = trx->update_undo;
|
|
is_insert = FALSE;
|
|
}
|
|
|
|
if (undo == NULL) {
|
|
/* Did not succeed: out of space */
|
|
mutex_exit(&(trx->undo_mutex));
|
|
|
|
return(DB_OUT_OF_FILE_SPACE);
|
|
}
|
|
|
|
page_no = undo->last_page_no;
|
|
|
|
mtr_start(&mtr);
|
|
|
|
for (;;) {
|
|
undo_page = buf_page_get_gen(undo->space, page_no,
|
|
RW_X_LATCH, undo->guess_page,
|
|
BUF_GET,
|
|
__FILE__, __LINE__,
|
|
&mtr);
|
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
buf_page_dbg_add_level(undo_page, SYNC_TRX_UNDO_PAGE);
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
if (op_type == TRX_UNDO_INSERT_OP) {
|
|
offset = trx_undo_page_report_insert(
|
|
undo_page, trx, index, clust_entry, &mtr);
|
|
} else {
|
|
offsets = rec_get_offsets(rec, index, offsets,
|
|
ULINT_UNDEFINED, &heap);
|
|
offset = trx_undo_page_report_modify(
|
|
undo_page, trx, index, rec, offsets, update,
|
|
cmpl_info, &mtr);
|
|
}
|
|
|
|
if (offset == 0) {
|
|
/* The record did not fit on the page. We erase the
|
|
end segment of the undo log page and write a log
|
|
record of it to to ensure deterministic contents. */
|
|
|
|
trx_undo_erase_page_end(undo_page, &mtr);
|
|
}
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
if (offset != 0) {
|
|
/* Success */
|
|
|
|
break;
|
|
}
|
|
|
|
ut_ad(page_no == undo->last_page_no);
|
|
|
|
/* We have to extend the undo log by one page */
|
|
|
|
mtr_start(&mtr);
|
|
|
|
/* When we add a page to an undo log, this is analogous to
|
|
a pessimistic insert in a B-tree, and we must reserve the
|
|
counterpart of the tree latch, which is the rseg mutex. */
|
|
|
|
mutex_enter(&(rseg->mutex));
|
|
|
|
page_no = trx_undo_add_page(trx, undo, &mtr);
|
|
|
|
mutex_exit(&(rseg->mutex));
|
|
|
|
if (page_no == FIL_NULL) {
|
|
/* Did not succeed: out of space */
|
|
|
|
mutex_exit(&(trx->undo_mutex));
|
|
mtr_commit(&mtr);
|
|
if (UNIV_LIKELY_NULL(heap)) {
|
|
mem_heap_free(heap);
|
|
}
|
|
return(DB_OUT_OF_FILE_SPACE);
|
|
}
|
|
}
|
|
|
|
undo->empty = FALSE;
|
|
undo->top_page_no = page_no;
|
|
undo->top_offset = offset;
|
|
undo->top_undo_no = trx->undo_no;
|
|
undo->guess_page = undo_page;
|
|
|
|
UT_DULINT_INC(trx->undo_no);
|
|
|
|
mutex_exit(&(trx->undo_mutex));
|
|
|
|
*roll_ptr = trx_undo_build_roll_ptr(is_insert, rseg->id, page_no,
|
|
offset);
|
|
if (UNIV_LIKELY_NULL(heap)) {
|
|
mem_heap_free(heap);
|
|
}
|
|
return(DB_SUCCESS);
|
|
}
|
|
|
|
/*============== BUILDING PREVIOUS VERSION OF A RECORD ===============*/
|
|
|
|
/**********************************************************************
|
|
Copies an undo record to heap. This function can be called if we know that
|
|
the undo log record exists. */
|
|
|
|
trx_undo_rec_t*
|
|
trx_undo_get_undo_rec_low(
|
|
/*======================*/
|
|
/* out, own: copy of the record */
|
|
dulint roll_ptr, /* in: roll pointer to record */
|
|
mem_heap_t* heap) /* in: memory heap where copied */
|
|
{
|
|
trx_undo_rec_t* undo_rec;
|
|
ulint rseg_id;
|
|
ulint page_no;
|
|
ulint offset;
|
|
page_t* undo_page;
|
|
trx_rseg_t* rseg;
|
|
ibool is_insert;
|
|
mtr_t mtr;
|
|
|
|
trx_undo_decode_roll_ptr(roll_ptr, &is_insert, &rseg_id, &page_no,
|
|
&offset);
|
|
rseg = trx_rseg_get_on_id(rseg_id);
|
|
|
|
mtr_start(&mtr);
|
|
|
|
undo_page = trx_undo_page_get_s_latched(rseg->space, page_no, &mtr);
|
|
|
|
undo_rec = trx_undo_rec_copy(undo_page + offset, heap);
|
|
|
|
mtr_commit(&mtr);
|
|
|
|
return(undo_rec);
|
|
}
|
|
|
|
/**********************************************************************
|
|
Copies an undo record to heap. */
|
|
|
|
ulint
|
|
trx_undo_get_undo_rec(
|
|
/*==================*/
|
|
/* out: DB_SUCCESS, or
|
|
DB_MISSING_HISTORY if the undo log
|
|
has been truncated and we cannot
|
|
fetch the old version; NOTE: the
|
|
caller must have latches on the
|
|
clustered index page and purge_view */
|
|
dulint roll_ptr, /* in: roll pointer to record */
|
|
dulint trx_id, /* in: id of the trx that generated
|
|
the roll pointer: it points to an
|
|
undo log of this transaction */
|
|
trx_undo_rec_t** undo_rec, /* out, own: copy of the record */
|
|
mem_heap_t* heap) /* in: memory heap where copied */
|
|
{
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
|
|
if (!trx_purge_update_undo_must_exist(trx_id)) {
|
|
|
|
/* It may be that the necessary undo log has already been
|
|
deleted */
|
|
|
|
return(DB_MISSING_HISTORY);
|
|
}
|
|
|
|
*undo_rec = trx_undo_get_undo_rec_low(roll_ptr, heap);
|
|
|
|
return(DB_SUCCESS);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Build a previous version of a clustered index record. This function checks
|
|
that the caller has a latch on the index page of the clustered index record
|
|
and an s-latch on the purge_view. This guarantees that the stack of versions
|
|
is locked. */
|
|
|
|
ulint
|
|
trx_undo_prev_version_build(
|
|
/*========================*/
|
|
/* out: DB_SUCCESS, or DB_MISSING_HISTORY if
|
|
the previous version is not >= purge_view,
|
|
which means that it may have been removed,
|
|
DB_ERROR if corrupted record */
|
|
rec_t* index_rec,/* in: clustered index record in the
|
|
index tree */
|
|
mtr_t* index_mtr __attribute__((unused)),
|
|
/* in: mtr which contains the latch to
|
|
index_rec page and purge_view */
|
|
rec_t* rec, /* in: version of a clustered index record */
|
|
dict_index_t* index, /* in: clustered index */
|
|
ulint* offsets,/* in: rec_get_offsets(rec, index) */
|
|
mem_heap_t* heap, /* in: memory heap from which the memory
|
|
needed is allocated */
|
|
rec_t** old_vers)/* out, own: previous version, or NULL if
|
|
rec is the first inserted version, or if
|
|
history data has been deleted */
|
|
{
|
|
trx_undo_rec_t* undo_rec;
|
|
dtuple_t* entry;
|
|
dulint rec_trx_id;
|
|
ulint type;
|
|
dulint undo_no;
|
|
dulint table_id;
|
|
dulint trx_id;
|
|
dulint roll_ptr;
|
|
dulint old_roll_ptr;
|
|
upd_t* update;
|
|
byte* ptr;
|
|
ulint info_bits;
|
|
ulint cmpl_info;
|
|
ibool dummy_extern;
|
|
byte* buf;
|
|
ulint err;
|
|
#ifdef UNIV_SYNC_DEBUG
|
|
ut_ad(rw_lock_own(&(purge_sys->latch), RW_LOCK_SHARED));
|
|
#endif /* UNIV_SYNC_DEBUG */
|
|
ut_ad(mtr_memo_contains(index_mtr, buf_block_align(index_rec),
|
|
MTR_MEMO_PAGE_S_FIX)
|
|
|| mtr_memo_contains(index_mtr, buf_block_align(index_rec),
|
|
MTR_MEMO_PAGE_X_FIX));
|
|
ut_ad(rec_offs_validate(rec, index, offsets));
|
|
|
|
if (!(index->type & DICT_CLUSTERED)) {
|
|
fprintf(stderr, "InnoDB: Error: trying to access"
|
|
" update undo rec for non-clustered index %s\n"
|
|
"InnoDB: Submit a detailed bug report to"
|
|
" http://bugs.mysql.com\n"
|
|
"InnoDB: index record ", index->name);
|
|
rec_print(stderr, index_rec, index);
|
|
fputs("\n"
|
|
"InnoDB: record version ", stderr);
|
|
rec_print_new(stderr, rec, offsets);
|
|
putc('\n', stderr);
|
|
return(DB_ERROR);
|
|
}
|
|
|
|
roll_ptr = row_get_rec_roll_ptr(rec, index, offsets);
|
|
old_roll_ptr = roll_ptr;
|
|
|
|
*old_vers = NULL;
|
|
|
|
if (trx_undo_roll_ptr_is_insert(roll_ptr)) {
|
|
|
|
/* The record rec is the first inserted version */
|
|
|
|
return(DB_SUCCESS);
|
|
}
|
|
|
|
rec_trx_id = row_get_rec_trx_id(rec, index, offsets);
|
|
|
|
err = trx_undo_get_undo_rec(roll_ptr, rec_trx_id, &undo_rec, heap);
|
|
|
|
if (err != DB_SUCCESS) {
|
|
|
|
return(err);
|
|
}
|
|
|
|
ptr = trx_undo_rec_get_pars(undo_rec, &type, &cmpl_info,
|
|
&dummy_extern, &undo_no, &table_id);
|
|
|
|
ptr = trx_undo_update_rec_get_sys_cols(ptr, &trx_id, &roll_ptr,
|
|
&info_bits);
|
|
ptr = trx_undo_rec_skip_row_ref(ptr, index);
|
|
|
|
ptr = trx_undo_update_rec_get_update(ptr, index, type, trx_id,
|
|
roll_ptr, info_bits,
|
|
NULL, heap, &update);
|
|
|
|
if (ut_dulint_cmp(table_id, index->table->id) != 0) {
|
|
ptr = NULL;
|
|
|
|
fprintf(stderr,
|
|
"InnoDB: Error: trying to access update undo rec"
|
|
" for table %s\n"
|
|
"InnoDB: but the table id in the"
|
|
" undo record is wrong\n"
|
|
"InnoDB: Submit a detailed bug report"
|
|
" to http://bugs.mysql.com\n"
|
|
"InnoDB: Run also CHECK TABLE %s\n",
|
|
index->table_name, index->table_name);
|
|
}
|
|
|
|
if (ptr == NULL) {
|
|
/* The record was corrupted, return an error; these printfs
|
|
should catch an elusive bug in row_vers_old_has_index_entry */
|
|
|
|
fprintf(stderr,
|
|
"InnoDB: table %s, index %s, n_uniq %lu\n"
|
|
"InnoDB: undo rec address %p, type %lu cmpl_info %lu\n"
|
|
"InnoDB: undo rec table id %lu %lu,"
|
|
" index table id %lu %lu\n"
|
|
"InnoDB: dump of 150 bytes in undo rec: ",
|
|
index->table_name, index->name,
|
|
(ulong) dict_index_get_n_unique(index),
|
|
undo_rec, (ulong) type, (ulong) cmpl_info,
|
|
(ulong) ut_dulint_get_high(table_id),
|
|
(ulong) ut_dulint_get_low(table_id),
|
|
(ulong) ut_dulint_get_high(index->table->id),
|
|
(ulong) ut_dulint_get_low(index->table->id));
|
|
ut_print_buf(stderr, undo_rec, 150);
|
|
fputs("\n"
|
|
"InnoDB: index record ", stderr);
|
|
rec_print(stderr, index_rec, index);
|
|
fputs("\n"
|
|
"InnoDB: record version ", stderr);
|
|
rec_print_new(stderr, rec, offsets);
|
|
fprintf(stderr, "\n"
|
|
"InnoDB: Record trx id %lu %lu, update rec"
|
|
" trx id %lu %lu\n"
|
|
"InnoDB: Roll ptr in rec %lu %lu, in update rec"
|
|
" %lu %lu\n",
|
|
(ulong) ut_dulint_get_high(rec_trx_id),
|
|
(ulong) ut_dulint_get_low(rec_trx_id),
|
|
(ulong) ut_dulint_get_high(trx_id),
|
|
(ulong) ut_dulint_get_low(trx_id),
|
|
(ulong) ut_dulint_get_high(old_roll_ptr),
|
|
(ulong) ut_dulint_get_low(old_roll_ptr),
|
|
(ulong) ut_dulint_get_high(roll_ptr),
|
|
(ulong) ut_dulint_get_low(roll_ptr));
|
|
|
|
trx_purge_sys_print();
|
|
return(DB_ERROR);
|
|
}
|
|
|
|
if (row_upd_changes_field_size_or_external(index, offsets, update)) {
|
|
ulint* ext_vect;
|
|
ulint n_ext_vect;
|
|
|
|
/* We have to set the appropriate extern storage bits in the
|
|
old version of the record: the extern bits in rec for those
|
|
fields that update does NOT update, as well as the the bits for
|
|
those fields that update updates to become externally stored
|
|
fields. Store the info to ext_vect: */
|
|
|
|
ext_vect = mem_alloc(sizeof(ulint)
|
|
* rec_offs_n_fields(offsets));
|
|
n_ext_vect = btr_push_update_extern_fields(ext_vect, offsets,
|
|
update);
|
|
entry = row_rec_to_index_entry(ROW_COPY_DATA, index, rec,
|
|
heap);
|
|
row_upd_index_replace_new_col_vals(entry, index, update, heap);
|
|
|
|
buf = mem_heap_alloc(heap,
|
|
rec_get_converted_size(index, entry));
|
|
|
|
*old_vers = rec_convert_dtuple_to_rec(buf, index, entry);
|
|
|
|
/* Now set the extern bits in the old version of the record */
|
|
rec_set_field_extern_bits(*old_vers, index,
|
|
ext_vect, n_ext_vect, NULL);
|
|
mem_free(ext_vect);
|
|
} else {
|
|
buf = mem_heap_alloc(heap, rec_offs_size(offsets));
|
|
*old_vers = rec_copy(buf, rec, offsets);
|
|
rec_offs_make_valid(*old_vers, index, offsets);
|
|
row_upd_rec_in_place(*old_vers, offsets, update);
|
|
}
|
|
|
|
return(DB_SUCCESS);
|
|
}
|