MySQL 8.4.2
Source Code Documentation
row0log.h File Reference

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

#include "my_psi_config.h"
#include "univ.i"
#include "data0types.h"
#include "dict0types.h"
#include "mtr0types.h"
#include "que0types.h"
#include "rem0types.h"
#include "row0types.h"
#include "trx0types.h"
#include "row0log.ic"

Go to the source code of this file.

Functions

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...
 
static void row_log_abort_sec (dict_index_t *index)
 Free the row log for an index on which online creation was aborted. More...
 
static bool row_log_online_op_try (dict_index_t *index, const dtuple_t *tuple, trx_id_t trx_id)
 Try to log an operation to a secondary index that is (or was) being created. More...
 
void row_log_online_op (dict_index_t *index, const dtuple_t *tuple, trx_id_t trx_id) UNIV_COLD
 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...
 
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) UNIV_COLD
 Logs a delete operation 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) UNIV_COLD
 Logs an update operation to a table that is being rebuilt. 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) UNIV_COLD
 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) UNIV_COLD
 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) UNIV_COLD
 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) UNIV_COLD
 Notes that a BLOB is being allocated during online ALTER TABLE. 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...
 
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...
 
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...
 
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...
 

Detailed Description

Modification log for online index creation and online table rebuild.

Created 2011-05-26 Marko Makela

Function Documentation

◆ row_log_abort_sec()

static void row_log_abort_sec ( dict_index_t index)
inlinestatic

Free the row log for an index on which online creation was aborted.

in/out: index (x-latched)

◆ 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_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 in: index, must be locked
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_online_op_try()

static bool row_log_online_op_try ( dict_index_t index,
const dtuple_t tuple,
trx_id_t  trx_id 
)
inlinestatic

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

Parameters
[in,out]indexIndex, S- or X-latched.
[in]tupleIndex tuple.
[in]trx_idTransaction ID for insert, or 0 for delete.
Return values
trueif the operation was logged or can be ignored
falseif online index creation is not taking place

◆ 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_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_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_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 in: clustered index of a table that is being rebuilt online
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_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_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 operation to a table that is being rebuilt.

This will be merged in row_log_table_apply_update().

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