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

Commit3603f7c

Browse files
committed
Remove WalCompressionMethod in favor of pg_compress_algorithm
The same structure, with the same set of elements (for none, lz4, gzipand zstd), exists in compression.h, so let's make use of the centralizedversion instead of duplicating things. Some of the variables usedpreviously for WalCompressionMethod are renamed to stick better with thenew structure and routine names.WalCompressionMethod was leading to some confusion in walmethods.c, asit was sometimes used to refer to some data unrelated to WAL.Reported-by: Robert HaasAuthor: Michael PaquierReviewed-by: Robert Haas, Georgios KokolatosDiscussion:https://postgr.es/m/YlPQGNAAa04raObK@paquier.xyz
1 parentce4f46f commit3603f7c

File tree

5 files changed

+84
-92
lines changed

5 files changed

+84
-92
lines changed

‎src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ typedef struct
520520
charxlog[MAXPGPATH];/* directory or tarfile depending on mode */
521521
char*sysidentifier;
522522
inttimeline;
523-
WalCompressionMethodwal_compress_method;
523+
pg_compress_algorithmwal_compress_algorithm;
524524
intwal_compress_level;
525525
}logstreamer_param;
526526

@@ -550,11 +550,11 @@ LogStreamerMain(logstreamer_param *param)
550550
stream.replication_slot=replication_slot;
551551
if (format=='p')
552552
stream.walmethod=CreateWalDirectoryMethod(param->xlog,
553-
COMPRESSION_NONE,0,
553+
PG_COMPRESSION_NONE,0,
554554
stream.do_sync);
555555
else
556556
stream.walmethod=CreateWalTarMethod(param->xlog,
557-
param->wal_compress_method,
557+
param->wal_compress_algorithm,
558558
param->wal_compress_level,
559559
stream.do_sync);
560560

