MySQL 9.0.0
Source Code Documentation
dd::sdi::Import_target Class Reference

State and operations for importing an sdi file into the DD. More...

#include <sdi_api.h>

Public Member Functions

 Import_target (String_type &&path, bool in_datadir)
 Creates an instance to handle the import of a single sdi file. More...
 
 Import_target (Import_target &&)=default
 Having a unique_ptr as member makes this a move-only type. More...
 
 Import_target (const Import_target &)=delete
 
bool commit () const
 Finish import by removing tmp sdi file when importing from sdi file in datadir. More...
 
bool rollback () const
 Restore old state by renaming tmp sdi file back to its original name when importing from sdi file in datadir. More...
 
const dd::String_typecan_table_name () const
 Obtains the canonical table name for use with MDL and privilege-checking. More...
 
const dd::String_typecan_schema_name () const
 Obtains the canonical schema name for use with MDL and privilege-checking. More...
 
bool load (THD *thd, String_type *shared_buffer)
 Reads the sdi file from disk and dserializes it into a Table object and its schema name, but does not store Table object in the DD. More...
 
Table_ref make_table_ref () const
 Constructs a Table_ref object with info from this Import_target. More...
 
bool store_in_dd (THD *thd) const
 Update the schema reference in the Table object and store it in the DD so that it becomes visible. More...
 

Private Attributes

dd::String_type m_path
 Full path to the sdi file being imported. More...
 
bool m_in_datadir
 True if path points inside data dir. More...
 
dd::String_type m_tmp_sdi_filename
 Temporary name for sdi files in data dir when import is ongoing. More...
 
std::unique_ptr< dd::Tablem_table_object
 Table object which the sdi will be deserialized into. More...
 
dd::String_type m_schema_name_in_sdi
 Schema name found in sdi. More...
 
std::unique_ptr< dd::String_typem_lc_tname
 Lower-case representation of table name if lower_case_table_names==2, nullptr otherwise. More...
 
std::unique_ptr< dd::String_typem_lc_sname
 Lower-case representation of schema name if lower_case_table_names==2, nullptr otherwise. More...
 

Detailed Description

State and operations for importing an sdi file into the DD.

Constructor & Destructor Documentation

◆ Import_target() [1/3]

dd::sdi::Import_target::Import_target ( String_type &&  path,
bool  in_datadir 
)

Creates an instance to handle the import of a single sdi file.

Parameters
pathfull path to an sdi file to import
in_datadirtrue if the file is located somewhere under the server's data directory.

◆ Import_target() [2/3]

dd::sdi::Import_target::Import_target ( Import_target &&  )
default

Having a unique_ptr as member makes this a move-only type.

◆ Import_target() [3/3]

dd::sdi::Import_target::Import_target ( const Import_target )
delete

Member Function Documentation

◆ can_schema_name()

const dd::String_type * dd::sdi::Import_target::can_schema_name ( ) const

Obtains the canonical schema name for use with MDL and privilege-checking.

For lower_case_table_names=0 and 1, this is the same as the schema name of the table in the sdi. For lower_case_table_names=2 it is the lower case version of the schemaname.

Returns
pointer to dd::String_type holding canonical name

◆ can_table_name()

const dd::String_type * dd::sdi::Import_target::can_table_name ( ) const

Obtains the canonical table name for use with MDL and privilege-checking.

For lower_case_table_names=0 and 1, this is the same as the name of the Table object. For lower_case_table_names=2 it is the lower case version of the tablename.

Returns
pointer to dd::String_type holding canonical name

◆ commit()

bool dd::sdi::Import_target::commit ( ) const

Finish import by removing tmp sdi file when importing from sdi file in datadir.

Return values
trueif an error occurred
falseotherwise

◆ load()

bool dd::sdi::Import_target::load ( THD thd,
String_type shared_buffer 
)

Reads the sdi file from disk and dserializes it into a Table object and its schema name, but does not store Table object in the DD.

Parameters
thdthread context
shared_bufferpointer to a dd::String_type which is used to store the sdi string until it is deserialized.
Return values
trueif an error occurred
falseotherwise

◆ make_table_ref()

Table_ref dd::sdi::Import_target::make_table_ref ( ) const

Constructs a Table_ref object with info from this Import_target.

Table_ref::db and Table_ref::table_name are initialized to the canonical (lowercased for lctn==2) representation, Table_ref::alias to the native table_name, and Table_ref::m_lock_descriptor.type is set to TL_IGNORE.

◆ rollback()

bool dd::sdi::Import_target::rollback ( ) const

Restore old state by renaming tmp sdi file back to its original name when importing from sdi file in datadir.

Return values
trueif an error occurred
falseotherwise

◆ store_in_dd()

bool dd::sdi::Import_target::store_in_dd ( THD thd) const

Update the schema reference in the Table object and store it in the DD so that it becomes visible.

Precondition: The Import_target must be loaded and privileges checked before this member function is called.

Parameters
thdthread handle
Return values
trueif an error occurred
falseotherwise

Member Data Documentation

◆ m_in_datadir

bool dd::sdi::Import_target::m_in_datadir
private

True if path points inside data dir.

◆ m_lc_sname

std::unique_ptr<dd::String_type> dd::sdi::Import_target::m_lc_sname
private

Lower-case representation of schema name if lower_case_table_names==2, nullptr otherwise.

◆ m_lc_tname

std::unique_ptr<dd::String_type> dd::sdi::Import_target::m_lc_tname
private

Lower-case representation of table name if lower_case_table_names==2, nullptr otherwise.

◆ m_path

dd::String_type dd::sdi::Import_target::m_path
private

Full path to the sdi file being imported.

◆ m_schema_name_in_sdi

dd::String_type dd::sdi::Import_target::m_schema_name_in_sdi
private

Schema name found in sdi.

◆ m_table_object

std::unique_ptr<dd::Table> dd::sdi::Import_target::m_table_object
private

Table object which the sdi will be deserialized into.

◆ m_tmp_sdi_filename

dd::String_type dd::sdi::Import_target::m_tmp_sdi_filename
private

Temporary name for sdi files in data dir when import is ongoing.


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