| MySQL 5.6.14 Source Code Document
    | 
#include "univ.i"#include "data0data.h"#include "dict0types.h"#include "trx0types.h"#include "que0types.h"#include "mtr0mtr.h"#include "rem0types.h"#include "rem0rec.h"#include "read0types.h"#include "btr0types.h"#include "row0mysql.h"#include "lock0types.h"#include "srv0srv.h"

Go to the source code of this file.
| Classes | |
| struct | mtuple_t | 
| struct | row_merge_buf_t | 
| struct | merge_file_t | 
| struct | index_field_t | 
| struct | index_def_t | 
| struct | row_merge_dup_t | 
| Typedefs | |
| typedef byte | row_merge_block_t | 
| Block size for I/O operations in merge sort. | |
| typedef byte | mrec_buf_t [UNIV_PAGE_SIZE_MAX] | 
| Secondary buffer for I/O operations of merge records. | |
| typedef byte | mrec_t | 
| Merge record in row_merge_block_t. | |
| Variables | |
| UNIV_INTERN dberr_t | warn_unused_result | 
| UNIV_INTERN row_merge_buf_t | nonnull | 
| UNIV_INTERN row_merge_buf_t | malloc | 
Index build routines using a merge sort
Created 13/06/2005 Jan Lindstrom
Definition in file row0merge.h.
| typedef byte mrec_buf_t[UNIV_PAGE_SIZE_MAX] | 
Secondary buffer for I/O operations of merge records.
This buffer is used for writing or reading a record that spans two row_merge_block_t. Thus, it must be able to hold one merge record, whose maximum size is the same as the minimum size of row_merge_block_t.
Definition at line 61 of file row0merge.h.
| typedef byte mrec_t | 
Merge record in row_merge_block_t.
The format is the same as a record in ROW_FORMAT=COMPACT with the exception that the REC_N_NEW_EXTRA_BYTES are omitted.
Definition at line 67 of file row0merge.h.
| typedef byte row_merge_block_t | 
Block size for I/O operations in merge sort.
The minimum is UNIV_PAGE_SIZE, or page_get_free_space_of_empty() rounded to a power of 2.
When not creating a PRIMARY KEY that contains column prefixes, this can be set as small as UNIV_PAGE_SIZE / 2.
Definition at line 44 of file row0merge.h.
| UNIV_INTERN char* row_make_new_pathname | ( | dict_table_t * | table, | 
| const char * | new_name | ||
| ) | 
Provide a new pathname for a table that is being renamed if it belongs to a file-per-table tablespace. The caller is responsible for freeing the memory allocated for the return value.
| table | in: table to be renamed | 
| UNIV_INTERN row_merge_buf_t* row_merge_buf_create | ( | dict_index_t * | index | ) | 
Allocate a sort buffer.
| index | in: secondary index | 

| UNIV_INTERN row_merge_buf_t* row_merge_buf_empty | ( | row_merge_buf_t * | buf | ) | 
Empty a sort buffer.
| buf | in,own: sort buffer | 

| UNIV_INTERN void row_merge_buf_free | ( | row_merge_buf_t * | buf | ) | 
Deallocate a sort buffer.
| buf | in,own: sort buffer to be freed | 

| UNIV_INTERN void row_merge_buf_sort | ( | row_merge_buf_t * | buf, | 
| row_merge_dup_t * | dup | ||
| ) | 
Sort a buffer.
| buf | in/out: sort buffer | 
| dup | in/out: reporter of duplicates (NULL if non-unique index) | 

| UNIV_INTERN void row_merge_buf_write | ( | const row_merge_buf_t * | buf, | 
| const merge_file_t * | of, | ||
| row_merge_block_t * | block | ||
| ) | 
Write a buffer to a block.
| buf | in: sorted buffer | 
| of | in: output file | 
| block | out: buffer for writing to file | 

