aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-06-15 13:15:05 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-06-15 13:15:36 -0400
commitdc014e0446f5bfb52129fc6781a98b236d8166c6 (patch)
treedc79e0675e71c0fffebae0a0fbe710f7aba5f2a8 /src
parent2b44a2d62d12406da59fa6b23a0854d1d5068b17 (diff)
downloadpostgresql-dc014e0446f5bfb52129fc6781a98b236d8166c6.tar.gz
postgresql-dc014e0446f5bfb52129fc6781a98b236d8166c6.zip
Fix oversights in pg_basebackup's -z (compression) option.
The short-form -z switch didn't work, for lack of telling getopt_long about it; and even if specified long-form, it failed to do anything, because the various tests elsewhere in the file would take Z_DEFAULT_COMPRESSION (which is -1) as meaning "don't compress". Per bug #6060 from Shigehiro Honda, though I editorialized on his patch a bit.
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_basebackup/pg_basebackup.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 9bf1fcdc4b5..bafaab6c001 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -264,7 +264,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
if (strcmp(basedir, "-") == 0)
{
#ifdef HAVE_LIBZ
- if (compresslevel > 0)
+ if (compresslevel != 0)
{
ztarfile = gzdopen(dup(fileno(stdout)), "wb");
if (gzsetparams(ztarfile, compresslevel, Z_DEFAULT_STRATEGY) != Z_OK)
@@ -281,7 +281,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
else
{
#ifdef HAVE_LIBZ
- if (compresslevel > 0)
+ if (compresslevel != 0)
{
snprintf(fn, sizeof(fn), "%s/base.tar.gz", basedir);
ztarfile = gzopen(fn, "wb");
@@ -305,7 +305,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
* Specific tablespace
*/
#ifdef HAVE_LIBZ
- if (compresslevel > 0)
+ if (compresslevel != 0)
{
snprintf(fn, sizeof(fn), "%s/%s.tar.gz", basedir, PQgetvalue(res, rownum, 0));
ztarfile = gzopen(fn, "wb");
@@ -325,7 +325,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
}
#ifdef HAVE_LIBZ
- if (compresslevel > 0)
+ if (compresslevel != 0)
{
if (!ztarfile)
{
@@ -976,7 +976,7 @@ main(int argc, char **argv)
}
}
- while ((c = getopt_long(argc, argv, "D:F:l:Z:c:h:p:U:xwWvP",
+ while ((c = getopt_long(argc, argv, "D:F:xl:zZ:c:h:p:U:wWvP",
long_options, &option_index)) != -1)
{
switch (c)
@@ -1089,7 +1089,7 @@ main(int argc, char **argv)
/*
* Mutually exclusive arguments
*/
- if (format == 'p' && compresslevel > 0)
+ if (format == 'p' && compresslevel != 0)
{
fprintf(stderr,
_("%s: only tar mode backups can be compressed\n"),
@@ -1100,7 +1100,7 @@ main(int argc, char **argv)
}
#ifndef HAVE_LIBZ
- if (compresslevel > 0)
+ if (compresslevel != 0)
{
fprintf(stderr,
_("%s: this build does not support compression\n"),