pgsql: Move tar detection and compression logic to common.

Started by Andrew Dunstan8 months ago4 messageshackerscomitters
Jump to latest
#1Andrew Dunstan
andrew@dunslane.net
comitters

Move tar detection and compression logic to common.

Consolidate tar archive identification and compression-type detection
logic into a shared location. Currently used by pg_basebackup and
pg_verifybackup, this functionality is also required for upcoming
pg_waldump enhancements.

This change promotes code reuse and simplifies maintenance across
frontend tools.

Author: Amul Sul <sulamul@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Jakub Wartak <jakub.wartak@enterprisedb.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Andrew Dunstan <andrew@dunslane.net>
Reviewed-by: Zsolt Parragi <zsolt.parragi@percona.com>
discussion: /messages/by-id/CAAJ_b94bqdWN3h2J-PzzzQ2Npbwct5ZQHggn_QoYGhC2rn-=WQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c8a350a439826267186c187dbfbf1f839f7521aa

Modified Files
--------------
src/bin/pg_basebackup/pg_basebackup.c | 36 ++++++++++---------------------
src/bin/pg_verifybackup/pg_verifybackup.c | 12 +----------
src/common/compression.c | 30 ++++++++++++++++++++++++++
src/include/common/compression.h | 2 ++
4 files changed, 44 insertions(+), 36 deletions(-)

#2Robert Haas
robertmhaas@gmail.com
In reply to: Andrew Dunstan (#1)
hackers
Re: pgsql: Move tar detection and compression logic to common.

On Fri, Mar 20, 2026 at 3:32 PM Andrew Dunstan <andrew@dunslane.net> wrote:

Move tar detection and compression logic to common.

Consolidate tar archive identification and compression-type detection
logic into a shared location. Currently used by pg_basebackup and
pg_verifybackup, this functionality is also required for upcoming
pg_waldump enhancements.

https://git.postgresql.org/pg/commitdiff/c8a350a439826267186c187dbfbf1f839f7521aa

Unfortunately, this commit not only consolidated the logic but also
changed the behavior at both of the then-existing call sites for the
worse.

I attach a patch to undo those behavior changes, which I intend to
commit and back-patch to v19.

--
Robert Haas
EDB: http://www.enterprisedb.com

Attachments:

t247062_2
v1-0001-Undo-inadvertent-loosening-of-archive-filename-ch.patchapplication/octet-stream; name=v1-0001-Undo-inadvertent-loosening-of-archive-filename-ch.patchDownload+28-14
#3Andrew Dunstan
andrew@dunslane.net
In reply to: Robert Haas (#2)
hackers
Re: pgsql: Move tar detection and compression logic to common.

On Wed, Jul 22, 2026 at 12:23 PM Robert Haas <robertmhaas@gmail.com> wrote:

On Fri, Mar 20, 2026 at 3:32 PM Andrew Dunstan <andrew@dunslane.net>
wrote:

Move tar detection and compression logic to common.

Consolidate tar archive identification and compression-type detection
logic into a shared location. Currently used by pg_basebackup and
pg_verifybackup, this functionality is also required for upcoming
pg_waldump enhancements.

https://git.postgresql.org/pg/commitdiff/c8a350a439826267186c187dbfbf1f839f7521aa

Unfortunately, this commit not only consolidated the logic but also
changed the behavior at both of the then-existing call sites for the
worse.

I attach a patch to undo those behavior changes, which I intend to
commit and back-patch to v19.

Thanks, Robert. The change in precheck_tar_backup could possibly do with a
comment like "Make sure there's nothing between the expected prefix and
suffix". I had to look hard to see what it was doing.

cheers

andrew

#4Robert Haas
robertmhaas@gmail.com
In reply to: Andrew Dunstan (#3)
hackers
Re: pgsql: Move tar detection and compression logic to common.

On Wed, Jul 22, 2026 at 3:28 PM Andrew Dunstan <andrew@dunslane.net> wrote:

Thanks, Robert. The change in precheck_tar_backup could possibly do with a comment like "Make sure there's nothing between the expected prefix and suffix". I had to look hard to see what it was doing.

Cool. I'll add some kind of a comment there before committing. Thanks
for the quick response.

--
Robert Haas
EDB: http://www.enterprisedb.com