Re: stat() vs ERROR_DELETE_PENDING, round N + 1

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: stat() vs ERROR_DELETE_PENDING, round N + 1
Date: 2021-12-06 08:17:54
Message-ID: CA+hUKGLdicsrNU_yJQUoDEySrvODbkBj7--tpDkKxA-9fAPwMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Dec 4, 2021 at 6:18 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Thu, Dec 2, 2021 at 3:11 AM Daniel Gustafsson <daniel(at)yesql(dot)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.

Attachment Content-Type Size
v4-0001-Check-for-STATUS_DELETE_PENDING-on-Windows.patch text/x-patch 17.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2021-12-06 08:44:51 Re: Alter all tables in schema owner fix
Previous Message Fujii Masao 2021-12-06 08:16:59 Re: Shouldn't postgres_fdw report warning when it gives up getting result from foreign server?