Re: pg_dump/pg_restore: Fix stdin/stdout handling of custom format on Win32 - Mailing list pgsql-hackers

From Juan José Santamaría Flecha
Subject Re: pg_dump/pg_restore: Fix stdin/stdout handling of custom format on Win32
Date
Msg-id CAC+AXB23S=JiFY9jFWq3FTHByNZZn37f9v3h=7j5UsbumqHKBw@mail.gmail.com
Whole thread Raw
In response to Re: pg_dump/pg_restore: Fix stdin/stdout handling of custom format on Win32  (Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>)
Responses Re: pg_dump/pg_restore: Fix stdin/stdout handling of custom format on Win32
List pgsql-hackers

On Tue, Mar 7, 2023 at 1:36 PM Juan José Santamaría Flecha <juanjo.santamaria@gmail.com> wrote:

On Thu, Mar 2, 2023 at 8:01 AM Michael Paquier <michael@paquier.xyz> wrote:

The internal implementation of _pgstat64() is used in quite a few
places, so we'd better update this part first, IMO, and then focus on
the pg_dump part.  Anyway, it looks like you are right here: there is
nothing for FILE_TYPE_PIPE or FILE_TYPE_CHAR in this WIN32
implementation of fstat().

I am amazed to hear that both ftello64() and fseek64() actually
succeed if you use a pipe:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fseek.html
Could it be something we should try to make more portable by ourselves
with a wrapper for these on WIN32?  That would not be the first one to
accomodate our code with POSIX, and who knows what code could be broken
because of that, like external extensions that use fseek64() without
knowing it.

The error is reproducible in versions previous to win32stat.c, so that might work as bug fix.

I've broken the patch in two:
1. fixes the detection of unseekable files in checkSeek(), using logic that hopefully is backpatchable,
2. the improvements on file type detection for stat() proposed by the OP.

Regards,

Juan José Santamaría Flecha
Attachment

pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Add macros for ReorderBufferTXN toptxn
Next
From: Tom Lane
Date:
Subject: Re: Sub-millisecond [autovacuum_]vacuum_cost_delay broken