diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-09-30 16:04:24 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-09-30 16:04:24 +0400 |
commit | cb2c799bd064a6204b35d102efb5409decc2cb5b (patch) | |
tree | b56762bab860a6d146896700d17f2baf53a15d4f /sql/item_sum.cc | |
parent | cc9cfecab78bde9376e4406bf24506e92fdaaeac (diff) | |
download | mariadb-git-cb2c799bd064a6204b35d102efb5409decc2cb5b.tar.gz |
MDEV-8860 Wrong result for WHERE 2016 < SOME (SELECT CAST(time_column AS DATETIME) FROM t1)
MDEV-8875 Wrong metadata for MAX(CAST(time_column AS DATETIME))
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r-- | sql/item_sum.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index a52c4d783f2..4cbbc274526 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1190,7 +1190,15 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) decimals=item->decimals; with_subselect= args[0]->with_subselect; - switch (hybrid_type= item->result_type()) { + Item *item2= item->real_item(); + if (item2->type() == Item::FIELD_ITEM) + set_handler_by_field_type(((Item_field*) item2)->field->type()); + else if (item->cmp_type() == TIME_RESULT) + set_handler_by_field_type(item2->field_type()); + else + set_handler_by_result_type(item2->result_type()); + + switch (Item_sum_hybrid::result_type()) { case INT_RESULT: case DECIMAL_RESULT: case STRING_RESULT: @@ -1210,11 +1218,6 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref) result_field=0; null_value=1; fix_length_and_dec(); - item= item->real_item(); - if (item->type() == Item::FIELD_ITEM) - hybrid_field_type= ((Item_field*) item)->field->type(); - else - hybrid_field_type= Item::field_type(); if (check_sum_func(thd, ref)) return TRUE; @@ -2235,7 +2238,7 @@ void Item_sum_num::reset_field() void Item_sum_hybrid::reset_field() { - switch(hybrid_type) { + switch(Item_sum_hybrid::result_type()) { case STRING_RESULT: { char buff[MAX_FIELD_WIDTH]; @@ -2507,7 +2510,7 @@ Item *Item_sum_avg::result_item(THD *thd, Field *field) void Item_sum_hybrid::update_field() { - switch (hybrid_type) { + switch (Item_sum_hybrid::result_type()) { case STRING_RESULT: min_max_update_str_field(); break; |