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

Commit4741e9a

Browse files
committed
Make the pg_upgrade log files contain actual commands
Now the log file not only contains the output from commands executed bysystem(), but also what command it was in the first place. Thisarrangement makes debugging a lot simpler.
1 parentb344c65 commit4741e9a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

‎contrib/pg_upgrade/exec.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ static intwin32_check_directory_write_permissions(void);
2929
*
3030
*Formats a command from the given argument list and executes that
3131
*command. If the command executes, exec_prog() returns 1 otherwise
32-
*exec_prog() logs an error message and returns 0.
32+
*exec_prog() logs an error message and returns 0. Either way, the command
33+
*line to be executed is saved to the specified log file.
3334
*
3435
*If throw_error is TRUE, this function will throw a PG_FATAL error
3536
*instead of returning should an error occur.
@@ -40,8 +41,10 @@ exec_prog(bool throw_error, bool is_priv,
4041
{
4142
va_listargs;
4243
intresult;
44+
intretval;
4345
charcmd[MAXPGPATH];
4446
mode_told_umask=0;
47+
FILE*log=fopen(log_file,"a+");
4548

4649
if (is_priv)
4750
old_umask=umask(S_IRWXG |S_IRWXO);
@@ -51,6 +54,8 @@ exec_prog(bool throw_error, bool is_priv,
5154
va_end(args);
5255

5356
pg_log(PG_VERBOSE,"%s\n",cmd);
57+
fprintf(log,"command: %s\n",cmd);
58+
fflush(log);
5459

5560
result=system(cmd);
5661

@@ -66,10 +71,15 @@ exec_prog(bool throw_error, bool is_priv,
6671
"Consult the last few lines of \"%s\" for\n"
6772
"the probable cause of the failure.\n",
6873
log_file);
69-
return1;
74+
retval=1;
7075
}
76+
else
77+
retval=0;
7178

72-
return0;
79+
fprintf(log,"\n\n");
80+
fclose(log);
81+
82+
returnretval;
7383
}
7484

7585

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp