MySQL 8.0.40
Source Code Documentation
alter_part_factory Class Reference

Construct all necessary alter_part_* objects according to the given partition states in both old and new tables. More...

Public Member Functions

 alter_part_factory (trx_t *trx, const Alter_inplace_info *ha_alter_info, Ha_innopart_share *part_share, partition_info *old_part_info)
 Constructor. More...
 
 ~alter_part_factory ()=default
 Destructor. More...
 
bool create (alter_part_array &to_drop, alter_part_array &all_news)
 Create the alter_part_* objects according to the given partition states. More...
 

Private Member Functions

bool create_for_reorg (alter_part_array &to_drop, alter_part_array &all_news)
 Suppose that there is a table with 4 range partitions: p0, p1, p2, p3, and the p2 and p3 are going to be reorganized into p21, p22, p31, p33. More...
 
bool create_for_non_reorg (alter_part_array &to_drop, alter_part_array &all_news)
 Suppose that there is a table with 4 range partitions: p0, p1, p2, p3. More...
 
bool create_new_checking_conflict (partition_element *new_part, uint &new_part_id, alter_part_array &all_news)
 Create alter_part_add object(s) along with checking if the partition (and its subpartitions) conflicts with any of the original ones This is only for REORGANIZE PARTITION. More...
 
bool create_old_checking_conflict (partition_element *old_part, uint &old_part_id, alter_part_array &to_drop)
 Create alter_part_drop object(s) along with checking if the partition (and its subpartitions) conflicts with any of the to be created ones. More...
 
bool is_conflict (const partition_element *new_part, const partition_element *old_part)
 Check if the two (sub)partitions conflict with each other, Which means they have same name. More...
 
bool create_one (alter_part_array &array, partition_element *part, uint &part_id, uint old_part_id, partition_state state, bool conflict)
 Create alter_part_* object(s) for subpartitions of a partition, or the partition itself. More...
 
alter_partcreate_one_low (uint &part_id, uint old_part_id, partition_state state, const char *tablespace, bool conflict)
 Create the specified alter_part_* object. 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
 ALTER information. More...
 
partition_info *const m_old_part_info
 Partition info of the table before ALTER TABLE. More...
 
bool m_file_per_table
 Current innodb_file_per_table value. More...
 

Detailed Description

Construct all necessary alter_part_* objects according to the given partition states in both old and new tables.

Constructor & Destructor Documentation

◆ alter_part_factory()

alter_part_factory::alter_part_factory ( trx_t trx,
const Alter_inplace_info ha_alter_info,
Ha_innopart_share part_share,
partition_info old_part_info 
)
inline

Constructor.

Parameters
[in,out]trxTransaction
[in]ha_alter_infoALTER Information
[in,out]part_shareInnopart share
[in]old_part_infoPartition info of the table before ALTER TABLE

◆ ~alter_part_factory()

alter_part_factory::~alter_part_factory ( )
default

Destructor.

Member Function Documentation

◆ create()

bool alter_part_factory::create ( alter_part_array to_drop,
alter_part_array all_news 
)
inline

Create the alter_part_* objects according to the given partition states.

Parameters
[in,out]to_dropTo store the alter_part_* objects for partitions to be dropped
[in,out]all_newsTo store the alter_part_* objects for partitions in table after ALTER TABLE
Returns
false On success
Return values
trueOn failure

◆ create_for_non_reorg()

bool alter_part_factory::create_for_non_reorg ( alter_part_array to_drop,
alter_part_array all_news 
)
private

Suppose that there is a table with 4 range partitions: p0, p1, p2, p3.

  1. ADD PARTITION p4 modified_part_info->partitions list contains {PART_NORMAL, PART_NORMAL, PART_NORMAL, PART_NORMAL, PART_TO_BE_ADDED}.

So finally, the to_drop array would contain {}, which is empty; the all_news array would contains {alter_part_normal, alter_part_normal, alter_part_normal, alter_part_normal, alter_part_add}.

  1. DROP PARTITION p2 modified_part_info->partitions list contain {PART_NORMAL, PART_NORMAL, PART_TO_BE_DROPPED, PART_NORMAL}.

So finally, the to_drop array would contain {alter_part_drop}, which is for p2, so part_id is 2; the all_news array would contains {alter_part_normal, alter_part_normal, alter_part_normal}.

Suppose it's the same table with 4 partitions, but it's partitioned by HASH.

  1. ADD PARTITION 2 modified_part_info->partitions list contains {PART_CHANGED, PART_CHANGED, PART_CHANGED, PART_CHANGED, PART_TO_BE_ADDED, PART_TO_BE_ADDED}.

So finally, the to_drop array would contain {}, which is empty; the all_news array would contains {alter_part_change, alter_part_change, alter_part_change, alter_part_change, alter_part_add, alter_part_add}.

  1. COALESCE PARTITION 2 modified_part_info->partitions contains: {PART_CHANGED, PART_CHANGED, PART_REORGED_DROPPED, PART_REORGED_DROPPED}.

So finally, the to_drop array would contain {alter_part_drop, alter_part_drop}, which are for p2, p3, part_id are 2 and 3; the all_news array would contains {alter_part_change, alter_part_change}.

  1. REBUILD PARTITION p0, p2 modified_part_info->partitions contains: {PART_NORMAL, PART_CHANGED, PART_NORMAL, PART_CHANGED}.

