Re: [pgsql-hackers-win32] [BUGS] pg_autovacuum in 8beta-dev3 small bug

"Dave Page" <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.general,gmane.comp.db.postgresql.devel.win32,gmane.comp.db.postgresql.devel.patches
Message-ID <E7F85A1B5FF8D44C8A1AF6885BC9A0E4527B5C@ratbert.vale-housing.co.uk>
 

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf 
> Of Bruce Momjian
> Sent: 27 November 2004 04:33
> To: [email protected]
> Cc: PostgreSQL Win32 port list; PostgreSQL-development
> Subject: Re: [pgsql-hackers-win32] [BUGS] pg_autovacuum in 
> 8beta-dev3 small bug
> 
> 
> Can someone comment on this?
> 
> --------------------------------------------------------------
> -------------
> 
> Leen Besselink wrote:
> > Hi folks,
> > 
> > 8.0beta3 has pg_autovacuum included, when I want to run this as a 
> > Windows service, it says you can use the -I and -R options.
> > 
> > When I do that and I specify a password with '-P' 
> (uppercase) then in 
> > the registry it's saved as '-p' (lowercase) in the 
> service-commandline 
> > (ImagePath).

This was fixed in v1.21 of pg_autovacuum.c, That rev is tagged for
beta3, so you should not be seeing this issue unless you actually have
an older version for some reason.

http://developer.postgresql.org/cvsweb.cgi/pgsql/contrib/pg_autovacuum/p
g_autovacuum.c.diff?r1=1.20;r2=1.21;f=h

> > Also it removes the quotes I added and I'm not so sure it 
> would work 
> > the way it's supposed to, without it.

It's not so much that it strips them (that happens automagically), more
that it doesn't re-add them when it writes the command line in the
registry. The attached patch fixes that by simply quoting all options
that may need it.

> > If you add DependOnService (a REG_MULTI_SZ an 
> array-like-thingie) and 
> > have the name (in this case: pgsql-8.0-beta2-dev3) of a service it 
> > depends on, it will not fail to start (it will not even try, as 
> > PostgreSQL is not running), when PostgreSQL already failed.
> > 
> > Maybe it's an idea to specify it on the commandline (what 
> service to 
> > depend on).

A -E <service> option is added in the attached patch.

Regards, Dave.


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match
pg_autovacuum.diff (application/octet-stream, 5.6 KB)
Common subdirectories: pg_autovacuum.orig/CVS and pg_autovacuum/CVS
diff -c pg_autovacuum.orig/README.pg_autovacuum pg_autovacuum/README.pg_autovacuum
*** pg_autovacuum.orig/README.pg_autovacuum	Wed Nov 17 21:30:36 2004
--- pg_autovacuum/README.pg_autovacuum	Sat Nov 27 21:52:49 2004
***************
*** 163,173 ****
     be stored in plain text.
  	     
  -N service user: Name of the Windows user account under which the service
!    will run.
     
! -W service password: The password for the service account.
  
  -R Uninstall pg_autovacuum as a service.
  
  Vacuum and Analyze:
  -------------------
--- 163,178 ----
     be stored in plain text.
  	     
  -N service user: Name of the Windows user account under which the service
!    will run. Only used when installing as a Windows service.
     
! -W service password: The password for the service account.Only used when 
!    installing as a Windows service.
  
  -R Uninstall pg_autovacuum as a service.
+ 
+ -E Dependent service that must start before this service. Normally this will be
+    a PostgreSQL instance, e.g. "-E pgsql-8.0.0". Only used when installing as 
+    a Windows service.
  
  Vacuum and Analyze:
  -------------------
Only in pg_autovacuum: dllist.c
Only in pg_autovacuum: dllist.o
diff -c pg_autovacuum.orig/pg_autovacuum.c pg_autovacuum/pg_autovacuum.c
*** pg_autovacuum.orig/pg_autovacuum.c	Wed Nov 17 21:30:36 2004
--- pg_autovacuum/pg_autovacuum.c	Sat Nov 27 21:52:49 2004
***************
*** 1100,1106 ****
  #ifndef WIN32
  	while ((c = getopt(argc, argv, "s:S:v:V:a:A:d:U:P:H:L:p:hD:c:C:m:n:l:")) != -1)
  #else
