1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Rework compression options of pg_receivewal

Since babbbb5 and the introduction of LZ4 in pg_receivewal, the
compression of the WAL archived is controlled by two options:
- --compression-method with "gzip", "none" or "lz4" as possible value.
- --compress=N to specify a compression level.  This includes a
backward-incompatible change where a value of 0 leads to a failure
instead of no compression enforced.

This commit takes advantage of a4b5754 and 3603f7c to rework the
compression options of pg_receivewal, as of:
- The removal of --compression-method.
- The extenction of --compress to use the same grammar as pg_basebackup,
with a METHOD:DETAIL format, where a METHOD is "gzip", "none" or "lz4"
and a DETAIL is a comma-separated list of options, the only keyword
supported is now "level" to control the compression level.  If only an
integer is specified as value of this option, "none" is implied on 0
and "gzip" is implied otherwise.  This brings back --compress to be
backward-compatible with ~14, while still supporting LZ4.

This has also the advantage of centralizing the set of checks used by
pg_receivewal to validate its compression options.

Author: Michael Paquier
Reviewed-by: Robert Haas, Georgios Kokolatos
Discussion: https://postgr.es/m/YlPQGNAAa04raObK@paquier.xyz
This commit is contained in:
Michael Paquier
2022-04-13 11:09:51 +09:00
parent d27323db7c
commit 042a923ad5
3 changed files with 122 additions and 80 deletions

View File

@ -263,15 +263,32 @@ PostgreSQL documentation
</varlistentry>
<varlistentry>
<term><option>--compression-method=<replaceable class="parameter">method</replaceable></option></term>
<term><option>-Z <replaceable class="parameter">level</replaceable></option></term>
<term><option>-Z <replaceable class="parameter">method</replaceable>[:<replaceable>detail</replaceable>]</option></term>
<term><option>--compress=<replaceable class="parameter">level</replaceable></option></term>
<term><option>--compress=<replaceable class="parameter">method</replaceable>[:<replaceable>detail</replaceable>]</option></term>
<listitem>
<para>
Enables compression of write-ahead logs using the specified method.
Supported values are <literal>gzip</literal>, <literal>lz4</literal>
(if <productname>PostgreSQL</productname> was compiled with
<option>--with-lz4</option>), and <literal>none</literal>.
Enables compression of write-ahead logs.
</para>
<para>
The compression method can be set to <literal>gzip</literal>,
<literal>lz4</literal> (if <productname>PostgreSQL</productname>
was compiled with <option>--with-lz4</option>) or
<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>.
</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>
The suffix <filename>.gz</filename> will automatically be added to
all filenames when using <literal>gzip</literal>, and the suffix
@ -279,24 +296,6 @@ PostgreSQL documentation
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-Z <replaceable class="parameter">level</replaceable></option></term>
<term><option>--compress=<replaceable class="parameter">level</replaceable></option></term>
<listitem>
<para>
Specifies the compression level (<literal>1</literal> through
<literal>9</literal>, <literal>1</literal> being worst compression
and <literal>9</literal> being best compression) for WAL segments
compressed with <application>gzip</application>.
</para>
<para>
This option requires <option>--compression-method</option> to be
specified with <literal>gzip</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>