Re: [HACKERS] BUG: pg_dump generates corrupted gzip file in Windows - Mailing list pgsql-hackers

From Kuntal Ghosh
Subject Re: [HACKERS] BUG: pg_dump generates corrupted gzip file in Windows
Date
Msg-id CAGz5QCLMY3KoU-Djwb_AKbDNwDyGPhSqnzZP43WYgnHQ6bxihg@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] BUG: pg_dump generates corrupted gzip file in Windows  (Kuntal Ghosh <kuntalghosh.2007@gmail.com>)
Responses Re: BUG: pg_dump generates corrupted gzip file in Windows  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Fri, Mar 24, 2017 at 2:17 PM, Kuntal Ghosh
<kuntalghosh.2007@gmail.com> wrote:
> On Fri, Mar 24, 2017 at 12:35 PM, Craig Ringer <craig@2ndquadrant.com> wrote:
>> On 24 March 2017 at 14:07, Kuntal Ghosh <kuntalghosh.2007@gmail.com> wrote:
>>> On Fri, Mar 24, 2017 at 11:28 AM, Kuntal Ghosh
>>> <kuntalghosh.2007@gmail.com> wrote:
>>>> Hello,
>>>> In Windows, if one needs to take a dump in plain text format (this is
>>>> the default option, or can be specified using -Fp) with some level of
>>>> compression (-Z[0-9]), an output file has to
>>>> be specified. Otherwise, if the output is redirected to stdout, it'll
>>>> create a corrupted dump (cmd is set to ASCII mode, so it'll put
>>>> carriage returns in the file).
>>> To reproduce the issue, please use the following command in windows cmd:
>>>
>>> pg_dump -Z 9 test > E:\test_xu.backup
>>> pg_dump -Fp -Z 9 test > E:\test_xu.backup
>>
>> This is a known problem. It is not specific to PostgreSQL, it affects
>> any software that attempts to use stdin/stdout on Windows via cmd,
>> where it is not 8-bit clean.
>>
>> We don't just refuse to run with stdout as a destination because it's
>> perfectly sensible if you're not using cmd.exe. pg_dump cannot, as far
>> as I know, tell whether it's being invoked by cmd or something else.
> ASAICU, if we use binary mode, output is stored bit by bit. In ASCII
> mode, cmd pokes its nose and does CR / LF conversions on its own. So,
> whenever we want compression on a plain-text dump file, we can set the
> stdout mode to O_BINARY. Is it a wrong approach?
With the help from Ashutosh Sharma, I tested this in Windows
environment. Sadly, it still doesn't work. :( IMHO, we should document
the issue somewhere.



-- 
Thanks & Regards,
Kuntal Ghosh
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: [HACKERS] Re: [COMMITTERS] pgsql: Fix and simplify check forwhether we're running as Windows serv
Next
From: Amit Langote
Date:
Subject: Re: [HACKERS] Partition-wise join for join between (declaratively)partitioned tables