1 #ifndef PARTITION_INFO_INCLUDED 
    2 #define PARTITION_INFO_INCLUDED 
   19 #include "partition_element.h" 
   20 #include "sql_class.h"                         
   29                                  longlong *func_value);
 
   52   get_part_id_func get_partition_id;
 
   55   get_part_id_func get_part_partition_id;
 
   64   get_subpart_id_func get_subpartition_id;
 
   72   get_part_id_func get_part_partition_id_charset;
 
   73   get_subpart_id_func get_subpartition_id_charset;
 
   76   Field **part_field_array;
 
   77   Field **subpart_field_array;
 
   78   Field **part_charset_field_array;
 
   79   Field **subpart_charset_field_array;
 
   84   Field **full_part_field_array;
 
   98   uchar **part_field_buffers;
 
   99   uchar **subpart_field_buffers;
 
  100   uchar **restore_part_field_ptrs;
 
  101   uchar **restore_subpart_field_ptrs;
 
  106   Item *item_free_list;
 
  136   bool bitmaps_are_initialized;
 
  139     longlong *range_int_array;
 
  152   get_partitions_in_range_iter get_part_iter_for_interval;
 
  157   get_partitions_in_range_iter get_subpart_iter_for_interval;
 
  164   char* part_info_string;
 
  166   char *part_func_string;
 
  167   char *subpart_func_string;
 
  172   uint curr_list_object;
 
  181   key_map all_fields_in_PF, all_fields_in_PPF, all_fields_in_SPF;
 
  185   partition_type part_type;
 
  186   partition_type subpart_type;
 
  190   uint subpart_func_len;
 
  194   uint count_curr_subparts;                  
 
  196   uint num_list_values;
 
  198   uint num_part_fields;
 
  199   uint num_subpart_fields;
 
  200   uint num_full_part_fields;
 
  202   uint has_null_part_id;
 
  208   uint16 linear_hash_mask;
 
  215   enum enum_key_algorithm
 
  217       KEY_ALGORITHM_NONE= 0,
 
  221   enum_key_algorithm key_algorithm;
 
  224   bool use_default_partitions;
 
  225   bool use_default_num_partitions;
 
  227   bool use_default_subpartitions;
 
  228   bool use_default_num_subpartitions;
 
  229   bool default_partitions_setup;
 
  230   bool defined_max_value;
 
  231   bool list_of_part_fields;                  
 
  232   bool list_of_subpart_fields;               
 
  233   bool linear_hash_ind;                      
 
  235   bool is_auto_partitioned;
 
  249   : get_partition_id(NULL), get_part_partition_id(NULL),
 
  250     get_subpartition_id(NULL),
 
  251     part_field_array(NULL), subpart_field_array(NULL),
 
  252     part_charset_field_array(NULL),
 
  253     subpart_charset_field_array(NULL),
 
  254     full_part_field_array(NULL),
 
  255     part_field_buffers(NULL), subpart_field_buffers(NULL),
 
  256     restore_part_field_ptrs(NULL), restore_subpart_field_ptrs(NULL),
 
  257     part_expr(NULL), subpart_expr(NULL), item_free_list(NULL),
 
  258     first_log_entry(NULL), exec_log_entry(NULL), frm_log_entry(NULL),
 
  259     bitmaps_are_initialized(FALSE),
 
  260     list_array(NULL), err_value(0),
 
  261     part_info_string(NULL),
 
  262     part_func_string(NULL), subpart_func_string(NULL),
 
  263     curr_part_elem(NULL), current_partition(NULL),
 
  264     curr_list_object(0), num_columns(0), table(NULL),
 
  265     default_engine_type(NULL),
 
  266     part_type(NOT_A_PARTITION), subpart_type(NOT_A_PARTITION),
 
  268     part_func_len(0), subpart_func_len(0),
 
  269     num_parts(0), num_subparts(0),
 
  270     count_curr_subparts(0),
 
  271     num_list_values(0), num_part_fields(0), num_subpart_fields(0),
 
  272     num_full_part_fields(0), has_null_part_id(0), linear_hash_mask(0),
 
  273     key_algorithm(KEY_ALGORITHM_NONE),
 
  274     use_default_partitions(TRUE), use_default_num_partitions(TRUE),
 
  275     use_default_subpartitions(TRUE), use_default_num_subpartitions(TRUE),
 
  276     default_partitions_setup(FALSE), defined_max_value(FALSE),
 
  277     list_of_part_fields(FALSE), list_of_subpart_fields(FALSE),
 
  278     linear_hash_ind(FALSE), fixed(FALSE),
 
  279     is_auto_partitioned(FALSE),
 
  283     temp_partitions.empty();
 
  284     part_field_list.empty();
 
  285     subpart_field_list.empty();
 
  290   bool set_named_partition_bitmap(
const char *part_name, uint length);
 
  291   bool set_partition_bitmaps(
TABLE_LIST *table_list);
 
  293   bool is_sub_partitioned()
 
  295     return (subpart_type == NOT_A_PARTITION ?  FALSE : TRUE);
 
  299   uint get_tot_partitions()
 
  301     return num_parts * (is_sub_partitioned() ? num_subparts : 1);
 
  306   char *find_duplicate_field();
 
  307   char *find_duplicate_name();
 
  309   bool check_range_constants(THD *thd);
 
  310   bool check_list_constants(THD *thd);
 
  311   bool check_partition_info(THD *thd, 
handlerton **eng_type,
 
  313                             bool check_partition_function);
 
  314   void print_no_partition_found(
TABLE *table);
 
  315   void print_debug(
const char *str, uint*);
 
  317   bool fix_partition_values(THD *thd,
 
  321   bool fix_column_value_functions(THD *thd,
 
  324   bool fix_parser_data(THD *thd);
 
  325   bool add_max_value();
 
  327   bool reorganize_into_single_field_col_val();
 
  329   bool set_part_expr(
char *start_token, 
Item *item_ptr,
 
  330                      char *end_token, 
bool is_subpart);
 
  331   static int compare_column_values(
const void *a, 
const void *b);
 
  332   bool set_up_charset_field_preps();
 
  333   bool check_partition_field_length();
 
  334   bool init_column_part();
 
  335   bool add_column_list_value(THD *thd, 
Item *item);
 
  336   void set_show_version_string(
String *packet);
 
  340   void report_part_expr_error(
bool use_subpart_expr);
 
  344                           bool copy_default_values,
 
  356   bool can_prune_insert(THD *thd,
 
  357                         enum_duplicates duplic,
 
  363                         bool *prune_needs_default_values,
 
  367   static int list_part_cmp(
const void* a, 
const void* b);
 
  371   char *create_default_partition_names(uint part_no, uint num_parts,
 
  373   char *create_default_subpartition_name(uint subpart_no,
 
  374                                          const char *part_name);
 
  375   bool prune_partition_bitmaps(
TABLE_LIST *table_list);
 
  376   bool add_named_partition(
const char *part_name, uint length);
 
  377   bool is_field_in_part_expr(
List<Item> &fields);
 
  378   bool is_full_part_expr_in_fields(
List<Item> &fields);
 
  386 static inline void init_single_partition_iterator(uint32 part_id,
 
  389   part_iter->part_nums.start= part_iter->part_nums.cur= part_id;
 
  390   part_iter->part_nums.end= part_id+1;
 
  391   part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE;
 
  392   part_iter->get_next= get_next_partition_id_range;
 
  400   part_iter->part_nums.start= part_iter->part_nums.cur= 0;
 
  401   part_iter->part_nums.end= part_info->num_parts;
 
  402   part_iter->ret_null_part= part_iter->ret_null_part_orig= FALSE;
 
  403   part_iter->get_next= get_next_partition_id_range;