8000 Fix incorrect value for "strategy" with deflateParams() in walmethods.c · postgres/postgres@f01cc02 · GitHub
[go: up one dir, main page]

Skip to content

Commit f01cc02

Browse files
committed
Fix incorrect value for "strategy" with deflateParams() in walmethods.c
The zlib documentation mentions the values supported for the compression strategy, but this code has been using a hardcoded value of 0 rather than Z_DEFAULT_STRATEGY. This commit adjusts the code to use Z_DEFAULT_STRATEGY. Backpatch down to where this code has been added to ease the backport of any future patch touching this area. Reported-by: Tom Lane Discussion: https://postgr.es/m/1400032.1662217889@sss.pgh.pa.us Backpatch-through: 10
1 parent e962235 commit f01cc02

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/bin/pg_basebackup/walmethods.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ tar_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
703703
return NULL;
704704

705705
/* Turn off compression for header */
706-
if (deflateParams(tar_data->zp, 0, 0) != Z_OK)
706+
if (deflateParams(tar_data->zp, 0, Z_DEFAULT_STRATEGY) != Z_OK)
707707
{
708708
tar_set_error("could not change compression parameters");
709709
return NULL;
@@ -741,7 +741,8 @@ tar_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
741741
return NULL;
742742

743743
/* Re-enable compression for the rest of the file */
744-
if (deflateParams(tar_data->zp, tar_data->compression, 0) != Z_OK)
744+
if (deflateParams(tar_data->zp, tar_data->compression,
745+
Z_DEFAULT_STRATEGY) != Z_OK)
745746
{
746747
tar_set_error("could not change compression parameters");
747748
return NULL;
@@ -955,7 +956,7 @@ tar_close(Walfile f, WalCloseMethod method)
955956
else
956957
{
957958
/* Turn off compression */
958-
if (deflateParams(tar_data->zp, 0, 0) != Z_OK)
959+
if (deflateParams(tar_data->zp, 0, Z_DEFAULT_STRATEGY) != Z_OK)
959960
{
960961
tar_set_error("could not change compression parameters");
961962
return -1;
@@ -966,7 +967,8 @@ tar_close(Walfile f, WalCloseMethod method)
966967
return -1;
967968

968969
/* Turn compression back on */
969-
if (deflateParams(tar_data->zp, tar_data->compression, 0) != Z_OK)
970+
if (deflateParams(tar_data->zp, tar_data->compression,
971+
Z_DEFAULT_STRATEGY) != Z_OK)
970972
{
971973
tar_set_error("could not change compression parameters");
972974
return -1;

0 commit comments

Comments
 (0)
0