MySQL 9.1.0
Source Code Documentation
SysTablespace Class Reference

Data structure that contains the information about shared tablespaces. More...

#include <fsp0sysspace.h>

Inheritance diagram for SysTablespace:
[legend]

Public Member Functions

 SysTablespace ()
 
 ~SysTablespace () override
 
void set_tablespace_full_status (bool is_full)
 Set tablespace full status. More...
 
bool get_tablespace_full_status ()
 Get tablespace full status. More...
 
void set_sanity_check_status (bool status)
 Set sanity check status. More...
 
bool get_sanity_check_status ()
 Get sanity check status. More...
 
bool parse_params (const char *filepath_spec, bool supports_raw)
 Parse the input params and populate member variables. More...
 
dberr_t check_file_spec (bool create_new_db, ulint min_expected_size)
 Check the data file specification. More...
 
void shutdown ()
 Free the memory allocated by parse() More...
 
bool created_new_raw () const
 
ulint can_auto_extend_last_file () const
 
void set_last_file_size (page_no_t size)
 Set the last file size. More...
 
page_no_t last_file_size () const
 Get the number of pages in the last data file in the tablespace. More...
 
page_no_t get_autoextend_increment () const
 
page_no_t get_pages_from_size (os_offset_t size)
 Round the number of bytes in the file to MegaBytes and then return the number of pages. More...
 
page_no_t get_increment () const
 
dberr_t open_or_create (bool is_temp, bool create_new_db, page_no_t *sum_new_sizes, lsn_t *flush_lsn)
 Open or create the data files. More...
 
- Public Member Functions inherited from Tablespace
 Tablespace ()
 
virtual ~Tablespace ()
 
 Tablespace (const Tablespace &)
 
Tablespaceoperator= (const Tablespace &)
 
void set_name (const char *name)
 Set tablespace name. More...
 
const char * name () const
 Get tablespace name. More...
 
void set_path (const char *path, size_t len)
 Set tablespace path and filename members. More...
 
void set_path (const char *path)
 Set tablespace path and filename members. More...
 
const char * path () const
 Get tablespace path. More...
 
void set_space_id (space_id_t space_id)
 Set the space id of the tablespace. More...
 
space_id_t space_id () const
 Get the space id of the tablespace. More...
 
void set_flags (uint32_t fsp_flags)
 Set the tablespace flags. More...
 
uint32_t flags () const
 Get the tablespace flags. More...
 
void set_ignore_read_only (bool read_only_status)
 Set Ignore Read Only Status for tablespace. More...
 
void shutdown ()
 Free the memory allocated by the Tablespace object. More...
 
page_no_t get_sum_of_sizes () const
 
void delete_files ()
 Delete all the data files. More...
 
bool intersection (const Tablespace *other_space)
 Check if two tablespaces have common data file names. More...
 
dberr_t add_datafile (const char *datafile_added)
 Use the ADD DATAFILE path to create a Datafile object and add it to the front of m_files. More...
 
Datafilefirst_datafile ()
 
void set_autoextend_size (uint64_t size)
 
uint64_t get_autoextend_size () const
 

Private Types

enum  file_status_t { FILE_STATUS_VOID = 0 , FILE_STATUS_RW_PERMISSION_ERROR , FILE_STATUS_READ_WRITE_ERROR , FILE_STATUS_NOT_REGULAR_FILE_ERROR }
 

Private Member Functions

dberr_t read_lsn_and_check_flags (lsn_t *flushed_lsn)
 Check the tablespace header for this tablespace. More...
 
dberr_t file_not_found (Datafile &file, bool create_new_db)
 Note that the data file was not found. More...
 
void file_found (Datafile &file)
 Note that the data file was found. More...
 
dberr_t create (Datafile &file)
 Create a data file. More...
 
dberr_t create_file (Datafile &file)
 Create a data file. More...
 
dberr_t open_file (Datafile &file)
 Open a data file. More...
 
dberr_t set_size (Datafile &file)
 Set the size of the file. More...
 
page_no_t parse_units (char *&ptr)
 Convert a numeric string that optionally ends in upper or lower case G, M, or K, rounding off to the nearest number of megabytes. More...
 
dberr_t check_size (Datafile &file)
 Verify the size of the physical file. More...
 
dberr_t check_file_status (const Datafile &file, file_status_t &reason)
 Check if a file can be opened in the correct mode. More...
 

