diff options
author | Michael Paquier <michael@paquier.xyz> | 2022-04-12 13:38:54 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2022-04-12 13:38:54 +0900 |
commit | a4b57543acfb52cc7c7e031501002563f536b929 (patch) | |
tree | a24d3a2c95880f547500a8bcdbe94d718d005eca /src/backend | |
parent | bd037dc928dd126e5623117b2fe7633ec3fa7c40 (diff) | |
download | postgresql-a4b57543acfb52cc7c7e031501002563f536b929.tar.gz postgresql-a4b57543acfb52cc7c7e031501002563f536b929.zip |
Rename backup_compression.{c,h} to compression.{c,h}
Compression option handling (level, algorithm or even workers) can be
used across several parts of the system and not only base backups.
Structures, objects and routines are renamed in consequence, to remove
the concept of base backups from this part of the code making this
change straight-forward.
pg_receivewal, that has gained support for LZ4 since babbbb5, will make
use of this infrastructure for its set of compression options, bringing
more consistency with pg_basebackup. This cleanup needs to be done
before releasing a beta of 15. pg_dump is a potential future target, as
well, and adding more compression options to it may happen in 16~.
Author: Michael Paquier
Reviewed-by: Robert Haas, Georgios Kokolatos
Discussion: https://postgr.es/m/YlPQGNAAa04raObK@paquier.xyz
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/replication/basebackup.c | 24 | ||||
-rw-r--r-- | src/backend/replication/basebackup_gzip.c | 4 | ||||
-rw-r--r-- | src/backend/replication/basebackup_lz4.c | 4 | ||||
-rw-r--r-- | src/backend/replication/basebackup_zstd.c | 10 |
4 files changed, 21 insertions, 21 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index 27e4152446d..67489192a26 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -17,7 +17,7 @@ #include <time.h> #include "access/xlog_internal.h" /* for pg_start/stop_backup */ -#include "common/backup_compression.h" +#include "common/compression.h" #include "common/file_perm.h" #include "commands/defrem.h" #include "lib/stringinfo.h" @@ -68,8 +68,8 @@ typedef struct bool use_copytblspc; BaseBackupTargetHandle *target_handle; backup_manifest_option manifest; - bc_algorithm compression; - bc_specification compression_specification; + pg_compress_algorithm compression; + pg_compress_specification compression_specification; pg_checksum_type manifest_checksum_type; } basebackup_options; @@ -691,8 +691,8 @@ parse_basebackup_options(List *options, basebackup_options *opt) MemSet(opt, 0, sizeof(*opt)); opt->manifest = MANIFEST_OPTION_NO; opt->manifest_checksum_type = CHECKSUM_TYPE_CRC32C; - opt->compression = BACKUP_COMPRESSION_NONE; - opt->compression_specification.algorithm = BACKUP_COMPRESSION_NONE; + opt->compression = PG_COMPRESSION_NONE; + opt->compression_specification.algorithm = PG_COMPRESSION_NONE; foreach(lopt, options) { @@ -859,7 +859,7 @@ parse_basebackup_options(List *options, basebackup_options *opt) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("duplicate option \"%s\"", defel->defname))); - if (!parse_bc_algorithm(optval, &opt->compression)) + if (!parse_compress_algorithm(optval, &opt->compression)) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("unrecognized compression algorithm \"%s\"", @@ -924,10 +924,10 @@ parse_basebackup_options(List *options, basebackup_options *opt) { char *error_detail; - parse_bc_specification(opt->compression, compression_detail_str, - &opt->compression_specification); + parse_compress_specification(opt->compression, compression_detail_str, + &opt->compression_specification); error_detail = - validate_bc_specification(&opt->compression_specification); + validate_compress_specification(&opt->compression_specification); if (error_detail != NULL) ereport(ERROR, errcode(ERRCODE_SYNTAX_ERROR), @@ -978,11 +978,11 @@ SendBaseBackup(BaseBackupCmd *cmd) sink = bbsink_throttle_new(sink, opt.maxrate); /* Set up server-side compression, if client requested it */ - if (opt.compression == BACKUP_COMPRESSION_GZIP) + if (opt.compression == PG_COMPRESSION_GZIP) sink = bbsink_gzip_new(sink, &opt.compression_specification); - else if (opt.compression == BACKUP_COMPRESSION_LZ4) + else if (opt.compression == PG_COMPRESSION_LZ4) sink = bbsink_lz4_new(sink, &opt.compression_specification); - else if (opt.compression == BACKUP_COMPRESSION_ZSTD) + else if (opt.compression == PG_COMPRESSION_ZSTD) sink = bbsink_zstd_new(sink, &opt.compression_specification); /* Set up progress reporting. */ diff --git a/src/backend/replication/basebackup_gzip.c b/src/backend/replication/basebackup_gzip.c index 43a7323e7d2..5ae7451187b 100644 --- a/src/backend/replication/basebackup_gzip.c +++ b/src/backend/replication/basebackup_gzip.c @@ -59,7 +59,7 @@ const bbsink_ops bbsink_gzip_ops = { * Create a new basebackup sink that performs gzip compression. */ bbsink * -bbsink_gzip_new(bbsink *next, bc_specification *compress) +bbsink_gzip_new(bbsink *next, pg_compress_specification *compress) { #ifndef HAVE_LIBZ ereport(ERROR, @@ -72,7 +72,7 @@ bbsink_gzip_new(bbsink *next, bc_specification *compress) Assert(next != NULL); - if ((compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) == 0) + if ((compress->options & PG_COMPRESSION_OPTION_LEVEL) == 0) compresslevel = Z_DEFAULT_COMPRESSION; else { diff --git a/src/backend/replication/basebackup_lz4.c b/src/backend/replication/basebackup_lz4.c index 032cc10bc4e..e06efddee08 100644 --- a/src/backend/replication/basebackup_lz4.c +++ b/src/backend/replication/basebackup_lz4.c @@ -59,7 +59,7 @@ const bbsink_ops bbsink_lz4_ops = { * Create a new basebackup sink that performs lz4 compression. */ bbsink * -bbsink_lz4_new(bbsink *next, bc_specification *compress) +bbsink_lz4_new(bbsink *next, pg_compress_specification *compress) { #ifndef USE_LZ4 ereport(ERROR, @@ -72,7 +72,7 @@ bbsink_lz4_new(bbsink *next, bc_specification *compress) Assert(next != NULL); - if ((compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) == 0) + if ((compress->options & PG_COMPRESSION_OPTION_LEVEL) == 0) compresslevel = 0; else { diff --git a/src/backend/replication/basebackup_zstd.c b/src/backend/replication/basebackup_zstd.c index 55dee6b0b5e..acb32275bcc 100644 --- a/src/backend/replication/basebackup_zstd.c +++ b/src/backend/replication/basebackup_zstd.c @@ -26,7 +26,7 @@ typedef struct bbsink_zstd bbsink base; /* Compression options */ - bc_specification *compress; + pg_compress_specification *compress; ZSTD_CCtx *cctx; ZSTD_outBuffer zstd_outBuf; @@ -58,7 +58,7 @@ const bbsink_ops bbsink_zstd_ops = { * Create a new basebackup sink that performs zstd compression. */ bbsink * -bbsink_zstd_new(bbsink *next, bc_specification *compress) +bbsink_zstd_new(bbsink *next, pg_compress_specification *compress) { #ifndef USE_ZSTD ereport(ERROR, @@ -90,13 +90,13 @@ bbsink_zstd_begin_backup(bbsink *sink) bbsink_zstd *mysink = (bbsink_zstd *) sink; size_t output_buffer_bound; size_t ret; - bc_specification *compress = mysink->compress; + pg_compress_specification *compress = mysink->compress; mysink->cctx = ZSTD_createCCtx(); if (!mysink->cctx) elog(ERROR, "could not create zstd compression context"); - if ((compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) != 0) + if ((compress->options & PG_COMPRESSION_OPTION_LEVEL) != 0) { ret = ZSTD_CCtx_setParameter(mysink->cctx, ZSTD_c_compressionLevel, compress->level); @@ -105,7 +105,7 @@ bbsink_zstd_begin_backup(bbsink *sink) compress->level, ZSTD_getErrorName(ret)); } - if ((compress->options & BACKUP_COMPRESSION_OPTION_WORKERS) != 0) + if ((compress->options & PG_COMPRESSION_OPTION_WORKERS) != 0) { /* * On older versions of libzstd, this option does not exist, and trying |