MySQL 9.1.0
Source Code Documentation
dict_name Namespace Reference

Innodb data dictionary name. More...

Typedefs

using Convert_Func = std::function< void(std::string &)>
 Name string conversion callback. More...
 

Functions

void file_to_table (std::string &name, bool quiet)
 Conversion function to change for system to file name cs. More...
 
void table_to_file (std::string &name)
 Conversion function to change for file name to system cs. More...
 
static void get_partition_separators (bool is_57, std::string &part_sep, std::string &sub_part_sep)
 Get partition and sub-partition separator strings. More...
 
static bool check_partition (const std::string &dict_name, bool sub_part, size_t &position)
 Check for partition and sub partition. More...
 
static bool check_tmp (const std::string &dict_name, size_t &position)
 Check for TMP extension name. More...
 
bool is_partition (const std::string &dict_name)
 Check if it is a table partition. More...
 
void get_table (const std::string &dict_name, std::string &schema, std::string &table)
 Get schema and table name from dictionary table name. More...
 
void get_table (const std::string &dict_name, bool convert, std::string &schema, std::string &table, std::string &partition, bool &is_tmp)
 Get schema, table name, partition string and temporary attribute from dictionary table name. More...
 
std::optional< table_name_componentsparse_tablespace_path (std::string path)
 Get schema, table name, partition, subpartition and absolute directory from dictionary from filepath. More...
 
void get_partition (const std::string &partition, bool convert, std::string &part, std::string &sub_part)
 Get partition and sub-partition name from partition string. More...
 
void build_table (const std::string &schema, const std::string &table, const std::string &partition, bool is_tmp, bool convert, std::string &dict_name)
 
static void build_partition_low (const std::string part, const std::string sub_part, Convert_Func conv, bool is_57, std::string &partition)
 Build partition string from partition and sub-partition name. More...
 
static void get_part_from_dd (const dd::Partition *dd_part, bool lower_case, std::string &part_name, std::string &sub_name)
 Get partition and sub-partition name from DD. More...
 
void build_partition (const dd::Partition *dd_part, std::string &partition)
 Build partition string from dd object. More...
 
void build_57_partition (const dd::Partition *dd_part, std::string &partition)
 Build 5.7 style partition string from dd object. More...
 
bool match_partition (const std::string &dict_name, const dd::Partition *dd_part)
 Check if dd partition matches with innodb dictionary table name. More...
 
static void get_table_parts (const std::string &dict_name, std::string &schema, std::string &table, std::string &partition, bool &is_tmp)
 Get table and partition string in system cs from dictionary name. More...
 
void convert_to_space (std::string &dict_name)
 
void rebuild_space (const std::string &dict_name, std::string &space_name)
 
void rebuild (std::string &dict_name)
 Rebuild table name to convert from 5.7 format to 8.0. More...
 

Variables

constexpr char PART_SEPARATOR [] = "#p#"
 Partition separator in dictionary table name and file name. More...
 
constexpr size_t PART_SEPARATOR_LEN = sizeof(PART_SEPARATOR) - 1
 Partition separator length excluding terminating NULL. More...
 
constexpr char SUB_PART_SEPARATOR [] = "#sp#"
 Sub-Partition separator in dictionary table name and file name. More...
 
constexpr size_t SUB_PART_SEPARATOR_LEN = sizeof(SUB_PART_SEPARATOR) - 1
 Sub-Partition separator length excluding terminating NULL. More...
 
constexpr char ALT_PART_SEPARATOR [] = "#P#"
 Alternative partition separator from 8.0.17 and older versions. More...
 
constexpr char ALT_SUB_PART_SEPARATOR [] = "#SP#"
 Alternative sub-partition separator from 8.0.17 and older versions. More...
 
constexpr char SCHEMA_SEPARATOR [] = "/"
 Schema separator is forward slash irrespective of platform. More...
 
constexpr size_t SCHEMA_SEPARATOR_LEN = sizeof(SCHEMA_SEPARATOR) - 1
 
constexpr size_t MAX_DB_UTF8MB3_LEN = NAME_LEN + 1
 The maximum length in bytes that a database name can occupy when stored in UTF8MB3, including the terminating null. More...
 
constexpr size_t MAX_DB_CHAR_LEN = NAME_CHAR_LEN
 The maximum length in characters for database name. More...
 
constexpr size_t MAX_TABLE_UTF8MB3_LEN
 The maximum length in bytes that a table name can occupy when stored in UTF8MB3, including the terminating null. More...
 
constexpr size_t MAX_TABLE_CHAR_LEN
 The maximum length in characters for table name. More...
 
constexpr char TMP_POSTFIX [] = "#tmp"
 Postfix for a table name which is being altered. More...
 
constexpr size_t TMP_POSTFIX_LEN = sizeof(TMP_POSTFIX) - 1
 
constexpr size_t MAX_SPACE_NAME_LEN
 Maximum space name length. More...
 

Detailed Description

Innodb data dictionary name.

NOTE: Innodb dictionary table name is always in my_charset_filename. Hence, dictionary name (dict_name) and partition string input parameters in dict_name:: interfaces are assumed to be in my_charset_filename.

Typedef Documentation

◆ Convert_Func

using dict_name::Convert_Func = typedef std::function<void(std::string &)>

Name string conversion callback.

Used for character set conversion.

Function Documentation

◆ build_57_partition()

void dict_name::build_57_partition ( const dd::Partition dd_part,
std::string &  partition 
)

Build 5.7 style partition string from dd object.

Parameters
[in]dd_partpartition object from DD
[out]partitionpartition string for dictionary table name

◆ build_partition()

void dict_name::build_partition ( const dd::Partition dd_part,
std::string &  partition 
)

Build partition string from dd object.

Parameters
[in]dd_partpartition object from DD
[out]partitionpartition string for dictionary table name

◆ build_partition_low()

static void dict_name::build_partition_low ( const std::string  part,
const std::string  sub_part,
Convert_Func  conv,
bool  is_57,
std::string &  partition 
)
static

Build partition string from partition and sub-partition name.

Parameters
[in]partpartition name
[in]sub_partsub-partition name
[in]convcallback to convert partition/sub-partition name
[in]is_57if 5.7 style partition name is needed
[out]partitionpartition string for dictionary table name

◆ build_table()

void dict_name::build_table ( const std::string &  schema,
const std::string &  table,
const std::string &  partition,
bool  is_tmp,
bool  convert,
std::string &  dict_name 
)

◆ check_partition()

static bool dict_name::check_partition ( const std::string &  dict_name,
bool  sub_part,
size_t &  position 
)
static

Check for partition and sub partition.

Parameters
[in]dict_namename from innodb dictionary
[in]sub_parttrue, if checking sub partition
[out]positionposition of partition in string
Returns
true, iff partition/sub-partition exists.

◆ check_tmp()

static bool dict_name::check_tmp ( const std::string &  dict_name,
size_t &  position 
)
static

Check for TMP extension name.

Parameters
[in]dict_namename from innodb dictionary
[out]positionposition of TMP extension in string
Returns
true, iff TMP extension exists.

◆ convert_to_space()

void dict_name::convert_to_space ( std::string &  dict_name)

◆ file_to_table()

void dict_name::file_to_table ( std::string &  name,
bool  quiet 
)

Conversion function to change for system to file name cs.

Parameters
[in,out]nameidentifier name.
[in]quiettrue, if we allow error during conversion.

◆ get_part_from_dd()

static void dict_name::get_part_from_dd ( const dd::Partition dd_part,
bool  lower_case,
std::string &  part_name,
std::string &  sub_name 
)
static

Get partition and sub-partition name from DD.

We convert the names to lower case.

Parameters
[in]dd_partpartition object from DD
[in]lower_caseconvert to lower case name
[out]part_namepartition name
[out]sub_namesub-partition name

◆ get_partition()

void dict_name::get_partition ( const std::string &  partition,
bool  convert,
std::string &  part,
std::string &  sub_part 
)

Get partition and sub-partition name from partition string.

Parameters
[in]partitionpartition string from dictionary table name
[in]convertconvert partition names to system cs
[out]partpartition name
[out]sub_partsub partition name if present

◆ get_partition_separators()

static void dict_name::get_partition_separators ( bool  is_57,
std::string &  part_sep,
std::string &  sub_part_sep 
)
static

Get partition and sub-partition separator strings.

Parameters
[in]is_57true, if 5.7 style separator is needed
[out]part_seppartition separator
[out]sub_part_sepsub-partition separator

◆ get_table() [1/2]

void dict_name::get_table ( const std::string &  dict_name,
bool  convert,
std::string &  schema,
std::string &  table,
std::string &  partition,
bool &  is_tmp 
)

Get schema, table name, partition string and temporary attribute from dictionary table name.

Parameters
[in]dict_nametable name in dictionary
[in]convertconvert schema & table name to system cs
[out]schemaschema name
[out]tabletable name
[out]partitionpartition string if table partition
[out]is_tmptrue, iff temporary table created by DDL

◆ get_table() [2/2]

void dict_name::get_table ( const std::string &  dict_name,
std::string &  schema,
std::string &  table 
)

Get schema and table name from dictionary table name.

Parameters
[in]dict_nametable name in dictionary
[out]schemaschema name
[out]tabletable name

◆ get_table_parts()

static void dict_name::get_table_parts ( const std::string &  dict_name,
std::string &  schema,
std::string &  table,
std::string &  partition,
bool &  is_tmp 
)
static

Get table and partition string in system cs from dictionary name.

Parameters
[in]dict_nametable name in dictionary
[out]schemaschema name
[out]tabletable name
[out]partitionpartition string
[out]is_tmptrue, if temporary table created by DDL

◆ is_partition()

bool dict_name::is_partition ( const std::string &  dict_name)

Check if it is a table partition.

Parameters
[in]dict_nametable name in dictionary
Returns
true, iff it is table partition.

◆ match_partition()

bool dict_name::match_partition ( const std::string &  dict_name,
const dd::Partition dd_part 
)

Check if dd partition matches with innodb dictionary table name.

Parameters
[in]dict_nametable name in innodb dictionary
[in]dd_partpartition object from DD
Returns
true, iff the name matches the partition from DD.

