Re: drop tablespace failed when location contains .. on win32

Kyotaro Horiguchi <horikyota.ntt@gmail.com>

From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: michael@paquier.xyz
Cc: wangsh.fnst@fujitsu.com, andrew@dunslane.net, pgsql-hackers@lists.postgresql.org
Date: 2021-09-13T08:36:29Z
Lists: pgsql-hackers
At Mon, 13 Sep 2021 16:06:52 +0900, Michael Paquier <michael@paquier.xyz> wrote in 
> On Sun, Sep 12, 2021 at 07:33:23AM +0000, wangsh.fnst@fujitsu.com wrote:
> > 0001 is a small fix, because I find that is_absolute_path is not appropriate, 
> > see comment in skip_drive:
> > > * On Windows, a path may begin with "C:" or "//network/".
> 
>  #define is_absolute_path(filename) \
>  ( \
> -       IS_DIR_SEP((filename)[0]) || \
> +       (IS_DIR_SEP((filename)[0]) && IS_DIR_SEP((filename)[1])) || \
>         (isalpha((unsigned char) ((filename)[0])) && (filename)[1] == ':' && \
>          IS_DIR_SEP((filename)[2])) \
> With this change you would consider a path beginning with "/foo/.." as
> not being an absolute path, but that's not correct.  Or am I missing
>  something obvious?

Mmm. I haven't thought that so seriously, but '/hoge/foo/bar' doesn't
seem to be an absolute path on Windows since it lacks
"<dirver-letter>:" or "//hostname" part.  If we're on drive D:,
"/Program\ Files" doesn't mean "C:\Program\ Files" but "D:\Program\
Files".

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



Commits

  1. Simplify coding around path_contains_parent_reference().

  2. Make canonicalize_path() more canonical.