MySQL 8.4.3
Source Code Documentation
|
#include <stddef.h>
#include <sys/types.h>
#include "lex_string.h"
#include "my_base.h"
#include "my_inttypes.h"
#include "sql/partition_element.h"
Go to the source code of this file.
Classes | |
struct | part_id_range |
Macros | |
#define | HA_CAN_UPDATE_PARTITION_KEY (1 << 1) |
#define | HA_CAN_PARTITION_UNIQUE (1 << 2) |
#define | HA_USE_AUTO_PARTITION (1 << 3) |
#define | HA_CAN_EXCHANGE_PARTITION (1 << 4) |
The handler can exchange a partition with a non-partitioned table of the same handlerton/engine. More... | |
#define | HA_CANNOT_PARTITION_FK (1 << 5) |
The handler can not use FOREIGN KEYS with partitioning. More... | |
#define | HA_TRUNCATE_PARTITION_PRECLOSE (1 << 6) |
Engine requires closing all open table instances before TRUNCATE PARTITION operation. More... | |
Typedefs | |
typedef key_range | key_range |
Enumerations | |
enum | enum_partition_keywords { PKW_HASH = 0 , PKW_RANGE , PKW_LIST , PKW_KEY , PKW_MAXVALUE , PKW_LINEAR , PKW_COLUMNS , PKW_ALGORITHM } |
Functions | |
int | get_parts_for_update (const uchar *old_data, const uchar *new_data, const uchar *rec0, partition_info *part_info, uint32 *old_part_id, uint32 *new_part_id, longlong *func_value) |
int | get_part_for_delete (const uchar *buf, const uchar *rec0, partition_info *part_info, uint32 *part_id) |
void | prune_partition_set (const TABLE *table, part_id_range *part_spec) |
void | set_linear_hash_mask (partition_info *part_info, uint num_parts) |
bool | fix_partition_func (THD *thd, TABLE *table, bool create_table_ind) |
bool | partition_key_modified (TABLE *table, const MY_BITMAP *fields) |
void | get_partition_set (const TABLE *table, uchar *buf, const uint index, const key_range *key_spec, part_id_range *part_spec) |
uint | get_partition_field_store_length (Field *field) |
bool | get_cs_converted_part_value_from_string (THD *thd, Item *item, String *input_str, String *output_str, const CHARSET_INFO *cs, bool use_hex) |
void | get_full_part_id_from_key (const TABLE *table, uchar *buf, KEY *key_info, const key_range *key_spec, part_id_range *part_spec) |
bool | mysql_unpack_partition (THD *thd, char *part_buf, uint part_info_len, TABLE *table, bool is_create_table_ind, handlerton *default_db_type, bool *work_part_info_used) |
bool | make_used_partitions_str (partition_info *part_info, List< const char > *parts) |
Return comma-separated list of used partitions in the provided given string. More... | |
bool | check_part_func_fields (Field **ptr, bool ok_with_charsets) |
bool | field_is_partition_charset (Field *field) |
Item * | convert_charset_partition_constant (Item *item, const CHARSET_INFO *cs) |
void | append_row_to_str (String &str, const uchar *row, TABLE *table) |
Append all fields in read_set to string. More... | |
void | mem_alloc_error (size_t size) |
void | truncate_partition_filename (MEM_ROOT *root, const char **path) |
Truncate the partition file name from a path if it exists. More... | |
bool | set_part_state (Alter_info *alter_info, partition_info *tab_part_info, enum partition_state part_state, bool include_subpartitions) |
Sets which partitions to be used in the command. More... | |
void | set_all_part_state (partition_info *tab_part_info, enum partition_state part_state) |
Set part_state for all partitions to given state. More... | |
uint | prep_alter_part_table (THD *thd, TABLE *table, Alter_info *alter_info, HA_CREATE_INFO *create_info, Alter_table_ctx *alter_ctx, bool *partition_changed, partition_info **new_part_info) |
int | expr_to_string (String *val_conv, Item *item_expr, Field *field, const char *field_name, const HA_CREATE_INFO *create_info, List< Create_field > *create_fields) |
char * | generate_partition_syntax (partition_info *part_info, uint *buf_length, bool use_sql_alloc, bool show_partition_options, bool print_expr, const char *current_comment_start) |
Generate the partition syntax from the partition data structure. More... | |
bool | verify_data_with_partition (TABLE *table, TABLE *part_table, uint32 part_id) |
Verify that all rows in a table is in the given partition. More... | |
bool | compare_partition_options (HA_CREATE_INFO *table_create_info, partition_element *part_elem) |
Check if partition is exchangeable with table by checking table options. More... | |
Variables | |
const LEX_CSTRING | partition_keywords [] |
#define HA_CAN_EXCHANGE_PARTITION (1 << 4) |
The handler can exchange a partition with a non-partitioned table of the same handlerton/engine.
#define HA_CAN_PARTITION_UNIQUE (1 << 2) |
#define HA_CAN_UPDATE_PARTITION_KEY (1 << 1) |
#define HA_CANNOT_PARTITION_FK (1 << 5) |
The handler can not use FOREIGN KEYS with partitioning.
#define HA_TRUNCATE_PARTITION_PRECLOSE (1 << 6) |
Engine requires closing all open table instances before TRUNCATE PARTITION operation.
#define HA_USE_AUTO_PARTITION (1 << 3) |
Append all fields in read_set to string.
[in,out] | str | String to append to. |
[in] | row | Row to append. |
[in] | table | Table containing read_set and fields for the row. |
bool check_part_func_fields | ( | Field ** | ptr, |
bool | ok_with_charsets | ||
) |
bool compare_partition_options | ( | HA_CREATE_INFO * | table_create_info, |
partition_element * | part_elem | ||
) |
Check if partition is exchangeable with table by checking table options.
table_create_info | Table options from table. |
part_elem | All the info of the partition. |
false | if they are equal, otherwise true. |
Item * convert_charset_partition_constant | ( | Item * | item, |
const CHARSET_INFO * | cs | ||
) |
int expr_to_string | ( | String * | val_conv, |
Item * | item_expr, | ||
Field * | field, | ||
const char * | field_name, | ||
const HA_CREATE_INFO * | create_info, | ||
List< Create_field > * | create_fields | ||
) |
bool field_is_partition_charset | ( | Field * | field | ) |
char * generate_partition_syntax | ( | partition_info * | part_info, |
uint * | buf_length, | ||
bool | use_sql_alloc, | ||
bool | show_partition_options, | ||
bool | print_expr, | ||
const char * | current_comment_start | ||
) |
Generate the partition syntax from the partition data structure.
Useful for support of generating defaults, SHOW CREATE TABLES and easy partition management.
part_info | The partitioning data structure |
buf_length | A pointer to the returned buffer length |
use_sql_alloc | Allocate buffer from sql_alloc if true otherwise use my_malloc |
show_partition_options | Should we display partition options |
print_expr | Indicates whether partitioning expressions should be re-printed to get quoting according to current sql_mode. |
current_comment_start | NULL, or comment string encapsulating the PARTITION BY clause. |
NULL | - error |
The implementation writes the syntax to a temporary file (essentially an abstraction of a dynamic array) and if all writes goes well it allocates a buffer and writes the syntax into this one and returns it.
As a security precaution the file is deleted before writing into it. This means that no other processes on the machine can open and read the file while this processing is ongoing.
The code is optimised for minimal code size since it is not used in any common queries.
bool get_cs_converted_part_value_from_string | ( | THD * | thd, |
Item * | item, | ||
String * | input_str, | ||
String * | output_str, | ||
const CHARSET_INFO * | cs, | ||
bool | use_hex | ||
) |
void get_full_part_id_from_key | ( | const TABLE * | table, |
uchar * | buf, | ||
KEY * | key_info, | ||
const key_range * | key_spec, | ||
part_id_range * | part_spec | ||
) |
int get_part_for_delete | ( | const uchar * | buf, |
const uchar * | rec0, | ||
partition_info * | part_info, | ||
uint32 * | part_id | ||
) |
uint get_partition_field_store_length | ( | Field * | field | ) |
void get_partition_set | ( | const TABLE * | table, |
uchar * | buf, | ||
const uint | index, | ||
const key_range * | key_spec, | ||
part_id_range * | part_spec | ||
) |
int get_parts_for_update | ( | const uchar * | old_data, |
const uchar * | new_data, | ||
const uchar * | rec0, | ||
partition_info * | part_info, | ||
uint32 * | old_part_id, | ||
uint32 * | new_part_id, | ||
longlong * | func_value | ||
) |
bool make_used_partitions_str | ( | partition_info * | part_info, |
List< const char > * | parts | ||
) |
Return comma-separated list of used partitions in the provided given string.
part_info | Partitioning info | |
[out] | parts | The resulting list of string to fill |
Generate a list of used partitions (from bits in part_info->read_partitions bitmap), and store it into the provided String object.
void mem_alloc_error | ( | size_t | size | ) |
bool mysql_unpack_partition | ( | THD * | thd, |
char * | part_buf, | ||
uint | part_info_len, | ||
TABLE * | table, | ||
bool | is_create_table_ind, | ||
handlerton * | default_db_type, | ||
bool * | work_part_info_used | ||
) |
uint prep_alter_part_table | ( | THD * | thd, |
TABLE * | table, | ||
Alter_info * | alter_info, | ||
HA_CREATE_INFO * | create_info, | ||
Alter_table_ctx * | alter_ctx, | ||
bool * | partition_changed, | ||
partition_info ** | new_part_info | ||
) |
void prune_partition_set | ( | const TABLE * | table, |
part_id_range * | part_spec | ||
) |
void set_all_part_state | ( | partition_info * | tab_part_info, |
enum partition_state | part_state | ||
) |
Set part_state for all partitions to given state.
tab_part_info | partition_info holding all partitions. |
part_state | Which state to set for the named partitions. |
void set_linear_hash_mask | ( | partition_info * | part_info, |
uint | num_parts | ||
) |
bool set_part_state | ( | Alter_info * | alter_info, |
partition_info * | tab_part_info, | ||
enum partition_state | part_state, | ||
bool | include_subpartitions | ||
) |
Sets which partitions to be used in the command.
alter_info | Alter_info pointer holding partition names and flags. |
tab_part_info | partition_info holding all partitions. |
part_state | Which state to set for the named partitions. |
include_subpartitions | Also include subpartitions in the search. |
false | Success |
true | Failure |
void truncate_partition_filename | ( | MEM_ROOT * | root, |
const char ** | path | ||
) |
Truncate the partition file name from a path if it exists.
A partition file name will contain one or more '#' characters. One of the occurrences of '#' will be either "#P#" or "#p#" depending on whether the storage engine has converted the filename to lower case. If we need to truncate the name, we will allocate a new string and replace with, in case the original string was owned by something else.
[in] | root | MEM_ROOT to allocate from. If NULL alter the string directly. |
[in,out] | path | Pointer to string to check and truncate. |
Verify that all rows in a table is in the given partition.
table | Table which contains the data that will be checked if it is matching the partition definition. |
part_table | Partitioned table containing the partition to check. |
part_id | Which partition to match with. |
true | Not all rows match the given partition |
false | OK |
|
extern |