File tree 3 files changed +24
-24
lines changed
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[])
57
57
int optindex = 0 ; /* used by getopt_long */
58
58
int os_user_effective_id ;
59
59
FILE * fp ;
60
- int i ;
60
+ char * * filename ;
61
61
time_t run_time = time (NULL );
62
62
63
63
user_opts .transfer_mode = TRANSFER_MODE_COPY ;
@@ -188,11 +188,12 @@ parseCommandLine(int argc, char *argv[])
188
188
}
189
189
190
190
/* label start of upgrade in logfiles */
191
- for (i = 0 ; i < NUM_LOG_FILES ; i ++ )
191
+ for (filename = output_files ; * filename != NULL ; filename ++ )
192
192
{
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. */
196
197
fprintf (fp , "\n"
197
198
"-----------------------------------------------------------------\n"
198
199
" pg_upgrade run on %s"
Original file line number Diff line number Diff line change @@ -55,11 +55,16 @@ ClusterInfo old_cluster,
55
55
new_cluster ;
56
56
OSInfo os_info ;
57
57
58
- char * output_files [NUM_LOG_FILES ] = {
58
+ char * output_files [] = {
59
59
SERVER_LOG_FILE ,
60
+ #ifdef WIN32
61
+ /* file is unique on Win32 */
62
+ SERVER_LOG_FILE2 ,
63
+ #endif
60
64
RESTORE_LOG_FILE ,
61
65
UTILITY_LOG_FILE ,
62
- INTERNAL_LOG_FILE
66
+ INTERNAL_LOG_FILE ,
67
+ NULL
63
68
};
64
69
65
70
@@ -454,21 +459,14 @@ cleanup(void)
454
459
/* Remove dump and log files? */
455
460
if (!log_opts .retain )
456
461
{
457
- char filename [MAXPGPATH ];
458
- int i ;
462
+ char * * filename ;
459
463
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 );
465
466
466
467
/* 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 );
473
471
}
474
472
}
Original file line number Diff line number Diff line change 40
40
#define UTILITY_LOG_FILE "pg_upgrade_utility.log"
41
41
#define INTERNAL_LOG_FILE "pg_upgrade_internal.log"
42
42
43
- #define NUM_LOG_FILES 4
44
43
extern char * output_files [];
45
44
46
45
/*
@@ -49,8 +48,10 @@ extern char *output_files[];
49
48
* On Win32, we can't send both pg_upgrade output and command output to the
50
49
* same file because we get the error: "The process cannot access the file
51
50
* 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.
54
55
*
55
56
* We could use the Windows pgwin32_open() flags to allow shared file
56
57
* writes but is unclear how all other tools would use those flags, so
@@ -60,7 +61,7 @@ extern char *output_files[];
60
61
#ifndef WIN32
61
62
#define SERVER_LOG_FILE2 SERVER_LOG_FILE
62
63
#else
63
- #define SERVER_LOG_FILE2 UTILITY_LOG_FILE
64
+ #define SERVER_LOG_FILE2 "pg_upgrade_server2.log"
64
65
#endif
65
66
66
67
You can’t perform that action at this time.
0 commit comments