mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Add suport for server-side LZ4 base backup compression.
LZ4 compression can be a lot faster than gzip compression, so users may prefer it even if the compression ratio is not as good. We will want pg_basebackup to support LZ4 compression and decompression on the client side as well, and there is a pending patch for that, but it's by a different author, so I am committing this part separately for that reason. Jeevan Ladhe, reviewed by Tushar Ahuja and by me. Discussion: http://postgr.es/m/CANm22Cg9cArXEaYgHVZhCnzPLfqXCZLAzjwTq7Fc0quXRPfbxA@mail.gmail.com
This commit is contained in:
@@ -391,7 +391,7 @@ usage(void)
|
||||
printf(_(" -X, --wal-method=none|fetch|stream\n"
|
||||
" include required WAL files with specified method\n"));
|
||||
printf(_(" -z, --gzip compress tar output\n"));
|
||||
printf(_(" -Z, --compress={[{client,server}-]gzip,none}[:LEVEL] or [LEVEL]\n"
|
||||
printf(_(" -Z, --compress={[{client,server}-]gzip,lz4,none}[:LEVEL] or [LEVEL]\n"
|
||||
" compress tar output with given compression method or level\n"));
|
||||
printf(_("\nGeneral options:\n"));
|
||||
printf(_(" -c, --checkpoint=fast|spread\n"
|
||||
@@ -1003,6 +1003,11 @@ parse_compress_options(char *src, WalCompressionMethod *methodres,
|
||||
*methodres = COMPRESSION_GZIP;
|
||||
*locationres = COMPRESS_LOCATION_SERVER;
|
||||
}
|
||||
else if (pg_strcasecmp(firstpart, "server-lz4") == 0)
|
||||
{
|
||||
*methodres = COMPRESSION_LZ4;
|
||||
*locationres = COMPRESS_LOCATION_SERVER;
|
||||
}
|
||||
else if (pg_strcasecmp(firstpart, "none") == 0)
|
||||
{
|
||||
*methodres = COMPRESSION_NONE;
|
||||
@@ -1930,6 +1935,9 @@ BaseBackup(void)
|
||||
case COMPRESSION_GZIP:
|
||||
compressmethodstr = "gzip";
|
||||
break;
|
||||
case COMPRESSION_LZ4:
|
||||
compressmethodstr = "lz4";
|
||||
break;
|
||||
default:
|
||||
Assert(false);
|
||||
break;
|
||||
@@ -2772,8 +2780,12 @@ main(int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
case COMPRESSION_LZ4:
|
||||
/* option not supported */
|
||||
Assert(false);
|
||||
if (compresslevel > 12)
|
||||
{
|
||||
pg_log_error("compression level %d of method %s higher than maximum of 12",
|
||||
compresslevel, "lz4");
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user