MySQL  8.0.21
Source Code Documentation
alter_parts Class Reference

Helper class for in-place alter partitions, see handler.h. More...

Inheritance diagram for alter_parts:
inplace_alter_handler_ctx

Public Member Functions

 alter_parts (trx_t *trx, Ha_innopart_share *part_share, const Alter_inplace_info *ha_alter_info, partition_info *old_part_info, Altered_partitions *new_partitions)
 Constructor. More...
 
 ~alter_parts ()
 Destructor. More...
 
int prepare (const dd::Table &old_dd_tab, dd::Table &new_dd_tab, TABLE *altered_table)
 Create the to be created partitions and update internal structures with concurrent writes blocked, while preparing ALTER TABLE. More...
 
void rollback ()
 Notify the storage engine that the changes made during prepare_inplace_alter_table() and inplace_alter_table() will be rolled back for all the partitions. More...
 
int try_commit (const dd::Table &old_dd_tab, dd::Table &new_dd_tab, const TABLE *table, TABLE *altered_table)
 Try to commit the changes made during prepare_inplace_alter_table() inside the storage engine. More...
 
- Public Member Functions inherited from inplace_alter_handler_ctx
 inplace_alter_handler_ctx ()
 
virtual void set_shared_data (const inplace_alter_handler_ctx *ctx)
 
virtual ~inplace_alter_handler_ctx ()
 

Static Public Member Functions

static bool apply_to (const Alter_inplace_info *ha_alter_info)
 Determine if this is an ALTER TABLE ... More...
 
static bool need_copy (const Alter_inplace_info *ha_alter_info)
 Determine if copying data between partitions is necessary. More...
 

Static Public Attributes

static constexpr Alter_inplace_info::HA_ALTER_FLAGS OPERATIONS
 Operations that the native partitioning can perform inplace. More...
 

Private Member Functions

bool prepare_alter_part (const dd::Table &old_dd_tab, dd::Table &new_dd_tab)
 Initialize the m_news and m_to_drop array here. More...
 
int prepare_or_commit_for_new (const dd::Table &old_dd_tab, dd::Table &new_dd_tab, TABLE *altered_table, bool prepare)
 Prepare or commit for all the partitions in table after ALTER TABLE. More...
 
int prepare_or_commit_for_old (const dd::Table &old_dd_tab, TABLE *altered_table, bool prepare)
 Prepare or commit for all the partitions in table before ALTER TABLE. More...
 

Private Attributes

trx_t *const m_trx
 InnoDB transaction. More...
 
Ha_innopart_share *const m_part_share
 InnoDB partition specific Handler_share. More...
 
const Alter_inplace_info *const m_ha_alter_info
 Operation being performed. More...
 
Altered_partitions *const m_new_partitions
 New partitions helper. More...
 
alter_part_factory m_factory
 alter_part factory which creates all the necessary alter_part_* More...
 
alter_part_array m_news
 The alter_part array for all the newly created partitions. More...
 
alter_part_array m_to_drop
 The alter_part array for all the to be dropped partitions. More...
 

Detailed Description

Helper class for in-place alter partitions, see handler.h.

Constructor & Destructor Documentation

◆ alter_parts()

alter_parts::alter_parts ( trx_t trx,
Ha_innopart_share part_share,
const Alter_inplace_info ha_alter_info,
partition_info old_part_info,
Altered_partitions new_partitions 
)
inline

Constructor.

Parameters
[in,out]trxInnoDB transaction
[in,out]part_shareInnopart share
[in]ha_alter_infoALTER information
[in]old_part_infoPartition info of the table before ALTER TABLE
[in,out]new_partitionsAltered partition helper

◆ ~alter_parts()

alter_parts::~alter_parts ( )

Destructor.

Member Function Documentation

◆ apply_to()

static bool alter_parts::apply_to ( const Alter_inplace_info ha_alter_info)
inlinestatic

Determine if this is an ALTER TABLE ...

PARTITION operation

Parameters
[in]ha_alter_infothd DDL operation
Returns
whether it is a such kind of operation

◆ need_copy()

static bool alter_parts::need_copy ( const Alter_inplace_info ha_alter_info)
inlinestatic

Determine if copying data between partitions is necessary.