@@ -602,7 +602,7 @@ LogStreamerMain(logstreamer_param *param)
602602
*/
603603
staticvoid
604604
StartLogStreamer(char*startpos,uint32timeline,char*sysidentifier,
605-
WalCompressionMethodwal_compress_method,
605+
pg_compress_algorithmwal_compress_algorithm,
606606
intwal_compress_level)
607607
{
608608
logstreamer_param*param;
@@ -613,7 +613,7 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier,
613613
param=pg_malloc0(sizeof(logstreamer_param));
614614
param->timeline=timeline;
615615
param->sysidentifier=sysidentifier;
616-
param->wal_compress_method=wal_compress_method;
616+
param->wal_compress_algorithm=wal_compress_algorithm;
617617
param->wal_compress_level=wal_compress_level;
618618

619619
/* Convert the starting position */
@@ -2019,27 +2019,27 @@ BaseBackup(char *compression_algorithm, char *compression_detail,
20192019
*/
20202020
if (includewal==STREAM_WAL)
20212021
{
2022-
WalCompressionMethodwal_compress_method;
2022+
pg_compress_algorithmwal_compress_algorithm;
20232023
intwal_compress_level;
20242024

20252025
if (verbose)
20262026
pg_log_info("starting background WAL receiver");
20272027

20282028
if (client_compress->algorithm==PG_COMPRESSION_GZIP)
20292029
{
2030-
wal_compress_method=COMPRESSION_GZIP;
2030+
wal_compress_algorithm=PG_COMPRESSION_GZIP;
20312031
wal_compress_level=
20322032
(client_compress->options&PG_COMPRESSION_OPTION_LEVEL)
20332033
!=0 ?client_compress->level :0;
20342034
}
20352035
else
20362036
{
2037-
wal_compress_method=COMPRESSION_NONE;
2037+
wal_compress_algorithm=PG_COMPRESSION_NONE;
20382038
wal_compress_level=0;
20392039
}
20402040

20412041
StartLogStreamer(xlogstart,starttli,sysidentifier,
2042-
wal_compress_method,wal_compress_level);
2042+
wal_compress_algorithm,wal_compress_level);
20432043
}
20442044

20452045
if (serverMajor >=1500)

‎src/bin/pg_basebackup/pg_receivewal.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static bool do_drop_slot = false;
5252
staticbooldo_sync= true;
5353
staticboolsynchronous= false;
5454
staticchar*replication_slot=NULL;
55-
staticWalCompressionMethodcompression_method=COMPRESSION_NONE;
55+
staticpg_compress_algorithmcompression_algorithm=PG_COMPRESSION_NONE;
5656
staticXLogRecPtrendpos=InvalidXLogRecPtr;
5757

5858

@@ -114,7 +114,7 @@ usage(void)
114114
*/
115115
staticbool
116116
is_xlogfilename(constchar*filename,bool*ispartial,
117-
WalCompressionMethod*wal_compression_method)
117+
pg_compress_algorithm*wal_compression_algorithm)
118118
{
119119
size_tfname_len=strlen(filename);
120120
size_txlog_pattern_len=strspn(filename,"0123456789ABCDEF");
@@ -127,7 +127,7 @@ is_xlogfilename(const char *filename, bool *ispartial,
127127
if (fname_len==XLOG_FNAME_LEN)
128128
{
129129
*ispartial= false;
130-
*wal_compression_method=COMPRESSION_NONE;
130+
*wal_compression_algorithm=PG_COMPRESSION_NONE;
131131
return true;
132132
}
133133

@@ -136,7 +136,7 @@ is_xlogfilename(const char *filename, bool *ispartial,
136136
strcmp(filename+XLOG_FNAME_LEN,".gz")==0)
137137
{
138138
*ispartial= false;
139-
*wal_compression_method=COMPRESSION_GZIP;
139+
*wal_compression_algorithm=PG_COMPRESSION_GZIP;
140140
return true;
141141
}
142142

@@ -145,7 +145,7 @@ is_xlogfilename(const char *filename, bool *ispartial,
145145
strcmp(filename+XLOG_FNAME_LEN,".lz4")==0)
146146
{
147147
*ispartial= false;
148-
*wal_compression_method=COMPRESSION_LZ4;
148+
*wal_compression_algorithm=PG_COMPRESSION_LZ4;
149149
return true;
150150
}
151151

@@ -154,7 +154,7 @@ is_xlogfilename(const char *filename, bool *ispartial,
154154
strcmp(filename+XLOG_FNAME_LEN,".partial")==0)
155155
{
156156
*ispartial= true;
157-
*wal_compression_method=COMPRESSION_NONE;
157+
*wal_compression_algorithm=PG_COMPRESSION_NONE;
158158
return true;
159159
}
160160

@@ -163,7 +163,7 @@ is_xlogfilename(const char *filename, bool *ispartial,
163163
strcmp(filename+XLOG_FNAME_LEN,".gz.partial")==0)
164164
{
165165
*ispartial= true;
166-
*wal_compression_method=COMPRESSION_GZIP;
166+
*wal_compression_algorithm=PG_COMPRESSION_GZIP;
167167
return true;
168168
}
169169

@@ -172,7 +172,7 @@ is_xlogfilename(const char *filename, bool *ispartial,
172172
strcmp(filename+XLOG_FNAME_LEN,".lz4.partial")==0)
173173
{
174174
*ispartial= true;
175-
*wal_compression_method=COMPRESSION_LZ4;
175+
*wal_compression_algorithm=PG_COMPRESSION_LZ4;
176176
return true;
177177
}
178178

@@ -279,11 +279,11 @@ FindStreamingStart(uint32 *tli)
279279
{
280280
uint32tli;
281281
XLogSegNosegno;
282-
WalCompressionMethodwal_compression_method;
282+
pg_compress_algorithmwal_compression_algorithm;
283283
boolispartial;
284284

285285
if (!is_xlogfilename(dirent->d_name,
286-
&ispartial,&wal_compression_method))
286+
&ispartial,&wal_compression_algorithm))
287287
continue;
288288

289289
/*
@@ -309,7 +309,7 @@ FindStreamingStart(uint32 *tli)
309309
* where WAL segments could have been compressed by a different source
310310
* than pg_receivewal, like an archive_command with lz4.
311311
*/
312-
if (!ispartial&&wal_compression_method==COMPRESSION_NONE)
312+
if (!ispartial&&wal_compression_algorithm==PG_COMPRESSION_NONE)
313313
{
314314
structstatstatbuf;
315315
charfullpath[MAXPGPATH*2];
@@ -325,7 +325,7 @@ FindStreamingStart(uint32 *tli)
325325
continue;
326326
}
327327
}
328-
elseif (!ispartial&&wal_compression_method==COMPRESSION_GZIP)
328+
elseif (!ispartial&&wal_compression_algorithm==PG_COMPRESSION_GZIP)
329329
{
330330
intfd;
331331
charbuf[4];
@@ -364,7 +364,7 @@ FindStreamingStart(uint32 *tli)
364364
continue;
365365
}
366366
}
367-
elseif (!ispartial&&wal_compression_method==COMPRESSION_LZ4)
367+
elseif (!ispartial&&wal_compression_algorithm==PG_COMPRESSION_LZ4)
368368
{
369369
#ifdefUSE_LZ4
370370
#defineLZ4_CHUNK_SZ64 * 1024/* 64kB as maximum chunk size read */
@@ -590,7 +590,7 @@ StreamLog(void)
590590
stream.do_sync=do_sync;
591591
stream.mark_done= false;
592592
stream.walmethod=CreateWalDirectoryMethod(basedir,
593-
compression_method,
593+
compression_algorithm,
594594
compresslevel,
595595
stream.do_sync);
596596
stream.partial_suffix=".partial";
@@ -750,11 +750,11 @@ main(int argc, char **argv)
750750
break;
751751
case6:
752752
if (pg_strcasecmp(optarg,"gzip")==0)
753-
compression_method=COMPRESSION_GZIP;
753+
compression_algorithm=PG_COMPRESSION_GZIP;
754754
elseif (pg_strcasecmp(optarg,"lz4")==0)
755-
compression_method=COMPRESSION_LZ4;
755+
compression_algorithm=PG_COMPRESSION_LZ4;
756756
elseif (pg_strcasecmp(optarg,"none")==0)
757-
compression_method=COMPRESSION_NONE;
757+
compression_algorithm=PG_COMPRESSION_NONE;
758758
else
759759
pg_fatal("invalid value \"%s\" for option %s",
760760
optarg,"--compression-method");
@@ -814,9 +814,9 @@ main(int argc, char **argv)
814814
/*
815815
* Compression-related options.
816816
*/
817-
switch (compression_method)
817+
switch (compression_algorithm)
818818
{
819-
caseCOMPRESSION_NONE:
819+
casePG_COMPRESSION_NONE:
820820
if (compresslevel!=0)
821821
{
822822
pg_log_error("cannot use --compress with --compression-method=%s",
@@ -825,7 +825,7 @@ main(int argc, char **argv)
825825
exit(1);
826826
}
827827
break;
828-
caseCOMPRESSION_GZIP:
828+
casePG_COMPRESSION_GZIP:
829829
#ifdefHAVE_LIBZ
830830
if (compresslevel==0)
831831
{
@@ -837,7 +837,7 @@ main(int argc, char **argv)
837837
"gzip");
838838
#endif
839839
break;
840-
caseCOMPRESSION_LZ4:
840+
casePG_COMPRESSION_LZ4:
841841
#ifdefUSE_LZ4
842842
if (compresslevel!=0)
843843
{
@@ -851,7 +851,7 @@ main(int argc, char **argv)
851851
"LZ4");
852852
#endif
853853
break;
854-
caseCOMPRESSION_ZSTD:
854+
casePG_COMPRESSION_ZSTD:
855855
pg_fatal("compression with %s is not yet supported","ZSTD");
856856
break;
857857
}

‎src/bin/pg_basebackup/receivelog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ open_walfile(StreamCtl *stream, XLogRecPtr startpoint)
114114
* When streaming to tar, no file with this name will exist before, so we
115115
* never have to verify a size.
116116
*/
117-
if (stream->walmethod->compression_method()==COMPRESSION_NONE&&
117+
if (stream->walmethod->compression_algorithm()==PG_COMPRESSION_NONE&&
118118
stream->walmethod->existsfile(fn))
119119
{
120120
size=stream->walmethod->get_file_size(fn);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp