From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Haribabu Kommi <kommi.haribabu@gmail.com>
Cc: henry_boehlert@agilent.com, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: BUG #14634: On Windows pg_basebackup should write tar to stdout in binary mode
Date: Fri, 14 Jul 2017 16:07:46 +0300
Message-ID: <49d09912-6ad5-ddac-24a7-e7d4b8139a3e@iki.fi> (raw)
In-Reply-To: <CAJrrPGdogN7GPyU+yWXH9gTMAhOBM4nmWBLq6i4jo-n+aYo74A@mail.gmail.com>
References: <20170428082818.24366.13134@wrigleys.postgresql.org>
<CAJrrPGeU=xWvFBvpGoHqTTGo-__iqUUFRNAZGXPGMymFWVQYXA@mail.gmail.com>
<931e755b-02df-d504-e5ad-eaeaa6ab9cd3@iki.fi>
<CAJrrPGdogN7GPyU+yWXH9gTMAhOBM4nmWBLq6i4jo-n+aYo74A@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 07/14/2017 05:27 AM, Haribabu Kommi wrote:
> On Fri, Jul 14, 2017 at 2:54 AM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>
>> On 05/03/2017 07:32 AM, Haribabu Kommi wrote:
>>
>>> [Adding -hackers mailing list]
>>>
>>> On Fri, Apr 28, 2017 at 6:28 PM, <henry_boehlert@agilent.com> wrote:
>>>
>>>> Executing command pg_basebackup -D -F t writes its output to stdout,
>>>> which
>>>> is open in text mode, causing LF to be converted to CR LF thus corrupting
>>>> the resulting archive.
>>>>
>>>> To write the tar to stdout, on Windows stdout's mode should be
>>>> temporarily
>>>> switched to binary.
>>>>
>>>> https://msdn.microsoft.com/en-us/library/tw4k6df8.aspx
>>>
>>> Thanks for reporting the issue.
>>> With the attached patch, I was able to extract the tar file that gets
>>> generated when the tar file is written into stdout. I tested the
>>> the compressed tar also.
>>>
>>> This bug needs to be fixed in back branches also.
>>
>> Seems reasonable. One question:
>>
>> In the patch, you used "_setmode" function, while the calls in
>> src/bin/pg_dump/pg_backup_archiver.c use "setmode". There are a few
>> places in the backend that also use "_setmode". What's the difference?
>> Should we change some of them to be consistent?
>
> Actually there is no functional difference between these two functions.
> one is a POSIX variant and another one is ISO C++ variant [1]. The support
> of POSIX variant is deprecated in windows, because of this reason we should
> use the _setmode instead of setmode.
>
> I attached the patch to change the pg_dump code to use _setmode function
> instead of _setmode to be consistent with other functions.
Ok, committed and backpatched both patches. Thanks!
- Heikki
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: hlinnaka@iki.fi, kommi.haribabu@gmail.com, pgsql-hackers@postgresql.org
Subject: Re: BUG #14634: On Windows pg_basebackup should write tar to stdout in binary mode
In-Reply-To: <49d09912-6ad5-ddac-24a7-e7d4b8139a3e@iki.fi>
References: <20170428082818.24366.13134@wrigleys.postgresql.org> <CAJrrPGeU=xWvFBvpGoHqTTGo-__iqUUFRNAZGXPGMymFWVQYXA@mail.gmail.com> <931e755b-02df-d504-e5ad-eaeaa6ab9cd3@iki.fi> <CAJrrPGdogN7GPyU+yWXH9gTMAhOBM4nmWBLq6i4jo-n+aYo74A@mail.gmail.com> <49d09912-6ad5-ddac-24a7-e7d4b8139a3e@iki.fi>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox