[MDEV-11558] Split Item_type_holder::display_length into virtual methods in Type_handler Created: 2016-12-13  Updated: 2017-04-07  Resolved: 2016-12-17

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

Type: Task 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   

The method Item_type_holder::display_length(Item *) has this switch:

  switch (item->field_type())

This is not friendly to pluggable data types.

We'll introduce a new Type_handler virtual method:

virtual uint32 max_display_length(const Item *item) const;

and move the pieces from Item_type_holder::display_length(Item *) into implementations of various Type_handler_xxx::max_display_length().

Additionally, instead of doing cast to Item_field:

uint32 Item_type_holder::display_length(Item *item)
{
  if (item->type() == Item::FIELD_ITEM)
    return ((Item_field *)item)->max_disp_length();
  return ...; // the implementation for non-field Items
}

we'll remove the method Item_type_holder::display_length() and introduce a new virtual method in Item:

 virtual uint32 max_display_length() const
 {
   return type_handler()->max_display_length(this);
 }

Notice the default implementation will use max_display_length() of the underlying data type handler.
Item_field will override this implementation and read the result from the underlying field:

uint32 max_display_length() const { return field->max_display_length(); }



 Comments   
Comment by Alexander Barkov [ 2016-12-17 ]

Pushed into bb-10.2-ext

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