The world's most popular open source database
00001 /* Copyright (C) 2006 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 #ifdef __GNUC__ 00018 #pragma interface /* gcc class implementation */ 00019 #endif 00020 00021 /* Flags for partition handlers */ 00022 #define HA_CAN_PARTITION (1 << 0) /* Partition support */ 00023 #define HA_CAN_UPDATE_PARTITION_KEY (1 << 1) 00024 #define HA_CAN_PARTITION_UNIQUE (1 << 2) 00025 #define HA_USE_AUTO_PARTITION (1 << 3) 00026 00027 /*typedef struct { 00028 ulonglong data_file_length; 00029 ulonglong max_data_file_length; 00030 ulonglong index_file_length; 00031 ulonglong delete_length; 00032 ha_rows records; 00033 ulong mean_rec_length; 00034 time_t create_time; 00035 time_t check_time; 00036 time_t update_time; 00037 ulonglong check_sum; 00038 } PARTITION_INFO; 00039 */ 00040 typedef struct { 00041 longlong list_value; 00042 uint32 partition_id; 00043 } LIST_PART_ENTRY; 00044 00045 typedef struct { 00046 uint32 start_part; 00047 uint32 end_part; 00048 } part_id_range; 00049 00050 struct st_partition_iter; 00051 #define NOT_A_PARTITION_ID ((uint32)-1) 00052 00053 bool is_partition_in_list(char *part_name, List<char> list_part_names); 00054 char *are_partitions_in_table(partition_info *new_part_info, 00055 partition_info *old_part_info); 00056 bool check_reorganise_list(partition_info *new_part_info, 00057 partition_info *old_part_info, 00058 List<char> list_part_names); 00059 handler *get_ha_partition(partition_info *part_info); 00060 int get_parts_for_update(const byte *old_data, byte *new_data, 00061 const byte *rec0, partition_info *part_info, 00062 uint32 *old_part_id, uint32 *new_part_id, 00063 longlong *func_value); 00064 int get_part_for_delete(const byte *buf, const byte *rec0, 00065 partition_info *part_info, uint32 *part_id); 00066 void prune_partition_set(const TABLE *table, part_id_range *part_spec); 00067 bool check_partition_info(partition_info *part_info,handlerton **eng_type, 00068 TABLE *table, handler *file, HA_CREATE_INFO *info); 00069 bool fix_partition_func(THD *thd, TABLE *table, bool create_table_ind); 00070 char *generate_partition_syntax(partition_info *part_info, 00071 uint *buf_length, bool use_sql_alloc, 00072 bool show_partition_options); 00073 bool partition_key_modified(TABLE *table, List<Item> &fields); 00074 void get_partition_set(const TABLE *table, byte *buf, const uint index, 00075 const key_range *key_spec, 00076 part_id_range *part_spec); 00077 void get_full_part_id_from_key(const TABLE *table, byte *buf, 00078 KEY *key_info, 00079 const key_range *key_spec, 00080 part_id_range *part_spec); 00081 bool mysql_unpack_partition(THD *thd, const uchar *part_buf, 00082 uint part_info_len, 00083 uchar *part_state, uint part_state_len, 00084 TABLE *table, bool is_create_table_ind, 00085 handlerton *default_db_type); 00086 void make_used_partitions_str(partition_info *part_info, String *parts_str); 00087 uint32 get_list_array_idx_for_endpoint(partition_info *part_info, 00088 bool left_endpoint, 00089 bool include_endpoint); 00090 uint32 get_partition_id_range_for_endpoint(partition_info *part_info, 00091 bool left_endpoint, 00092 bool include_endpoint); 00093 bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, 00094 bool is_sub_part, bool is_field_to_be_setup); 00095 00096 /* 00097 A "Get next" function for partition iterator. 00098 00099 SYNOPSIS 00100 partition_iter_func() 00101 part_iter Partition iterator, you call only "iter.get_next(&iter)" 00102 00103 DESCRIPTION 00104 Depending on whether partitions or sub-partitions are iterated, the 00105 function returns next subpartition id/partition number. The sequence of 00106 returned numbers is not ordered and may contain duplicates. 00107 00108 When the end of sequence is reached, NOT_A_PARTITION_ID is returned, and 00109 the iterator resets itself (so next get_next() call will start to 00110 enumerate the set all over again). 00111 00112 RETURN 00113 NOT_A_PARTITION_ID if there are no more partitions. 00114 [sub]partition_id of the next partition 00115 */ 00116 00117 typedef uint32 (*partition_iter_func)(st_partition_iter* part_iter); 00118 00119 00120 /* 00121 Partition set iterator. Used to enumerate a set of [sub]partitions 00122 obtained in partition interval analysis (see get_partitions_in_range_iter). 00123 00124 For the user, the only meaningful field is get_next, which may be used as 00125 follows: 00126 part_iterator.get_next(&part_iterator); 00127 00128 Initialization is done by any of the following calls: 00129 - get_partitions_in_range_iter-type function call 00130 - init_single_partition_iterator() 00131 - init_all_partitions_iterator() 00132 Cleanup is not needed. 00133 */ 00134 00135 typedef struct st_partition_iter 00136 { 00137 partition_iter_func get_next; 00138 /* 00139 Valid for "Interval mapping" in LIST partitioning: if true, let the 00140 iterator also produce id of the partition that contains NULL value. 00141 */ 00142 bool ret_null_part, ret_null_part_orig; 00143 struct st_part_num_range 00144 { 00145 uint32 start; 00146 uint32 cur; 00147 uint32 end; 00148 }; 00149 00150 struct st_field_value_range 00151 { 00152 longlong start; 00153 longlong cur; 00154 longlong end; 00155 }; 00156 00157 union 00158 { 00159 struct st_part_num_range part_nums; 00160 struct st_field_value_range field_vals; 00161 }; 00162 partition_info *part_info; 00163 } PARTITION_ITERATOR; 00164 00165 00166 /* 00167 Get an iterator for set of partitions that match given field-space interval 00168 00169 SYNOPSIS 00170 get_partitions_in_range_iter() 00171 part_info Partitioning info 00172 is_subpart 00173 min_val Left edge, field value in opt_range_key format. 00174 max_val Right edge, field value in opt_range_key format. 00175 flags Some combination of NEAR_MIN, NEAR_MAX, NO_MIN_RANGE, 00176 NO_MAX_RANGE. 00177 part_iter Iterator structure to be initialized 00178 00179 DESCRIPTION 00180 Functions with this signature are used to perform "Partitioning Interval 00181 Analysis". This analysis is applicable for any type of [sub]partitioning 00182 by some function of a single fieldX. The idea is as follows: 00183 Given an interval "const1 <=? fieldX <=? const2", find a set of partitions 00184 that may contain records with value of fieldX within the given interval. 00185 00186 The min_val, max_val and flags parameters specify the interval. 00187 The set of partitions is returned by initializing an iterator in *part_iter 00188 00189 NOTES 00190 There are currently two functions of this type: 00191 - get_part_iter_for_interval_via_walking 00192 - get_part_iter_for_interval_via_mapping 00193 00194 RETURN 00195 0 - No matching partitions, iterator not initialized 00196 1 - Some partitions would match, iterator intialized for traversing them 00197 -1 - All partitions would match, iterator not initialized 00198 */ 00199 00200 typedef int (*get_partitions_in_range_iter)(partition_info *part_info, 00201 bool is_subpart, 00202 char *min_val, char *max_val, 00203 uint flags, 00204 PARTITION_ITERATOR *part_iter); 00205 00206 #include "partition_info.h" 00207
1.4.7

