Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita4b5754

Browse files
committed
Rename backup_compression.{c,h} to compression.{c,h}
Compression option handling (level, algorithm or even workers) can beused across several parts of the system and not only base backups.Structures, objects and routines are renamed in consequence, to removethe concept of base backups from this part of the code making thischange straight-forward.pg_receivewal, that has gained support for LZ4 sincebabbbb5, will makeuse of this infrastructure for its set of compression options, bringingmore consistency with pg_basebackup. This cleanup needs to be donebefore releasing a beta of 15. pg_dump is a potential future target, aswell, and adding more compression options to it may happen in 16~.Author: Michael PaquierReviewed-by: Robert Haas, Georgios KokolatosDiscussion:https://postgr.es/m/YlPQGNAAa04raObK@paquier.xyz
1 parentbd037dc commita4b5754

File tree

17 files changed

+142
-140
lines changed

17 files changed

+142
-140
lines changed

‎src/backend/replication/basebackup.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include<time.h>
1818

1919
#include"access/xlog_internal.h"/* for pg_start/stop_backup */
20-
#include"common/backup_compression.h"
20+
#include"common/compression.h"
2121
#include"common/file_perm.h"
2222
#include"commands/defrem.h"
2323
#include"lib/stringinfo.h"
@@ -68,8 +68,8 @@ typedef struct
6868
booluse_copytblspc;
6969
BaseBackupTargetHandle*target_handle;
7070
backup_manifest_optionmanifest;
71-
bc_algorithmcompression;
72-
bc_specificationcompression_specification;
71+
pg_compress_algorithmcompression;
72+
pg_compress_specificationcompression_specification;
7373
pg_checksum_typemanifest_checksum_type;
7474
}basebackup_options;
7575

@@ -691,8 +691,8 @@ parse_basebackup_options(List *options, basebackup_options *opt)
691691
MemSet(opt,0,sizeof(*opt));
692692
opt->manifest=MANIFEST_OPTION_NO;
693693
opt->manifest_checksum_type=CHECKSUM_TYPE_CRC32C;
694-
opt->compression=BACKUP_COMPRESSION_NONE;
695-
opt->compression_specification.algorithm=BACKUP_COMPRESSION_NONE;
694+
opt->compression=PG_COMPRESSION_NONE;
695+
opt->compression_specification.algorithm=PG_COMPRESSION_NONE;
696696

697697
foreach(lopt,options)
698698
{
@@ -859,7 +859,7 @@ parse_basebackup_options(List *options, basebackup_options *opt)
859859
ereport(ERROR,
860860
(errcode(ERRCODE_SYNTAX_ERROR),
861861
errmsg("duplicate option \"%s\"",defel->defname)));
862-
if (!parse_bc_algorithm(optval,&opt->compression))
862+
if (!parse_compress_algorithm(optval,&opt->compression))
863863
ereport(ERROR,
864864
(errcode(ERRCODE_SYNTAX_ERROR),
865865
errmsg("unrecognized compression algorithm \"%s\"",
@@ -924,10 +924,10 @@ parse_basebackup_options(List *options, basebackup_options *opt)
924924
{
925925
char*error_detail;
926926

927-
parse_bc_specification(opt->compression,compression_detail_str,
928-
&opt->compression_specification);
927+
parse_compress_specification(opt->compression,compression_detail_str,
928+
&opt->compression_specification);
929929
error_detail=
930-
validate_bc_specification(&opt->compression_specification);
930+
validate_compress_specification(&opt->compression_specification);
931931
if (error_detail!=NULL)
932932
ereport(ERROR,
933933
errcode(ERRCODE_SYNTAX_ERROR),
@@ -978,11 +978,11 @@ SendBaseBackup(BaseBackupCmd *cmd)
978978
sink=bbsink_throttle_new(sink,opt.maxrate);
979979

980980
/* Set up server-side compression, if client requested it */
981-
if (opt.compression==BACKUP_COMPRESSION_GZIP)
981+
if (opt.compression==PG_COMPRESSION_GZIP)
982982
sink=bbsink_gzip_new(sink,&opt.compression_specification);
983-
elseif (opt.compression==BACKUP_COMPRESSION_LZ4)
983+
elseif (opt.compression==PG_COMPRESSION_LZ4)
984984
sink=bbsink_lz4_new(sink,&opt.compression_specification);
985-
elseif (opt.compression==BACKUP_COMPRESSION_ZSTD)
985+
elseif (opt.compression==PG_COMPRESSION_ZSTD)
986986
sink=bbsink_zstd_new(sink,&opt.compression_specification);
987987

988988
/* Set up progress reporting. */

‎src/backend/replication/basebackup_gzip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const bbsink_ops bbsink_gzip_ops = {
5959
* Create a new basebackup sink that performs gzip compression.
6060
*/
6161
bbsink*
62-
bbsink_gzip_new(bbsink*next,bc_specification*compress)
62+
bbsink_gzip_new(bbsink*next,pg_compress_specification*compress)
6363
{
6464
#ifndefHAVE_LIBZ
6565
ereport(ERROR,
@@ -72,7 +72,7 @@ bbsink_gzip_new(bbsink *next, bc_specification *compress)
7272

7373
Assert(next!=NULL);
7474

75-
if ((compress->options&BACKUP_COMPRESSION_OPTION_LEVEL)==0)
75+
if ((compress->options&PG_COMPRESSION_OPTION_LEVEL)==0)
7676
compresslevel=Z_DEFAULT_COMPRESSION;
7777
else
7878
{

‎src/backend/replication/basebackup_lz4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const bbsink_ops bbsink_lz4_ops = {
5959
* Create a new basebackup sink that performs lz4 compression.
6060
*/
6161
bbsink*
62-
bbsink_lz4_new(bbsink*next,bc_specification*compress)
62+
bbsink_lz4_new(bbsink*next,pg_compress_specification*compress)
6363
{
6464
#ifndefUSE_LZ4
6565
ereport(ERROR,
@@ -72,7 +72,7 @@ bbsink_lz4_new(bbsink *next, bc_specification *compress)
7272

7373
Assert(next!=NULL);
7474

75-
if ((compress->options&BACKUP_COMPRESSION_OPTION_LEVEL)==0)
75+
if ((compress->options&PG_COMPRESSION_OPTION_LEVEL)==0)
7676
compresslevel=0;
7777
else
7878
{

‎src/backend/replication/basebackup_zstd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef struct bbsink_zstd
2626
bbsinkbase;
2727

2828
/* Compression options */
29-
bc_specification*compress;
29+
pg_compress_specification*compress;
3030

3131
ZSTD_CCtx*cctx;
3232
ZSTD_outBufferzstd_outBuf;
@@ -58,7 +58,7 @@ const bbsink_ops bbsink_zstd_ops = {
5858
* Create a new basebackup sink that performs zstd compression.
5959
*/
6060
bbsink*
61-
bbsink_zstd_new(bbsink*next,bc_specification*compress)
61+
bbsink_zstd_new(bbsink*next,pg_compress_specification*compress)
6262
{
6363
#ifndefUSE_ZSTD
6464
ereport(ERROR,
@@ -90,13 +90,13 @@ bbsink_zstd_begin_backup(bbsink *sink)
9090
bbsink_zstd*mysink= (bbsink_zstd*)sink;
9191
size_toutput_buffer_bound;
9292
size_tret;
93-
bc_specification*compress=mysink->compress;
93+
pg_compress_specification*compress=mysink->compress;
9494

9595
mysink->cctx=ZSTD_createCCtx();
9696
if (!mysink->cctx)
9797
elog(ERROR,"could not create zstd compression context");
9898

99-
if ((compress->options&BACKUP_COMPRESSION_OPTION_LEVEL)!=0)
99+
if ((compress->options&PG_COMPRESSION_OPTION_LEVEL)!=0)
100100
{
101101
ret=ZSTD_CCtx_setParameter(mysink->cctx,ZSTD_c_compressionLevel,
102102
compress->level);
@@ -105,7 +105,7 @@ bbsink_zstd_begin_backup(bbsink *sink)
105105
compress->level,ZSTD_getErrorName(ret));
106106
}
107107

108-
if ((compress->options&BACKUP_COMPRESSION_OPTION_WORKERS)!=0)
108+
if ((compress->options&PG_COMPRESSION_OPTION_WORKERS)!=0)
109109
{
110110
/*
111111
* On older versions of libzstd, this option does not exist, and trying

‎src/bin/pg_basebackup/bbstreamer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifndefBBSTREAMER_H
2323
#defineBBSTREAMER_H
2424

25-
#include"common/backup_compression.h"
25+
#include"common/compression.h"
2626
#include"lib/stringinfo.h"
2727
#include"pqexpbuffer.h"
2828

@@ -201,17 +201,17 @@ bbstreamer_buffer_until(bbstreamer *streamer, const char **data, int *len,
201201
*/
202202
externbbstreamer*bbstreamer_plain_writer_new(char*pathname,FILE*file);
203203
externbbstreamer*bbstreamer_gzip_writer_new(char*pathname,FILE*file,
204-
bc_specification*compress);
204+
pg_compress_specification*compress);
205205
externbbstreamer*bbstreamer_extractor_new(constchar*basepath,
206206
constchar*(*link_map) (constchar*),
207207
void (*report_output_file) (constchar*));
208208

209209
externbbstreamer*bbstreamer_gzip_decompressor_new(bbstreamer*next);
210210
externbbstreamer*bbstreamer_lz4_compressor_new(bbstreamer*next,
211-
bc_specification*compress);
211+
pg_compress_specification*compress);
212212
externbbstreamer*bbstreamer_lz4_decompressor_new(bbstreamer*next);
213213
externbbstreamer*bbstreamer_zstd_compressor_new(bbstreamer*next,
214-
bc_specification*compress);
214+
pg_compress_specification*compress);
215215
externbbstreamer*bbstreamer_zstd_decompressor_new(bbstreamer*next);
216216
externbbstreamer*bbstreamer_tar_parser_new(bbstreamer*next);
217217
externbbstreamer*bbstreamer_tar_terminator_new(bbstreamer*next);

‎src/bin/pg_basebackup/bbstreamer_gzip.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const bbstreamer_ops bbstreamer_gzip_decompressor_ops = {
7777
*/
7878
bbstreamer*
7979
bbstreamer_gzip_writer_new(char*pathname,FILE*file,
80-
bc_specification*compress)
80+
pg_compress_specification*compress)
8181
{
8282
#ifdefHAVE_LIBZ
8383
bbstreamer_gzip_writer*streamer;
@@ -107,7 +107,7 @@ bbstreamer_gzip_writer_new(char *pathname, FILE *file,
107107
pg_fatal("could not open output file: %m");
108108
}
109109

110-
if ((compress->options&BACKUP_COMPRESSION_OPTION_LEVEL)!=0&&
110+
if ((compress->options&PG_COMPRESSION_OPTION_LEVEL)!=0&&
111111
gzsetparams(streamer->gzfile,compress->level,
112112
Z_DEFAULT_STRATEGY)!=Z_OK)
113113
pg_fatal("could not set compression level %d: %s",

‎src/bin/pg_basebackup/bbstreamer_lz4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const bbstreamer_ops bbstreamer_lz4_decompressor_ops = {
6767
* blocks.
6868
*/
6969
bbstreamer*
70-
bbstreamer_lz4_compressor_new(bbstreamer*next,bc_specification*compress)
70+
bbstreamer_lz4_compressor_new(bbstreamer*next,pg_compress_specification*compress)
7171
{
7272
#ifdefUSE_LZ4
7373
bbstreamer_lz4_frame*streamer;
@@ -88,7 +88,7 @@ bbstreamer_lz4_compressor_new(bbstreamer *next, bc_specification *compress)
8888
prefs=&streamer->prefs;
8989
memset(prefs,0,sizeof(LZ4F_preferences_t));
9090
prefs->frameInfo.blockSizeID=LZ4F_max256KB;
91-
if ((compress->options&BACKUP_COMPRESSION_OPTION_LEVEL)!=0)
91+
if ((compress->options&PG_COMPRESSION_OPTION_LEVEL)!=0)
9292
prefs->compressionLevel=compress->level;
9393

9494
ctxError=LZ4F_createCompressionContext(&streamer->cctx,LZ4F_VERSION);

‎src/bin/pg_basebackup/bbstreamer_zstd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const bbstreamer_ops bbstreamer_zstd_decompressor_ops = {
6363
* blocks.
6464
*/
6565
bbstreamer*
66-
bbstreamer_zstd_compressor_new(bbstreamer*next,bc_specification*compress)
66+
bbstreamer_zstd_compressor_new(bbstreamer*next,pg_compress_specification*compress)
6767
{
6868
#ifdefUSE_ZSTD
6969
bbstreamer_zstd_frame*streamer;
@@ -85,7 +85,7 @@ bbstreamer_zstd_compressor_new(bbstreamer *next, bc_specification *compress)
8585
pg_fatal("could not create zstd compression context");
8686

8787
/* Set compression level, if specified */
88-
if ((compress->options&BACKUP_COMPRESSION_OPTION_LEVEL)!=0)
88+
if ((compress->options&PG_COMPRESSION_OPTION_LEVEL)!=0)
8989
{
9090
ret=ZSTD_CCtx_setParameter(streamer->cctx,ZSTD_c_compressionLevel,
9191
compress->level);
@@ -95,7 +95,7 @@ bbstreamer_zstd_compressor_new(bbstreamer *next, bc_specification *compress)
9595
}
9696

9797
/* Set # of workers, if specified */
98-
if ((compress->options&BACKUP_COMPRESSION_OPTION_WORKERS)!=0)
98+
if ((compress->options&PG_COMPRESSION_OPTION_WORKERS)!=0)
9999
{
100100
/*
101101
* On older versions of libzstd, this option does not exist, and

‎src/bin/pg_basebackup/nls.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ GETTEXT_FILES = $(FRONTEND_COMMON_GETTEXT_FILES) \
1414
receivelog.c\
1515
streamutil.c\
1616
walmethods.c\
17-
../../common/backup_compression.c\
17+
../../common/compression.c\
1818
../../common/fe_memutils.c\
1919
../../common/file_utils.c\
2020
../../fe_utils/recovery_gen.c

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp