1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

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
This commit is contained in:
Robert Haas
2022-03-23 09:19:14 -04:00
parent 4a39f87acd
commit ffd53659c4
17 changed files with 669 additions and 338 deletions

View File

@ -2731,14 +2731,24 @@ The commands accepted in replication mode are:
</varlistentry>
<varlistentry>
<term><literal>COMPRESSION_LEVEL</literal> <replaceable>level</replaceable></term>
<term><literal>COMPRESSION_DETAIL</literal> <replaceable>detail</replaceable></term>
<listitem>
<para>
Specifies the compression level to be used. This should only be
used in conjunction with the <literal>COMPRESSION</literal> option.
For <literal>gzip</literal> the value should be an integer between 1
and 9, for <literal>lz4</literal> between 1 and 12, and for
<literal>zstd</literal> it should be between 1 and 22.
Specifies details for the chosen compression method. This should only
be used in conjunction with the <literal>COMPRESSION</literal>
option. If the value is an integer, it specifies the compression
level. Otherwise, it should be a comma-separated list of items,
each of the form <literal>keyword</literal> or
<literal>keyword=value</literal>. Currently, the only supported
keyword is <literal>level</literal>, which sets the compression
level.
</para>
<para>
For <literal>gzip</literal> the compression level should be an
integer between 1 and 9, for <literal>lz4</literal> an integer
between 1 and 12, and for <literal>zstd</literal> an integer
between 1 and 22.
</para>
</listitem>
</varlistentry>

View File

@ -399,9 +399,9 @@ PostgreSQL documentation
<varlistentry>
<term><option>-Z <replaceable class="parameter">level</replaceable></option></term>
<term><option>-Z [{client|server}-]<replaceable class="parameter">method</replaceable></option>[:<replaceable>level</replaceable>]</term>
<term><option>-Z [{client|server}-]<replaceable class="parameter">method</replaceable>[:<replaceable>detail</replaceable>]</option></term>
<term><option>--compress=<replaceable class="parameter">level</replaceable></option></term>
<term><option>--compress=[{client|server}-]<replaceable class="parameter">method</replaceable></option>[:<replaceable>level</replaceable>]</term>
<term><option>--compress=[{client|server}-]<replaceable class="parameter">method</replaceable>[:<replaceable>detail</replaceable>]</option></term>
<listitem>
<para>
Requests compression of the backup. If <literal>client</literal> or
@ -419,13 +419,20 @@ PostgreSQL documentation
<para>
The compression method can be set to <literal>gzip</literal>,
<literal>lz4</literal>, <literal>zstd</literal>, or
<literal>none</literal> for no compression. A compression level can
optionally be specified, by appending the level number after a colon
(<literal>:</literal>). If no level is specified, the default
compression level will be used. If only a level is specified without
mentioning an algorithm, <literal>gzip</literal> compression will be
used if the level is greater than 0, and no compression will be used if
the level is 0.
<literal>none</literal> for no compression. A compression detail
string can optionally be specified. If the detail string is an
integer, it specifies the compression level. Otherwise, it should be
a comma-separated list of items, each of the form
<literal>keyword</literal> or <literal>keyword=value</literal>.
Currently, the only supported keyword is <literal>level</literal>,
which sets the compression level.
</para>
<para>
If no compression level is specified, the default compression level
will be used. If only a level is specified without mentioning an
algorithm, <literal>gzip</literal> compression will be used if the
level is greater than 0, and no compression will be used if the level
is 0.
</para>
<para>
When the tar format is used with <literal>gzip</literal>,