MySQL 8.0.40
Source Code Documentation
create_table_info_t Class Reference

Class for handling create table information. More...

#include <ha_innodb.h>

Public Member Functions

 create_table_info_t (THD *thd, TABLE *form, HA_CREATE_INFO *create_info, char *table_name, char *remote_path, char *tablespace, bool file_per_table, bool skip_strict, uint32_t old_flags, uint32_t old_flags2, bool is_partition)
 Constructor. More...
 
int initialize ()
 Initialize the object. More...
 
void set_tablespace_type (bool table_being_altered_is_file_per_table)
 Set m_tablespace_type. More...
 
int create_table (const dd::Table *dd_table, const dd::Table *old_part_table)
 Create the internal innodb table. More...
 
int create_table_update_dict ()
 Update the internal data dictionary. More...
 
template<typename Table >
int create_table_update_global_dd (Table *dd_table)
 Update the global data dictionary. More...
 
const char * create_options_are_invalid ()
 Validates the create options. More...
 
bool create_option_data_directory_is_valid (bool ignore=false)
 Validate DATA DIRECTORY option. More...
 
bool create_option_tablespace_is_valid ()
 Validate TABLESPACE option. More...
 
bool create_option_compression_is_valid ()
 Validate COMPRESSION option. More...
 
int prepare_create_table (const char *name)
 Prepare to create a table. More...
 
bool innobase_table_flags ()
 Determine InnoDB table flags. More...
 
void set_remote_path_flags ()
 Set flags and append '/' to remote path if necessary. More...
 
uint32_t flags () const
 Get table flags. More...
 
uint32_t flags2 () const
 Get table flags2. More...
 
void flags_reset ()
 Reset table flags. More...
 
void flags2_reset ()
 Reset table flags2. More...
 
bool skip_strict () const
 whether to skip strict check. More...
 
const char * table_name () const
 Return table name. More...
 
THDthd () const
 
bool is_intrinsic_temp_table () const
 
bool is_temp_table () const
 
void detach ()
 Detach the just created table and its auxiliary tables if exist. More...
 

Static Public Member Functions

static bool normalize_table_name (char *norm_name, const char *name)
 Normalizes a table name string. More...
 

Private Member Functions

void log_error_invalid_location (std::string &msg, bool ignore)
 Put a warning or error message to the error log for the DATA DIRECTORY option. More...
 
int parse_table_name (const char *name)
 Parses the table name into normal name and either temp path or remote path if needed. More...
 
int create_table_def (const dd::Table *dd_table, const dd::Table *old_part_table)
 Create a table definition to an InnoDB database. More...
 
void initialize_autoinc ()
 Initialize the autoinc of this table if necessary, which should be called before we flush logs, so autoinc counter can be persisted. More...
 

Private Attributes

THDm_thd
 Connection thread handle. More...
 
trx_tm_trx
 InnoDB transaction handle. More...
 
const TABLEm_form
 Information on table columns and indexes. More...
 
HA_CREATE_INFOm_create_info
 Create options. More...
 
char * m_table_name
 Table name. More...
 
char * m_remote_path
 Remote path (DATA DIRECTORY) or zero length-string. More...
 
char * m_tablespace
 Tablespace name or zero length-string. More...
 
dict_table_tm_table
 The newly created InnoDB table object. More...
 
bool m_innodb_file_per_table
 Local copy of srv_file_per_table. More...
 
bool m_allow_file_per_table
 Allow file_per_table for this table either because: 1) the setting innodb_file_per_table=on, 2) it was explicitly requested by tablespace=innodb_file_per_table. More...
 
bool m_use_file_per_table
 After all considerations, this shows whether we will actually create a table and tablespace using file-per-table. More...
 
bool m_use_data_dir
 Using DATA DIRECTORY. More...
 
bool m_use_shared_space
 Using a Shared General Tablespace. More...
 
uint32_t m_flags
 Table flags. More...
 
uint32_t m_flags2
 Table flags2. More...
 
bool m_skip_strict
 Skip strict check. More...
 
bool m_partition
 True if this table is a partition. More...
 

Detailed Description

Class for handling create table information.

Constructor & Destructor Documentation

◆ create_table_info_t()

create_table_info_t::create_table_info_t ( THD thd,
TABLE form,
HA_CREATE_INFO create_info,
char *  table_name,
char *  remote_path,
char *  tablespace,
bool  file_per_table,
bool  skip_strict,
uint32_t  old_flags,
uint32_t  old_flags2,
bool  is_partition 
)
inline

