@@ -1949,6 +1949,26 @@ static char *cover_definer_clause(const char *stmt_str,
19491949 return query_str;
19501950}
19511951
1952+
1953+ static const char * build_path_for_table (char *to, const char *dir,
1954+ const char *table, const char *ext)
1955+ {
1956+ char filename[FN_REFLEN], tmp_path[FN_REFLEN];
1957+ convert_dirname (tmp_path, dir, NULL );
1958+ my_load_path (tmp_path, tmp_path, NULL );
1959+ if (check_if_legal_tablename (table))
1960+ strxnmov (filename, sizeof (filename) - 1 , table, " @@@" , NULL );
1961+ else
1962+ {
1963+ uint errors, len;
1964+ len= my_convert (filename, sizeof (filename) - 1 , &my_charset_filename,
1965+ table, (uint32)strlen (table), charset_info, &errors);
1966+ filename[len]= 0 ;
1967+ }
1968+ return fn_format (to, filename, tmp_path, ext, MYF (MY_UNPACK_FILENAME));
1969+ }
1970+
1971+
19521972/*
19531973 Open a new .sql file to dump the table or view into
19541974
@@ -1964,7 +1984,7 @@ static char *cover_definer_clause(const char *stmt_str,
19641984static FILE* open_sql_file_for_table (const char *db, const char * table, int flags)
19651985{
19661986 FILE* res;
1967- char filename[FN_REFLEN], tmp_path[FN_REFLEN] ;
1987+ char filename[FN_REFLEN];
19681988 char out_dir_buf[FN_REFLEN];
19691989
19701990 char *out_dir= path;
@@ -1974,8 +1994,7 @@ static FILE* open_sql_file_for_table(const char *db, const char* table, int flag
19741994 my_snprintf (out_dir_buf, sizeof (out_dir_buf), " %s/%s" , opt_dir, db);
19751995 }
19761996
1977- convert_dirname (tmp_path, out_dir, NullS);
1978- res= my_fopen (fn_format (filename, table, tmp_path, " .sql" , 4 ),
1997+ res= my_fopen (build_path_for_table (filename, out_dir, table, " .sql" ),
19791998 flags, MYF (MY_WME));
19801999 return res;
19812000}
@@ -4297,7 +4316,7 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
42974316
42984317 if (multi_file_output)
42994318 {
4300- char filename[FN_REFLEN], tmp_path[FN_REFLEN] ;
4319+ char filename[FN_REFLEN];
43014320 char out_dir_buf[FN_REFLEN];
43024321 char *out_dir= path;
43034322 if (!out_dir)
@@ -4310,9 +4329,7 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
43104329 Convert the path to native os format
43114330 and resolve to the full filepath.
43124331 */
4313- convert_dirname (tmp_path,out_dir,NullS);
4314- my_load_path (tmp_path, tmp_path, NULL );
4315- fn_format (filename, table, tmp_path, " .txt" , MYF (MY_UNPACK_FILENAME));
4332+ build_path_for_table (filename, out_dir, table, " .txt" );
43164333
43174334 /* Must delete the file that 'INTO OUTFILE' will write to */
43184335 my_delete (filename, MYF (0 ));
@@ -4321,7 +4338,6 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
43214338 to_unix_path (filename);
43224339
43234340 /* now build the query string */
4324-
43254341 dynstr_append_checked (&query_string, " SELECT /*!40001 SQL_NO_CACHE */ " );
43264342 dynstr_append_checked (&query_string, select_field_names.str );
43274343 dynstr_append_checked (&query_string, " INTO OUTFILE '" );
0 commit comments