Change HAVE_LIBLZ4 and HAVE_LIBZSTD tests to USE_LZ4 and USE_ZSTD.

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
This commit is contained in:
Robert Haas 2022-03-15 13:06:25 -04:00
parent 695f459f17
commit 75eae09087
11 changed files with 41 additions and 41 deletions

View File

@ -12,13 +12,13 @@
*/
#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.

View File

@ -12,13 +12,13 @@
*/
#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.

View 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

View File

@ -13,14 +13,14 @@
#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

View 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",

View 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();');

View 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;

View 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;');

View 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")
}
);

View 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")
}
);

View 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")
}
);