diff options
-rw-r--r-- | sql/item.h | 3 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 11 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 2 | ||||
-rw-r--r-- | sql/item_func.cc | 13 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 2 | ||||
-rw-r--r-- | sql/sql_analyse.cc | 6 | ||||
-rw-r--r-- | sql/sql_analyse.h | 5 |
7 files changed, 17 insertions, 25 deletions
diff --git a/sql/item.h b/sql/item.h index e80648b89de..57061221878 100644 --- a/sql/item.h +++ b/sql/item.h @@ -185,9 +185,6 @@ public: collation.collation= collation_arg->collation; collation.derivation= collation_arg->derivation; } - bool binary() const - { return charset()->state & MY_CS_BINSORT ? 1 : 0 ; } - virtual void set_outer_resolving() {} // Row emulation diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index e3586fef260..a19311cd2fe 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -380,12 +380,7 @@ bool Item_in_optimizer::fix_fields(THD *thd, struct st_table_list *tables, return 1; if (args[0]->maybe_null) maybe_null=1; - /* - TODO: Check if following is right - (set_charset set type of result, not how compare should be used) - */ - if (args[0]->binary()) - set_charset(&my_charset_bin); + with_sum_func= args[0]->with_sum_func; used_tables_cache= args[0]->used_tables(); const_item_cache= args[0]->const_item(); @@ -933,7 +928,7 @@ Item *Item_func_case::find_item(String *str) if ((tmp=args[i]->val_str(str))) // If not null { /* QQ: COERCIBILITY */ - if (first_expr_is_binary || args[i]->binary()) + if (first_expr_is_binary || (args[i]->charset()->state & MY_CS_BINSORT)) { if (sortcmp(tmp,first_expr_str,&my_charset_bin)==0) return args[i+1]; @@ -1044,7 +1039,7 @@ Item_func_case::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) used_tables_cache|=(first_expr)->used_tables(); const_item_cache&= (first_expr)->const_item(); with_sum_func= with_sum_func || (first_expr)->with_sum_func; - first_expr_is_binary= first_expr->binary(); + first_expr_is_binary= first_expr->charset()->state & MY_CS_BINSORT; } if (else_expr) { diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 1311cae335f..1d93c9b6892 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -129,8 +129,6 @@ public: bool have_rev_func() const { return rev_functype() != UNKNOWN_FUNC; } void print(String *str) { Item_func::print_op(str); } bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); } - virtual bool binary() const - { return test(cmp_collation.collation->state & MY_CS_BINSORT); } static Item_bool_func2* eq_creator(Item *a, Item *b); static Item_bool_func2* ne_creator(Item *a, Item *b); diff --git a/sql/item_func.cc b/sql/item_func.cc index d7237f55522..41daa09521c 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1353,7 +1353,18 @@ udf_handler::fix_fields(THD *thd, TABLE_LIST *tables, Item_result_field *func, Item *item= *arg; if (item->fix_fields(thd, tables, arg) || item->check_cols(1)) return 1; - if (item->binary()) + /* + TODO: We should think about this. It is not always + right way just to set an UDF result to return my_charset_bin + if one argument has binary sorting order. + The result collation should be calculated according to arguments + derivations in some cases and should not in other cases. + Moreover, some arguments can represent a numeric input + which doesn't effect the result character set and collation. + There is no a general rule for UDF. Everything depends on + the particular user definted function. + */ + if (item->charset()->state & MY_CS_BINSORT) func->set_charset(&my_charset_bin); if (item->maybe_null) func->maybe_null=1; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index ae63ac85d4d..cbfe98bfd21 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -748,7 +748,7 @@ String *Item_func_replace::val_str(String *str) res->set_charset(collation.collation); #ifdef USE_MB - binary_cmp = (args[0]->binary() || args[1]->binary() || !use_mb(res->charset())); + binary_cmp = ((res->charset()->state & MY_CS_BINSORT) || !use_mb(res->charset())); #endif if (res2->length() == 0) diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 1b1f7c75c26..ced5993e293 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -44,12 +44,6 @@ int sortcmp2(void* cmp_arg __attribute__((unused)), return sortcmp(a,b,a->charset()); } -int stringcmp2(void* cmp_arg __attribute__((unused)), - const String *a,const String *b) -{ - return sortcmp(a,b,&my_charset_bin); -} - int compare_double2(void* cmp_arg __attribute__((unused)), const double *s, const double *t) { diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index 2087e6b2b75..3d1cffecaef 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -99,8 +99,6 @@ int collect_string(String *element, element_count count, int sortcmp2(void* cmp_arg __attribute__((unused)), const String *a,const String *b); -int stringcmp2(void* cmp_arg __attribute__((unused)), - const String *a,const String *b); class field_str :public field_info { @@ -117,8 +115,7 @@ public: max_arg("",default_charset_info), sum(0), must_be_blob(0), was_zero_fill(0), was_maybe_zerofill(0), can_be_still_num(1) - { init_tree(&tree, 0, 0, sizeof(String), a->binary() ? - (qsort_cmp2) stringcmp2 : (qsort_cmp2) sortcmp2, + { init_tree(&tree, 0, 0, sizeof(String), (qsort_cmp2) sortcmp2, 0, (tree_element_free) free_string, NULL); }; void add(); |