BUG#18198: Partition function handling

Review fixes
parent 21f8aef4
...@@ -807,26 +807,10 @@ class Item { ...@@ -807,26 +807,10 @@ class Item {
below should be defined in the new Item class. below should be defined in the new Item class.
*/ */
#define PF_SAFE_BINARY_COLLATION 3
#define PF_SAFE_SINGLE_CHAR_COLLATION 2
#define PF_SAFE 1
#define PF_UNSAFE 0
bool safe_for_binary_collation(byte *int_arg)
{
if (*(int *)int_arg != PF_UNSAFE)
*(int*)int_arg= PF_SAFE_BINARY_COLLATION;
return 0;
}
bool safe_for_single_char_collation(byte *int_arg)
{
if (*(int*)int_arg == PF_SAFE)
*(int*)int_arg= PF_SAFE_SINGLE_CHAR_COLLATION;
return 0;
}
virtual bool check_partition_func_processor(byte *int_arg) virtual bool check_partition_func_processor(byte *int_arg)
{ {
*(int *)int_arg= PF_UNSAFE; *(int *)int_arg= 0;
return 0; return FALSE;
} }
virtual Item *equal_fields_propagator(byte * arg) { return this; } virtual Item *equal_fields_propagator(byte * arg) { return this; }
...@@ -1126,8 +1110,7 @@ class Item_name_const : public Item ...@@ -1126,8 +1110,7 @@ class Item_name_const : public Item
Item::maybe_null= TRUE; Item::maybe_null= TRUE;
} }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg); }
bool fix_fields(THD *, Item **); bool fix_fields(THD *, Item **);
enum Type type() const; enum Type type() const;
...@@ -1174,7 +1157,7 @@ class Item_num: public Item ...@@ -1174,7 +1157,7 @@ class Item_num: public Item
Item_num() {} /* Remove gcc warning */ Item_num() {} /* Remove gcc warning */
virtual Item_num *neg()= 0; virtual Item_num *neg()= 0;
Item *safe_charset_converter(CHARSET_INFO *tocs); Item *safe_charset_converter(CHARSET_INFO *tocs);
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
#define NO_CACHED_FIELD_INDEX ((uint)(-1)) #define NO_CACHED_FIELD_INDEX ((uint)(-1))
...@@ -1310,7 +1293,7 @@ class Item_field :public Item_ident ...@@ -1310,7 +1293,7 @@ class Item_field :public Item_ident
bool collect_item_field_processor(byte * arg); bool collect_item_field_processor(byte * arg);
bool find_item_in_field_list_processor(byte *arg); bool find_item_in_field_list_processor(byte *arg);
bool register_field_in_read_map(byte *arg); bool register_field_in_read_map(byte *arg);
bool check_partition_func_processor(byte *int_arg) { return 0; } bool check_partition_func_processor(byte *int_arg) { return FALSE; }
void cleanup(); void cleanup();
bool result_as_longlong() bool result_as_longlong()
{ {
...@@ -1358,7 +1341,7 @@ class Item_null :public Item ...@@ -1358,7 +1341,7 @@ class Item_null :public Item
bool is_null() { return 1; } bool is_null() { return 1; }
void print(String *str) { str->append(STRING_WITH_LEN("NULL")); } void print(String *str) { str->append(STRING_WITH_LEN("NULL")); }
Item *safe_charset_converter(CHARSET_INFO *tocs); Item *safe_charset_converter(CHARSET_INFO *tocs);
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
class Item_null_result :public Item_null class Item_null_result :public Item_null
...@@ -1372,7 +1355,7 @@ class Item_null_result :public Item_null ...@@ -1372,7 +1355,7 @@ class Item_null_result :public Item_null
save_in_field(result_field, no_conversions); save_in_field(result_field, no_conversions);
} }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg)
{ *(int *)int_arg= PF_UNSAFE; return 0; } { *(int *)int_arg= 0; return FALSE; }
}; };
/* Item represents one placeholder ('?') of prepared statement */ /* Item represents one placeholder ('?') of prepared statement */
...@@ -1664,7 +1647,7 @@ class Item_static_float_func :public Item_float ...@@ -1664,7 +1647,7 @@ class Item_static_float_func :public Item_float
void print(String *str) { str->append(func_name); } void print(String *str) { str->append(func_name); }
Item *safe_charset_converter(CHARSET_INFO *tocs); Item *safe_charset_converter(CHARSET_INFO *tocs);
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg)
{ *(int *)int_arg= PF_UNSAFE; return 0; } { *(int *)int_arg= 0; return FALSE; }
}; };
...@@ -1742,7 +1725,7 @@ class Item_string :public Item ...@@ -1742,7 +1725,7 @@ class Item_string :public Item
void print(String *str); void print(String *str);
// to prevent drop fixed flag (no need parent cleanup call) // to prevent drop fixed flag (no need parent cleanup call)
void cleanup() {} void cleanup() {}
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -1758,7 +1741,7 @@ class Item_static_string_func :public Item_string ...@@ -1758,7 +1741,7 @@ class Item_static_string_func :public Item_string
Item *safe_charset_converter(CHARSET_INFO *tocs); Item *safe_charset_converter(CHARSET_INFO *tocs);
void print(String *str) { str->append(func_name); } void print(String *str) { str->append(func_name); }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg)
{ *(int *)int_arg= PF_UNSAFE; return 0; } { *(int *)int_arg= 0; return FALSE; }
}; };
...@@ -1772,7 +1755,7 @@ class Item_datetime :public Item_string ...@@ -1772,7 +1755,7 @@ class Item_datetime :public Item_string
{ max_length=19;} { max_length=19;}
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg)
{ *(int *)int_arg= PF_UNSAFE; return 0; } { *(int *)int_arg= 0; return FALSE; }
}; };
class Item_empty_string :public Item_string class Item_empty_string :public Item_string
...@@ -1796,7 +1779,7 @@ class Item_return_int :public Item_int ...@@ -1796,7 +1779,7 @@ class Item_return_int :public Item_int
} }
enum_field_types field_type() const { return int_field_type; } enum_field_types field_type() const { return int_field_type; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg)
{ *(int *)int_arg= PF_UNSAFE; return 0; } { *(int *)int_arg= 0; return FALSE; }
}; };
...@@ -1820,8 +1803,7 @@ class Item_hex_string: public Item ...@@ -1820,8 +1803,7 @@ class Item_hex_string: public Item
void cleanup() {} void cleanup() {}
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
virtual Item *safe_charset_converter(CHARSET_INFO *tocs); virtual Item *safe_charset_converter(CHARSET_INFO *tocs);
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_binary_collation(int_arg);}
}; };
...@@ -2049,7 +2031,7 @@ class Item_int_with_ref :public Item_int ...@@ -2049,7 +2031,7 @@ class Item_int_with_ref :public Item_int
Item *new_item(); Item *new_item();
virtual Item *real_item() { return ref; } virtual Item *real_item() { return ref; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg)
{ *(int *)int_arg= PF_UNSAFE; return 0; } { *(int *)int_arg= 0; return FALSE; }
}; };
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
......
...@@ -240,8 +240,7 @@ class Item_bool_rowready_func2 :public Item_bool_func2 ...@@ -240,8 +240,7 @@ class Item_bool_rowready_func2 :public Item_bool_func2
} }
Item *neg_transformer(THD *thd); Item *neg_transformer(THD *thd);
virtual Item *negated_item(); virtual Item *negated_item();
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg); }
}; };
class Item_func_not :public Item_bool_func class Item_func_not :public Item_bool_func
...@@ -252,8 +251,7 @@ class Item_func_not :public Item_bool_func ...@@ -252,8 +251,7 @@ class Item_func_not :public Item_bool_func
enum Functype functype() const { return NOT_FUNC; } enum Functype functype() const { return NOT_FUNC; }
const char *func_name() const { return "not"; } const char *func_name() const { return "not"; }
Item *neg_transformer(THD *thd); Item *neg_transformer(THD *thd);
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg); }
}; };
class Item_maxmin_subselect; class Item_maxmin_subselect;
...@@ -468,8 +466,7 @@ class Item_func_between :public Item_func_opt_neg ...@@ -468,8 +466,7 @@ class Item_func_between :public Item_func_opt_neg
bool is_bool_func() { return 1; } bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
uint decimal_precision() const { return 1; } uint decimal_precision() const { return 1; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg); }
}; };
...@@ -481,8 +478,7 @@ class Item_func_strcmp :public Item_bool_func2 ...@@ -481,8 +478,7 @@ class Item_func_strcmp :public Item_bool_func2
optimize_type select_optimize() const { return OPTIMIZE_NONE; } optimize_type select_optimize() const { return OPTIMIZE_NONE; }
const char *func_name() const { return "strcmp"; } const char *func_name() const { return "strcmp"; }
void print(String *str) { Item_func::print(str); } void print(String *str) { Item_func::print(str); }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg); }
}; };
...@@ -545,7 +541,7 @@ class Item_func_ifnull :public Item_func_coalesce ...@@ -545,7 +541,7 @@ class Item_func_ifnull :public Item_func_coalesce
const char *func_name() const { return "ifnull"; } const char *func_name() const { return "ifnull"; }
Field *tmp_table_field(TABLE *table); Field *tmp_table_field(TABLE *table);
uint decimal_precision() const; uint decimal_precision() const;
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE; }
}; };
...@@ -586,7 +582,7 @@ class Item_func_nullif :public Item_bool_func2 ...@@ -586,7 +582,7 @@ class Item_func_nullif :public Item_bool_func2
void print(String *str) { Item_func::print(str); } void print(String *str) { Item_func::print(str); }
table_map not_null_tables() const { return 0; } table_map not_null_tables() const { return 0; }
bool is_null(); bool is_null();
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE; }
}; };
...@@ -629,8 +625,7 @@ class Item_func_case :public Item_func ...@@ -629,8 +625,7 @@ class Item_func_case :public Item_func
void print(String *str); void print(String *str);
Item *find_item(String *str); Item *find_item(String *str);
CHARSET_INFO *compare_collation() { return cmp_collation.collation; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg); }
}; };
...@@ -981,8 +976,7 @@ class Item_func_in :public Item_func_opt_neg ...@@ -981,8 +976,7 @@ class Item_func_in :public Item_func_opt_neg
bool nulls_in_row(); bool nulls_in_row();
bool is_bool_func() { return 1; } bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg); }
}; };
/* Functions used by where clause */ /* Functions used by where clause */
...@@ -1024,7 +1018,7 @@ class Item_func_isnull :public Item_bool_func ...@@ -1024,7 +1018,7 @@ class Item_func_isnull :public Item_bool_func
optimize_type select_optimize() const { return OPTIMIZE_NULL; } optimize_type select_optimize() const { return OPTIMIZE_NULL; }
Item *neg_transformer(THD *thd); Item *neg_transformer(THD *thd);
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; } CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE; }
}; };
/* Functions used by HAVING for rewriting IN subquery */ /* Functions used by HAVING for rewriting IN subquery */
...@@ -1047,7 +1041,7 @@ class Item_is_not_null_test :public Item_func_isnull ...@@ -1047,7 +1041,7 @@ class Item_is_not_null_test :public Item_func_isnull
table_map used_tables() const table_map used_tables() const
{ return used_tables_cache | RAND_TABLE_BIT; } { return used_tables_cache | RAND_TABLE_BIT; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg)
{ *(int *)int_arg= PF_UNSAFE; return 0; } { *(int *)int_arg= 0; return FALSE; }
}; };
...@@ -1070,7 +1064,7 @@ class Item_func_isnotnull :public Item_bool_func ...@@ -1070,7 +1064,7 @@ class Item_func_isnotnull :public Item_bool_func
void print(String *str); void print(String *str);
CHARSET_INFO *compare_collation() { return args[0]->collation.collation; } CHARSET_INFO *compare_collation() { return args[0]->collation.collation; }
void top_level_item() { abort_on_null=1; } void top_level_item() { abort_on_null=1; }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE; }
}; };
...@@ -1109,8 +1103,7 @@ class Item_func_like :public Item_bool_func2 ...@@ -1109,8 +1103,7 @@ class Item_func_like :public Item_bool_func2
const char *func_name() const { return "like"; } const char *func_name() const { return "like"; }
bool fix_fields(THD *thd, Item **ref); bool fix_fields(THD *thd, Item **ref);
void cleanup(); void cleanup();
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg); }
}; };
#ifdef USE_REGEX #ifdef USE_REGEX
...@@ -1133,8 +1126,7 @@ class Item_func_regex :public Item_bool_func ...@@ -1133,8 +1126,7 @@ class Item_func_regex :public Item_bool_func
const char *func_name() const { return "regexp"; } const char *func_name() const { return "regexp"; }
void print(String *str) { print_op(str); } void print(String *str) { print_op(str); }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_binary_collation(int_arg); }
}; };
#else #else
...@@ -1191,8 +1183,7 @@ class Item_cond :public Item_bool_func ...@@ -1191,8 +1183,7 @@ class Item_cond :public Item_bool_func
Item *transform(Item_transformer transformer, byte *arg); Item *transform(Item_transformer transformer, byte *arg);
void traverse_cond(Cond_traverser, void *arg, traverse_order order); void traverse_cond(Cond_traverser, void *arg, traverse_order order);
void neg_arguments(THD *thd); void neg_arguments(THD *thd);
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg); }
}; };
......
This diff is collapsed.
...@@ -47,8 +47,7 @@ class Item_func_md5 :public Item_str_func ...@@ -47,8 +47,7 @@ class Item_func_md5 :public Item_str_func
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "md5"; } const char *func_name() const { return "md5"; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg);}
}; };
...@@ -89,8 +88,7 @@ class Item_func_concat :public Item_str_func ...@@ -89,8 +88,7 @@ class Item_func_concat :public Item_str_func
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "concat"; } const char *func_name() const { return "concat"; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg);}
}; };
class Item_func_concat_ws :public Item_str_func class Item_func_concat_ws :public Item_str_func
...@@ -111,8 +109,7 @@ class Item_func_reverse :public Item_str_func ...@@ -111,8 +109,7 @@ class Item_func_reverse :public Item_str_func
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "reverse"; } const char *func_name() const { return "reverse"; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg);}
}; };
...@@ -150,8 +147,7 @@ class Item_str_conv :public Item_str_func ...@@ -150,8 +147,7 @@ class Item_str_conv :public Item_str_func
public: public:
Item_str_conv(Item *item) :Item_str_func(item) {} Item_str_conv(Item *item) :Item_str_func(item) {}
String *val_str(String *); String *val_str(String *);
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_binary_collation(int_arg);}
}; };
...@@ -419,8 +415,7 @@ class Item_func_soundex :public Item_str_func ...@@ -419,8 +415,7 @@ class Item_func_soundex :public Item_str_func
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "soundex"; } const char *func_name() const { return "soundex"; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg);}
}; };
...@@ -528,8 +523,7 @@ class Item_func_rpad :public Item_str_func ...@@ -528,8 +523,7 @@ class Item_func_rpad :public Item_str_func
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "rpad"; } const char *func_name() const { return "rpad"; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg);}
}; };
...@@ -542,8 +536,7 @@ class Item_func_lpad :public Item_str_func ...@@ -542,8 +536,7 @@ class Item_func_lpad :public Item_str_func
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "lpad"; } const char *func_name() const { return "lpad"; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg);}
}; };
...@@ -558,8 +551,7 @@ class Item_func_conv :public Item_str_func ...@@ -558,8 +551,7 @@ class Item_func_conv :public Item_str_func
collation.set(default_charset()); collation.set(default_charset());
max_length= 64; max_length= 64;
} }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg);}
}; };
...@@ -576,8 +568,7 @@ class Item_func_hex :public Item_str_func ...@@ -576,8 +568,7 @@ class Item_func_hex :public Item_str_func
decimals=0; decimals=0;
max_length=args[0]->max_length*2*collation.collation->mbmaxlen; max_length=args[0]->max_length*2*collation.collation->mbmaxlen;
} }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_binary_collation(int_arg);}
}; };
class Item_func_unhex :public Item_str_func class Item_func_unhex :public Item_str_func
...@@ -593,8 +584,7 @@ class Item_func_unhex :public Item_str_func ...@@ -593,8 +584,7 @@ class Item_func_unhex :public Item_str_func
decimals=0; decimals=0;
max_length=(1+args[0]->max_length)/2; max_length=(1+args[0]->max_length)/2;
} }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_binary_collation(int_arg);}
}; };
...@@ -618,8 +608,7 @@ class Item_func_binary :public Item_str_func ...@@ -618,8 +608,7 @@ class Item_func_binary :public Item_str_func
} }
void print(String *str); void print(String *str);
const char *func_name() const { return "cast_as_binary"; } const char *func_name() const { return "cast_as_binary"; }
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg);}
}; };
...@@ -659,7 +648,7 @@ class Item_func_inet_ntoa : public Item_str_func ...@@ -659,7 +648,7 @@ class Item_func_inet_ntoa : public Item_str_func
String* val_str(String* str); String* val_str(String* str);
const char *func_name() const { return "inet_ntoa"; } const char *func_name() const { return "inet_ntoa"; }
void fix_length_and_dec() { decimals = 0; max_length=3*8+7; } void fix_length_and_dec() { decimals = 0; max_length=3*8+7; }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE; }
}; };
class Item_func_quote :public Item_str_func class Item_func_quote :public Item_str_func
...@@ -674,7 +663,7 @@ class Item_func_quote :public Item_str_func ...@@ -674,7 +663,7 @@ class Item_func_quote :public Item_str_func
collation.set(args[0]->collation); collation.set(args[0]->collation);
max_length= args[0]->max_length * 2 + 2; max_length= args[0]->max_length * 2 + 2;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE; }
}; };
class Item_func_conv_charset :public Item_str_func class Item_func_conv_charset :public Item_str_func
...@@ -775,8 +764,7 @@ class Item_func_crc32 :public Item_int_func ...@@ -775,8 +764,7 @@ class Item_func_crc32 :public Item_int_func
const char *func_name() const { return "crc32"; } const char *func_name() const { return "crc32"; }
void fix_length_and_dec() { max_length=10; } void fix_length_and_dec() { max_length=10; }
longlong val_int(); longlong val_int();
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg);}
}; };
class Item_func_uncompressed_length : public Item_int_func class Item_func_uncompressed_length : public Item_int_func
......
...@@ -39,7 +39,7 @@ class Item_func_period_add :public Item_int_func ...@@ -39,7 +39,7 @@ class Item_func_period_add :public Item_int_func
{ {
max_length=6*MY_CHARSET_BIN_MB_MAXLEN; max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -54,7 +54,7 @@ class Item_func_period_diff :public Item_int_func ...@@ -54,7 +54,7 @@ class Item_func_period_diff :public Item_int_func
decimals=0; decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN; max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -71,7 +71,7 @@ class Item_func_to_days :public Item_int_func ...@@ -71,7 +71,7 @@ class Item_func_to_days :public Item_int_func
maybe_null=1; maybe_null=1;
} }
enum_monotonicity_info get_monotonicity_info() const; enum_monotonicity_info get_monotonicity_info() const;
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -87,7 +87,7 @@ class Item_func_dayofmonth :public Item_int_func ...@@ -87,7 +87,7 @@ class Item_func_dayofmonth :public Item_int_func
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -112,7 +112,7 @@ class Item_func_month :public Item_func ...@@ -112,7 +112,7 @@ class Item_func_month :public Item_func
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -145,7 +145,7 @@ class Item_func_dayofyear :public Item_int_func ...@@ -145,7 +145,7 @@ class Item_func_dayofyear :public Item_int_func
max_length=3*MY_CHARSET_BIN_MB_MAXLEN; max_length=3*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -161,7 +161,7 @@ class Item_func_hour :public Item_int_func ...@@ -161,7 +161,7 @@ class Item_func_hour :public Item_int_func
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -177,7 +177,7 @@ class Item_func_minute :public Item_int_func ...@@ -177,7 +177,7 @@ class Item_func_minute :public Item_int_func
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -193,7 +193,7 @@ class Item_func_quarter :public Item_int_func ...@@ -193,7 +193,7 @@ class Item_func_quarter :public Item_int_func
max_length=1*MY_CHARSET_BIN_MB_MAXLEN; max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -209,7 +209,7 @@ class Item_func_second :public Item_int_func ...@@ -209,7 +209,7 @@ class Item_func_second :public Item_int_func
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -225,7 +225,7 @@ class Item_func_week :public Item_int_func ...@@ -225,7 +225,7 @@ class Item_func_week :public Item_int_func
max_length=2*MY_CHARSET_BIN_MB_MAXLEN; max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
class Item_func_yearweek :public Item_int_func class Item_func_yearweek :public Item_int_func
...@@ -240,7 +240,7 @@ class Item_func_yearweek :public Item_int_func ...@@ -240,7 +240,7 @@ class Item_func_yearweek :public Item_int_func
max_length=6*MY_CHARSET_BIN_MB_MAXLEN; max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -257,7 +257,7 @@ class Item_func_year :public Item_int_func ...@@ -257,7 +257,7 @@ class Item_func_year :public Item_int_func
max_length=4*MY_CHARSET_BIN_MB_MAXLEN; max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -287,7 +287,7 @@ class Item_func_weekday :public Item_func ...@@ -287,7 +287,7 @@ class Item_func_weekday :public Item_func
max_length=1*MY_CHARSET_BIN_MB_MAXLEN; max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
class Item_func_dayname :public Item_func_weekday class Item_func_dayname :public Item_func_weekday
...@@ -320,7 +320,7 @@ class Item_func_unix_timestamp :public Item_int_func ...@@ -320,7 +320,7 @@ class Item_func_unix_timestamp :public Item_int_func
decimals=0; decimals=0;
max_length=10*MY_CHARSET_BIN_MB_MAXLEN; max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -335,7 +335,7 @@ class Item_func_time_to_sec :public Item_int_func ...@@ -335,7 +335,7 @@ class Item_func_time_to_sec :public Item_int_func
decimals=0; decimals=0;
max_length=10*MY_CHARSET_BIN_MB_MAXLEN; max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -545,7 +545,7 @@ class Item_func_from_days :public Item_date ...@@ -545,7 +545,7 @@ class Item_func_from_days :public Item_date
Item_func_from_days(Item *a) :Item_date(a) {} Item_func_from_days(Item *a) :Item_date(a) {}
const char *func_name() const { return "from_days"; } const char *func_name() const { return "from_days"; }
bool get_date(TIME *res, uint fuzzy_date); bool get_date(TIME *res, uint fuzzy_date);
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -563,7 +563,7 @@ class Item_func_date_format :public Item_str_func ...@@ -563,7 +563,7 @@ class Item_func_date_format :public Item_str_func
void fix_length_and_dec(); void fix_length_and_dec();
uint format_length(const String *format); uint format_length(const String *format);
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -582,7 +582,7 @@ class Item_func_from_unixtime :public Item_date_func ...@@ -582,7 +582,7 @@ class Item_func_from_unixtime :public Item_date_func
const char *func_name() const { return "from_unixtime"; } const char *func_name() const { return "from_unixtime"; }
void fix_length_and_dec(); void fix_length_and_dec();
bool get_date(TIME *res, uint fuzzy_date); bool get_date(TIME *res, uint fuzzy_date);
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -651,7 +651,7 @@ class Item_func_sec_to_time :public Item_str_func ...@@ -651,7 +651,7 @@ class Item_func_sec_to_time :public Item_str_func
return tmp_table_field_from_field_type(table, 0); return tmp_table_field_from_field_type(table, 0);
} }
bool result_as_longlong() { return TRUE; } bool result_as_longlong() { return TRUE; }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -674,7 +674,7 @@ class Item_date_add_interval :public Item_date_func ...@@ -674,7 +674,7 @@ class Item_date_add_interval :public Item_date_func
bool get_date(TIME *res, uint fuzzy_date); bool get_date(TIME *res, uint fuzzy_date);
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
void print(String *str); void print(String *str);
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -692,8 +692,7 @@ class Item_extract :public Item_int_func ...@@ -692,8 +692,7 @@ class Item_extract :public Item_int_func
void fix_length_and_dec(); void fix_length_and_dec();
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
void print(String *str); void print(String *str);
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE;}
{ return safe_for_single_char_collation(int_arg); }
}; };
...@@ -730,7 +729,7 @@ class Item_typecast_maybe_null :public Item_typecast ...@@ -730,7 +729,7 @@ class Item_typecast_maybe_null :public Item_typecast
max_length=args[0]->max_length; max_length=args[0]->max_length;
maybe_null= 1; maybe_null= 1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -750,8 +749,7 @@ class Item_char_typecast :public Item_typecast ...@@ -750,8 +749,7 @@ class Item_char_typecast :public Item_typecast
String *val_str(String *a); String *val_str(String *a);
void fix_length_and_dec(); void fix_length_and_dec();
void print(String *str); void print(String *str);
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE;}
{ return safe_for_single_char_collation(int_arg); }
}; };
...@@ -831,7 +829,7 @@ class Item_func_makedate :public Item_str_func ...@@ -831,7 +829,7 @@ class Item_func_makedate :public Item_str_func
} }
bool result_as_longlong() { return TRUE; } bool result_as_longlong() { return TRUE; }
longlong val_int(); longlong val_int();
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -854,7 +852,7 @@ class Item_func_add_time :public Item_str_func ...@@ -854,7 +852,7 @@ class Item_func_add_time :public Item_str_func
} }
void print(String *str); void print(String *str);
const char *func_name() const { return "add_time"; } const char *func_name() const { return "add_time"; }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
class Item_func_timediff :public Item_str_func class Item_func_timediff :public Item_str_func
...@@ -894,7 +892,7 @@ class Item_func_maketime :public Item_str_func ...@@ -894,7 +892,7 @@ class Item_func_maketime :public Item_str_func
{ {
return tmp_table_field_from_field_type(table, 0); return tmp_table_field_from_field_type(table, 0);
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
class Item_func_microsecond :public Item_int_func class Item_func_microsecond :public Item_int_func
...@@ -908,7 +906,7 @@ class Item_func_microsecond :public Item_int_func ...@@ -908,7 +906,7 @@ class Item_func_microsecond :public Item_int_func
decimals=0; decimals=0;
maybe_null=1; maybe_null=1;
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -926,7 +924,7 @@ class Item_func_timestamp_diff :public Item_int_func ...@@ -926,7 +924,7 @@ class Item_func_timestamp_diff :public Item_int_func
maybe_null=1; maybe_null=1;
} }
void print(String *str); void print(String *str);
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
...@@ -973,7 +971,7 @@ class Item_func_str_to_date :public Item_str_func ...@@ -973,7 +971,7 @@ class Item_func_str_to_date :public Item_str_func
{ {
return tmp_table_field_from_field_type(table, 1); return tmp_table_field_from_field_type(table, 1);
} }
bool check_partition_func_processor(byte *int_arg) { return 0;} bool check_partition_func_processor(byte *int_arg) { return FALSE;}
}; };
......
...@@ -42,8 +42,7 @@ class Item_func_xml_extractvalue: public Item_xml_str_func ...@@ -42,8 +42,7 @@ class Item_func_xml_extractvalue: public Item_xml_str_func
Item_func_xml_extractvalue(Item *a,Item *b) :Item_xml_str_func(a,b) {} Item_func_xml_extractvalue(Item *a,Item *b) :Item_xml_str_func(a,b) {}
const char *func_name() const { return "extractvalue"; } const char *func_name() const { return "extractvalue"; }
String *val_str(String *); String *val_str(String *);
bool check_partition_func_processor(byte *int_arg) bool check_partition_func_processor(byte *int_arg) { return FALSE; }
{ return safe_for_single_char_collation(int_arg);}
}; };
......
...@@ -718,25 +718,26 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, ...@@ -718,25 +718,26 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
uint i, tot_partitions; uint i, tot_partitions;
bool result= TRUE; bool result= TRUE;
char *same_name; char *same_name;
int part_expression_ok= PF_SAFE;
DBUG_ENTER("partition_info::check_partition_info"); DBUG_ENTER("partition_info::check_partition_info");
pf_collation_allowed= PF_SAFE;
spf_collation_allowed= PF_SAFE;
if (check_partition_function) if (check_partition_function)
{ {
int part_expression_ok= 1;
int pf_collation_allowed= 1;
int spf_collation_allowed= 1;
if (part_type != HASH_PARTITION || !list_of_part_fields) if (part_type != HASH_PARTITION || !list_of_part_fields)
{ {
part_expr->walk(&Item::check_partition_func_processor, 0, part_expr->walk(&Item::check_partition_func_processor, 0,
(byte*)(&part_expression_ok)); (byte*)(&part_expression_ok));
pf_collation_allowed= (char)part_expression_ok; pf_collation_allowed= part_expression_ok;
part_expression_ok= PF_SAFE; part_expression_ok= 1;
if (is_sub_partitioned() && !list_of_subpart_fields) if (is_sub_partitioned() && !list_of_subpart_fields)
{ {
subpart_expr->walk(&Item::check_partition_func_processor, 0, subpart_expr->walk(&Item::check_partition_func_processor, 0,
(byte*)(&part_expression_ok)); (byte*)(&part_expression_ok));
} }
spf_collation_allowed= (char)part_expression_ok; spf_collation_allowed= part_expression_ok;
} }
if (!pf_collation_allowed || if (!pf_collation_allowed ||
!spf_collation_allowed) !spf_collation_allowed)
......
...@@ -188,8 +188,6 @@ class partition_info : public Sql_alloc ...@@ -188,8 +188,6 @@ class partition_info : public Sql_alloc
bool is_auto_partitioned; bool is_auto_partitioned;
bool from_openfrm; bool from_openfrm;
bool has_null_value; bool has_null_value;
char pf_collation_allowed;
char spf_collation_allowed;
partition_info() partition_info()
...@@ -219,9 +217,7 @@ class partition_info : public Sql_alloc ...@@ -219,9 +217,7 @@ class partition_info : public Sql_alloc
list_of_part_fields(FALSE), list_of_subpart_fields(FALSE), list_of_part_fields(FALSE), list_of_subpart_fields(FALSE),
linear_hash_ind(FALSE), fixed(FALSE), linear_hash_ind(FALSE), fixed(FALSE),
is_auto_partitioned(FALSE), from_openfrm(FALSE), is_auto_partitioned(FALSE), from_openfrm(FALSE),
has_null_value(FALSE), has_null_value(FALSE)
pf_collation_allowed(0),
spf_collation_allowed(0)
{ {
all_fields_in_PF.clear_all(); all_fields_in_PF.clear_all();
all_fields_in_PPF.clear_all(); all_fields_in_PPF.clear_all();
......
...@@ -1376,7 +1376,7 @@ static uint32 get_part_id_from_linear_hash(longlong hash_value, uint mask, ...@@ -1376,7 +1376,7 @@ static uint32 get_part_id_from_linear_hash(longlong hash_value, uint mask,
Check that partition function do not contain any forbidden Check that partition function do not contain any forbidden
character sets and collations. character sets and collations.
SYNOPSIS SYNOPSIS
check_part_func_collation() check_part_func_fields()
part_info Partition info part_info Partition info
ptr Array of Field pointers ptr Array of Field pointers
RETURN VALUES RETURN VALUES
...@@ -1384,19 +1384,24 @@ static uint32 get_part_id_from_linear_hash(longlong hash_value, uint mask, ...@@ -1384,19 +1384,24 @@ static uint32 get_part_id_from_linear_hash(longlong hash_value, uint mask,
TRUE Error TRUE Error
*/ */
static bool check_part_func_collation(int collation_allowed, static bool check_part_func_fields(Field **ptr)
Field **ptr)
{ {
Field *field; Field *field;
while ((field= *(ptr++))) while ((field= *(ptr++)))
{ {
if (field->result_type() == STRING_RESULT) /*
For CHAR/VARCHAR fields we need to take special precautions.
Binary collation with CHAR is automatically supported. Other
types need some kind of standardisation function handling
*/
if (field->type() == MYSQL_TYPE_STRING ||
field->type() == MYSQL_TYPE_VARCHAR)
{ {
CHARSET_INFO *cs= ((Field_str*)field)->charset(); CHARSET_INFO *cs= ((Field_str*)field)->charset();
if (use_strnxfrm(cs) || if (field->type() == MYSQL_TYPE_STRING &&
(collation_allowed == PF_SAFE_BINARY_COLLATION && cs->state & MY_CS_BINSORT)
(!(cs->state & MY_CS_BINSORT)))) return FALSE;
return TRUE; return TRUE;
} }
} }
return FALSE; return FALSE;
...@@ -1548,13 +1553,9 @@ bool fix_partition_func(THD *thd, TABLE *table, ...@@ -1548,13 +1553,9 @@ bool fix_partition_func(THD *thd, TABLE *table,
goto end; goto end;
} }
} }
if (((part_info->pf_collation_allowed != PF_SAFE) && if ((check_part_func_fields(part_info->part_field_array)) ||
check_part_func_collation(part_info->pf_collation_allowed,
part_info->part_field_array)) ||
(part_info->is_sub_partitioned() && (part_info->is_sub_partitioned() &&
part_info->spf_collation_allowed != PF_SAFE && check_part_func_fields(part_info->subpart_field_array)))
check_part_func_collation(part_info->spf_collation_allowed,
part_info->subpart_field_array)))
{ {
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0)); my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
goto end; goto end;
......
...@@ -3619,7 +3619,7 @@ part_bit_expr: ...@@ -3619,7 +3619,7 @@ part_bit_expr:
{ {
Item *part_expr= $1; Item *part_expr= $1;
bool not_corr_func; bool not_corr_func;
bool part_expression_ok= TRUE; int part_expression_ok= 1;
LEX *lex= Lex; LEX *lex= Lex;
THD *thd= YYTHD; THD *thd= YYTHD;
longlong item_value; longlong item_value;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment