diff options
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 31197a0191e..b6ea4beb339 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -128,7 +128,7 @@ int Item_bool_func2::compare_string() if ((res2=args[1]->val_str(&tmp_value2))) { null_value=0; - return binary ? stringcmp(res1,res2) : sortcmp(res1,res2); + return binary() ? stringcmp(res1,res2) : sortcmp(res1,res2); } } null_value=1; @@ -199,7 +199,7 @@ longlong Item_func_equal::val_int() res2=args[1]->val_str(&tmp_value2); if (!res1 || !res2) return test(res1 == res2); - return (binary ? test(stringcmp(res1,res2) == 0) : + return (binary() ? test(stringcmp(res1,res2) == 0) : test(sortcmp(res1,res2) == 0)); } case REAL_RESULT: @@ -266,7 +266,7 @@ longlong Item_func_strcmp::val_int() null_value=1; return 0; } - int value= binary ? stringcmp(a,b) : sortcmp(a,b); + int value= binary() ? stringcmp(a,b) : sortcmp(a,b); null_value=0; return !value ? 0 : (value < 0 ? (longlong) -1 : (longlong) 1); } @@ -355,7 +355,7 @@ void Item_func_between::fix_length_and_dec() if (!args[0] || !args[1] || !args[2]) return; cmp_type=args[0]->result_type(); - if (args[0]->binary) + if (args[0]->binary()) string_compare=stringcmp; else string_compare=sortcmp; @@ -511,21 +511,22 @@ Item_func_if::fix_length_and_dec() if (null1) { cached_result_type= arg2_type; - binary= args[2]->binary; + set_charset(args[2]->charset()); } else if (null2) { cached_result_type= arg1_type; - binary= args[1]->binary; + set_charset(args[1]->charset()); } else if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT) { cached_result_type = STRING_RESULT; - binary=args[1]->binary | args[2]->binary; + set_charset( (args[1]->binary() || args[2]->binary()) ? + my_charset_bin : args[1]->charset()); } else { - binary=1; // Number + set_charset(my_charset_bin); // Number if (arg1_type == REAL_RESULT || arg2_type == REAL_RESULT) cached_result_type = REAL_RESULT; else @@ -663,7 +664,7 @@ Item *Item_func_case::find_item(String *str) } if ((tmp=args[i]->val_str(str))) // If not null { - if (first_expr->binary || args[i]->binary) + if (first_expr->binary() || args[i]->binary()) { if (stringcmp(tmp,first_expr_str)==0) return args[i+1]; @@ -977,7 +978,7 @@ void Item_func_in::fix_length_and_dec() { switch (item->result_type()) { case STRING_RESULT: - if (item->binary) + if (item->binary()) array=new in_string(arg_count,(qsort_cmp) stringcmp); /* purecov: inspected */ else array=new in_string(arg_count,(qsort_cmp) sortcmp); @@ -1003,7 +1004,7 @@ void Item_func_in::fix_length_and_dec() { switch (item->result_type()) { case STRING_RESULT: - if (item->binary) + if (item->binary()) in_item= new cmp_item_binary_string; else in_item= new cmp_item_sort_string; @@ -1275,9 +1276,12 @@ longlong Item_func_like::val_int() return 0; } null_value=0; + if ((res->charset()->state & MY_CS_BINSORT) || + (res2->charset()->state & MY_CS_BINSORT)) + set_charset(my_charset_bin); if (canDoTurboBM) return turboBM_matches(res->ptr(), res->length()) ? 1 : 0; - if (binary) + if (binary()) return wild_compare(*res,*res2,escape) ? 0 : 1; else return wild_case_compare(*res,*res2,escape) ? 0 : 1; @@ -1359,7 +1363,9 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) return 1; /* purecov: inspected */ with_sum_func=args[0]->with_sum_func || args[1]->with_sum_func; max_length=1; decimals=0; - binary=args[0]->binary || args[1]->binary; + if (args[0]->binary() || args[1]->binary()) + set_charset(my_charset_bin); + used_tables_cache=args[0]->used_tables() | args[1]->used_tables(); const_item_cache=args[0]->const_item() && args[1]->const_item(); if (!regex_compiled && args[1]->const_item()) @@ -1374,7 +1380,7 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) } int error; if ((error=regcomp(&preg,res->c_ptr(), - binary ? REG_EXTENDED | REG_NOSUB : + binary() ? REG_EXTENDED | REG_NOSUB : REG_EXTENDED | REG_NOSUB | REG_ICASE, res->charset()))) { @@ -1421,7 +1427,7 @@ longlong Item_func_regex::val_int() regex_compiled=0; } if (regcomp(&preg,res2->c_ptr(), - binary ? REG_EXTENDED | REG_NOSUB : + binary() ? REG_EXTENDED | REG_NOSUB : REG_EXTENDED | REG_NOSUB | REG_ICASE, res->charset())) @@ -1471,7 +1477,7 @@ void Item_func_like::turboBM_compute_suffixes(int* suff) *splm1 = pattern_len; - if (binary) + if (binary()) { int i; for (i = pattern_len - 2; i >= 0; i--) @@ -1574,7 +1580,7 @@ void Item_func_like::turboBM_compute_bad_character_shifts() for (i = bmBc; i < end; i++) *i = pattern_len; - if (binary) + if (binary()) { for (j = 0; j < plm1; j++) bmBc[pattern[j]] = plm1 - j; @@ -1605,7 +1611,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const const int tlmpl = text_len - pattern_len; /* Searching */ - if (binary) + if (binary()) { while (j <= tlmpl) { |