drop tablespace failed when location contains .. on win32

From: "wangsh(dot)fnst(at)fujitsu(dot)com" <wangsh(dot)fnst(at)fujitsu(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: drop tablespace failed when location contains .. on win32
Date: 2021-09-08 10:16:46
Message-ID: OSBPR01MB4214FA221FFE046F11F2AD74F2D49@OSBPR01MB4214.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I find a problem related to tablespace on win32(server2019).

> postgres=# create tablespace tbs location 'C:\Users\postgres\postgres_install\aa\..\aa';
> CREATE TABLESPACE
> postgres=# create table tbl(col int) tablespace tbs;
> ERROR: could not stat directory "pg_tblspc/16384/PG_15_202109061/12754": Invalid argument
> postgres=# drop tablespace tbs;
> WARNING: could not open directory "pg_tblspc/16384/PG_15_202109061": No such file or directory
> ERROR: could not stat file "pg_tblspc/16384": Invalid argument

I find that canonicalize_path() only remove the trailing '..', in this case, '..' is not removed , and
pgsymlink succeed.

But, in fact, if I double click the dir (%PGDATA%\pg_tblspac\16387), the error message is shown:
> The filename, directory name, or volume label syntax is incorrect.

Since the pgsymlink() seems right and I'm not sure I can change the action of canonicalize_path,
so I want to add a error check(patch is attached).

Any comment ?

Regards,
Shenhao Wang

Attachment Content-Type Size
problem.diff application/octet-stream 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2021-09-08 10:19:19 Re: ResourceOwner refactoring
Previous Message Drouvot, Bertrand 2021-09-08 10:08:43 Re: Minimal logical decoding on standbys