Make pg_dump behave more sanely when built without HAVE_LIBZ.
authorTom Lane
Thu, 26 May 2016 15:51:04 +0000 (11:51 -0400)
committerTom Lane
Thu, 26 May 2016 15:51:16 +0000 (11:51 -0400)
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[email protected]>

src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_dump.c

index 046611c39d2611861b5a51368a6f86c4935c1e06..76e39680992fe8d02bb5f7d00f75cf1df7c4f7ae 100644 (file)
@@ -3298,17 +3298,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);
index 2eab1d469bedbdeb1507fdd2561860a80234cda6..7af49750948ac1ac06dc3e0dedc10d6b510eb7d4 100644 (file)
@@ -603,12 +603,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