Re: BUG #15858: could not stat file - over 4GB - Mailing list pgsql-hackers

From Juan José Santamaría Flecha
Subject Re: BUG #15858: could not stat file - over 4GB
Date
Msg-id CAC+AXB0f-pGWb2Rx1amCRCpjKohKLQ4L+Vsy7JaeHVgwJgbnGA@mail.gmail.com
Whole thread Raw
In response to Re: BUG #15858: could not stat file - over 4GB  (Michael Paquier <michael@paquier.xyz>)
Responses Re: BUG #15858: could not stat file - over 4GB  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Sat, Oct 10, 2020 at 2:24 PM Michael Paquier <michael@paquier.xyz> wrote:

-               _dosmaperr(GetLastError());
+               DWORD           err = GetLastError();
+
+               /* report when not ERROR_SUCCESS */
+               if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
+                       errno = ENOENT;
+               else
+                       _dosmaperr(err);
Why are you changing that?  The original coding is fine, as
_dosmaperr() already maps ERROR_FILE_NOT_FOUND and
ERROR_PATH_NOT_FOUND to ENOENT.

If the file does not exist there is no need to call _dosmaperr() and log the error. 

-      _dosmaperr(GetLastError());
+      DWORD           err = GetLastError();
+
       CloseHandle(hFile);
+      _dosmaperr(err);
These parts are indeed incorrect.  CloseHandle() could overwrite
errno.

The meaningful error should come from the previous call, and an error from CloseHandle() could mask it. Not sure it makes a difference anyhow.

Regards,

Juan José Santamaría Flecha

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #15858: could not stat file - over 4GB
Next
From: Andrey Borodin
Date:
Subject: Re: Batching page logging during B-tree build