MySQL 8.3.0
Source Code Documentation
partition_info Class Reference

#include <partition_info.h>

Public Types

enum  enum_can_prune { PRUNE_NO = 0 , PRUNE_DEFAULTS , PRUNE_YES }
 PRUNE_NO - Unable to prune. More...
 

Public Member Functions

 partition_info ()
 
partition_infoget_clone (THD *thd, bool reset=false)
 
partition_infoget_full_clone (THD *thd)
 
bool set_named_partition_bitmap (const char *part_name, size_t length)
 Mark named [sub]partition to be used/locked. More...
 
bool set_partition_bitmaps (Table_ref *table_list)
 Set read/lock_partitions bitmap over non pruned partitions. More...
 
bool set_read_partitions (List< String > *partition_names)
 Prune away partitions not mentioned in the PARTITION () clause, if used. More...
 
bool is_sub_partitioned () const
 
uint get_tot_partitions () const
 
bool set_up_defaults_for_partitioning (Partition_handler *part_handler, HA_CREATE_INFO *info, uint start_no)
 
char * find_duplicate_field ()
 
const char * find_duplicate_name ()
 
bool check_engine_mix (handlerton *engine_type, bool default_engine)
 
bool check_range_constants (THD *thd)
 
bool check_list_constants (THD *thd)
 
bool check_partition_info (THD *thd, handlerton **eng_type, handler *file, HA_CREATE_INFO *info, bool check_partition_function)
 
void print_no_partition_found (THD *thd, TABLE *table)
 
void print_debug (const char *str, uint *)
 
Itemget_column_item (Item *item, Field *field)
 Get column item with a proper character set according to the field. More...
 
bool fix_partition_values (part_elem_value *val, partition_element *part_elem, uint part_id)
 This function handles the case of function-based partitioning. More...
 
bool fix_column_value_functions (THD *thd, part_elem_value *val, uint part_id)
 Evaluate VALUES functions for column list values. More...
 
bool fix_parser_data (THD *thd)
 Fix partition data from parser. More...
 
bool set_part_expr (char *start_token, Item *item_ptr, char *end_token, bool is_subpart)
 
bool set_up_charset_field_preps ()
 
bool check_partition_field_length ()
 
void set_show_version_string (String *packet)
 
partition_elementget_part_elem (const char *partition_name, uint32 *part_id)
 Get part_elem and part_id from partition name. More...
 
void report_part_expr_error (bool use_subpart_expr)
 Check what kind of error to report. More...
 
bool set_used_partition (THD *thd, const mem_root_deque< Item * > &fields, const mem_root_deque< Item * > &values, COPY_INFO &info, bool copy_default_values, MY_BITMAP *used_partitions)
 Mark the partition, the record belongs to, as used. More...
 
bool can_prune_insert (THD *thd, enum_duplicates duplic, COPY_INFO &update, const mem_root_deque< Item * > &update_fields, const mem_root_deque< Item * > &fields, bool empty_values, enum_can_prune *can_prune_partitions, bool *prune_needs_default_values, MY_BITMAP *used_partitions)
 Checks if possible to do prune partitions on insert. More...
 
bool has_same_partitioning (partition_info *new_part_info)
 Check if the new part_info has the same partitioning. More...
 
bool is_partition_used (uint part_id) const
 
bool is_partition_locked (uint part_id) const
 
uint num_partitions_used ()
 
uint get_first_used_partition () const
 
uint get_next_used_partition (uint part_id) const
 
bool same_key_column_order (List< Create_field > *create_list)
 Check if the partitioning columns are in the same order as the given list. More...
 
bool init_partition_bitmap (MY_BITMAP *bitmap, MEM_ROOT *mem_root)
 Allocate memory for one partitions bitmap and initialize it. More...
 

Static Public Member Functions

static bool compare_column_values (const part_column_list_val *a, const part_column_list_val *b)
 

Public Attributes

List< partition_elementpartitions
 
List< partition_elementtemp_partitions
 
List< char > part_field_list
 
List< char > subpart_field_list
 
get_part_id_func get_partition_id
 
get_part_id_func get_part_partition_id
 
get_subpart_id_func get_subpartition_id
 
get_part_id_func get_part_partition_id_charset
 
get_subpart_id_func get_subpartition_id_charset
 
Field ** part_field_array
 
Field ** subpart_field_array
 
Field ** part_charset_field_array
 
Field ** subpart_charset_field_array
 
Field ** full_part_field_array
 
MY_BITMAP full_part_field_set
 
uchar ** part_field_buffers
 
uchar ** subpart_field_buffers
 
uchar ** restore_part_field_ptrs
 
uchar ** restore_subpart_field_ptrs
 
Itempart_expr
 
Itemsubpart_expr
 
Itemitem_list
 
MY_BITMAP read_partitions
 
MY_BITMAP lock_partitions
 
bool bitmaps_are_initialized
 
union {
   longlong *   range_int_array
 
   LIST_PART_ENTRY *   list_array
 
   part_column_list_val *   range_col_array
 
   part_column_list_val *   list_col_array
 
}; 
 
get_partitions_in_range_iter get_part_iter_for_interval
 
get_partitions_in_range_iter get_subpart_iter_for_interval
 
longlong err_value
 
char * part_func_string
 Partition expression as string. More...
 
char * subpart_func_string
 Subpartition expression as string. More...
 
uint num_columns
 
TABLEtable
 
Key_map all_fields_in_PF
 
Key_map all_fields_in_PPF
 
Key_map all_fields_in_SPF
 
Key_map some_fields_in_PF
 
handlertondefault_engine_type
 
partition_type part_type
 
partition_type subpart_type
 
size_t part_func_len
 
size_t subpart_func_len
 
uint num_parts
 
uint num_subparts
 
uint num_list_values
 
uint num_part_fields
 
uint num_subpart_fields
 
uint num_full_part_fields
 
uint has_null_part_id
 
uint16 linear_hash_mask
 
enum_key_algorithm key_algorithm
 
bool use_default_partitions
 
bool use_default_num_partitions
 
bool use_default_subpartitions
 
bool use_default_num_subpartitions
 
bool default_partitions_setup
 
bool defined_max_value
 
bool list_of_part_fields
 
bool list_of_subpart_fields
 
bool linear_hash_ind
 
bool fixed
 
bool is_auto_partitioned
 
bool has_null_value
 
bool column_list
 
bool is_pruning_completed
 True if pruning has been completed and can not be pruned any further, even if there are subqueries or stored programs in the condition. More...
 

Private Member Functions

bool set_up_default_partitions (Partition_handler *part_handler, HA_CREATE_INFO *info, uint start_no)
 
bool set_up_default_subpartitions (Partition_handler *part_handler, HA_CREATE_INFO *info)
 
char * create_default_partition_names (uint num_parts, uint start_no)
 
char * create_default_subpartition_name (uint subpart_no, const char *part_name)
 
bool add_named_partition (const char *part_name, size_t length)
 Mark named [sub]partition to be used/locked. More...
 
bool is_fields_in_part_expr (const mem_root_deque< Item * > &fields)
 Check if fields are in the partitioning expression. More...
 
bool is_full_part_expr_in_fields (const mem_root_deque< Item * > &fields)
 Check if all partitioning fields are included. More...
 

Member Enumeration Documentation

◆ enum_can_prune

PRUNE_NO - Unable to prune.

PRUNE_DEFAULTS - Partitioning field is only set to DEFAULT values, only need to check pruning for one row where the DEFAULTS values are set. PRUNE_YES - Pruning is possible, calculate the used partition set by evaluate the partition_id on row by row basis.

Enumerator
PRUNE_NO 
PRUNE_DEFAULTS 
PRUNE_YES 

Constructor & Destructor Documentation

◆ partition_info()

partition_info::partition_info ( )
inline

Member Function Documentation

◆ add_named_partition()

bool partition_info::add_named_partition ( const char *  part_name,
size_t  length 
)
private

Mark named [sub]partition to be used/locked.

Parameters
part_namePartition name to match.
lengthPartition name length.
Returns
Success if partition found
Return values
truePartition found
falsePartition not found

◆ can_prune_insert()

bool partition_info::can_prune_insert ( THD thd,
enum_duplicates  duplic,
COPY_INFO update,
const mem_root_deque< Item * > &  update_fields,
const mem_root_deque< Item * > &  fields,
bool  empty_values,
enum_can_prune can_prune_partitions,
bool *  prune_needs_default_values,
MY_BITMAP used_partitions 
)

Checks if possible to do prune partitions on insert.

Parameters
thdThread context
duplicHow to handle duplicates
updateIn case of ON DUPLICATE UPDATE, default function fields
update_fieldsIn case of ON DUPLICATE UPDATE, which fields to update
fieldsListed fields
empty_valuesTrue if values is empty (only defaults)
[out]prune_needs_default_valuesSet on return if copying of default values is needed
[out]can_prune_partitionsEnum showing if possible to prune
[in,out]used_partitionsIf possible to prune the bitmap is initialized and cleared
Returns
Operation status
Return values
falseSuccess
trueFailure

◆ check_engine_mix()

bool partition_info::check_engine_mix ( handlerton engine_type,
bool  default_engine 
)

◆ check_list_constants()

bool partition_info::check_list_constants ( THD thd)

◆ check_partition_field_length()

bool partition_info::check_partition_field_length ( )

◆ check_partition_info()

bool partition_info::check_partition_info ( THD thd,
handlerton **  eng_type,
handler file,
HA_CREATE_INFO info,
bool  check_partition_function 
)

◆ check_range_constants()

bool partition_info::check_range_constants ( THD thd)

◆ compare_column_values()

bool partition_info::compare_column_values ( const part_column_list_val a,
const part_column_list_val b 
)
static

◆ create_default_partition_names()

char * partition_info::create_default_partition_names ( uint  num_parts,
uint  start_no 
)
private

◆ create_default_subpartition_name()

char * partition_info::create_default_subpartition_name ( uint  subpart_no,
const char *  part_name 
)
private

◆ find_duplicate_field()

char * partition_info::find_duplicate_field ( )

◆ find_duplicate_name()

const char * partition_info::find_duplicate_name ( )

◆ fix_column_value_functions()

bool partition_info::fix_column_value_functions ( THD thd,
part_elem_value val,
uint  part_id 
)

Evaluate VALUES functions for column list values.

Parameters
thdThread object
valList of column values
part_idPartition id we are fixing
Returns
Operation status
Return values
trueError
falseSuccess
Note
Fix column VALUES and store in memory array adapted to the data type.

◆ fix_parser_data()

bool partition_info::fix_parser_data ( THD thd)

Fix partition data from parser.

The parser generates generic data structures, we need to set them up as the rest of the code expects to find them. This is in reality part of the syntax check of the parser code.

It is necessary to call this function in the case of a CREATE TABLE statement, in this case we do it early in the check_partition_info function.

It is necessary to call this function for ALTER TABLE where we assign a completely new partition structure, in this case we do it in prep_alter_part_table after discovering that the partition structure is entirely redefined.

It's necessary to call this method also for ALTER TABLE ADD/REORGANIZE of partitions, in this we call it in prep_alter_part_table after making some initial checks but before going deep to check the partition info, we also assign the column_list variable before calling this function here.

Finally we also call it immediately after returning from parsing the partitioning text found in the frm file.

This function mainly fixes the VALUES parts, these are handled differently whether or not we use column list partitioning. Since the parser doesn't know which we are using we need to set-up the old data structures after the parser is complete when we know if what type of partitioning the base table is using.

For column lists we will handle this in the fix_column_value_function. For column lists it is sufficient to verify that the number of columns and number of elements are in synch with each other. So only partitioning using functions need to be set-up to their data structures.

Parameters
thdThread object
Returns
Operation status
Return values
trueFailure
falseSuccess

◆ fix_partition_values()

bool partition_info::fix_partition_values ( part_elem_value val,
partition_element part_elem,
uint  part_id 
)

This function handles the case of function-based partitioning.

It fixes some data structures created in the parser and puts them in the format required by the rest of the partitioning code.

Parameters
valArray of one value
part_elemThe partition instance
part_idId of partition instance
Returns
Operation status
Return values
trueFailure
falseSuccess

◆ get_clone()

partition_info * partition_info::get_clone ( THD thd,
bool  reset = false 
)

◆ get_column_item()

Item * partition_info::get_column_item ( Item item,
Field field 
)

Get column item with a proper character set according to the field.

Parameters
itemItem object to start with
fieldField for which the item will be compared to
Returns
Column item
Return values
NULLError
itemReturned item

◆ get_first_used_partition()

uint partition_info::get_first_used_partition ( ) const
inline

◆ get_full_clone()

partition_info * partition_info::get_full_clone ( THD thd)

◆ get_next_used_partition()

uint partition_info::get_next_used_partition ( uint  part_id) const
inline

◆ get_part_elem()

partition_element * partition_info::get_part_elem ( const char *  partition_name,
uint32 part_id 
)

Get part_elem and part_id from partition name.

Parameters
partition_nameName of partition to search for.
[out]part_idId of found partition or NOT_A_PARTITION_ID.
Return values
Pointerto part_elem of [sub]partition, if not found NULL
Note
Since names of partitions AND subpartitions must be unique, this function searches both partitions and subpartitions and if name of a partition is given for a subpartitioned table, part_elem will be the partition, but part_id will be NOT_A_PARTITION_ID and file_name not set.

◆ get_tot_partitions()

uint partition_info::get_tot_partitions ( ) const
inline

◆ has_same_partitioning()

bool partition_info::has_same_partitioning ( partition_info new_part_info)

Check if the new part_info has the same partitioning.

Parameters
new_part_infoNew partition definition to compare with.
Returns
True if not considered to have changed the partitioning.
Return values
trueAllowed change (only .frm change, compatible distribution).
falseDifferent partitioning, will need redistribution of rows.
Note
Currently only used to allow changing from non-set key_algorithm to a specified key_algorithm, to avoid rebuild when upgrading from 5.1 of such partitioned tables using numeric columns in the partitioning expression. For more info see bug#14521864. Does not check if columns etc has changed, i.e. only for alter_info->flags == ALTER_PARTITION.

◆ init_partition_bitmap()

bool partition_info::init_partition_bitmap ( MY_BITMAP bitmap,
MEM_ROOT mem_root 
)

Allocate memory for one partitions bitmap and initialize it.

Parameters
bitmapBitmap instance to initialize.
mem_rootMemory root to use for bitmap buffer allocation.
Return values
trueMemory allocation failure
falseSuccess

◆ is_fields_in_part_expr()

bool partition_info::is_fields_in_part_expr ( const mem_root_deque< Item * > &  fields)
private

Check if fields are in the partitioning expression.

Parameters
fieldsList of Items (fields)
Returns
True if any field in the fields list is used by a partitioning expr.
Return values
trueAt least one field in the field list is found.
falseNo field is within any partitioning expression.

◆ is_full_part_expr_in_fields()

bool partition_info::is_full_part_expr_in_fields ( const mem_root_deque< Item * > &  fields)
private

Check if all partitioning fields are included.

◆ is_partition_locked()

bool partition_info::is_partition_locked ( uint  part_id) const
inline

◆ is_partition_used()

bool partition_info::is_partition_used ( uint  part_id) const
inline

◆ is_sub_partitioned()

bool partition_info::is_sub_partitioned ( ) const
inline

◆ num_partitions_used()

uint partition_info::num_partitions_used ( )
inline

◆ print_debug()

void partition_info::print_debug ( const char *  str,
uint *  value 
)

◆ print_no_partition_found()

void partition_info::print_no_partition_found ( THD thd,
TABLE table 
)

◆ report_part_expr_error()

void partition_info::report_part_expr_error ( bool  use_subpart_expr)