! 	while ((c = getopt(argc, argv, "s:S:v:V:a:A:d:U:P:H:L:p:hIRN:W:c:C:m:n:l:")) != -1)
  #endif
  	{
  		switch (c)
--- 1100,1106 ----
  #ifndef WIN32
  	while ((c = getopt(argc, argv, "s:S:v:V:a:A:d:U:P:H:L:p:hD:c:C:m:n:l:")) != -1)
  #else
! 	while ((c = getopt(argc, argv, "s:S:v:V:a:A:d:U:P:H:L:p:hIRN:W:E:c:C:m:n:l:")) != -1)
  #endif
  	{
  		switch (c)
***************
*** 1165,1170 ****
--- 1165,1173 ----
  				usage();
  				exit(0);
  #ifdef WIN32
+ 			case 'E':
+ 				args->service_dependencies = optarg;
+ 				break;
  			case 'I':
  				args->install_as_service++;
  				break;
***************
*** 1216,1221 ****
--- 1219,1225 ----
  	fprintf(stderr, "   [-R] Remove as a Windows service (all other options will be ignored)\n");
  	fprintf(stderr, "   [-N] Username to run service as (only useful when installing as a Windows service)\n");
  	fprintf(stderr, "   [-W] Password to run service with (only useful when installing as a Windows service)\n");
+ 	fprintf(stderr, "   [-E] Dependent service that must start before this service (only useful when installing as a Windows service)\n");
  #endif
  	i = AUTOVACUUM_DEBUG;
  	fprintf(stderr, "   [-d] debug (debug level=0,1,2,3; default=%d)\n", i);
***************
*** 1273,1278 ****
--- 1277,1284 ----
  	log_entry(logbuffer, LVL_INFO);
  	sprintf(logbuffer, "  args->remove_as_service=%d", args->remove_as_service);
  	log_entry(logbuffer, LVL_INFO);
+ 	sprintf(logbuffer, "  args->service_dependencies=%s", (args->service_dependencies) ? args->service_dependencies : "(null)");
+ 	log_entry(logbuffer, LVL_INFO);
  	sprintf(logbuffer, "  args->service_user=%s", (args->service_user) ? args->service_user : "(null)");
  	log_entry(logbuffer, LVL_INFO);
  	sprintf(logbuffer, "  args->service_password=%s", (args->service_password) ? args->service_password : "(null)");
***************
*** 1385,1391 ****
  							   szFilename,		/* Service binary */
  							   NULL,	/* No load ordering group */
  							   NULL,	/* No tag identifier */
! 							   NULL,	/* Dependencies */
  							   args->service_user,		/* Service account */
  							   args->service_password); /* Account password */
  
--- 1391,1397 ----
  							   szFilename,		/* Service binary */
  							   NULL,	/* No load ordering group */
  							   NULL,	/* No tag identifier */
! 							   args->service_dependencies,	/* Dependencies */
  							   args->service_user,		/* Service account */
  							   args->service_password); /* Account password */
  
***************
*** 1406,1416 ****
  	if (args->port)
  		sprintf(szCommand, "%s -p %s", szCommand, args->port);
  	if (args->user)
! 		sprintf(szCommand, "%s -U %s", szCommand, args->user);
  	if (args->password)
! 		sprintf(szCommand, "%s -P %s", szCommand, args->password);
  	if (args->logfile)
! 		sprintf(szCommand, "%s -L %s", szCommand, args->logfile);
  	if (args->sleep_base_value != (int) SLEEPBASEVALUE)
  		sprintf(szCommand, "%s -s %d", szCommand, args->sleep_base_value);
  	if (args->sleep_scaling_factor != (float) SLEEPSCALINGFACTOR)
--- 1412,1422 ----
  	if (args->port)
  		sprintf(szCommand, "%s -p %s", szCommand, args->port);
  	if (args->user)
! 		sprintf(szCommand, "%s -U \"%s\"", szCommand, args->user);
  	if (args->password)
! 		sprintf(szCommand, "%s -P \"%s\"", szCommand, args->password);
  	if (args->logfile)
! 		sprintf(szCommand, "%s -L \"%s\"", szCommand, args->logfile);
  	if (args->sleep_base_value != (int) SLEEPBASEVALUE)
  		sprintf(szCommand, "%s -s %d", szCommand, args->sleep_base_value);
  	if (args->sleep_scaling_factor != (float) SLEEPSCALINGFACTOR)
Only in pg_autovacuum: pg_autovacuum.exe
diff -c pg_autovacuum.orig/pg_autovacuum.h pg_autovacuum/pg_autovacuum.h
*** pg_autovacuum.orig/pg_autovacuum.h	Wed Nov 17 16:54:15 2004
--- pg_autovacuum/pg_autovacuum.h	Sat Nov 27 21:52:49 2004
***************
*** 68,73 ****
--- 68,74 ----
  	char	   *user,
  			   *password,
  #ifdef WIN32
+ 			   *service_dependencies,
  			   *service_user,
  			   *service_password,
  #endif
Only in pg_autovacuum: pg_autovacuum.o
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.