1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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()
This commit is contained in:
bar@mysql.com
2005-12-31 12:34:39 +04:00
parent ce1f07078e
commit dc1b2cd312
4 changed files with 40 additions and 15 deletions

View File

@ -102,6 +102,38 @@ static bool abort_and_upgrade_lock(THD *thd, TABLE *table, const char *db,
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