Re: pg_dump/pg_restore: Fix stdin/stdout handling of custom format on Win32

From: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Daniel Watzinger <daniel(dot)watzinger(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_dump/pg_restore: Fix stdin/stdout handling of custom format on Win32
Date: 2023-03-09 23:12:37
Message-ID: CAC+AXB23S=JiFY9jFWq3FTHByNZZn37f9v3h=7j5UsbumqHKBw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

>
> On Thu, Mar 2, 2023 at 8:01 AM Michael Paquier <michael(at)paquier(dot)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 Content-Type Size
v2-0002-improve-detection-file-type-for-WIN32-stat.patch application/octet-stream 2.8 KB
v2-0001-fix-chechSeek-for-WIN32.patch application/octet-stream 1.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-03-09 23:17:59 Re: Sub-millisecond [autovacuum_]vacuum_cost_delay broken
Previous Message Peter Smith 2023-03-09 23:06:02 Add macros for ReorderBufferTXN toptxn