Re: stat() on Windows might cause error if target file is larger than 4GB - Mailing list pgsql-hackers

From Tom Lane
Subject Re: stat() on Windows might cause error if target file is larger than 4GB
Date
Msg-id 1513.1536722828@sss.pgh.pa.us
Whole thread Raw
In response to Re: stat() on Windows might cause error if target file is largerthan 4GB  (Michael Paquier <michael@paquier.xyz>)
Responses Re: stat() on Windows might cause error if target file is largerthan 4GB  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
Michael Paquier <michael@paquier.xyz> writes:
> At the end, I have finally been able to put my hands on a Windows VM
> which uses VS2015, and I am able to see the problem.  In short, Windows
> definition of stat() is an utter mess as this documentation page, which
> is the latest one available, nicely summarizes:
> https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions?view=vs-2017

Egad.

> It is possible to get away with the error by using _stat64(), which
> returns as result a _stat64 structure.  Still, it has one difference
> with the native result returned by stat() (which maps to _stat64i32) as
> st_size is a 32-bit integer in _stat64i32, and a 64-bit integer with
> _stat64.  This mess is mixed also with the fact that pgwin32_safestat
> relies on a result stored in _stat, so we'd lose the 32 high bits from
> the size if we only do a direct mapping, which is bad.

Could we fix things so that Postgres thinks that struct stat is
struct __stat64?  That is, act as though that variant is the native
stat structure?

            regards, tom lane


pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: stat() on Windows might cause error if target file is largerthan 4GB
Next
From: Michael Paquier
Date:
Subject: Re: stat() on Windows might cause error if target file is largerthan 4GB