aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/compress_io.c
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2015-07-25 17:14:36 -0400
committerAndrew Dunstan <andrew@dunslane.net>2015-07-25 17:15:48 -0400
commit41ed5bb9aeddddbe8f8afb901567fd5f306d2a45 (patch)
tree0bcf5509f0937d6aa6f45934785e4467c48cbbb5 /src/bin/pg_dump/compress_io.c
parentb7551339dfde58682dfd9f32f6cea27491da6463 (diff)
downloadpostgresql-41ed5bb9aeddddbe8f8afb901567fd5f306d2a45.tar.gz
postgresql-41ed5bb9aeddddbe8f8afb901567fd5f306d2a45.zip
Restore use of zlib default compression in pg_dump directory mode.
This was broken by commit 0e7e355f27302b62af3e1add93853ccd45678443 and friends, which ignored the fact that gzopen() will treat "-1" in the mode argument as an invalid character, which it ignores, and a flag for compression level 1. Now, when this value is encountered no compression level flag is passed to gzopen, leaving it to use the zlib default. Also, enforce the documented allowed range for pg_dump's -Z option, namely 0 .. 9, and remove some consequently dead code from pg_backup_tar.c. Problem reported by Marc Mamin. Backpatch to 9.1, like the patch that introduced the bug.
Diffstat (limited to 'src/bin/pg_dump/compress_io.c')
-rw-r--r--src/bin/pg_dump/compress_io.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/bin/pg_dump/compress_io.c b/src/bin/pg_dump/compress_io.c
index ffced11a02e..9511313dd6e 100644
--- a/src/bin/pg_dump/compress_io.c
+++ b/src/bin/pg_dump/compress_io.c
@@ -546,11 +546,21 @@ cfopen(const char *path, const char *mode, int compression)
if (compression != 0)
{
#ifdef HAVE_LIBZ
- char mode_compression[32];
+ if (compression != Z_DEFAULT_COMPRESSION)
+ {
+ /* user has specified a compression level, so tell zlib to use it */
+ char mode_compression[32];
+
+ snprintf(mode_compression, sizeof(mode_compression), "%s%d",
+ mode, compression);
+ fp->compressedfp = gzopen(path, mode_compression);
+ }
+ else
+ {
+ /* don't specify a level, just use the zlib default */
+ fp->compressedfp = gzopen(path, mode);
+ }
- snprintf(mode_compression, sizeof(mode_compression), "%s%d",
- mode, compression);
- fp->compressedfp = gzopen(path, mode_compression);
fp->uncompressedfp = NULL;
if (fp->compressedfp == NULL)
{