Skip to content
Permalink
Browse files

MDEV-8717 - Obsolete sql_strdup() in favor of THD::strdup() and thd_s…

…trdup()
  • Loading branch information
svoj committed Nov 18, 2015
1 parent 13af865 commit 464394bf478a7f3b397ec7045627f827a34c1f09
Showing with 6 additions and 16 deletions.
  1. +5 −4 sql/sql_table.cc
  2. +0 −10 sql/thr_malloc.cc
  3. +0 −1 sql/thr_malloc.h
  4. +1 −1 storage/archive/ha_archive.cc
@@ -63,7 +63,8 @@
const char *primary_key_name="PRIMARY";

static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end);
static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end);
static char *make_unique_key_name(THD *thd, const char *field_name, KEY *start,
KEY *end);
static int copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
List<Create_field> &create, bool ignore,
uint order_num, ORDER *order,
@@ -4026,7 +4027,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
primary_key=1;
}
else if (!(key_name= key->name.str))
key_name=make_unique_key_name(sql_field->field_name,
key_name=make_unique_key_name(thd, sql_field->field_name,
*key_info_buffer, key_info);
if (check_if_keyname_exists(key_name, *key_info_buffer, key_info))
{
@@ -5068,7 +5069,7 @@ check_if_keyname_exists(const char *name, KEY *start, KEY *end)


static char *
make_unique_key_name(const char *field_name,KEY *start,KEY *end)
make_unique_key_name(THD *thd, const char *field_name,KEY *start,KEY *end)
{
char buff[MAX_FIELD_NAME],*buff_end;

@@ -5086,7 +5087,7 @@ make_unique_key_name(const char *field_name,KEY *start,KEY *end)
*buff_end= '_';
int10_to_str(i, buff_end+1, 10);
if (!check_if_keyname_exists(buff,start,end))
return sql_strdup(buff);
return thd->strdup(buff);
}
return (char*) "not_specified"; // Should never happen
}
@@ -84,16 +84,6 @@ void *sql_calloc(size_t size)
}


char *sql_strdup(const char *str)
{
size_t len= strlen(str)+1;
char *pos;
if ((pos= (char*) sql_alloc(len)))
memcpy(pos,str,len);
return pos;
}


char *sql_strmake(const char *str, size_t len)
{
char *pos;
@@ -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_strdup(const char *str);
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,
@@ -1645,7 +1645,7 @@ void ha_archive::update_create_info(HA_CREATE_INFO *create_info)
}

if (!(my_readlink(tmp_real_path, share->data_file_name, MYF(0))))
create_info->data_file_name= sql_strdup(tmp_real_path);
create_info->data_file_name= thd_strdup(ha_thd(), tmp_real_path);

DBUG_VOID_RETURN;
}

0 comments on commit 464394b

Please sign in to comment.
You can’t perform that action at this time.