MySQL 9.1.0
Source Code Documentation
Log_DDL Class Reference

Class to write and replay ddl logs. More...

#include <log0ddl.h>

Public Member Functions

 Log_DDL ()
 Constructor. More...
 
 ~Log_DDL ()=default
 Deconstructor. More...
 
dberr_t write_free_tree_log (trx_t *trx, const dict_index_t *index, bool is_drop_table)
 Write DDL log for freeing B-tree. More...
 
dberr_t write_delete_space_log (trx_t *trx, const dict_table_t *table, space_id_t space_id, const char *file_path, bool is_drop, bool dict_locked)
 Write DDL log for deleting tablespace file. More...
 
dberr_t write_rename_space_log (space_id_t space_id, const char *old_file_path, const char *new_file_path)
 Write a RENAME log record. More...
 
DDL_Recordfind_alter_encrypt_record (space_id_t space_id)
 Find alter encrypt record for the tablespace. More...
 
dberr_t write_alter_encrypt_space_log (space_id_t space_id, Encryption::Progress type, DDL_Record *existing_rec)
 Write an ALTER ENCRYPT Tablespace DDL log record. More...
 
dberr_t write_drop_log (trx_t *trx, const table_id_t table_id)
 Write a DROP log to indicate the entry in innodb_table_metadata should be removed for specified table. More...
 
dberr_t write_rename_table_log (dict_table_t *table, const char *old_name, const char *new_name)
 Write a RENAME table log record. More...
 
dberr_t write_remove_cache_log (trx_t *trx, dict_table_t *table)
 Write a REMOVE cache log record. More...
 
dberr_t write_delete_schema_directory_log (trx_t *trx, const char *schema_directory_path, const bool is_drop_schema)
 Write a DELETE_SCHEMA_DIRECTORY_LOG. More...
 
dberr_t replay (DDL_Record &record)
 Replay DDL log record. More...
 
dberr_t post_ddl (THD *thd)
 Replay and clean DDL logs after DDL transaction commints or rollbacks. More...
 
dberr_t recover ()
 Recover in server startup. More...
 

Static Public Member Functions

static bool is_in_recovery ()
 Is it in ddl recovery in server startup. More...
 

Private Member Functions

dberr_t insert_free_tree_log (trx_t *trx, const dict_index_t *index, uint64_t id, ulint thread_id)
 Insert a FREE log record. More...
 
void replay_free_tree_log (space_id_t space_id, page_no_t page_no, ulint index_id)
 Replay FREE log(free B-tree if exist) More...
 
dberr_t insert_delete_space_log (trx_t *trx, uint64_t id, ulint thread_id, space_id_t space_id, const char *file_path, bool dict_locked)
 Insert a DELETE log record. More...
 
void replay_delete_space_log (space_id_t space_id, const char *file_path)
 Replay DELETE log(delete file if exist) More...
 
dberr_t insert_rename_space_log (uint64_t id, ulint thread_id, space_id_t space_id, const char *old_file_path, const char *new_file_path)
 Insert a RENAME log record. More...
 
void replay_rename_space_log (space_id_t space_id, const char *old_file_path, const char *new_file_path)
 Replay RENAME log. More...
 
dberr_t insert_alter_encrypt_space_log (uint64_t id, ulint thread_id, space_id_t space_id, Encryption::Progress type, DDL_Record *existing_rec)
 Insert an ALTER ENCRYPT TABLESPACE log record. More...
 
dberr_t replay_alter_encrypt_space_log (DDL_Record &record)
 Replay an ALTER ENCRYPT TABLESPACE log record. More...
 
dberr_t insert_drop_log (trx_t *trx, uint64_t id, ulint thread_id, const table_id_t table_id)
 Insert a DROP log record. More...
 
void replay_drop_log (const table_id_t table_id)
 Replay DROP log. More...
 
dberr_t insert_rename_table_log (uint64_t id, ulint thread_id, table_id_t table_id, const char *old_name, const char *new_name)
 Insert a RENAME TABLE log record. More...
 
void replay_rename_table_log (const char *old_name, const char *new_name)
 Relay RENAME TABLE log. More...
 
dberr_t insert_remove_cache_log (uint64_t id, ulint thread_id, table_id_t table_id, const char *table_name)
 Insert a REMOVE cache log record. More...
 
void replay_remove_cache_log (table_id_t table_id, const char *table_name)
 Relay remove cache log. More...
 
dberr_t insert_delete_schema_directory_log (trx_t *trx, uint64_t id, ulint thread_id, const char *schema_directory_path)
 Insert a DELETE_SCHEMA_DIRECTORY_LOG. More...
 
dberr_t replay_delete_schema_directory_log (const char *schema_directory_path)
 Replay a DELETE_SCHEMA_DIRECTORY_LOG. More...
 
dberr_t delete_by_id (trx_t *trx, uint64_t id, bool dict_locked)
 Delete log record by id. More...
 
dberr_t replay_by_thread_id (ulint thread_id)
 Scan, replay and delete log records by thread id. More...
 
dberr_t delete_by_ids (DDL_Records &records)
 Delete the log records present in the list. More...
 
dberr_t replay_all ()
 Scan, replay and delete all log records. More...
 
uint64_t next_id ()
 Get next autoinc counter by increasing 1 for innodb_ddl_log. More...
 
bool skip (const dict_table_t *table, THD *thd)
 Check if we need to skip ddl log for a table. More...
 

Static Private Attributes

static bool s_in_recovery = false
 Whether in recover(replay) ddl log in startup. More...
 

Detailed Description

Class to write and replay ddl logs.

Constructor & Destructor Documentation

◆ Log_DDL()

Log_DDL::Log_DDL ( )

Constructor.

◆ ~Log_DDL()

Log_DDL::~Log_DDL ( )
default

Deconstructor.

Member Function Documentation

◆ delete_by_id()

dberr_t Log_DDL::delete_by_id ( trx_t trx,
uint64_t  id,
bool  dict_locked 
)
private

Delete log record by id.

Parameters
[in]trxtransaction instance
[in]idlog id
[in]dict_lockedtrue if dict_sys mutex is held, otherwise false
Returns
DB_SUCCESS or error

◆ delete_by_ids()

dberr_t Log_DDL::delete_by_ids ( DDL_Records records)
private

Delete the log records present in the list.

Parameters
[in]recordsDDL_Records where the IDs are got
Returns
DB_SUCCESS or error.

◆ find_alter_encrypt_record()

DDL_Record * Log_DDL::find_alter_encrypt_record ( space_id_t  space_id)

Find alter encrypt record for the tablespace.

Parameters
[in]space_idspace_id return log record if exists, null otherwise

◆ insert_alter_encrypt_space_log()

dberr_t Log_DDL::insert_alter_encrypt_space_log ( uint64_t  id,
ulint  thread_id,
space_id_t  space_id,
Encryption::Progress  type,
DDL_Record existing_rec 
)
private

Insert an ALTER ENCRYPT TABLESPACE log record.

Parameters
[in]idlog id
[in]thread_idthread id
[in]space_idtablespace id
[in]typeencryption operation type
[out]existing_recalter_encrypt ddl record, nullptr if none
Returns
DB_SUCCESS or error

◆ insert_delete_schema_directory_log()

dberr_t Log_DDL::insert_delete_schema_directory_log ( trx_t trx,
uint64_t  id,
ulint  thread_id,
const char *  schema_directory_path 
)
private

Insert a DELETE_SCHEMA_DIRECTORY_LOG.

Parameters
[in,out]trxtransaction
[in]idrecord id
[in]thread_idthread id
[in]schema_directory_pathpath to the schema directory
Returns
DB_SUCCESS or not

◆ insert_delete_space_log()

dberr_t Log_DDL::insert_delete_space_log ( trx_t trx,
uint64_t  id,
ulint  thread_id,
space_id_t  space_id,
const char *  file_path,
bool  dict_locked 
)
private

Insert a DELETE log record.

Parameters
[in,out]trxtransaction
[in]idlog id
[in]thread_idthread id
[in]space_idtablespace id
[in]file_pathfile path
[in]dict_lockedtrue if dict_sys mutex is held
Returns
DB_SUCCESS or error

◆ insert_drop_log()

dberr_t Log_DDL::insert_drop_log ( trx_t trx,
uint64_t  id,
ulint  thread_id,
const table_id_t  table_id 
)
private

Insert a DROP log record.

Parameters
[in,out]trxtransaction
[in]idlog id
[in]thread_idthread id
[in]table_idtable id
Returns
DB_SUCCESS or error

◆ insert_free_tree_log()

dberr_t Log_DDL::insert_free_tree_log ( trx_t trx,
const dict_index_t index,
uint64_t  id,
ulint  thread_id 
)
private

Insert a FREE log record.

Parameters
[in,out]trxtransaction
[in]indexdict index
[in]idlog id
[in]thread_idthread id
Returns
DB_SUCCESS or error

◆ insert_remove_cache_log()

dberr_t Log_DDL::insert_remove_cache_log ( uint64_t  id,
ulint  thread_id,
table_id_t  table_id,
const char *  table_name 
)
private

Insert a REMOVE cache log record.

Parameters
[in]idlog id
[in]thread_idthread id
[in]table_idtable id
[in]table_nametable name
Returns
DB_SUCCESS or error

◆ insert_rename_space_log()

dberr_t Log_DDL::insert_rename_space_log ( uint64_t  id,
ulint  thread_id,
space_id_t  space_id,
const char *  old_file_path,
const char *  new_file_path 
)
private

Insert a RENAME log record.

Parameters
[in]idlog id
[in]thread_idthread id
[in]space_idtablespace id
[in]old_file_pathfile path after rename
[in]new_file_pathfile path before rename
Returns
DB_SUCCESS or error

◆ insert_rename_table_log()

dberr_t Log_DDL::insert_rename_table_log ( uint64_t  id,
ulint  thread_id,
table_id_t  table_id,
const char *  old_name,
const char *  new_name 
)
private

Insert a RENAME TABLE log record.

Parameters
[in]idlog id
[in]thread_idthread id
[in]table_idtable id
[in]old_nametable name after rename
[in]new_nametable name before rename
Returns
DB_SUCCESS or error

◆ is_in_recovery()

static bool Log_DDL::is_in_recovery ( )
inlinestatic

Is it in ddl recovery in server startup.

Returns
true if it's in ddl recover

◆ next_id()

uint64_t Log_DDL::next_id ( )
inlineprivate

Get next autoinc counter by increasing 1 for innodb_ddl_log.

Returns
new next counter

◆ post_ddl()

dberr_t Log_DDL::post_ddl ( THD thd)

Replay and clean DDL logs after DDL transaction commints or rollbacks.

Parameters
[in]thdmysql thread
Returns
DB_SUCCESS or error

◆ recover()

dberr_t Log_DDL::recover ( )

Recover in server startup.

Scan innodb_ddl_log table, and replay all log entries. Note: redo log should be applied, and DD transactions should be recovered before calling this function.

Returns
DB_SUCCESS or error

◆ replay()

dberr_t Log_DDL::replay ( DDL_Record record)

Replay DDL log record.

Parameters
[in,out]recordDDL log record return DB_SUCCESS or error

◆ replay_all()

dberr_t Log_DDL::replay_all ( )
private

Scan, replay and delete all log records.

Returns
DB_SUCCESS or error

◆ replay_alter_encrypt_space_log()

dberr_t Log_DDL::replay_alter_encrypt_space_log ( DDL_Record record)
private

Replay an ALTER ENCRYPT TABLESPACE log record.

Parameters
[in]recordDDL Record
Returns
DB_SUCCESS or error

◆ replay_by_thread_id()

dberr_t Log_DDL::replay_by_thread_id ( ulint  thread_id)
private

Scan, replay and delete log records by thread id.

Parameters
[in]thread_idthread id
Returns
DB_SUCCESS or error

◆ replay_delete_schema_directory_log()

dberr_t Log_DDL::replay_delete_schema_directory_log ( const char *  schema_directory_path)
private

Replay a DELETE_SCHEMA_DIRECTORY_LOG.

Parameters
schema_directory_pathpath to the schema directory
Returns
DB_SUCCESS or not

◆ replay_delete_space_log()

void Log_DDL::replay_delete_space_log ( space_id_t  space_id,
const char *  file_path 
)
private

Replay DELETE log(delete file if exist)

Parameters
[in]space_idtablespace id
[in]file_pathfile path

◆ replay_drop_log()

void Log_DDL::replay_drop_log ( const table_id_t  table_id)
private

Replay DROP log.

Parameters
[in]table_idtable id

◆ replay_free_tree_log()

void Log_DDL::replay_free_tree_log ( space_id_t  space_id,
page_no_t  page_no,
ulint  index_id 
)
private

Replay FREE log(free B-tree if exist)

Parameters
[in]space_idtablespace id
[in]page_noroot page no
[in]index_idindex id

◆ replay_remove_cache_log()

void Log_DDL::replay_remove_cache_log ( table_id_t  table_id,
const char *  table_name 
)
private

Relay remove cache log.

Parameters
[in]table_idtable id
[in]table_nametable name

◆ replay_rename_space_log()

void Log_DDL::replay_rename_space_log ( space_id_t  space_id,
const char *  old_file_path,
const char *  new_file_path 
)
private

Replay RENAME log.

Parameters
[in]space_idtablespace id
[in]old_file_pathold file path
[in]new_file_pathnew file path

◆ replay_rename_table_log()

void Log_DDL::replay_rename_table_log ( const char *  old_name,
const char *  new_name 
)
private

Relay RENAME TABLE log.

Parameters
[in]old_nameold name
[in]new_namenew name

◆ skip()

bool Log_DDL::skip ( const dict_table_t table,
THD thd 
)
inlineprivate

Check if we need to skip ddl log for a table.

Parameters
[in]tabledict table
[in]thdmysql thread
Returns
true if should skip, otherwise false

◆ write_alter_encrypt_space_log()

dberr_t Log_DDL::write_alter_encrypt_space_log ( space_id_t  space_id,
Encryption::Progress  type,
DDL_Record existing_rec 
)

Write an ALTER ENCRYPT Tablespace DDL log record.

Parameters
[in]space_idtablespace id
[in]typeencryption operation type
[out]existing_recalter_encrypt ddl record, nullptr if none
Returns
DB_SUCCESS or error

◆ write_delete_schema_directory_log()

dberr_t Log_DDL::write_delete_schema_directory_log ( trx_t trx,
const char *  schema_directory_path,
const bool  is_drop_schema 
)

Write a DELETE_SCHEMA_DIRECTORY_LOG.

Parameters
[in,out]trxtransaction
[in]schema_directory_pathpath to the database directory
[in]is_drop_schemais it DROP SCHEMA query
Returns
DB_SUCCESS or error

◆ write_delete_space_log()

dberr_t Log_DDL::write_delete_space_log ( trx_t trx,
const dict_table_t table,
space_id_t  space_id,
const char *  file_path,
bool  is_drop,
bool  dict_locked 
)

Write DDL log for deleting tablespace file.

Parameters
[in,out]trxtransaction
[in]tabledict table
[in]space_idtablespace id
[in]file_pathfile path
[in]is_dropflag whether dropping tablespace
[in]dict_lockedtrue if dict_sys mutex is held
Returns
DB_SUCCESS or error

◆ write_drop_log()

dberr_t Log_DDL::write_drop_log ( trx_t trx,
const table_id_t  table_id 
)

Write a DROP log to indicate the entry in innodb_table_metadata should be removed for specified table.

Parameters
[in,out]trxtransaction
[in]table_idtable ID
Returns
DB_SUCCESS or error

◆ write_free_tree_log()

dberr_t Log_DDL::write_free_tree_log ( trx_t trx,
const dict_index_t index,
bool  is_drop_table 
)

Write DDL log for freeing B-tree.

Parameters
[in,out]trxtransaction
[in]indexdict index
[in]is_drop_tabletrue if this is drop table
Returns
DB_SUCCESS or error

◆ write_remove_cache_log()

dberr_t Log_DDL::write_remove_cache_log ( trx_t trx,
dict_table_t table 
)

Write a REMOVE cache log record.

Parameters
[in,out]trxtransaction
[in]tabledict table
Returns
DB_SUCCESS or error

◆ write_rename_space_log()

dberr_t Log_DDL::write_rename_space_log ( space_id_t  space_id,
const char *  old_file_path,
const char *  new_file_path 
)

Write a RENAME log record.

Parameters
[in]space_idtablespace id
[in]old_file_pathfile path after rename
[in]new_file_pathfile path before rename
Returns
DB_SUCCESS or error

◆ write_rename_table_log()

dberr_t Log_DDL::write_rename_table_log ( dict_table_t table,
const char *  old_name,
const char *  new_name 
)

Write a RENAME table log record.

Parameters
[in]tabledict table
[in]old_nametable name after rename
[in]new_nametable name before rename
Returns
DB_SUCCESS or error

Member Data Documentation

◆ s_in_recovery

bool Log_DDL::s_in_recovery = false
staticprivate

Whether in recover(replay) ddl log in startup.

Whether in recover(replay) DDL log in startup.


The documentation for this class was generated from the following files: