1 #ifndef PARTITION_ELEMENT_INCLUDED
2 #define PARTITION_ELEMENT_INCLUDED
3 
4 /* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
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 as published by
8    the Free Software Foundation; version 2 of the License.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
18 
19 #include "my_base.h"                            /* ha_rows */
20 #include "handler.h"                            /* UNDEF_NODEGROUP */
21 
22 /**
23  * An enum and a struct to handle partitioning and subpartitioning.
24  */
25 enum partition_type {
26   NOT_A_PARTITION= 0,
27   RANGE_PARTITION,
28   HASH_PARTITION,
29   LIST_PARTITION
30 };
31 
32 enum partition_state {
33   PART_NORMAL= 0,
34   PART_IS_DROPPED= 1,
35   PART_TO_BE_DROPPED= 2,
36   PART_TO_BE_ADDED= 3,
37   PART_TO_BE_REORGED= 4,
38   PART_REORGED_DROPPED= 5,
39   PART_CHANGED= 6,
40   PART_IS_CHANGED= 7,
41   PART_IS_ADDED= 8,
42   PART_ADMIN= 9
43 };
44 
45 /*
46   This struct is used to keep track of column expressions as part
47   of the COLUMNS concept in conjunction with RANGE and LIST partitioning.
48   The value can be either of MINVALUE, MAXVALUE and an expression that
49   must be constant and evaluate to the same type as the column it
50   represents.
51 
52   The data in this fixed in two steps. The parser will only fill in whether
53   it is a max_value or provide an expression. Filling in
54   column_value, part_info, partition_id, null_value is done by the
55   function fix_column_value_function. However the item tree needs
56   fixed also before writing it into the frm file (in add_column_list_values).
57   To distinguish between those two variants, fixed= 1 after the
58   fixing in add_column_list_values and fixed= 2 otherwise. This is
59   since the fixing in add_column_list_values isn't a complete fixing.
60 */
61 
62 typedef struct p_column_list_val
63 {
64   void* column_value;
65   Item* item_expression;
66   partition_info *part_info;
67   uint partition_id;
68   bool max_value;
69   bool null_value;
70   char fixed;
71 } part_column_list_val;
72 
73 
74 /*
75   This struct is used to contain the value of an element
76   in the VALUES IN struct. It needs to keep knowledge of
77   whether it is a signed/unsigned value and whether it is
78   NULL or not.
79 */
80 
81 typedef struct p_elem_val
82 {
83   longlong value;
84   uint added_items;
85   bool null_value;
86   bool unsigned_flag;
87   part_column_list_val *col_val_array;
88 } part_elem_value;
89 
90 struct st_ddl_log_memory_entry;
91 
92 class partition_element :public Sql_alloc {
93 public:
94   List<partition_element> subpartitions;
95   List<part_elem_value> list_val_list;
96   ha_rows part_max_rows;
97   ha_rows part_min_rows;
98   longlong range_value;
99   char *partition_name;
100   char *tablespace_name;
101   struct st_ddl_log_memory_entry *log_entry;
102   char* part_comment;
103   char* data_file_name;
104   char* index_file_name;
105   handlerton *engine_type;
106   enum partition_state part_state;
107   uint16 nodegroup_id;
108   bool has_null_value;
109   bool signed_flag;                          // Range value signed
110   bool max_value;                            // MAXVALUE range
111 
partition_element()112   partition_element()
113   : part_max_rows(0), part_min_rows(0), range_value(0),
114     partition_name(NULL), tablespace_name(NULL),
115     log_entry(NULL), part_comment(NULL),
116     data_file_name(NULL), index_file_name(NULL),
117     engine_type(NULL), part_state(PART_NORMAL),
118     nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE),
119     signed_flag(FALSE), max_value(FALSE)
120   {
121   }
partition_element(partition_element * part_elem)122   partition_element(partition_element *part_elem)
123   : part_max_rows(part_elem->part_max_rows),
124     part_min_rows(part_elem->part_min_rows),
125     range_value(0), partition_name(NULL),
126     tablespace_name(part_elem->tablespace_name),
127     part_comment(part_elem->part_comment),
128     data_file_name(part_elem->data_file_name),
129     index_file_name(part_elem->index_file_name),
130     engine_type(part_elem->engine_type),
131     part_state(part_elem->part_state),
132     nodegroup_id(part_elem->nodegroup_id),
133     has_null_value(FALSE)
134   {
135   }
~partition_element()136   ~partition_element() {}
137 };
138 
139 #endif /* PARTITION_ELEMENT_INCLUDED */
140