MySQL 9.0.0
Source Code Documentation
undo::Tablespace Struct Reference

An undo::Tablespace object is used to easily convert between undo_space_id and undo_space_num and to create the automatic file_name and space name. More...

#include <trx0purge.h>

Public Member Functions

 Tablespace (space_id_t id)
 Constructor. More...
 
 Tablespace (Tablespace &other)
 Copy Constructor. More...
 
 ~Tablespace ()
 Destructor. More...
 
bool needs_truncation ()
 
void set_space_id (space_id_t space_id)
 Change the space_id from its current value. More...
 
void set_space_name (const char *new_space_name)
 Replace the standard undo space name if it exists with a copy of the undo tablespace name provided. More...
 
char * space_name ()
 Get the undo tablespace name. More...
 
void set_file_name (const char *file_name)
 Replace the standard undo file name if it exists with a copy of the file name provided. More...
 
char * file_name ()
 Get the undo space filename. More...
 
char * make_log_file_name (space_id_t space_id, const char *location)
 Build a log file name based on space_id. More...
 
char * log_file_name ()
 Get the undo log filename. More...
 
char * log_file_name_old ()
 Get the old undo log filename from the srv_log_group_home_dir. More...
 
space_id_t id ()
 Get the undo tablespace ID. More...
 
space_id_t num ()
 Get the undo tablespace number. More...
 
Rsegsrsegs ()
 Get a reference to the List of rollback segments within this undo tablespace. More...
 
bool is_explicit ()
 Report whether this undo tablespace was explicitly created by an SQL statement. More...
 
bool is_implicit ()
 Report whether this undo tablespace was implicitly created. More...
 
bool is_new ()
 Report whether this undo tablespace was created at startup. More...
 
void set_new ()
 Note that this undo tablespace is being created. More...
 
bool is_active ()
 Return whether the undo tablespace is active. More...
 
bool is_active_no_latch ()
 Return whether the undo tablespace is active. More...
 
trx_rseg_tget_active (ulint slot)
 Return the rseg at the requested rseg slot if the undo space is active. More...
 
bool is_inactive_implicit ()
 Return whether the undo tablespace is inactive due to implicit selection by the purge thread. More...
 
bool is_inactive_explicit ()
 Return whether the undo tablespace was made inactive by ALTER TABLESPACE. More...
 
bool is_empty ()
 Return whether the undo tablespace is empty and ready to be dropped. More...
 
void set_active ()
 Set the undo tablespace active for use by transactions. More...
 
void set_inactive_implicit (space_id_t *marked_space_id)
 Set the state of the rollback segments in this undo tablespace to inactive_implicit if currently active. More...
 
void set_inactive_explicit ()
 Make the undo tablespace inactive so that it will not be used for new transactions. More...
 
void alter_active ()
 Make the undo tablespace active again so that it will be used for new transactions. More...
 
void set_empty ()
 Set the state of the undo tablespace to empty so that it can be dropped. More...
 

Private Attributes

space_id_t m_id
 Undo Tablespace ID. More...
 
space_id_t m_num
 Undo Tablespace number, from 1 to 127. More...
 
bool m_implicit
 True if this is an implicit undo tablespace. More...
 
bool m_new
 True if this undo tablespace was implicitly created when this instance started up. More...
 
char * m_space_name
 The tablespace name, auto-generated when needed from the space number. More...
 
char * m_file_name
 The tablespace file name, auto-generated when needed from the space number. More...
 
char * m_log_file_name
 The truncation log file name, auto-generated when needed from the space number and the srv_undo_dir. More...
 
char * m_log_file_name_old
 The old truncation log file name, auto-generated when needed from the space number and the srv_log_group_home_dir. More...
 
Rsegsm_rsegs
 List of rollback segments within this tablespace. More...
 

Detailed Description

An undo::Tablespace object is used to easily convert between undo_space_id and undo_space_num and to create the automatic file_name and space name.

In addition, it is used in undo::Tablespaces to track the trx_rseg_t objects in an Rsegs vector. So we do not allocate the Rsegs vector for each object, only when requested by the constructor.

Constructor & Destructor Documentation

◆ Tablespace() [1/2]

undo::Tablespace::Tablespace ( space_id_t  id)
inlineexplicit

Constructor.

Parameters
[in]idtablespace id

◆ Tablespace() [2/2]

undo::Tablespace::Tablespace ( Tablespace other)
inline

Copy Constructor.

Parameters
[in]otherundo tablespace to copy

◆ ~Tablespace()

undo::Tablespace::~Tablespace ( )
inline

Destructor.

Member Function Documentation

◆ alter_active()

void Tablespace::alter_active ( )

Make the undo tablespace active again so that it will be used for new transactions.

If current State is ___ then do: empty: Set active. active_implicit: Ignore. It was not altered inactive. When it is done being truncated it will go back to active. active_explicit: Depends if it is marked for truncation. marked: Set to inactive_implicit. the next state will be active. not yet: Set to active so that it does not get truncated.

◆ file_name()

char * undo::Tablespace::file_name ( )
inline

Get the undo space filename.

Make it if not yet made. NOTE: This is only called from stack objects so there is no race condition. If it is ever called from a shared object like undo::spaces, then it must be protected by the caller.

Returns
tablespace filename created from the space_id

◆ get_active()

trx_rseg_t * undo::Tablespace::get_active ( ulint  slot)
inline

Return the rseg at the requested rseg slot if the undo space is active.

Parameters
[in]slotThe slot of the rseg. 1 to 127
Returns
Rseg pointer of nullptr if the space is not active.

◆ id()

space_id_t undo::Tablespace::id ( )
inline

Get the undo tablespace ID.

Returns
tablespace ID

◆ is_active()

bool undo::Tablespace::is_active ( )
inline

Return whether the undo tablespace is active.

Returns
true if active

◆ is_active_no_latch()

bool undo::Tablespace::is_active_no_latch ( )
inline

Return whether the undo tablespace is active.

For optimization purposes, do not take a latch.

Returns
true if active

◆ is_empty()

bool undo::Tablespace::is_empty ( void  )
inline

Return whether the undo tablespace is empty and ready to be dropped.

Returns
true if empty

◆ is_explicit()

bool undo::Tablespace::is_explicit ( )
inline

Report whether this undo tablespace was explicitly created by an SQL statement.

Returns
true if the tablespace was created explicitly.

◆ is_implicit()

bool undo::Tablespace::is_implicit ( )
inline

Report whether this undo tablespace was implicitly created.

Returns
true if the tablespace was created implicitly.

◆ is_inactive_explicit()

bool undo::Tablespace::is_inactive_explicit ( )
inline

Return whether the undo tablespace was made inactive by ALTER TABLESPACE.

Returns
true if altered inactive

◆ is_inactive_implicit()

bool undo::Tablespace::is_inactive_implicit ( )
inline

Return whether the undo tablespace is inactive due to implicit selection by the purge thread.

Returns
true if marked for truncation by the purge thread

◆ is_new()

bool undo::Tablespace::is_new ( )
inline

Report whether this undo tablespace was created at startup.

Return values
trueif created at startup.
falseif pre-existed at startup.

◆ log_file_name()

char * undo::Tablespace::log_file_name ( )
inline

Get the undo log filename.

Make it if not yet made. NOTE: This is only called from stack objects so there is no race condition. If it is ever called from a shared object like undo::spaces, then it must be protected by the caller.

Returns
tablespace filename created from the space_id

◆ log_file_name_old()

char * undo::Tablespace::log_file_name_old ( )
inline

Get the old undo log filename from the srv_log_group_home_dir.

Make it if not yet made.

◆ make_log_file_name()

char * Tablespace::make_log_file_name ( space_id_t  space_id,
const char *  location 
)

Build a log file name based on space_id.

Parameters
[in]space_idid of the undo tablespace.
[in]locationdirectory location of the file.
Returns
DB_SUCCESS or error code

◆ needs_truncation()

