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

Commitaba78ab

Browse files
committed
pg_upgrade: Improve invalid option handling
Currently, calling pg_upgrade with an invalid command-line optionaborts pg_upgrade but leaves a pg_upgrade_internal.log file lyingaround. Reorder things a bit so that that file is not created untilall the options have been parsed.Discussion:https://www.postgresql.org/message-id/24c8bd05-aed1-6301-919d-8acbabdb8c24@2ndquadrant.com
1 parentdfd79e2 commitaba78ab

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎src/bin/pg_upgrade/option.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ parseCommandLine(int argc, char *argv[])
101101
if (os_user_effective_id==0)
102102
pg_fatal("%s: cannot be run as root\n",os_info.progname);
103103

104-
if ((log_opts.internal=fopen_priv(INTERNAL_LOG_FILE,"a"))==NULL)
105-
pg_fatal("could not write to log file \"%s\"\n",INTERNAL_LOG_FILE);
106-
107104
while ((option=getopt_long(argc,argv,"d:D:b:B:cj:ko:O:p:P:rs:U:v",
108105
long_options,&optindex))!=-1)
109106
{
@@ -205,7 +202,6 @@ parseCommandLine(int argc, char *argv[])
205202
break;
206203

207204
case'v':
208-
pg_log(PG_REPORT,"Running in verbose mode\n");
209205
log_opts.verbose= true;
210206
break;
211207

@@ -214,12 +210,18 @@ parseCommandLine(int argc, char *argv[])
214210
break;
215211

216212
default:
217-
pg_fatal("Try \"%s --help\" for more information.\n",
218-
os_info.progname);
219-
break;
213+
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),
214+
os_info.progname);
215+
exit(1);
220216
}
221217
}
222218

219+
if ((log_opts.internal=fopen_priv(INTERNAL_LOG_FILE,"a"))==NULL)
220+
pg_fatal("could not write to log file \"%s\"\n",INTERNAL_LOG_FILE);
221+
222+
if (log_opts.verbose)
223+
pg_log(PG_REPORT,"Running in verbose mode\n");
224+
223225
/* label start of upgrade in logfiles */
224226
for (filename=output_files;*filename!=NULL;filename++)
225227
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp