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

From Kuntal Ghosh
Subject [HACKERS] BUG: pg_dump generates corrupted gzip file in Windows
Date
Msg-id CAGz5QCJPvbBjXAmJuGx1B_41yVCetAJhp7rtaDf7XQGWuB1GSw@mail.gmail.com
Whole thread Raw
Responses Re: [HACKERS] BUG: pg_dump generates corrupted gzip file in Windows  (Kuntal Ghosh <kuntalghosh.2007@gmail.com>)
List pgsql-hackers
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).

I'm referring the following part of pg_dump code:

    /*
     * On Windows, we need to use binary mode to read/write non-text archive
     * formats.  Force stdin/stdout into binary mode if that is what we are
     * using.
     */
#ifdef WIN32
    if (fmt != archNull &&
        (AH->fSpec == NULL || strcmp(AH->fSpec, "") == 0))
    {
        if (mode == archModeWrite)
            setmode(fileno(stdout), O_BINARY);
        else
            setmode(fileno(stdin), O_BINARY);
    }
#endif

For plain-text format, fmt is set to archNull. In that case, the
binary mode will not be forced(I think). To fix this, I've attached a
patch which adds one extra check in the 'if condition' to check the
compression level. PFA.


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

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachment

pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: [HACKERS] create_unique_path and GEQO
Next
From: Fabien COELHO
Date:
Subject: Re: [pgsql-www] [HACKERS] Small issue in online devel documentationbuild