MySQL 8.4.3
Source Code Documentation
partition_element.h
Go to the documentation of this file.
1#ifndef PARTITION_ELEMENT_INCLUDED
2#define PARTITION_ELEMENT_INCLUDED
3
4/* Copyright (c) 2005, 2024, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is designed to work with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27#include "my_base.h" /* ha_rows */
28#include "sql/handler.h" /* UNDEF_NODEGROUP */
29
30/**
31 * An enum and a struct to handle partitioning and subpartitioning.
32 */
33enum class partition_type { NONE = 0, RANGE, HASH, LIST };
34
45 PART_ADMIN = 9
46};
47
48/*
49 This struct is used to keep track of column expressions as part
50 of the COLUMNS concept in conjunction with RANGE and LIST partitioning.
51 The value can be either of MINVALUE, MAXVALUE and an expression that
52 must be constant and evaluate to the same type as the column it
53 represents.
54
55 The data in this fixed in two steps. The parser will only fill in whether
56 it is a max_value or provide an expression. Filling in
57 column_value, part_info, partition_id, null_value is done by the
58 function fix_column_value_function. However the item tree needs
59 fixed also before writing it into the frm file (in add_column_list_values).
60 To distinguish between those two variants, fixed= 1 after the
61 fixing in add_column_list_values and fixed= 2 otherwise. This is
62 since the fixing in add_column_list_values isn't a complete fixing.
63*/
64
65typedef struct p_column_list_val {
67 /**
68 When a table is opened this is set to the field image of the value
69 from the item_expression below.
70 */
72 /**
73 When the values are read from dd.Partition_value it is carried as
74 a C-string.
75 */
76 const char *value_str;
78 /**
79 When partition clause is parsed this is set to the item expression
80 for the value. Must be NULL if the value was not parsed, but
81 read from dd.Partition_value instead.
82 */
86 /** MAXVALUE is set (only for RANGE COLUMNS) */
88 /** NULL is set (only for LIST COLUMNS) */
90 char fixed;
92
93/*
94 This struct is used to contain the value of an element
95 in the VALUES IN struct. It needs to keep knowledge of
96 whether it is a signed/unsigned value and whether it is
97 NULL or not.
98*/
99
100typedef struct p_elem_val {
107
109 public:
111 List<part_elem_value> list_val_list; // list of LIST values/column arrays
112 // TODO: Handle options in a more general way, like dd::Properties
113 // for max/min rows, tablespace, data/index file, nodegroup etc.
117 const char *partition_name;
118 const char *tablespace_name;
120 const char *data_file_name;
121 const char *index_file_name;
126 /* TODO: Move this to partition_info?*/
127 bool signed_flag; // Range value signed
128 bool max_value; // MAXVALUE range
129
131 : part_max_rows(0),
132 part_min_rows(0),
133 range_value(0),
142 has_null_value(false),
143 signed_flag(false),
144 max_value(false) {}
146 : part_max_rows(part_elem->part_max_rows),
147 part_min_rows(part_elem->part_min_rows),
148 range_value(0),
151 part_comment(part_elem->part_comment),
152 data_file_name(part_elem->data_file_name),
154 engine_type(part_elem->engine_type),
155 part_state(part_elem->part_state),
156 nodegroup_id(part_elem->nodegroup_id),
157 has_null_value(false),
158 signed_flag(false),
159 max_value(false) {}
160 inline void set_from_info(const HA_CREATE_INFO *info) {
164 part_max_rows = info->max_rows;
165 part_min_rows = info->min_rows;
166 }
167 inline void put_to_info(HA_CREATE_INFO *info) const {
171 info->max_rows = part_max_rows;
172 info->min_rows = part_min_rows;
173 }
174};
175
176#endif /* PARTITION_ELEMENT_INCLUDED */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
Definition: sql_list.h:467
Definition: partition_element.h:108
partition_element()
Definition: partition_element.h:130
const char * index_file_name
Definition: partition_element.h:121
void set_from_info(const HA_CREATE_INFO *info)
Definition: partition_element.h:160
List< part_elem_value > list_val_list
Definition: partition_element.h:111
char * part_comment
Definition: partition_element.h:119
List< partition_element > subpartitions
Definition: partition_element.h:110
handlerton * engine_type
Definition: partition_element.h:122
const char * partition_name
Definition: partition_element.h:117
bool max_value
Definition: partition_element.h:128
bool signed_flag
Definition: partition_element.h:127
longlong range_value
Definition: partition_element.h:116
ha_rows part_min_rows
Definition: partition_element.h:115
void put_to_info(HA_CREATE_INFO *info) const
Definition: partition_element.h:167
enum partition_state part_state
Definition: partition_element.h:123
bool has_null_value
Definition: partition_element.h:125
ha_rows part_max_rows
Definition: partition_element.h:114
uint16 nodegroup_id
Definition: partition_element.h:124
partition_element(partition_element *part_elem)
Definition: partition_element.h:145
const char * data_file_name
Definition: partition_element.h:120
const char * tablespace_name
Definition: partition_element.h:118
Definition: partition_info.h:209
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1141
unsigned char uchar
Definition: my_inttypes.h:52
long long int longlong
Definition: my_inttypes.h:55
uint16_t uint16
Definition: my_inttypes.h:65
struct p_column_list_val part_column_list_val
partition_type
An enum and a struct to handle partitioning and subpartitioning.
Definition: partition_element.h:33
struct p_elem_val part_elem_value
partition_state
Definition: partition_element.h:35
@ PART_TO_BE_ADDED
Definition: partition_element.h:39
@ PART_IS_CHANGED
Definition: partition_element.h:43
@ PART_CHANGED
Definition: partition_element.h:42
@ PART_NORMAL
Definition: partition_element.h:36
@ PART_ADMIN
Definition: partition_element.h:45
@ PART_IS_DROPPED
Definition: partition_element.h:37
@ PART_IS_ADDED
Definition: partition_element.h:44
@ PART_REORGED_DROPPED
Definition: partition_element.h:41
@ PART_TO_BE_DROPPED
Definition: partition_element.h:38
@ PART_TO_BE_REORGED
Definition: partition_element.h:40
#define UNDEF_NODEGROUP
Definition: handler.h:836
Struct to hold information about the table that should be created.
Definition: handler.h:3202
const char * data_file_name
Definition: handler.h:3236
const char * tablespace
Definition: handler.h:3208
ulonglong max_rows
Definition: handler.h:3239
const char * index_file_name
Definition: handler.h:3237
ulonglong min_rows
Definition: handler.h:3240
Definition: my_list.h:36
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2734
Definition: partition_element.h:65
Item * item_expression
When partition clause is parsed this is set to the item expression for the value.
Definition: partition_element.h:83
partition_info * part_info
Definition: partition_element.h:84
char fixed
Definition: partition_element.h:90
bool max_value
MAXVALUE is set (only for RANGE COLUMNS)
Definition: partition_element.h:87
uint partition_id
Definition: partition_element.h:85
bool null_value
NULL is set (only for LIST COLUMNS)
Definition: partition_element.h:89
union p_column_list_val::column_value_union column_value
Definition: partition_element.h:100
part_column_list_val * col_val_array
Definition: partition_element.h:105
uint added_items
Definition: partition_element.h:102
bool unsigned_flag
Definition: partition_element.h:104
bool null_value
Definition: partition_element.h:103
longlong value
Definition: partition_element.h:101
Definition: partition_element.h:66
const uchar * field_image
When a table is opened this is set to the field image of the value from the item_expression below.
Definition: partition_element.h:71
const char * value_str
When the values are read from dd.Partition_value it is carried as a C-string.
Definition: partition_element.h:76