[Commits] 2a592b7: MDEV-8718 - Obsolete sql_strmake() in favor of THD::strmake() and thd_strmake()

Sergey Vojtovich svoj at mariadb.org
Wed Nov 18 20:56:00 EET 2015


revision-id: 2a592b70a50baa0adf76502d7fffe9c3873ee762 (mariadb-10.1.8-53-g2a592b7)
parent(s): 7374363a9a93737685c3147bd933496063c68c75
committer: Sergey Vojtovich
timestamp: 2015-11-18 22:55:17 +0400
message:

MDEV-8718 - Obsolete sql_strmake() in favor of THD::strmake() and thd_strmake()

---
 libmysqld/lib_sql.cc |  2 +-
 sql/field.cc         |  2 +-
 sql/item.cc          | 33 ++++++++++++++++----------------
 sql/item.h           | 53 +++++++++++++++++++++++++++-------------------------
 sql/item_func.cc     |  8 ++++----
 sql/item_func.h      |  6 +++---
 sql/item_row.h       |  2 +-
 sql/item_strfunc.cc  | 14 ++++++++------
 sql/item_strfunc.h   |  2 +-
 sql/procedure.h      |  2 +-
 sql/protocol.cc      |  2 +-
 sql/sp_head.cc       |  2 +-
 sql/sql_base.cc      |  8 ++++----
 sql/sql_cursor.cc    |  2 +-
 sql/sql_derived.cc   |  2 +-
 sql/sql_parse.cc     |  2 +-
 sql/sql_profile.cc   |  2 +-
 sql/sql_select.cc    |  2 +-
 sql/sql_show.cc      | 20 ++++++++++----------
 sql/sql_view.cc      | 20 ++++++++++----------
 sql/sql_view.h       |  3 ++-
 sql/sql_yacc.yy      | 14 +++++++-------
 sql/thr_malloc.cc    | 12 ------------
 sql/thr_malloc.h     |  1 -
 24 files changed, 105 insertions(+), 111 deletions(-)

diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 86a0676..5035064 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -1029,7 +1029,7 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
   while ((item= it++))
   {
     Send_field server_field;
-    item->make_field(&server_field);
+    item->make_field(thd, &server_field);
 
     /* Keep things compatible for old clients */
     if (server_field.type == MYSQL_TYPE_VARCHAR)
diff --git a/sql/field.cc b/sql/field.cc
index 585abad..1bd74f3 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -10549,7 +10549,7 @@ Create_field::Create_field(THD *thd, Field *old_field, Field *orig_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 a1a9100..346dc1a 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -971,7 +971,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)
   {
@@ -1002,7 +1002,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)));
@@ -1026,11 +1025,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))
   {
@@ -1041,7 +1041,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));
 }
 
 
@@ -1050,7 +1050,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)
   {
@@ -1704,7 +1704,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;
@@ -2169,7 +2170,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;
@@ -3847,9 +3848,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;
@@ -5364,13 +5365,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());
 }
@@ -5690,7 +5691,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);
@@ -7303,9 +7304,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;
@@ -8491,7 +8492,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 e662eed..817d849 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -715,14 +715,15 @@ class Item: public Value_source,
     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 **);
   /*
@@ -1983,7 +1984,7 @@ class Item_sp_variable :public Item
   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;
   
@@ -1995,15 +1996,15 @@ class Item_sp_variable :public Item
   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
@@ -2326,7 +2327,7 @@ class Item_ident_for_show :public Item
   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(); }
 };
@@ -2382,7 +2383,7 @@ class Item_field :public Item_ident
   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);
@@ -2734,7 +2735,7 @@ class Item_param :public Item_basic_value,
 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;
@@ -2926,10 +2927,11 @@ class Item_string :public Item_basic_constant
     // 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 */
@@ -2938,7 +2940,7 @@ class Item_string :public Item_basic_constant
   {
     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;
   }
@@ -2947,7 +2949,7 @@ class Item_string :public Item_basic_constant
     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);
@@ -2958,14 +2960,14 @@ class Item_string :public Item_basic_constant
               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)
@@ -2973,7 +2975,7 @@ class Item_string :public Item_basic_constant
     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,
@@ -2982,7 +2984,7 @@ class Item_string :public Item_basic_constant
   {
     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):
@@ -2990,7 +2992,7 @@ class Item_string :public Item_basic_constant
   {
     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
   {
@@ -3219,7 +3221,7 @@ class Item_empty_string :public Item_partition_func_safe_string
     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);
 };
 
 
@@ -3891,7 +3893,7 @@ class Item_ref :public Item_ident
   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);
@@ -4156,7 +4158,8 @@ class Item_cache_wrapper :public Item_result_field
 
   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();
@@ -4585,7 +4588,7 @@ class Item_copy :public Item
   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; }
@@ -5195,7 +5198,7 @@ class Item_cache_row: public Item_cache
   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 235aec4..e4f6eaf 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 @@ Item_func_sp::execute_impl(THD *thd)
 
 
 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 6230550..c784459 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1753,7 +1753,7 @@ class Item_func_set_user_var :public Item_func_user_var
   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();
@@ -2105,7 +2105,7 @@ class Item_func_sp :public Item_func
 
   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 cf55edd..c9e94ed 100644
--- a/sql/item_row.h
+++ b/sql/item_row.h
@@ -49,7 +49,7 @@ class Item_row: public Item,
   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 04ddbf2..203fc4a 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 1a9f855..2f3fe0b 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -1195,7 +1195,7 @@ class Item_func_dyncol_create: public Item_str_func
   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 a46e8cf..2326f37 100644
--- a/sql/procedure.h
+++ b/sql/procedure.h
@@ -48,7 +48,7 @@ class Item_proc :public Item
   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 249dd73..1b2ba74 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -755,7 +755,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 a117963..375a77d 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -2149,7 +2149,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 1189a26..6c3c356 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 a8c5569..7ecce8a 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 67e7b61..baba4a8 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 d6e5082..9dca938 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -7047,7 +7047,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 bc11f5f..7b5cd69 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -125,7 +125,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 3ab81aa..617b88a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -22975,7 +22975,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 10d8ed2..edde3cb 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 b240958..1115449a 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 @@ bool check_duplicate_names(List<Item> &item_list, bool gen_unique_view_name)
   @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 ce83dc6..9c75643 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 5cc905e..9d67642 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -8684,11 +8684,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());
             }
           }
         ;
@@ -9990,7 +9990,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);
@@ -10277,7 +10277,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
@@ -10287,7 +10287,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;
           }
         ;
@@ -11715,7 +11715,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());
           }
         ;
 
@@ -13441,7 +13441,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 f43acd2..10fc5b8 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 97ab763..4eb1e66 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,


More information about the commits mailing list