Skip to content

Commit 99565a1

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 b9784e1 commit 99565a1

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
@@ -3214,17 +3214,7 @@ WriteHead(ArchiveHandle *AH)
32143214
(*AH->WriteBytePtr) (AH, AH->intSize);
32153215
(*AH->WriteBytePtr) (AH, AH->offSize);
32163216
(*AH->WriteBytePtr) (AH, AH->format);
3217-
3218-
#ifndef HAVE_LIBZ
3219-
if (AH->compression != 0)
3220-
write_msg(modulename, "WARNING: requested compression not available in this "
3221-
"installation -- archive will be uncompressed\n");
3222-
3223-
AH->compression = 0;
3224-
#endif
3225-
32263217
WriteInt(AH, AH->compression);
3227-
32283218
crtm = *localtime(&AH->createDate);
32293219
WriteInt(AH, crtm.tm_sec);
32303220
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
@@ -595,12 +595,21 @@ main(int argc, char **argv)
595595
/* Custom and directory formats are compressed by default, others not */
596596
if (compressLevel == -1)
597597
{
598+
#ifdef HAVE_LIBZ
598599
if (archiveFormat == archCustom || archiveFormat == archDirectory)
599600
compressLevel = Z_DEFAULT_COMPRESSION;
600601
else
602+
#endif
601603
compressLevel = 0;
602604
}
603605

606+
#ifndef HAVE_LIBZ
607+
if (compressLevel != 0)
608+
write_msg(NULL, "WARNING: requested compression not available in this "
609+
"installation -- archive will be uncompressed\n");
610+
compressLevel = 0;
611+
#endif
612+
604613
/*
605614
* On Windows we can only have at most MAXIMUM_WAIT_OBJECTS (= 64 usually)
606615
* parallel jobs because that's the maximum limit for the

0 commit comments

Comments
 (0)