summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/mysql_priv.h15
-rw-r--r--sql/sql_show.cc5
-rw-r--r--sql/sql_table.cc32
-rw-r--r--sql/strfunc.cc3
4 files changed, 40 insertions, 15 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index fabc2e2e1cd..b6be03003c6 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -1504,20 +1504,11 @@ char *fn_rext(char *name);
/* Conversion functions */
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,
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 */
struct in_addr;
my_string ip_to_hostname(struct in_addr *in,uint *errors);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 16a783a2ad0..705ebb4aef3 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -437,9 +437,10 @@ mysql_find_files(THD *thd,List<char> *files, const char *db,const char *path,
continue;
}
#endif
+ if (!MY_S_ISDIR(file->mystat->st_mode))
+ continue;
VOID(filename_to_tablename(file->name, uname, sizeof(uname)));
- if (!MY_S_ISDIR(file->mystat->st_mode) ||
- (wild && wild_compare(uname, wild, 0)))
+ if (wild && wild_compare(uname, wild, 0))
continue;
file->name= uname;
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 5a083fcdd22..dd91d7ecd0f 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -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
diff --git a/sql/strfunc.cc b/sql/strfunc.cc
index 4eb20faa97c..2525703172f 100644
--- a/sql/strfunc.cc
+++ b/sql/strfunc.cc
@@ -258,7 +258,7 @@ uint check_word(TYPELIB *lib, const char *val, const char *end,
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;
my_wc_t wc;
@@ -308,6 +308,7 @@ outp:
break;
}
*to= '\0';
+ *errors= error_count;
return (uint32) (to - to_start);
}