MySQL 9.1.0
Source Code Documentation
alter_part Class Reference

Class(interface) which manages the operations for partitions of states in different categories during ALTER PARTITION. More...

Inheritance diagram for alter_part:
[legend]

Public Member Functions

virtual ~alter_part ()=default
 Virtual destructor. More...
 
virtual uint part_id () const
 Return the partition id. More...
 
virtual partition_state state () const
 Return the partition state. More...
 
dict_table_tnew_table ()
 Get the InnoDB table object for newly created partition if applicable. More...
 
void free_old_part (bool check_in_cache, const char *part_name)
 Set the freed old partition to nullptr to avoid dangling pointer. More...
 
virtual int prepare (TABLE *altered_table, const dd::Partition *old_part, dd::Partition *new_part)
 Prepare. More...
 
virtual int try_commit (const TABLE *table, TABLE *altered_table, const dd::Partition *old_part, dd::Partition *new_part)
 Try to commit. More...
 
virtual void rollback ()
 Rollback. More...
 

Protected Member Functions

 alter_part (trx_t *trx, uint part_id, partition_state state, const char *table_name, dict_table_t **old)
 Constructor. More...
 
bool build_partition_name (const dd::Partition *dd_part, bool temp, char *name)
 Build the partition name for specified partition. More...
 
int create (const dd::Table *part_table, const char *part_name, dd::Partition *dd_part, TABLE *table, const char *tablespace, bool file_per_table, uint64_t autoinc, uint64_t autoextend_size)
 Create a new partition. More...
 

Protected Attributes

trx_t *const m_trx
 InnoDB transaction, nullptr if not used. More...
 
uint m_part_id
 Partition id in the table. More...
 
partition_state m_state
 Partition state of the partition on which this class will do operations. More...
 
const char * m_table_name
 Partitioned table name, in form of . More...
 
dict_table_t ** m_old
 The InnoDB table object for old partition. More...
 
dict_table_tm_new
 The InnoDB table object for newly created partition. More...
 

Detailed Description

Class(interface) which manages the operations for partitions of states in different categories during ALTER PARTITION.

There are four categories for now:

  1. normal: mapping to PART_NORMAL, which means the partition is not changed
  2. add: mapping to PART_TO_BE_ADDED
  3. drop: mapping to PART_TO_BE_DROPPED, PART_TO_BE_REORGED and PART_REORGED_DROPPED
  4. change: mapping to PART_CHANGED

Constructor & Destructor Documentation

◆ ~alter_part()

virtual alter_part::~alter_part ( )
virtualdefault

Virtual destructor.

◆ alter_part()

alter_part::alter_part ( trx_t trx,
uint  part_id,
partition_state  state,
const char *  table_name,
dict_table_t **  old 
)
inlineprotected

Constructor.

Parameters
[in,out]trxInnoDB transaction, nullptr if not used
[in]part_idPartition id in the table. This could be partition id for either old table or new table, callers should remember which one is applicable
[in]statePartition state of the partition on which this class will do operations. If this is for one partition in new table, the partition state is the same for both the new partition and the corresponding old partition
[in]table_namePartitioned table name, in the form of db/table, which considers the charset
[in,out]oldInnoDB table object for old partition, default is nullptr, which means there is no corresponding object

Member Function Documentation

◆ build_partition_name()

bool alter_part::build_partition_name ( const dd::Partition dd_part,
bool  temp,
char *  name 
)
protected

Build the partition name for specified partition.

Parameters
[in]dd_partdd::Partition
[in]tempTrue if this is a temporary name
[out]namePartition name buffer of length FN_REFLEN
Returns
true if successful.

◆ create()

int alter_part::create ( const dd::Table part_table,
const char *  part_name,
dd::Partition dd_part,
TABLE table,
const char *  tablespace,
bool  file_per_table,
uint64_t  autoinc,
uint64_t  autoextend_size 
)
protected

Create a new partition.

Parameters
[in]part_tablepartition table
[in]part_namePartition name, including db/table
[in,out]dd_partdd::Partition
[in]tableTable format
[in]tablespaceTablespace of this partition, if length is 0, it means no tablespace specified
[in]file_per_tableCurrent value of innodb_file_per_table
[in]autoincNext AUTOINC value to use
[in]autoextend_sizeValue of AUTOEXTEND_SIZE for this tablespace
Returns
0 or error number

◆ free_old_part()

void alter_part::free_old_part ( bool  check_in_cache,
const char *  part_name 
)
inline

Set the freed old partition to nullptr to avoid dangling pointer.

Parameters
check_in_cachewhether we need to check table in cache
part_namePartitioned table name .

◆ new_table()

dict_table_t * alter_part::new_table ( )
inline

Get the InnoDB table object for newly created partition if applicable.

Returns
the InnoDB table object or nullptr if not applicable

◆ part_id()

virtual uint alter_part::part_id ( ) const
inlinevirtual

Return the partition id.

◆ prepare()

virtual int alter_part::prepare ( TABLE altered_table,
const dd::Partition old_part,
dd::Partition new_part 
)
inlinevirtual

Prepare.

Parameters
[in,out]altered_tableTable definition after the ALTER
[in]old_partthe stored old partition or nullptr if no corresponding one exists
[in,out]new_partthe stored new partition or nullptr if no corresponding one exists
Returns
0 or error number

Reimplemented in alter_part_normal, alter_part_add, and alter_part_change.

◆ rollback()

virtual void alter_part::rollback ( )
inlinevirtual

Rollback.

Reimplemented in alter_part_add, and alter_part_change.

◆ state()

virtual partition_state alter_part::state ( ) const
inlinevirtual

Return the partition state.

◆ try_commit()

virtual int alter_part::try_commit ( const TABLE table,
TABLE altered_table,
const dd::Partition old_part,
dd::Partition new_part 
)
inlinevirtual

Try to commit.

Parameters
[in]tableTable definition before the ALTER
[in,out]altered_tableTable definition after the ALTER
[in]old_partthe stored old partition or nullptr if no corresponding one exists
[in,out]new_partthe stored new partition or nullptr if no corresponding one exists
Returns
0 or error number

Reimplemented in alter_part_normal, alter_part_add, alter_part_drop, and alter_part_change.

Member Data Documentation

◆ m_new

dict_table_t* alter_part::m_new
protected

The InnoDB table object for newly created partition.

◆ m_old

dict_table_t** alter_part::m_old
protected

The InnoDB table object for old partition.

◆ m_part_id

uint alter_part::m_part_id
protected

Partition id in the table.

This could be partition id for either old table or new table, callers should remember which one is applicable

◆ m_state

partition_state alter_part::m_state
protected

Partition state of the partition on which this class will do operations.

If this is for one partition in new table, the partition state is the same for both the new partition and the corresponding old partition

◆ m_table_name

const char* alter_part::m_table_name
protected

Partitioned table name, in form of .

/db/table, which already considers the charset

◆ m_trx

trx_t* const alter_part::m_trx
protected

InnoDB transaction, nullptr if not used.


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