MySQL  8.0.27
Source Code Documentation
Go to the documentation of this file.
4 /* Copyright (c) 2005, 2021, Oracle and/or its affiliates.
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.
10  This program is also distributed 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 included with MySQL.
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  GNU General Public License, version 2.0, for more details.
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26 #include "my_base.h" /* ha_rows */
27 #include "sql/handler.h" /* UNDEF_NODEGROUP */
29 /**
30  * An enum and a struct to handle partitioning and subpartitioning.
31  */
32 enum class partition_type { NONE = 0, RANGE, HASH, LIST };
44  PART_ADMIN = 9
45 };
47 /*
48  This struct is used to keep track of column expressions as part
49  of the COLUMNS concept in conjunction with RANGE and LIST partitioning.
50  The value can be either of MINVALUE, MAXVALUE and an expression that
51  must be constant and evaluate to the same type as the column it
52  represents.
54  The data in this fixed in two steps. The parser will only fill in whether
55  it is a max_value or provide an expression. Filling in
56  column_value, part_info, partition_id, null_value is done by the
57  function fix_column_value_function. However the item tree needs
58  fixed also before writing it into the frm file (in add_column_list_values).
59  To distinguish between those two variants, fixed= 1 after the
60  fixing in add_column_list_values and fixed= 2 otherwise. This is
61  since the fixing in add_column_list_values isn't a complete fixing.
62 */
64 typedef struct p_column_list_val {
66  /**
67  When a table is opened this is set to the field image of the value
68  from the item_expression below.
69  */
71  /**
72  When the values are read from dd.Partition_value it is carried as
73  a C-string.
74  */
75  const char *value_str;
77  /**
78  When partition clause is parsed this is set to the item expression
79  for the value. Must be NULL if the value was not parsed, but
80  read from dd.Partition_value instead.
81  */
85  /** MAXVALUE is set (only for RANGE COLUMNS) */
86  bool max_value;
87  /** NULL is set (only for LIST COLUMNS) */
88  bool null_value;
89  char fixed;
92 /*
93  This struct is used to contain the value of an element
94  in the VALUES IN struct. It needs to keep knowledge of
95  whether it is a signed/unsigned value and whether it is
96  NULL or not.
97 */
99 typedef struct p_elem_val {
108  public:
110  List<part_elem_value> list_val_list; // list of LIST values/column arrays
111  // TODO: Handle options in a more general way, like dd::Properties
112  // for max/min rows, tablespace, data/index file, nodegroup etc.
116  const char *partition_name;
117  const char *tablespace_name;
119  const char *data_file_name;
120  const char *index_file_name;
125  /* TODO: Move this to partition_info?*/
126  bool signed_flag; // Range value signed
127  bool max_value; // MAXVALUE range
130  : part_max_rows(0),
131  part_min_rows(0),
132  range_value(0),
141  has_null_value(false),
142  signed_flag(false),
143  max_value(false) {}
145  : part_max_rows(part_elem->part_max_rows),
146  part_min_rows(part_elem->part_min_rows),
147  range_value(0),
149  tablespace_name(part_elem->tablespace_name),
150  part_comment(part_elem->part_comment),
151  data_file_name(part_elem->data_file_name),
152  index_file_name(part_elem->index_file_name),
153  engine_type(part_elem->engine_type),
154  part_state(part_elem->part_state),
155  nodegroup_id(part_elem->nodegroup_id),
156  has_null_value(false),
157  signed_flag(false),
158  max_value(false) {}
159  inline void set_from_info(const HA_CREATE_INFO *info) {
160  data_file_name = info->data_file_name;
161  index_file_name = info->index_file_name;
162  tablespace_name = info->tablespace;
163  part_max_rows = info->max_rows;
164  part_min_rows = info->min_rows;
165  }
166  inline void put_to_info(HA_CREATE_INFO *info) const {
167  info->data_file_name = data_file_name;
168  info->index_file_name = index_file_name;
169  info->tablespace = tablespace_name;
170  info->max_rows = part_max_rows;
171  info->min_rows = part_min_rows;
172  }
173 };
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
Definition: partition_element.h:107
Definition: partition_element.h:129
const char * index_file_name
Definition: partition_element.h:120
void set_from_info(const HA_CREATE_INFO *info)
Definition: partition_element.h:159
List< part_elem_value > list_val_list
Definition: partition_element.h:110
char * part_comment
Definition: partition_element.h:118
List< partition_element > subpartitions
Definition: partition_element.h:109
handlerton * engine_type
Definition: partition_element.h:121
const char * partition_name
Definition: partition_element.h:116
bool max_value
Definition: partition_element.h:127
bool signed_flag
Definition: partition_element.h:126
longlong range_value
Definition: partition_element.h:115
ha_rows part_min_rows
Definition: partition_element.h:114
void put_to_info(HA_CREATE_INFO *info) const
Definition: partition_element.h:166
enum partition_state part_state
Definition: partition_element.h:122
bool has_null_value
Definition: partition_element.h:124
ha_rows part_max_rows
Definition: partition_element.h:113
uint16 nodegroup_id
Definition: partition_element.h:123
partition_element(partition_element *part_elem)
Definition: partition_element.h:144
const char * data_file_name
Definition: partition_element.h:119
const char * tablespace_name
Definition: partition_element.h:117
Definition: partition_info.h:208
Dialog Client Authentication nullptr
This file includes constants used by all storage engines.
my_off_t ha_rows
Definition: my_base.h:1138
unsigned char uchar
Definition: my_inttypes.h:51
long long int longlong
Definition: my_inttypes.h:54
uint16_t uint16
Definition: my_inttypes.h:64
Log info(cout, "NOTE")
struct p_column_list_val part_column_list_val
An enum and a struct to handle partitioning and subpartitioning.
Definition: partition_element.h:32
struct p_elem_val part_elem_value
Definition: partition_element.h:34
Definition: partition_element.h:38
Definition: partition_element.h:42
Definition: partition_element.h:41
Definition: partition_element.h:35
Definition: partition_element.h:44
Definition: partition_element.h:36
Definition: partition_element.h:43
Definition: partition_element.h:40
Definition: partition_element.h:37
Definition: partition_element.h:39
Definition: handler.h:820
Definition: handler.h:2764
Definition: my_list.h:35
handlerton is a singleton structure - one instance per storage engine - to provide access to storage ...
Definition: handler.h:2391
Definition: partition_element.h:64
Item * item_expression
When partition clause is parsed this is set to the item expression for the value.
Definition: partition_element.h:82
partition_info * part_info
Definition: partition_element.h:83
char fixed
Definition: partition_element.h:89
bool max_value
MAXVALUE is set (only for RANGE COLUMNS)
Definition: partition_element.h:86
uint partition_id
Definition: partition_element.h:84
bool null_value
NULL is set (only for LIST COLUMNS)
Definition: partition_element.h:88
union p_column_list_val::column_value_union column_value
Definition: partition_element.h:99
part_column_list_val * col_val_array
Definition: partition_element.h:104
uint added_items
Definition: partition_element.h:101
bool unsigned_flag
Definition: partition_element.h:103
bool null_value
Definition: partition_element.h:102
longlong value
Definition: partition_element.h:100
unsigned int uint
Definition: partition_element.h:65
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:70
const char * value_str
When the values are read from dd.Partition_value it is carried as a C-string.
Definition: partition_element.h:75