Skip to content

Commit 013f423

Browse files
committed
Fix pg_basebackup so that it accepts 0 as a valid compression level.
The help message for pg_basebackup specifies that the numbers 0 through 9 are accepted as valid values of -Z option. But, previously -Z 0 was rejected as an invalid compression level. Per discussion, it's better to make pg_basebackup treat 0 as valid compression level meaning no compression, like pg_dump. Back-patch to all supported versions. Reported-By: Jeff Janes Reviewed-By: Amit Kapila Discussion: CAMkU=1x+GwjSayc57v6w87ij6iRGFWt=hVfM0B64b1_bPVKRqg@mail.gmail.com
1 parent 9c6e594 commit 013f423

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

doc/src/sgml/ref/pg_basebackup.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ PostgreSQL documentation
283283
<listitem>
284284
<para>
285285
Enables gzip compression of tar file output, and specifies the
286-
compression level (1 through 9, 9 being best
286+
compression level (0 through 9, 0 being no compression and 9 being best
287287
compression). Compression is only available when using the tar
288288
format.
289289
</para>

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ main(int argc, char **argv)
17891789
break;
17901790
case 'Z':
17911791
compresslevel = atoi(optarg);
1792-
if (compresslevel <= 0 || compresslevel > 9)
1792+
if (compresslevel < 0 || compresslevel > 9)
17931793
{
17941794
fprintf(stderr, _("%s: invalid compression level \"%s\"\n"),
17951795
progname, optarg);

0 commit comments

Comments
 (0)