We document 'pg_ctl restart' to preserve any command-line arguments
passed when the server was started:
Restarting the server is almost equivalent to stopping the
server and starting it again except that <command>pg_ctl</command>
saves and reuses the command line options that were passed
to the previously running instance. To restart
However, as of 2004-10-15, this has not worked. :-( The attached patch
is the one that caused the bug --- on non-Unix systems, SYSTEMQUOTE is
"", meaning zero-length string. I should have seen the bug when I
applied the contributed patch in 2004.
The second attached applied patch fixes the problem.
--
Bruce Momjian <[EMAIL PROTECTED]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.433
retrieving revision 1.434
diff -c -r1.433 -r1.434
*** src/backend/postmaster/postmaster.c 14 Oct 2004 20:23:45 -0000 1.433
--- src/backend/postmaster/postmaster.c 15 Oct 2004 04:54:31 -0000 1.434
***************
*** 3301,3307 ****
fprintf(fp, "%s", fullprogname);
for (i = 1; i < argc; i++)
! fprintf(fp, " '%s'", argv[i]);
fputs("\n", fp);
if (fclose(fp))
--- 3301,3307 ----
fprintf(fp, "%s", fullprogname);
for (i = 1; i < argc; i++)
! fprintf(fp, " %s%s%s", SYSTEMQUOTE, argv[i], SYSTEMQUOTE);
fputs("\n", fp);
if (fclose(fp))
Index: src/bin/pg_ctl/pg_ctl.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/pg_ctl/pg_ctl.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -c -r1.37 -r1.38
*** src/bin/pg_ctl/pg_ctl.c 15 Oct 2004 04:32:14 -0000 1.37
--- src/bin/pg_ctl/pg_ctl.c 15 Oct 2004 04:54:33 -0000 1.38
***************
*** 501,507 ****
{
char *arg1;
! arg1 = strchr(optline, '\'');
if (arg1 == NULL || arg1 == optline)
post_opts = "";
else
--- 501,507 ----
{
char *arg1;
! arg1 = strchr(optline, *SYSTEMQUOTE);
if (arg1 == NULL || arg1 == optline)
post_opts = "";
else
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.560
diff -c -c -r1.560 postmaster.c
*** src/backend/postmaster/postmaster.c 26 Jun 2008 01:35:45 -0000 1.560
--- src/backend/postmaster/postmaster.c 26 Jun 2008 02:41:04 -0000
***************
*** 4184,4190 ****
fprintf(fp, "%s", fullprogname);
for (i = 1; i < argc; i++)
! fprintf(fp, " " SYSTEMQUOTE "%s" SYSTEMQUOTE, argv[i]);
fputs("\n", fp);
if (fclose(fp))
--- 4184,4190 ----
fprintf(fp, "%s", fullprogname);
for (i = 1; i < argc; i++)
! fprintf(fp, " \"%s\"", argv[i]);
fputs("\n", fp);
if (fclose(fp))
Index: src/bin/pg_ctl/pg_ctl.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/pg_ctl/pg_ctl.c,v
retrieving revision 1.100
diff -c -c -r1.100 pg_ctl.c
*** src/bin/pg_ctl/pg_ctl.c 26 Jun 2008 01:35:45 -0000 1.100
--- src/bin/pg_ctl/pg_ctl.c 26 Jun 2008 02:41:04 -0000
***************
*** 573,583 ****
{
if (post_opts == NULL)
{
- char **optlines;
-
post_opts = ""; /* defatult */
if (ctl_command == RESTART_COMMAND)
{
optlines = readfile(postopts_file);
if (optlines == NULL)
{
--- 573,583 ----
{
if (post_opts == NULL)
{
post_opts = ""; /* defatult */
if (ctl_command == RESTART_COMMAND)
{
+ char **optlines;
+
optlines = readfile(postopts_file);
if (optlines == NULL)
{
***************
*** 593,612 ****
else
{
int len;
! char *optline = NULL;
char *arg1;
optline = optlines[0];
len = strcspn(optline, "\r\n");
optline[len] = '\0';
! arg1 = strchr(optline, *SYSTEMQUOTE);
! if (arg1 == NULL || arg1 == optline)
! post_opts = "";
! else
{
! *(arg1 - 1) = '\0'; /* this should be a space */
! post_opts = arg1;
}
if (postgres_path != NULL)
postgres_path = optline;
--- 593,618 ----
else
{
int len;
! char *optline;
char *arg1;
optline = optlines[0];
+ /* trim off line endings */
len = strcspn(optline, "\r\n");
optline[len] = '\0';
! for (arg1 = optline; *arg1; arg1++)
{
! /*
! * Are we at the first option, as defined by space,
! * double-quote, and a dash?
! */
! if (*arg1 == ' ' && *(arg1+1) == '"' && *(arg1+2) == '-')
! {
! *arg1 = '\0'; /* terminate so we get only program name */
! post_opts = arg1 + 1; /* point past whitespace */
! break;
! }
}
if (postgres_path != NULL)
postgres_path = optline;
--
Sent via pgsql-patches mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches