diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 71 | ||||
-rw-r--r-- | sql/item_func.h | 18 | ||||
-rw-r--r-- | sql/item_row.h | 2 | ||||
-rw-r--r-- | sql/item_strfunc.h | 4 | ||||
-rw-r--r-- | sql/item_sum.cc | 23 | ||||
-rw-r--r-- | sql/item_sum.h | 20 | ||||
-rw-r--r-- | sql/item_windowfunc.cc | 3 | ||||
-rw-r--r-- | sql/item_windowfunc.h | 2 | ||||
-rw-r--r-- | sql/item_xmlfunc.cc | 4 | ||||
-rw-r--r-- | sql/procedure.h | 4 | ||||
-rw-r--r-- | sql/rpl_utility_server.cc | 3 | ||||
-rw-r--r-- | sql/sql_insert.cc | 7 | ||||
-rw-r--r-- | sql/sql_select.cc | 59 | ||||
-rw-r--r-- | sql/sql_type.cc | 364 | ||||
-rw-r--r-- | sql/sql_type.h | 225 | ||||
-rw-r--r-- | sql/sql_type_geom.cc | 14 | ||||
-rw-r--r-- | sql/sql_type_geom.h | 6 |
17 files changed, 496 insertions, 333 deletions
diff --git a/sql/item.h b/sql/item.h index 0816f8d1e39..14c29fe4e6a 100644 --- a/sql/item.h +++ b/sql/item.h @@ -783,10 +783,11 @@ protected: /** Create a field based on the exact data type handler. */ - Field *create_table_field_from_handler(TABLE *table) + Field *create_table_field_from_handler(MEM_ROOT *root, TABLE *table) { const Type_handler *h= type_handler(); - return h->make_and_init_table_field(&name, Record_addr(maybe_null), + return h->make_and_init_table_field(root, &name, + Record_addr(maybe_null), *this, table); } /** @@ -799,11 +800,12 @@ protected: @retval NULL error @retval !NULL on success */ - Field *tmp_table_field_from_field_type(TABLE *table) + Field *tmp_table_field_from_field_type(MEM_ROOT *root, TABLE *table) { DBUG_ASSERT(is_fixed()); const Type_handler *h= type_handler()->type_handler_for_tmp_table(this); - return h->make_and_init_table_field(&name, Record_addr(maybe_null), + return h->make_and_init_table_field(root, &name, + Record_addr(maybe_null), *this, table); } /** @@ -815,17 +817,20 @@ protected: - does not need to set Field::is_created_from_null_item for the result See create_tmp_field_ex() for details on parameters and return values. */ - Field *create_tmp_field_ex_simple(TABLE *table, + Field *create_tmp_field_ex_simple(MEM_ROOT *root, + TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) { DBUG_ASSERT(!param->make_copy_field()); DBUG_ASSERT(!is_result_field()); DBUG_ASSERT(type() != NULL_ITEM); - return tmp_table_field_from_field_type(table); + return tmp_table_field_from_field_type(root, table); } - Field *create_tmp_field_int(TABLE *table, uint convert_int_length); - Field *tmp_table_field_from_field_type_maybe_null(TABLE *table, + Field *create_tmp_field_int(MEM_ROOT *root, TABLE *table, + uint convert_int_length); + Field *tmp_table_field_from_field_type_maybe_null(MEM_ROOT *root, + TABLE *table, Tmp_field_src *src, const Tmp_field_param *param, bool is_explicit_null); @@ -1505,7 +1510,7 @@ public: int save_str_value_in_field(Field *field, String *result); virtual Field *get_tmp_table_field() { return 0; } - virtual Field *create_field_for_create_select(TABLE *table); + virtual Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table); virtual const char *full_name() const { return name.str ? name.str : "???"; } const char *field_name_or_null() { return real_item()->type() == Item::FIELD_ITEM ? name.str : NULL; } @@ -2082,7 +2087,8 @@ public: @retval NULL (on error) @retval a pointer to a newly create Field (on success) */ - virtual Field *create_tmp_field_ex(TABLE *table, + virtual Field *create_tmp_field_ex(MEM_ROOT *root, + TABLE *table, Tmp_field_src *src, const Tmp_field_param *param)= 0; virtual Item_field *field_for_view_update() { return 0; } @@ -2653,7 +2659,8 @@ protected: } Item_basic_value(THD *thd): Item(thd) {} public: - Field *create_tmp_field_ex(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) { @@ -2665,7 +2672,8 @@ public: DECLARE c CURSOR FOR SELECT 'test'; OPEN c; */ - return tmp_table_field_from_field_type_maybe_null(table, src, param, + return tmp_table_field_from_field_type_maybe_null(root, + table, src, param, type() == Item::NULL_ITEM); } bool eq(const Item *item, bool binary_cmp) const; @@ -2737,10 +2745,11 @@ public: inline bool const_item() const; - Field *create_tmp_field_ex(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) { - return create_tmp_field_ex_simple(table, src, param); + return create_tmp_field_ex_simple(root, table, src, param); } inline int save_in_field(Field *field, bool no_conversions); inline bool send(Protocol *protocol, st_value *buffer); @@ -2843,8 +2852,8 @@ public: The inherited implementation would create a column based on result_type(), which is less exact. */ - Field *create_field_for_create_select(TABLE *table) - { return create_table_field_from_handler(table); } + Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) + { return create_table_field_from_handler(root, table); } bool is_valid_limit_clause_variable_with_error() const { @@ -3033,7 +3042,8 @@ public: return TRUE; } - Field *create_tmp_field_ex(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) { /* @@ -3041,7 +3051,7 @@ public: DECLARE c CURSOR FOR SELECT NAME_CONST('x','y') FROM t1; OPEN c; */ - return tmp_table_field_from_field_type_maybe_null(table, src, param, + return tmp_table_field_from_field_type_maybe_null(root, table, src, param, type() == Item::NULL_ITEM); } int save_in_field(Field *field, bool no_conversions) @@ -3101,7 +3111,7 @@ public: {} ~Item_result_field() {} /* Required with gcc 2.95 */ Field *get_tmp_table_field() { return result_field; } - Field *create_tmp_field_ex(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); void get_tmp_field_src(Tmp_field_src *src, const Tmp_field_param *param); /* @@ -3289,10 +3299,11 @@ public: return &type_handler_null; return field->type_handler(); } - Field *create_tmp_field_from_item_field(TABLE *new_table, + Field *create_tmp_field_from_item_field(MEM_ROOT *root, TABLE *new_table, Item_ref *orig_item, const Tmp_field_param *param); - Field *create_tmp_field_ex(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 TYPELIB *get_typelib() const { return field->get_typelib(); } enum_monotonicity_info get_monotonicity_info() const @@ -3535,7 +3546,7 @@ public: { return result_field->type(); } - Field *create_tmp_field_ex(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) { DBUG_ASSERT(0); @@ -4003,8 +4014,8 @@ public: Item_int(THD *thd, const char *str_arg, size_t length=64); const Type_handler *type_handler() const { return type_handler_long_or_longlong(); } - Field *create_field_for_create_select(TABLE *table) - { return tmp_table_field_from_field_type(table); } + Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) + { return tmp_table_field_from_field_type(root, table); } const longlong *const_ptr_longlong() const { return &value; } longlong val_int() { return value; } longlong val_int_min() const { return value; } @@ -5106,7 +5117,7 @@ public: Field *get_tmp_table_field() { return result_field ? result_field : (*ref)->get_tmp_table_field(); } Item *get_tmp_table_item(THD *thd); - Field *create_tmp_field_ex(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); Item* propagate_equal_fields(THD *, const Context &, COND_EQUAL *); table_map used_tables() const; @@ -5866,7 +5877,7 @@ public: const Type_handler *type_handler() const { return Type_handler_hybrid_field_type::type_handler(); } - Field *create_tmp_field_ex(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) { DBUG_ASSERT(0); @@ -6384,10 +6395,10 @@ public: const Type_handler *type_handler() const { return Type_handler_hybrid_field_type::type_handler(); } - Field *create_tmp_field_ex(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) { - return create_tmp_field_ex_simple(table, src, param); + return create_tmp_field_ex_simple(root, table, src, param); } virtual void keep_array() {} @@ -6929,11 +6940,11 @@ public: my_decimal *val_decimal(my_decimal *); String *val_str(String*); bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate); - Field *create_tmp_field_ex(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) { return Item_type_holder::real_type_handler()-> - make_and_init_table_field(&name, Record_addr(maybe_null), + make_and_init_table_field(root, &name, Record_addr(maybe_null), *this, table); } Item* get_copy(THD *thd) { return 0; } diff --git a/sql/item_func.h b/sql/item_func.h index d1be46e41a7..54087a17127 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -188,8 +188,8 @@ public: void signal_divide_by_null(); friend class udf_handler; - Field *create_field_for_create_select(TABLE *table) - { return tmp_table_field_from_field_type(table); } + Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) + { return tmp_table_field_from_field_type(root, table); } Item *get_tmp_table_item(THD *thd); my_decimal *val_decimal(my_decimal *); @@ -2673,10 +2673,10 @@ public: Item_func_user_var(THD *thd, Item_func_user_var *item) :Item_hybrid_func(thd, item), m_var_entry(item->m_var_entry), name(item->name) { } - Field *create_tmp_field_ex(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); - Field *create_field_for_create_select(TABLE *table) - { return create_table_field_from_handler(table); } + Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) + { return create_table_field_from_handler(root, table); } bool check_vcol_func_processor(void *arg); bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) { @@ -2851,7 +2851,7 @@ public: { return 0; } - Field *create_tmp_field_ex(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) { DBUG_ASSERT(0); @@ -3173,13 +3173,13 @@ public: const Type_handler *type_handler() const; - Field *create_tmp_field_ex(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); - Field *create_field_for_create_select(TABLE *table) + Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) { return result_type() != STRING_RESULT ? sp_result_field : - create_table_field_from_handler(table); + create_table_field_from_handler(root, table); } void make_send_field(THD *thd, Send_field *tmp_field); diff --git a/sql/item_row.h b/sql/item_row.h index ea5a0f21d8b..28e6c09a873 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -60,7 +60,7 @@ public: bool with_subquery() const { DBUG_ASSERT(fixed); return m_with_subquery; } enum Type type() const { return ROW_ITEM; }; const Type_handler *type_handler() const { return &type_handler_row; } - Field *create_tmp_field_ex(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) { return NULL; // Check with Vicentiu why it's called for Item_row diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 3ed5a7036c3..676a815eb4e 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -1796,8 +1796,8 @@ public: TABLE *table; Item_temptable_rowid(TABLE *table_arg); const Type_handler *type_handler() const { return &type_handler_string; } - Field *create_tmp_field(bool group, TABLE *table) - { return create_table_field_from_handler(table); } + Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table) + { return create_table_field_from_handler(root, table); } String *val_str(String *str); enum Functype functype() const { return TEMPTABLE_ROWID; } const char *func_name() const { return "<rowid>"; } diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 4051ae461ee..0fbb0fd5ec3 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1231,21 +1231,22 @@ void Item_sum_hybrid::setup_hybrid(THD *thd, Item *item, Item *value_arg) } -Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table) +Field *Item_sum_hybrid::create_tmp_field(MEM_ROOT *root, + bool group, TABLE *table) { DBUG_ENTER("Item_sum_hybrid::create_tmp_field"); if (args[0]->type() == Item::FIELD_ITEM) { Field *field= ((Item_field*) args[0])->field; - if ((field= field->create_tmp_field(table->in_use->mem_root, table, true))) + if ((field= field->create_tmp_field(root, table, true))) { DBUG_ASSERT((field->flags & NOT_NULL_FLAG) == 0); field->field_name= name; } DBUG_RETURN(field); } - DBUG_RETURN(tmp_table_field_from_field_type(table)); + DBUG_RETURN(tmp_table_field_from_field_type(root, table)); } /*********************************************************************** @@ -1935,7 +1936,7 @@ Item *Item_sum_avg::copy_or_same(THD* thd) } -Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table) +Field *Item_sum_avg::create_tmp_field(MEM_ROOT *root, bool group, TABLE *table) { if (group) @@ -1945,7 +1946,7 @@ Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table) The easiest way is to do this is to store both value in a string and unpack on access. */ - Field *field= new (table->in_use->mem_root) + Field *field= new (root) Field_string(((result_type() == DECIMAL_RESULT) ? dec_bin_size : sizeof(double)) + sizeof(longlong), 0, &name, &my_charset_bin); @@ -1953,7 +1954,7 @@ Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table) field->init(table); return field; } - return tmp_table_field_from_field_type(table); + return tmp_table_field_from_field_type(root, table); } @@ -2177,7 +2178,8 @@ Item *Item_sum_variance::copy_or_same(THD* thd) If we're grouping, then we need some space to serialize variables into, to pass around. */ -Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table) +Field *Item_sum_variance::create_tmp_field(MEM_ROOT *root, + bool group, TABLE *table) { Field *field; if (group) @@ -2187,11 +2189,12 @@ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table) The easiest way is to do this is to store both value in a string and unpack on access. */ - field= new Field_string(Stddev::binary_size(), 0, &name, &my_charset_bin); + field= new (root) Field_string(Stddev::binary_size(), 0, + &name, &my_charset_bin); } else - field= new Field_double(max_length, maybe_null, &name, decimals, - TRUE); + field= new (root) Field_double(max_length, maybe_null, &name, decimals, + TRUE); if (field != NULL) field->init(table); diff --git a/sql/item_sum.h b/sql/item_sum.h index dbcb617ce51..cc25a2543d1 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -513,11 +513,11 @@ public: } virtual void make_unique() { force_copy_fields= TRUE; } Item *get_tmp_table_item(THD *thd); - virtual Field *create_tmp_field(bool group, TABLE *table); - Field *create_tmp_field_ex(TABLE *table, Tmp_field_src *src, + virtual Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table); + Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) { - return create_tmp_field(param->group(), table); + return create_tmp_field(root, param->group(), table); } virtual bool collect_outer_ref_processor(void *param); bool init_sum_func_check(THD *thd); @@ -928,7 +928,7 @@ public: return has_with_distinct() ? "avg(distinct " : "avg("; } Item *copy_or_same(THD* thd); - Field *create_tmp_field(bool group, TABLE *table); + Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table); void cleanup() { count= 0; @@ -1013,7 +1013,7 @@ public: const char *func_name() const { return sample ? "var_samp(" : "variance("; } Item *copy_or_same(THD* thd); - Field *create_tmp_field(bool group, TABLE *table); + Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table); const Type_handler *type_handler() const { return &type_handler_double; } void cleanup() { @@ -1100,7 +1100,7 @@ protected: bool any_value() { return was_values; } void no_rows_in_result(); void restore_to_before_no_rows_in_result(); - Field *create_tmp_field(bool group, TABLE *table); + Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table); void setup_caches(THD *thd) { setup_hybrid(thd, arguments()[0], NULL); } }; @@ -1323,9 +1323,9 @@ public: { return SP_AGGREGATE_FUNC; } - Field *create_field_for_create_select(TABLE *table) + Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) { - return create_table_field_from_handler(table); + return create_table_field_from_handler(root, table); } bool fix_length_and_dec(); bool fix_fields(THD *thd, Item **ref); @@ -1407,10 +1407,10 @@ public: unsigned_flag= item->unsigned_flag; } table_map used_tables() const { return (table_map) 1L; } - Field *create_tmp_field_ex(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) { - return create_tmp_field_ex_simple(table, src, param); + return create_tmp_field_ex_simple(root, table, src, param); } void save_in_result_field(bool no_conversions) { DBUG_ASSERT(0); } bool check_vcol_func_processor(void *arg) diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc index adff1c3612b..8eb4692b36e 100644 --- a/sql/item_windowfunc.cc +++ b/sql/item_windowfunc.cc @@ -458,7 +458,8 @@ bool Item_sum_hybrid_simple::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t f return retval; } -Field *Item_sum_hybrid_simple::create_tmp_field(bool group, TABLE *table) +Field *Item_sum_hybrid_simple::create_tmp_field(MEM_ROOT *root, + bool group, TABLE *table) { DBUG_ASSERT(0); return NULL; diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h index ecac80d2aaa..f858378de25 100644 --- a/sql/item_windowfunc.h +++ b/sql/item_windowfunc.h @@ -320,7 +320,7 @@ class Item_sum_hybrid_simple : public Item_sum, const Type_handler *type_handler() const { return Type_handler_hybrid_field_type::type_handler(); } void update_field(); - Field *create_tmp_field(bool group, TABLE *table); + Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table); void clear() { value->clear(); diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index d879c6c2abc..42ed6a3addf 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -195,7 +195,7 @@ public: { return &type_handler_xpath_nodeset; } - Field *create_tmp_field_ex(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) { DBUG_ASSERT(0); @@ -606,7 +606,7 @@ public: { return mark_unsupported_function(func_name(), arg, VCOL_IMPOSSIBLE); } - Field *create_tmp_field_ex(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) { DBUG_ASSERT(0); diff --git a/sql/procedure.h b/sql/procedure.h index 15fd525ec65..008c5a8b294 100644 --- a/sql/procedure.h +++ b/sql/procedure.h @@ -44,7 +44,7 @@ public: this->name.length= strlen(name_par); } enum Type type() const { return Item::PROC_ITEM; } - Field *create_tmp_field_ex(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) { /* @@ -52,7 +52,7 @@ public: DECLARE c CURSOR FOR SELECT * FROM t1 PROCEDURE analyse(); OPEN c; */ - return create_tmp_field_ex_simple(table, src, param); + return create_tmp_field_ex_simple(root, table, src, param); } virtual void set(double nr)=0; virtual void set(const char *str,uint length,CHARSET_INFO *cs)=0; diff --git a/sql/rpl_utility_server.cc b/sql/rpl_utility_server.cc index f3b11e46fa0..4abcd9d6e1e 100644 --- a/sql/rpl_utility_server.cc +++ b/sql/rpl_utility_server.cc @@ -1034,7 +1034,8 @@ public: bool add(const Type_handler *handler, uint16 metadata, const Field *target_field) { - Field *tmp= handler->make_conversion_table_field(this, metadata, + Field *tmp= handler->make_conversion_table_field(in_use->mem_root, + this, metadata, target_field); if (!tmp) return true; diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 1c482446866..bb35949884c 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4127,11 +4127,11 @@ void select_insert::abort_result_set() { CREATE TABLE (SELECT) ... ***************************************************************************/ -Field *Item::create_field_for_create_select(TABLE *table) +Field *Item::create_field_for_create_select(MEM_ROOT *root, TABLE *table) { static Tmp_field_param param(false, false, false, false); Tmp_field_src src; - return create_tmp_field_ex(table, &src, ¶m); + return create_tmp_field_ex(root, table, &src, ¶m); } @@ -4202,7 +4202,8 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items, while ((item=it++)) { - Field *tmp_field= item->create_field_for_create_select(&tmp_table); + Field *tmp_field= item->create_field_for_create_select(thd->mem_root, + &tmp_table); if (!tmp_field) DBUG_RETURN(NULL); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1f397b20b98..8163f5b4cf0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -17474,16 +17474,18 @@ const_expression_in_where(COND *cond, Item *comp_item, Field *comp_field, Create internal temporary table ****************************************************************************/ -Field *Item::create_tmp_field_int(TABLE *table, uint convert_int_length) +Field *Item::create_tmp_field_int(MEM_ROOT *root, TABLE *table, + uint convert_int_length) { const Type_handler *h= &type_handler_long; if (max_char_length() > convert_int_length) h= &type_handler_longlong; - return h->make_and_init_table_field(&name, Record_addr(maybe_null), + return h->make_and_init_table_field(root, &name, Record_addr(maybe_null), *this, table); } -Field *Item::tmp_table_field_from_field_type_maybe_null(TABLE *table, +Field *Item::tmp_table_field_from_field_type_maybe_null(MEM_ROOT *root, + TABLE *table, Tmp_field_src *src, const Tmp_field_param *param, bool is_explicit_null) @@ -17495,7 +17497,7 @@ Field *Item::tmp_table_field_from_field_type_maybe_null(TABLE *table, DBUG_ASSERT(!param->make_copy_field() || type() == CONST_ITEM); DBUG_ASSERT(!is_result_field()); Field *result; - if ((result= tmp_table_field_from_field_type(table))) + if ((result= tmp_table_field_from_field_type(root, table))) { if (result && is_explicit_null) result->is_created_from_null_item= true; @@ -17504,15 +17506,14 @@ Field *Item::tmp_table_field_from_field_type_maybe_null(TABLE *table, } -Field *Item_sum::create_tmp_field(bool group, TABLE *table) +Field *Item_sum::create_tmp_field(MEM_ROOT *root, bool group, TABLE *table) { Field *UNINIT_VAR(new_field); - MEM_ROOT *mem_root= table->in_use->mem_root; switch (cmp_type()) { case REAL_RESULT: { - new_field= new (mem_root) + new_field= new (root) Field_double(max_char_length(), maybe_null, &name, decimals, TRUE); break; } @@ -17520,7 +17521,7 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table) case TIME_RESULT: case DECIMAL_RESULT: case STRING_RESULT: - new_field= tmp_table_field_from_field_type(table); + new_field= tmp_table_field_from_field_type(root, table); break; case ROW_RESULT: // This case should never be choosen @@ -17539,7 +17540,7 @@ Field *Item_sum::create_tmp_field(bool group, TABLE *table) either direct or referenced by an Item_ref. */ Field * -Item_field::create_tmp_field_from_item_field(TABLE *new_table, +Item_field::create_tmp_field_from_item_field(MEM_ROOT *root, TABLE *new_table, Item_ref *orig_item, const Tmp_field_param *param) { @@ -17563,14 +17564,15 @@ Item_field::create_tmp_field_from_item_field(TABLE *new_table, Record_addr rec(orig_item ? orig_item->maybe_null : maybe_null); const Type_handler *handler= type_handler()-> type_handler_for_tmp_table(this); - result= handler->make_and_init_table_field(orig_item ? &orig_item->name : &name, + result= handler->make_and_init_table_field(root, + orig_item ? &orig_item->name : &name, rec, *this, new_table); } else if (param->table_cant_handle_bit_fields() && field->type() == MYSQL_TYPE_BIT) { const Type_handler *handler= type_handler_long_or_longlong(); - result= handler->make_and_init_table_field(&name, + result= handler->make_and_init_table_field(root, &name, Record_addr(maybe_null), *this, new_table); } @@ -17579,8 +17581,7 @@ Item_field::create_tmp_field_from_item_field(TABLE *new_table, LEX_CSTRING *tmp= orig_item ? &orig_item->name : &name; bool tmp_maybe_null= param->modify_item() ? maybe_null : field->maybe_null(); - result= field->create_tmp_field(new_table->in_use->mem_root, new_table, - tmp_maybe_null); + result= field->create_tmp_field(root, new_table, tmp_maybe_null); if (result) result->field_name= *tmp; } @@ -17590,14 +17591,14 @@ Item_field::create_tmp_field_from_item_field(TABLE *new_table, } -Field *Item_field::create_tmp_field_ex(TABLE *table, +Field *Item_field::create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) { DBUG_ASSERT(!is_result_field()); Field *result; src->set_field(field); - if (!(result= create_tmp_field_from_item_field(table, NULL, param))) + if (!(result= create_tmp_field_from_item_field(root, table, NULL, param))) return NULL; /* Fields that are used as arguments to the DEFAULT() function already have @@ -17610,7 +17611,7 @@ Field *Item_field::create_tmp_field_ex(TABLE *table, } -Field *Item_ref::create_tmp_field_ex(TABLE *table, +Field *Item_ref::create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) { @@ -17623,13 +17624,14 @@ Field *Item_ref::create_tmp_field_ex(TABLE *table, Tmp_field_param prm2(*param); prm2.set_modify_item(false); src->set_field(field->field); - if (!(result= field->create_tmp_field_from_item_field(table, this, &prm2))) + if (!(result= field->create_tmp_field_from_item_field(root, table, + this, &prm2))) return NULL; if (param->modify_item()) result_field= result; return result; } - return Item_result_field::create_tmp_field_ex(table, src, param); + return Item_result_field::create_tmp_field_ex(root, table, src, param); } @@ -17648,7 +17650,7 @@ void Item_result_field::get_tmp_field_src(Tmp_field_src *src, } -Field *Item_result_field::create_tmp_field_ex(TABLE *table, +Field *Item_result_field::create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) { @@ -17662,13 +17664,14 @@ Field *Item_result_field::create_tmp_field_ex(TABLE *table, DBUG_ASSERT(type() != NULL_ITEM); get_tmp_field_src(src, param); Field *result; - if ((result= tmp_table_field_from_field_type(table)) && param->modify_item()) + 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(TABLE *table, +Field *Item_func_user_var::create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) { @@ -17676,20 +17679,20 @@ Field *Item_func_user_var::create_tmp_field_ex(TABLE *table, DBUG_ASSERT(type() != NULL_ITEM); get_tmp_field_src(src, param); Field *result; - if ((result= create_table_field_from_handler(table)) && param->modify_item()) + if ((result= create_table_field_from_handler(root, table)) && + param->modify_item()) result_field= result; return result; } -Field *Item_func_sp::create_tmp_field_ex(TABLE *table, +Field *Item_func_sp::create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) { Field *result; get_tmp_field_src(src, param); - if ((result= sp_result_field->create_tmp_field(table->in_use->mem_root, - table))) + if ((result= sp_result_field->create_tmp_field(root, table))) { result->field_name= name; if (param->modify_item()) @@ -17735,7 +17738,8 @@ Field *create_tmp_field(TABLE *table, Item *item, Tmp_field_src src; Tmp_field_param prm(group, modify_item, table_cant_handle_bit_fields, make_copy_field); - Field *result= item->create_tmp_field_ex(table, &src, &prm); + Field *result= item->create_tmp_field_ex(table->in_use->mem_root, + table, &src, &prm); *from_field= src.field(); *default_field= src.default_field(); if (src.item_result_field()) @@ -18736,7 +18740,8 @@ bool Create_tmp_table::add_schema_fields(THD *thd, TABLE *table, bool visible= bitmap_is_set(&bitmap, fieldnr); Record_addr addr(def.nullable()); const Type_handler *h= def.type_handler(); - Field *field= h->make_schema_field(table, addr, def, visible); + Field *field= h->make_schema_field(&table->mem_root, table, + addr, def, visible); if (!field) { thd->mem_root= mem_root_save; diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 0268e36ca5b..5cecd9f50f7 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -2000,7 +2000,8 @@ Type_handler_int_result::make_num_distinct_aggregator_field(MEM_ROOT *mem_root, /***********************************************************************/ -Field *Type_handler_tiny::make_conversion_table_field(TABLE *table, +Field *Type_handler_tiny::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const @@ -2011,84 +2012,91 @@ Field *Type_handler_tiny::make_conversion_table_field(TABLE *table, using conversions so it should be true also when using conversions. */ bool unsigned_flag= ((Field_num*) target)->unsigned_flag; - return new (table->in_use->mem_root) + return new (root) Field_tiny(NULL, 4 /*max_length*/, (uchar *) "", 1, Field::NONE, &empty_clex_str, 0/*zerofill*/, unsigned_flag); } -Field *Type_handler_short::make_conversion_table_field(TABLE *table, +Field *Type_handler_short::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { bool unsigned_flag= ((Field_num*) target)->unsigned_flag; - return new (table->in_use->mem_root) + return new (root) Field_short(NULL, 6 /*max_length*/, (uchar *) "", 1, Field::NONE, &empty_clex_str, 0/*zerofill*/, unsigned_flag); } -Field *Type_handler_int24::make_conversion_table_field(TABLE *table, +Field *Type_handler_int24::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { bool unsigned_flag= ((Field_num*) target)->unsigned_flag; - return new (table->in_use->mem_root) + return new (root) Field_medium(NULL, 9 /*max_length*/, (uchar *) "", 1, Field::NONE, &empty_clex_str, 0/*zerofill*/, unsigned_flag); } -Field *Type_handler_long::make_conversion_table_field(TABLE *table, +Field *Type_handler_long::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { bool unsigned_flag= ((Field_num*) target)->unsigned_flag; - return new (table->in_use->mem_root) + return new (root) Field_long(NULL, 11 /*max_length*/, (uchar *) "", 1, Field::NONE, &empty_clex_str, 0/*zerofill*/, unsigned_flag); } -Field *Type_handler_longlong::make_conversion_table_field(TABLE *table, +Field *Type_handler_longlong::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { bool unsigned_flag= ((Field_num*) target)->unsigned_flag; - return new (table->in_use->mem_root) + return new (root) Field_longlong(NULL, 20 /*max_length*/,(uchar *) "", 1, Field::NONE, &empty_clex_str, 0/*zerofill*/, unsigned_flag); } -Field *Type_handler_float::make_conversion_table_field(TABLE *table, +Field *Type_handler_float::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new (table->in_use->mem_root) + return new (root) Field_float(NULL, 12 /*max_length*/, (uchar *) "", 1, Field::NONE, &empty_clex_str, 0/*dec*/, 0/*zerofill*/, 0/*unsigned_flag*/); } -Field *Type_handler_double::make_conversion_table_field(TABLE *table, +Field *Type_handler_double::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new (table->in_use->mem_root) + return new (root) Field_double(NULL, 22 /*max_length*/, (uchar *) "", 1, Field::NONE, &empty_clex_str, 0/*dec*/, 0/*zerofill*/, 0/*unsigned_flag*/); } -Field *Type_handler_newdecimal::make_conversion_table_field(TABLE *table, +Field *Type_handler_newdecimal::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const @@ -2097,13 +2105,14 @@ Field *Type_handler_newdecimal::make_conversion_table_field(TABLE *table, uint8 decimals= metadata & 0x00ff; uint32 max_length= my_decimal_precision_to_length(precision, decimals, false); DBUG_ASSERT(decimals <= DECIMAL_MAX_SCALE); - return new (table->in_use->mem_root) + return new (root) Field_new_decimal(NULL, max_length, (uchar *) "", 1, Field::NONE, &empty_clex_str, decimals, 0/*zerofill*/, 0/*unsigned*/); } -Field *Type_handler_olddecimal::make_conversion_table_field(TABLE *table, +Field *Type_handler_olddecimal::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const @@ -2120,152 +2129,168 @@ Field *Type_handler_olddecimal::make_conversion_table_field(TABLE *table, } -Field *Type_handler_year::make_conversion_table_field(TABLE *table, +Field *Type_handler_year::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new(table->in_use->mem_root) + return new(root) Field_year(NULL, 4, (uchar *) "", 1, Field::NONE, &empty_clex_str); } -Field *Type_handler_null::make_conversion_table_field(TABLE *table, +Field *Type_handler_null::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new(table->in_use->mem_root) + return new(root) Field_null(NULL, 0, Field::NONE, &empty_clex_str, target->charset()); } -Field *Type_handler_timestamp::make_conversion_table_field(TABLE *table, +Field *Type_handler_timestamp::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new_Field_timestamp(table->in_use->mem_root, NULL, (uchar *) "", 1, - Field::NONE, &empty_clex_str, table->s, target->decimals()); + return new_Field_timestamp(root, NULL, (uchar *) "", 1, + Field::NONE, &empty_clex_str, + table->s, target->decimals()); } -Field *Type_handler_timestamp2::make_conversion_table_field(TABLE *table, +Field *Type_handler_timestamp2::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new(table->in_use->mem_root) + return new(root) Field_timestampf(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, table->s, metadata); } -Field *Type_handler_newdate::make_conversion_table_field(TABLE *table, +Field *Type_handler_newdate::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new(table->in_use->mem_root) + return new(root) Field_newdate(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str); } -Field *Type_handler_date::make_conversion_table_field(TABLE *table, +Field *Type_handler_date::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new(table->in_use->mem_root) + return new(root) Field_date(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str); } -Field *Type_handler_time::make_conversion_table_field(TABLE *table, +Field *Type_handler_time::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new_Field_time(table->in_use->mem_root, NULL, (uchar *) "", 1, + return new_Field_time(root, NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, target->decimals()); } -Field *Type_handler_time2::make_conversion_table_field(TABLE *table, +Field *Type_handler_time2::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new(table->in_use->mem_root) + return new(root) Field_timef(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, metadata); } -Field *Type_handler_datetime::make_conversion_table_field(TABLE *table, +Field *Type_handler_datetime::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new_Field_datetime(table->in_use->mem_root, NULL, (uchar *) "", 1, + return new_Field_datetime(root, NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, target->decimals()); } -Field *Type_handler_datetime2::make_conversion_table_field(TABLE *table, +Field *Type_handler_datetime2::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new(table->in_use->mem_root) + return new(root) Field_datetimef(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, metadata); } -Field *Type_handler_bit::make_conversion_table_field(TABLE *table, +Field *Type_handler_bit::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { DBUG_ASSERT((metadata & 0xff) <= 7); uint32 max_length= 8 * (metadata >> 8U) + (metadata & 0x00ff); - return new(table->in_use->mem_root) + return new(root) Field_bit_as_char(NULL, max_length, (uchar *) "", 1, Field::NONE, &empty_clex_str); } -Field *Type_handler_string::make_conversion_table_field(TABLE *table, +Field *Type_handler_string::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { /* This is taken from Field_string::unpack. */ uint32 max_length= (((metadata >> 4) & 0x300) ^ 0x300) + (metadata & 0x00ff); - return new(table->in_use->mem_root) + return new(root) Field_string(NULL, max_length, (uchar *) "", 1, Field::NONE, &empty_clex_str, target->charset()); } -Field *Type_handler_varchar::make_conversion_table_field(TABLE *table, +Field *Type_handler_varchar::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new(table->in_use->mem_root) + return new(root) Field_varstring(NULL, metadata, HA_VARCHAR_PACKLENGTH(metadata), (uchar *) "", 1, Field::NONE, &empty_clex_str, table->s, target->charset()); } -Field *Type_handler_varchar_compressed::make_conversion_table_field(TABLE *table, +Field *Type_handler_varchar_compressed::make_conversion_table_field( + MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { - return new(table->in_use->mem_root) + return new(root) Field_varstring_compressed(NULL, metadata, HA_VARCHAR_PACKLENGTH(metadata), (uchar *) "", 1, Field::NONE, @@ -2276,7 +2301,9 @@ Field *Type_handler_varchar_compressed::make_conversion_table_field(TABLE *table -Field *Type_handler_blob_compressed::make_conversion_table_field(TABLE *table, +Field *Type_handler_blob_compressed::make_conversion_table_field( + MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const @@ -2284,7 +2311,7 @@ Field *Type_handler_blob_compressed::make_conversion_table_field(TABLE *table, uint pack_length= metadata & 0x00ff; if (pack_length < 1 || pack_length > 4) return NULL; // Broken binary log? - return new(table->in_use->mem_root) + return new(root) Field_blob_compressed(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, table->s, pack_length, target->charset(), @@ -2292,14 +2319,15 @@ Field *Type_handler_blob_compressed::make_conversion_table_field(TABLE *table, } -Field *Type_handler_enum::make_conversion_table_field(TABLE *table, +Field *Type_handler_enum::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { DBUG_ASSERT(target->type() == MYSQL_TYPE_STRING); DBUG_ASSERT(target->real_type() == MYSQL_TYPE_ENUM); - return new(table->in_use->mem_root) + return new(root) Field_enum(NULL, target->field_length, (uchar *) "", 1, Field::NONE, &empty_clex_str, metadata & 0x00ff/*pack_length()*/, @@ -2307,14 +2335,15 @@ Field *Type_handler_enum::make_conversion_table_field(TABLE *table, } -Field *Type_handler_set::make_conversion_table_field(TABLE *table, +Field *Type_handler_set::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { DBUG_ASSERT(target->type() == MYSQL_TYPE_STRING); DBUG_ASSERT(target->real_type() == MYSQL_TYPE_SET); - return new(table->in_use->mem_root) + return new(root) Field_set(NULL, target->field_length, (uchar *) "", 1, Field::NONE, &empty_clex_str, metadata & 0x00ff/*pack_length()*/, @@ -2322,7 +2351,7 @@ Field *Type_handler_set::make_conversion_table_field(TABLE *table, } -Field *Type_handler_enum::make_schema_field(TABLE *table, +Field *Type_handler_enum::make_schema_field(MEM_ROOT *root, TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const @@ -2334,7 +2363,7 @@ Field *Type_handler_enum::make_schema_field(TABLE *table, Assume I_S columns don't have non-ASCII characters in names. If we eventually want to, Typelib::max_char_length() must be implemented. */ - return new (table->in_use->mem_root) + return new (root) Field_enum(addr.ptr(), (uint32) typelib->max_octet_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, @@ -2995,49 +3024,53 @@ uint32 Type_handler_enum::calc_pack_length(uint32 length) const /*************************************************************************/ -Field *Type_handler::make_and_init_table_field(const LEX_CSTRING *name, +Field *Type_handler::make_and_init_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - Field *field= make_table_field(name, addr, attr, table); + Field *field= make_table_field(root, name, addr, attr, table); if (field) field->init(table); return field; } -Field *Type_handler_tiny::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_tiny::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_tiny(addr.ptr(), attr.max_char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, 0/*zerofill*/, attr.unsigned_flag); } -Field *Type_handler_short::make_table_field(const LEX_CSTRING *name, - const Record_addr &addr, - const Type_all_attributes &attr, - TABLE *table) const +Field *Type_handler_short::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, + const Record_addr &addr, + const Type_all_attributes &attr, + TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_short(addr.ptr(), attr.max_char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, 0/*zerofill*/, attr.unsigned_flag); } -Field *Type_handler_int24::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_int24::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_medium(addr.ptr(), attr.max_char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, @@ -3045,24 +3078,26 @@ Field *Type_handler_int24::make_table_field(const LEX_CSTRING *name, } -Field *Type_handler_long::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_long::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_long(addr.ptr(), attr.max_char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, 0/*zerofill*/, attr.unsigned_flag); } -Field *Type_handler_longlong::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_longlong::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_longlong(addr.ptr(), attr.max_char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, @@ -3070,12 +3105,13 @@ Field *Type_handler_longlong::make_table_field(const LEX_CSTRING *name, } -Field *Type_handler_vers_trx_id::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_vers_trx_id::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_vers_trx_id(addr.ptr(), attr.max_char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, @@ -3083,12 +3119,13 @@ Field *Type_handler_vers_trx_id::make_table_field(const LEX_CSTRING *name, } -Field *Type_handler_float::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_float::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_float(addr.ptr(), attr.max_char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, @@ -3096,12 +3133,13 @@ Field *Type_handler_float::make_table_field(const LEX_CSTRING *name, } -Field *Type_handler_double::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_double::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_double(addr.ptr(), attr.max_char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, @@ -3110,7 +3148,8 @@ Field *Type_handler_double::make_table_field(const LEX_CSTRING *name, Field * -Type_handler_olddecimal::make_table_field(const LEX_CSTRING *name, +Type_handler_olddecimal::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const @@ -3123,7 +3162,7 @@ Type_handler_olddecimal::make_table_field(const LEX_CSTRING *name, in make_field() in field.cc, to open old tables with old decimal. */ DBUG_ASSERT(0); - return new (table->in_use->mem_root) + return new (root) Field_decimal(addr.ptr(), attr.max_length, addr.null_ptr(), addr.null_bit(), Field::NONE, name, (uint8) attr.decimals, @@ -3132,7 +3171,8 @@ Type_handler_olddecimal::make_table_field(const LEX_CSTRING *name, Field * -Type_handler_newdecimal::make_table_field(const LEX_CSTRING *name, +Type_handler_newdecimal::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const @@ -3171,50 +3211,54 @@ Type_handler_newdecimal::make_table_field(const LEX_CSTRING *name, /* Corrected value fits. */ len= required_length; } - return new (table->in_use->mem_root) + return new (root) Field_new_decimal(addr.ptr(), len, addr.null_ptr(), addr.null_bit(), Field::NONE, name, dec, 0/*zerofill*/, attr.unsigned_flag); } -Field *Type_handler_year::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_year::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_year(addr.ptr(), attr.max_length, addr.null_ptr(), addr.null_bit(), Field::NONE, name); } -Field *Type_handler_null::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_null::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_null(addr.ptr(), attr.max_length, Field::NONE, name, attr.collation.collation); } -Field *Type_handler_timestamp::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_timestamp::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new_Field_timestamp(table->in_use->mem_root, + return new_Field_timestamp(root, addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, table->s, attr.decimals); } -Field *Type_handler_timestamp2::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_timestamp2::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const @@ -3224,25 +3268,27 @@ Field *Type_handler_timestamp2::make_table_field(const LEX_CSTRING *name, Will be changed to "new Field_timestampf" when we reuse make_table_field() for make_field() purposes in field.cc. */ - return new_Field_timestamp(table->in_use->mem_root, + return new_Field_timestamp(root, addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, table->s, attr.decimals); } -Field *Type_handler_newdate::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_newdate::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_newdate(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name); } -Field *Type_handler_date::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_date::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const @@ -3253,25 +3299,27 @@ Field *Type_handler_date::make_table_field(const LEX_CSTRING *name, for make_field() in field.cc */ DBUG_ASSERT(0); - return new (table->in_use->mem_root) + return new (root) Field_date(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name); } -Field *Type_handler_time::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_time::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new_Field_time(table->in_use->mem_root, + return new_Field_time(root, addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, attr.decimals); } -Field *Type_handler_time2::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_time2::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const @@ -3282,25 +3330,27 @@ Field *Type_handler_time2::make_table_field(const LEX_CSTRING *name, Will be changed to "new Field_timef" when we reuse make_table_field() for make_field() purposes in field.cc. */ - return new_Field_time(table->in_use->mem_root, + return new_Field_time(root, addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, attr.decimals); } -Field *Type_handler_datetime::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_datetime::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new_Field_datetime(table->in_use->mem_root, + return new_Field_datetime(root, addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, attr.decimals); } -Field *Type_handler_datetime2::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_datetime2::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const @@ -3309,45 +3359,48 @@ Field *Type_handler_datetime2::make_table_field(const LEX_CSTRING *name, Will be changed to "new Field_datetimef" when we reuse make_table_field() for make_field() purposes in field.cc. */ - return new_Field_datetime(table->in_use->mem_root, + return new_Field_datetime(root, addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, attr.decimals); } -Field *Type_handler_bit::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_bit::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_bit_as_char(addr.ptr(), attr.max_length, addr.null_ptr(), addr.null_bit(), Field::NONE, name); } -Field *Type_handler_string::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_string::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_string(addr.ptr(), attr.max_length, addr.null_ptr(), addr.null_bit(), Field::NONE, name, attr.collation); } -Field *Type_handler_varchar::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_varchar::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_varstring(addr.ptr(), attr.max_length, HA_VARCHAR_PACKLENGTH(attr.max_length), addr.null_ptr(), addr.null_bit(), @@ -3356,26 +3409,28 @@ Field *Type_handler_varchar::make_table_field(const LEX_CSTRING *name, } -Field *Type_handler_tiny_blob::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_tiny_blob::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_blob(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, table->s, 1, attr.collation); } -Field *Type_handler_blob::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_blob::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_blob(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, table->s, 2, attr.collation); @@ -3383,40 +3438,43 @@ Field *Type_handler_blob::make_table_field(const LEX_CSTRING *name, Field * -Type_handler_medium_blob::make_table_field(const LEX_CSTRING *name, +Type_handler_medium_blob::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_blob(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, table->s, 3, attr.collation); } -Field *Type_handler_long_blob::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_long_blob::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_blob(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, table->s, 4, attr.collation); } -Field *Type_handler_enum::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_enum::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { const TYPELIB *typelib= attr.get_typelib(); DBUG_ASSERT(typelib); - return new (table->in_use->mem_root) + return new (root) Field_enum(addr.ptr(), attr.max_length, addr.null_ptr(), addr.null_bit(), Field::NONE, name, @@ -3425,7 +3483,8 @@ Field *Type_handler_enum::make_table_field(const LEX_CSTRING *name, } -Field *Type_handler_set::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_set::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const @@ -3433,7 +3492,7 @@ Field *Type_handler_set::make_table_field(const LEX_CSTRING *name, { const TYPELIB *typelib= attr.get_typelib(); DBUG_ASSERT(typelib); - return new (table->in_use->mem_root) + return new (root) Field_set(addr.ptr(), attr.max_length, addr.null_ptr(), addr.null_bit(), Field::NONE, name, @@ -3444,13 +3503,13 @@ Field *Type_handler_set::make_table_field(const LEX_CSTRING *name, /*************************************************************************/ -Field *Type_handler_float::make_schema_field(TABLE *table, - const Record_addr &addr, - const ST_FIELD_INFO &def, - bool show_field) const +Field *Type_handler_float::make_schema_field(MEM_ROOT *root, TABLE *table, + const Record_addr &addr, + const ST_FIELD_INFO &def, + bool show_field) const { LEX_CSTRING name= def.name(); - return new (table->in_use->mem_root) + return new (root) Field_float(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, @@ -3459,13 +3518,13 @@ Field *Type_handler_float::make_schema_field(TABLE *table, } -Field *Type_handler_double::make_schema_field(TABLE *table, +Field *Type_handler_double::make_schema_field(MEM_ROOT *root, TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const { LEX_CSTRING name= def.name(); - return new (table->in_use->mem_root) + return new (root) Field_double(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, @@ -3474,7 +3533,8 @@ Field *Type_handler_double::make_schema_field(TABLE *table, } -Field *Type_handler_decimal_result::make_schema_field(TABLE *table, +Field *Type_handler_decimal_result::make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const @@ -3484,14 +3544,14 @@ Field *Type_handler_decimal_result::make_schema_field(TABLE *table, uint prec= def.decimal_precision(); DBUG_ASSERT(dec <= DECIMAL_MAX_SCALE); uint32 len= my_decimal_precision_to_length(prec, dec, def.unsigned_flag()); - return new (table->in_use->mem_root) + return new (root) Field_new_decimal(addr.ptr(), len, addr.null_ptr(), addr.null_bit(), Field::NONE, &name, (uint8) dec, 0/*zerofill*/, def.unsigned_flag()); } -Field *Type_handler_blob_common::make_schema_field(TABLE *table, +Field *Type_handler_blob_common::make_schema_field(MEM_ROOT *root, TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const @@ -3499,19 +3559,19 @@ Field *Type_handler_blob_common::make_schema_field(TABLE *table, LEX_CSTRING name= def.name(); if (show_field) { - return new (table->in_use->mem_root) + return new (root) Field_blob(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, table->s, length_bytes(), &my_charset_bin); } else - return new (table->in_use->mem_root) + return new (root) Field_null(addr.ptr(), 0, Field::NONE, &name, &my_charset_bin); } -Field *Type_handler_varchar::make_schema_field(TABLE *table, +Field *Type_handler_varchar::make_schema_field(MEM_ROOT *root, TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const @@ -3521,7 +3581,7 @@ Field *Type_handler_varchar::make_schema_field(TABLE *table, uint32 octet_length= (uint32) def.char_length() * 3; if (octet_length > MAX_FIELD_VARCHARLENGTH) { - Field *field= new (table->in_use->mem_root) + Field *field= new (root) Field_blob(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, table->s, 4, system_charset_info); if (field) @@ -3530,7 +3590,7 @@ Field *Type_handler_varchar::make_schema_field(TABLE *table, } else if (show_field) { - return new (table->in_use->mem_root) + return new (root) Field_varstring(addr.ptr(), octet_length, HA_VARCHAR_PACKLENGTH(octet_length), addr.null_ptr(), addr.null_bit(), @@ -3538,96 +3598,97 @@ Field *Type_handler_varchar::make_schema_field(TABLE *table, table->s, system_charset_info); } else - return new (table->in_use->mem_root) + return new (root) Field_null(addr.ptr(), 0, Field::NONE, &name, system_charset_info); } -Field *Type_handler_tiny::make_schema_field(TABLE *table, +Field *Type_handler_tiny::make_schema_field(MEM_ROOT *root, TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const { LEX_CSTRING name= def.name(); - return new (table->in_use->mem_root) + return new (root) Field_tiny(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, 0/*zerofill*/, def.unsigned_flag()); } -Field *Type_handler_short::make_schema_field(TABLE *table, +Field *Type_handler_short::make_schema_field(MEM_ROOT *root, TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const { LEX_CSTRING name= def.name(); - return new (table->in_use->mem_root) + return new (root) Field_short(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, 0/*zerofill*/, def.unsigned_flag()); } -Field *Type_handler_long::make_schema_field(TABLE *table, +Field *Type_handler_long::make_schema_field(MEM_ROOT *root, TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const { LEX_CSTRING name= def.name(); - return new (table->in_use->mem_root) + return new (root) Field_long(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, 0/*zerofill*/, def.unsigned_flag()); } -Field *Type_handler_longlong::make_schema_field(TABLE *table, +Field *Type_handler_longlong::make_schema_field(MEM_ROOT *root, TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const { LEX_CSTRING name= def.name(); - return new (table->in_use->mem_root) + return new (root) Field_longlong(addr.ptr(), def.char_length(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, 0/*zerofill*/, def.unsigned_flag()); } -Field *Type_handler_date_common::make_schema_field(TABLE *table, +Field *Type_handler_date_common::make_schema_field(MEM_ROOT *root, TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const { LEX_CSTRING name= def.name(); - return new (table->in_use->mem_root) + return new (root) Field_newdate(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name); } -Field *Type_handler_time_common::make_schema_field(TABLE *table, +Field *Type_handler_time_common::make_schema_field(MEM_ROOT *root, TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const { LEX_CSTRING name= def.name(); - return new_Field_time(table->in_use->mem_root, + return new_Field_time(root, addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, &name, def.fsp()); } -Field *Type_handler_datetime_common::make_schema_field(TABLE *table, +Field *Type_handler_datetime_common::make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const { LEX_CSTRING name= def.name(); - return new_Field_datetime(table->in_use->mem_root, - addr.ptr(), addr.null_ptr(), addr.null_bit(), - Field::NONE, &name, def.fsp()); + return new_Field_datetime(root, + addr.ptr(), addr.null_ptr(), addr.null_bit(), + Field::NONE, &name, def.fsp()); } @@ -7270,7 +7331,8 @@ void Type_handler_datetime_common::Item_param_set_param_func(Item_param *param, param->set_param_datetime(pos, len); } -Field *Type_handler_blob_common::make_conversion_table_field(TABLE *table, +Field *Type_handler_blob_common::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const @@ -7278,7 +7340,7 @@ Field *Type_handler_blob_common::make_conversion_table_field(TABLE *table, uint pack_length= metadata & 0x00ff; if (pack_length < 1 || pack_length > 4) return NULL; // Broken binary log? - return new(table->in_use->mem_root) + return new(root) Field_blob(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, table->s, pack_length, target->charset()); } diff --git a/sql/sql_type.h b/sql/sql_type.h index 0182913b618..8f2d4d0c49d 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -3472,7 +3472,8 @@ public: This information is not available in the binary log, so we assume that these fields are the same on the master and on the slave. */ - virtual Field *make_conversion_table_field(TABLE *TABLE, + virtual Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const= 0; virtual void show_binlog_type(const Conv_source &src, String *str) const; @@ -3566,15 +3567,18 @@ public: { return true; // Error } - virtual Field *make_table_field(const LEX_CSTRING *name, + virtual Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const= 0; - Field *make_and_init_table_field(const LEX_CSTRING *name, + Field *make_and_init_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; - virtual Field *make_schema_field(TABLE *table, + virtual Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const @@ -3943,7 +3947,8 @@ public: DBUG_ASSERT(0); return NULL; } - Field *make_conversion_table_field(TABLE *TABLE, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const { @@ -3980,7 +3985,8 @@ public: { return false; } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const @@ -4385,7 +4391,8 @@ public: } bool subquery_type_allows_materialization(const Item *inner, const Item *outer) const; - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -4971,18 +4978,21 @@ public: { return Item_send_tiny(item, protocol, buf); } - Field *make_conversion_table_field(TABLE *TABLE, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy_num(c, MYSQL_TYPE_TINY); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -5022,18 +5032,21 @@ public: uint32 max_display_length_for_field(const Conv_source &src) const { return 6; } uint32 calc_pack_length(uint32 length) const { return 2; } - Field *make_conversion_table_field(TABLE *TABLE, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy_num(c, MYSQL_TYPE_SHORT); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -5073,18 +5086,21 @@ public: { return Item_send_long(item, protocol, buf); } - Field *make_conversion_table_field(TABLE *TABLE, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy_num(c, MYSQL_TYPE_LONG); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -5137,7 +5153,8 @@ public: { return Item_send_longlong(item, protocol, buf); } - Field *make_conversion_table_field(TABLE *TABLE, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, @@ -5146,11 +5163,13 @@ public: { return Column_definition_prepare_stage2_legacy_num(c, MYSQL_TYPE_LONGLONG); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -5170,7 +5189,8 @@ class Type_handler_vers_trx_id: public Type_handler_longlong { public: virtual ~Type_handler_vers_trx_id() {} - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5201,14 +5221,16 @@ public: uint32 max_display_length_for_field(const Conv_source &src) const { return 9; } uint32 calc_pack_length(uint32 length) const { return 3; } - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *mem_root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy_num(c, MYSQL_TYPE_INT24); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5241,7 +5263,8 @@ public: { return Item_send_short(item, protocol, buf); } - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; void Column_definition_reuse_fix_attributes(THD *thd, @@ -5251,7 +5274,8 @@ public: handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy_num(c, MYSQL_TYPE_YEAR); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5296,7 +5320,8 @@ public: return print_item_value_csstr(thd, item, str); } void show_binlog_type(const Conv_source &src, String *str) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage1(THD *thd, @@ -5312,7 +5337,8 @@ public: bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5350,18 +5376,21 @@ public: return Item_send_float(item, protocol, buf); } Field *make_num_distinct_aggregator_field(MEM_ROOT *, const Item *) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy_real(c, MYSQL_TYPE_FLOAT); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -5404,18 +5433,21 @@ public: { return Item_send_double(item, protocol, buf); } - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy_real(c, MYSQL_TYPE_DOUBLE); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -5456,7 +5488,8 @@ public: { return MYSQL_TIMESTAMP_TIME; } - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -5536,13 +5569,15 @@ public: uint32 max_display_length_for_field(const Conv_source &src) const { return MIN_TIME_WIDTH; } uint32 calc_pack_length(uint32 length) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy(c, MYSQL_TYPE_TIME); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5564,13 +5599,15 @@ public: enum_field_types real_field_type() const { return MYSQL_TYPE_TIME2; } uint32 max_display_length_for_field(const Conv_source &src) const; uint32 calc_pack_length(uint32 length) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy(c, MYSQL_TYPE_TIME2); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5635,7 +5672,8 @@ public: { return true; } - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -5668,13 +5706,15 @@ class Type_handler_date: public Type_handler_date_common public: virtual ~Type_handler_date() {} uint32 calc_pack_length(uint32 length) const { return 4; } - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy(c, MYSQL_TYPE_DATE); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5694,13 +5734,15 @@ public: virtual ~Type_handler_newdate() {} enum_field_types real_field_type() const { return MYSQL_TYPE_NEWDATE; } uint32 calc_pack_length(uint32 length) const { return 3; } - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy(c, MYSQL_TYPE_NEWDATE); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5739,7 +5781,8 @@ public: { return true; } - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -5790,13 +5833,15 @@ public: uint32 max_display_length_for_field(const Conv_source &src) const { return MAX_DATETIME_WIDTH; } uint32 calc_pack_length(uint32 length) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy(c, MYSQL_TYPE_DATETIME); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5818,13 +5863,15 @@ public: enum_field_types real_field_type() const { return MYSQL_TYPE_DATETIME2; } uint32 max_display_length_for_field(const Conv_source &src) const; uint32 calc_pack_length(uint32 length) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy(c, MYSQL_TYPE_DATETIME2); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5928,13 +5975,15 @@ public: uint32 max_display_length_for_field(const Conv_source &src) const { return MAX_DATETIME_WIDTH; } uint32 calc_pack_length(uint32 length) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy_num(c, MYSQL_TYPE_TIMESTAMP); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5956,7 +6005,8 @@ public: enum_field_types real_field_type() const { return MYSQL_TYPE_TIMESTAMP2; } uint32 max_display_length_for_field(const Conv_source &src) const; uint32 calc_pack_length(uint32 length) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, @@ -5964,7 +6014,8 @@ public: { return Column_definition_prepare_stage2_legacy_num(c, MYSQL_TYPE_TIMESTAMP2); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -5990,14 +6041,16 @@ public: const Type_handler *type_handler_for_tmp_table(const Item *item) const; const Type_handler *type_handler_for_union(const Item *item) const; void show_binlog_type(const Conv_source &src, String *str) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy_num(c, MYSQL_TYPE_DECIMAL); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -6021,7 +6074,8 @@ public: uint32 max_display_length_for_field(const Conv_source &src) const; uint32 calc_pack_length(uint32 length) const; void show_binlog_type(const Conv_source &src, String *str) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage1(THD *thd, @@ -6037,7 +6091,8 @@ public: bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -6072,7 +6127,8 @@ public: bool binary_cmp) const; bool Item_save_in_value(THD *thd, Item *item, st_value *value) const; bool Item_send(Item *item, Protocol *protocol, st_value *buf) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage1(THD *thd, @@ -6089,7 +6145,8 @@ public: handler *file, ulonglong table_flags) const { return Column_definition_prepare_stage2_legacy(c, MYSQL_TYPE_NULL); } - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -6128,7 +6185,8 @@ public: return varstring_type_handler(item); } void show_binlog_type(const Conv_source &src, String *str) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, @@ -6136,7 +6194,8 @@ public: ulonglong table_flags) const; bool Key_part_spec_init_ft(Key_part_spec *part, const Column_definition &def) const; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -6208,7 +6267,8 @@ public: } bool is_param_long_data_type() const { return true; } void show_binlog_type(const Conv_source &src, String *str) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, @@ -6216,11 +6276,13 @@ public: ulonglong table_flags) const; bool Key_part_spec_init_ft(Key_part_spec *part, const Column_definition &def) const; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -6255,7 +6317,8 @@ public: } uint32 max_display_length_for_field(const Conv_source &src) const; void show_binlog_type(const Conv_source &src, String *str) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; enum_dynamic_column_type dyncol_type(const Type_all_attributes *attr) const { @@ -6270,7 +6333,8 @@ class Type_handler_blob_common: public Type_handler_longstr public: virtual ~Type_handler_blob_common() { } virtual uint length_bytes() const= 0; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const override; const Type_handler *type_handler_for_tmp_table(const Item *item) const override @@ -6318,7 +6382,8 @@ public: override; void Item_param_setup_conversion(THD *thd, Item_param *) const override; - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const override; @@ -6342,7 +6407,8 @@ public: enum_field_types field_type() const { return MYSQL_TYPE_TINY_BLOB; } uint32 max_display_length_for_field(const Conv_source &src) const; uint32 calc_pack_length(uint32 length) const; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -6360,7 +6426,8 @@ public: enum_field_types field_type() const { return MYSQL_TYPE_MEDIUM_BLOB; } uint32 max_display_length_for_field(const Conv_source &src) const; uint32 calc_pack_length(uint32 length) const; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -6380,7 +6447,8 @@ public: uint32 calc_pack_length(uint32 length) const; Item *create_typecast_item(THD *thd, Item *item, const Type_cast_attributes &attr) const; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -6398,7 +6466,8 @@ public: enum_field_types field_type() const { return MYSQL_TYPE_BLOB; } uint32 max_display_length_for_field(const Conv_source &src) const; uint32 calc_pack_length(uint32 length) const; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -6415,7 +6484,8 @@ public: } uint32 max_display_length_for_field(const Conv_source &src) const; void show_binlog_type(const Conv_source &src, String *str) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; enum_dynamic_column_type dyncol_type(const Type_all_attributes *attr) const { @@ -6469,13 +6539,15 @@ public: return MYSQL_TYPE_ENUM; } uint32 calc_pack_length(uint32 length) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; @@ -6486,7 +6558,8 @@ public: const Bit_addr &bit, const Column_definition_attributes *attr, uint32 flags) const; - Field *make_schema_field(TABLE *table, + Field *make_schema_field(MEM_ROOT *root, + TABLE *table, const Record_addr &addr, const ST_FIELD_INFO &def, bool show_field) const; @@ -6505,13 +6578,15 @@ public: return MYSQL_TYPE_SET; } uint32 calc_pack_length(uint32 length) const; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const; bool Column_definition_fix_attributes(Column_definition *c) const; bool Column_definition_prepare_stage2(Column_definition *c, handler *file, ulonglong table_flags) const; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const; diff --git a/sql/sql_type_geom.cc b/sql/sql_type_geom.cc index 4b8d8ab97be..9bd8e3935b8 100644 --- a/sql/sql_type_geom.cc +++ b/sql/sql_type_geom.cc @@ -205,7 +205,8 @@ const Type_handler *Type_handler_geometry::type_handler_for_comparison() const } -Field *Type_handler_geometry::make_conversion_table_field(TABLE *table, +Field *Type_handler_geometry::make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const @@ -218,7 +219,7 @@ Field *Type_handler_geometry::make_conversion_table_field(TABLE *table, The statistics was already incremented when "target" was created. */ const Field_geom *fg= static_cast<const Field_geom*>(target); - return new(table->in_use->mem_root) + return new (root) Field_geom(NULL, (uchar *) "", 1, Field::NONE, &empty_clex_str, table->s, 4, fg->type_handler_geom(), fg->srid); } @@ -440,12 +441,13 @@ uint32 Type_handler_geometry::calc_pack_length(uint32 length) const } -Field *Type_handler_geometry::make_table_field(const LEX_CSTRING *name, +Field *Type_handler_geometry::make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const { - return new (table->in_use->mem_root) + return new (root) Field_geom(addr.ptr(), addr.null_ptr(), addr.null_bit(), Field::NONE, name, table->s, 4, this, 0); } @@ -609,14 +611,14 @@ void Type_handler_geometry::Item_param_set_param_func(Item_param *param, Field *Type_handler_geometry:: - make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *mem_root, + make_table_field_from_def(TABLE_SHARE *share, MEM_ROOT *root, const LEX_CSTRING *name, const Record_addr &rec, const Bit_addr &bit, const Column_definition_attributes *attr, uint32 flags) const { status_var_increment(current_thd->status_var.feature_gis); - return new (mem_root) + return new (root) Field_geom(rec.ptr(), rec.null_ptr(), rec.null_bit(), attr->unireg_check, name, share, attr->pack_flag_to_pack_length(), this, attr->srid); diff --git a/sql/sql_type_geom.h b/sql/sql_type_geom.h index c27811cedf1..3955172e39b 100644 --- a/sql/sql_type_geom.h +++ b/sql/sql_type_geom.h @@ -73,7 +73,8 @@ public: Item_param *param, const Type_all_attributes *attr, const st_value *value) const override; - Field *make_conversion_table_field(TABLE *, uint metadata, + Field *make_conversion_table_field(MEM_ROOT *root, + TABLE *table, uint metadata, const Field *target) const override; uint Column_definition_gis_options_image(uchar *buff, const Column_definition &def) @@ -115,7 +116,8 @@ public: const handler *file) const override; bool Key_part_spec_init_spatial(Key_part_spec *part, const Column_definition &def) const override; - Field *make_table_field(const LEX_CSTRING *name, + Field *make_table_field(MEM_ROOT *root, + const LEX_CSTRING *name, const Record_addr &addr, const Type_all_attributes &attr, TABLE *table) const override; |