Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)

From: Andres Freund <andres(at)anarazel(dot)de>
To: Ryan Murphy <ryanfmurphy(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)
Date: 2016-08-16 23:05:17
Message-ID: 20160816230517.vo43steejci6em3q@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2016-08-14 10:12:45 -0500, Ryan Murphy wrote:
> Hello Postgres Team!
> but this command did not work for me because my data directory
> contained a space. The src/bin/initdb/initdb.c source code
> did already have a QUOTE_PATH constant, but it was the empty
> string for non-windows cases.
>
> Therefore, added quotes via existing QUOTE_PATH constant:
>
> pg_ctl -D '/some/path/to/data' -l logfile start

> From 275d045bc41b136df8c413eedba12fbd21609de1 Mon Sep 17 00:00:00 2001
> From: ryanfmurphy <ryanfmurphy(at)gmail(dot)com>
> Date: Sun, 14 Aug 2016 08:56:50 -0500
> Subject: [PATCH] initdb: "'" for QUOTE_PATH (non-windows)
>
> fix issue when running initdb
>
> at the end of a successful initdb it says:
>
> Success. You can now start the database server using:
> pg_ctl -D /some/path/to/data -l logfile start
>
> but this command will not work if the data directory contains a space
> therefore, added quotes via existing QUOTE_PATH constant:
>
> pg_ctl -D '/some/path/to/data' -l logfile start
> ---
> src/bin/initdb/initdb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
> index 73cb7ee..6dc1e23 100644
> --- a/src/bin/initdb/initdb.c
> +++ b/src/bin/initdb/initdb.c
> @@ -332,7 +332,7 @@ do { \
> } while (0)
>
> #ifndef WIN32
> -#define QUOTE_PATH ""
> +#define QUOTE_PATH "'"
> #define DIR_SEP "/"
> #else
> #define QUOTE_PATH "\""

ISTM that the correct fix would be to actually introduce something like
quote_path_for_shell() which either adds proper quotes, or fails if
that'd be hard (e.g. if the path contains quotes, and we're on
windows).

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Browne 2016-08-16 23:12:31 Re: [GENERAL] C++ port of Postgres
Previous Message Ryan Murphy 2016-08-16 22:53:13 Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)