Re: More time spending with "delete pending" - Mailing list pgsql-hackers

From Juan José Santamaría Flecha
Subject Re: More time spending with "delete pending"
Date
Msg-id CAC+AXB3Ckp+ErgqrDutQ5LQZUubnt3OYBki0WTVcx7CqOQajDA@mail.gmail.com
Whole thread Raw
In response to Re: More time spending with "delete pending"  (Alexander Lakhin <exclusion@gmail.com>)
List pgsql-hackers

On Sun, Nov 15, 2020 at 4:00 PM Alexander Lakhin <exclusion@gmail.com> wrote:
As I've found out, readdir() replacement for Windows in fact gets all
the needed information (correct file size, attributes...) in
WIN32_FIND_DATA, but it just leaves it inside and returns only fields of
the dirent structure. So pg_ls_dir_files() (that calls
ReadDir()/readdir()) needs to get this information again, that leads to
opening a file on Windows.
I think it can be done more effectively by adding a new function
ReadDirExtendedInfo(), that will additionally accept a pointer to
"struct dirent_extra" with fields {valid (indicating that the structure
is filled), attributes, file size, mtime}. Maybe the advanced function
could also invoke stat() inside (not on Windows).

As to patch I proposed before, I think it's still needed to fully
support the following usage pattern:
stat();
if (no_error) {
    do_something();
} else if (file_not_found) {
    do_something_else();
} else {
    error();
}

We are currently missing a WIN32 lstat() port. I was thinking about proposing a patch to implement it using GetFileAttributesEx(). That might work as fall back to the CreateFile() if the file attribute is not a FILE_ATTRIBUTE_REPARSE_POINT.

Anyhow, I do not think any retry logic should be in the stat() function, but in the caller.

Regards,

Juan José Santamaría Flecha
 

pgsql-hackers by date:

Previous
From: Li Japin
Date:
Subject: Re: Terminate the idle sessions
Next
From: Shawn Wang
Date:
Subject: Re: ECPG: proposal for new DECLARE STATEMENT