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

Commit022cd22

Browse files
committed
In pg_upgrade, document why we can't issue \n\n in the command logfile
on Windows. Slightly cleanup log output on Windows given thisrestriction.Backpatch to 9.2.
1 parentc4c2274 commit022cd22

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

‎contrib/pg_upgrade/exec.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,11 @@ exec_prog(const char *log_file, const char *opt_log_file,
6363
if (written >=MAXCMDLEN)
6464
pg_log(PG_FATAL,"command too long\n");
6565

66-
if ((log=fopen_priv(log_file,"a+"))==NULL)
66+
if ((log=fopen_priv(log_file,"a"))==NULL)
6767
pg_log(PG_FATAL,"cannot write to log file %s\n",log_file);
68+
#ifdefWIN32
69+
fprintf(log,"\n\n");
70+
#endif
6871
pg_log(PG_VERBOSE,"%s\n",cmd);
6972
fprintf(log,"command: %s\n",cmd);
7073

@@ -97,10 +100,13 @@ exec_prog(const char *log_file, const char *opt_log_file,
97100

98101
#ifndefWIN32
99102
/*
100-
* Can't do this on Windows, postmaster will still hold the log file
101-
* open if the command was "pg_ctl start".
103+
*We can't do this on Windows because it will keep the "pg_ctl start"
104+
*output filename open until the server stops, so we do the \n\n above
105+
*on that platform. We use a unique filename for "pg_ctl start" that is
106+
*never reused while the server is running, so it works fine. We could
107+
*log these commands to a third file, but that just adds complexity.
102108
*/
103-
if ((log=fopen_priv(log_file,"a+"))==NULL)
109+
if ((log=fopen_priv(log_file,"a"))==NULL)
104110
pg_log(PG_FATAL,"cannot write to log file %s\n",log_file);
105111
fprintf(log,"\n\n");
106112
fclose(log);

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ extern char *output_files[];
6363
#defineSERVER_STOP_LOG_FILESERVER_LOG_FILE
6464
#else
6565
#defineSERVER_START_LOG_FILE"pg_upgrade_server_start.log"
66-
/* pg_ctl stop doesn't keep the log file open, so reuse UTILITY_LOG_FILE */
66+
/*
67+
*"pg_ctl start" keeps SERVER_START_LOG_FILE and SERVER_LOG_FILE open
68+
*while the server is running, so we use UTILITY_LOG_FILE for "pg_ctl
69+
*stop".
70+
*/
6771
#defineSERVER_STOP_LOG_FILEUTILITY_LOG_FILE
6872
#endif
6973

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp