My Project
partition_element.h
00001 #ifndef PARTITION_ELEMENT_INCLUDED
00002 #define PARTITION_ELEMENT_INCLUDED
00003 
00004 /* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; version 2 of the License.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00018 
00019 #include "my_base.h"                            /* ha_rows */
00020 #include "handler.h"                            /* UNDEF_NODEGROUP */
00021 
00025 enum partition_type {
00026   NOT_A_PARTITION= 0,
00027   RANGE_PARTITION,
00028   HASH_PARTITION,
00029   LIST_PARTITION
00030 };
00031 
00032 enum partition_state {
00033   PART_NORMAL= 0,
00034   PART_IS_DROPPED= 1,
00035   PART_TO_BE_DROPPED= 2,
00036   PART_TO_BE_ADDED= 3,
00037   PART_TO_BE_REORGED= 4,
00038   PART_REORGED_DROPPED= 5,
00039   PART_CHANGED= 6,
00040   PART_IS_CHANGED= 7,
00041   PART_IS_ADDED= 8,
00042   PART_ADMIN= 9
00043 };
00044 
00045 /*
00046   This struct is used to keep track of column expressions as part
00047   of the COLUMNS concept in conjunction with RANGE and LIST partitioning.
00048   The value can be either of MINVALUE, MAXVALUE and an expression that
00049   must be constant and evaluate to the same type as the column it
00050   represents.
00051 
00052   The data in this fixed in two steps. The parser will only fill in whether
00053   it is a max_value or provide an expression. Filling in
00054   column_value, part_info, partition_id, null_value is done by the
00055   function fix_column_value_function. However the item tree needs
00056   fixed also before writing it into the frm file (in add_column_list_values).
00057   To distinguish between those two variants, fixed= 1 after the
00058   fixing in add_column_list_values and fixed= 2 otherwise. This is
00059   since the fixing in add_column_list_values isn't a complete fixing.
00060 */
00061 
00062 typedef struct p_column_list_val
00063 {
00064   void* column_value;
00065   Item* item_expression;
00066   partition_info *part_info;
00067   uint partition_id;
00068   bool max_value;
00069   bool null_value;
00070   char fixed;
00071 } part_column_list_val;
00072 
00073 
00074 /*
00075   This struct is used to contain the value of an element
00076   in the VALUES IN struct. It needs to keep knowledge of
00077   whether it is a signed/unsigned value and whether it is
00078   NULL or not.
00079 */
00080 
00081 typedef struct p_elem_val
00082 {
00083   longlong value;
00084   uint added_items;
00085   bool null_value;
00086   bool unsigned_flag;
00087   part_column_list_val *col_val_array;
00088 } part_elem_value;
00089 
00090 struct st_ddl_log_memory_entry;
00091 
00092 class partition_element :public Sql_alloc {
00093 public:
00094   List<partition_element> subpartitions;
00095   List<part_elem_value> list_val_list;  // list of LIST values/column arrays
00096   ha_rows part_max_rows;
00097   ha_rows part_min_rows;
00098   longlong range_value;
00099   char *partition_name;
00100   char *tablespace_name;
00101   struct st_ddl_log_memory_entry *log_entry;
00102   char* part_comment;
00103   char* data_file_name;
00104   char* index_file_name;
00105   handlerton *engine_type;
00106   enum partition_state part_state;
00107   uint16 nodegroup_id;
00108   bool has_null_value;
00109   bool signed_flag;                          // Range value signed
00110   bool max_value;                            // MAXVALUE range
00111 
00112   partition_element()
00113   : part_max_rows(0), part_min_rows(0), range_value(0),
00114     partition_name(NULL), tablespace_name(NULL),
00115     log_entry(NULL), part_comment(NULL),
00116     data_file_name(NULL), index_file_name(NULL),
00117     engine_type(NULL), part_state(PART_NORMAL),
00118     nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE),
00119     signed_flag(FALSE), max_value(FALSE)
00120   {
00121   }
00122   partition_element(partition_element *part_elem)
00123   : part_max_rows(part_elem->part_max_rows),
00124     part_min_rows(part_elem->part_min_rows),
00125     range_value(0), partition_name(NULL),
00126     tablespace_name(part_elem->tablespace_name),
00127     part_comment(part_elem->part_comment),
00128     data_file_name(part_elem->data_file_name),
00129     index_file_name(part_elem->index_file_name),
00130     engine_type(part_elem->engine_type),
00131     part_state(part_elem->part_state),
00132     nodegroup_id(part_elem->nodegroup_id),
00133     has_null_value(FALSE)
00134   {
00135   }
00136   ~partition_element() {}
00137 };
00138 
00139 #endif /* PARTITION_ELEMENT_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines