Re: Fix initdb for path with whitespace and at char

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Nikhil Deshpande <nikhail(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix initdb for path with whitespace and at char
Date: 2014-04-30 10:31:53
Message-ID: 5360D119.4070708@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sign\install". I suspect it doesn't, but the attached patch
fixes it.

- Heikki

Attachment Content-Type Size
0001-Replace-SYSTEMQUOTEs-with-Windows-specific-wrapper-f.patch text/x-diff 26.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-04-30 11:18:07 Re: includedir_internal headers are not self-contained
Previous Message Etsuro Fujita 2014-04-30 08:10:50 Re: Minor improvement to fdwhandler.sgml