@@ -1942,6 +1942,26 @@ static char *cover_definer_clause(const char *stmt_str,
19421942 return query_str;
19431943}
19441944
1945+
1946+ static const char * build_path_for_table (char *to, const char *dir,
1947+ const char *table, const char *ext)
1948+ {
1949+ char filename[FN_REFLEN], tmp_path[FN_REFLEN];
1950+ convert_dirname (tmp_path, dir, NULL );
1951+ my_load_path (tmp_path, tmp_path, NULL );
1952+ if (check_if_legal_tablename (table))
1953+ strxnmov (filename, sizeof (filename) - 1 , table, " @@@" , NULL );
1954+ else
1955+ {
1956+ uint errors, len;
1957+ len= my_convert (filename, sizeof (filename) - 1 , &my_charset_filename,
1958+ table, (uint32)strlen (table), charset_info, &errors);
1959+ filename[len]= 0 ;
1960+ }
1961+ return fn_format (to, filename, tmp_path, ext, MYF (MY_UNPACK_FILENAME));
1962+ }
1963+
1964+
19451965/*
19461966 Open a new .sql file to dump the table or view into
19471967
@@ -1957,7 +1977,7 @@ static char *cover_definer_clause(const char *stmt_str,
19571977static FILE* open_sql_file_for_table (const char *db, const char * table, int flags)
19581978{
19591979 FILE* res;
1960- char filename[FN_REFLEN], tmp_path[FN_REFLEN] ;
1980+ char filename[FN_REFLEN];
19611981 char out_dir_buf[FN_REFLEN];
19621982
19631983 char *out_dir= path;
@@ -1967,8 +1987,7 @@ static FILE* open_sql_file_for_table(const char *db, const char* table, int flag
19671987 my_snprintf (out_dir_buf, sizeof (out_dir_buf), " %s/%s" , opt_dir, db);
19681988 }
19691989
1970- convert_dirname (tmp_path, out_dir, NullS);
1971- res= my_fopen (fn_format (filename, table, tmp_path, " .sql" , 4 ),
1990+ res= my_fopen (build_path_for_table (filename, out_dir, table, " .sql" ),
19721991 flags, MYF (MY_WME));
19731992 return res;
19741993}
@@ -4290,7 +4309,7 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
42904309
42914310 if (multi_file_output)
42924311 {
4293- char filename[FN_REFLEN], tmp_path[FN_REFLEN] ;
4312+ char filename[FN_REFLEN];
42944313 char out_dir_buf[FN_REFLEN];
42954314 char *out_dir= path;
42964315 if (!out_dir)
@@ -4303,9 +4322,7 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
43034322 Convert the path to native os format
43044323 and resolve to the full filepath.
43054324 */
4306- convert_dirname (tmp_path,out_dir,NullS);
4307- my_load_path (tmp_path, tmp_path, NULL );
4308- fn_format (filename, table, tmp_path, " .txt" , MYF (MY_UNPACK_FILENAME));
4325+ build_path_for_table (filename, out_dir, table, " .txt" );
43094326
43104327 /* Must delete the file that 'INTO OUTFILE' will write to */
43114328 my_delete (filename, MYF (0 ));
@@ -4314,7 +4331,6 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
43144331 to_unix_path (filename);
43154332
43164333 /* now build the query string */
4317-
43184334 dynstr_append_checked (&query_string, " SELECT /*!40001 SQL_NO_CACHE */ " );
43194335 dynstr_append_checked (&query_string, select_field_names.str );
43204336 dynstr_append_checked (&query_string, " INTO OUTFILE '" );
0 commit comments