mariadb/storage/xtradb/include/row0merge.h

459 lines
16 KiB
C
Raw Normal View History

2009-03-25 23:11:11 -07:00
/*****************************************************************************
2016-08-10 19:24:58 +02:00
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
MDEV-12634: Uninitialised ROW_MERGE_RESERVE_SIZE bytes written to tem… …porary file Fixed by removing writing key version to start of every block that was encrypted. Instead we will use single key version from log_sys crypt info. After this MDEV also blocks writen to row log are encrypted and blocks read from row log aren decrypted if encryption is configured for the table. innodb_status_variables[], struct srv_stats_t Added status variables for merge block and row log block encryption and decryption amounts. Removed ROW_MERGE_RESERVE_SIZE define. row_merge_fts_doc_tokenize Remove ROW_MERGE_RESERVE_SIZE row_log_t Add index, crypt_tail, crypt_head to be used in case of encryption. row_log_online_op, row_log_table_close_func Before writing a block encrypt it if encryption is enabled row_log_table_apply_ops, row_log_apply_ops After reading a block decrypt it if encryption is enabled row_log_allocate Allocate temporary buffers crypt_head and crypt_tail if needed. row_log_free Free temporary buffers crypt_head and crypt_tail if they exist. row_merge_encrypt_buf, row_merge_decrypt_buf Removed. row_merge_buf_create, row_merge_buf_write Remove ROW_MERGE_RESERVE_SIZE row_merge_build_indexes Allocate temporary buffer used in decryption and encryption if needed. log_tmp_blocks_crypt, log_tmp_block_encrypt, log_temp_block_decrypt New functions used in block encryption and decryption log_tmp_is_encrypted New function to check is encryption enabled. Added test case innodb-rowlog to force creating a row log and verify that operations are done using introduced status variables.
2017-09-14 09:23:20 +03:00
Copyright (c) 2015, 2017, MariaDB Corporation.
2009-03-25 23:11:11 -07:00
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
2013-12-16 15:38:05 +01:00
this program; if not, write to the Free Software Foundation, Inc.,
2019-05-11 19:25:02 +03:00
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
2009-03-25 23:11:11 -07:00
*****************************************************************************/
2009-09-07 10:22:53 +00:00
/**************************************************//**
@file include/row0merge.h
Index build routines using a merge sort
Created 13/06/2005 Jan Lindstrom
*******************************************************/
#ifndef row0merge_h
#define row0merge_h
#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"
2013-12-16 15:38:05 +01:00
#include "srv0srv.h"
/* Cluster index read task is mandatory */
#define COST_READ_CLUSTERED_INDEX 1.0
/* Basic fixed cost to build all type of index */
#define COST_BUILD_INDEX_STATIC 0.5
/* Dynamic cost to build all type of index, dynamic cost will be re-distributed based on page count ratio of each index */
#define COST_BUILD_INDEX_DYNAMIC 0.5
/* Sum of below two must be 1.0 */
#define PCT_COST_MERGESORT_INDEX 0.4
#define PCT_COST_INSERT_INDEX 0.6
2013-12-16 15:38:05 +01:00
// Forward declaration
struct ib_sequence_t;
/** @brief 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. */
typedef byte row_merge_block_t;
/** @brief 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. */
typedef byte mrec_buf_t[UNIV_PAGE_SIZE_MAX];
/** @brief 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. */
typedef byte mrec_t;
/** Merge record in row_merge_buf_t */
struct mtuple_t {
dfield_t* fields; /*!< data fields */
};
/** Buffer for sorting in main memory. */
struct row_merge_buf_t {
mem_heap_t* heap; /*!< memory heap where allocated */
dict_index_t* index; /*!< the index the tuples belong to */
ulint total_size; /*!< total amount of data bytes */
ulint n_tuples; /*!< number of data tuples */
ulint max_tuples; /*!< maximum number of data tuples */
mtuple_t* tuples; /*!< array of data tuples */
mtuple_t* tmp_tuples; /*!< temporary copy of tuples,
for sorting */
};
/** Information about temporary files used in merge sort */
struct merge_file_t {
int fd; /*!< file descriptor */
ulint offset; /*!< file offset (end of file) */
ib_uint64_t n_rec; /*!< number of records in the file */
};
2009-09-07 10:22:53 +00:00
/** Index field definition */
2013-12-16 15:38:05 +01:00
struct index_field_t {
ulint col_no; /*!< column offset */
2009-09-07 10:22:53 +00:00
ulint prefix_len; /*!< column prefix length, or 0
if indexing the whole column */
};
2009-09-07 10:22:53 +00:00
/** Definition of an index being created */
2013-12-16 15:38:05 +01:00
struct index_def_t {
const char* name; /*!< index name */
ulint ind_type; /*!< 0, DICT_UNIQUE,
or DICT_CLUSTERED */
ulint key_number; /*!< MySQL key number,
or ULINT_UNDEFINED if none */
ulint n_fields; /*!< number of fields in index */
index_field_t* fields; /*!< field definitions */
};
2013-12-16 15:38:05 +01:00
/** Structure for reporting duplicate records. */
struct row_merge_dup_t {
dict_index_t* index; /*!< index being sorted */
struct TABLE* table; /*!< MySQL table object */
const ulint* col_map;/*!< mapping of column numbers
in table to the rebuilt table
(index->table), or NULL if not
rebuilding table */
ulint n_dup; /*!< number of duplicates */
};
2013-12-16 15:38:05 +01:00
/*************************************************************//**
Report a duplicate key. */
UNIV_INTERN
void
row_merge_dup_report(
/*=================*/
row_merge_dup_t* dup, /*!< in/out: for reporting duplicates */
const dfield_t* entry) /*!< in: duplicate index entry */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull));
2009-09-07 10:22:53 +00:00
/*********************************************************************//**
Sets an exclusive lock on a table, for the duration of creating indexes.
@return error code or DB_SUCCESS */
UNIV_INTERN
2013-12-16 15:38:05 +01:00
dberr_t
row_merge_lock_table(
/*=================*/
2009-09-07 10:22:53 +00:00
trx_t* trx, /*!< in/out: transaction */
dict_table_t* table, /*!< in: table to lock */
2013-12-16 15:38:05 +01:00
enum lock_mode mode) /*!< in: LOCK_X or LOCK_S */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull, warn_unused_result));
2009-09-07 10:22:53 +00:00
/*********************************************************************//**
2013-12-16 15:38:05 +01:00
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. */
UNIV_INTERN
void
2013-12-16 15:38:05 +01:00
row_merge_drop_indexes_dict(
/*========================*/
trx_t* trx, /*!< in/out: dictionary transaction */
table_id_t table_id)/*!< in: table identifier */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull));
2009-09-07 10:22:53 +00:00
/*********************************************************************//**
2013-12-16 15:38:05 +01:00
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. */
UNIV_INTERN
void
row_merge_drop_indexes(
/*===================*/
2013-12-16 15:38:05 +01:00
trx_t* trx, /*!< in/out: transaction */
dict_table_t* table, /*!< in/out: table containing the indexes */
ibool locked) /*!< in: TRUE=table locked,
FALSE=may need to do a lazy drop */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull));
2009-09-07 10:22:53 +00:00
/*********************************************************************//**
Drop all partially created indexes during crash recovery. */
UNIV_INTERN
void
row_merge_drop_temp_indexes(void);
/*=============================*/
2013-12-16 15:38:05 +01:00
2016-04-26 19:07:11 +02:00
/** Create temporary merge files in the given paramater path, and if
UNIV_PFS_IO defined, register the file descriptor with Performance Schema.
@param[in] path location for creating temporary merge files.
2013-12-16 15:38:05 +01:00
@return File descriptor */
UNIV_INTERN
int
2016-04-26 19:07:11 +02:00
row_merge_file_create_low(
const char* path)
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((warn_unused_result));
2013-12-16 15:38:05 +01:00
/*********************************************************************//**
Destroy a merge file. And de-register the file from Performance Schema
if UNIV_PFS_IO is defined. */
UNIV_INTERN
void
row_merge_file_destroy_low(
/*=======================*/
int fd); /*!< in: merge file descriptor */
/*********************************************************************//**
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.
@return new pathname of tablespace file, or NULL if space = 0 */
UNIV_INTERN
char*
row_make_new_pathname(
/*==================*/
dict_table_t* table, /*!< in: table to be renamed */
const char* new_name); /*!< in: new name */
2009-09-07 10:22:53 +00:00
/*********************************************************************//**
2008-12-02 21:06:00 -08:00
Rename the tables in the data dictionary. The data dictionary must
have been locked exclusively by the caller, because the transaction
2009-09-07 10:22:53 +00:00
will not be committed.
@return error code or DB_SUCCESS */
UNIV_INTERN
2013-12-16 15:38:05 +01:00
dberr_t
row_merge_rename_tables_dict(
/*=========================*/
2009-09-07 10:22:53 +00:00
dict_table_t* old_table, /*!< in/out: old table, renamed to
tmp_name */
2009-09-07 10:22:53 +00:00
dict_table_t* new_table, /*!< in/out: new table, renamed to
old_table->name */
2009-09-07 10:22:53 +00:00
const char* tmp_name, /*!< in: new name for old_table */
2013-12-16 15:38:05 +01:00
trx_t* trx) /*!< in/out: dictionary transaction */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull, warn_unused_result));
2009-09-07 10:22:53 +00:00
/*********************************************************************//**
2013-12-16 15:38:05 +01:00
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.
@return DB_SUCCESS if all OK */
UNIV_INTERN
2013-12-16 15:38:05 +01:00
dberr_t
row_merge_rename_index_to_add(
/*==========================*/
trx_t* trx, /*!< in/out: transaction */
table_id_t table_id, /*!< in: table identifier */
index_id_t index_id) /*!< in: index identifier */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull));
2013-12-16 15:38:05 +01:00
/*********************************************************************//**
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.
2009-09-07 10:22:53 +00:00
@return DB_SUCCESS if all OK */
UNIV_INTERN
2013-12-16 15:38:05 +01:00
dberr_t
row_merge_rename_index_to_drop(
/*===========================*/
2009-09-07 10:22:53 +00:00
trx_t* trx, /*!< in/out: transaction */
2013-12-16 15:38:05 +01:00
table_id_t table_id, /*!< in: table identifier */
index_id_t index_id) /*!< in: index identifier */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull));
2009-09-07 10:22:53 +00:00
/*********************************************************************//**
Create the index and load in to the dictionary.
@return index, or NULL on error */
UNIV_INTERN
dict_index_t*
row_merge_create_index(
/*===================*/
2009-09-07 10:22:53 +00:00
trx_t* trx, /*!< in/out: trx (sets error_state) */
dict_table_t* table, /*!< in: the index is on this table */
MDEV-13838: Wrong result after altering a partitioned table Reverted incorrect changes done on MDEV-7367 and MDEV-9469. Fixes properly also related bugs: MDEV-13668: InnoDB unnecessarily rebuilds table when renaming a column and adding index MDEV-9469: 'Incorrect key file' on ALTER TABLE MDEV-9548: Alter table (renaming and adding index) fails with "Incorrect key file for table" MDEV-10535: ALTER TABLE causes standalone/wsrep cluster crash MDEV-13640: ALTER TABLE CHANGE and ADD INDEX on auto_increment column fails with "Incorrect key file for table..." Root cause for all these bugs is the fact that MariaDB .frm file can contain virtual columns but InnoDB dictionary does not and previous fixes were incorrect or unnecessarily forced table rebuilt. In index creation key_part->fieldnr can be bigger than number of columns in InnoDB data dictionary. We need to skip not stored fields when calculating correct column number for InnoDB data dictionary. dict_table_get_col_name_for_mysql Remove innobase_match_index_columns Revert incorrect change done on MDEV-7367 innobase_need_rebuild Remove unnecessary rebuild force when column is renamed. innobase_create_index_field_def Calculate InnoDB column number correctly and remove unnecessary column name set. innobase_create_index_def, innobase_create_key_defs Remove unneeded fields parameter. Revert unneeded memset. prepare_inplace_alter_table_dict Remove unneeded col_names parameter index_field_t Remove unneeded col_name member. row_merge_create_index Remove unneeded col_names parameter and resolution. Effected tests: innodb-alter-table : Add test case for MDEV-13668 innodb-alter : Remove MDEV-13668, MDEV-9469 FIXMEs and restore original tests innodb-wl5980-alter : Remove MDEV-13668, MDEV-9469 FIXMEs and restore original tests
2017-10-10 10:19:10 +03:00
const index_def_t* index_def); /*!< in: the index definition */
2009-09-07 10:22:53 +00:00
/*********************************************************************//**
Check if a transaction can use an index.
@return TRUE if index can be used by the transaction else FALSE */
UNIV_INTERN
ibool
row_merge_is_index_usable(
/*======================*/
2009-09-07 10:22:53 +00:00
const trx_t* trx, /*!< in: transaction */
const dict_index_t* index); /*!< in: index to check */
/*********************************************************************//**
2013-12-16 15:38:05 +01:00
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.
2009-09-07 10:22:53 +00:00
@return DB_SUCCESS or error code */
UNIV_INTERN
2013-12-16 15:38:05 +01:00
dberr_t
row_merge_drop_table(
/*=================*/
2009-09-07 10:22:53 +00:00
trx_t* trx, /*!< in: transaction */
2013-12-16 15:38:05 +01:00
dict_table_t* table) /*!< in: table instance to drop */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull));
2009-09-07 10:22:53 +00:00
/*********************************************************************//**
Build indexes on a table by reading a clustered index,
creating a temporary file containing index entries, merge sorting
2009-09-07 10:22:53 +00:00
these index entries and inserting sorted index entries to indexes.
@return DB_SUCCESS or error code */
UNIV_INTERN
2013-12-16 15:38:05 +01:00
dberr_t
row_merge_build_indexes(
/*====================*/
2009-09-07 10:22:53 +00:00
trx_t* trx, /*!< in: transaction */
dict_table_t* old_table, /*!< in: table where rows are
read from */
2009-09-07 10:22:53 +00:00
dict_table_t* new_table, /*!< in: table where indexes are
created; identical to old_table
unless creating a PRIMARY KEY */
2013-12-16 15:38:05 +01:00
bool online, /*!< in: true if creating indexes
online */
2009-09-07 10:22:53 +00:00
dict_index_t** indexes, /*!< in: indexes to be created */
2013-12-16 15:38:05 +01:00
const ulint* key_numbers, /*!< in: MySQL key numbers */
2009-09-07 10:22:53 +00:00
ulint n_indexes, /*!< in: size of indexes[] */
2013-12-16 15:38:05 +01:00
struct TABLE* table, /*!< in/out: MySQL table, for
reporting erroneous key value
if applicable */
2013-12-16 15:38:05 +01:00
const dtuple_t* add_cols, /*!< in: default values of
added columns, or NULL */
const ulint* col_map, /*!< in: mapping of old column
numbers to new ones, or NULL
if old_table == new_table */
ulint add_autoinc, /*!< in: number of added
AUTO_INCREMENT column, or
ULINT_UNDEFINED if none is added */
ib_sequence_t& sequence) /*!< in/out: autoinc sequence */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull(1,2,3,5,6,8), warn_unused_result));
2013-12-16 15:38:05 +01:00
/********************************************************************//**
Write a buffer to a block. */
UNIV_INTERN
void
row_merge_buf_write(
/*================*/
const row_merge_buf_t* buf, /*!< in: sorted buffer */
const merge_file_t* of, /*!< in: output file */
row_merge_block_t* block) /*!< out: buffer for writing to file */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull));
2013-12-16 15:38:05 +01:00
/********************************************************************//**
Sort a buffer. */
UNIV_INTERN
void
row_merge_buf_sort(
/*===============*/
row_merge_buf_t* buf, /*!< in/out: sort buffer */
row_merge_dup_t* dup) /*!< in/out: reporter of duplicates
(NULL if non-unique index) */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull(1)));
2013-12-16 15:38:05 +01:00
/********************************************************************//**
Write a merge block to the file system.
@return TRUE if request was successful, FALSE if fail */
UNIV_INTERN
MDEV-12634: Uninitialised ROW_MERGE_RESERVE_SIZE bytes written to tem… …porary file Fixed by removing writing key version to start of every block that was encrypted. Instead we will use single key version from log_sys crypt info. After this MDEV also blocks writen to row log are encrypted and blocks read from row log aren decrypted if encryption is configured for the table. innodb_status_variables[], struct srv_stats_t Added status variables for merge block and row log block encryption and decryption amounts. Removed ROW_MERGE_RESERVE_SIZE define. row_merge_fts_doc_tokenize Remove ROW_MERGE_RESERVE_SIZE row_log_t Add index, crypt_tail, crypt_head to be used in case of encryption. row_log_online_op, row_log_table_close_func Before writing a block encrypt it if encryption is enabled row_log_table_apply_ops, row_log_apply_ops After reading a block decrypt it if encryption is enabled row_log_allocate Allocate temporary buffers crypt_head and crypt_tail if needed. row_log_free Free temporary buffers crypt_head and crypt_tail if they exist. row_merge_encrypt_buf, row_merge_decrypt_buf Removed. row_merge_buf_create, row_merge_buf_write Remove ROW_MERGE_RESERVE_SIZE row_merge_build_indexes Allocate temporary buffer used in decryption and encryption if needed. log_tmp_blocks_crypt, log_tmp_block_encrypt, log_temp_block_decrypt New functions used in block encryption and decryption log_tmp_is_encrypted New function to check is encryption enabled. Added test case innodb-rowlog to force creating a row log and verify that operations are done using introduced status variables.
2017-09-14 09:23:20 +03:00
bool
2013-12-16 15:38:05 +01:00
row_merge_write(
/*============*/
int fd, /*!< in: file descriptor */
ulint offset, /*!< in: offset where to write,
in number of row_merge_block_t elements */
const void* buf, /*!< in: data */
void* crypt_buf, /*!< in: crypt buf or NULL */
MDEV-12634: Uninitialised ROW_MERGE_RESERVE_SIZE bytes written to tem… …porary file Fixed by removing writing key version to start of every block that was encrypted. Instead we will use single key version from log_sys crypt info. After this MDEV also blocks writen to row log are encrypted and blocks read from row log aren decrypted if encryption is configured for the table. innodb_status_variables[], struct srv_stats_t Added status variables for merge block and row log block encryption and decryption amounts. Removed ROW_MERGE_RESERVE_SIZE define. row_merge_fts_doc_tokenize Remove ROW_MERGE_RESERVE_SIZE row_log_t Add index, crypt_tail, crypt_head to be used in case of encryption. row_log_online_op, row_log_table_close_func Before writing a block encrypt it if encryption is enabled row_log_table_apply_ops, row_log_apply_ops After reading a block decrypt it if encryption is enabled row_log_allocate Allocate temporary buffers crypt_head and crypt_tail if needed. row_log_free Free temporary buffers crypt_head and crypt_tail if they exist. row_merge_encrypt_buf, row_merge_decrypt_buf Removed. row_merge_buf_create, row_merge_buf_write Remove ROW_MERGE_RESERVE_SIZE row_merge_build_indexes Allocate temporary buffer used in decryption and encryption if needed. log_tmp_blocks_crypt, log_tmp_block_encrypt, log_temp_block_decrypt New functions used in block encryption and decryption log_tmp_is_encrypted New function to check is encryption enabled. Added test case innodb-rowlog to force creating a row log and verify that operations are done using introduced status variables.
2017-09-14 09:23:20 +03:00
ulint space) /*!< in: space id */
MY_ATTRIBUTE((warn_unused_result));
2013-12-16 15:38:05 +01:00
/********************************************************************//**
Empty a sort buffer.
@return sort buffer */
UNIV_INTERN
row_merge_buf_t*
row_merge_buf_empty(
/*================*/
row_merge_buf_t* buf) /*!< in,own: sort buffer */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((warn_unused_result, nonnull));
2016-04-26 19:07:11 +02:00
/** Create a merge file in the given location.
@param[out] merge_file merge file structure
@param[in] path location for creating temporary file
2013-12-16 15:38:05 +01:00
@return file descriptor, or -1 on failure */
UNIV_INTERN
int
row_merge_file_create(
2016-04-26 19:07:11 +02:00
merge_file_t* merge_file,
const char* path);
2013-12-16 15:38:05 +01:00
/*********************************************************************//**
Merge disk files.
@return DB_SUCCESS or error code */
UNIV_INTERN
dberr_t
row_merge_sort(
/*===========*/
trx_t* trx, /*!< in: transaction */
const row_merge_dup_t* dup, /*!< in: descriptor of
index being created */
merge_file_t* file, /*!< in/out: file containing
index entries */
row_merge_block_t* block, /*!< in/out: 3 buffers */
int* tmpfd, /*!< in/out: temporary file handle */
const bool update_progress, /*!< in: update progress status variable or not */
const float pct_progress, /*!< in: total progress percent until now */
const float pct_cost, /*!< in: current progress percent */
row_merge_block_t* crypt_block, /*!< in: crypt buf or NULL */
MDEV-12634: Uninitialised ROW_MERGE_RESERVE_SIZE bytes written to tem… …porary file Fixed by removing writing key version to start of every block that was encrypted. Instead we will use single key version from log_sys crypt info. After this MDEV also blocks writen to row log are encrypted and blocks read from row log aren decrypted if encryption is configured for the table. innodb_status_variables[], struct srv_stats_t Added status variables for merge block and row log block encryption and decryption amounts. Removed ROW_MERGE_RESERVE_SIZE define. row_merge_fts_doc_tokenize Remove ROW_MERGE_RESERVE_SIZE row_log_t Add index, crypt_tail, crypt_head to be used in case of encryption. row_log_online_op, row_log_table_close_func Before writing a block encrypt it if encryption is enabled row_log_table_apply_ops, row_log_apply_ops After reading a block decrypt it if encryption is enabled row_log_allocate Allocate temporary buffers crypt_head and crypt_tail if needed. row_log_free Free temporary buffers crypt_head and crypt_tail if they exist. row_merge_encrypt_buf, row_merge_decrypt_buf Removed. row_merge_buf_create, row_merge_buf_write Remove ROW_MERGE_RESERVE_SIZE row_merge_build_indexes Allocate temporary buffer used in decryption and encryption if needed. log_tmp_blocks_crypt, log_tmp_block_encrypt, log_temp_block_decrypt New functions used in block encryption and decryption log_tmp_is_encrypted New function to check is encryption enabled. Added test case innodb-rowlog to force creating a row log and verify that operations are done using introduced status variables.
2017-09-14 09:23:20 +03:00
ulint space) /*!< in: space id */
MY_ATTRIBUTE((warn_unused_result));
2013-12-16 15:38:05 +01:00
/*********************************************************************//**
Allocate a sort buffer.
@return own: sort buffer */
UNIV_INTERN
row_merge_buf_t*
row_merge_buf_create(
/*=================*/
dict_index_t* index) /*!< in: secondary index */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((warn_unused_result, nonnull, malloc));
2013-12-16 15:38:05 +01:00
/*********************************************************************//**
Deallocate a sort buffer. */
UNIV_INTERN
void
row_merge_buf_free(
/*===============*/
row_merge_buf_t* buf) /*!< in,own: sort buffer to be freed */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull));
2013-12-16 15:38:05 +01:00
/*********************************************************************//**
Destroy a merge file. */
UNIV_INTERN
void
row_merge_file_destroy(
/*===================*/
merge_file_t* merge_file) /*!< in/out: merge file structure */
2016-08-10 19:24:58 +02:00
MY_ATTRIBUTE((nonnull));
2013-12-16 15:38:05 +01:00
/********************************************************************//**
Read a merge block from the file system.
@return TRUE if request was successful, FALSE if fail */
UNIV_INTERN
MDEV-12634: Uninitialised ROW_MERGE_RESERVE_SIZE bytes written to tem… …porary file Fixed by removing writing key version to start of every block that was encrypted. Instead we will use single key version from log_sys crypt info. After this MDEV also blocks writen to row log are encrypted and blocks read from row log aren decrypted if encryption is configured for the table. innodb_status_variables[], struct srv_stats_t Added status variables for merge block and row log block encryption and decryption amounts. Removed ROW_MERGE_RESERVE_SIZE define. row_merge_fts_doc_tokenize Remove ROW_MERGE_RESERVE_SIZE row_log_t Add index, crypt_tail, crypt_head to be used in case of encryption. row_log_online_op, row_log_table_close_func Before writing a block encrypt it if encryption is enabled row_log_table_apply_ops, row_log_apply_ops After reading a block decrypt it if encryption is enabled row_log_allocate Allocate temporary buffers crypt_head and crypt_tail if needed. row_log_free Free temporary buffers crypt_head and crypt_tail if they exist. row_merge_encrypt_buf, row_merge_decrypt_buf Removed. row_merge_buf_create, row_merge_buf_write Remove ROW_MERGE_RESERVE_SIZE row_merge_build_indexes Allocate temporary buffer used in decryption and encryption if needed. log_tmp_blocks_crypt, log_tmp_block_encrypt, log_temp_block_decrypt New functions used in block encryption and decryption log_tmp_is_encrypted New function to check is encryption enabled. Added test case innodb-rowlog to force creating a row log and verify that operations are done using introduced status variables.
2017-09-14 09:23:20 +03:00
bool
2013-12-16 15:38:05 +01:00
row_merge_read(
/*===========*/
int fd, /*!< in: file descriptor */
ulint offset, /*!< in: offset where to read
in number of row_merge_block_t
elements */
row_merge_block_t* buf, /*!< out: data */
row_merge_block_t* crypt_buf, /*!< in: crypt buf or NULL */
MDEV-12634: Uninitialised ROW_MERGE_RESERVE_SIZE bytes written to tem… …porary file Fixed by removing writing key version to start of every block that was encrypted. Instead we will use single key version from log_sys crypt info. After this MDEV also blocks writen to row log are encrypted and blocks read from row log aren decrypted if encryption is configured for the table. innodb_status_variables[], struct srv_stats_t Added status variables for merge block and row log block encryption and decryption amounts. Removed ROW_MERGE_RESERVE_SIZE define. row_merge_fts_doc_tokenize Remove ROW_MERGE_RESERVE_SIZE row_log_t Add index, crypt_tail, crypt_head to be used in case of encryption. row_log_online_op, row_log_table_close_func Before writing a block encrypt it if encryption is enabled row_log_table_apply_ops, row_log_apply_ops After reading a block decrypt it if encryption is enabled row_log_allocate Allocate temporary buffers crypt_head and crypt_tail if needed. row_log_free Free temporary buffers crypt_head and crypt_tail if they exist. row_merge_encrypt_buf, row_merge_decrypt_buf Removed. row_merge_buf_create, row_merge_buf_write Remove ROW_MERGE_RESERVE_SIZE row_merge_build_indexes Allocate temporary buffer used in decryption and encryption if needed. log_tmp_blocks_crypt, log_tmp_block_encrypt, log_temp_block_decrypt New functions used in block encryption and decryption log_tmp_is_encrypted New function to check is encryption enabled. Added test case innodb-rowlog to force creating a row log and verify that operations are done using introduced status variables.
2017-09-14 09:23:20 +03:00
ulint space) /*!< in: space id */
MY_ATTRIBUTE((warn_unused_result));
2013-12-16 15:38:05 +01:00
/********************************************************************//**
Read a merge record.
@return pointer to next record, or NULL on I/O error or end of list */
UNIV_INTERN
const byte*
row_merge_read_rec(
/*===============*/
row_merge_block_t* block, /*!< in/out: file buffer */
mrec_buf_t* buf, /*!< in/out: secondary buffer */
const byte* b, /*!< in: pointer to record */
const dict_index_t* index, /*!< in: index of the record */
int fd, /*!< in: file descriptor */
ulint* foffs, /*!< in/out: file offset */
const mrec_t** mrec, /*!< out: pointer to merge record,
or NULL on end of list
(non-NULL on I/O error) */
ulint* offsets,/*!< out: offsets of mrec */
row_merge_block_t* crypt_block, /*!< in: crypt buf or NULL */
MDEV-12634: Uninitialised ROW_MERGE_RESERVE_SIZE bytes written to tem… …porary file Fixed by removing writing key version to start of every block that was encrypted. Instead we will use single key version from log_sys crypt info. After this MDEV also blocks writen to row log are encrypted and blocks read from row log aren decrypted if encryption is configured for the table. innodb_status_variables[], struct srv_stats_t Added status variables for merge block and row log block encryption and decryption amounts. Removed ROW_MERGE_RESERVE_SIZE define. row_merge_fts_doc_tokenize Remove ROW_MERGE_RESERVE_SIZE row_log_t Add index, crypt_tail, crypt_head to be used in case of encryption. row_log_online_op, row_log_table_close_func Before writing a block encrypt it if encryption is enabled row_log_table_apply_ops, row_log_apply_ops After reading a block decrypt it if encryption is enabled row_log_allocate Allocate temporary buffers crypt_head and crypt_tail if needed. row_log_free Free temporary buffers crypt_head and crypt_tail if they exist. row_merge_encrypt_buf, row_merge_decrypt_buf Removed. row_merge_buf_create, row_merge_buf_write Remove ROW_MERGE_RESERVE_SIZE row_merge_build_indexes Allocate temporary buffer used in decryption and encryption if needed. log_tmp_blocks_crypt, log_tmp_block_encrypt, log_temp_block_decrypt New functions used in block encryption and decryption log_tmp_is_encrypted New function to check is encryption enabled. Added test case innodb-rowlog to force creating a row log and verify that operations are done using introduced status variables.
2017-09-14 09:23:20 +03:00
ulint space) /*!< in: space id */
MY_ATTRIBUTE((warn_unused_result));
#endif /* row0merge.h */