Re: Fix fseek() detection of unseekable files on WIN32

From: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix fseek() detection of unseekable files on WIN32
Date: 2023-03-16 09:08:44
Message-ID: CAC+AXB0PcESdDEUCA16ofNBqrHvQBL4L4H9LH4GBWBm0xR3m0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 16, 2023 at 2:05 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:

> On Wed, Mar 15, 2023 at 12:18:25PM +0100, Juan José Santamaría Flecha
> wrote:
> > PFA a new version of the patch.
>
> +_pgftello64(FILE *stream)
> +{
> + DWORD fileType;
> +
> + fileType = GetFileType((HANDLE) _get_osfhandle(_fileno(stream)));
>
> Hmm. I am a bit surprised here.. It seems to me that we should make
> sure that:
> - We exist quickly if _get_osfhandle() returns -2 or
> INVALID_HANDLE_VALUE, returning EINVAL?
> - After GetFileType(), check for GetLastError() and the
> FILE_TYPE_UNKNOWN case?
>
> Do you think that these would be improvements?
>

IDK, this is just looking for the good case, anything else we'll fail with
ESPIPE or EINVAL anyway. If we want to get the proper file type we can call
fstat(), which has the full logic.

Regards,

Juan José Santamaría Flecha

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2023-03-16 09:19:31 Re: Add pg_walinspect function with block info columns
Previous Message Julien Rouhaud 2023-03-16 09:03:52 Re: pg_dump versus hash partitioning