On 04/29/2014 09:14 PM, Nikhil Deshpande wrote:
On win32, initdb fails if it's path includes a space and at ('@')
character. E.g.

C:\>"C:\Program Files\user@company\Postgres\9.3\bin\initdb.exe" -D "c:\baz"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Here's a patch that fixes initdb by enclosing the command string in
extra double quotes being passed to popen() (similar to system() call).

This looks correct to me. popen() requires SYSTEMQUOTEs on Windows, like system() does. We already use SYSTEMQUOTEs in some popen() calls, like in pg_ctl, but initdb is missing them. get_bin_version function in pg_upgrade is also missing it, as is the popen() call in COPY TO/FROM PROGRAM command.

Is there any situation where would *not* want to wrap the command in SYSTEMQUOTEs? If there isn't, ISTM it would be better to create a wrapper function, pgwin32_popen(), which adds the quotes instead of sprinkling them into all callers. Even if we go around and fix all of the callers now, we're bound to forget it again in the future.

- Heikki


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to