[MDEV-12710] Fix Item_cache constructors to accept Type_handler instead of enum_field_types Created: 2017-05-06  Updated: 2017-05-06  Resolved: 2017-05-06

Status: Closed
Project: MariaDB Server
Component/s: OTHER
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   

Item_cache and its descendants have this style constructors:

  Item_cache(THD *thd, enum_field_types field_type_arg):
    Item_basic_constant(thd),
    Type_handler_hybrid_field_type(field_type_arg),
    example(0), cached_field(0),
    value_cached(0)
  {
    fixed= 1;
    maybe_null= 1;
    null_value= 1;
  }

Making a cache involves calls for field_type(), e.g.:

new (thd->mem_root) Item_cache_int(thd, item->field_type());
new (thd->mem_root) Item_cache_temporal(thd, item->field_type());

This is not friendly to pluggable data types, which will return existing type codes in field_type().

We'll change all Item_cache* constructors to accept a Type_handler pointer instead:

  Item_cache(THD *thd, const Type_handler *):
    Item_basic_constant(thd),
    Type_handler_hybrid_field_type(handler),
    example(0), cached_field(0),
    value_cached(0)
  {
    ...
  }

And replace constructor calls to:

new (thd->mem_root) Item_cache_int(thd, item->type_handler());
new (thd->mem_root) Item_cache_temporal(thd, item->type_handler());



 Comments   
Comment by Alexander Barkov [ 2017-05-06 ]

Pushed to bb-10.2-ext

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