bool Tablespace::needs_truncation ( )

◆ num()

space_id_t undo::Tablespace::num ( )
inline

Get the undo tablespace number.

This is the same as m_id if m_id is 0 or this is a v5.6-5.7 undo tablespace. v8+ undo tablespaces use a space_id from the reserved range.

Returns
undo tablespace number

◆ rsegs()

Rsegs * undo::Tablespace::rsegs ( )
inline

Get a reference to the List of rollback segments within this undo tablespace.

Returns
a reference to the Rsegs vector.

◆ set_active()

void undo::Tablespace::set_active ( )
inline

Set the undo tablespace active for use by transactions.

◆ set_empty()

void undo::Tablespace::set_empty ( )
inline

Set the state of the undo tablespace to empty so that it can be dropped.

◆ set_file_name()

void Tablespace::set_file_name ( const char *  file_name)

Replace the standard undo file name if it exists with a copy of the file name provided.

This name can come in three forms: absolute path, relative path, and basename. Undo ADD DATAFILE does not accept a relative path. So if that comes in here, it was the scanned name and is relative to the datadir. If this is just a basename, add it to srv_undo_dir.

Parameters
[in]file_nameexplicit undo file name

◆ set_inactive_explicit()

void undo::Tablespace::set_inactive_explicit ( )
inline

Make the undo tablespace inactive so that it will not be used for new transactions.

The purge thread will clear out all the undo logs, truncate it, and then mark it empty.

◆ set_inactive_implicit()

void undo::Tablespace::set_inactive_implicit ( space_id_t marked_space_id)
inline

Set the state of the rollback segments in this undo tablespace to inactive_implicit if currently active.

If the state is inactive_explicit, leave as is. Then put the space_id into the callers marked_space_id. This is done when marking a space for truncate. It will not be used for new transactions until it becomes active again.

◆ set_new()

void undo::Tablespace::set_new ( )
inline

Note that this undo tablespace is being created.

◆ set_space_id()

void Tablespace::set_space_id ( space_id_t  space_id)

Change the space_id from its current value.

Parameters
[in]space_idThe new undo tablespace ID

◆ set_space_name()

void Tablespace::set_space_name ( const char *  new_space_name)

Replace the standard undo space name if it exists with a copy of the undo tablespace name provided.

Parameters
[in]new_space_namenon-standard undo space name

◆ space_name()

char * undo::Tablespace::space_name ( )
inline

Get the undo tablespace name.

Make it if not yet made. NOTE: This is only called from stack objects so there is no race condition. If it is ever called from a shared object like undo::spaces, then it must be protected by the caller.

Returns
tablespace name created from the space_id

Member Data Documentation

◆ m_file_name

char* undo::Tablespace::m_file_name
private

The tablespace file name, auto-generated when needed from the space number.

◆ m_id

space_id_t undo::Tablespace::m_id
private

Undo Tablespace ID.

◆ m_implicit

bool undo::Tablespace::m_implicit
private

True if this is an implicit undo tablespace.

◆ m_log_file_name

char* undo::Tablespace::m_log_file_name
private

The truncation log file name, auto-generated when needed from the space number and the srv_undo_dir.

◆ m_log_file_name_old

char* undo::Tablespace::m_log_file_name_old
private

The old truncation log file name, auto-generated when needed from the space number and the srv_log_group_home_dir.

◆ m_new

bool undo::Tablespace::m_new
private

True if this undo tablespace was implicitly created when this instance started up.

False if it pre-existed.

◆ m_num

space_id_t undo::Tablespace::m_num
private

Undo Tablespace number, from 1 to 127.

This is the 7-bit number that is used in a rollback pointer. Use id2num() to get this number from a space_id.

◆ m_rsegs

Rsegs* undo::Tablespace::m_rsegs
private

List of rollback segments within this tablespace.

This is not always used. Must call init_rsegs to use it.

◆ m_space_name

char* undo::Tablespace::m_space_name
private

The tablespace name, auto-generated when needed from the space number.


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