diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 39b4e1802e1..b90489ffeea 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1020,6 +1020,8 @@ public: bool walk(Item_processor processor, byte *arg); Item *transform(Item_transformer transformer, byte *arg); void print(String *str); + CHARSET_INFO *compare_collation() + { return fields.head()->collation.collation; } }; class COND_EQUAL diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 5b5cd44d277..36205effe71 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4539,6 +4539,12 @@ static bool check_equality(Item *item, COND_EQUAL *cond_equal) field_item->result_type() == const_item->result_type()) { bool copyfl; + + if (field_item->result_type() == STRING_RESULT && + ((Field_str *) field_item)->charset() != + ((Item_cond *) item)->compare_collation()) + return FALSE; + Item_equal *item_equal = find_item_equal(cond_equal, field_item->field, ©fl); if (copyfl)