diff options
| author | Michael Paquier | 2022-04-12 04:38:54 +0000 |
|---|---|---|
| committer | Michael Paquier | 2022-04-12 04:38:54 +0000 |
| commit | a4b57543acfb52cc7c7e031501002563f536b929 (patch) | |
| tree | a24d3a2c95880f547500a8bcdbe94d718d005eca /src/bin | |
| parent | bd037dc928dd126e5623117b2fe7633ec3fa7c40 (diff) | |
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/bin')
| -rw-r--r-- | src/bin/pg_basebackup/bbstreamer.h | 8 | ||||
| -rw-r--r-- | src/bin/pg_basebackup/bbstreamer_gzip.c | 4 | ||||
| -rw-r--r-- | src/bin/pg_basebackup/bbstreamer_lz4.c | 4 | ||||
| -rw-r--r-- | src/bin/pg_basebackup/bbstreamer_zstd.c | 6 | ||||
| -rw-r--r-- | src/bin/pg_basebackup/nls.mk | 2 | ||||
| -rw-r--r-- | src/bin/pg_basebackup/pg_basebackup.c | 44 |
6 files changed, 34 insertions, 34 deletions
diff --git a/src/bin/pg_basebackup/bbstreamer.h b/src/bin/pg_basebackup/bbstreamer.h index dfa3f77af47..29b48ef54d9 100644 --- a/src/bin/pg_basebackup/bbstreamer.h +++ b/src/bin/pg_basebackup/bbstreamer.h @@ -22,7 +22,7 @@ #ifndef BBSTREAMER_H #define BBSTREAMER_H -#include "common/backup_compression.h" +#include "common/compression.h" #include "lib/stringinfo.h" #include "pqexpbuffer.h" @@ -201,17 +201,17 @@ bbstreamer_buffer_until(bbstreamer *streamer, const char **data, int *len, */ extern bbstreamer *bbstreamer_plain_writer_new(char *pathname, FILE *file); extern bbstreamer *bbstreamer_gzip_writer_new(char *pathname, FILE *file, - bc_specification *compress); + pg_compress_specification *compress); extern bbstreamer *bbstreamer_extractor_new(const char *basepath, const char *(*link_map) (const char *), void (*report_output_file) (const char *)); extern bbstreamer *bbstreamer_gzip_decompressor_new(bbstreamer *next); extern bbstreamer *bbstreamer_lz4_compressor_new(bbstreamer *next, - bc_specification *compress); + pg_compress_specification *compress); extern bbstreamer *bbstreamer_lz4_decompressor_new(bbstreamer *next); extern bbstreamer *bbstreamer_zstd_compressor_new(bbstreamer *next, - bc_specification *compress); + pg_compress_specification *compress); extern bbstreamer *bbstreamer_zstd_decompressor_new(bbstreamer *next); extern bbstreamer *bbstreamer_tar_parser_new(bbstreamer *next); extern bbstreamer *bbstreamer_tar_terminator_new(bbstreamer *next); diff --git a/src/bin/pg_basebackup/bbstreamer_gzip.c b/src/bin/pg_basebackup/bbstreamer_gzip.c index 1ab7ee6ea91..b3bfcd62ac3 100644 --- a/src/bin/pg_basebackup/bbstreamer_gzip.c +++ b/src/bin/pg_basebackup/bbstreamer_gzip.c @@ -77,7 +77,7 @@ const bbstreamer_ops bbstreamer_gzip_decompressor_ops = { */ bbstreamer * bbstreamer_gzip_writer_new(char *pathname, FILE *file, - bc_specification *compress) + pg_compress_specification *compress) { #ifdef HAVE_LIBZ bbstreamer_gzip_writer *streamer; @@ -107,7 +107,7 @@ bbstreamer_gzip_writer_new(char *pathname, FILE *file, pg_fatal("could not open output file: %m"); } - if ((compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) != 0 && + if ((compress->options & PG_COMPRESSION_OPTION_LEVEL) != 0 && gzsetparams(streamer->gzfile, compress->level, Z_DEFAULT_STRATEGY) != Z_OK) pg_fatal("could not set compression level %d: %s", diff --git a/src/bin/pg_basebackup/bbstreamer_lz4.c b/src/bin/pg_basebackup/bbstreamer_lz4.c index 2f75ba56029..6070a72cdb5 100644 --- a/src/bin/pg_basebackup/bbstreamer_lz4.c +++ b/src/bin/pg_basebackup/bbstreamer_lz4.c @@ -67,7 +67,7 @@ const bbstreamer_ops bbstreamer_lz4_decompressor_ops = { * blocks. */ bbstreamer * -bbstreamer_lz4_compressor_new(bbstreamer *next, bc_specification *compress) +bbstreamer_lz4_compressor_new(bbstreamer *next, pg_compress_specification *compress) { #ifdef USE_LZ4 bbstreamer_lz4_frame *streamer; @@ -88,7 +88,7 @@ bbstreamer_lz4_compressor_new(bbstreamer *next, bc_specification *compress) prefs = &streamer->prefs; memset(prefs, 0, sizeof(LZ4F_preferences_t)); prefs->frameInfo.blockSizeID = LZ4F_max256KB; - if ((compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) != 0) + if ((compress->options & PG_COMPRESSION_OPTION_LEVEL) != 0) prefs->compressionLevel = compress->level; ctxError = LZ4F_createCompressionContext(&streamer->cctx, LZ4F_VERSION); diff --git a/src/bin/pg_basebackup/bbstreamer_zstd.c b/src/bin/pg_basebackup/bbstreamer_zstd.c index a5167e9fea1..8a839145a65 100644 --- a/src/bin/pg_basebackup/bbstreamer_zstd.c +++ b/src/bin/pg_basebackup/bbstreamer_zstd.c @@ -63,7 +63,7 @@ const bbstreamer_ops bbstreamer_zstd_decompressor_ops = { * blocks. */ bbstreamer * -bbstreamer_zstd_compressor_new(bbstreamer *next, bc_specification *compress) +bbstreamer_zstd_compressor_new(bbstreamer *next, pg_compress_specification *compress) { #ifdef USE_ZSTD bbstreamer_zstd_frame *streamer; @@ -85,7 +85,7 @@ bbstreamer_zstd_compressor_new(bbstreamer *next, bc_specification *compress) pg_fatal("could not create zstd compression context"); /* Set compression level, if specified */ - if ((compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) != 0) + if ((compress->options & PG_COMPRESSION_OPTION_LEVEL) != 0) { ret = ZSTD_CCtx_setParameter(streamer->cctx, ZSTD_c_compressionLevel, compress->level); @@ -95,7 +95,7 @@ bbstreamer_zstd_compressor_new(bbstreamer *next, bc_specification *compress) } /* Set # of workers, if specified */ - 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 diff --git a/src/bin/pg_basebackup/nls.mk b/src/bin/pg_basebackup/nls.mk index cf8570ce189..298a6e02f0f 100644 --- a/src/bin/pg_basebackup/nls.mk +++ b/src/bin/pg_basebackup/nls.mk @@ -14,7 +14,7 @@ GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \ receivelog.c \ streamutil.c \ walmethods.c \ - ../../common/backup_compression.c \ + ../../common/compression.c \ ../../common/fe_memutils.c \ ../../common/file_utils.c \ ../../fe_utils/recovery_gen.c diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index d96ae873032..91bdaf6cc2d 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -29,7 +29,7 @@ #include "access/xlog_internal.h" #include "bbstreamer.h" -#include "common/backup_compression.h" +#include "common/compression.h" #include "common/file_perm.h" #include "common/file_utils.h" #include "common/logging.h" @@ -58,7 +58,7 @@ typedef struct TablespaceList typedef struct ArchiveStreamState { int tablespacenum; - bc_specification *compress; + pg_compress_specification *compress; bbstreamer *streamer; bbstreamer *manifest_inject_streamer; PQExpBuffer manifest_buffer; @@ -198,7 +198,7 @@ static bbstreamer *CreateBackupStreamer(char *archive_name, char *spclocation, bbstreamer **manifest_inject_streamer_p, bool is_recovery_guc_supported, bool expect_unterminated_tarfile, - bc_specification *compress); + pg_compress_specification *compress); static void ReceiveArchiveStreamChunk(size_t r, char *copybuf, void *callback_data); static char GetCopyDataByte(size_t r, char *copybuf, size_t *cursor); @@ -207,7 +207,7 @@ static uint64 GetCopyDataUInt64(size_t r, char *copybuf, size_t *cursor); static void GetCopyDataEnd(size_t r, char *copybuf, size_t cursor); static void ReportCopyDataParseError(size_t r, char *copybuf); static void ReceiveTarFile(PGconn *conn, char *archive_name, char *spclocation, - bool tablespacenum, bc_specification *compress); + bool tablespacenum, pg_compress_specification *compress); static void ReceiveTarCopyChunk(size_t r, char *copybuf, void *callback_data); static void ReceiveBackupManifest(PGconn *conn); static void ReceiveBackupManifestChunk(size_t r, char *copybuf, @@ -217,7 +217,7 @@ static void ReceiveBackupManifestInMemoryChunk(size_t r, char *copybuf, void *callback_data); static void BaseBackup(char *compression_algorithm, char *compression_detail, CompressionLocation compressloc, - bc_specification *client_compress); + pg_compress_specification *client_compress); static bool reached_end_position(XLogRecPtr segendpos, uint32 timeline, bool segment_finished); @@ -1077,7 +1077,7 @@ CreateBackupStreamer(char *archive_name, char *spclocation, bbstreamer **manifest_inject_streamer_p, bool is_recovery_guc_supported, bool expect_unterminated_tarfile, - bc_specification *compress) + pg_compress_specification *compress) { bbstreamer *streamer = NULL; bbstreamer *manifest_inject_streamer = NULL; @@ -1193,23 +1193,23 @@ CreateBackupStreamer(char *archive_name, char *spclocation, archive_file = NULL; } - if (compress->algorithm == BACKUP_COMPRESSION_NONE) + if (compress->algorithm == PG_COMPRESSION_NONE) streamer = bbstreamer_plain_writer_new(archive_filename, archive_file); - else if (compress->algorithm == BACKUP_COMPRESSION_GZIP) + else if (compress->algorithm == PG_COMPRESSION_GZIP) { strlcat(archive_filename, ".gz", sizeof(archive_filename)); streamer = bbstreamer_gzip_writer_new(archive_filename, archive_file, compress); } - else if (compress->algorithm == BACKUP_COMPRESSION_LZ4) + else if (compress->algorithm == PG_COMPRESSION_LZ4) { strlcat(archive_filename, ".lz4", sizeof(archive_filename)); streamer = bbstreamer_plain_writer_new(archive_filename, archive_file); streamer = bbstreamer_lz4_compressor_new(streamer, compress); } - else if (compress->algorithm == BACKUP_COMPRESSION_ZSTD) + else if (compress->algorithm == PG_COMPRESSION_ZSTD) { strlcat(archive_filename, ".zst", sizeof(archive_filename)); streamer = bbstreamer_plain_writer_new(archive_filename, @@ -1288,7 +1288,7 @@ CreateBackupStreamer(char *archive_name, char *spclocation, * manifest if present - as a single COPY stream. */ static void -ReceiveArchiveStream(PGconn *conn, bc_specification *compress) +ReceiveArchiveStream(PGconn *conn, pg_compress_specification *compress) { ArchiveStreamState state; @@ -1604,7 +1604,7 @@ ReportCopyDataParseError(size_t r, char *copybuf) */ static void ReceiveTarFile(PGconn *conn, char *archive_name, char *spclocation, - bool tablespacenum, bc_specification *compress) + bool tablespacenum, pg_compress_specification *compress) { WriteTarState state; bbstreamer *manifest_inject_streamer; @@ -1758,7 +1758,7 @@ ReceiveBackupManifestInMemoryChunk(size_t r, char *copybuf, static void BaseBackup(char *compression_algorithm, char *compression_detail, - CompressionLocation compressloc, bc_specification *client_compress) + CompressionLocation compressloc, pg_compress_specification *client_compress) { PGresult *res; char *sysidentifier; @@ -2025,11 +2025,11 @@ BaseBackup(char *compression_algorithm, char *compression_detail, if (verbose) pg_log_info("starting background WAL receiver"); - if (client_compress->algorithm == BACKUP_COMPRESSION_GZIP) + if (client_compress->algorithm == PG_COMPRESSION_GZIP) { wal_compress_method = COMPRESSION_GZIP; wal_compress_level = - (client_compress->options & BACKUP_COMPRESSION_OPTION_LEVEL) + (client_compress->options & PG_COMPRESSION_OPTION_LEVEL) != 0 ? client_compress->level : 0; } else @@ -2316,7 +2316,7 @@ main(int argc, char **argv) char *compression_algorithm = "none"; char *compression_detail = NULL; CompressionLocation compressloc = COMPRESS_LOCATION_UNSPECIFIED; - bc_specification client_compress; + pg_compress_specification client_compress; pg_logging_init(argv[0]); progname = get_progname(argv[0]); @@ -2558,15 +2558,15 @@ main(int argc, char **argv) */ if (compressloc == COMPRESS_LOCATION_CLIENT) { - bc_algorithm alg; + pg_compress_algorithm alg; char *error_detail; - if (!parse_bc_algorithm(compression_algorithm, &alg)) + if (!parse_compress_algorithm(compression_algorithm, &alg)) pg_fatal("unrecognized compression algorithm \"%s\"", compression_algorithm); - parse_bc_specification(alg, compression_detail, &client_compress); - error_detail = validate_bc_specification(&client_compress); + parse_compress_specification(alg, compression_detail, &client_compress); + error_detail = validate_compress_specification(&client_compress); if (error_detail != NULL) pg_fatal("invalid compression specification: %s", error_detail); @@ -2574,7 +2574,7 @@ main(int argc, char **argv) else { Assert(compressloc == COMPRESS_LOCATION_SERVER); - client_compress.algorithm = BACKUP_COMPRESSION_NONE; + client_compress.algorithm = PG_COMPRESSION_NONE; client_compress.options = 0; } @@ -2593,7 +2593,7 @@ main(int argc, char **argv) * Client-side compression doesn't make sense unless tar format is in use. */ if (format == 'p' && compressloc == COMPRESS_LOCATION_CLIENT && - client_compress.algorithm != BACKUP_COMPRESSION_NONE) + client_compress.algorithm != PG_COMPRESSION_NONE) { pg_log_error("only tar mode backups can be compressed"); pg_log_error_hint("Try \"%s --help\" for more information.", progname); |