Constructor.

Used in two ways:

  • all but file_per_table is used, when creating the table.
  • all but name/path is used, when validating options and using flags.

Member Function Documentation

◆ create_option_compression_is_valid()

bool create_table_info_t::create_option_compression_is_valid ( )

Validate COMPRESSION option.

Validate the COPMRESSION option.

Returns
true if valid, false if not.

◆ create_option_data_directory_is_valid()

bool create_table_info_t::create_option_data_directory_is_valid ( bool  ignore = false)

Validate DATA DIRECTORY option.

◆ create_option_tablespace_is_valid()

bool create_table_info_t::create_option_tablespace_is_valid ( )

Validate TABLESPACE option.

Returns
true if valid, false if not.

◆ create_options_are_invalid()

const char * create_table_info_t::create_options_are_invalid ( )

Validates the create options.

Validate the create options.

Checks that the options KEY_BLOCK_SIZE, ROW_FORMAT, DATA DIRECTORY, TEMPORARY & TABLESPACE are compatible with each other and other settings. These CREATE OPTIONS are not validated here unless innodb_strict_mode is on. With strict mode, this function will report each problem it finds using a custom message with error code ER_ILLEGAL_HA_CREATE_OPTION, not its built-in message.

Returns
NULL if valid, string name of bad option if not.

Check that the options KEY_BLOCK_SIZE, ROW_FORMAT, DATA DIRECTORY, TEMPORARY & TABLESPACE are compatible with each other and other settings. These CREATE OPTIONS are not validated here unless innodb_strict_mode is on. With strict mode, this function will report each problem it finds using a custom message with error code ER_ILLEGAL_HA_CREATE_OPTION, not its built-in message.

Returns
NULL if valid, string name of bad option if not.

◆ create_table()

int create_table_info_t::create_table ( const dd::Table dd_table,
const dd::Table old_part_table 
)

Create the internal innodb table.

Parameters
[in]dd_tabledd::Table or nullptr for intrinsic table
[in]old_part_tabledd::Table from an old partition for partitioned table, NULL otherwise.
Returns
0 or error number

◆ create_table_def()

int create_table_info_t::create_table_def ( const dd::Table dd_table,
const dd::Table old_part_table 
)
inlineprivate

Create a table definition to an InnoDB database.

Parameters
[in]dd_tabledd::Table or nullptr for intrinsic table
[in]old_part_tabledd::Table from an old partition for partitioned table, NULL otherwise.
Returns
HA_* level error

Fill base columns for the stored column present in the list.

◆ create_table_update_dict()

int create_table_info_t::create_table_update_dict ( )

Update the internal data dictionary.

Update a new table in an InnoDB database.

Returns
error number

◆ create_table_update_global_dd()

template<typename Table >
int create_table_info_t::create_table_update_global_dd ( Table *  dd_table)

Update the global data dictionary.

Parameters
[in]dd_tabledd::Table or dd::Partition
Return values
0On success
errornumber On failure

◆ detach()

void create_table_info_t::detach ( )

Detach the just created table and its auxiliary tables if exist.

◆ flags()

uint32_t create_table_info_t::flags ( ) const
inline

Get table flags.

◆ flags2()

uint32_t create_table_info_t::flags2 ( ) const
inline

Get table flags2.

◆ flags2_reset()

void create_table_info_t::flags2_reset ( )
inline

Reset table flags2.

◆ flags_reset()

void create_table_info_t::flags_reset ( )
inline

Reset table flags.

◆ initialize()

int create_table_info_t::initialize ( )

Initialize the object.

Initialize the create_table_info_t object.

Returns
error number

◆ initialize_autoinc()

void create_table_info_t::initialize_autoinc ( )
private

Initialize the autoinc of this table if necessary, which should be called before we flush logs, so autoinc counter can be persisted.

◆ innobase_table_flags()

bool create_table_info_t::innobase_table_flags ( )

Determine InnoDB table flags.

If strict_mode=OFF, this will adjust the flags to what should be assumed. However, if an existing general tablespace is being targeted, we will NOT assume anything or adjust these flags.

Return values
trueif successful, false if error

◆ is_intrinsic_temp_table()

bool create_table_info_t::is_intrinsic_temp_table ( ) const
inline

