@@ -18,7 +18,6 @@ static void copy_clog_xlog_xid(migratorContext *ctx);
1818static void set_frozenxids (migratorContext * ctx );
1919static void setup (migratorContext * ctx ,char * argv0 ,bool live_check );
2020static void cleanup (migratorContext * ctx );
21- static void create_empty_output_directory (migratorContext * ctx );
2221
2322
2423int
@@ -37,8 +36,6 @@ main(int argc, char **argv)
3736
3837setup (& ctx ,argv [0 ],live_check );
3938
40- create_empty_output_directory (& ctx );
41-
4239check_cluster_versions (& ctx );
4340check_cluster_compatibility (& ctx ,live_check );
4441
@@ -201,7 +198,7 @@ prepare_new_databases(migratorContext *ctx)
201198exec_prog (ctx , true,
202199SYSTEMQUOTE "\"%s/psql\" --set ON_ERROR_STOP=on --port %d "
203200"-f \"%s/%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE ,
204- ctx -> new .bindir ,ctx -> new .port ,ctx -> output_dir ,
201+ ctx -> new .bindir ,ctx -> new .port ,ctx -> cwd ,
205202GLOBALS_DUMP_FILE ,ctx -> logfile );
206203check_ok (ctx );
207204
@@ -223,7 +220,7 @@ create_new_objects(migratorContext *ctx)
223220exec_prog (ctx , true,
224221SYSTEMQUOTE "\"%s/psql\" --set ON_ERROR_STOP=on --port %d "
225222"-f \"%s/%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE ,
226- ctx -> new .bindir ,ctx -> new .port ,ctx -> output_dir ,
223+ ctx -> new .bindir ,ctx -> new .port ,ctx -> cwd ,
227224DB_DUMP_FILE ,ctx -> logfile );
228225check_ok (ctx );
229226
@@ -399,33 +396,10 @@ cleanup(migratorContext *ctx)
399396if (ctx -> debug_fd )
400397fclose (ctx -> debug_fd );
401398
402- snprintf (filename ,sizeof (filename ),"%s/%s" ,ctx -> output_dir ,ALL_DUMP_FILE );
399+ snprintf (filename ,sizeof (filename ),"%s/%s" ,ctx -> cwd ,ALL_DUMP_FILE );
403400unlink (filename );
404- snprintf (filename ,sizeof (filename ),"%s/%s" ,ctx -> output_dir ,GLOBALS_DUMP_FILE );
401+ snprintf (filename ,sizeof (filename ),"%s/%s" ,ctx -> cwd ,GLOBALS_DUMP_FILE );
405402unlink (filename );
406- snprintf (filename ,sizeof (filename ),"%s/%s" ,ctx -> output_dir ,DB_DUMP_FILE );
403+ snprintf (filename ,sizeof (filename ),"%s/%s" ,ctx -> cwd ,DB_DUMP_FILE );
407404unlink (filename );
408405}
409-
410-
411- /*
412- * create_empty_output_directory
413- *
414- *Create empty directory for output files
415- */
416- static void
417- create_empty_output_directory (migratorContext * ctx )
418- {
419- /*
420- *rmtree() outputs a warning if the directory does not exist,
421- *so we try to create the directory first.
422- */
423- if (mkdir (ctx -> output_dir ,S_IRWXU )!= 0 )
424- {
425- if (errno == EEXIST )
426- rmtree (ctx -> output_dir , false);
427- else
428- pg_log (ctx ,PG_FATAL ,"Cannot create subdirectory %s: %s\n" ,
429- ctx -> output_dir ,getErrorText (errno ));
430- }
431- }