mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Fix 'pg_ctl restart' to preserve command-line arguments.
This commit is contained in:
		@@ -37,7 +37,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * IDENTIFICATION
 | 
					 * IDENTIFICATION
 | 
				
			||||||
 *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.560 2008/06/26 01:35:45 momjian Exp $
 | 
					 *	  $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.561 2008/06/26 02:47:19 momjian Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * NOTES
 | 
					 * NOTES
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -4184,7 +4184,7 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	fprintf(fp, "%s", fullprogname);
 | 
						fprintf(fp, "%s", fullprogname);
 | 
				
			||||||
	for (i = 1; i < argc; i++)
 | 
						for (i = 1; i < argc; i++)
 | 
				
			||||||
		fprintf(fp, " " SYSTEMQUOTE "%s" SYSTEMQUOTE, argv[i]);
 | 
							fprintf(fp, " \"%s\"", argv[i]);
 | 
				
			||||||
	fputs("\n", fp);
 | 
						fputs("\n", fp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (fclose(fp))
 | 
						if (fclose(fp))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
 | 
					 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.100 2008/06/26 01:35:45 momjian Exp $
 | 
					 * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.101 2008/06/26 02:47:19 momjian Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *-------------------------------------------------------------------------
 | 
					 *-------------------------------------------------------------------------
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -573,11 +573,11 @@ read_post_opts(void)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	if (post_opts == NULL)
 | 
						if (post_opts == NULL)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		char	  **optlines;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		post_opts = "";		/* defatult */
 | 
							post_opts = "";		/* defatult */
 | 
				
			||||||
		if (ctl_command == RESTART_COMMAND)
 | 
							if (ctl_command == RESTART_COMMAND)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 | 
								char	  **optlines;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			optlines = readfile(postopts_file);
 | 
								optlines = readfile(postopts_file);
 | 
				
			||||||
			if (optlines == NULL)
 | 
								if (optlines == NULL)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
@@ -593,20 +593,26 @@ read_post_opts(void)
 | 
				
			|||||||
			else
 | 
								else
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				int			len;
 | 
									int			len;
 | 
				
			||||||
				char	   *optline = NULL;
 | 
									char	   *optline;
 | 
				
			||||||
				char	   *arg1;
 | 
									char	   *arg1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				optline = optlines[0];
 | 
									optline = optlines[0];
 | 
				
			||||||
 | 
									/* trim off line endings */
 | 
				
			||||||
				len = strcspn(optline, "\r\n");
 | 
									len = strcspn(optline, "\r\n");
 | 
				
			||||||
				optline[len] = '\0';
 | 
									optline[len] = '\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				arg1 = strchr(optline, *SYSTEMQUOTE);
 | 
									for (arg1 = optline; *arg1; arg1++)
 | 
				
			||||||
				if (arg1 == NULL || arg1 == optline)
 | 
					 | 
				
			||||||
					post_opts = "";
 | 
					 | 
				
			||||||
				else
 | 
					 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					*(arg1 - 1) = '\0'; /* this should be a space */
 | 
										/*
 | 
				
			||||||
					post_opts = 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)
 | 
									if (postgres_path != NULL)
 | 
				
			||||||
					postgres_path = optline;
 | 
										postgres_path = optline;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user