MySQL 8.3.0
Source Code Documentation
row0log.cc File Reference

Modification log for online index creation and online table rebuild. More...

#include "row0log.h"
#include "my_config.h"
#include <fcntl.h>
#include <algorithm>
#include <map>
#include "data0data.h"
#include "ddl0ddl.h"
#include "handler0alter.h"
#include "lob0lob.h"
#include "log0chkp.h"
#include "que0que.h"
#include "row0ext.h"
#include "row0ins.h"
#include "row0mysql.h"
#include "row0row.h"
#include "row0upd.h"
#include "srv0mon.h"
#include "trx0rec.h"
#include "ut0new.h"
#include "ut0stage.h"
#include "my_dbug.h"

Classes

struct  row_log_buf_t
 Log block for modifications during online ALTER TABLE. More...
 
class  row_log_table_blob_t
 Tracks BLOB allocation during online ALTER TABLE. More...
 
struct  row_log_t
 Buffer for logging modifications during online index creation. More...
 

Typedefs

typedef std::map< page_no_t, row_log_table_blob_t, std::less< page_no_t >, ut::allocator< std::pair< const page_no_t, row_log_table_blob_t > > > page_no_map
 Map of off-page column page numbers to 0 or log byte offsets. More...
 

Enumerations

enum  row_tab_op { ROW_T_INSERT = 0x41 , ROW_T_UPDATE , ROW_T_DELETE }
 Table row modification operations during online table rebuild. More...
 
enum  row_op { ROW_OP_INSERT = 0x61 , ROW_OP_DELETE }
 Index record modification operations during online index creation. More...
 

Functions

static bool row_log_tmpfile (row_log_t *log)
 Create the file or online log if it does not exist. More...
 
static bool row_log_block_allocate (row_log_buf_t &log_buf)
 Allocate the memory for the log buffer. More...
 
static void row_log_block_free (row_log_buf_t &log_buf)
 Free the log buffer. More...
 
void row_log_online_op (dict_index_t *index, const dtuple_t *tuple, trx_id_t trx_id)
 Logs an operation to a secondary index that is (or was) being created. More...
 
dberr_t row_log_table_get_error (const dict_index_t *index)
 Gets the error status of the online index rebuild log. More...
 
static byterow_log_table_open (row_log_t *log, ulint size, ulint *avail)
 Starts logging an operation to a table that is being rebuilt. More...
 
static void row_log_table_close_func (row_log_t *log, const byte *b, ulint size, ulint avail)
 Stops logging an operation to a table that is being rebuilt. More...
 
static void row_log_table_close (row_log_t *log, const byte *b, ulint size, ulint avail)
 
bool row_log_col_is_indexed (const dict_index_t *index, ulint v_no)
 Check whether a virtual column is indexed in the new table being created during alter table. More...
 
void row_log_table_delete (const rec_t *rec, const dtuple_t *ventry, dict_index_t *index, const ulint *offsets, const byte *sys)
 Logs a delete operation to a table that is being rebuilt. More...
 
static void row_log_table_low_redundant (const rec_t *rec, const dtuple_t *ventry, const dtuple_t *o_ventry, dict_index_t *index, bool insert, const dtuple_t *old_pk, const dict_index_t *new_index)
 Logs an insert or update to a table that is being rebuilt. More...
 
static void row_log_table_low (const rec_t *rec, const dtuple_t *ventry, const dtuple_t *o_ventry, dict_index_t *index, const ulint *offsets, bool insert, const dtuple_t *old_pk)
 Logs an insert or update to a table that is being rebuilt. More...
 
void row_log_table_update (const rec_t *rec, dict_index_t *index, const ulint *offsets, const dtuple_t *old_pk, const dtuple_t *new_v_row, const dtuple_t *old_v_row)
 Logs an update to a table that is being rebuilt. More...
 
static const dict_col_trow_log_table_get_pk_old_col (const dict_table_t *table, const ulint *col_map, ulint col_no)
 Gets the old table column of a PRIMARY KEY column. More...
 
static dberr_t row_log_table_get_pk_col (dict_index_t *index, const dict_field_t *ifield, dfield_t *dfield, mem_heap_t *heap, const rec_t *rec, const ulint *offsets, ulint i, const page_size_t &page_size, ulint max_len)
 Maps an old table column of a PRIMARY KEY column. More...
 
const dtuple_trow_log_table_get_pk (const rec_t *rec, dict_index_t *index, const ulint *offsets, byte *sys, mem_heap_t **heap)
 Constructs the old PRIMARY KEY and DB_TRX_ID,DB_ROLL_PTR of a table that is being rebuilt. More...
 
void row_log_table_insert (const rec_t *rec, const dtuple_t *ventry, dict_index_t *index, const ulint *offsets)
 Logs an insert to a table that is being rebuilt. More...
 
void row_log_table_blob_free (dict_index_t *index, page_no_t page_no)
 Notes that a BLOB is being freed during online ALTER TABLE. More...
 
void row_log_table_blob_alloc (dict_index_t *index, page_no_t page_no)
 Notes that a BLOB is being allocated during online ALTER TABLE. More...
 
static const dtuple_trow_log_table_apply_convert_mrec (const ddl::mrec_t *mrec, dict_index_t *index, const ulint *offsets, const row_log_t *log, mem_heap_t *heap, dberr_t *error)
 Converts a log record to a table row. More...
 
static dberr_t apply_insert_multi_value (uint32_t flags, dict_index_t *index, mem_heap_t *offsets_heap, mem_heap_t *heap, dtuple_t *entry, trx_id_t trx_id, que_thr_t *thr)
 Tries to insert an entry into a secondary index, which is created for multi-value field. More...
 
static dberr_t row_log_table_apply_insert_low (que_thr_t *thr, const dtuple_t *row, trx_id_t trx_id, mem_heap_t *offsets_heap, mem_heap_t *heap, ddl::Dup *dup)
 Replays an insert operation on a table that was rebuilt. More...
 
static dberr_t row_log_table_apply_insert (que_thr_t *thr, const ddl::mrec_t *mrec, const ulint *offsets, mem_heap_t *offsets_heap, mem_heap_t *heap, ddl::Dup *dup, trx_id_t trx_id)
 Replays an insert operation on a table that was rebuilt. More...
 
static dberr_t row_log_table_delete_sec (dict_index_t *index, const dtuple_t *entry, btr_pcur_t *pcur)
 Delete a record from a secondary index. More...
 
static dberr_t apply_delete_multi_value (const dtuple_t *row, row_ext_t *ext, dict_index_t *index, btr_pcur_t *pcur, mem_heap_t *heap)
 Deletes a record from a multi-value index. More...
 
static dberr_t row_log_table_apply_delete_low (btr_pcur_t *pcur, const dtuple_t *ventry, const ulint *offsets, mem_heap_t *heap, mtr_t *mtr)
 Deletes a record from a table that is being rebuilt. More...
 
static dberr_t row_log_table_apply_delete (ulint trx_id_col, const ddl::mrec_t *mrec, const ulint *moffsets, mem_heap_t *offsets_heap, mem_heap_t *heap, const row_log_t *log)
 Replays a delete operation on a table that was rebuilt. More...
 
static dberr_t apply_update_multi_value (dict_index_t *index, uint32_t n_index, const dtuple_t *old_row, row_ext_t *old_ext, const dtuple_t *new_row, bool non_mv_upd, trx_id_t trx_id, que_thr_t *thr, mem_heap_t *offsets_heap, mem_heap_t *heap)
 Replays an update operation on the multi-value index. More...
 
static dberr_t row_log_table_apply_update (que_thr_t *thr, ulint new_trx_id_col, const ddl::mrec_t *mrec, const ulint *offsets, mem_heap_t *offsets_heap, mem_heap_t *heap, ddl::Dup *dup, trx_id_t trx_id, const dtuple_t *old_pk)
 Replays an update operation on a table that was rebuilt. More...
 
static const ddl::mrec_trow_log_table_apply_op (que_thr_t *thr, ulint trx_id_col, ulint new_trx_id_col, ddl::Dup *dup, dberr_t *error, mem_heap_t *offsets_heap, mem_heap_t *heap, const ddl::mrec_t *mrec, const ddl::mrec_t *mrec_end, ulint *offsets)
 Applies an operation to a table that was rebuilt. More...
 
ulint row_log_progress_inc_per_block ()
 Estimate how much an ALTER TABLE progress should be incremented per one block of log applied. More...
 
ulint row_log_estimate_work (const dict_index_t *index)
 Estimate how much work is to be done by the log apply phase of an ALTER TABLE for this index. More...
 
static dberr_t row_log_table_apply_ops (que_thr_t *thr, ddl::Dup *dup, Alter_stage *stage)
 Applies operations to a table was rebuilt. More...
 
dberr_t row_log_table_apply (que_thr_t *thr, dict_table_t *old_table, struct TABLE *table, Alter_stage *stage)
 Apply the row_log_table log to a table upon completing rebuild. More...
 
bool row_log_allocate (dict_index_t *index, dict_table_t *table, bool same_pk, const dtuple_t *add_cols, const ulint *col_map, const char *path)
 Allocate the row log for an index and flag the index for online creation. More...
 
void row_log_free (row_log_t *&log)
 Free the row log for an index that was being created online. More...
 
trx_id_t row_log_get_max_trx (dict_index_t *index)
 Get the latest transaction ID that has invoked row_log_online_op() during online creation. More...
 
static void row_log_apply_op_low (dict_index_t *index, ddl::Dup *dup, dberr_t *error, mem_heap_t *offsets_heap, bool has_index_lock, enum row_op op, trx_id_t trx_id, const dtuple_t *entry)
 Applies an operation to a secondary index that was being created. More...
 
static const ddl::mrec_trow_log_apply_op (dict_index_t *index, ddl::Dup *dup, dberr_t *error, mem_heap_t *offsets_heap, mem_heap_t *heap, bool has_index_lock, const ddl::mrec_t *mrec, const ddl::mrec_t *mrec_end, ulint *offsets)
 Applies an operation to a secondary index that was being created. More...
 
static dberr_t row_log_apply_ops (const trx_t *trx, dict_index_t *index, ddl::Dup *dup, Alter_stage *stage)
 Applies operations to a secondary index that was being created. More...
 
dberr_t row_log_apply (const trx_t *trx, dict_index_t *index, struct TABLE *table, Alter_stage *stage)
 Apply the row log to the index upon completing index creation. More...
 

Variables

constexpr uint32_t ROW_LOG_HEADER_SIZE = 2
 Size of the modification log entry header, in bytes. More...
 

Detailed Description

Modification log for online index creation and online table rebuild.

Created 2011-05-26 Marko Makela

Typedef Documentation

◆ page_no_map

typedef std::map< page_no_t, row_log_table_blob_t, std::less<page_no_t>, ut::allocator<std::pair<const page_no_t, row_log_table_blob_t> > > page_no_map

Map of off-page column page numbers to 0 or log byte offsets.

If there is no mapping for a page number, it is safe to access. If a page number maps to 0, it is an off-page column that has been freed. If a page number maps to a nonzero number, the number is a byte offset into the index->online_log, indicating that the page is safe to access when applying log records starting from that offset.

Enumeration Type Documentation

◆ row_op

enum row_op

Index record modification operations during online index creation.

Enumerator
ROW_OP_INSERT 

Insert a record.

ROW_OP_DELETE 

Delete a record.

◆ row_tab_op

enum row_tab_op

Table row modification operations during online table rebuild.

Delete-marked records are not copied to the rebuilt table.

Enumerator
ROW_T_INSERT 

Insert a record.

ROW_T_UPDATE 

Update a record in place.

ROW_T_DELETE 

Delete (purge) a record.

Function Documentation

◆ apply_delete_multi_value()

static dberr_t apply_delete_multi_value ( const dtuple_t row,
row_ext_t ext,
dict_index_t index,
btr_pcur_t pcur,
mem_heap_t heap 
)
inlinestatic

Deletes a record from a multi-value index.

Parameters
[in]rowrow to delete
[in]extexternal data
[in]indexmulti-value index
[in,out]pcurB-tree cursor
[in,out]heapmemory heap
Returns
DB_SUCCESS or error code

◆ apply_insert_multi_value()

static dberr_t apply_insert_multi_value ( uint32_t  flags,
dict_index_t index,
mem_heap_t offsets_heap,
mem_heap_t heap,
dtuple_t entry,
trx_id_t  trx_id,
que_thr_t thr 
)
static

Tries to insert an entry into a secondary index, which is created for multi-value field.

For each value to be inserted, if a record with exactly the same fields is found, the other record is necessarily marked deleted. It is then unmarked. Otherwise, the entry is just inserted to the index.

Parameters
[in]flagsundo logging and locking flags
[in]indexsecondary index
[in,out]offsets_heapmemory heap that can be emptied
[in,out]heapmemory heap
[in,out]entryindex entry to insert
[in]trx_idPAGE_MAX_TRX_ID during row_log_table_apply(), or trx_id when undo log is disabled during alter copy operation or 0
[in]thrquery thread
Return values
DB_SUCCESSon success
DB_LOCK_WAITon lock wait when !(flags & BTR_NO_LOCKING_FLAG)
DB_FAILif retry with BTR_MODIFY_TREE is needed
Returns
error code

◆ apply_update_multi_value()

static dberr_t apply_update_multi_value ( dict_index_t index,
uint32_t  n_index,
const dtuple_t old_row,
row_ext_t old_ext,
const dtuple_t new_row,
bool  non_mv_upd,
trx_id_t  trx_id,
que_thr_t thr,
mem_heap_t offsets_heap,
mem_heap_t heap 
)
static

Replays an update operation on the multi-value index.

Parameters
[in]indexmulti-value index
[in]n_indexthe sequence of the index
[in]old_rowold row of the update
[in]old_extold external data of the update
[in]new_rownew row of the update
[in]non_mv_updtrue if any non-multi-value field on the index gets updated too
[in]trx_idtransaction id of the update
[in]thrquery graph
[in,out]offsets_heapmemory heap that can be emptied
[in,out]heapmemory heap
Returns
DB_SUCCESS or error code

◆ row_log_allocate()

bool row_log_allocate ( dict_index_t index,
dict_table_t table,
bool  same_pk,
const dtuple_t add_cols,
const ulint col_map,
const char *  path 
)

Allocate the row log for an index and flag the index for online creation.

Parameters
[in]indexIndex.
[in]tableNew table being rebuilt, or NULL when creating a secondary index.
[in]same_pkWhether the definition of the PRIMARY KEY has remained the same.
[in]add_colsDefault values of added columns, or nullptr.
[in]col_mapMapping of old column numbers to new ones, or nullptr if !table.
[in]pathWhere to create temporary file.
Return values
trueif success, false if not

◆ row_log_apply()

dberr_t row_log_apply ( const trx_t trx,
dict_index_t index,
struct TABLE table,
Alter_stage stage 
)

Apply the row log to the index upon completing index creation.

Parameters
[in]trxtransaction (for checking if the operation was interrupted)
[in,out]indexsecondary index
[in,out]tableMySQL table (for reporting duplicates)
[in,out]stageperformance schema accounting object, used by ALTER TABLE. stage->begin_phase_log_index() will be called initially and then stage->inc() will be called for each block of log that is applied.
Returns
DB_SUCCESS, or error code on failure

◆ row_log_apply_op()

static const ddl::mrec_t * row_log_apply_op ( dict_index_t index,
ddl::Dup dup,
dberr_t error,
mem_heap_t offsets_heap,
mem_heap_t heap,
bool  has_index_lock,
const ddl::mrec_t mrec,
const ddl::mrec_t mrec_end,
ulint offsets 
)
static

Applies an operation to a secondary index that was being created.

Returns
NULL on failure (mrec corruption) or when out of data; pointer to next record on success
Parameters
indexin/out: index
dupin/out: for reporting duplicate key errors
errorout: DB_SUCCESS or error code
offsets_heapin/out: memory heap for allocating offsets; can be emptied
heapin/out: memory heap for allocating data tuples
has_index_lockin: true if holding index->lock in exclusive mode
mrecin: merge record
mrec_endin: end of buffer
offsetsin/out: work area for rec_deserialize_init_offsets()

◆ row_log_apply_op_low()

static void row_log_apply_op_low ( dict_index_t index,
ddl::Dup dup,
dberr_t error,
mem_heap_t offsets_heap,
bool  has_index_lock,
enum row_op  op,
trx_id_t  trx_id,
const dtuple_t entry 
)
static

Applies an operation to a secondary index that was being created.

