From: | Paul Guo <paulguo(at)gmail(dot)com> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Use access() to check file existence in GetNewRelFileNode(). |
Date: | 2018-05-17 09:23:28 |
Message-ID: | CABQrizfczjNhAY1+bMLZCrSLFE24w=UOYNYW5ovzsadmDnBZKA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
F_OK seems to be better than R_OK because we want to check file existence
(not read permission) before creating the relation file with the path
later.
2018-05-17 17:09 GMT+08:00 Michael Paquier <michael(at)paquier(dot)xyz>:
> On Thu, May 17, 2018 at 04:09:27PM +0800, Paul Guo wrote:
> > Previous code uses BasicOpenFile() + close().
> >
> > access() should be faster than BasicOpenFile()+close() and access()
> > should be more correct since BasicOpenFile() could fail for various
> > cases (e.g. due to file permission, etc) even the file exists.
>
> Failing because of file permissions would be correct. There have been
> cases in the past, particularly on Windows, where anti-virus softwares
> wildly scan files, causing EACCES on various points of the data folder.
>
> > access() is supported on Linux/Unix. I do not have a Windows dev
> > environment, but MSDN tells me that access() is supported on Windows also
> > and there have been access() call in the workspace, so I assume there is
> no
> > portability issue.
>
> Yes, access() is spread already in the core code.
>
> - fd = BasicOpenFile(rpath, O_RDONLY | PG_BINARY);
>
> - if (fd >= 0)
> + if (access(rpath, F_OK) == 0)
>
> What you are looking for here is R_OK, no?
> --
> Michael
>
From | Date | Subject | |
---|---|---|---|
Next Message | Konstantin Knizhnik | 2018-05-17 09:31:09 | Re: Possible bug in logical replication. |
Previous Message | Michael Paquier | 2018-05-17 09:09:50 | Re: [PATCH] Use access() to check file existence in GetNewRelFileNode(). |