So finally, the to_drop array would contain {}, which is empty; the all_news array would contains {alter_part_normal, alter_part_change, alter_part_normal, alter_part_change}. Create the alter_part_* objects when it's NOT an operation like REORGANIZE PARTITION

Parameters
[in,out]to_dropTo store the alter_part_* objects for partitions to be dropped
[in,out]all_newsTo store the alter_part_* objects for partitions in table after ALTER TABLE
Returns
false On success
Return values
trueOn Failure

◆ create_for_reorg()

bool alter_part_factory::create_for_reorg ( alter_part_array to_drop,
alter_part_array all_news 
)
private

Suppose that there is a table with 4 range partitions: p0, p1, p2, p3, and the p2 and p3 are going to be reorganized into p21, p22, p31, p33.

In modified_part_info->temp_partitions list, there are only p2 and p3 with the state PART_TO_BE_REORGED, while in modified_part_info->partitions list, it contains {PART_NORMAL, PART_NORMAL, PART_TO_BE_ADDED, PART_TO_BE_ADDED, PART_TO_BE_ADDED, PART_TO_BE_ADDED}.

So finally, the to_drop array would contain {alter_part_drop, alter_part_drop}, which are for p2, p3; the all_news array would contains {alter_part_normal, alter_part_normal, alter_part_add, alter_part_add, alter_part_add, alter_part_add}.

Note that the scenario that reorganized and to be reorganized partition/subpartition have the same name, would be checked here too Create the alter_part_* objects when it's an operation like REORGANIZE PARTITION

Parameters
[in,out]to_dropTo store the alter_part_* objects for partitions to be dropped
[in,out]all_newsTo store the alter_part_* objects for partitions in table after ALTER TABLE
Returns
false On success
Return values
trueOn failure

◆ create_new_checking_conflict()

bool alter_part_factory::create_new_checking_conflict ( partition_element new_part,
uint new_part_id,
alter_part_array all_news 
)
private

Create alter_part_add object(s) along with checking if the partition (and its subpartitions) conflicts with any of the original ones This is only for REORGANIZE PARTITION.

Parameters
[in]new_partThe new partition to check
[in,out]new_part_idPartition id for both partition and subpartition, which would be increased by number of subpartitions per partition here
[in,out]all_newsTo store the alter_part_add objects here
Return values
falseOn success
trueOn failure

◆ create_old_checking_conflict()

bool alter_part_factory::create_old_checking_conflict ( partition_element old_part,
uint old_part_id,
alter_part_array to_drop 
)
private

Create alter_part_drop object(s) along with checking if the partition (and its subpartitions) conflicts with any of the to be created ones.

This is only for REORGANIZE PARTITION

Parameters
[in]old_partThe old partition to check
[in,out]old_part_idPartition id for this partition or the first subpartition, which would be increased by number of subpartitions per partition here
[in,out]to_dropTo store the alter_part_drop objects
Return values
falseOn success
trueOn failure

◆ create_one()

bool alter_part_factory::create_one ( alter_part_array array,
partition_element part,
uint part_id,
uint  old_part_id,
partition_state  state,
bool  conflict 
)
private

Create alter_part_* object(s) for subpartitions of a partition, or the partition itself.

Parameters
[in,out]arrayWhere to store the new object(s)
[in]partpartition_element to handle
[in,out]part_idPartition id for both partition and subpartition, which would be increased by number of object(s) created
[in]old_part_idStart partition id of the table before ALTER TABLE
[in]statePartition state
[in]conflictOnly valid when state is PART_TO_BE_ADDED. True if the new (sub)partition has the same name with an exist one and they are of innodb_file_per_table
Return values
falseOn success
trueOn failure

◆ create_one_low()

alter_part * alter_part_factory::create_one_low ( uint part_id,
uint  old_part_id,
partition_state  state,
const char *  tablespace,
bool  conflict 
)
private

Create the specified alter_part_* object.

Parameters
[in]part_idPartition id for current partition
[in]old_part_idStart partition id of the table before ALTER TABLE
[in]statePartition state
[in]tablespaceTablespace specified explicitly
[in]conflictOnly valid when state is PART_TO_BE_ADDED. True if the new (sub)partition has the same name with an exist one and they are of innodb_file_per_table
Returns
alter_part_* object or nullptr

◆ is_conflict()

bool alter_part_factory::is_conflict ( const partition_element new_part,
const partition_element old_part 
)
private

Check if the two (sub)partitions conflict with each other, Which means they have same name.

Parameters
[in]new_partNew partition to check
[in]old_partOld partition to check
Return values
trueConflict
falseNot conflict

Member Data Documentation

◆ m_file_per_table

bool alter_part_factory::m_file_per_table
private

Current innodb_file_per_table value.

◆ m_ha_alter_info

const Alter_inplace_info* const alter_part_factory::m_ha_alter_info
private

ALTER information.

◆ m_old_part_info

partition_info* const alter_part_factory::m_old_part_info
private

Partition info of the table before ALTER TABLE.

◆ m_part_share

Ha_innopart_share* const alter_part_factory::m_part_share
private

InnoDB partition specific Handler_share.

◆ m_trx

trx_t* const alter_part_factory::m_trx
private

InnoDB transaction.


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