Commit 04ed0446 authored by unknown's avatar unknown

Making old tables seen with "#mysql50#" prefix,

  which makes it possible to run RENAME TABLE
  on old tables when upgrading from 5.0.
  TODO: A stored procedure to rename all tables and
  databases with old name format into new format,
  it will simplify upgrade.
sql_table.cc:
  Making old tables seen with "#mysql50#" prefix.
  Adding warning into .err log when an old name is found.
sql_show.cc:
  Skip non-directories before filename_to_tablename
  call, to avoid unnecessary warnings.
strfunc.cc:
  Adding "error" argument to strconvert()
mysql_priv.h:
  Adding "error" agrument to strconvert()


sql/mysql_priv.h:
  Adding "error" agrument to strconvert()
sql/strfunc.cc:
  Adding "error" argument to strconvert()
sql/sql_show.cc:
  Skip non-directories before filename_to_tablename
  call, to avoid warning.
sql/sql_table.cc:
  Making old tables seen with "#mysql50#" prefix,
  which makes it possible to run RENAME TABLE
  on old tables.
  Adding warning into .err log when an old name is found.
parent 91f2109a
...@@ -1504,20 +1504,11 @@ char *fn_rext(char *name); ...@@ -1504,20 +1504,11 @@ char *fn_rext(char *name);
/* Conversion functions */ /* Conversion functions */
uint strconvert(CHARSET_INFO *from_cs, const char *from, uint strconvert(CHARSET_INFO *from_cs, const char *from,
CHARSET_INFO *to_cs, char *to, uint to_length); CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors);
uint filename_to_tablename(const char *from, char *to, uint to_length);
uint tablename_to_filename(const char *from, char *to, uint to_length);
uint build_table_filename(char *buff, size_t bufflen, const char *db, uint build_table_filename(char *buff, size_t bufflen, const char *db,
const char *table, const char *ext); const char *table, const char *ext);
inline uint filename_to_tablename(const char *from, char *to, uint to_length)
{
return strconvert(&my_charset_filename, from,
system_charset_info, to, to_length);
}
inline uint tablename_to_filename(const char *from, char *to, uint to_length)
{
return strconvert(system_charset_info, from,
&my_charset_filename, to, to_length);
}
/* from hostname.cc */ /* from hostname.cc */
struct in_addr; struct in_addr;
my_string ip_to_hostname(struct in_addr *in,uint *errors); my_string ip_to_hostname(struct in_addr *in,uint *errors);
......
...@@ -437,9 +437,10 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path, ...@@ -437,9 +437,10 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
continue; continue;
} }
#endif #endif
if (!MY_S_ISDIR(file->mystat->st_mode))
continue;
VOID(filename_to_tablename(file->name, uname, sizeof(uname))); VOID(filename_to_tablename(file->name, uname, sizeof(uname)));
if (!MY_S_ISDIR(file->mystat->st_mode) || if (wild && wild_compare(uname, wild, 0))
(wild && wild_compare(uname, wild, 0)))
continue; continue;
file->name= uname; file->name= uname;
} }
......
...@@ -102,6 +102,38 @@ static bool abort_and_upgrade_lock(THD *thd, TABLE *table, const char *db, ...@@ -102,6 +102,38 @@ static bool abort_and_upgrade_lock(THD *thd, TABLE *table, const char *db,
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
#define MYSQL50_TABLE_NAME_PREFIX "#mysql50#"
#define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9
uint filename_to_tablename(const char *from, char *to, uint to_length)
{
uint errors, res= strconvert(&my_charset_filename, from,
system_charset_info, to, to_length, &errors);
if (errors) // Old 5.0 name
{
res= strxnmov(to, to_length, MYSQL50_TABLE_NAME_PREFIX, from, NullS) - to;
sql_print_error("Invalid (old?) table or database name '%s'", from);
/*
TODO: add a stored procedure for fix table and database names,
and mention its name in error log.
*/
}
return res;
}
uint tablename_to_filename(const char *from, char *to, uint to_length)
{
uint errors;
if (from[0] && !strncmp(from, MYSQL50_TABLE_NAME_PREFIX,
MYSQL50_TABLE_NAME_PREFIX_LENGTH))
return my_snprintf(to, to_length, "%s", from + 9);
return strconvert(system_charset_info, from,
&my_charset_filename, to, to_length, &errors);
}
/* /*
Creates path to a file: mysql_data_dir/db/table.ext Creates path to a file: mysql_data_dir/db/table.ext
......
...@@ -258,7 +258,7 @@ uint check_word(TYPELIB *lib, const char *val, const char *end, ...@@ -258,7 +258,7 @@ uint check_word(TYPELIB *lib, const char *val, const char *end,
uint strconvert(CHARSET_INFO *from_cs, const char *from, uint strconvert(CHARSET_INFO *from_cs, const char *from,
CHARSET_INFO *to_cs, char *to, uint to_length) CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors)
{ {
int cnvres; int cnvres;
my_wc_t wc; my_wc_t wc;
...@@ -308,6 +308,7 @@ uint strconvert(CHARSET_INFO *from_cs, const char *from, ...@@ -308,6 +308,7 @@ uint strconvert(CHARSET_INFO *from_cs, const char *from,
break; break;
} }
*to= '\0'; *to= '\0';
*errors= error_count;
return (uint32) (to - to_start); return (uint32) (to - to_start);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment