diff options
author | Robert Haas <rhaas@postgresql.org> | 2022-03-23 09:19:14 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2022-03-23 09:19:14 -0400 |
commit | ffd53659c46a54a6978bcb8c4424c1e157a2c0f1 (patch) | |
tree | f06520bc72f04ebb35b643a32e7a3ee42dee5378 /src/backend/replication/basebackup_gzip.c | |
parent | 4a39f87acd6e681e5ded1239391d8a92645b43d6 (diff) | |
download | postgresql-ffd53659c46a54a6978bcb8c4424c1e157a2c0f1.tar.gz postgresql-ffd53659c46a54a6978bcb8c4424c1e157a2c0f1.zip |
Replace BASE_BACKUP COMPRESSION_LEVEL option with COMPRESSION_DETAIL.
There are more compression parameters that can be specified than just
an integer compression level, so rename the new COMPRESSION_LEVEL
option to COMPRESSION_DETAIL before it gets released. Introduce a
flexible syntax for that option to allow arbitrary options to be
specified without needing to adjust the main replication grammar,
and common code to parse it that is shared between the client and
the server.
This commit doesn't actually add any new compression parameters,
so the only user-visible change is that you can now type something
like pg_basebackup --compress gzip:level=5 instead of writing just
pg_basebackup --compress gzip:5. However, it should make it easy to
add new options. If for example gzip starts offering fries, we can
support pg_basebackup --compress gzip:level=5,fries=true for the
benefit of users who want fries with that.
Along the way, this fixes a few things in pg_basebackup so that the
pg_basebackup can be used with a server-side compression algorithm
that pg_basebackup itself does not understand. For example,
pg_basebackup --compress server-lz4 could still succeed even if
only the server and not the client has LZ4 support, provided that
the other options to pg_basebackup don't require the client to
decompress the archive.
Patch by me. Reviewed by Justin Pryzby and Dagfinn Ilmari Mannsåker.
Discussion: http://postgr.es/m/CA+TgmoYvpetyRAbbg1M8b3-iHsaN4nsgmWPjOENu5-doHuJ7fA@mail.gmail.com
Diffstat (limited to 'src/backend/replication/basebackup_gzip.c')
-rw-r--r-- | src/backend/replication/basebackup_gzip.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/backend/replication/basebackup_gzip.c b/src/backend/replication/basebackup_gzip.c index b66d3da7a3f..703a91ba776 100644 --- a/src/backend/replication/basebackup_gzip.c +++ b/src/backend/replication/basebackup_gzip.c @@ -56,12 +56,13 @@ const bbsink_ops bbsink_gzip_ops = { #endif /* - * Create a new basebackup sink that performs gzip compression using the - * designated compression level. + * Create a new basebackup sink that performs gzip compression. */ bbsink * -bbsink_gzip_new(bbsink *next, int compresslevel) +bbsink_gzip_new(bbsink *next, bc_specification *compress) { + int compresslevel; + #ifndef HAVE_LIBZ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -71,15 +72,14 @@ bbsink_gzip_new(bbsink *next, int compresslevel) bbsink_gzip *sink; Assert(next != NULL); - Assert(compresslevel >= 0 && compresslevel <= 9); - if (compresslevel == 0) + if ((compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) == 0) compresslevel = Z_DEFAULT_COMPRESSION; - else if (compresslevel < 0 || compresslevel > 9) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("gzip compression level %d is out of range", - compresslevel))); + else + { + compresslevel = compress->level; + Assert(compresslevel >= 1 && compresslevel <= 9); + } sink = palloc0(sizeof(bbsink_gzip)); *((const bbsink_ops **) &sink->base.bbs_ops) = &bbsink_gzip_ops; |