diff options
Diffstat (limited to 'sql/item.h')
-rw-r--r-- | sql/item.h | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/sql/item.h b/sql/item.h index a6132aba8b0..7b93db6301a 100644 --- a/sql/item.h +++ b/sql/item.h @@ -789,7 +789,7 @@ public: Check if a partition function is allowed SYNOPSIS check_partition_func_processor() - bool_arg Return argument + int_arg Return argument RETURN VALUE 0 DESCRIPTION @@ -806,8 +806,28 @@ public: whether this should be inherited to the new class. If not the function below should be defined in the new Item class. */ - virtual bool check_partition_func_processor(byte *bool_arg) - { *(bool *)bool_arg= FALSE; return 0; } + +#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) + { + *(int *)int_arg= PF_UNSAFE; + return 0; + } virtual Item *equal_fields_propagator(byte * arg) { return this; } virtual Item *set_no_const_sub(byte *arg) { return this; } @@ -1106,7 +1126,8 @@ public: Item::maybe_null= TRUE; } - bool check_partition_func_processor(byte *bool_arg) { return 0; } + bool check_partition_func_processor(byte *int_arg) + { return safe_for_single_char_collation(int_arg); } bool fix_fields(THD *, Item **); enum Type type() const; @@ -1153,7 +1174,7 @@ public: Item_num() {} /* Remove gcc warning */ virtual Item_num *neg()= 0; Item *safe_charset_converter(CHARSET_INFO *tocs); - bool check_partition_func_processor(byte *bool_arg) { return 0;} + bool check_partition_func_processor(byte *int_arg) { return 0;} }; #define NO_CACHED_FIELD_INDEX ((uint)(-1)) @@ -1289,7 +1310,7 @@ public: bool collect_item_field_processor(byte * arg); bool find_item_in_field_list_processor(byte *arg); bool register_field_in_read_map(byte *arg); - bool check_partition_func_processor(byte *bool_arg) { return 0; } + bool check_partition_func_processor(byte *int_arg) { return 0; } void cleanup(); bool result_as_longlong() { @@ -1337,7 +1358,7 @@ public: bool is_null() { return 1; } void print(String *str) { str->append(STRING_WITH_LEN("NULL")); } Item *safe_charset_converter(CHARSET_INFO *tocs); - bool check_partition_func_processor(byte *bool_arg) { return 0;} + bool check_partition_func_processor(byte *int_arg) { return 0;} }; class Item_null_result :public Item_null @@ -1350,8 +1371,8 @@ public: { save_in_field(result_field, no_conversions); } - bool check_partition_func_processor(byte *bool_arg) - { *(bool *)bool_arg= FALSE; return 0; } + bool check_partition_func_processor(byte *int_arg) + { *(int *)int_arg= PF_UNSAFE; return 0; } }; /* Item represents one placeholder ('?') of prepared statement */ @@ -1642,8 +1663,8 @@ public: {} void print(String *str) { str->append(func_name); } Item *safe_charset_converter(CHARSET_INFO *tocs); - bool check_partition_func_processor(byte *bool_arg) - { *(bool *)bool_arg= FALSE; return 0; } + bool check_partition_func_processor(byte *int_arg) + { *(int *)int_arg= PF_UNSAFE; return 0; } }; @@ -1721,7 +1742,7 @@ public: void print(String *str); // to prevent drop fixed flag (no need parent cleanup call) void cleanup() {} - bool check_partition_func_processor(byte *bool_arg) { return 0;} + bool check_partition_func_processor(byte *int_arg) { return 0;} }; @@ -1736,8 +1757,8 @@ public: {} Item *safe_charset_converter(CHARSET_INFO *tocs); void print(String *str) { str->append(func_name); } - bool check_partition_func_processor(byte *bool_arg) - { *(bool *)bool_arg= FALSE; return 0; } + bool check_partition_func_processor(byte *int_arg) + { *(int *)int_arg= PF_UNSAFE; return 0; } }; @@ -1750,8 +1771,8 @@ public: &my_charset_bin) { max_length=19;} enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } - bool check_partition_func_processor(byte *bool_arg) - { *(bool *)bool_arg= FALSE; return 0; } + bool check_partition_func_processor(byte *int_arg) + { *(int *)int_arg= PF_UNSAFE; return 0; } }; class Item_empty_string :public Item_string @@ -1774,8 +1795,8 @@ public: unsigned_flag=1; } enum_field_types field_type() const { return int_field_type; } - bool check_partition_func_processor(byte *bool_arg) - { *(bool *)bool_arg= FALSE; return 0; } + bool check_partition_func_processor(byte *int_arg) + { *(int *)int_arg= PF_UNSAFE; return 0; } }; @@ -1799,7 +1820,8 @@ public: void cleanup() {} bool eq(const Item *item, bool binary_cmp) const; virtual Item *safe_charset_converter(CHARSET_INFO *tocs); - bool check_partition_func_processor(byte *bool_arg) { return 0;} + bool check_partition_func_processor(byte *int_arg) + { return safe_for_binary_collation(int_arg);} }; @@ -2026,8 +2048,8 @@ public: } Item *new_item(); virtual Item *real_item() { return ref; } - bool check_partition_func_processor(byte *bool_arg) - { *(bool *)bool_arg= FALSE; return 0; } + bool check_partition_func_processor(byte *int_arg) + { *(int *)int_arg= PF_UNSAFE; return 0; } }; #ifdef MYSQL_SERVER |