summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2016-11-28 10:21:01 +0400
committerAlexander Barkov <bar@mariadb.org>2016-12-16 18:23:21 +0400
commit9185f8d4a72e7e2001c29bf1502ce7dd4e782e98 (patch)
tree742ac6196d4f291be78c19f84a0f73f46461d427 /sql/item_sum.cc
parent749bbb3d7b213b5044d97006259f013d70007d60 (diff)
downloadmariadb-git-9185f8d4a72e7e2001c29bf1502ce7dd4e782e98.tar.gz
MDEV-11365 Split the data type and attribute related code in Item_sum_hybrid::fix_fields into Type_handler::Item_sum_hybrid_fix_length_and_dec()
This patch: - Implements the task according to the description - Adds a new class Type_handler_numeric as a common parent for Type_handler_real_result, Type_handler_int_result, Type_handler_decimal_result, to share the common code between numeric data type handlers. - Removes the dedundant call for collation.set(item->collation) in Item_sum_hybrid::setup_hybrid(), because setup_hybrid() is called either after fix_length_and_dec() or afte ther constructor Item_sum_hybrid(THD *thd, Item_sum_hybrid *item), so the collation is already properly set in all cases.
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc36
1 files changed, 9 insertions, 27 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 9ffb056b2a2..879115d9b3b 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -1126,36 +1126,11 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
if ((!item->fixed && item->fix_fields(thd, args)) ||
(item= args[0])->check_cols(1))
return TRUE;
- Type_std_attributes::set(args[0]);
with_subselect= args[0]->with_subselect;
- 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(),
- max_length, collation.collation);
-
- switch (Item_sum_hybrid::result_type()) {
- case INT_RESULT:
- case DECIMAL_RESULT:
- case STRING_RESULT:
- break;
- case REAL_RESULT:
- max_length= float_length(decimals);
- break;
- case ROW_RESULT:
- case TIME_RESULT:
- DBUG_ASSERT(0);
- };
+ fix_length_and_dec();
setup_hybrid(thd, args[0], NULL);
- /* MIN/MAX can return NULL for empty set indepedent of the used column */
- maybe_null= 1;
result_field=0;
- null_value=1;
- fix_length_and_dec();
if (check_sum_func(thd, ref))
return TRUE;
@@ -1166,6 +1141,14 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
}
+void Item_sum_hybrid::fix_length_and_dec()
+{
+ DBUG_ASSERT(args[0]->field_type() == args[0]->real_item()->field_type());
+ DBUG_ASSERT(args[0]->result_type() == args[0]->real_item()->result_type());
+ (void) args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this);
+}
+
+
/**
MIN/MAX function setup.
@@ -1201,7 +1184,6 @@ void Item_sum_hybrid::setup_hybrid(THD *thd, Item *item, Item *value_arg)
cmp= new Arg_comparator();
if (cmp)
cmp->set_cmp_func(this, (Item**)&arg_cache, (Item**)&value, FALSE);
- collation.set(item->collation);
}