@@ -749,7 +749,7 @@ tar_write(Walfile f, const void *buf, size_t count)
749749tar_clear_error ();
750750
751751/* Tarfile will always be positioned at the end */
752- if (! tar_data -> compression_level )
752+ if (tar_data -> compression_method == COMPRESSION_NONE )
753753{
754754errno = 0 ;
755755r = write (tar_data -> fd ,buf ,count );
@@ -763,21 +763,20 @@ tar_write(Walfile f, const void *buf, size_t count)
763763return r ;
764764}
765765#ifdef HAVE_LIBZ
766- else
766+ else if ( tar_data -> compression_method == COMPRESSION_GZIP )
767767{
768768if (!tar_write_compressed_data (unconstify (void * ,buf ),count , false))
769769return -1 ;
770770((TarMethodFile * )f )-> currpos += count ;
771771return count ;
772772}
773- #else
773+ #endif
774774else
775775{
776- /* Can't happen - compression enabled with nolibz */
776+ /* Can't happen - compression enabled with nomethod set */
777777tar_data -> lasterrno = ENOSYS ;
778778return -1 ;
779779}
780- #endif
781780}
782781
783782static bool
@@ -833,7 +832,7 @@ tar_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
833832}
834833
835834#ifdef HAVE_LIBZ
836- if (tar_data -> compression_level )
835+ if (tar_data -> compression_method == COMPRESSION_GZIP )
837836{
838837tar_data -> zp = (z_streamp )pg_malloc (sizeof (z_stream ));
839838tar_data -> zp -> zalloc = Z_NULL ;
@@ -884,7 +883,7 @@ tar_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
884883pg_free (tmppath );
885884
886885#ifdef HAVE_LIBZ
887- if (tar_data -> compression_level )
886+ if (tar_data -> compression_method == COMPRESSION_GZIP )
888887{
889888/* Flush existing data */
890889if (!tar_write_compressed_data (NULL ,0 , true))
@@ -909,7 +908,7 @@ tar_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
909908}
910909tar_data -> currentfile -> currpos = 0 ;
911910
912- if (! tar_data -> compression_level )
911+ if (tar_data -> compression_method == COMPRESSION_NONE )
913912{
914913errno = 0 ;
915914if (write (tar_data -> fd ,tar_data -> currentfile -> header ,
@@ -923,7 +922,7 @@ tar_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
923922}
924923}
925924#ifdef HAVE_LIBZ
926- else
925+ else if ( tar_data -> compression_method == COMPRESSION_GZIP )
927926{
928927/* Write header through the zlib APIs but with no compression */
929928if (!tar_write_compressed_data (tar_data -> currentfile -> header ,
@@ -938,6 +937,11 @@ tar_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
938937}
939938}
940939#endif
940+ else
941+ {
942+ /* not reachable */
943+ Assert (false);
944+ }
941945
942946tar_data -> currentfile -> pathname = pg_strdup (pathname );
943947
@@ -948,7 +952,7 @@ tar_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
948952if (pad_to_size )
949953{
950954tar_data -> currentfile -> pad_to_size = pad_to_size ;
951- if (! tar_data -> compression_level )
955+ if (tar_data -> compression_method == COMPRESSION_NONE )
952956{
953957/* Uncompressed, so pad now */
954958if (!tar_write_padding_data (tar_data -> currentfile ,pad_to_size ))
@@ -1009,7 +1013,7 @@ tar_sync(Walfile f)
10091013 * Always sync the whole tarfile, because that's all we can do. This makes
10101014 * no sense on compressed files, so just ignore those.
10111015 */
1012- if (tar_data -> compression_level )
1016+ if (tar_data -> compression_method != COMPRESSION_NONE )
10131017return 0 ;
10141018
10151019r = fsync (tar_data -> fd );
@@ -1030,7 +1034,7 @@ tar_close(Walfile f, WalCloseMethod method)
10301034
10311035if (method == CLOSE_UNLINK )
10321036{
1033- if (tar_data -> compression_level )
1037+ if (tar_data -> compression_method != COMPRESSION_NONE )
10341038{
10351039tar_set_error ("unlink not supported with compression" );
10361040return -1 ;
@@ -1061,7 +1065,7 @@ tar_close(Walfile f, WalCloseMethod method)
10611065 */
10621066if (tf -> pad_to_size )
10631067{
1064- if (tar_data -> compression_level )
1068+ if (tar_data -> compression_method == COMPRESSION_GZIP )
10651069{
10661070/*
10671071 * A compressed tarfile is padded on close since we cannot know
@@ -1102,7 +1106,7 @@ tar_close(Walfile f, WalCloseMethod method)
11021106
11031107
11041108#ifdef HAVE_LIBZ
1105- if (tar_data -> compression_level )
1109+ if (tar_data -> compression_method == COMPRESSION_GZIP )
11061110{
11071111/* Flush the current buffer */
11081112if (!tar_write_compressed_data (NULL ,0 , true))
@@ -1131,7 +1135,7 @@ tar_close(Walfile f, WalCloseMethod method)
11311135tar_data -> lasterrno = errno ;
11321136return -1 ;
11331137}
1134- if (! tar_data -> compression_level )
1138+ if (tar_data -> compression_method == COMPRESSION_NONE )
11351139{
11361140errno = 0 ;
11371141if (write (tar_data -> fd ,tf -> header ,TAR_BLOCK_SIZE )!= TAR_BLOCK_SIZE )
@@ -1142,7 +1146,7 @@ tar_close(Walfile f, WalCloseMethod method)
11421146}
11431147}
11441148#ifdef HAVE_LIBZ
1145- else
1149+ else if ( tar_data -> compression_method == COMPRESSION_GZIP )
11461150{
11471151/* Turn off compression */
11481152if (deflateParams (tar_data -> zp ,0 ,0 )!= Z_OK )
@@ -1164,6 +1168,11 @@ tar_close(Walfile f, WalCloseMethod method)
11641168}
11651169}
11661170#endif
1171+ else
1172+ {
1173+ /* not reachable */
1174+ Assert (false);
1175+ }
11671176
11681177/* Move file pointer back down to end, so we can write the next file */
11691178if (lseek (tar_data -> fd ,0 ,SEEK_END )< 0 )
@@ -1212,7 +1221,7 @@ tar_finish(void)
12121221
12131222/* A tarfile always ends with two empty blocks */
12141223MemSet (zerobuf ,0 ,sizeof (zerobuf ));
1215- if (! tar_data -> compression_level )
1224+ if (tar_data -> compression_method == COMPRESSION_NONE )
12161225{
12171226errno = 0 ;
12181227if (write (tar_data -> fd ,zerobuf ,sizeof (zerobuf ))!= sizeof (zerobuf ))
@@ -1223,7 +1232,7 @@ tar_finish(void)
12231232}
12241233}
12251234#ifdef HAVE_LIBZ
1226- else
1235+ else if ( tar_data -> compression_method == COMPRESSION_GZIP )
12271236{
12281237if (!tar_write_compressed_data (zerobuf ,sizeof (zerobuf ), false))
12291238return false;
@@ -1268,6 +1277,11 @@ tar_finish(void)
12681277}
12691278}
12701279#endif
1280+ else
1281+ {
1282+ /* not reachable */
1283+ Assert (false);
1284+ }
12711285
12721286/* sync the empty blocks as well, since they're after the last file */
12731287if (tar_data -> sync )
@@ -1312,7 +1326,8 @@ CreateWalTarMethod(const char *tarbase,
13121326int compression_level ,bool sync )
13131327{
13141328WalWriteMethod * method ;
1315- const char * suffix = (compression_level != 0 ) ?".tar.gz" :".tar" ;
1329+ const char * suffix = (compression_method == COMPRESSION_GZIP ) ?
1330+ ".tar.gz" :".tar" ;
13161331
13171332method = pg_malloc0 (sizeof (WalWriteMethod ));
13181333method -> open_for_write = tar_open_for_write ;
@@ -1335,7 +1350,7 @@ CreateWalTarMethod(const char *tarbase,
13351350tar_data -> compression_level = compression_level ;
13361351tar_data -> sync = sync ;
13371352#ifdef HAVE_LIBZ
1338- if (compression_level )
1353+ if (compression_method == COMPRESSION_GZIP )
13391354tar_data -> zlibOut = (char * )pg_malloc (ZLIB_OUT_SIZE + 1 );
13401355#endif
13411356
@@ -1347,7 +1362,7 @@ FreeWalTarMethod(void)
13471362{
13481363pg_free (tar_data -> tarfilename );
13491364#ifdef HAVE_LIBZ
1350- if (tar_data -> compression_level )
1365+ if (tar_data -> compression_method == COMPRESSION_GZIP )
13511366pg_free (tar_data -> zlibOut );
13521367#endif
13531368pg_free (tar_data );