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

MDEV-16309 Split ::create_tmp_field() into virtual methods in Item

Detailed: changes:
1. Moving Field specific code into new methods on Field:
   - Field *Field::create_tmp_field(...)
   - virtual void init_for_tmp_table(...)

2. Removing virtual Item::create_tmp_field().
   Adding instead a new virtual method Item::create_tmp_field_ex().

   Note, a virtual create_tmp_field() still exists, but only for Item_sum.
   This resembles 10.0 code structure. Perhaps create_tmp_field() should
   be removed from Item_sum and Item_sum descendants should override
   create_tmp_field_ex() directly. This can be done in a separate commit.

3. Adding helper classes Tmp_field_src and Tmp_field_param,
   to make the API for Item::create_tmp_field_ex() smaller
   and easier to extend in the future.

4. Decomposing the public function create_tmp_field() into
   virtual implementations for Item and a number of its descendants:
   - Item_basic_value
   - Item_sp_variable
   - Item_name_const
   - Item_result_field
   - Item_field
   - Item_ref
   - Item_type_holder
   - Item_row
   - Item_func_sp
   - Item_func_user_var
   - Item_sum
   - Item_sum_field
   - Item_proc

5. Adding DBUG_ASSERT-only virtual implementations for
   Item types that should not appear in create_tmp_table_ex(),
   for easier debugging:
   - Item_nodeset_func
   - Item_nodeset_to_const_comparator
   - Item_null_result
   - Item_copy
   - Item_ident_for_show
   - Item_user_var_as_out_param

6. Moving public function create_tmp_field_from_field()
   as a method to Item_field.

7. Removing Item::set_result_field(). It's not needed any more.

8. Cleanup: Removing the enum value "EXPR_CACHE_ITEM",
   as it's not used for a very long time.
This commit is contained in:
Alexander Barkov
2018-05-28 16:57:59 +04:00
parent 13f7ac2269
commit 637af78383
16 changed files with 611 additions and 310 deletions

View File

@ -1228,6 +1228,12 @@ public:
virtual Field *new_key_field(MEM_ROOT *root, TABLE *new_table,
uchar *new_ptr, uint32 length,
uchar *new_null_ptr, uint new_null_bit);
Field *create_tmp_field(MEM_ROOT *root, TABLE *new_table,
bool maybe_null_arg);
Field *create_tmp_field(MEM_ROOT *root, TABLE *new_table)
{
return create_tmp_field(root, new_table, maybe_null());
}
Field *clone(MEM_ROOT *mem_root, TABLE *new_table);
Field *clone(MEM_ROOT *mem_root, TABLE *new_table, my_ptrdiff_t diff,
bool stat_flag= FALSE);
@ -1388,7 +1394,19 @@ public:
orig_table= table= table_arg;
set_table_name(&table_arg->alias);
}
virtual void init_for_tmp_table(Field *org_field, TABLE *new_table)
{
init(new_table);
orig_table= org_field->orig_table;
vcol_info= 0;
cond_selectivity= 1.0;
next_equal_field= NULL;
option_list= NULL;
option_struct= NULL;
if (org_field->type() == MYSQL_TYPE_VAR_STRING ||
org_field->type() == MYSQL_TYPE_VARCHAR)
new_table->s->db_create_options|= HA_OPTION_PACK_RECORD;
}
/* maximum possible display length */
virtual uint32 max_display_length()= 0;
@ -2307,6 +2325,11 @@ public:
if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC;
}
void init_for_tmp_table(Field *org_field, TABLE *new_table)
{
Field::init_for_tmp_table(org_field, new_table);
not_fixed= true;
}
const Type_handler *type_handler() const { return &type_handler_double; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; }
int store(const char *to,size_t length,CHARSET_INFO *charset);