Re: Fix initdb for path with whitespace and at char

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: Nikhil Deshpande <nikhail(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fix initdb for path with whitespace and at char
Date: 2014-04-29 19:21:37
Message-ID: 535FFBC1.2020402@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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(at)company\Postgres\9(dot)3\bin\initdb(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2014-04-29 19:51:20 Re: Buildfarm "master-next" branch?
Previous Message Jim Nasby 2014-04-29 19:11:27 Re: Buildfarm "master-next" branch?