Static Private Member Functions

static char * parse_file_name (char *ptr)
 Put the pointer to the next byte after a valid file name. More...
 

Private Attributes

bool m_auto_extend_last_file
 if true, then we auto-extend the last data file More...
 
page_no_t m_last_file_size_max
 if != 0, this tells the max size auto-extending may increase the last data file size More...
 
bool m_created_new_raw
 If the following is true we do not allow inserts etc. More...
 
bool m_is_tablespace_full
 Tablespace full status. More...
 
bool m_sanity_checks_done
 if false, then sanity checks are still pending More...
 

Additional Inherited Members

- Public Types inherited from Tablespace
typedef std::vector< Datafile, ut::allocator< Datafile > > files_t
 
- Public Attributes inherited from Tablespace
files_t m_files
 Data file information - each Datafile can be accessed globally. More...
 
- Protected Attributes inherited from Tablespace
bool m_ignore_read_only
 Ignore server read only configuration for this tablespace. More...
 

Detailed Description

Data structure that contains the information about shared tablespaces.

Currently this can be the system tablespace or a temporary table tablespace

Member Enumeration Documentation

◆ file_status_t

Enumerator
FILE_STATUS_VOID 
FILE_STATUS_RW_PERMISSION_ERROR 

status not set

FILE_STATUS_READ_WRITE_ERROR 

permission error

FILE_STATUS_NOT_REGULAR_FILE_ERROR 

not readable/writable

not a regular file

Constructor & Destructor Documentation

◆ SysTablespace()

SysTablespace::SysTablespace ( )
inline

◆ ~SysTablespace()

SysTablespace::~SysTablespace ( )
inlineoverride

Member Function Documentation

◆ can_auto_extend_last_file()

ulint SysTablespace::can_auto_extend_last_file ( ) const
inline
Returns
auto_extend value setting

◆ check_file_spec()

dberr_t SysTablespace::check_file_spec ( bool  create_new_db,
ulint  min_expected_size 
)

Check the data file specification.

Parameters
[in]create_new_dbTrue if a new database is to be created
[in]min_expected_sizeMinimum expected tablespace size in bytes
Returns
DB_SUCCESS if all OK else error code

◆ check_file_status()

dberr_t SysTablespace::check_file_status ( const Datafile file,
file_status_t reason 
)
private

Check if a file can be opened in the correct mode.

Parameters
[in,out]filedata file object
[out]reasonexact reason if file_status check failed.
Returns
DB_SUCCESS or error code.

◆ check_size()

dberr_t SysTablespace::check_size ( Datafile file)
private

Verify the size of the physical file.

Parameters
[in]filedata file object
Returns
DB_SUCCESS if OK else error code.

◆ create()

dberr_t SysTablespace::create ( Datafile file)
private

Create a data file.

Parameters
[in,out]filedata file object
Returns
DB_SUCCESS or error code

◆ create_file()

dberr_t SysTablespace::create_file ( Datafile file)
private

Create a data file.

Parameters
[in,out]filedata file object
Returns
DB_SUCCESS or error code

◆ created_new_raw()

bool SysTablespace::created_new_raw ( ) const
inline
Returns
true if a new raw device was created.

◆ file_found()

void SysTablespace::file_found ( Datafile file)
private

Note that the data file was found.

Parameters
[in,out]filedata file object

◆ file_not_found()

dberr_t SysTablespace::file_not_found ( Datafile file,
bool  create_new_db 
)
private

Note that the data file was not found.

Parameters
[in]filedata file object
[in]create_new_dbtrue if a new instance to be created
Returns
DB_SUCCESS or error code

◆ get_autoextend_increment()

page_no_t SysTablespace::get_autoextend_increment ( ) const
inline
Returns
the autoextend increment in pages.

◆ get_increment()

page_no_t SysTablespace::get_increment ( ) const
Returns
next increment size

◆ get_pages_from_size()

page_no_t SysTablespace::get_pages_from_size ( os_offset_t  size)
inline

Round the number of bytes in the file to MegaBytes and then return the number of pages.

Note: Only system tablespaces are required to be at least 1 megabyte.

Returns
the number of pages in the file.

◆ get_sanity_check_status()

bool SysTablespace::get_sanity_check_status ( )
inline

Get sanity check status.

Returns
true if sanity checks are done

◆ get_tablespace_full_status()

bool SysTablespace::get_tablespace_full_status ( )
inline

Get tablespace full status.

Returns
true if table is full

◆ last_file_size()

page_no_t SysTablespace::last_file_size ( ) const
inline

Get the number of pages in the last data file in the tablespace.

Returns
the size of the last data file in the array

◆ open_file()

dberr_t SysTablespace::open_file ( Datafile file)
private

Open a data file.

Parameters
[in,out]filedata file object
Returns
DB_SUCCESS or error code

◆ open_or_create()

dberr_t SysTablespace::open_or_create ( bool  is_temp,
bool  create_new_db,
page_no_t sum_new_sizes,
lsn_t flush_lsn 
)

Open or create the data files.

Parameters
[in]is_tempwhether this is a temporary tablespace
[in]create_new_dbwhether we are creating a new database
[out]sum_new_sizessum of sizes of the new files added
[out]flush_lsnlsn stored at offset FIL_PAGE_FILE_FLUSH_LSN in the system tablespace header; might be nullptr if not interested in having that
Returns
DB_SUCCESS or error code

◆ parse_file_name()

char * SysTablespace::parse_file_name ( char *  ptr)
staticprivate

Put the pointer to the next byte after a valid file name.

Note that we must step over the ':' in a Windows filepath. A Windows path normally looks like "C:\ibdata\ibdata1:1G", but a Windows raw partition may have a specification like "\\.\C::1Gnewraw" or "\\.\PHYSICALDRIVE2:1Gnewraw".

Parameters
[in]ptrsystem tablespace file path spec
Returns
next character in string after the file name

◆ parse_params()

bool SysTablespace::parse_params ( const char *  filepath_spec,
bool  supports_raw 
)

Parse the input params and populate member variables.

Parameters
[in]filepath_specpath to data files
[in]supports_rawtrue if the tablespace supports raw devices
Returns
true on success parse

◆ parse_units()

page_no_t SysTablespace::parse_units ( char *&  ptr)
private

Convert a numeric string that optionally ends in upper or lower case G, M, or K, rounding off to the nearest number of megabytes.

Convert a numeric string representing a number of bytes optionally ending in upper or lower case G, M, or K, to a number of megabytes, rounding down to the nearest megabyte.

Then return the number of pages in the file.

Parameters
[in,out]ptrPointer to a numeric string
Returns
the number of pages in the file.

◆ read_lsn_and_check_flags()

dberr_t SysTablespace::read_lsn_and_check_flags ( lsn_t flushed_lsn)
private

Check the tablespace header for this tablespace.

Parameters
[out]flushed_lsnvalue stored at offset FIL_PAGE_FILE_FLUSH_LSN
Returns
DB_SUCCESS or error code

◆ set_last_file_size()

void SysTablespace::set_last_file_size ( page_no_t  size)
inline

Set the last file size.

Parameters
[in]sizethe size to set

◆ set_sanity_check_status()

void SysTablespace::set_sanity_check_status ( bool  status)
inline

Set sanity check status.

Parameters
[in]statustrue if sanity checks are done

◆ set_size()

dberr_t SysTablespace::set_size ( Datafile file)
private

Set the size of the file.

Parameters
[in,out]filedata file object
Returns
DB_SUCCESS or error code

◆ set_tablespace_full_status()

void SysTablespace::set_tablespace_full_status ( bool  is_full)
inline

Set tablespace full status.

Parameters
[in]is_fulltrue if full

◆ shutdown()

void SysTablespace::shutdown ( )

Free the memory allocated by parse()

Frees the memory allocated by the parse method.

Member Data Documentation

◆ m_auto_extend_last_file

bool SysTablespace::m_auto_extend_last_file
private

if true, then we auto-extend the last data file

◆ m_created_new_raw

bool SysTablespace::m_created_new_raw
private

If the following is true we do not allow inserts etc.

This protects the user from forgetting the 'newraw' keyword to my.cnf

◆ m_is_tablespace_full

bool SysTablespace::m_is_tablespace_full
private

Tablespace full status.

◆ m_last_file_size_max

page_no_t SysTablespace::m_last_file_size_max
private

if != 0, this tells the max size auto-extending may increase the last data file size

◆ m_sanity_checks_done

bool SysTablespace::m_sanity_checks_done
private

if false, then sanity checks are still pending


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