Re: Fix initdb for path with whitespace and at char - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Fix initdb for path with whitespace and at char
Date
Msg-id 5360D119.4070708@vmware.com
Whole thread Raw
In response to Re: Fix initdb for path with whitespace and at char  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Responses Re: Fix initdb for path with whitespace and at char  (Andrew Dunstan <andrew@dunslane.net>)
Re: Fix initdb for path with whitespace and at char  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Fix initdb for path with whitespace and at char  (Amit Kapila <amit.kapila16@gmail.com>)
List pgsql-hackers
I committed the non-invasive fixes to backbranches (and master too, just
to keep it in sync), but the attached is what I came up with for master.

There are a couple of places in the code where we have #ifdef WIN32 code
that uses CreateProcess with "CMD /C ..." directly. I believe those are
currently (ie. before this patch) wrong for cygwin builds. SYSTEMQUOTE
is defined as:

#if defined(WIN32) && !defined(__CYGWIN__)
#define SYSTEMQUOTE "\""
#else
#define SYSTEMQUOTE ""
#endif

I presume the !CYGWIN part is because cygwin version of system() and
popen() don't require the extra quoting, because cygwin does that for
us. But when we use CreateProcess directly, e.g like this in pg_ctl.c:

   snprintf(cmd, MAXPGPATH, "CMD /C " SYSTEMQUOTE "\"\"%s\" %s%s <
\"%s\" 2>&1\"" SYSTEMQUOTE,
            exec_path, pgdata_opt, post_opts, DEVNULL);

   if (!CreateRestrictedProcess(cmd, &pi, false))
     return GetLastError();

we would need the extra quotes, but SYSTEMQUOTE doesn't provide them
with cygwin.


Andrew: you have a cygwin installation, don't you? Could you test if
"pg_ctl start" works when the binaries are installed to a path that
contains both a space and an @ sign, like "C:\white
space\at@sign\install". I suspect it doesn't, but the attached patch
fixes it.

- Heikki

Attachment

pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Re: Minor improvement to fdwhandler.sgml
Next
From: Heikki Linnakangas
Date:
Subject: Re: includedir_internal headers are not self-contained