/**************************************************//**
@file include/fsp0sysspace.h
Multi file, shared, system tablespace implementation.
Created 2013-7-26 by Kevin Lewis
*******************************************************/
#ifndef fsp0sysspace_h #define fsp0sysspace_h
#include"fsp0space.h"
/** If the last data file is auto-extended, we add this many pages to it
at a time. We have to make this public because it is a config variable. */ extern uint sys_tablespace_auto_extend_increment;
/** Data structure that contains the information about shared tablespaces.
Currently this can be the system tablespace or a temporary table tablespace */ class SysTablespace : public Tablespace
{ public:
SysTablespace()
:
m_auto_extend_last_file(),
m_last_file_size_max(),
m_created_new_raw(),
m_is_tablespace_full(false),
m_sanity_checks_done(false)
{ /* No op */
}
~SysTablespace() override
{
shutdown();
}
/** Set tablespace full status
@param[in] is_full true if full */ void set_tablespace_full_status(bool is_full)
{
m_is_tablespace_full = is_full;
}
/** Get tablespace full status
@return true if table is full */ bool get_tablespace_full_status()
{ return(m_is_tablespace_full);
}
/** Set sanity check status
@param[in] status true if sanity checks are done */ void set_sanity_check_status(bool status)
{
m_sanity_checks_done = status;
}
/** Get sanity check status
@return true if sanity checks are done */ bool get_sanity_check_status()
{ return(m_sanity_checks_done);
}
/** Parse the input params and populate member variables. @paramfilepathpathtodatafiles @paramsupports_rawtrueifitsupportsrawdevices
@return true on success parse */ bool parse_params(constchar* filepath, bool supports_raw);
/** Check the data file specification. @param[out]create_new_dbtrueifanewdatabase istobecreated @param[in]min_expected_sizeexpectedtablespace sizeinbytes
@return DB_SUCCESS if all OK else error code */
dberr_t check_file_spec( bool* create_new_db,
ulint min_expected_tablespace_size);
/** Free the memory allocated by parse() */ void shutdown();
/** Normalize the file size, convert to extents. */ void normalize_size();
/**
@return true if a new raw device was created. */ bool created_new_raw() const
{ return(m_created_new_raw);
}
/** Set the last file size.
@param[in] size the size to set */ void set_last_file_size(uint32_t size)
{
ut_ad(!m_files.empty());
m_files.back().m_size = size;
}
/** Get the size of the last data file in the tablespace
@return the size of the last data file in the array */
uint32_t last_file_size() const
{
ut_ad(!m_files.empty()); return(m_files.back().m_size);
}
/**
@return the autoextend increment in pages. */
uint32_t get_autoextend_increment() const
{ return sys_tablespace_auto_extend_increment
<< (20 - srv_page_size_shift);
}
/**
@return user specified tablespace size */
uint32_t get_min_size() const
{
uint32_t full_size= 0; for (uint32_t i= 0; i < m_files.size(); i++)
full_size+= m_files.at(i).m_user_param_size; return full_size;
}
/**
@return next increment size */
uint32_t get_increment() const;
/** Open or create the data files @param[in]is_tempwhetherthisisatemporarytablespace @param[in]create_new_dbwhetherwearecreatinganewdatabase @param[out]sum_new_sizessumofsizesofthenewfilesadded
@return DB_SUCCESS or error code */
dberr_t open_or_create( bool is_temp, bool create_new_db,
ulint* sum_new_sizes)
MY_ATTRIBUTE((warn_unused_result));
/** @return whether shrinking failed during
previous attempt of system tablespace shrinking */ bool is_shrink_fail() noexcept { return m_auto_shrink_fail; }
void set_shrink_fail() noexcept { m_auto_shrink_fail= true; } private: /** Check the tablespace header for this tablespace.
@return DB_SUCCESS or error code */ inline dberr_t read_lsn_and_check_flags();
/**
@return true if the last file size is valid. */ bool is_valid_size() const
{ return(m_last_file_size_max >= last_file_size());
}
/**
@return true if configured to use raw devices */ bool has_raw_device();
/** Note that the data file was not found. @param[in]filedatafileobject @param[out]create_new_dbtrueifanewinstancetobecreated
@return DB_SUCESS or error code */
dberr_t file_not_found(Datafile& file, bool* create_new_db);
/** Note that the data file was found. @param[in,out]filedatafileobject
@return true if a new instance to be created */ bool file_found(Datafile& file);
/** Create a data file. @param[in,out]filedatafileobject
@return DB_SUCCESS or error code */
dberr_t create(Datafile& file);
/** Create a data file. @param[in,out]filedatafileobject
@return DB_SUCCESS or error code */
dberr_t create_file(Datafile& file);
/** Open a data file. @param[in,out]filedatafileobject
@return DB_SUCCESS or error code */
dberr_t open_file(Datafile& file);
/** Set the size of the file. @param[in,out]filedatafileobject
@return DB_SUCCESS or error code */
dberr_t set_size(Datafile& file);
/** Convert a numeric string that optionally ends in G or M, to a numbercontainingmegabytes. @param[in]ptrstringwithaquantityinbytes @param[out]megsthenumberinmegabytes
@return next character in string */ staticchar* parse_units(char* ptr, ulint* megs);
private: enum file_status_t {
FILE_STATUS_VOID = 0, /** status not set */
FILE_STATUS_RW_PERMISSION_ERROR,/** permission error */
FILE_STATUS_READ_WRITE_ERROR, /** not readable/writable */
FILE_STATUS_NOT_REGULAR_FILE_ERROR /** not a regular file */
};
/** Verify the size of the physical file @param[in]filedatafileobject
@return DB_SUCCESS if OK else error code. */
dberr_t check_size(Datafile& file);
/** Check if a file can be opened in the correct mode. @param[in,out]filedatafileobject @param[out]reasonexactreasoniffile_statuscheckfailed.
@return DB_SUCCESS or error code. */
dberr_t check_file_status( const Datafile& file,
file_status_t& reason);
/* DATA MEMBERS */
/** if true, then we auto-extend the last data file */ bool m_auto_extend_last_file;
/** maximum size of the last data file (0=unlimited) */
ulint m_last_file_size_max;
/** If the following is true we do not allow insertsetc.Thisprotectstheuserfromforgetting
the 'newraw' keyword to my.cnf */ bool m_created_new_raw;
/** Tablespace full status */ bool m_is_tablespace_full;
/** if false, then sanity checks are still pending */ bool m_sanity_checks_done;
/** Shrink the system tablespace if the value is
enabled */ bool m_auto_shrink;
/** Set to true only when InnoDB system tablespace
shrink fails during startup */ bool m_auto_shrink_fail;
};
/* GLOBAL OBJECTS */
/** The control info of the system tablespace. */ extern SysTablespace srv_sys_space;
/** The control info of a temporary table shared tablespace. */ extern SysTablespace srv_tmp_space;
/** Check if the space_id is for a system-tablespace (shared + temp). @param[in]idSpaceIDtocheck
@return true if id is a system tablespace, false if not. */ inlinebool is_system_tablespace(uint32_t id)
{ return id == TRX_SYS_SPACE || id == SRV_TMP_SPACE_ID;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.