File tree Expand file tree Collapse file tree 3 files changed +24
-24
lines changed Expand file tree Collapse file tree 3 files changed +24
-24
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ parseCommandLine(int argc, char *argv[])
5757 int optindex = 0 ; /* used by getopt_long */
5858 int os_user_effective_id ;
5959 FILE * fp ;
60- int i ;
60+ char * * filename ;
6161 time_t run_time = time (NULL );
6262
6363 user_opts .transfer_mode = TRANSFER_MODE_COPY ;
@@ -188,11 +188,12 @@ parseCommandLine(int argc, char *argv[])
188188 }
189189
190190 /* label start of upgrade in logfiles */
191- for (i = 0 ; i < NUM_LOG_FILES ; i ++ )
191+ for (filename = output_files ; * filename != NULL ; filename ++ )
192192 {
193- if ((fp = fopen_priv (output_files [i ], "a" )) == NULL )
194- pg_log (PG_FATAL , "cannot write to log file %s\n" ,
195- output_files [i ]);
193+ if ((fp = fopen_priv (* filename , "a" )) == NULL )
194+ pg_log (PG_FATAL , "cannot write to log file %s\n" , * filename );
195+
196+ /* Start with newline because we might be appending to a file. */
196197 fprintf (fp , "\n"
197198 "-----------------------------------------------------------------\n"
198199 " pg_upgrade run on %s"
Original file line number Diff line number Diff line change @@ -55,11 +55,16 @@ ClusterInfo old_cluster,
5555 new_cluster ;
5656OSInfo os_info ;
5757
58- char * output_files [NUM_LOG_FILES ] = {
58+ char * output_files [] = {
5959 SERVER_LOG_FILE ,
60+ #ifdef WIN32
61+ /* file is unique on Win32 */
62+ SERVER_LOG_FILE2 ,
63+ #endif
6064 RESTORE_LOG_FILE ,
6165 UTILITY_LOG_FILE ,
62- INTERNAL_LOG_FILE
66+ INTERNAL_LOG_FILE ,
67+ NULL
6368};
6469
6570
@@ -454,21 +459,14 @@ cleanup(void)
454459 /* Remove dump and log files? */
455460 if (!log_opts .retain )
456461 {
457- char filename [MAXPGPATH ];
458- int i ;
462+ char * * filename ;
459463
460- for (i = 0 ; i < NUM_LOG_FILES ; i ++ )
461- {
462- snprintf (filename , sizeof (filename ), "%s" , output_files [i ]);
463- unlink (filename );
464- }
464+ for (filename = output_files ; * filename != NULL ; filename ++ )
465+ unlink (* filename );
465466
466467 /* remove SQL files */
467- snprintf (filename , sizeof (filename ), "%s" , ALL_DUMP_FILE );
468- unlink (filename );
469- snprintf (filename , sizeof (filename ), "%s" , GLOBALS_DUMP_FILE );
470- unlink (filename );
471- snprintf (filename , sizeof (filename ), "%s" , DB_DUMP_FILE );
472- unlink (filename );
468+ unlink (ALL_DUMP_FILE );
469+ unlink (GLOBALS_DUMP_FILE );
470+ unlink (DB_DUMP_FILE );
473471 }
474472}
Original file line number Diff line number Diff line change 4040#define UTILITY_LOG_FILE "pg_upgrade_utility.log"
4141#define INTERNAL_LOG_FILE "pg_upgrade_internal.log"
4242
43- #define NUM_LOG_FILES 4
4443extern char * output_files [];
4544
4645/*
@@ -49,8 +48,10 @@ extern char *output_files[];
4948 * On Win32, we can't send both pg_upgrade output and command output to the
5049 * same file because we get the error: "The process cannot access the file
5150 * because it is being used by another process." so send the pg_ctl
52- * command-line output to the utility log file on Windows, rather than
53- * into the server log file.
51+ * command-line output to a new file, rather than into the server log file.
52+ * Ideally we could use UTILITY_LOG_FILE for this, but some Windows platforms
53+ * keep the pg_ctl output file open even after pg_ctl exits, perhaps by the
54+ * running postmaster.
5455 *
5556 * We could use the Windows pgwin32_open() flags to allow shared file
5657 * writes but is unclear how all other tools would use those flags, so
@@ -60,7 +61,7 @@ extern char *output_files[];
6061#ifndef WIN32
6162#define SERVER_LOG_FILE2 SERVER_LOG_FILE
6263#else
63- #define SERVER_LOG_FILE2 UTILITY_LOG_FILE
64+ #define SERVER_LOG_FILE2 "pg_upgrade_server2.log"
6465#endif
6566
6667
You can’t perform that action at this time.
0 commit comments