| UNIV_INTERN dberr_t row_merge_build_indexes | ( | trx_t * | trx, | 
| dict_table_t * | old_table, | ||
| dict_table_t * | new_table, | ||
| bool | online, | ||
| dict_index_t ** | indexes, | ||
| const ulint * | key_numbers, | ||
| ulint | n_indexes, | ||
| struct TABLE * | table, | ||
| const dtuple_t * | add_cols, | ||
| const ulint * | col_map, | ||
| ulint | add_autoinc, | ||
| ib_sequence_t & | sequence | ||
| ) | 
Build indexes on a table by reading a clustered index, creating a temporary file containing index entries, merge sorting these index entries and inserting sorted index entries to indexes.
| trx | in: transaction | 
| old_table | in: table where rows are read from | 
| new_table | in: table where indexes are created; identical to old_table unless creating a PRIMARY KEY | 
| online | in: true if creating indexes online | 
| indexes | in: indexes to be created | 
| key_numbers | in: MySQL key numbers | 
| n_indexes | in: size of indexes[] | 
| table | in/out: MySQL table, for reporting erroneous key value if applicable | 
| add_cols | in: default values of added columns, or NULL | 
| col_map | in: mapping of old column numbers to new ones, or NULL if old_table == new_table | 
| add_autoinc | in: number of added AUTO_INCREMENT column, or ULINT_UNDEFINED if none is added | 
| sequence | in/out: autoinc sequence | 
| UNIV_INTERN dict_index_t* row_merge_create_index | ( | trx_t * | trx, | 
| dict_table_t * | table, | ||
| const index_def_t * | index_def | ||
| ) | 
Create the index and load in to the dictionary.
| trx | in/out: trx (sets error_state) | 
| table | in: the index is on this table | 
| UNIV_INTERN void row_merge_drop_indexes | ( | trx_t * | trx, | 
| dict_table_t * | table, | ||
| ibool | locked | ||
| ) | 
Drop those indexes which were created before an error occurred. The data dictionary must have been locked exclusively by the caller, because the transaction will not be committed.
| trx | in/out: transaction | 
| table | in/out: table containing the indexes | 
| locked | in: TRUE=table locked, FALSE=may need to do a lazy drop | 
| UNIV_INTERN void row_merge_drop_indexes_dict | ( | trx_t * | trx, | 
| table_id_t | table_id | ||
| ) | 
Drop indexes that were created before an error occurred. The data dictionary must have been locked exclusively by the caller, because the transaction will not be committed.
| trx | in/out: dictionary transaction | 
| table_id | in: table identifier | 
| UNIV_INTERN dberr_t row_merge_drop_table | ( | trx_t * | trx, | 
| dict_table_t * | table | ||
| ) | 
Drop a table. The caller must have ensured that the background stats thread is not processing the table. This can be done by calling dict_stats_wait_bg_to_stop_using_table() after locking the dictionary and before calling this function.
| trx | in: transaction | 
| table | in: table instance to drop | 
| UNIV_INTERN void row_merge_drop_temp_indexes | ( | void | ) | 
Drop all partially created indexes during crash recovery.

| UNIV_INTERN void row_merge_dup_report | ( | row_merge_dup_t * | dup, | 
| const dfield_t * | entry | ||
| ) | 
Report a duplicate key.
| dup | in/out: for reporting duplicates | 
| entry | in: duplicate index entry | 
| UNIV_INTERN int row_merge_file_create | ( | merge_file_t * | merge_file | ) | 
Create a merge file.
| merge_file | out: merge file structure | 

| UNIV_INTERN int row_merge_file_create_low | ( | void | ) | 
Creates temporary merge files, and if UNIV_PFS_IO defined, register the file descriptor with Performance Schema.

| UNIV_INTERN void row_merge_file_destroy | ( | merge_file_t * | merge_file | ) | 
Destroy a merge file.
| merge_file | in/out: merge file structure | 

| UNIV_INTERN void row_merge_file_destroy_low | ( | int | fd | ) | 
Destroy a merge file. And de-register the file from Performance Schema if UNIV_PFS_IO is defined. in: merge file descriptor
| UNIV_INTERN ibool row_merge_is_index_usable | ( | const trx_t * | trx, | 
| const dict_index_t * | index | ||
| ) | 
Check if a transaction can use an index.
| trx | in: transaction | 
| UNIV_INTERN dberr_t row_merge_lock_table | ( | trx_t * | trx, | 
| dict_table_t * | table, | ||
| enum lock_mode | mode | ||
| ) | 
Sets an exclusive lock on a table, for the duration of creating indexes.
| trx | in/out: transaction | 
| table | in: table to lock | 
| mode | in: LOCK_X or LOCK_S | 
| UNIV_INTERN ibool row_merge_read | ( | int | fd, | 
| ulint | offset, | ||
| row_merge_block_t * | buf | ||
| ) | 
Read a merge block from the file system.
| fd | in: file descriptor | 
| offset | in: offset where to read in number of row_merge_block_t elements | 
| UNIV_INTERN const byte* row_merge_read_rec | ( | row_merge_block_t * | block, | 
| mrec_buf_t * | buf, | ||
| const byte * | b, | ||
| const dict_index_t * | index, | ||
| int | fd, | ||
| ulint * | foffs, | ||
| const mrec_t ** | mrec, | ||
| ulint * | offsets | ||
| ) | 
Read a merge record.
| block | in/out: file buffer | 
| buf | in/out: secondary buffer | 
| b | in: pointer to record | 
| index | in: index of the record | 
| fd | in: file descriptor | 
| foffs | in/out: file offset | 
| mrec | out: pointer to merge record, or NULL on end of list (non-NULL on I/O error) | 
| offsets | out: offsets of mrec | 
| UNIV_INTERN dberr_t row_merge_rename_index_to_add | ( | trx_t * | trx, | 
| table_id_t | table_id, | ||
| index_id_t | index_id | ||
| ) | 
Rename an index in the dictionary that was created. The data dictionary must have been locked exclusively by the caller, because the transaction will not be committed.
| trx | in/out: transaction | 
| table_id | in: table identifier | 
| index_id | in: index identifier | 
| UNIV_INTERN dberr_t row_merge_rename_index_to_drop | ( | trx_t * | trx, | 
| table_id_t | table_id, | ||
| index_id_t | index_id | ||
| ) | 
Rename an index in the dictionary that is to be dropped. The data dictionary must have been locked exclusively by the caller, because the transaction will not be committed.
| trx | in/out: transaction | 
| table_id | in: table identifier | 
| index_id | in: index identifier | 
| UNIV_INTERN dberr_t row_merge_rename_tables_dict | ( | dict_table_t * | old_table, | 
| dict_table_t * | new_table, | ||
| const char * | tmp_name, | ||
| trx_t * | trx | ||
| ) | 
Rename the tables in the data dictionary. The data dictionary must have been locked exclusively by the caller, because the transaction will not be committed.
| old_table | in/out: old table, renamed to tmp_name | 
| new_table | in/out: new table, renamed to old_table->name | 
| tmp_name | in: new name for old_table | 
| trx | in/out: dictionary transaction | 
| UNIV_INTERN dberr_t row_merge_sort | ( | trx_t * | trx, | 
| const row_merge_dup_t * | dup, | ||
| merge_file_t * | file, | ||
| row_merge_block_t * | block, | ||
| int * | tmpfd | ||
| ) | 
Merge disk files.
| trx | in: transaction | 
| dup | in: descriptor of index being created | 
| file | in/out: file containing index entries | 
| block | in/out: 3 buffers | 
| tmpfd | in/out: temporary file handle | 

| UNIV_INTERN ibool row_merge_write | ( | int | fd, | 
| ulint | offset, | ||
| const void * | buf | ||
| ) | 
Write a merge block to the file system.
| fd | in: file descriptor | 
| offset | in: offset where to write, in number of row_merge_block_t elements | 
