pg_basebackup: Cleaner handling when compression is multiply specified.
authorRobert Haas <rhaas@postgresql.org>
Fri, 28 Jan 2022 16:40:53 +0000 (11:40 -0500)
committerRobert Haas <rhaas@postgresql.org>
Fri, 28 Jan 2022 16:40:53 +0000 (11:40 -0500)
Tushar Ahuja discovered that if you use both --compress and --gzip,
or --compress multiple times, the last instance of one of these
options doesn't in all cases overwrite the compression level set by
an earlier option. That's not a serious bug, but it also has nothing
to recommend it. Repair.

Discussion: http://postgr.es/m/CA+TgmoZfP=rsZB_9vDGfhuNgSu_M_09UWu8SjvsP65y_1pQFCg@mail.gmail.com

src/bin/pg_basebackup/pg_basebackup.c

index 1f81bbf4e2a07f47f0c073d4966d617171526474..c40925c1f0435d388569b772cc4d1da1350dd299 100644 (file)
@@ -966,6 +966,12 @@ parse_compress_options(char *src, WalCompressionMethod *methodres,
    int         firstlen;
    char       *firstpart;
 
+   /*
+    * clear 'levelres' so that if there are multiple compression options,
+    * the last one fully overrides the earlier ones
+    */
+   *levelres = 0;
+
    /* check if the option is split in two */
    sep = strchr(src, ':');