diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 0b90d3e..4b466a5 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4814,11 +4814,14 @@ bool in_decimal::compare_elems(uint pos1, uint pos2) const cmp_item* cmp_item::get_comparator(Item_result type, - const CHARSET_INFO *cs) + const CHARSET_INFO *cs, Item *date_item) { switch (type) { case STRING_RESULT: - return new cmp_item_string(cs); + if (date_item) + return new cmp_item_datetime(date_item); + else + return new cmp_item_string(cs); case INT_RESULT: return new cmp_item_int; case REAL_RESULT: @@ -7584,8 +7587,24 @@ longlong Item_equal::val_int() void Item_equal::fix_length_and_dec() { Item *item= get_first(); + Item *date_item= 0; + + if (item->result_type() == STRING_RESULT) + { + List_iterator it(fields); + Item *item1; + while ((item1= it++)) + { + if (item1->is_temporal_with_date()) + { + date_item= item1; + break; + } + } + } + eval_item= cmp_item::get_comparator(item->result_type(), - item->collation.collation); + item->collation.collation, date_item); } bool Item_equal::walk(Item_processor processor, enum_walk walk, uchar *arg) diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 474001c..8c15cbf 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1395,7 +1395,8 @@ public: virtual int cmp(Item *item)= 0; // for optimized IN with row virtual int compare(const cmp_item *item) const= 0; - static cmp_item* get_comparator(Item_result type, const CHARSET_INFO *cs); + static cmp_item* get_comparator(Item_result type, const CHARSET_INFO *cs, + Item *date_item= 0); virtual cmp_item *make_same()= 0; virtual void store_value_by_template(cmp_item *tmpl, Item *item) {