Thread: Re: [pgsql-hackers-win32] pg_autovacuum log paths can't contain spaces

Re: [pgsql-hackers-win32] pg_autovacuum log paths can't contain spaces

From
"Dave Page"
Date:

> -----Original Message-----
> From: pgsql-hackers-win32-owner@postgresql.org
> [mailto:pgsql-hackers-win32-owner@postgresql.org] On Behalf
> Of Barry Lind
> Sent: 21 September 2004 00:46
> To: pgsql-hackers-win32@postgresql.org
> Subject: [pgsql-hackers-win32] pg_autovacuum log paths can't
> contain spaces
>
> I just installed the beta2 Dev 3 version of the installer.
> When I went to go tryout pg_autovacuum I noticed two problem:
>
> 1) -P isn't working correctly.  -P is being interpreted as -p
> in the service code and it tries to use the password (-P)
> that I passed in as the port (-p).  I seem to recall a
> previous email about this and think this is already fixed in CVS.

Yup, it has been.

> 2) When I specify a path that contains spaces to the -L
> switch it doesn't work correctly.

The patch below should rectify this.

Regards, Dave.


Index: pg_autovacuum.c
===================================================================
RCS file:
/projects/cvsroot/pgsql-server/contrib/pg_autovacuum/pg_autovacuum.c,v
retrieving revision 1.21
diff -u -r1.21 pg_autovacuum.c
--- pg_autovacuum.c    14 Sep 2004 04:06:20 -0000    1.21
+++ pg_autovacuum.c    21 Sep 2004 09:10:22 -0000
@@ -1217,7 +1217,13 @@
     if (args->password)
         sprintf(szCommand, "%s -P %s", szCommand,
args->password);
     if (args->logfile)
-        sprintf(szCommand, "%s -L %s", szCommand,
args->logfile);
+    {
+        if (strstr(args->logfile, " "))
+            sprintf(szCommand, "%s -L \"%s\"", szCommand,
args->logfile);
+        else
+            sprintf(szCommand, "%s -L %s", szCommand,
args->logfile);
+    }
+
     if (args->sleep_base_value != (int) SLEEPBASEVALUE)
         sprintf(szCommand, "%s -s %i", szCommand,
args->sleep_base_value);
     if (args->sleep_scaling_factor != (float) SLEEPSCALINGFACTOR)