pgsql: Move tar detection and compression logic to common.

Started by Andrew Dunstan6 months ago4 messageshackerscomitters
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

This thread has been committed, so CI has stopped here. Anything below is the last result it produced.

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t247062
psql -h localhost -U postgres

Built from patchset v2 (message #2), August 02, 2026 at 10:21 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t247062_2 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t247062_2 && git checkout t247062_2

Patchset v2 (message #2) is on t247062_2

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