[HACKERS] BUG: pg_dump generates corrupted gzip file in Windows
От | Kuntal Ghosh |
---|---|
Тема | [HACKERS] BUG: pg_dump generates corrupted gzip file in Windows |
Дата | |
Msg-id | CAGz5QCJPvbBjXAmJuGx1B_41yVCetAJhp7rtaDf7XQGWuB1GSw@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: [HACKERS] BUG: pg_dump generates corrupted gzip file in Windows
|
Список | 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
Вложения
В списке pgsql-hackers по дате отправления: