[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() Created: 2016-11-28  Updated: 2017-04-09  Resolved: 2016-12-01

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.3
Fix Version/s: 10.3.0

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: datatype

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed

 Description   

Item_sum_hybrid::fix_fields has a code to fix the data type and its attributes:

Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
{
...
  Type_std_attributes::set(args[0]);
...
  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);
  };
  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();
...
}

This task will introduce a new virtual method in Type_handler:

bool Item_sum_hybrid_fix_length_and_dec(Item_sum_hybrid *func) const;

and move pieces of the above fragment to relevant implementations of Type_handler_xxx.

The above fragment in Item_sum_hybrid::fix_fields() will be replaced to a call of the new method:

args[0]->type_handler()->Item_sum_hybrid_fix_length_and_dec(this);


Generated at Thu Feb 08 07:49:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.