--- Percona-Server-5.1.59/sql/item_cmpfunc.cc 2011-08-11 21:52:53.000000000 +0800 +++ Percona-Server-5.1.59-debug/sql/item_cmpfunc.cc 2011-12-02 17:04:35.000000000 +0800 @@ -506,13 +506,24 @@ !(field_item->is_datetime() && args[1]->result_type() == STRING_RESULT)) { - if (convert_constant_item(thd, field_item, &args[1])) + if (!(field_item->field->type() == MYSQL_TYPE_LONGLONG && + (args[1]->real_item()->type() == DECIMAL_ITEM || + (args[1]->real_item()->type() == REAL_ITEM && + args[1]->cmp_context == REAL_RESULT ) || + (args[1]->real_item()->type() == STRING_ITEM && + args[1]->cmp_context == REAL_RESULT ))) && + convert_constant_item(thd, field_item, &args[1]) ) { cmp.set_cmp_func(this, tmp_arg, tmp_arg+1, INT_RESULT); // Works for all types. args[0]->cmp_context= args[1]->cmp_context= INT_RESULT; return; - } + } else { + cmp.set_cmp_func(this, tmp_arg, tmp_arg+1, + DECIMAL_RESULT); // Works for all types. + args[0]->cmp_context= args[1]->cmp_context= DECIMAL_RESULT; + return; + } } } if (args[1]->real_item()->type() == FIELD_ITEM) @@ -522,13 +533,24 @@ !(field_item->is_datetime() && args[0]->result_type() == STRING_RESULT)) { - if (convert_constant_item(thd, field_item, &args[0])) + if (!(field_item->field->type() == MYSQL_TYPE_LONGLONG && + (args[0]->real_item()->type() == DECIMAL_ITEM || + (args[0]->real_item()->type() == REAL_ITEM && + args[0]->cmp_context == REAL_RESULT ) || + (args[0]->real_item()->type() == STRING_ITEM && + args[0]->cmp_context == REAL_RESULT))) && + convert_constant_item(thd, field_item, &args[0]) ) { cmp.set_cmp_func(this, tmp_arg, tmp_arg+1, - INT_RESULT); // Works for all types. + INT_RESULT); // Works for all types. args[0]->cmp_context= args[1]->cmp_context= INT_RESULT; return; - } + } else { + cmp.set_cmp_func(this, tmp_arg, tmp_arg+1, + DECIMAL_RESULT); // Works for all types. + args[0]->cmp_context= args[1]->cmp_context= DECIMAL_RESULT; + return; + } } } }