@@ -1837,6 +1837,17 @@ static char *cover_definer_clause(const char *stmt_str,
18371837 return query_str ;
18381838}
18391839
1840+
1841+ static const char * build_path_for_table (char * to , const char * dir ,
1842+ const char * table , const char * ext )
1843+ {
1844+ char tmp_path [FN_REFLEN ];
1845+ convert_dirname (tmp_path , path , NULL );
1846+ my_load_path (tmp_path , tmp_path , NULL );
1847+ return fn_format (to , table , tmp_path , ext , MYF (MY_UNPACK_FILENAME ));
1848+ }
1849+
1850+
18401851/*
18411852 Open a new .sql file to dump the table or view into
18421853
@@ -1851,12 +1862,9 @@ static char *cover_definer_clause(const char *stmt_str,
18511862*/
18521863static FILE * open_sql_file_for_table (const char * table , int flags )
18531864{
1854- FILE * res ;
1855- char filename [FN_REFLEN ], tmp_path [FN_REFLEN ];
1856- convert_dirname (tmp_path ,path ,NullS );
1857- res = my_fopen (fn_format (filename , table , tmp_path , ".sql" , 4 ),
1858- flags , MYF (MY_WME ));
1859- return res ;
1865+ char filename [FN_REFLEN ];
1866+ return my_fopen (build_path_for_table (filename , path , table , ".sql" ),
1867+ flags , MYF (MY_WME ));
18601868}
18611869
18621870
@@ -4043,15 +4051,9 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
40434051
40444052 if (path )
40454053 {
4046- char filename [FN_REFLEN ], tmp_path [ FN_REFLEN ] ;
4054+ char filename [FN_REFLEN ];
40474055
4048- /*
4049- Convert the path to native os format
4050- and resolve to the full filepath.
4051- */
4052- convert_dirname (tmp_path ,path ,NullS );
4053- my_load_path (tmp_path , tmp_path , NULL );
4054- fn_format (filename , table , tmp_path , ".txt" , MYF (MY_UNPACK_FILENAME ));
4056+ build_path_for_table (filename , path , table , ".txt" );
40554057
40564058 /* Must delete the file that 'INTO OUTFILE' will write to */
40574059 my_delete (filename , MYF (0 ));
@@ -4060,7 +4062,6 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
40604062 to_unix_path (filename );
40614063
40624064 /* now build the query string */
4063-
40644065 dynstr_append_checked (& query_string , "SELECT /*!40001 SQL_NO_CACHE */ " );
40654066 dynstr_append_checked (& query_string , select_field_names .str );
40664067 dynstr_append_checked (& query_string , " INTO OUTFILE '" );
0 commit comments