mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +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:
12
sql/item.h
12
sql/item.h
@ -3169,6 +3169,11 @@ class st_select_lex;
|
|||||||
|
|
||||||
class Item_result_field :public Item_fixed_hybrid /* Item with result field */
|
class Item_result_field :public Item_fixed_hybrid /* Item with result field */
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
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);
|
||||||
public:
|
public:
|
||||||
Field *result_field; /* Save result here */
|
Field *result_field; /* Save result here */
|
||||||
Item_result_field(THD *thd): Item_fixed_hybrid(thd), result_field(0) {}
|
Item_result_field(THD *thd): Item_fixed_hybrid(thd), result_field(0) {}
|
||||||
@ -3179,7 +3184,12 @@ public:
|
|||||||
~Item_result_field() {} /* Required with gcc 2.95 */
|
~Item_result_field() {} /* Required with gcc 2.95 */
|
||||||
Field *get_tmp_table_field() { return result_field; }
|
Field *get_tmp_table_field() { return result_field; }
|
||||||
Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src,
|
Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src,
|
||||||
const Tmp_field_param *param);
|
const Tmp_field_param *param)
|
||||||
|
{
|
||||||
|
DBUG_ASSERT(fixed);
|
||||||
|
const Type_handler *h= type_handler()->type_handler_for_tmp_table(this);
|
||||||
|
return create_tmp_field_ex_from_handler(root, table, src, param, h);
|
||||||
|
}
|
||||||
void get_tmp_field_src(Tmp_field_src *src, const Tmp_field_param *param);
|
void get_tmp_field_src(Tmp_field_src *src, const Tmp_field_param *param);
|
||||||
/*
|
/*
|
||||||
This implementation of used_tables() used by Item_avg_field and
|
This implementation of used_tables() used by Item_avg_field and
|
||||||
|
@ -2732,7 +2732,12 @@ public:
|
|||||||
:Item_hybrid_func(thd, item),
|
:Item_hybrid_func(thd, item),
|
||||||
m_var_entry(item->m_var_entry), name(item->name) { }
|
m_var_entry(item->m_var_entry), name(item->name) { }
|
||||||
Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src,
|
Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src,
|
||||||
const Tmp_field_param *param);
|
const Tmp_field_param *param)
|
||||||
|
{
|
||||||
|
DBUG_ASSERT(fixed);
|
||||||
|
return create_tmp_field_ex_from_handler(root, table, src, param,
|
||||||
|
type_handler());
|
||||||
|
}
|
||||||
Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table)
|
Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table)
|
||||||
{ return create_table_field_from_handler(root, table); }
|
{ return create_table_field_from_handler(root, table); }
|
||||||
bool check_vcol_func_processor(void *arg);
|
bool check_vcol_func_processor(void *arg);
|
||||||
|
@ -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,
|
Field *
|
||||||
Tmp_field_src *src,
|
Item_result_field::create_tmp_field_ex_from_handler(
|
||||||
const Tmp_field_param *param)
|
MEM_ROOT *root,
|
||||||
|
TABLE *table,
|
||||||
|
Tmp_field_src *src,
|
||||||
|
const Tmp_field_param *param,
|
||||||
|
const Type_handler *h)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Possible Item types:
|
Possible Item types:
|
||||||
@ -17750,26 +17754,14 @@ Field *Item_result_field::create_tmp_field_ex(MEM_ROOT *root, TABLE *table,
|
|||||||
- Item_func
|
- Item_func
|
||||||
- Item_subselect
|
- Item_subselect
|
||||||
*/
|
*/
|
||||||
|
DBUG_ASSERT(fixed);
|
||||||
DBUG_ASSERT(is_result_field());
|
DBUG_ASSERT(is_result_field());
|
||||||
DBUG_ASSERT(type() != NULL_ITEM);
|
DBUG_ASSERT(type() != NULL_ITEM);
|
||||||
get_tmp_field_src(src, param);
|
get_tmp_field_src(src, param);
|
||||||
Field *result;
|
Field *result;
|
||||||
if ((result= tmp_table_field_from_field_type(root, table)) &&
|
if ((result= h->make_and_init_table_field(root, &name,
|
||||||
param->modify_item())
|
Record_addr(maybe_null),
|
||||||
result_field= result;
|
*this, table)) &&
|
||||||
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)) &&
|
|
||||||
param->modify_item())
|
param->modify_item())
|
||||||
result_field= result;
|
result_field= result;
|
||||||
return result;
|
return result;
|
||||||
|
Reference in New Issue
Block a user