diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/item.cc | 33 | ||||
-rw-r--r-- | sql/item.h | 53 | ||||
-rw-r--r-- | sql/item_func.cc | 8 | ||||
-rw-r--r-- | sql/item_func.h | 6 | ||||
-rw-r--r-- | sql/item_row.h | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 14 | ||||
-rw-r--r-- | sql/item_strfunc.h | 2 | ||||
-rw-r--r-- | sql/procedure.h | 2 | ||||
-rw-r--r-- | sql/protocol.cc | 2 | ||||
-rw-r--r-- | sql/sp_head.cc | 2 | ||||
-rw-r--r-- | sql/sql_base.cc | 8 | ||||
-rw-r--r-- | sql/sql_cursor.cc | 2 | ||||
-rw-r--r-- | sql/sql_derived.cc | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 | ||||
-rw-r--r-- | sql/sql_profile.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 20 | ||||
-rw-r--r-- | sql/sql_view.cc | 20 | ||||
-rw-r--r-- | sql/sql_view.h | 3 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 14 | ||||
-rw-r--r-- | sql/thr_malloc.cc | 12 | ||||
-rw-r--r-- | sql/thr_malloc.h | 1 |
23 files changed, 104 insertions, 110 deletions
diff --git a/sql/field.cc b/sql/field.cc index 01786d932d6..29c9625e3bc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -10531,7 +10531,7 @@ Column_definition::Column_definition(THD *thd, Field *old_field, { StringBuffer<MAX_FIELD_WIDTH> tmp(charset); String *res= orig_field->val_str(&tmp, orig_field->ptr_in_record(dv)); - char *pos= (char*) sql_strmake(res->ptr(), res->length()); + char *pos= (char*) thd->strmake(res->ptr(), res->length()); def= new (thd->mem_root) Item_string(thd, pos, res->length(), charset); } } diff --git a/sql/item.cc b/sql/item.cc index 0f10ccbd88c..3cc50b2a0fa 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -970,7 +970,7 @@ bool Item::check_cols(uint c) } -void Item::set_name(const char *str, uint length, CHARSET_INFO *cs) +void Item::set_name(THD *thd, const char *str, uint length, CHARSET_INFO *cs) { if (!length) { @@ -1001,7 +1001,6 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs) if (str != str_start && !is_autogenerated_name) { char buff[SAFE_NAME_LEN]; - THD *thd= current_thd; strmake(buff, str_start, MY_MIN(sizeof(buff)-1, length + (int) (str-str_start))); @@ -1025,11 +1024,12 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs) name_length= res_length; } else - name= sql_strmake(str, (name_length= MY_MIN(length,MAX_ALIAS_NAME))); + name= thd->strmake(str, (name_length= MY_MIN(length,MAX_ALIAS_NAME))); } -void Item::set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs) +void Item::set_name_no_truncate(THD *thd, const char *str, uint length, + CHARSET_INFO *cs) { if (!my_charset_same(cs, system_charset_info)) { @@ -1040,7 +1040,7 @@ void Item::set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs) name_length= res_length; } else - name= sql_strmake(str, (name_length= length)); + name= thd->strmake(str, (name_length= length)); } @@ -1049,7 +1049,7 @@ void Item::set_name_for_rollback(THD *thd, const char *str, uint length, { char *old_name, *new_name; old_name= name; - set_name(str, length, cs); + set_name(thd, str, length, cs); new_name= name; if (old_name != new_name) { @@ -1703,7 +1703,8 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref) } if (is_autogenerated_name) { - set_name(item_name->ptr(), (uint) item_name->length(), system_charset_info); + set_name(thd, item_name->ptr(), (uint) item_name->length(), + system_charset_info); } collation.set(value_item->collation.collation, DERIVATION_IMPLICIT); max_length= value_item->max_length; @@ -2168,7 +2169,7 @@ bool Item_func_or_sum::agg_item_set_converter(const DTCollation &coll, } -void Item_ident_for_show::make_field(Send_field *tmp_field) +void Item_ident_for_show::make_field(THD *thd, Send_field *tmp_field) { tmp_field->table_name= tmp_field->org_table_name= table_name; tmp_field->db_name= db_name; @@ -3846,9 +3847,9 @@ Item_param::get_out_param_info() const @param field container for meta-data to be filled */ -void Item_param::make_field(Send_field *field) +void Item_param::make_field(THD *thd, Send_field *field) { - Item::make_field(field); + Item::make_field(thd, field); if (!m_out_param_info) return; @@ -5379,13 +5380,13 @@ void Item::init_make_field(Send_field *tmp_field, tmp_field->flags |= UNSIGNED_FLAG; } -void Item::make_field(Send_field *tmp_field) +void Item::make_field(THD *thd, Send_field *tmp_field) { init_make_field(tmp_field, field_type()); } -void Item_empty_string::make_field(Send_field *tmp_field) +void Item_empty_string::make_field(THD *thd, Send_field *tmp_field) { init_make_field(tmp_field, string_field_type()); } @@ -5705,7 +5706,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, /* ARGSUSED */ -void Item_field::make_field(Send_field *tmp_field) +void Item_field::make_field(THD *thd, Send_field *tmp_field) { field->make_field(tmp_field); DBUG_ASSERT(tmp_field->table_name != 0); @@ -7319,9 +7320,9 @@ void Item_ref::save_org_in_field(Field *field, fast_field_copier optimizer_data) } -void Item_ref::make_field(Send_field *field) +void Item_ref::make_field(THD *thd, Send_field *field) { - (*ref)->make_field(field); + (*ref)->make_field(thd, field); /* Non-zero in case of a view */ if (name) field->col_name= name; @@ -8507,7 +8508,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) else { uint length= result->length(); - char *tmp_str= sql_strmake(result->ptr(), length); + char *tmp_str= thd->strmake(result->ptr(), length); new_item= new (mem_root) Item_string(thd, name, tmp_str, length, result->charset()); } break; diff --git a/sql/item.h b/sql/item.h index e262ce9d12d..88cdca67a02 100644 --- a/sql/item.h +++ b/sql/item.h @@ -714,14 +714,15 @@ public: name=0; #endif } /*lint -e1509 */ - void set_name(const char *str, uint length, CHARSET_INFO *cs); - void set_name_no_truncate(const char *str, uint length, CHARSET_INFO *cs); + void set_name(THD *thd, const char *str, uint length, CHARSET_INFO *cs); + void set_name_no_truncate(THD *thd, const char *str, uint length, + CHARSET_INFO *cs); void set_name_for_rollback(THD *thd, const char *str, uint length, CHARSET_INFO *cs); void rename(char *new_name); void init_make_field(Send_field *tmp_field,enum enum_field_types type); virtual void cleanup(); - virtual void make_field(Send_field *field); + virtual void make_field(THD *thd, Send_field *field); virtual Field *make_string_field(TABLE *table); virtual bool fix_fields(THD *, Item **); /* @@ -1982,7 +1983,7 @@ public: bool is_null(); public: - inline void make_field(Send_field *field); + inline void make_field(THD *thd, Send_field *field); inline bool const_item() const; @@ -1994,15 +1995,15 @@ public: Item_sp_variable inline implementation. *****************************************************************************/ -inline void Item_sp_variable::make_field(Send_field *field) +inline void Item_sp_variable::make_field(THD *thd, Send_field *field) { Item *it= this_item(); if (name) - it->set_name(name, (uint) strlen(name), system_charset_info); + it->set_name(thd, name, (uint) strlen(name), system_charset_info); else - it->set_name(m_name.str, (uint) m_name.length, system_charset_info); - it->make_field(field); + it->set_name(thd, m_name.str, (uint) m_name.length, system_charset_info); + it->make_field(thd, field); } inline bool Item_sp_variable::const_item() const @@ -2325,7 +2326,7 @@ public: longlong val_int() { return field->val_int(); } String *val_str(String *str) { return field->val_str(str); } my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); } - void make_field(Send_field *tmp_field); + void make_field(THD *thd, Send_field *tmp_field); CHARSET_INFO *charset_for_protocol(void) const { return field->charset_for_protocol(); } }; @@ -2381,7 +2382,7 @@ public: void reset_field(Field *f); bool fix_fields(THD *, Item **); void fix_after_pullout(st_select_lex *new_parent, Item **ref); - void make_field(Send_field *tmp_field); + void make_field(THD *thd, Send_field *tmp_field); int save_in_field(Field *field,bool no_conversions); void save_org_in_field(Field *field, fast_field_copier optimizer_data); fast_field_copier setup_fast_field_copier(Field *field); @@ -2733,7 +2734,7 @@ private: public: virtual const Send_field *get_out_param_info() const; - virtual void make_field(Send_field *field); + virtual void make_field(THD *thd, Send_field *field); private: Send_field *m_out_param_info; @@ -2925,10 +2926,11 @@ protected: // it is constant => can be used without fix_fields (and frequently used) fixed= 1; } - void fix_and_set_name_from_value(Derivation dv, const Metadata metadata) + void fix_and_set_name_from_value(THD *thd, Derivation dv, + const Metadata metadata) { fix_from_value(dv, metadata); - set_name(str_value.ptr(), str_value.length(), str_value.charset()); + set_name(thd, str_value.ptr(), str_value.length(), str_value.charset()); } protected: /* Just create an item and do not fill string representation */ @@ -2937,7 +2939,7 @@ protected: { collation.set(cs, dv); max_length= 0; - set_name(NULL, 0, system_charset_info); + set_name(thd, NULL, 0, system_charset_info); decimals= NOT_FIXED_DEC; fixed= 1; } @@ -2946,7 +2948,7 @@ public: Item_basic_constant(thd) { collation.set(csi, DERIVATION_COERCIBLE); - set_name(NULL, 0, system_charset_info); + set_name(thd, NULL, 0, system_charset_info); decimals= NOT_FIXED_DEC; fixed= 1; str_value.copy(str_arg, length_arg, csi); @@ -2957,14 +2959,14 @@ public: Derivation dv, uint repertoire): Item_basic_constant(thd) { str_value.set_or_copy_aligned(str, length, cs); - fix_and_set_name_from_value(dv, Metadata(&str_value, repertoire)); + fix_and_set_name_from_value(thd, dv, Metadata(&str_value, repertoire)); } Item_string(THD *thd, const char *str, uint length, CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE): Item_basic_constant(thd) { str_value.set_or_copy_aligned(str, length, cs); - fix_and_set_name_from_value(dv, Metadata(&str_value)); + fix_and_set_name_from_value(thd, dv, Metadata(&str_value)); } Item_string(THD *thd, const String *str, CHARSET_INFO *tocs, uint *conv_errors, Derivation dv, uint repertoire): Item_basic_constant(thd) @@ -2972,7 +2974,7 @@ public: if (str_value.copy(str, tocs, conv_errors)) str_value.set("", 0, tocs); // EOM ? str_value.mark_as_const(); - fix_and_set_name_from_value(dv, Metadata(&str_value, repertoire)); + fix_and_set_name_from_value(thd, dv, Metadata(&str_value, repertoire)); } // Constructors with an externally provided item name Item_string(THD *thd, const char *name_par, const char *str, uint length, @@ -2981,7 +2983,7 @@ public: { str_value.set_or_copy_aligned(str, length, cs); fix_from_value(dv, Metadata(&str_value)); - set_name(name_par, 0, system_charset_info); + set_name(thd, name_par, 0, system_charset_info); } Item_string(THD *thd, const char *name_par, const char *str, uint length, CHARSET_INFO *cs, Derivation dv, uint repertoire): @@ -2989,7 +2991,7 @@ public: { str_value.set_or_copy_aligned(str, length, cs); fix_from_value(dv, Metadata(&str_value, repertoire)); - set_name(name_par, 0, system_charset_info); + set_name(thd, name_par, 0, system_charset_info); } void print_value(String *to) const { @@ -3218,7 +3220,7 @@ public: Item_partition_func_safe_string(thd, "", 0, cs ? cs : &my_charset_utf8_general_ci) { name=(char*) header; max_length= length * collation.collation->mbmaxlen; } - void make_field(Send_field *field); + void make_field(THD *thd, Send_field *field); }; @@ -3890,7 +3892,7 @@ public: bool val_bool_result(); bool is_null_result(); bool send(Protocol *prot, String *tmp); - void make_field(Send_field *field); + void make_field(THD *thd, Send_field *field); bool fix_fields(THD *, Item **); void fix_after_pullout(st_select_lex *new_parent, Item **ref); int save_in_field(Field *field, bool no_conversions); @@ -4155,7 +4157,8 @@ public: virtual void print(String *str, enum_query_type query_type); virtual const char *full_name() const { return orig_item->full_name(); } - virtual void make_field(Send_field *field) { orig_item->make_field(field); } + virtual void make_field(THD *thd, Send_field *field) + { orig_item->make_field(thd, field); } bool eq(const Item *item, bool binary_cmp) const { Item *it= ((Item *) item)->real_item(); @@ -4586,7 +4589,7 @@ public: enum_field_types field_type() const { return cached_field_type; } enum Item_result result_type () const { return cached_result_type; } - void make_field(Send_field *field) { item->make_field(field); } + void make_field(THD *thd, Send_field *field) { item->make_field(thd, field); } table_map used_tables() const { return (table_map) 1L; } bool const_item() const { return 0; } bool is_null() { return null_value; } @@ -5196,7 +5199,7 @@ public: bool setup(THD *thd, Item *item); void store(Item *item); void illegal_method_call(const char *); - void make_field(Send_field *) + void make_field(THD *thd, Send_field *) { illegal_method_call((const char*)"make_field"); }; diff --git a/sql/item_func.cc b/sql/item_func.cc index 235aec4a17e..e4f6eafffa2 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5345,7 +5345,7 @@ bool Item_func_set_user_var::send(Protocol *protocol, String *str_arg) return Item::send(protocol, str_arg); } -void Item_func_set_user_var::make_field(Send_field *tmp_field) +void Item_func_set_user_var::make_field(THD *thd, Send_field *tmp_field) { if (result_field) { @@ -5355,7 +5355,7 @@ void Item_func_set_user_var::make_field(Send_field *tmp_field) tmp_field->col_name=Item::name; // Use user supplied name } else - Item::make_field(tmp_field); + Item::make_field(thd, tmp_field); } @@ -5811,7 +5811,7 @@ Item_func_get_system_var(THD *thd, sys_var *var_arg, enum_var_type var_type_arg, orig_var_type(var_type_arg), component(*component_arg), cache_present(0) { /* set_name() will allocate the name */ - set_name(name_arg, (uint) name_len_arg, system_charset_info); + set_name(thd, name_arg, (uint) name_len_arg, system_charset_info); } @@ -6768,7 +6768,7 @@ error: void -Item_func_sp::make_field(Send_field *tmp_field) +Item_func_sp::make_field(THD *thd, Send_field *tmp_field) { DBUG_ENTER("Item_func_sp::make_field"); DBUG_ASSERT(sp_result_field); diff --git a/sql/item_func.h b/sql/item_func.h index 9cf42fd5a78..bb0c143d877 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1753,7 +1753,7 @@ public: bool update_hash(void *ptr, uint length, enum Item_result type, CHARSET_INFO *cs, bool unsigned_arg); bool send(Protocol *protocol, String *str_arg); - void make_field(Send_field *tmp_field); + void make_field(THD *thd, Send_field *tmp_field); bool check(bool use_result_field); void save_item_result(Item *item); bool update(); @@ -1839,7 +1839,7 @@ class Item_user_var_as_out_param :public Item user_var_entry *entry; public: Item_user_var_as_out_param(THD *thd, LEX_STRING a): Item(thd), name(a) - { set_name(a.str, 0, system_charset_info); } + { set_name(thd, a.str, 0, system_charset_info); } /* We should return something different from FIELD_ITEM here */ enum Type type() const { return STRING_ITEM;} double val_real(); @@ -2132,7 +2132,7 @@ public: Field *tmp_table_field(TABLE *t_arg); - void make_field(Send_field *tmp_field); + void make_field(THD *thd, Send_field *tmp_field); Item_result result_type() const; diff --git a/sql/item_row.h b/sql/item_row.h index cf55eddc19c..c9e94ed2efe 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -49,7 +49,7 @@ public: enum Type type() const { return ROW_ITEM; }; void illegal_method_call(const char *); bool is_null() { return null_value; } - void make_field(Send_field *) + void make_field(THD *thd, Send_field *) { illegal_method_call((const char*)"make_field"); }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 04ddbf2c0f9..203fc4a7481 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -4312,7 +4312,7 @@ void Item_func_dyncol_create::fix_length_and_dec() decimals= 0; } -bool Item_func_dyncol_create::prepare_arguments(bool force_names_arg) +bool Item_func_dyncol_create::prepare_arguments(THD *thd, bool force_names_arg) { char buff[STRING_BUFFER_USUAL_SIZE]; String *res, tmp(buff, sizeof(buff), &my_charset_bin); @@ -4432,7 +4432,7 @@ bool Item_func_dyncol_create::prepare_arguments(bool force_names_arg) if (my_charset_same(res->charset(), &my_charset_utf8_general_ci)) { keys_str[i].length= res->length(); - keys_str[i].str= sql_strmake(res->ptr(), res->length()); + keys_str[i].str= thd->strmake(res->ptr(), res->length()); } else { @@ -4487,7 +4487,7 @@ bool Item_func_dyncol_create::prepare_arguments(bool force_names_arg) case DYN_COL_STRING: res= args[valpos]->val_str(&tmp); if (res && - (vals[i].x.string.value.str= sql_strmake(res->ptr(), res->length()))) + (vals[i].x.string.value.str= thd->strmake(res->ptr(), res->length()))) { vals[i].x.string.value.length= res->length(); vals[i].x.string.charset= res->charset(); @@ -4519,7 +4519,7 @@ bool Item_func_dyncol_create::prepare_arguments(bool force_names_arg) case DYN_COL_DATETIME: case DYN_COL_DATE: args[valpos]->get_date(&vals[i].x.time_value, - sql_mode_for_dates(current_thd)); + sql_mode_for_dates(thd)); break; case DYN_COL_TIME: args[valpos]->get_time(&vals[i].x.time_value); @@ -4545,7 +4545,8 @@ String *Item_func_dyncol_create::val_str(String *str) enum enum_dyncol_func_result rc; DBUG_ASSERT((arg_count & 0x1) == 0); // even number of arguments - if (prepare_arguments(FALSE)) + /* FIXME: add thd argument to Item::val_str() */ + if (prepare_arguments(current_thd, FALSE)) { res= NULL; null_value= 1; @@ -4690,7 +4691,8 @@ String *Item_func_dyncol_add::val_str(String *str) col.length= res->length(); memcpy(col.str, res->ptr(), col.length); - if (prepare_arguments(mariadb_dyncol_has_names(&col))) + /* FIXME: add thd argument to Item::val_str() */ + if (prepare_arguments(current_thd, mariadb_dyncol_has_names(&col))) goto null; if ((rc= ((names || force_names) ? diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 1a9f855dec5..2f3fe0b9eca 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -1195,7 +1195,7 @@ protected: uint *keys_num; LEX_STRING *keys_str; bool names, force_names; - bool prepare_arguments(bool force_names); + bool prepare_arguments(THD *thd, bool force_names); void print_arguments(String *str, enum_query_type query_type); public: Item_func_dyncol_create(THD *thd, List<Item> &args, DYNCALL_CREATE_DEF *dfs); diff --git a/sql/procedure.h b/sql/procedure.h index a46e8cfc137..2326f375721 100644 --- a/sql/procedure.h +++ b/sql/procedure.h @@ -48,7 +48,7 @@ public: virtual void set(longlong nr)=0; virtual enum_field_types field_type() const=0; void set(const char *str) { set(str,(uint) strlen(str), default_charset()); } - void make_field(Send_field *tmp_field) + void make_field(THD *thd, Send_field *tmp_field) { init_make_field(tmp_field,field_type()); } diff --git a/sql/protocol.cc b/sql/protocol.cc index fa42915f5a9..9e528708823 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -754,7 +754,7 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags) char *pos; CHARSET_INFO *cs= system_charset_info; Send_field field; - item->make_field(&field); + item->make_field(thd, &field); /* Keep things compatible for old clients */ if (field.type == MYSQL_TYPE_VARCHAR) diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 81a9c1fbe5b..51a1f9c9539 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -2148,7 +2148,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) } Send_field *out_param_info= new (thd->mem_root) Send_field(); - nctx->get_item(i)->make_field(out_param_info); + nctx->get_item(i)->make_field(thd, out_param_info); out_param_info->db_name= m_db.str; out_param_info->table_name= m_name.str; out_param_info->org_table_name= m_name.str; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index e2339e1c537..5c3b7c236c0 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -6137,9 +6137,9 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list, } else { - item->set_name((*ref)->name, (*ref)->name_length, + item->set_name(thd, (*ref)->name, (*ref)->name_length, system_charset_info); - item->real_item()->set_name((*ref)->name, (*ref)->name_length, + item->real_item()->set_name(thd, (*ref)->name, (*ref)->name_length, system_charset_info); } } @@ -6233,9 +6233,9 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, */ if (*ref && !(*ref)->is_autogenerated_name) { - item->set_name((*ref)->name, (*ref)->name_length, + item->set_name(thd, (*ref)->name, (*ref)->name_length, system_charset_info); - item->real_item()->set_name((*ref)->name, (*ref)->name_length, + item->real_item()->set_name(thd, (*ref)->name, (*ref)->name_length, system_charset_info); } if (register_tree_change && arena) diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc index a8c5569ba4a..7ecce8a8da3 100644 --- a/sql/sql_cursor.cc +++ b/sql/sql_cursor.cc @@ -277,7 +277,7 @@ int Materialized_cursor::send_result_set_metadata( { Send_field send_field; Item_ident *ident= static_cast<Item_ident *>(item_dst); - item_org->make_field(&send_field); + item_org->make_field(thd, &send_field); ident->db_name= thd->strdup(send_field.db_name); ident->table_name= thd->strdup(send_field.table_name); diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 67e7b6115a3..baba4a876b3 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -671,7 +671,7 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived) if ((res= unit->prepare(thd, derived->derived_result, 0))) goto exit; lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_DERIVED; - if ((res= check_duplicate_names(unit->types, 0))) + if ((res= check_duplicate_names(thd, unit->types, 0))) goto exit; /* diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index bc26780b806..efec0c42b22 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7083,7 +7083,7 @@ void create_select_for_variable(const char *var_name) if ((var= get_system_var(thd, OPT_SESSION, tmp, null_lex_str))) { end= strxmov(buff, "@@session.", var_name, NullS); - var->set_name(buff, end-buff, system_charset_info); + var->set_name(thd, buff, end-buff, system_charset_info); add_item_to_list(thd, var); } DBUG_VOID_RETURN; diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index 48f7987daf5..a169823e25e 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -124,7 +124,7 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table) NullS, NullS, field_info->field_name); if (field) { - field->set_name(field_info->old_name, + field->set_name(thd, field_info->old_name, (uint) strlen(field_info->old_name), system_charset_info); if (add_item_to_list(thd, field)) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6f9aab01195..277a4297e6f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -22857,7 +22857,7 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, str.length(0); str.extra_allocation(1024); item->print(&str, QT_ORDINARY); - item_field->name= sql_strmake(str.ptr(),str.length()); + item_field->name= thd->strmake(str.ptr(),str.length()); } #endif } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index e3d34aa19e4..2211d9f58ae 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -7447,7 +7447,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) item->max_length+= 1; if (item->decimals > 0) item->max_length+= 1; - item->set_name(fields_info->field_name, + item->set_name(thd, fields_info->field_name, strlen(fields_info->field_name), cs); break; case MYSQL_TYPE_TINY_BLOB: @@ -7470,7 +7470,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) { DBUG_RETURN(0); } - item->set_name(fields_info->field_name, + item->set_name(thd, fields_info->field_name, strlen(fields_info->field_name), cs); break; } @@ -7529,7 +7529,7 @@ static int make_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) Item_field(thd, context, NullS, NullS, field_info->field_name); if (field) { - field->set_name(field_info->old_name, + field->set_name(thd, field_info->old_name, strlen(field_info->old_name), system_charset_info); if (add_item_to_list(thd, field)) @@ -7564,7 +7564,7 @@ int make_schemata_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) buffer.append(lex->wild->ptr()); buffer.append(')'); } - field->set_name(buffer.ptr(), buffer.length(), system_charset_info); + field->set_name(thd, buffer.ptr(), buffer.length(), system_charset_info); } return 0; } @@ -7591,15 +7591,15 @@ int make_table_names_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) NullS, NullS, field_info->field_name); if (add_item_to_list(thd, field)) return 1; - field->set_name(buffer.ptr(), buffer.length(), system_charset_info); + field->set_name(thd, buffer.ptr(), buffer.length(), system_charset_info); if (thd->lex->verbose) { - field->set_name(buffer.ptr(), buffer.length(), system_charset_info); + field->set_name(thd, buffer.ptr(), buffer.length(), system_charset_info); field_info= &schema_table->fields_info[3]; field= new (thd->mem_root) Item_field(thd, context, NullS, NullS, field_info->field_name); if (add_item_to_list(thd, field)) return 1; - field->set_name(field_info->old_name, strlen(field_info->old_name), + field->set_name(thd, field_info->old_name, strlen(field_info->old_name), system_charset_info); } return 0; @@ -7624,7 +7624,7 @@ int make_columns_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) NullS, NullS, field_info->field_name); if (field) { - field->set_name(field_info->old_name, + field->set_name(thd, field_info->old_name, strlen(field_info->old_name), system_charset_info); if (add_item_to_list(thd, field)) @@ -7649,7 +7649,7 @@ int make_character_sets_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) NullS, NullS, field_info->field_name); if (field) { - field->set_name(field_info->old_name, + field->set_name(thd, field_info->old_name, strlen(field_info->old_name), system_charset_info); if (add_item_to_list(thd, field)) @@ -7674,7 +7674,7 @@ int make_proc_old_format(THD *thd, ST_SCHEMA_TABLE *schema_table) NullS, NullS, field_info->field_name); if (field) { - field->set_name(field_info->old_name, + field->set_name(thd, field_info->old_name, strlen(field_info->old_name), system_charset_info); if (add_item_to_list(thd, field)) diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 85189fa481f..62e6790a142 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -58,7 +58,7 @@ static int mysql_register_view(THD *, TABLE_LIST *, enum_view_create_mode); NAME_LEN, it is truncated. */ -static void make_unique_view_field_name(Item *target, +static void make_unique_view_field_name(THD *thd, Item *target, List<Item> &item_list, Item *last_element) { @@ -96,7 +96,7 @@ static void make_unique_view_field_name(Item *target, } target->orig_name= target->name; - target->set_name(buff, name_len, system_charset_info); + target->set_name(thd, buff, name_len, system_charset_info); } @@ -123,7 +123,7 @@ static void make_unique_view_field_name(Item *target, isn't allowed */ -bool check_duplicate_names(List<Item> &item_list, bool gen_unique_view_name) +bool check_duplicate_names(THD *thd, List<Item> &item_list, bool gen_unique_view_name) { Item *item; List_iterator_fast<Item> it(item_list); @@ -144,9 +144,9 @@ bool check_duplicate_names(List<Item> &item_list, bool gen_unique_view_name) if (!gen_unique_view_name) goto err; if (item->is_autogenerated_name) - make_unique_view_field_name(item, item_list, item); + make_unique_view_field_name(thd, item, item_list, item); else if (check->is_autogenerated_name) - make_unique_view_field_name(check, item_list, item); + make_unique_view_field_name(thd, check, item_list, item); else goto err; } @@ -167,7 +167,7 @@ err: @param item_list List of Items which should be checked */ -static void make_valid_column_names(List<Item> &item_list) +static void make_valid_column_names(THD *thd, List<Item> &item_list) { Item *item; uint name_len; @@ -181,7 +181,7 @@ static void make_valid_column_names(List<Item> &item_list) continue; name_len= my_snprintf(buff, NAME_LEN, "Name_exp_%u", column_no); item->orig_name= item->name; - item->set_name(buff, name_len, system_charset_info); + item->set_name(thd, buff, name_len, system_charset_info); } DBUG_VOID_RETURN; @@ -539,16 +539,16 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, } while ((item= it++, name= nm++)) { - item->set_name(name->str, (uint) name->length, system_charset_info); + item->set_name(thd, name->str, (uint) name->length, system_charset_info); item->is_autogenerated_name= FALSE; } } /* Check if the auto generated column names are conforming. */ for (sl= select_lex; sl; sl= sl->next_select()) - make_valid_column_names(sl->item_list); + make_valid_column_names(thd, sl->item_list); - if (check_duplicate_names(select_lex->item_list, 1)) + if (check_duplicate_names(thd, select_lex->item_list, 1)) { res= TRUE; goto err; diff --git a/sql/sql_view.h b/sql/sql_view.h index ce83dc656ad..9c75643fd48 100644 --- a/sql/sql_view.h +++ b/sql/sql_view.h @@ -51,7 +51,8 @@ int view_repair(THD *thd, TABLE_LIST *view, HA_CHECK_OPT *check_opt); extern TYPELIB updatable_views_with_limit_typelib; -bool check_duplicate_names(List<Item>& item_list, bool gen_unique_view_names); +bool check_duplicate_names(THD *thd, List<Item>& item_list, + bool gen_unique_view_names); bool mysql_rename_view(THD *thd, const char *new_db, const char *new_name, TABLE_LIST *view); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 4db7d4d8d59..19bde4fceae 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -8659,11 +8659,11 @@ select_item: MYSQL_YYABORT; } $2->is_autogenerated_name= FALSE; - $2->set_name($4.str, $4.length, system_charset_info); + $2->set_name(thd, $4.str, $4.length, system_charset_info); } else if (!$2->name) { - $2->set_name($1, (uint) ($3 - $1), thd->charset()); + $2->set_name(thd, $1, (uint) ($3 - $1), thd->charset()); } } ; @@ -9917,7 +9917,7 @@ function_call_conflict: if (!(i1= get_system_var(thd, OPT_SESSION, name, null_lex_str))) MYSQL_YYABORT; - i1->set_name((const char *) + i1->set_name(thd, (const char *) STRING_WITH_LEN("@@default_week_format"), system_charset_info); $$= new (thd->mem_root) Item_func_week(thd, $3, i1); @@ -10204,7 +10204,7 @@ udf_expr: if ($4.str) { $2->is_autogenerated_name= FALSE; - $2->set_name($4.str, $4.length, system_charset_info); + $2->set_name(thd, $4.str, $4.length, system_charset_info); } /* A field has to have its proper name in order for name @@ -10214,7 +10214,7 @@ udf_expr: */ else if ($2->type() != Item::FIELD_ITEM && $2->type() != Item::REF_ITEM /* For HAVING */ ) - $2->set_name($1, (uint) ($3 - $1), thd->charset()); + $2->set_name(thd, $1, (uint) ($3 - $1), thd->charset()); $$= $2; } ; @@ -11643,7 +11643,7 @@ procedure_item: if (add_proc_to_list(thd, $2)) MYSQL_YYABORT; if (!$2->name) - $2->set_name($1, (uint) ($3 - $1), thd->charset()); + $2->set_name(thd, $1, (uint) ($3 - $1), thd->charset()); } ; @@ -13369,7 +13369,7 @@ load_data_set_elem: if (lex->update_list.push_back($1, thd->mem_root) || lex->value_list.push_back($4, thd->mem_root)) MYSQL_YYABORT; - $4->set_name_no_truncate($3, (uint) ($5 - $3), thd->charset()); + $4->set_name_no_truncate(thd, $3, (uint) ($5 - $3), thd->charset()); } ; diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc index f43acd23abc..10fc5b83a1b 100644 --- a/sql/thr_malloc.cc +++ b/sql/thr_malloc.cc @@ -84,18 +84,6 @@ void *sql_calloc(size_t size) } -char *sql_strmake(const char *str, size_t len) -{ - char *pos; - if ((pos= (char*) sql_alloc(len+1))) - { - memcpy(pos,str,len); - pos[len]=0; - } - return pos; -} - - char *sql_strmake_with_convert(const char *str, size_t arg_length, CHARSET_INFO *from_cs, size_t max_res_length, diff --git a/sql/thr_malloc.h b/sql/thr_malloc.h index 97ab7638afd..4eb1e66d970 100644 --- a/sql/thr_malloc.h +++ b/sql/thr_malloc.h @@ -24,7 +24,6 @@ void init_sql_alloc(MEM_ROOT *root, uint block_size, uint pre_alloc_size, myf my_flags); void *sql_alloc(size_t); void *sql_calloc(size_t); -char *sql_strmake(const char *str, size_t len); char *sql_strmake_with_convert(const char *str, size_t arg_length, CHARSET_INFO *from_cs, size_t max_res_length, |