[MDEV-12559] Split Item::temporal_precision() into virtual methods in Type_handler Created: 2017-04-22  Updated: 2017-04-22  Resolved: 2017-04-22

Status: Closed
Project: MariaDB Server
Component/s: Temporal Types
Fix Version/s: 10.3.1

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: datatype, refactoring

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

 Description   

This code:

uint Item::temporal_precision(enum_field_types type_arg)
{
  if (const_item() && result_type() == STRING_RESULT &&
      !is_temporal_type(field_type()))
  {
...
        !(type_arg == MYSQL_TYPE_TIME ?
         str_to_time(tmp->charset(), tmp->ptr(), tmp->length(),
                     &ltime, TIME_TIME_ONLY, &status) :
         str_to_datetime(tmp->charset(), tmp->ptr(), tmp->length(),
                         &ltime, TIME_FUZZY_DATES, &status)))
  }
...
  return MY_MIN(decimals, TIME_SECOND_PART_DIGITS);
}

as well as some pieces of the code calling Item::temporal_precision():

class Item_temporal_typecast: public Item_temporal_func
{
  ..
  void fix_length_and_dec_generic(uint int_part_len)
  {
    if (decimals == NOT_FIXED_DEC)
      decimals= args[0]->temporal_precision(field_type());
    fix_attributes_temporal(int_part_len, decimals);
    maybe_null= true;
  }
  ..
}

are not friendly to pluggable data types, because they use field_type().
Also, we'll have to fix this code when adding TIMESTAMP WITH TIME ZONE and TIME WITH TIME ZONE.

To make the code safe for new data types, we'll split this code into two methods in Type_handler:

+  virtual uint Item_time_precision(Item *item) const;
+  virtual uint Item_datetime_precision(Item *item) const;



 Comments   
Comment by Alexander Barkov [ 2017-04-22 ]

Pushed to bb-10.2-ext

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