Skip to content

Commit 31156ce

Browse files
committed
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.
1 parent 264a6b1 commit 31156ce

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
264264
if (strcmp(basedir, "-") == 0)
265265
{
266266
#ifdef HAVE_LIBZ
267-
if (compresslevel > 0)
267+
if (compresslevel != 0)
268268
{
269269
ztarfile = gzdopen(dup(fileno(stdout)), "wb");
270270
if (gzsetparams(ztarfile, compresslevel, Z_DEFAULT_STRATEGY) != Z_OK)
@@ -281,7 +281,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
281281
else
282282
{
283283
#ifdef HAVE_LIBZ
284-
if (compresslevel > 0)
284+
if (compresslevel != 0)
285285
{
286286
snprintf(fn, sizeof(fn), "%s/base.tar.gz", basedir);
287287
ztarfile = gzopen(fn, "wb");
@@ -305,7 +305,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
305305
* Specific tablespace
306306
*/
307307
#ifdef HAVE_LIBZ
308-
if (compresslevel > 0)
308+
if (compresslevel != 0)
309309
{
310310
snprintf(fn, sizeof(fn), "%s/%s.tar.gz", basedir, PQgetvalue(res, rownum, 0));
311311
ztarfile = gzopen(fn, "wb");
@@ -325,7 +325,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
325325
}
326326

327327
#ifdef HAVE_LIBZ
328-
if (compresslevel > 0)
328+
if (compresslevel != 0)
329329
{
330330
if (!ztarfile)
331331
{
@@ -976,7 +976,7 @@ main(int argc, char **argv)
976976
}
977977
}
978978

979-
while ((c = getopt_long(argc, argv, "D:F:l:Z:c:h:p:U:xwWvP",
979+
while ((c = getopt_long(argc, argv, "D:F:xl:zZ:c:h:p:U:wWvP",
980980
long_options, &option_index)) != -1)
981981
{
982982
switch (c)
@@ -1089,7 +1089,7 @@ main(int argc, char **argv)
10891089
/*
10901090
* Mutually exclusive arguments
10911091
*/
1092-
if (format == 'p' && compresslevel > 0)
1092+
if (format == 'p' && compresslevel != 0)
10931093
{
10941094
fprintf(stderr,
10951095
_("%s: only tar mode backups can be compressed\n"),
@@ -1100,7 +1100,7 @@ main(int argc, char **argv)
11001100
}
11011101

11021102
#ifndef HAVE_LIBZ
1103-
if (compresslevel > 0)
1103+
if (compresslevel != 0)
11041104
{
11051105
fprintf(stderr,
11061106
_("%s: this build does not support compression\n"),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy