1
/* Copyright (C) 2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
#pragma interface /* gcc class implementation */
20
/* Flags for partition handlers */
21
#define HA_CAN_PARTITION (1 << 0) /* Partition support */
22
#define HA_CAN_UPDATE_PARTITION_KEY (1 << 1)
23
#define HA_CAN_PARTITION_UNIQUE (1 << 2)
24
#define HA_USE_AUTO_PARTITION (1 << 3)
27
ulonglong data_file_length;
28
ulonglong max_data_file_length;
29
ulonglong index_file_length;
30
ulonglong delete_length;
32
ulong mean_rec_length;
49
struct st_partition_iter;
50
#define NOT_A_PARTITION_ID ((uint32)-1)
52
bool is_partition_in_list(char *part_name, List<char> list_part_names);
53
char *are_partitions_in_table(partition_info *new_part_info,
54
partition_info *old_part_info);
55
bool check_reorganise_list(partition_info *new_part_info,
56
partition_info *old_part_info,
57
List<char> list_part_names);
58
handler *get_ha_partition(partition_info *part_info);
59
int get_parts_for_update(const uchar *old_data, uchar *new_data,
60
const uchar *rec0, partition_info *part_info,
61
uint32 *old_part_id, uint32 *new_part_id,
62
longlong *func_value);
63
int get_part_for_delete(const uchar *buf, const uchar *rec0,
64
partition_info *part_info, uint32 *part_id);
65
void prune_partition_set(const TABLE *table, part_id_range *part_spec);
66
bool check_partition_info(partition_info *part_info,handlerton **eng_type,
67
TABLE *table, handler *file, HA_CREATE_INFO *info);
68
void set_linear_hash_mask(partition_info *part_info, uint no_parts);
69
bool fix_partition_func(THD *thd, TABLE *table, bool create_table_ind);
70
char *generate_partition_syntax(partition_info *part_info,
71
uint *buf_length, bool use_sql_alloc,
72
bool show_partition_options);
73
bool partition_key_modified(TABLE *table, const MY_BITMAP *fields);
74
void get_partition_set(const TABLE *table, uchar *buf, const uint index,
75
const key_range *key_spec,
76
part_id_range *part_spec);
77
void get_full_part_id_from_key(const TABLE *table, uchar *buf,
79
const key_range *key_spec,
80
part_id_range *part_spec);
81
bool mysql_unpack_partition(THD *thd, const char *part_buf,
83
const char *part_state, uint part_state_len,
84
TABLE *table, bool is_create_table_ind,
85
handlerton *default_db_type,
86
bool *work_part_info_used);
87
void make_used_partitions_str(partition_info *part_info, String *parts_str);
88
uint32 get_list_array_idx_for_endpoint(partition_info *part_info,
90
bool include_endpoint);
91
uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
93
bool include_endpoint);
94
bool check_part_func_fields(Field **ptr, bool ok_with_charsets);
95
bool field_is_partition_charset(Field *field);
98
A "Get next" function for partition iterator.
101
partition_iter_func()
102
part_iter Partition iterator, you call only "iter.get_next(&iter)"
105
Depending on whether partitions or sub-partitions are iterated, the
106
function returns next subpartition id/partition number. The sequence of
107
returned numbers is not ordered and may contain duplicates.
109
When the end of sequence is reached, NOT_A_PARTITION_ID is returned, and
110
the iterator resets itself (so next get_next() call will start to
111
enumerate the set all over again).
114
NOT_A_PARTITION_ID if there are no more partitions.
115
[sub]partition_id of the next partition
118
typedef uint32 (*partition_iter_func)(st_partition_iter* part_iter);
122
Partition set iterator. Used to enumerate a set of [sub]partitions
123
obtained in partition interval analysis (see get_partitions_in_range_iter).
125
For the user, the only meaningful field is get_next, which may be used as
127
part_iterator.get_next(&part_iterator);
129
Initialization is done by any of the following calls:
130
- get_partitions_in_range_iter-type function call
131
- init_single_partition_iterator()
132
- init_all_partitions_iterator()
133
Cleanup is not needed.
136
typedef struct st_partition_iter
138
partition_iter_func get_next;
140
Valid for "Interval mapping" in LIST partitioning: if true, let the
141
iterator also produce id of the partition that contains NULL value.
143
bool ret_null_part, ret_null_part_orig;
144
struct st_part_num_range
151
struct st_field_value_range
160
struct st_part_num_range part_nums;
161
struct st_field_value_range field_vals;
163
partition_info *part_info;
164
} PARTITION_ITERATOR;
168
Get an iterator for set of partitions that match given field-space interval
171
get_partitions_in_range_iter()
172
part_info Partitioning info
174
min_val Left edge, field value in opt_range_key format.
175
max_val Right edge, field value in opt_range_key format.
176
flags Some combination of NEAR_MIN, NEAR_MAX, NO_MIN_RANGE,
178
part_iter Iterator structure to be initialized
181
Functions with this signature are used to perform "Partitioning Interval
182
Analysis". This analysis is applicable for any type of [sub]partitioning
183
by some function of a single fieldX. The idea is as follows:
184
Given an interval "const1 <=? fieldX <=? const2", find a set of partitions
185
that may contain records with value of fieldX within the given interval.
187
The min_val, max_val and flags parameters specify the interval.
188
The set of partitions is returned by initializing an iterator in *part_iter
191
There are currently two functions of this type:
192
- get_part_iter_for_interval_via_walking
193
- get_part_iter_for_interval_via_mapping
196
0 - No matching partitions, iterator not initialized
197
1 - Some partitions would match, iterator intialized for traversing them
198
-1 - All partitions would match, iterator not initialized
201
typedef int (*get_partitions_in_range_iter)(partition_info *part_info,
203
uchar *min_val, uchar *max_val,
205
PARTITION_ITERATOR *part_iter);
207
#include "partition_info.h"