Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit476291b

Browse files
committed
Adjust pg_upgrade to output a separate log file for pg_ctl output on
Windows, to avoid opening a file by multiple processes.
1 parent77f93cb commit476291b

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

‎contrib/pg_upgrade/option.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ parseCommandLine(int argc, char *argv[])
5757
intoptindex=0;/* used by getopt_long */
5858
intos_user_effective_id;
5959
FILE*fp;
60-
inti;
60+
char**filename;
6161
time_trun_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"

‎contrib/pg_upgrade/pg_upgrade.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ ClusterInfo old_cluster,
5555
new_cluster;
5656
OSInfoos_info;
5757

58-
char*output_files[NUM_LOG_FILES]= {
58+
char*output_files[]= {
5959
SERVER_LOG_FILE,
60+
#ifdefWIN32
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-
charfilename[MAXPGPATH];
458-
inti;
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
}

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#defineUTILITY_LOG_FILE"pg_upgrade_utility.log"
4141
#defineINTERNAL_LOG_FILE"pg_upgrade_internal.log"
4242

43-
#defineNUM_LOG_FILES4
4443
externchar*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
#ifndefWIN32
6162
#defineSERVER_LOG_FILE2SERVER_LOG_FILE
6263
#else
63-
#defineSERVER_LOG_FILE2UTILITY_LOG_FILE
64+
#defineSERVER_LOG_FILE2"pg_upgrade_server2.log"
6465
#endif
6566

6667

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp