Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 067f1e5

Browse files
committed
Fix 'pg_ctl restart' to preserve command-line arguments.
1 parent a118323 commit 067f1e5

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.560 2008/06/26 01:35:45 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.561 2008/06/26 02:47:19 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -4184,7 +4184,7 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname)
41844184

41854185
fprintf(fp, "%s", fullprogname);
41864186
for (i = 1; i < argc; i++)
4187-
fprintf(fp, " " SYSTEMQUOTE "%s" SYSTEMQUOTE, argv[i]);
4187+
fprintf(fp, " \"%s\"", argv[i]);
41884188
fputs("\n", fp);
41894189

41904190
if (fclose(fp))

src/bin/pg_ctl/pg_ctl.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.100 2008/06/26 01:35:45 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.101 2008/06/26 02:47:19 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -573,11 +573,11 @@ read_post_opts(void)
573573
{
574574
if (post_opts == NULL)
575575
{
576-
char **optlines;
577-
578576
post_opts = ""; /* defatult */
579577
if (ctl_command == RESTART_COMMAND)
580578
{
579+
char **optlines;
580+
581581
optlines = readfile(postopts_file);
582582
if (optlines == NULL)
583583
{
@@ -593,20 +593,26 @@ read_post_opts(void)
593593
else
594594
{
595595
int len;
596-
char *optline = NULL;
596+
char *optline;
597597
char *arg1;
598598

599599
optline = optlines[0];
600+
/* trim off line endings */
600601
len = strcspn(optline, "\r\n");
601602
optline[len] = '\0';
602603

603-
arg1 = strchr(optline, *SYSTEMQUOTE);
604-
if (arg1 == NULL || arg1 == optline)
605-
post_opts = "";
606-
else
604+
for (arg1 = optline; *arg1; arg1++)
607605
{
608-
*(arg1 - 1) = '\0'; /* this should be a space */
609-
post_opts = arg1;
606+
/*
607+
* Are we at the first option, as defined by space,
608+
* double-quote, and a dash?
609+
*/
610+
if (*arg1 == ' ' && *(arg1+1) == '"' && *(arg1+2) == '-')
611+
{
612+
*arg1 = '\0'; /* terminate so we get only program name */
613+
post_opts = arg1 + 1; /* point past whitespace */
614+
break;
615+
}
610616
}
611617
if (postgres_path != NULL)
612618
postgres_path = optline;

0 commit comments

Comments
 (0)