MySQL 9.1.0
Source Code Documentation
|
#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_info * | get_clone (THD *thd, bool reset=false) |
partition_info * | get_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 *) |
Item * | get_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_element * | get_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) |
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... | |
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 |
|
inline |
|
private |
Mark named [sub]partition to be used/locked.
part_name | Partition name to match. |
length | Partition name length. |
true | Partition found |
false | Partition not found |
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.
thd | Thread context | |
duplic | How to handle duplicates | |
update | In case of ON DUPLICATE UPDATE, default function fields | |
update_fields | In case of ON DUPLICATE UPDATE, which fields to update | |
fields | Listed fields | |
empty_values | True if values is empty (only defaults) | |
[out] | prune_needs_default_values | Set on return if copying of default values is needed |
[out] | can_prune_partitions | Enum showing if possible to prune |
[in,out] | used_partitions | If possible to prune the bitmap is initialized and cleared |
false | Success |
true | Failure |
bool partition_info::check_engine_mix | ( | handlerton * | engine_type, |
bool | default_engine | ||
) |
bool partition_info::check_list_constants | ( | THD * | thd | ) |
bool partition_info::check_partition_field_length | ( | ) |
bool partition_info::check_partition_info | ( | THD * | thd, |
handlerton ** | eng_type, | ||
handler * | file, | ||
HA_CREATE_INFO * | info, | ||
bool | check_partition_function | ||
) |
bool partition_info::check_range_constants | ( | THD * | thd | ) |
|
static |
|
private |
|
private |
char * partition_info::find_duplicate_field | ( | ) |
const char * partition_info::find_duplicate_name | ( | ) |
bool partition_info::fix_column_value_functions | ( | THD * | thd, |
part_elem_value * | val, | ||
uint | part_id | ||
) |
Evaluate VALUES functions for column list values.
thd | Thread object |
val | List of column values |
part_id | Partition id we are fixing |
true | Error |
false | Success |
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.
thd | Thread object |
true | Failure |
false | Success |
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.
val | Array of one value |
part_elem | The partition instance |
part_id | Id of partition instance |
true | Failure |
false | Success |
partition_info * partition_info::get_clone | ( | THD * | thd, |
bool | reset = false |
||
) |
Get column item with a proper character set according to the field.
item | Item object to start with |
field | Field for which the item will be compared to |
NULL | Error |
item | Returned item |
|
inline |
partition_info * partition_info::get_full_clone | ( | THD * | thd | ) |
|
inline |
partition_element * partition_info::get_part_elem | ( | const char * | partition_name, |
uint32 * | part_id | ||
) |
Get part_elem and part_id from partition name.
partition_name | Name of partition to search for. | |
[out] | part_id | Id of found partition or NOT_A_PARTITION_ID. |
Pointer | to part_elem of [sub]partition, if not found NULL |
|
inline |
bool partition_info::has_same_partitioning | ( | partition_info * | new_part_info | ) |
Check if the new part_info has the same partitioning.
new_part_info | New partition definition to compare with. |
true | Allowed change (only .frm change, compatible distribution). |
false | Different partitioning, will need redistribution of rows. |
Allocate memory for one partitions bitmap and initialize it.
bitmap | Bitmap instance to initialize. |
mem_root | Memory root to use for bitmap buffer allocation. |
true | Memory allocation failure |
false | Success |
|
private |
Check if fields are in the partitioning expression.
fields | List of Items (fields) |
true | At least one field in the field list is found. |
false | No field is within any partitioning expression. |
|
private |
Check if all partitioning fields are included.
|
inline |
|
inline |
|
inline |
|
inline |
void partition_info::print_debug | ( | const char * | str, |
uint * | value | ||
) |
void partition_info::report_part_expr_error | ( | bool | use_subpart_expr | ) |
Check what kind of error to report.
use_subpart_expr | Use the subpart_expr instead of part_expr |
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.
[in] | create_list | Column list after ALTER TABLE. |
bool partition_info::set_named_partition_bitmap | ( | const char * | part_name, |
size_t | length | ||
) |
Mark named [sub]partition to be used/locked.
bool partition_info::set_part_expr | ( | char * | start_token, |
Item * | item_ptr, | ||
char * | end_token, | ||
bool | is_subpart | ||
) |
bool partition_info::set_partition_bitmaps | ( | Table_ref * | table_list | ) |
Set read/lock_partitions bitmap over non pruned partitions.
table_list | Possible Table_ref which can contain list of partition names to query |
false | OK |
true | Failed to allocate memory for bitmap or list of partitions did not match |
Prune away partitions not mentioned in the PARTITION () clause, if used.
false | Success |
true | Failure |
void partition_info::set_show_version_string | ( | String * | packet | ) |
bool partition_info::set_up_charset_field_preps | ( | ) |
|
private |
|
private |
bool partition_info::set_up_defaults_for_partitioning | ( | Partition_handler * | part_handler, |
HA_CREATE_INFO * | info, | ||
uint | start_no | ||
) |
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.
thd | Thread handler |
fields | Fields to set |
values | Values to use |
info | COPY_INFO used for default values handling |
copy_default_values | True if we should copy default values |
used_partitions | Bitmap to set |
false | Success |
true | Failure A return value of 'true' may indicate conversion error, so caller must check thd->is_error(). |
union { ... } partition_info::@154 |
Key_map partition_info::all_fields_in_PF |
Key_map partition_info::all_fields_in_PPF |
Key_map partition_info::all_fields_in_SPF |
bool partition_info::bitmaps_are_initialized |
bool partition_info::column_list |
handlerton* partition_info::default_engine_type |
bool partition_info::default_partitions_setup |
bool partition_info::defined_max_value |
longlong partition_info::err_value |
bool partition_info::fixed |
Field** partition_info::full_part_field_array |
MY_BITMAP partition_info::full_part_field_set |
get_partitions_in_range_iter partition_info::get_part_iter_for_interval |
get_part_id_func partition_info::get_part_partition_id |
get_part_id_func partition_info::get_part_partition_id_charset |
get_part_id_func partition_info::get_partition_id |
get_partitions_in_range_iter partition_info::get_subpart_iter_for_interval |
get_subpart_id_func partition_info::get_subpartition_id |
get_subpart_id_func partition_info::get_subpartition_id_charset |
uint partition_info::has_null_part_id |
bool partition_info::has_null_value |
bool partition_info::is_auto_partitioned |
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* partition_info::item_list |
enum_key_algorithm partition_info::key_algorithm |
bool partition_info::linear_hash_ind |
uint16 partition_info::linear_hash_mask |
LIST_PART_ENTRY* partition_info::list_array |
part_column_list_val* partition_info::list_col_array |
bool partition_info::list_of_part_fields |
bool partition_info::list_of_subpart_fields |
MY_BITMAP partition_info::lock_partitions |
uint partition_info::num_columns |
uint partition_info::num_full_part_fields |
uint partition_info::num_list_values |
uint partition_info::num_part_fields |
uint partition_info::num_parts |
uint partition_info::num_subpart_fields |
uint partition_info::num_subparts |
Field** partition_info::part_charset_field_array |
Item* partition_info::part_expr |
Field** partition_info::part_field_array |
uchar** partition_info::part_field_buffers |
List<char> partition_info::part_field_list |
size_t partition_info::part_func_len |
char* partition_info::part_func_string |
Partition expression as string.
partition_type partition_info::part_type |
List<partition_element> partition_info::partitions |
part_column_list_val* partition_info::range_col_array |
longlong* partition_info::range_int_array |
MY_BITMAP partition_info::read_partitions |
uchar** partition_info::restore_part_field_ptrs |
uchar** partition_info::restore_subpart_field_ptrs |
Key_map partition_info::some_fields_in_PF |
Field** partition_info::subpart_charset_field_array |
Item* partition_info::subpart_expr |
Field** partition_info::subpart_field_array |
uchar** partition_info::subpart_field_buffers |
List<char> partition_info::subpart_field_list |
size_t partition_info::subpart_func_len |
char* partition_info::subpart_func_string |
Subpartition expression as string.
partition_type partition_info::subpart_type |
TABLE* partition_info::table |
List<partition_element> partition_info::temp_partitions |
bool partition_info::use_default_num_partitions |
bool partition_info::use_default_num_subpartitions |
bool partition_info::use_default_partitions |
bool partition_info::use_default_subpartitions |