From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Jeevan Ladhe <jeevanladhe(dot)os(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "Shinoda, Noriyoshi (PN Japan FSIP)" <noriyoshi(dot)shinoda(at)hpe(dot)com>, Dipesh Pandit <dipesh(dot)pandit(at)gmail(dot)com>, Abhijit Menon-Sen <ams(at)toroid(dot)org>, Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, Jeevan Ladhe <jeevan(dot)ladhe(at)enterprisedb(dot)com>, Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org, tushar <tushar(dot)ahuja(at)enterprisedb(dot)com>, Andres Freund <andres(at)anarazel(dot)de> |
Subject: | Re: refactoring basebackup.c |
Date: | 2022-03-11 16:29:11 |
Message-ID: | 20220311162911.GM28503@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Mar 11, 2022 at 10:19:29AM -0500, Robert Haas wrote:
> So I think we should just refuse this command. Patch for that attached.
Sounds right.
Also, I think the magic 8 for .gz should actually be a 7.
I'm not sure why it tests for ".gz" but not ".tar.gz", which would help to make
them all less magic.
commit 1fb1e21ba7a500bb2b85ec3e65f59130fcdb4a7e
Author: Justin Pryzby <pryzbyj(at)telsasoft(dot)com>
Date: Thu Mar 10 21:22:16 2022 -0600
pg_basebackup: make magic numbers less magic
The magic 8 for .gz should actually be a 7.
.tar.gz
1234567
.tar.lz4
.tar.zst
12345678
See d45099425, 751b8d23b, 7cf085f07.
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 9f3ecc60fbe..8dd9721323d 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -1223,17 +1223,17 @@ CreateBackupStreamer(char *archive_name, char *spclocation,
is_tar = (archive_name_len > 4 &&
strcmp(archive_name + archive_name_len - 4, ".tar") == 0);
- /* Is this a gzip archive? */
- is_tar_gz = (archive_name_len > 8 &&
- strcmp(archive_name + archive_name_len - 3, ".gz") == 0);
+ /* Is this a .tar.gz archive? */
+ is_tar_gz = (archive_name_len > 7 &&
+ strcmp(archive_name + archive_name_len - 7, ".tar.gz") == 0);
- /* Is this a LZ4 archive? */
+ /* Is this a .tar.lz4 archive? */
is_tar_lz4 = (archive_name_len > 8 &&
- strcmp(archive_name + archive_name_len - 4, ".lz4") == 0);
+ strcmp(archive_name + archive_name_len - 8, ".tar.lz4") == 0);
- /* Is this a ZSTD archive? */
+ /* Is this a .tar.zst archive? */
is_tar_zstd = (archive_name_len > 8 &&
- strcmp(archive_name + archive_name_len - 4, ".zst") == 0);
+ strcmp(archive_name + archive_name_len - 8, ".tar.zst") == 0);
/*
* We have to parse the archive if (1) we're suppose to extract it, or if
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-03-11 16:34:36 | Re: role self-revocation |
Previous Message | Robert Haas | 2022-03-11 16:13:00 | Re: role self-revocation |