Parameters
[in]ha_alter_infothd DDL operation
Returns
whether it is necessary to copy data

◆ prepare()

int alter_parts::prepare ( const dd::Table old_dd_tab,
dd::Table new_dd_tab,
TABLE altered_table 
)

Create the to be created partitions and update internal structures with concurrent writes blocked, while preparing ALTER TABLE.

Parameters
[in]old_dd_tabdd::Table before ALTER TABLE
[in,out]new_dd_tabdd::Table after ALTER TABLE
[in,out]altered_tableTable definition after the ALTER
Returns
0 or error number, my_error() should be called by callers

◆ prepare_alter_part()

bool alter_parts::prepare_alter_part ( const dd::Table old_dd_tab,
dd::Table new_dd_tab 
)
private

Initialize the m_news and m_to_drop array here.

Parameters
[in]old_dd_tabdd::Table before ALTER TABLE
[in]new_dd_tabdd::Table after ALTER TABLE
Return values
trueif success
falseon failure

◆ prepare_or_commit_for_new()

int alter_parts::prepare_or_commit_for_new ( const dd::Table old_dd_tab,
dd::Table new_dd_tab,
TABLE altered_table,
bool  prepare 
)
private

Prepare or commit for all the partitions in table after ALTER TABLE.

Prepare for all the partitions in table after ALTER TABLE.

Parameters
[in]old_dd_tabdd::Table before ALTER TABLE
[in,out]new_dd_tabdd::Table after ALTER TABLE
[in,out]altered_tableTable definition after the ALTER
[in]preparetrue if it's in prepare phase, false if it's in commit phase
Returns
0 or error number

◆ prepare_or_commit_for_old()

int alter_parts::prepare_or_commit_for_old ( const dd::Table old_dd_tab,
TABLE altered_table,
bool  prepare 
)
private

Prepare or commit for all the partitions in table before ALTER TABLE.

Parameters
[in]old_dd_tabdd::Table before ALTER TABLE
[in,out]altered_tableTable definition after the ALTER
[in]preparetrue if it's in prepare phase, false if it's in commit phase
Returns
0 or error number

◆ rollback()

void alter_parts::rollback ( )

Notify the storage engine that the changes made during prepare_inplace_alter_table() and inplace_alter_table() will be rolled back for all the partitions.

◆ try_commit()

int alter_parts::try_commit ( const dd::Table old_dd_tab,
dd::Table new_dd_tab,
const TABLE table,
TABLE altered_table 
)

Try to commit the changes made during prepare_inplace_alter_table() inside the storage engine.

Try to commit the changes made during prepare_inplace_alter_table() inside the storage engine.v This is protected by MDL_EXCLUSIVE.

This is protected by MDL_EXCLUSIVE.

Parameters
[in]old_dd_tabdd::Table before ALTER TABLE
[in,out]new_dd_tabdd::Table after ALTER TABLE
[in]tableTable definition before the ALTER
[in,out]altered_tableTable definition after the ALTER
Returns
0 or error number, my_error() should be called by callers
Parameters
[in]old_dd_tabdd::Table before ALTER TABLE
[in,out]new_dd_tabdd::Table after ALTER TABLE
[in]tableTable definition before the ALTER
[in,out]altered_tableTable definition after the ALTER
Returns
0 or error number, my_error() should be called by callers

Member Data Documentation

◆ m_factory

alter_part_factory alter_parts::m_factory
private

alter_part factory which creates all the necessary alter_part_*

◆ m_ha_alter_info

const Alter_inplace_info* const alter_parts::m_ha_alter_info
private

Operation being performed.

◆ m_new_partitions

Altered_partitions* const alter_parts::m_new_partitions
private

New partitions helper.

◆ m_news

alter_part_array alter_parts::m_news
private

The alter_part array for all the newly created partitions.

◆ m_part_share

Ha_innopart_share* const alter_parts::m_part_share
private

InnoDB partition specific Handler_share.

◆ m_to_drop

alter_part_array alter_parts::m_to_drop
private

The alter_part array for all the to be dropped partitions.

◆ m_trx

trx_t* const alter_parts::m_trx
private

InnoDB transaction.

◆ OPERATIONS


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