◆ is_temp_table()

bool create_table_info_t::is_temp_table ( ) const
inline
Returns
true only if table is temporary and not intrinsic

◆ log_error_invalid_location()

void create_table_info_t::log_error_invalid_location ( std::string &  msg,
bool  ignore 
)
private

Put a warning or error message to the error log for the DATA DIRECTORY option.

Parameters
[in]msgThe reason that data directory is wrong.
[in]ignoreIf true, append a message about ignoring the data directory location.

◆ normalize_table_name()

bool create_table_info_t::normalize_table_name ( char *  norm_name,
const char *  name 
)
static

Normalizes a table name string.

A normalized name consists of the database name catenated to '/' and table name. An example: test/mytable. On case insensitive file system normalization converts name to lower case.

Parameters
[in,out]norm_nameBuffer to return the normalized name in.
[in]nameTable name string.
Returns
true if successful.

◆ parse_table_name()

int create_table_info_t::parse_table_name ( const char *  name)
private

Parses the table name into normal name and either temp path or remote path if needed.

Parse the table name into normal name and remote path if needed.

Parameters
[in]nameTable name (db/table or full path).
Returns
0 if successful, otherwise, error number

◆ prepare_create_table()

int create_table_info_t::prepare_create_table ( const char *  name)

Prepare to create a table.

Prepare to create a new table to an InnoDB database.

Parameters
[in]nameTable name
Returns
error number

◆ set_remote_path_flags()

void create_table_info_t::set_remote_path_flags ( )

Set flags and append '/' to remote path if necessary.

◆ set_tablespace_type()

void create_table_info_t::set_tablespace_type ( bool  table_being_altered_is_file_per_table)

Set m_tablespace_type.

Set m_use_* flags.

Allow file_per_table for this table either because: 1) the setting innodb_file_per_table=on, 2) the table being altered is currently file_per_table 3) explicitly requested by tablespace=innodb_file_per_table.

◆ skip_strict()

bool create_table_info_t::skip_strict ( ) const
inline

whether to skip strict check.

◆ table_name()

const char * create_table_info_t::table_name ( ) const
inline

Return table name.

◆ thd()

THD * create_table_info_t::thd ( ) const
inline

Member Data Documentation

◆ m_allow_file_per_table

bool create_table_info_t::m_allow_file_per_table
private

Allow file_per_table for this table either because: 1) the setting innodb_file_per_table=on, 2) it was explicitly requested by tablespace=innodb_file_per_table.

3) the table being altered is currently file_per_table

◆ m_create_info

HA_CREATE_INFO* create_table_info_t::m_create_info
private

Create options.

◆ m_flags

uint32_t create_table_info_t::m_flags
private

Table flags.

◆ m_flags2

uint32_t create_table_info_t::m_flags2
private

Table flags2.

◆ m_form

const TABLE* create_table_info_t::m_form
private

Information on table columns and indexes.

◆ m_innodb_file_per_table

bool create_table_info_t::m_innodb_file_per_table
private

Local copy of srv_file_per_table.

◆ m_partition

bool create_table_info_t::m_partition
private

True if this table is a partition.

◆ m_remote_path

char* create_table_info_t::m_remote_path
private

Remote path (DATA DIRECTORY) or zero length-string.

◆ m_skip_strict

bool create_table_info_t::m_skip_strict
private

Skip strict check.

◆ m_table

dict_table_t* create_table_info_t::m_table
private

The newly created InnoDB table object.

This is currently only used in this class, since the new table is not evictable until final success/failure, it can be accessed directly.

◆ m_table_name

char* create_table_info_t::m_table_name
private

Table name.

◆ m_tablespace

char* create_table_info_t::m_tablespace
private

Tablespace name or zero length-string.

◆ m_thd

THD* create_table_info_t::m_thd
private

Connection thread handle.

◆ m_trx

trx_t* create_table_info_t::m_trx
private

InnoDB transaction handle.

◆ m_use_data_dir

bool create_table_info_t::m_use_data_dir
private

Using DATA DIRECTORY.

◆ m_use_file_per_table

bool create_table_info_t::m_use_file_per_table
private

After all considerations, this shows whether we will actually create a table and tablespace using file-per-table.

◆ m_use_shared_space

bool create_table_info_t::m_use_shared_space
private

Using a Shared General Tablespace.


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