Check what kind of error to report.

Parameters
use_subpart_exprUse the subpart_expr instead of part_expr

◆ same_key_column_order()

bool partition_info::same_key_column_order ( List< Create_field > *  create_list)

Check if the partitioning columns are in the same order as the given list.

Used to see if INPLACE alter can be allowed or not. If the order is different then the rows must be redistributed for KEY [sub]partitioning.

Parameters
[in]create_listColumn list after ALTER TABLE.
Returns
true is same order as before ALTER TABLE, else false.

◆ set_named_partition_bitmap()

bool partition_info::set_named_partition_bitmap ( const char *  part_name,
size_t  length 
)

Mark named [sub]partition to be used/locked.

◆ set_part_expr()

bool partition_info::set_part_expr ( char *  start_token,
Item item_ptr,
char *  end_token,
bool  is_subpart 
)

◆ set_partition_bitmaps()

bool partition_info::set_partition_bitmaps ( Table_ref table_list)

Set read/lock_partitions bitmap over non pruned partitions.

Parameters
table_listPossible Table_ref which can contain list of partition names to query
Returns
Operation status
Return values
falseOK
trueFailed to allocate memory for bitmap or list of partitions did not match
Note
OK to call multiple times without the need for free_bitmaps.

◆ set_read_partitions()

bool partition_info::set_read_partitions ( List< String > *  partition_names)

Prune away partitions not mentioned in the PARTITION () clause, if used.

Returns
Operation status
Return values
falseSuccess
trueFailure

◆ set_show_version_string()

void partition_info::set_show_version_string ( String packet)

◆ set_up_charset_field_preps()

bool partition_info::set_up_charset_field_preps ( )

◆ set_up_default_partitions()

bool partition_info::set_up_default_partitions ( Partition_handler part_handler,
HA_CREATE_INFO info,
uint  start_no 
)
private

◆ set_up_default_subpartitions()

bool partition_info::set_up_default_subpartitions ( Partition_handler part_handler,
HA_CREATE_INFO info 
)
private

◆ set_up_defaults_for_partitioning()

bool partition_info::set_up_defaults_for_partitioning ( Partition_handler part_handler,
HA_CREATE_INFO info,
uint  start_no 
)

◆ set_used_partition()

bool partition_info::set_used_partition ( THD thd,
const mem_root_deque< Item * > &  fields,
const mem_root_deque< Item * > &  values,
COPY_INFO info,
bool  copy_default_values,
MY_BITMAP used_partitions 
)

Mark the partition, the record belongs to, as used.

Parameters
thdThread handler
fieldsFields to set
valuesValues to use
infoCOPY_INFO used for default values handling
copy_default_valuesTrue if we should copy default values
used_partitionsBitmap to set
Returns
Operational status
Return values
falseSuccess
trueFailure A return value of 'true' may indicate conversion error, so caller must check thd->is_error().

Member Data Documentation

◆ 

union { ... } partition_info::@149

◆ all_fields_in_PF

Key_map partition_info::all_fields_in_PF

◆ all_fields_in_PPF

Key_map partition_info::all_fields_in_PPF

◆ all_fields_in_SPF

Key_map partition_info::all_fields_in_SPF

◆ bitmaps_are_initialized

bool partition_info::bitmaps_are_initialized

◆ column_list

bool partition_info::column_list

◆ default_engine_type

handlerton* partition_info::default_engine_type

◆ default_partitions_setup

bool partition_info::default_partitions_setup

◆ defined_max_value

bool partition_info::defined_max_value

◆ err_value

longlong partition_info::err_value

◆ fixed

bool partition_info::fixed

◆ full_part_field_array

Field** partition_info::full_part_field_array

◆ full_part_field_set

MY_BITMAP partition_info::full_part_field_set

◆ get_part_iter_for_interval

get_partitions_in_range_iter partition_info::get_part_iter_for_interval

◆ get_part_partition_id

get_part_id_func partition_info::get_part_partition_id

◆ get_part_partition_id_charset