◆ parse_tablespace_path()

std::optional< table_name_components > dict_name::parse_tablespace_path ( std::string  path)

Get schema, table name, partition, subpartition and absolute directory from dictionary from filepath.

Parameters
[in]pathpath where the ibd file is located
Returns
table_name_components struct with parsed out parts of the table name

◆ rebuild()

void dict_name::rebuild ( std::string &  dict_name)

Rebuild table name to convert from 5.7 format to 8.0.

Parameters
[in,out]dict_nametable name in dictionary

◆ rebuild_space()

void dict_name::rebuild_space ( const std::string &  dict_name,
std::string &  space_name 
)

◆ table_to_file()

void dict_name::table_to_file ( std::string &  name)

Conversion function to change for file name to system cs.

Parameters
[in,out]nameidentifier name.

Variable Documentation

◆ ALT_PART_SEPARATOR

constexpr char dict_name::ALT_PART_SEPARATOR[] = "#P#"
constexpr

Alternative partition separator from 8.0.17 and older versions.

◆ ALT_SUB_PART_SEPARATOR

constexpr char dict_name::ALT_SUB_PART_SEPARATOR[] = "#SP#"
constexpr

Alternative sub-partition separator from 8.0.17 and older versions.

◆ MAX_DB_CHAR_LEN

constexpr size_t dict_name::MAX_DB_CHAR_LEN = NAME_CHAR_LEN
constexpr

The maximum length in characters for database name.

◆ MAX_DB_UTF8MB3_LEN

constexpr size_t dict_name::MAX_DB_UTF8MB3_LEN = NAME_LEN + 1
constexpr

The maximum length in bytes that a database name can occupy when stored in UTF8MB3, including the terminating null.

◆ MAX_SPACE_NAME_LEN

constexpr size_t dict_name::MAX_SPACE_NAME_LEN
constexpr
Initial value:
=
#define NAME_LEN
Definition: mysql_com.h:67
constexpr size_t PART_SEPARATOR_LEN
Partition separator length excluding terminating NULL.
Definition: dict0types.h:76
constexpr size_t SUB_PART_SEPARATOR_LEN
Sub-Partition separator length excluding terminating NULL.
Definition: dict0types.h:82
constexpr size_t SCHEMA_SEPARATOR_LEN
Definition: dict0types.h:92
constexpr size_t TMP_POSTFIX_LEN
Definition: dict0types.h:121

Maximum space name length.

Space name includes schema name, table name along with partition and sub-partition name for partitioned table.

◆ MAX_TABLE_CHAR_LEN

constexpr size_t dict_name::MAX_TABLE_CHAR_LEN
constexpr
Initial value:
#define NAME_CHAR_LEN
Field/table name length.
Definition: mysql_com.h:60

The maximum length in characters for table name.

◆ MAX_TABLE_UTF8MB3_LEN

constexpr size_t dict_name::MAX_TABLE_UTF8MB3_LEN
constexpr
Initial value:

The maximum length in bytes that a table name can occupy when stored in UTF8MB3, including the terminating null.

NAME_LEN is added 3 times to consider table name, partition name and sub-partition name for a partitioned table. In innodb each partition/sub-partition is a separate table named as below. table_name<PART_SEPARATOR>partition_name<SUB_PART_SEPARATOR>subpartition_name This macro only applies to table name, without any database name prefixed.

◆ PART_SEPARATOR

constexpr char dict_name::PART_SEPARATOR[] = "#p#"
constexpr

Partition separator in dictionary table name and file name.

◆ PART_SEPARATOR_LEN

constexpr size_t dict_name::PART_SEPARATOR_LEN = sizeof(PART_SEPARATOR) - 1
constexpr

Partition separator length excluding terminating NULL.

◆ SCHEMA_SEPARATOR

constexpr char dict_name::SCHEMA_SEPARATOR[] = "/"
constexpr

Schema separator is forward slash irrespective of platform.

◆ SCHEMA_SEPARATOR_LEN

constexpr size_t dict_name::SCHEMA_SEPARATOR_LEN = sizeof(SCHEMA_SEPARATOR) - 1
constexpr

◆ SUB_PART_SEPARATOR

constexpr char dict_name::SUB_PART_SEPARATOR[] = "#sp#"
constexpr

Sub-Partition separator in dictionary table name and file name.

◆ SUB_PART_SEPARATOR_LEN

constexpr size_t dict_name::SUB_PART_SEPARATOR_LEN = sizeof(SUB_PART_SEPARATOR) - 1
constexpr

Sub-Partition separator length excluding terminating NULL.

◆ TMP_POSTFIX

constexpr char dict_name::TMP_POSTFIX[] = "#tmp"
constexpr

Postfix for a table name which is being altered.

Since during ALTER TABLE ... PARTITION, new partitions have to be created before dropping existing partitions, so a postfix is appended to the name to prevent name conflicts. This is also used for EXCHANGE PARTITION

◆ TMP_POSTFIX_LEN

constexpr size_t dict_name::TMP_POSTFIX_LEN = sizeof(TMP_POSTFIX) - 1
constexpr