Commit e1f81822 authored by Alexander Barkov's avatar Alexander Barkov

A cleanup for MDEV-11514, MDEV-11497, MDEV-11554, MDEV-11555 - IN and CASE...

A cleanup for MDEV-11514, MDEV-11497, MDEV-11554, MDEV-11555 - IN and CASE type aggregation problems

Removing cmp_item::get_comparator() and calling instead
Type_handler::make_cmp_item(), which was earlier introduced by this patch:

74891ed2
parent 109bc470
......@@ -3738,30 +3738,6 @@ bool Predicant_to_list_comparator::make_unique_cmp_items(THD *thd,
}
cmp_item* cmp_item::get_comparator(Item_result type, Item *warn_item,
CHARSET_INFO *cs)
{
switch (type) {
case STRING_RESULT:
return new cmp_item_sort_string(cs);
case INT_RESULT:
return new cmp_item_int;
case REAL_RESULT:
return new cmp_item_real;
case ROW_RESULT:
return new cmp_item_row;
case DECIMAL_RESULT:
return new cmp_item_decimal;
case TIME_RESULT:
DBUG_ASSERT(warn_item);
return warn_item->field_type() == MYSQL_TYPE_TIME ?
(cmp_item *) new cmp_item_time() :
(cmp_item *) new cmp_item_datetime();
}
return 0; // to satisfy compiler :)
}
cmp_item* cmp_item_sort_string::make_same()
{
return new cmp_item_sort_string_in_static(cmp_charset);
......@@ -3814,7 +3790,8 @@ bool cmp_item_row::alloc_comparators(THD *thd, uint cols)
void cmp_item_row::store_value(Item *item)
{
DBUG_ENTER("cmp_item_row::store_value");
if (!alloc_comparators(current_thd, item->cols()))
THD *thd= current_thd;
if (!alloc_comparators(thd, item->cols()))
{
item->bring_value();
item->null_value= 0;
......@@ -3836,10 +3813,11 @@ void cmp_item_row::store_value(Item *item)
- predicate0, value00, value01
- predicate1, value10, value11
*/
DBUG_ASSERT(item->element_index(i)->cmp_type() != TIME_RESULT);
Item *elem= item->element_index(i);
const Type_handler *handler= elem->type_handler();
DBUG_ASSERT(elem->cmp_type() != TIME_RESULT);
if (!(comparators[i]=
cmp_item::get_comparator(item->element_index(i)->result_type(), 0,
item->element_index(i)->collation.collation)))
handler->make_cmp_item(thd, elem->collation.collation)))
break; // new failed
}
comparators[i]->store_value(item->element_index(i));
......@@ -6551,8 +6529,8 @@ longlong Item_equal::val_int()
void Item_equal::fix_length_and_dec()
{
Item *item= get_first(NO_PARTICULAR_TAB, NULL);
eval_item= cmp_item::get_comparator(item->cmp_type(), item,
item->collation.collation);
const Type_handler *handler= item->type_handler();
eval_item= handler->make_cmp_item(current_thd, item->collation.collation);
}
......
......@@ -1467,8 +1467,6 @@ class cmp_item :public Sql_alloc
virtual int cmp(Item *item)= 0;
// for optimized IN with row
virtual int compare(cmp_item *item)= 0;
static cmp_item* get_comparator(Item_result type, Item * warn_item,
CHARSET_INFO *cs);
virtual cmp_item *make_same()= 0;
virtual void store_value_by_template(THD *thd, cmp_item *tmpl, Item *item)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment