mirror of
https://github.com/MariaDB/server.git
synced 2026-05-17 20:37:12 +02:00
MDEV-37483 mariadb-dump -T doesn't convert table names
use my_charset_filename to build file names from table names. this guarantees that file name will be always valid for any table name, no matter what characters it contains and what file name rules local filesystem has. mariadb-import now converts back, if possible.
This commit is contained in:
parent
75b000372b
commit
ff12ec86a5
4 changed files with 109 additions and 2 deletions
|
|
@ -1841,10 +1841,19 @@ static char *cover_definer_clause(const char *stmt_str,
|
|||
static const char* build_path_for_table(char *to, const char *dir,
|
||||
const char *table, const char *ext)
|
||||
{
|
||||
char tmp_path[FN_REFLEN];
|
||||
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
|
||||
convert_dirname(tmp_path, path, NULL);
|
||||
my_load_path(tmp_path, tmp_path, NULL);
|
||||
return fn_format(to, table, tmp_path, ext, MYF(MY_UNPACK_FILENAME));
|
||||
if (check_if_legal_tablename(table))
|
||||
strxnmov(filename, sizeof(filename) - 1, table, "@@@", NULL);
|
||||
else
|
||||
{
|
||||
uint errors, len;
|
||||
len= my_convert(filename, sizeof(filename) - 1, &my_charset_filename,
|
||||
table, (uint32)strlen(table), charset_info, &errors);
|
||||
filename[len]= 0;
|
||||
}
|
||||
return fn_format(to, filename, tmp_path, ext, MYF(MY_UNPACK_FILENAME));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -340,6 +340,16 @@ static int write_to_table(char *filename, MYSQL *mysql)
|
|||
DBUG_PRINT("enter",("filename: %s",filename));
|
||||
|
||||
fn_format(tablename, filename, "", "", MYF(MY_REPLACE_DIR | MY_REPLACE_EXT));
|
||||
if (strchr(tablename, '@'))
|
||||
{
|
||||
uint errors, len;
|
||||
const char *csname= my_default_csname(); /* see MYSQL_SET_CHARSET_NAME */
|
||||
CHARSET_INFO *cs= get_charset_by_csname(csname, MY_CS_PRIMARY, MYF(0));
|
||||
len= my_convert(escaped_name, sizeof(escaped_name) - 1, cs, tablename,
|
||||
(uint32)strlen(tablename), &my_charset_filename, &errors);
|
||||
if (!errors)
|
||||
strmake(tablename, escaped_name, len);
|
||||
}
|
||||
if (!opt_local_file)
|
||||
strmov(hard_path,filename);
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue