Re: stat() vs ERROR_DELETE_PENDING, round N + 1
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>, Alexander Lakhin <exclusion@gmail.com>, Michael Paquier <michael@paquier.xyz>, Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2021-12-06T08:17:54Z
Lists: pgsql-hackers
Attachments
- v4-0001-Check-for-STATUS_DELETE_PENDING-on-Windows.patch (text/x-patch) patch v4-0001
On Sat, Dec 4, 2021 at 6:18 PM Thomas Munro <thomas.munro@gmail.com> wrote: > On Thu, Dec 2, 2021 at 3:11 AM Daniel Gustafsson <daniel@yesql.se> wrote: > > > This patch doesn't compile on Windows according to Appveyor, seemingly because > > > of a syntax error in the new win32ntdll.h file, but the MSVC logs are hard on > > > the eye so it might be unrelated. > I think this was broken by WIN32_LEAN_AND_MEAN (and since gained a > merge conflict, but that's easy to fix). I'll try to figure out the > right system header hacks to unbreak it... Short version: It needed <winternl.h>. Long version: Where Unix shares headers between user space and kernel with #ifdef _KERNEL, today I learned that Windows seems to have two universes of headers, with some stuff defined in both places. You can't cross the streams. I had already defined UMDF_USING_NTSTATUS, which tells <windows.h> that you're planning to include <ntstatus.h>, to avoid a bunch of double-definitions (the other approach I'd found on the 'net was to #define and #undef WIN32_NO_STATUS in the right places), but when WIN32_LEAN_AND_MEAN was added, that combination lost the definition of NTSTATUS, which is needed by various macros like WAIT_OBJECT_0 (it's used in casts). It's supposed to come from <ntdef.h>, but if you include that directly you get more double definitions of other random stuff. Eventually I learned that <winternl.h> fixes that. No doubt this is eroding the gains made by WIN32_LEAN_AND_MEAN, but I don't see how to avoid it until we do the work to stop including <windows.h> in win32_port.h. Well, I do know one way... I noticed that <bcrypt.h> just defines NTSTATUS itself if it sees that <ntdef.h> hasn't been included (by testing its include guard). I tried that and it worked, but it seems pretty ugly and not something that we should be doing.
Commits
-
Check for STATUS_DELETE_PENDING on Windows.
- e2f0f8ed251d 15.0 landed
-
Fix our Windows stat() emulation to handle file sizes > 4GB.
- bed90759fcbc 14.0 cited
-
Attempt to handle pending-delete files on Windows
- 9951741bbeb3 10.0 cited