1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

A small cleanup for MDEV-16309 Split ::create_tmp_field() into virtual methods in Item

These two methods:
- Item_result_field::create_tmp_field_ex()
- Item_func_user_var::create_tmp_field_ex()
had duplicate code, except that they used a different type handler.
Adding a protected method Item_result_field::create_tmp_field_ex_from_handler()
with a "const Type_handler*" parameter, and reusing it from the
two mentioned methods.
This commit is contained in:
Alexander Barkov
2019-10-10 22:19:53 +04:00
parent f5833a4e45
commit 5e17b1f7cb
3 changed files with 28 additions and 21 deletions

View File

@ -17740,9 +17740,13 @@ void Item_result_field::get_tmp_field_src(Tmp_field_src *src,
}
Field *Item_result_field::create_tmp_field_ex(MEM_ROOT *root, TABLE *table,
Tmp_field_src *src,
const Tmp_field_param *param)
Field *
Item_result_field::create_tmp_field_ex_from_handler(
MEM_ROOT *root,
TABLE *table,
Tmp_field_src *src,
const Tmp_field_param *param,
const Type_handler *h)
{
/*
Possible Item types:
@ -17750,26 +17754,14 @@ Field *Item_result_field::create_tmp_field_ex(MEM_ROOT *root, TABLE *table,
- Item_func
- Item_subselect
*/
DBUG_ASSERT(fixed);
DBUG_ASSERT(is_result_field());
DBUG_ASSERT(type() != NULL_ITEM);
get_tmp_field_src(src, param);
Field *result;
if ((result= tmp_table_field_from_field_type(root, table)) &&
param->modify_item())
result_field= result;
return result;
}
Field *Item_func_user_var::create_tmp_field_ex(MEM_ROOT *root, TABLE *table,
Tmp_field_src *src,
const Tmp_field_param *param)
{
DBUG_ASSERT(is_result_field());
DBUG_ASSERT(type() != NULL_ITEM);
get_tmp_field_src(src, param);
Field *result;
if ((result= create_table_field_from_handler(root, table)) &&
if ((result= h->make_and_init_table_field(root, &name,
Record_addr(maybe_null),
*this, table)) &&
param->modify_item())
result_field= result;
return result;