diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-05-26 11:51:04 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-05-26 11:51:04 -0400 |
commit | cae2bb1986bc8fd409424562638434d588d0201f (patch) | |
tree | afdf62ed39089c5dc32de2470a4ec38b893677b9 /src | |
parent | df8d2d8c42c5731ad997793cb6a59b617532dffa (diff) | |
download | postgresql-cae2bb1986bc8fd409424562638434d588d0201f.tar.gz postgresql-cae2bb1986bc8fd409424562638434d588d0201f.zip |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/pg_dump/pg_backup_archiver.c | 10 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_dump.c | 9 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 9390a6b837e..8ffd8f7cad1 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -3475,17 +3475,7 @@ WriteHead(ArchiveHandle *AH) (*AH->WriteBytePtr) (AH, AH->intSize); (*AH->WriteBytePtr) (AH, AH->offSize); (*AH->WriteBytePtr) (AH, AH->format); - -#ifndef HAVE_LIBZ - if (AH->compression != 0) - write_msg(modulename, "WARNING: requested compression not available in this " - "installation -- archive will be uncompressed\n"); - - AH->compression = 0; -#endif - WriteInt(AH, AH->compression); - crtm = *localtime(&AH->createDate); WriteInt(AH, crtm.tm_sec); WriteInt(AH, crtm.tm_min); diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 2848fa995f1..a958225f1f8 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -589,12 +589,21 @@ main(int argc, char **argv) /* Custom and directory formats are compressed by default, others not */ if (compressLevel == -1) { +#ifdef HAVE_LIBZ if (archiveFormat == archCustom || archiveFormat == archDirectory) compressLevel = Z_DEFAULT_COMPRESSION; else +#endif compressLevel = 0; } +#ifndef HAVE_LIBZ + if (compressLevel != 0) + write_msg(NULL, "WARNING: requested compression not available in this " + "installation -- archive will be uncompressed\n"); + compressLevel = 0; +#endif + /* * On Windows we can only have at most MAXIMUM_WAIT_OBJECTS (= 64 usually) * parallel jobs because that's the maximum limit for the |