Re: stat() on Windows might cause error if target file is larger than 4GB

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Higuchi, Daisuke" <higuchi(dot)daisuke(at)jp(dot)fujitsu(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: stat() on Windows might cause error if target file is larger than 4GB
Date: 2018-09-12 03:47:31
Message-ID: 20180912034731.GF25160@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 11, 2018 at 11:27:08PM -0400, Tom Lane wrote:
> Michael Paquier <michael(at)paquier(dot)xyz> writes:
>> 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?

That's exactly what I would like to do and what I meant two paragraphs
above as that's the only solution I think would be clean, and this would
take care of st_size nicely. I have not tested (yet), but some tweaks
in win32_port.h could be enough before mapping lstat to stat?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2018-09-12 04:11:20 Re: Retrieve memory size allocated by libpq
Previous Message Tom Lane 2018-09-12 03:27:08 Re: stat() on Windows might cause error if target file is larger than 4GB