Parameters
indexin/out: index
dupin/out: for reporting duplicate key errors
errorout: DB_SUCCESS or error code
offsets_heapin/out: memory heap for allocating offsets; can be emptied
has_index_lockin: true if holding index->lock in exclusive mode
opin: operation being applied
trx_idin: transaction identifier
entryin: row

◆ row_log_apply_ops()

static dberr_t row_log_apply_ops ( const trx_t trx,
dict_index_t index,
ddl::Dup dup,
Alter_stage stage 
)
static

Applies operations to a secondary index that was being created.

Parameters
[in]trxtransaction (for checking if the operation was interrupted)
[in,out]indexindex
[in,out]dupfor reporting duplicate key errors
[in,out]stageperformance schema accounting object, used by ALTER TABLE. If not NULL, then stage->inc() will be called for each block of log that is applied.
Returns
DB_SUCCESS, or error code on failure

◆ row_log_block_allocate()

static bool row_log_block_allocate ( row_log_buf_t log_buf)
static

Allocate the memory for the log buffer.

Parameters
[in,out]log_bufBuffer used for log operation
Returns
true if success, false if not

◆ row_log_block_free()

static void row_log_block_free ( row_log_buf_t log_buf)
static

Free the log buffer.

Parameters
[in,out]log_bufBuffer used for log operation

◆ row_log_col_is_indexed()

bool row_log_col_is_indexed ( const dict_index_t index,
ulint  v_no 
)

Check whether a virtual column is indexed in the new table being created during alter table.

Parameters
[in]indexcluster index
[in]v_novirtual column number
Returns
true if it is indexed, else false

◆ row_log_estimate_work()

ulint row_log_estimate_work ( const dict_index_t index)

Estimate how much work is to be done by the log apply phase of an ALTER TABLE for this index.

Parameters
[in]indexindex whose log to assess
Returns
work to be done by log-apply in abstract units

◆ row_log_free()

void row_log_free ( row_log_t *&  log)

Free the row log for an index that was being created online.

in,own: row log

Parameters
login,own: row log

◆ row_log_get_max_trx()

trx_id_t row_log_get_max_trx ( dict_index_t index)

Get the latest transaction ID that has invoked row_log_online_op() during online creation.

Returns
latest transaction ID, or 0 if nothing was logged
Parameters
indexin: index, must be locked

◆ row_log_online_op()

void row_log_online_op ( dict_index_t index,
const dtuple_t tuple,
trx_id_t  trx_id 
)

Logs an operation to a secondary index that is (or was) being created.

Parameters
indexin/out: index, S or X latched
tuplein: index tuple
trx_idin: transaction ID for insert, or 0 for delete

◆ row_log_progress_inc_per_block()

ulint row_log_progress_inc_per_block ( )
inline

Estimate how much an ALTER TABLE progress should be incremented per one block of log applied.

For the other phases of ALTER TABLE we increment the progress with 1 per page processed.

Returns
amount of abstract units to add to work_completed when one block of log is applied.

◆ row_log_table_apply()

dberr_t row_log_table_apply ( que_thr_t thr,
dict_table_t old_table,
struct TABLE table,
Alter_stage stage 
)

Apply the row_log_table log to a table upon completing rebuild.

Parameters
[in]thrquery graph
[in]old_tableold table
[in,out]tableMySQL table (for reporting duplicates)
[in,out]stageperformance schema accounting object, used by ALTER TABLE. stage->begin_phase_log_table() will be called initially and then stage->inc() will be called for each block of log that is applied.
Returns
DB_SUCCESS, or error code on failure

◆ row_log_table_apply_convert_mrec()

static const dtuple_t * row_log_table_apply_convert_mrec ( const ddl::mrec_t mrec,
dict_index_t index,
const ulint offsets,
const row_log_t log,
mem_heap_t heap,
dberr_t error 
)
static

Converts a log record to a table row.

Returns
converted row, or NULL if the conversion fails
Parameters
mrecin: merge record
indexin: index of mrec
offsetsin: offsets of mrec
login: rebuild context
heapin/out: memory heap
errorout: DB_SUCCESS or DB_MISSING_HISTORY or reason of failure

◆ row_log_table_apply_delete()

static dberr_t row_log_table_apply_delete ( ulint  trx_id_col,
const ddl::mrec_t mrec,
const ulint moffsets,
mem_heap_t offsets_heap,
mem_heap_t heap,
const row_log_t log 
)
static

Replays a delete operation on a table that was rebuilt.

Returns
DB_SUCCESS or error code
Parameters
trx_id_colin: position of DB_TRX_ID in the new clustered index
mrecin: merge record
moffsetsin: offsets of mrec
offsets_heapin/out: memory heap that can be emptied
heapin/out: memory heap
login: online log

◆ row_log_table_apply_delete_low()

static dberr_t row_log_table_apply_delete_low ( btr_pcur_t pcur,
const dtuple_t ventry,
const ulint offsets,
mem_heap_t heap,
mtr_t mtr 
)
static

Deletes a record from a table that is being rebuilt.

Returns
DB_SUCCESS or error code
Parameters
pcurin/out: B-tree cursor, will be trashed
ventryin: dtuple holding virtual column info
offsetsin: offsets on pcur
heapin/out: memory heap
mtrin/out: mini-transaction, will be committed

◆ row_log_table_apply_insert()

static dberr_t row_log_table_apply_insert ( que_thr_t thr,
const ddl::mrec_t mrec,
const ulint offsets,
mem_heap_t offsets_heap,
mem_heap_t heap,
ddl::Dup dup,
trx_id_t  trx_id 
)
static

Replays an insert operation on a table that was rebuilt.

Returns
DB_SUCCESS or error code
Parameters
thrin: query graph
mrecin: record to insert
offsetsin: offsets of mrec
offsets_heapin/out: memory heap that can be emptied
heapin/out: memory heap
dupin/out: for reporting duplicate key errors
trx_idin: DB_TRX_ID of mrec

◆ row_log_table_apply_insert_low()

static dberr_t row_log_table_apply_insert_low ( que_thr_t thr,
const dtuple_t row,
trx_id_t  trx_id,
mem_heap_t offsets_heap,
mem_heap_t heap,
ddl::Dup dup 
)
static

Replays an insert operation on a table that was rebuilt.

Returns
DB_SUCCESS or error code
Parameters
thrin: query graph
rowin: table row in the old table definition
trx_idin: trx_id of the row
offsets_heapin/out: memory heap that can be emptied
heapin/out: memory heap
dupin/out: for reporting duplicate key errors

◆ row_log_table_apply_op()

static const ddl::mrec_t * row_log_table_apply_op ( que_thr_t thr,
ulint  trx_id_col,
ulint  new_trx_id_col,
ddl::Dup dup,
dberr_t error,
mem_heap_t offsets_heap,
mem_heap_t heap,
const ddl::mrec_t mrec,
const ddl::mrec_t mrec_end,
ulint offsets 
)
static

Applies an operation to a table that was rebuilt.

Returns
NULL on failure (mrec corruption) or when out of data; pointer to next record on success
Parameters
thrin: query graph
trx_id_colin: position of DB_TRX_ID in old index
new_trx_id_colin: position of DB_TRX_ID in new index
dupin/out: for reporting duplicate key errors
errorout: DB_SUCCESS or error code
offsets_heapin/out: memory heap that can be emptied
heapin/out: memory heap
mrecin: merge record
mrec_endin: end of buffer
offsetsin/out: work area for parsing mrec

◆ row_log_table_apply_ops()

static dberr_t row_log_table_apply_ops ( que_thr_t thr,
ddl::Dup dup,
Alter_stage stage 
)
static

Applies operations to a table was rebuilt.

Parameters
[in]thrquery graph
[in,out]dupfor reporting duplicate key errors
[in,out]stageperformance schema accounting object, used by ALTER TABLE. If not NULL, then stage->inc() will be called for each block of log that is applied.
Returns
DB_SUCCESS, or error code on failure

◆ row_log_table_apply_update()

static dberr_t row_log_table_apply_update ( que_thr_t thr,
ulint  new_trx_id_col,
const ddl::mrec_t mrec,
const ulint offsets,
mem_heap_t offsets_heap,
mem_heap_t heap,
ddl::Dup dup,
trx_id_t  trx_id,
const dtuple_t old_pk 
)
static

Replays an update operation on a table that was rebuilt.