get_part_id_func partition_info::get_part_partition_id_charset

◆ get_partition_id

get_part_id_func partition_info::get_partition_id

◆ get_subpart_iter_for_interval

get_partitions_in_range_iter partition_info::get_subpart_iter_for_interval

◆ get_subpartition_id

get_subpart_id_func partition_info::get_subpartition_id

◆ get_subpartition_id_charset

get_subpart_id_func partition_info::get_subpartition_id_charset

◆ has_null_part_id

uint partition_info::has_null_part_id

◆ has_null_value

bool partition_info::has_null_value

◆ is_auto_partitioned

bool partition_info::is_auto_partitioned

◆ is_pruning_completed

bool partition_info::is_pruning_completed

True if pruning has been completed and can not be pruned any further, even if there are subqueries or stored programs in the condition.

Some times it is needed to run prune_partitions() a second time to prune read partitions after tables are locked, when subquery and stored functions might have been evaluated.

◆ item_list

Item* partition_info::item_list

◆ key_algorithm

enum_key_algorithm partition_info::key_algorithm

◆ linear_hash_ind

bool partition_info::linear_hash_ind

◆ linear_hash_mask

uint16 partition_info::linear_hash_mask

◆ list_array

LIST_PART_ENTRY* partition_info::list_array

◆ list_col_array

part_column_list_val* partition_info::list_col_array

◆ list_of_part_fields

bool partition_info::list_of_part_fields

◆ list_of_subpart_fields

bool partition_info::list_of_subpart_fields

◆ lock_partitions

MY_BITMAP partition_info::lock_partitions

◆ num_columns

uint partition_info::num_columns

◆ num_full_part_fields

uint partition_info::num_full_part_fields

◆ num_list_values

uint partition_info::num_list_values

◆ num_part_fields

uint partition_info::num_part_fields

◆ num_parts

uint partition_info::num_parts

◆ num_subpart_fields

uint partition_info::num_subpart_fields

◆ num_subparts

uint partition_info::num_subparts

◆ part_charset_field_array

Field** partition_info::part_charset_field_array

◆ part_expr

Item* partition_info::part_expr

◆ part_field_array

Field** partition_info::part_field_array

◆ part_field_buffers

uchar** partition_info::part_field_buffers

◆ part_field_list

List<char> partition_info::part_field_list

◆ part_func_len

size_t partition_info::part_func_len

◆ part_func_string

char* partition_info::part_func_string

Partition expression as string.

◆ part_type

partition_type partition_info::part_type

◆ partitions

List<partition_element> partition_info::partitions

◆ range_col_array

part_column_list_val* partition_info::range_col_array

◆ range_int_array

longlong* partition_info::range_int_array

◆ read_partitions

MY_BITMAP partition_info::read_partitions

◆ restore_part_field_ptrs

uchar** partition_info::restore_part_field_ptrs

◆ restore_subpart_field_ptrs

uchar** partition_info::restore_subpart_field_ptrs

◆ some_fields_in_PF

Key_map partition_info::some_fields_in_PF

◆ subpart_charset_field_array

Field** partition_info::subpart_charset_field_array

◆ subpart_expr

Item* partition_info::subpart_expr

◆ subpart_field_array

Field** partition_info::subpart_field_array

◆ subpart_field_buffers

uchar** partition_info::subpart_field_buffers

◆ subpart_field_list

List<char> partition_info::subpart_field_list

◆ subpart_func_len

size_t partition_info::subpart_func_len

◆ subpart_func_string

char* partition_info::subpart_func_string

Subpartition expression as string.

◆ subpart_type

partition_type partition_info::subpart_type

◆ table

TABLE* partition_info::table

◆ temp_partitions

List<partition_element> partition_info::temp_partitions

◆ use_default_num_partitions

bool partition_info::use_default_num_partitions

◆ use_default_num_subpartitions

bool partition_info::use_default_num_subpartitions

◆ use_default_partitions

bool partition_info::use_default_partitions

◆ use_default_subpartitions

bool partition_info::use_default_subpartitions

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