Skip to content

Commit 64b2969

Browse files
committed
Make pg_dump behave more sanely when built without HAVE_LIBZ.
For some reason the code to emit a warning and switch to uncompressed output was placed down in the guts of pg_backup_archiver.c. This is definitely too late in the case of parallel operation (and I rather wonder if it wasn't too late for other purposes as well). Put it in pg_dump.c's option-processing logic, which seems a much saner place. Also, the default behavior with custom or directory output format was to emit the warning telling you the output would be uncompressed. This seems unhelpful, so silence that case. Back-patch to 9.3 where parallel dump was introduced. Kyotaro Horiguchi, adjusted a bit by me Report: <20160526.185551.242041780.horiguchi.kyotaro@lab.ntt.co.jp>
1 parent 6479df1 commit 64b2969

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3413,17 +3413,7 @@ WriteHead(ArchiveHandle *AH)
34133413
(*AH->WriteBytePtr) (AH, AH->intSize);
34143414
(*AH->WriteBytePtr) (AH, AH->offSize);
34153415
(*AH->WriteBytePtr) (AH, AH->format);
3416-
3417-
#ifndef HAVE_LIBZ
3418-
if (AH->compression != 0)
3419-
write_msg(modulename, "WARNING: requested compression not available in this "
3420-
"installation -- archive will be uncompressed\n");
3421-
3422-
AH->compression = 0;
3423-
#endif
3424-
34253416
WriteInt(AH, AH->compression);
3426-
34273417
crtm = *localtime(&AH->createDate);
34283418
WriteInt(AH, crtm.tm_sec);
34293419
WriteInt(AH, crtm.tm_min);

src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,21 @@ main(int argc, char **argv)
579579
/* Custom and directory formats are compressed by default, others not */
580580
if (compressLevel == -1)
581581
{
582+
#ifdef HAVE_LIBZ
582583
if (archiveFormat == archCustom || archiveFormat == archDirectory)
583584
compressLevel = Z_DEFAULT_COMPRESSION;
584585
else
586+
#endif
585587
compressLevel = 0;
586588
}
587589

590+
#ifndef HAVE_LIBZ
591+
if (compressLevel != 0)
592+
write_msg(NULL, "WARNING: requested compression not available in this "
593+
"installation -- archive will be uncompressed\n");
594+
compressLevel = 0;
595+
#endif
596+
588597
/*
589598
* On Windows we can only have at most MAXIMUM_WAIT_OBJECTS (= 64 usually)
590599
* parallel jobs because that's the maximum limit for the

0 commit comments

Comments
 (0)