Returns
DB_SUCCESS or error code

It allows to create tuple with virtual column information.

Parameters
thrin: query graph
new_trx_id_colin: position of DB_TRX_ID in the new clustered index
mrecin: new value
offsetsin: offsets of mrec
offsets_heapin/out: memory heap that can be emptied
heapin/out: memory heap
dupin/out: for reporting duplicate key errors
trx_idin: DB_TRX_ID of mrec
old_pkin: PRIMARY KEY and DB_TRX_ID,DB_ROLL_PTR of the old value, or PRIMARY KEY if same_pk

◆ row_log_table_blob_alloc()

void row_log_table_blob_alloc ( dict_index_t index,
page_no_t  page_no 
)

Notes that a BLOB is being allocated during online ALTER TABLE.

Parameters
indexin/out: clustered index, X-latched
page_noin: starting page number of the BLOB

◆ row_log_table_blob_free()

void row_log_table_blob_free ( dict_index_t index,
page_no_t  page_no 
)

Notes that a BLOB is being freed during online ALTER TABLE.

Parameters
indexin/out: clustered index, X-latched
page_noin: starting page number of the BLOB

◆ row_log_table_close()

static void row_log_table_close ( row_log_t log,
const byte b,
ulint  size,
ulint  avail 
)
inlinestatic

◆ row_log_table_close_func()

static void row_log_table_close_func ( row_log_t log,
const byte b,
ulint  size,
ulint  avail 
)
static

Stops logging an operation to a table that is being rebuilt.

Parameters
[in,out]logonline rebuild log
[in]bend of log record
[in]sizesize od log record
[in]availavailable size for log record

◆ row_log_table_delete()

void row_log_table_delete ( const rec_t rec,
const dtuple_t ventry,
dict_index_t index,
const ulint offsets,
const byte sys 
)

Logs a delete operation to a table that is being rebuilt.

This will be merged in row_log_table_apply_delete().

Parameters
recin: clustered index leaf page record, page X-latched
ventryin: dtuple holding virtual column info
indexin/out: clustered index, S-latched or X-latched
offsetsin: rec_get_offsets(rec,index)
sysin: DB_TRX_ID,DB_ROLL_PTR that should be logged, or NULL to use those in rec

◆ row_log_table_delete_sec()

static dberr_t row_log_table_delete_sec ( dict_index_t index,
const dtuple_t entry,
btr_pcur_t pcur 
)
inlinestatic

Delete a record from a secondary index.

Parameters
[in]indexsecondary index
[in]entryentry to delete
[in,out]pcurB-tree cursor
Returns
DB_SUCCESS or error code

◆ row_log_table_get_error()

dberr_t row_log_table_get_error ( const dict_index_t index)

Gets the error status of the online index rebuild log.

Returns
DB_SUCCESS or error code
Parameters
indexin: clustered index of a table that is being rebuilt online

◆ row_log_table_get_pk()

const dtuple_t * row_log_table_get_pk ( const rec_t rec,
dict_index_t index,
const ulint offsets,
byte sys,
mem_heap_t **  heap 
)

Constructs the old PRIMARY KEY and DB_TRX_ID,DB_ROLL_PTR of a table that is being rebuilt.

Returns
tuple of PRIMARY KEY,DB_TRX_ID,DB_ROLL_PTR in the rebuilt table, or NULL if the PRIMARY KEY definition does not change
Parameters
recin: clustered index leaf page record, page X-latched
indexin/out: clustered index, S-latched or X-latched
offsetsin: rec_get_offsets(rec,index)
sysout: DB_TRX_ID,DB_ROLL_PTR for row_log_table_delete(), or NULL
heapin/out: memory heap where allocated

◆ row_log_table_get_pk_col()

static dberr_t row_log_table_get_pk_col ( dict_index_t index,
const dict_field_t ifield,
dfield_t dfield,
mem_heap_t heap,
const rec_t rec,
const ulint offsets,
ulint  i,
const page_size_t page_size,
ulint  max_len 
)
static

Maps an old table column of a PRIMARY KEY column.

Parameters
[in]indexindex being operated on
[in]ifieldclustered index field in the new table (after ALTER TABLE)
[in,out]dfieldclustered index tuple field in the new table
[in,out]heapmemory heap for allocating dfield contents
[in]recclustered index leaf page record in the old table
[in]offsetsrec_get_offsets(rec)
[in]irec field corresponding to col
[in]page_sizepage size of the old table
[in]max_lenmaximum length of dfield
Return values
DB_INVALID_NULLif a NULL value is encountered
DB_TOO_BIG_INDEX_COLif the maximum prefix length is exceeded

◆ row_log_table_get_pk_old_col()

static const dict_col_t * row_log_table_get_pk_old_col ( const dict_table_t table,
const ulint col_map,
ulint  col_no 
)
static

Gets the old table column of a PRIMARY KEY column.

Parameters
tableold table (before ALTER TABLE)
col_mapmapping of old column numbers to new ones
col_nocolumn position in the new table
Returns
old table column, or NULL if this is an added column

◆ row_log_table_insert()

void row_log_table_insert ( const rec_t rec,
const dtuple_t ventry,
dict_index_t index,
const ulint offsets 
)

Logs an insert to a table that is being rebuilt.

This will be merged in row_log_table_apply_insert().

Parameters
recin: clustered index leaf page record, page X-latched
ventryin: dtuple holding virtual column info
indexin/out: clustered index, S-latched or X-latched
offsetsin: rec_get_offsets(rec,index)

◆ row_log_table_low()

static void row_log_table_low ( const rec_t rec,
const dtuple_t ventry,
const dtuple_t o_ventry,
dict_index_t index,
const ulint offsets,
bool  insert,
const dtuple_t old_pk 
)
static

Logs an insert or update to a table that is being rebuilt.

Parameters
[in]recclustered index leaf page record, page X-latched
[in]ventrydtuple holding virtual column info
[in]o_ventrydtuple holding old virtual column info
[in,out]indexclustered index, S-latched or X-latched
[in]offsetsrec_get_offsets(rec,index)
[in]inserttrue if insert, false if update
[in]old_pkold PRIMARY KEY value (if !insert and a PRIMARY KEY is being created)

◆ row_log_table_low_redundant()

static void row_log_table_low_redundant ( const rec_t rec,
const dtuple_t ventry,
const dtuple_t o_ventry,
dict_index_t index,
bool  insert,
const dtuple_t old_pk,
const dict_index_t new_index 
)
static

Logs an insert or update to a table that is being rebuilt.

Parameters
[in]recclustered index leaf page record in ROW_FORMAT=REDUNDANT, page X-latched
[in]ventrydtuple holding virtual column info or NULL
[in]o_ventryold dtuple holding virtual column info or NULL
[in,out]indexclustered index, S-latched or X-latched
[in]inserttrue if insert, false if update
[in]old_pkold PRIMARY KEY value (if !insert and a PRIMARY KEY is being created)
[in]new_indexclustered index of the new table, not latched

◆ row_log_table_open()

static byte * row_log_table_open ( row_log_t log,
ulint  size,
ulint avail 
)
static

Starts logging an operation to a table that is being rebuilt.

Returns
pointer to log, or NULL if no logging is necessary
Parameters
login/out: online rebuild log
sizein: size of log record
availout: available size for log record

◆ row_log_table_update()

void row_log_table_update ( const rec_t rec,
dict_index_t index,
const ulint offsets,
const dtuple_t old_pk,
const dtuple_t new_v_row,
const dtuple_t old_v_row 
)

Logs an update to a table that is being rebuilt.

Logs an update operation to a table that is being rebuilt.

This will be merged in row_log_table_apply_update().

Parameters
recin: clustered index leaf page record, page X-latched
indexin/out: clustered index, S-latched or X-latched
offsetsin: rec_get_offsets(rec,index)
old_pkin: row_log_table_get_pk() before the update
new_v_rowin: dtuple contains the new virtual columns
old_v_rowin: dtuple contains the old virtual columns

◆ row_log_tmpfile()

static bool row_log_tmpfile ( row_log_t log)
static

Create the file or online log if it does not exist.

Parameters
[in,out]logonline rebuild log
Returns
true if success, false if not

Variable Documentation

◆ ROW_LOG_HEADER_SIZE

constexpr uint32_t ROW_LOG_HEADER_SIZE = 2
constexpr

Size of the modification log entry header, in bytes.

op, extra_size