MySQL 8.0.39
Source Code Documentation
|
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... | |
Rsegs * | rsegs () |
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_t * | get_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... | |
Rsegs * | m_rsegs |
List of rollback segments within this tablespace. More... | |
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.
|
inlineexplicit |
Constructor.
[in] | id | tablespace id |
|
inline |
Copy Constructor.
[in] | other | undo tablespace to copy |
|
inline |
Destructor.
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.
|
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.
|
inline |
Return the rseg at the requested rseg slot if the undo space is active.
[in] | slot | The slot of the rseg. 1 to 127 |
|
inline |
Get the undo tablespace ID.
|
inline |
Return whether the undo tablespace is active.
|
inline |
Return whether the undo tablespace is active.
For optimization purposes, do not take a latch.
|
inline |
Return whether the undo tablespace is empty and ready to be dropped.
|
inline |
Report whether this undo tablespace was explicitly created by an SQL statement.
|
inline |
Report whether this undo tablespace was implicitly created.
|
inline |
Return whether the undo tablespace was made inactive by ALTER TABLESPACE.
|
inline |
Return whether the undo tablespace is inactive due to implicit selection by the purge thread.
|
inline |
Report whether this undo tablespace was created at startup.
true | if created at startup. |
false | if pre-existed at startup. |
|
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.
|
inline |
Get the old undo log filename from the srv_log_group_home_dir.
Make it if not yet made.
char * Tablespace::make_log_file_name | ( | space_id_t | space_id, |
const char * | location | ||
) |
Build a log file name based on space_id.
[in] | space_id | id of the undo tablespace. |
[in] | location | directory location of the file. |
bool Tablespace::needs_truncation | ( | ) |
|
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.
|
inline |
Get a reference to the List of rollback segments within this undo tablespace.
|
inline |
Set the undo tablespace active for use by transactions.
|
inline |
Set the state of the undo tablespace to empty so that it can be dropped.
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.
[in] | file_name | explicit undo file name |
|
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.
|
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.
|
inline |
Note that this undo tablespace is being created.
void Tablespace::set_space_id | ( | space_id_t | space_id | ) |
Change the space_id from its current value.
[in] | space_id | The new undo tablespace ID |
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.
[in] | new_space_name | non-standard undo 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.
|
private |
The tablespace file name, auto-generated when needed from the space number.
|
private |
Undo Tablespace ID.
|
private |
True if this is an implicit undo tablespace.
|
private |
The truncation log file name, auto-generated when needed from the space number and the srv_undo_dir.
|
private |
The old truncation log file name, auto-generated when needed from the space number and the srv_log_group_home_dir.
|
private |
True if this undo tablespace was implicitly created when this instance started up.
False if it pre-existed.
|
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.
|
private |
List of rollback segments within this tablespace.
This is not always used. Must call init_rsegs to use it.
|
private |
The tablespace name, auto-generated when needed from the space number.