Change HAVE_LIBLZ4 and HAVE_LIBZSTD tests to USE_LZ4 and USE_ZSTD.
authorRobert Haas <rhaas@postgresql.org>
Tue, 15 Mar 2022 17:06:25 +0000 (13:06 -0400)
committerRobert Haas <rhaas@postgresql.org>
Tue, 15 Mar 2022 17:06:25 +0000 (13:06 -0400)
These tests were added recently, but older code tests USE_LZ4 rathr
than HAVE_LIBLZ4, so let's follow the established precedent. It
also seems more consistent with the intent of the configure tests,
since I think that the USE_* symbols are intended to correspond to
what the user requested, and the HAVE_* symbols to what configure
found while probing.

Discussion: http://postgr.es/m/CA+Tgmoap+hTD2-QNPJLH4tffeFE8MX5+xkbFKMU3FKBy=ZSNKA@mail.gmail.com

src/backend/replication/basebackup_lz4.c
src/backend/replication/basebackup_zstd.c
src/bin/pg_basebackup/bbstreamer_lz4.c
src/bin/pg_basebackup/bbstreamer_zstd.c
src/bin/pg_basebackup/pg_receivewal.c
src/bin/pg_basebackup/t/020_pg_receivewal.pl
src/bin/pg_basebackup/walmethods.c
src/bin/pg_dump/t/002_pg_dump.pl
src/bin/pg_verifybackup/t/008_untar.pl
src/bin/pg_verifybackup/t/009_extract.pl
src/bin/pg_verifybackup/t/010_client_untar.pl

index 472b620d7c7032271525979be85af743ceb3c36e..d838f723d0258219e0bf6ec7375171b29e48f7ee 100644 (file)
  */
 #include "postgres.h"
 
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
 #include <lz4frame.h>
 #endif
 
 #include "replication/basebackup_sink.h"
 
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
 
 typedef struct bbsink_lz4
 {
@@ -62,7 +62,7 @@ const bbsink_ops bbsink_lz4_ops = {
 bbsink *
 bbsink_lz4_new(bbsink *next, int compresslevel)
 {
-#ifndef HAVE_LIBLZ4
+#ifndef USE_LZ4
        ereport(ERROR,
                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                         errmsg("lz4 compression is not supported by this build")));
@@ -87,7 +87,7 @@ bbsink_lz4_new(bbsink *next, int compresslevel)
 #endif
 }
 
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
 
 /*
  * Begin backup.
index e3f9b1d4dc05c68884af37fc342ddbc9be5b74b5..c0e2be6e27b766318ff26d3e32f54e55d1cc162a 100644 (file)
  */
 #include "postgres.h"
 
-#ifdef HAVE_LIBZSTD
+#ifdef USE_ZSTD
 #include <zstd.h>
 #endif
 
 #include "replication/basebackup_sink.h"
 
-#ifdef HAVE_LIBZSTD
+#ifdef USE_ZSTD
 
 typedef struct bbsink_zstd
 {
@@ -61,7 +61,7 @@ const bbsink_ops bbsink_zstd_ops = {
 bbsink *
 bbsink_zstd_new(bbsink *next, int compresslevel)
 {
-#ifndef HAVE_LIBZSTD
+#ifndef USE_ZSTD
        ereport(ERROR,
                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                         errmsg("zstd compression is not supported by this build")));
@@ -86,7 +86,7 @@ bbsink_zstd_new(bbsink *next, int compresslevel)
 #endif
 }
 
-#ifdef HAVE_LIBZSTD
+#ifdef USE_ZSTD
 
 /*
  * Begin backup.
index bde018246f277e6298a26297a361619260615a23..810052e4e3d182ce0bd527133d52e134f9f378e5 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <unistd.h>
 
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
 #include <lz4frame.h>
 #endif
 
@@ -22,7 +22,7 @@
 #include "common/file_perm.h"
 #include "common/string.h"
 
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
 typedef struct bbstreamer_lz4_frame
 {
        bbstreamer      base;
@@ -69,7 +69,7 @@ const bbstreamer_ops bbstreamer_lz4_decompressor_ops = {
 bbstreamer *
 bbstreamer_lz4_compressor_new(bbstreamer *next, int compresslevel)
 {
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
        bbstreamer_lz4_frame   *streamer;
        LZ4F_errorCode_t                ctxError;
        LZ4F_preferences_t         *prefs;
@@ -114,7 +114,7 @@ bbstreamer_lz4_compressor_new(bbstreamer *next, int compresslevel)
 #endif
 }
 
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
 /*
  * Compress the input data to output buffer.
  *
@@ -280,7 +280,7 @@ bbstreamer_lz4_compressor_free(bbstreamer *streamer)
 bbstreamer *
 bbstreamer_lz4_decompressor_new(bbstreamer *next)
 {
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
        bbstreamer_lz4_frame    *streamer;
        LZ4F_errorCode_t                ctxError;
 
@@ -309,7 +309,7 @@ bbstreamer_lz4_decompressor_new(bbstreamer *next)
 #endif
 }
 
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
 /*
  * Decompress the input data to output buffer until we run out of input
  * data. Each time the output buffer is full, pass on the decompressed data
index cc68367dd56fa398915d67efa6d809afea49927a..e86749a8fb7cf67bd4e842f8013b01b2a8aa229c 100644 (file)
 
 #include <unistd.h>
 
-#ifdef HAVE_LIBZSTD
+#ifdef USE_ZSTD
 #include <zstd.h>
 #endif
 
 #include "bbstreamer.h"
 #include "common/logging.h"
 
-#ifdef HAVE_LIBZSTD
+#ifdef USE_ZSTD
 
 typedef struct bbstreamer_zstd_frame
 {
@@ -65,7 +65,7 @@ const bbstreamer_ops bbstreamer_zstd_decompressor_ops = {
 bbstreamer *
 bbstreamer_zstd_compressor_new(bbstreamer *next, int compresslevel)
 {
-#ifdef HAVE_LIBZSTD
+#ifdef USE_ZSTD
        bbstreamer_zstd_frame *streamer;
 
        Assert(next != NULL);
@@ -99,7 +99,7 @@ bbstreamer_zstd_compressor_new(bbstreamer *next, int compresslevel)
 #endif
 }
 
-#ifdef HAVE_LIBZSTD
+#ifdef USE_ZSTD
 /*
  * Compress the input data to output buffer.
  *
@@ -225,7 +225,7 @@ bbstreamer_zstd_compressor_free(bbstreamer *streamer)
 bbstreamer *
 bbstreamer_zstd_decompressor_new(bbstreamer *next)
 {
-#ifdef HAVE_LIBZSTD
+#ifdef USE_ZSTD
        bbstreamer_zstd_frame *streamer;
 
        Assert(next != NULL);
@@ -257,7 +257,7 @@ bbstreamer_zstd_decompressor_new(bbstreamer *next)
 #endif
 }
 
-#ifdef HAVE_LIBZSTD
+#ifdef USE_ZSTD
 /*
  * Decompress the input data to output buffer until we run out of input
  * data. Each time the output buffer is full, pass on the decompressed data
index 8a4c2b8964657a9094273d753a46f79c93c67a65..e2ceafeb0f59ae191b45d78107730da8c8f18321 100644 (file)
@@ -32,7 +32,7 @@
 #include "receivelog.h"
 #include "streamutil.h"
 
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
 #include "lz4frame.h"
 #endif
 
@@ -382,7 +382,7 @@ FindStreamingStart(uint32 *tli)
                }
                else if (!ispartial && wal_compression_method == COMPRESSION_LZ4)
                {
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
 #define LZ4_CHUNK_SZ   64 * 1024       /* 64kB as maximum chunk size read */
                        int                     fd;
                        ssize_t         r;
@@ -889,7 +889,7 @@ main(int argc, char **argv)
 #endif
                        break;
                case COMPRESSION_LZ4:
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
                        if (compresslevel != 0)
                        {
                                pg_log_error("cannot use --compress with --compression-method=%s",
index 545618e0b201797a2618e89321c98ce7209ae885..8c38816b22b0cd355d78d0f7293cdf5730ca0363 100644 (file)
@@ -141,7 +141,7 @@ SKIP:
 SKIP:
 {
        skip "postgres was not built with LZ4 support", 5
-         if (!check_pg_config("#define HAVE_LIBLZ4 1"));
+         if (!check_pg_config("#define USE_LZ4 1"));
 
        # Generate more WAL including one completed, compressed segment.
        $primary->psql('postgres', 'SELECT pg_switch_wal();');
index a6d08c1270ad6bf94b0e8afa3ddb8875524df2d6..1e0ff760ebaee008152ec83a7cda8a4a5a10ad5d 100644 (file)
@@ -18,7 +18,7 @@
 #include <time.h>
 #include <unistd.h>
 
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
 #include <lz4frame.h>
 #endif
 #ifdef HAVE_LIBZ
@@ -70,7 +70,7 @@ typedef struct DirectoryMethodFile
 #ifdef HAVE_LIBZ
        gzFile          gzfp;
 #endif
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
        LZ4F_compressionContext_t ctx;
        size_t          lz4bufsize;
        void       *lz4buf;
@@ -114,7 +114,7 @@ dir_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
 #ifdef HAVE_LIBZ
        gzFile          gzfp = NULL;
 #endif
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
        LZ4F_compressionContext_t ctx = NULL;
        size_t          lz4bufsize = 0;
        void       *lz4buf = NULL;
@@ -160,7 +160,7 @@ dir_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
                }
        }
 #endif
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
        if (dir_data->compression_method == COMPRESSION_LZ4)
        {
                size_t          ctx_out;
@@ -245,7 +245,7 @@ dir_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
                                gzclose(gzfp);
                        else
 #endif
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
                        if (dir_data->compression_method == COMPRESSION_LZ4)
                        {
                                (void) LZ4F_compressEnd(ctx, lz4buf, lz4bufsize, NULL);
@@ -265,7 +265,7 @@ dir_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_
        if (dir_data->compression_method == COMPRESSION_GZIP)
                f->gzfp = gzfp;
 #endif
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
        if (dir_data->compression_method == COMPRESSION_LZ4)
        {
                f->ctx = ctx;
@@ -306,7 +306,7 @@ dir_write(Walfile f, const void *buf, size_t count)
        }
        else
 #endif
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
        if (dir_data->compression_method == COMPRESSION_LZ4)
        {
                size_t          chunk;
@@ -394,7 +394,7 @@ dir_close(Walfile f, WalCloseMethod method)
        }
        else
 #endif
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
        if (dir_data->compression_method == COMPRESSION_LZ4)
        {
                size_t          compressed;
@@ -487,7 +487,7 @@ dir_close(Walfile f, WalCloseMethod method)
        if (r != 0)
                dir_data->lasterrno = errno;
 
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
        pg_free(df->lz4buf);
        /* supports free on NULL */
        LZ4F_freeCompressionContext(df->ctx);
@@ -523,7 +523,7 @@ dir_sync(Walfile f)
                }
        }
 #endif
-#ifdef HAVE_LIBLZ4
+#ifdef USE_LZ4
        if (dir_data->compression_method == COMPRESSION_LZ4)
        {
                DirectoryMethodFile *df = (DirectoryMethodFile *) f;
index 3e55ff26f82f9f2725f34b6aa4ecb9219cd8d46e..fd1052e5db857b2700280e7221930801e3a6eb01 100644 (file)
@@ -3743,7 +3743,7 @@ if ($collation_check_stderr !~ /ERROR: /)
 }
 
 # Determine whether build supports LZ4.
-my $supports_lz4 = check_pg_config("#define HAVE_LIBLZ4 1");
+my $supports_lz4 = check_pg_config("#define USE_LZ4 1");
 
 # Create additional databases for mutations of schema public
 $node->psql('postgres', 'create database regress_pg_dump_test;');
index d52ca17430b670b9b05544fa9eaa54a6cdab165c..98d09ce40c2f120345349b838c96a178b538571e 100644 (file)
@@ -41,7 +41,7 @@ my @test_configuration = (
                'backup_archive' => 'base.tar.lz4',
                'decompress_program' => $ENV{'LZ4'},
                'decompress_flags' => [ '-d', '-m'],
-               'enabled' => check_pg_config("#define HAVE_LIBLZ4 1")
+               'enabled' => check_pg_config("#define USE_LZ4 1")
        },
        {
                'compression_method' => 'zstd',
@@ -49,7 +49,7 @@ my @test_configuration = (
                'backup_archive' => 'base.tar.zst',
                'decompress_program' => $ENV{'ZSTD'},
                'decompress_flags' => [ '-d' ],
-               'enabled' => check_pg_config("#define HAVE_LIBZSTD 1")
+               'enabled' => check_pg_config("#define USE_ZSTD 1")
        }
 );
 
index d30ba01742a90303bb0bc973df8cc614c8c3d2d3..9f9cc7540b623429d8f2e164492ea2b07a9ff2d7 100644 (file)
@@ -30,12 +30,12 @@ my @test_configuration = (
        {
                'compression_method' => 'lz4',
                'backup_flags' => ['--compress', 'server-lz4:5'],
-               'enabled' => check_pg_config("#define HAVE_LIBLZ4 1")
+               'enabled' => check_pg_config("#define USE_LZ4 1")
        },
        {
                'compression_method' => 'zstd',
                'backup_flags' => ['--compress', 'server-zstd:5'],
-               'enabled' => check_pg_config("#define HAVE_LIBZSTD 1")
+               'enabled' => check_pg_config("#define USE_ZSTD 1")
        }
 );
 
index 0b96b6cc43ced102634dbc772be7be705fa92f76..487e30e826dc049fd8fb62a71b0f228cc4084665 100644 (file)
@@ -41,7 +41,7 @@ my @test_configuration = (
                'decompress_program' => $ENV{'LZ4'},
                'decompress_flags' => [ '-d' ],
                'output_file' => 'base.tar',
-               'enabled' => check_pg_config("#define HAVE_LIBLZ4 1")
+               'enabled' => check_pg_config("#define USE_LZ4 1")
        },
        {
                'compression_method' => 'zstd',
@@ -49,7 +49,7 @@ my @test_configuration = (
                'backup_archive' => 'base.tar.zst',
                'decompress_program' => $ENV{'ZSTD'},
                'decompress_flags' => [ '-d' ],
-               'enabled' => check_pg_config("#define HAVE_LIBZSTD 1")
+               'enabled' => check_pg_config("#define USE_ZSTD 1")
        }
 );