[MDEV-11357] Split Item_cache::get_cache() into virtual methods in Type_handler Created: 2016-11-26  Updated: 2017-04-07  Resolved: 2016-12-10

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   

As a part of preparatory work for MDEV-4912, we'll add a new virtual method in Type_handler:

virtual Item_cache *Item_get_cache(THD *thd, const Item *item) const;

and split this code into implementations of the new virtual method:

Item_cache* Item_cache::get_cache(THD *thd, const Item *item,
                                  const Item_result type)
{
  MEM_ROOT *mem_root= thd->mem_root;
  switch (type) {
  case INT_RESULT:
    return new (mem_root) Item_cache_int(thd, item->field_type());
  case REAL_RESULT:
    return new (mem_root) Item_cache_real(thd);
  case DECIMAL_RESULT:
    return new (mem_root) Item_cache_decimal(thd);
  case STRING_RESULT:
    return new (mem_root) Item_cache_str(thd, item);
  case ROW_RESULT:
    return new (mem_root) Item_cache_row(thd);
  case TIME_RESULT:
    return new (mem_root) Item_cache_temporal(thd, item->field_type());
  }
  return 0;                                     // Impossible
}

This will allow data type plugins to create their own versions of Item_cache, to optimize comparison with constants.



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

Reviewed and approved by Sanja.

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