diff options
author | Kartik Soneji <kartiksoneji@rocketmail.com> | 2021-08-31 14:09:47 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-09-14 18:19:08 +0200 |
commit | 67a8fca9b7319eb111e330c1e8ed3d21b0f133e2 (patch) | |
tree | 7d640c8e5881ef425093d569e779971ce978e7d6 | |
parent | 07f5c551b02f62223ed93fc9f6b73ffd47521bbb (diff) | |
download | mariadb-git-preview-10.7-MDEV-12933-provider-plugins_triggerBB.tar.gz |
MDEV-12933 sort out the compression library chaospreview-10.7-MDEV-12933-provider-plugins_triggerBB
bzip2/lz4/lzma/lzo/snappy compression is now provided via *services*
they're almost like normal services, but in include/providers/
and they're supposed to provide exactly the same interface
as original compression libraries (but not everything,
only enough of if for the code to compile).
the services are implemented via dummy functions that return
corresponding error values (LZMA_PROG_ERROR, LZO_E_INTERNAL_ERROR, etc).
the actual compression libraries are linked into corresponding
provider plugins. Providers are daemon plugins that when loaded
replace service pointers to point to actual compression functions.
That is, run-time dependency on compression libraries is now on plugins,
and the server doesn't need any compression libraries to run, but
will automatically support the compression when a plugin is loaded.
InnoDB and Mroonga use compression plugins now. RocksDB doesn't,
because it comes with standalone utility binaries that cannot
load plugins.
94 files changed, 1957 insertions, 452 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 00007f92f57..b0491150e40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -370,7 +370,8 @@ ADD_DEFINITIONS(-DHAVE_CONFIG_H) IF(_FILE_OFFSET_BITS) ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS}) ENDIF() -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include + ${CMAKE_SOURCE_DIR}/include/providers) # Add bundled or system zlib. MYSQL_CHECK_ZLIB_WITH_COMPRESS() diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index 0060477197a..b9728ca1ab9 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -108,14 +108,10 @@ ELSEIF(RPM) # not yet, SLES 12.3 doesn't provide pcre2 #SET(WITH_PCRE system CACHE STRING "") IF(RPM MATCHES "fedora|centos|rhel") - SET(WITH_INNODB_BZIP2 OFF CACHE STRING "") - SET(WITH_INNODB_LZO OFF CACHE STRING "") SET(WITH_ROCKSDB_BZip2 OFF CACHE STRING "") ENDIF() IF(RPM MATCHES "opensuse|sles|centos|rhel") - SET(WITH_INNODB_LZ4 OFF CACHE STRING "") SET(WITH_ROCKSDB_LZ4 OFF CACHE STRING "") - SET(GRN_WITH_LZ4 no CACHE STRING "") ENDIF() ELSEIF(DEB) SET(WITH_SSL system CACHE STRING "") @@ -125,9 +121,6 @@ ELSEIF(DEB) SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "") SET(WITH_EMBEDDED_SERVER ON CACHE BOOL "") SET(WITH_PCRE system CACHE STRING "") - SET(WITH_INNODB_BZIP2 OFF CACHE STRING "") - SET(WITH_INNODB_LZMA OFF CACHE STRING "") - SET(WITH_INNODB_LZO OFF CACHE STRING "") SET(WITH_ROCKSDB_BZip2 OFF CACHE STRING "") ELSE() SET(WITH_SSL bundled CACHE STRING "") @@ -137,12 +130,8 @@ ELSE() SET(PLUGIN_AUTH_SOCKET STATIC CACHE STRING "") SET(WITH_STRIPPED_CLIENT ON CACHE BOOL "Strip all client binaries") SET(WITH_PCRE bundled CACHE STRING "") - SET(WITH_INNODB_BZIP2 OFF CACHE STRING "") - SET(WITH_INNODB_LZ4 OFF CACHE STRING "") - SET(WITH_INNODB_LZO OFF CACHE STRING "") SET(WITH_ROCKSDB_BZip2 OFF CACHE STRING "") SET(WITH_ROCKSDB_LZ4 OFF CACHE STRING "") - SET(GRN_WITH_LZ4 no CACHE STRING "") ENDIF() IF(NOT COMPILATION_COMMENT) diff --git a/debian/control b/debian/control index 9cf0a8fae0e..8473607f52d 100644 --- a/debian/control +++ b/debian/control @@ -18,6 +18,7 @@ Build-Depends: bison, libboost-regex-dev [amd64], libboost-system-dev [amd64], libboost-thread-dev [amd64], + libbz2-dev, libcrack2-dev (>= 2.9.0), libcurl4-openssl-dev | libcurl4-dev, libedit-dev, @@ -26,6 +27,8 @@ Build-Depends: bison, libjudy-dev, libkrb5-dev, liblz4-dev, + liblzma-dev, + liblzo2-dev, libncurses5-dev (>= 5.0-6~), libncurses5-dev:native (>= 5.0-6~), libnuma-dev [linux-any], @@ -934,6 +937,41 @@ Description: CrackLib Password Validation Plugin for MariaDB . Install and configure this to enforce stronger passwords for MariaDB users. +Package: mariadb-plugin-provider-bzip2 +Architecture: any +Depends: mariadb-server-10.7, + ${misc:Depends}, + ${shlibs:Depends} +Description: BZip2 compression support in the server and storage engines + +Package: mariadb-plugin-provider-lz4 +Architecture: any +Depends: mariadb-server-10.7, + ${misc:Depends}, + ${shlibs:Depends} +Description: LZ4 compression support in the server and storage engines + +Package: mariadb-plugin-provider-lzma +Architecture: any +Depends: mariadb-server-10.7, + ${misc:Depends}, + ${shlibs:Depends} +Description: LZMA compression support in the server and storage engines + +Package: mariadb-plugin-provider-lzo +Architecture: any +Depends: mariadb-server-10.7, + ${misc:Depends}, + ${shlibs:Depends} +Description: LZO compression support in the server and storage engines + +Package: mariadb-plugin-provider-snappy +Architecture: any +Depends: mariadb-server-10.7, + ${misc:Depends}, + ${shlibs:Depends} +Description: Snappy compression support in the server and storage engines + Package: mariadb-test Architecture: any Depends: mariadb-client-10.7 (= ${binary:Version}), diff --git a/debian/mariadb-plugin-provider-bzip2.install b/debian/mariadb-plugin-provider-bzip2.install new file mode 100644 index 00000000000..75a73c384a7 --- /dev/null +++ b/debian/mariadb-plugin-provider-bzip2.install @@ -0,0 +1,2 @@ +etc/mysql/mariadb.conf.d/provider_bzip2.cnf +usr/lib/mysql/plugin/provider_bzip2.so diff --git a/debian/mariadb-plugin-provider-lz4.install b/debian/mariadb-plugin-provider-lz4.install new file mode 100644 index 00000000000..a3ba1d77bb3 --- /dev/null +++ b/debian/mariadb-plugin-provider-lz4.install @@ -0,0 +1,2 @@ +etc/mysql/mariadb.conf.d/provider_lz4.cnf +usr/lib/mysql/plugin/provider_lz4.so diff --git a/debian/mariadb-plugin-provider-lzma.install b/debian/mariadb-plugin-provider-lzma.install new file mode 100644 index 00000000000..4a4138b45c6 --- /dev/null +++ b/debian/mariadb-plugin-provider-lzma.install @@ -0,0 +1,2 @@ +etc/mysql/mariadb.conf.d/provider_lzma.cnf +usr/lib/mysql/plugin/provider_lzma.so diff --git a/debian/mariadb-plugin-provider-lzo.install b/debian/mariadb-plugin-provider-lzo.install new file mode 100644 index 00000000000..2bf4c091ddc --- /dev/null +++ b/debian/mariadb-plugin-provider-lzo.install @@ -0,0 +1,2 @@ +etc/mysql/mariadb.conf.d/provider_lzo.cnf +usr/lib/mysql/plugin/provider_lzo.so diff --git a/debian/mariadb-plugin-provider-snappy.install b/debian/mariadb-plugin-provider-snappy.install new file mode 100644 index 00000000000..26c929c89ba --- /dev/null +++ b/debian/mariadb-plugin-provider-snappy.install @@ -0,0 +1,2 @@ +etc/mysql/mariadb.conf.d/provider_snappy.cnf +usr/lib/mysql/plugin/provider_snappy.so diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 61df34e28d1..3b46d1fd7c4 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3309,7 +3309,8 @@ static void xb_load_single_table_tablespace(const char *dirname, 0, false, false); node->deferred= defer; mysql_mutex_lock(&fil_system.mutex); - space->read_page0(); + if (!space->read_page0()) + err= DB_CANNOT_OPEN_FILE; mysql_mutex_unlock(&fil_system.mutex); if (srv_operation == SRV_OPERATION_RESTORE_DELTA diff --git a/include/providers/bzlib.h b/include/providers/bzlib.h new file mode 100644 index 00000000000..70b180c6cbe --- /dev/null +++ b/include/providers/bzlib.h @@ -0,0 +1,122 @@ +/** + @file bzlib.h + This service provides dynamic access to BZip2. +*/ + +#ifndef BZIP2_INCLUDED +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MYSQL_ABI_CHECK +#include <stdbool.h> +#endif + +#ifndef BZ_RUN +#define BZ_RUN 0 +#define BZ_FINISH 2 + +#define BZ_OK 0 +#define BZ_RUN_OK 1 +#define BZ_FINISH_OK 3 +#define BZ_STREAM_END 4 + +typedef struct +{ + char *next_in; + unsigned int avail_in; + unsigned int total_in_lo32; + unsigned int total_in_hi32; + + char *next_out; + unsigned int avail_out; + unsigned int total_out_lo32; + unsigned int total_out_hi32; + + void *state; + + void *(*bzalloc)(void *, int, int); + void (*bzfree)(void *, void *); + void *opaque; +} bz_stream; + +#define BZ2_bzBuffToBuffCompress(...) provider_service_bzip2->BZ2_bzBuffToBuffCompress_ptr (__VA_ARGS__) +#define BZ2_bzBuffToBuffDecompress(...) provider_service_bzip2->BZ2_bzBuffToBuffDecompress_ptr (__VA_ARGS__) +#define BZ2_bzCompress(...) provider_service_bzip2->BZ2_bzCompress_ptr (__VA_ARGS__) +#define BZ2_bzCompressEnd(...) provider_service_bzip2->BZ2_bzCompressEnd_ptr (__VA_ARGS__) +#define BZ2_bzCompressInit(...) provider_service_bzip2->BZ2_bzCompressInit_ptr (__VA_ARGS__) +#define BZ2_bzDecompress(...) provider_service_bzip2->BZ2_bzDecompress_ptr (__VA_ARGS__) +#define BZ2_bzDecompressEnd(...) provider_service_bzip2->BZ2_bzDecompressEnd_ptr (__VA_ARGS__) +#define BZ2_bzDecompressInit(...) provider_service_bzip2->BZ2_bzDecompressInit_ptr (__VA_ARGS__) +#endif + +#define DEFINE_BZ2_bzBuffToBuffCompress(NAME) NAME( \ + char *dest, \ + unsigned int *destLen, \ + char *source, \ + unsigned int sourceLen, \ + int blockSize100k, \ + int verbosity, \ + int workFactor \ +) + +#define DEFINE_BZ2_bzBuffToBuffDecompress(NAME) NAME( \ + char *dest, \ + unsigned int *destLen, \ + char *source, \ + unsigned int sourceLen, \ + int small, \ + int verbosity \ +) + +#define DEFINE_BZ2_bzCompress(NAME) NAME( \ + bz_stream *strm, \ + int action \ +) + +#define DEFINE_BZ2_bzCompressEnd(NAME) NAME( \ + bz_stream *strm \ +) + +#define DEFINE_BZ2_bzCompressInit(NAME) NAME( \ + bz_stream *strm, \ + int blockSize100k, \ + int verbosity, \ + int workFactor \ +) + +#define DEFINE_BZ2_bzDecompress(NAME) NAME( \ + bz_stream *strm \ +) + +#define DEFINE_BZ2_bzDecompressEnd(NAME) NAME( \ + bz_stream *strm \ +) + +#define DEFINE_BZ2_bzDecompressInit(NAME) NAME( \ + bz_stream *strm, \ + int verbosity, \ + int small \ +) + +struct provider_service_bzip2_st{ + int DEFINE_BZ2_bzBuffToBuffCompress((*BZ2_bzBuffToBuffCompress_ptr)); + int DEFINE_BZ2_bzBuffToBuffDecompress((*BZ2_bzBuffToBuffDecompress_ptr)); + int DEFINE_BZ2_bzCompress((*BZ2_bzCompress_ptr)); + int DEFINE_BZ2_bzCompressEnd((*BZ2_bzCompressEnd_ptr)); + int DEFINE_BZ2_bzCompressInit((*BZ2_bzCompressInit_ptr)); + int DEFINE_BZ2_bzDecompress((*BZ2_bzDecompress_ptr)); + int DEFINE_BZ2_bzDecompressEnd((*BZ2_bzDecompressEnd_ptr)); + int DEFINE_BZ2_bzDecompressInit((*BZ2_bzDecompressInit_ptr)); + + bool is_loaded; +}; + +extern struct provider_service_bzip2_st *provider_service_bzip2; + +#ifdef __cplusplus +} +#endif + +#define BZIP2_INCLUDED +#endif diff --git a/include/providers/lz4.h b/include/providers/lz4.h new file mode 100644 index 00000000000..ad0a9d1cf06 --- /dev/null +++ b/include/providers/lz4.h @@ -0,0 +1,59 @@ +/** + @file lz4.h + This service provides dynamic access to LZ4. +*/ + +#ifndef LZ4_INCLUDED +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MYSQL_ABI_CHECK +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> +#endif + +#ifndef LZ4_VERSION_NUMBER +#define LZ4_MAX_INPUT_SIZE 0x7E000000 + +#define LZ4_compressBound(...) provider_service_lz4->LZ4_compressBound_ptr (__VA_ARGS__) +#define LZ4_compress_default(...) provider_service_lz4->LZ4_compress_default_ptr (__VA_ARGS__) +#define LZ4_decompress_safe(...) provider_service_lz4->LZ4_decompress_safe_ptr (__VA_ARGS__) +#endif + +#define DEFINE_LZ4_compressBound(NAME) NAME( \ + int inputSize \ +) + +#define DEFINE_LZ4_compress_default(NAME) NAME( \ + const char *src, \ + char *dst, \ + int srcSize, \ + int dstCapacity \ +) + +#define DEFINE_LZ4_decompress_safe(NAME) NAME( \ + const char *src, \ + char *dst, \ + int compressedSize, \ + int dstCapacity \ +) + +struct provider_service_lz4_st +{ + int DEFINE_LZ4_compressBound((*LZ4_compressBound_ptr)); + int DEFINE_LZ4_compress_default((*LZ4_compress_default_ptr)); + int DEFINE_LZ4_decompress_safe((*LZ4_decompress_safe_ptr)); + + bool is_loaded; +}; + +extern struct provider_service_lz4_st *provider_service_lz4; + +#ifdef __cplusplus +} +#endif + +#define LZ4_INCLUDED +#endif diff --git a/include/providers/lzma.h b/include/providers/lzma.h new file mode 100644 index 00000000000..7dadf63a938 --- /dev/null +++ b/include/providers/lzma.h @@ -0,0 +1,92 @@ +/** + @file lzma.h + This service provides dynamic access to LZMA. +*/ + +#ifndef LZMA_INCLUDED +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MYSQL_ABI_CHECK +#include <stdbool.h> +#include <stdint.h> +#include <stddef.h> +#endif + +#ifndef LZMA_VERSION +typedef enum +{ + LZMA_OK = 0, + LZMA_STREAM_END = 1, + LZMA_NO_CHECK = 2, + LZMA_UNSUPPORTED_CHECK = 3, + LZMA_GET_CHECK = 4, + LZMA_MEM_ERROR = 5, + LZMA_MEMLIMIT_ERROR = 6, + LZMA_FORMAT_ERROR = 7, + LZMA_OPTIONS_ERROR = 8, + LZMA_DATA_ERROR = 9, + LZMA_BUF_ERROR = 10, + LZMA_PROG_ERROR = 11, +} lzma_ret; + +typedef struct +{ + void *(*alloc)(void *opaque, size_t nmemb, size_t size); + void (*free)(void *opaque, void *ptr); + void *opaque; +} lzma_allocator; + +typedef enum +{ + LZMA_CHECK_NONE = 0, + LZMA_CHECK_CRC32 = 1, + LZMA_CHECK_CRC64 = 4, + LZMA_CHECK_SHA256 = 10 +} lzma_check; + +#define lzma_stream_buffer_decode(...) provider_service_lzma->lzma_stream_buffer_decode_ptr (__VA_ARGS__) +#define lzma_easy_buffer_encode(...) provider_service_lzma->lzma_easy_buffer_encode_ptr (__VA_ARGS__) +#endif + +#define DEFINE_lzma_stream_buffer_decode(NAME) NAME( \ + uint64_t *memlimit, \ + uint32_t flags, \ + const lzma_allocator *allocator, \ + const uint8_t *in, \ + size_t *in_pos, \ + size_t in_size, \ + uint8_t *out, \ + size_t *out_pos, \ + size_t out_size \ +) + +#define DEFINE_lzma_easy_buffer_encode(NAME) NAME( \ + uint32_t preset, \ + lzma_check check, \ + const lzma_allocator *allocator, \ + const uint8_t *in, \ + size_t in_size, \ + uint8_t *out, \ + size_t *out_pos, \ + size_t out_size \ +) + +struct provider_service_lzma_st +{ + lzma_ret DEFINE_lzma_stream_buffer_decode((*lzma_stream_buffer_decode_ptr)); + lzma_ret DEFINE_lzma_easy_buffer_encode((*lzma_easy_buffer_encode_ptr)); + + bool is_loaded; +}; + +extern struct provider_service_lzma_st *provider_service_lzma; + + +#ifdef __cplusplus +} +#endif + +#define LZMA_INCLUDED +#endif diff --git a/include/providers/lzo/lzo1x.h b/include/providers/lzo/lzo1x.h new file mode 100644 index 00000000000..b1a9edd28d8 --- /dev/null +++ b/include/providers/lzo/lzo1x.h @@ -0,0 +1,58 @@ +/** + @file lzo/lzo1x.h + This service provides dynamic access to LZO. +*/ + +#ifndef LZO_INCLUDED +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MYSQL_ABI_CHECK +#include <stdbool.h> +#endif + +#ifndef LZO_E_OK +#define LZO_E_OK 0 +#define LZO_E_INTERNAL_ERROR (-99) + +#define LZO1X_1_15_MEM_COMPRESS ((unsigned int) (32768L * ((unsigned) sizeof(unsigned char *)))) + +typedef size_t lzo_uint; + +#define lzo1x_1_15_compress(...) provider_service_lzo->lzo1x_1_15_compress_ptr (__VA_ARGS__) +#define lzo1x_decompress_safe(...) provider_service_lzo->lzo1x_decompress_safe_ptr (__VA_ARGS__) +#endif + +#define DEFINE_lzo1x_1_15_compress(NAME) NAME( \ + const unsigned char *src, \ + lzo_uint src_len, \ + unsigned char *dst, \ + lzo_uint *dst_len, \ + void *wrkmem \ +) + +#define DEFINE_lzo1x_decompress_safe(NAME) NAME( \ + const unsigned char *src, \ + lzo_uint src_len, \ + unsigned char *dst, \ + lzo_uint *dst_len, \ + void *wrkmem \ +) + +struct provider_service_lzo_st +{ + int DEFINE_lzo1x_1_15_compress((*lzo1x_1_15_compress_ptr)); + int DEFINE_lzo1x_decompress_safe((*lzo1x_decompress_safe_ptr)); + + bool is_loaded; +}; + +extern struct provider_service_lzo_st *provider_service_lzo; + +#ifdef __cplusplus +} +#endif + +#define LZO_INCLUDED +#endif diff --git a/include/providers/snappy-c.h b/include/providers/snappy-c.h new file mode 100644 index 00000000000..579ad2a5b4a --- /dev/null +++ b/include/providers/snappy-c.h @@ -0,0 +1,71 @@ +/** + @file snappy-c.h + This service provides dynamic access to Snappy as a C header. +*/ + +#ifndef SNAPPY_C_INCLUDED +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MYSQL_ABI_CHECK +#include <stddef.h> +#include <stdbool.h> +#endif + +#ifndef SNAPPY_C +typedef enum +{ + SNAPPY_OK = 0, + SNAPPY_INVALID_INPUT = 1, + SNAPPY_BUFFER_TOO_SMALL = 2 +} snappy_status; + +#define snappy_max_compressed_length(...) provider_service_snappy->snappy_max_compressed_length_ptr (__VA_ARGS__) +#define snappy_compress(...) provider_service_snappy->snappy_compress_ptr (__VA_ARGS__) +#define snappy_uncompressed_length(...) provider_service_snappy->snappy_uncompressed_length_ptr (__VA_ARGS__) +#define snappy_uncompress(...) provider_service_snappy->snappy_uncompress_ptr (__VA_ARGS__) +#endif + +#define DEFINE_snappy_max_compressed_length(NAME) NAME( \ + size_t source_length \ +) + +#define DEFINE_snappy_compress(NAME) NAME( \ + const char *input, \ + size_t input_length, \ + char *compressed, \ + size_t *compressed_length \ +) + +#define DEFINE_snappy_uncompressed_length(NAME) NAME( \ + const char *compressed, \ + size_t compressed_length, \ + size_t *result \ +) + +#define DEFINE_snappy_uncompress(NAME) NAME( \ + const char *compressed, \ + size_t compressed_length, \ + char *uncompressed, \ + size_t *uncompressed_length \ +) + +struct provider_service_snappy_st +{ + size_t DEFINE_snappy_max_compressed_length((*snappy_max_compressed_length_ptr)); + snappy_status DEFINE_snappy_compress((*snappy_compress_ptr)); + snappy_status DEFINE_snappy_uncompressed_length((*snappy_uncompressed_length_ptr)); + snappy_status DEFINE_snappy_uncompress((*snappy_uncompress_ptr)); + + bool is_loaded; +}; + +extern struct provider_service_snappy_st *provider_service_snappy; + +#ifdef __cplusplus +} +#endif + +#define SNAPPY_C_INCLUDED +#endif diff --git a/include/service_versions.h b/include/service_versions.h index 34e4952c94c..64c5bdcf389 100644 --- a/include/service_versions.h +++ b/include/service_versions.h @@ -44,3 +44,8 @@ #define VERSION_wsrep 0x0500 #define VERSION_json 0x0100 #define VERSION_thd_mdl 0x0100 +#define VERSION_provider_bzip2 0x0100 +#define VERSION_provider_lz4 0x0100 +#define VERSION_provider_lzma 0x0100 +#define VERSION_provider_lzo 0x0100 +#define VERSION_provider_snappy 0x0100 diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt index 274c8ce6dac..c854680679c 100644 --- a/libservices/CMakeLists.txt +++ b/libservices/CMakeLists.txt @@ -38,7 +38,12 @@ SET(MYSQLSERVICES_SOURCES thd_wait_service.c wsrep_service.c json_service.c - ) + provider_service_bzip2.c + provider_service_lz4.c + provider_service_lzma.c + provider_service_lzo.c + provider_service_snappy.c +) ADD_CONVENIENCE_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES}) INSTALL(TARGETS mysqlservices DESTINATION ${INSTALL_LIBDIR} COMPONENT Development) diff --git a/libservices/provider_service_bzip2.c b/libservices/provider_service_bzip2.c new file mode 100644 index 00000000000..f18ce55dd4e --- /dev/null +++ b/libservices/provider_service_bzip2.c @@ -0,0 +1,17 @@ +/* Copyright (C) 2021 MariaDB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include <service_versions.h> +SERVICE_VERSION provider_service_bzip2 = (void*) VERSION_provider_bzip2; diff --git a/libservices/provider_service_lz4.c b/libservices/provider_service_lz4.c new file mode 100644 index 00000000000..2653f86e26c --- /dev/null +++ b/libservices/provider_service_lz4.c @@ -0,0 +1,14 @@ +/* Copyright (C) 2021 MariaDB + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include <service_versions.h> +SERVICE_VERSION provider_service_lz4 = (void*) VERSION_provider_lz4; diff --git a/libservices/provider_service_lzma.c b/libservices/provider_service_lzma.c new file mode 100644 index 00000000000..79fc982140d --- /dev/null +++ b/libservices/provider_service_lzma.c @@ -0,0 +1,17 @@ +/* Copyright (C) 2021 MariaDB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include <service_versions.h> +SERVICE_VERSION provider_service_lzma = (void*) VERSION_provider_lzma; diff --git a/libservices/provider_service_lzo.c b/libservices/provider_service_lzo.c new file mode 100644 index 00000000000..8b72ac017ea --- /dev/null +++ b/libservices/provider_service_lzo.c @@ -0,0 +1,14 @@ +/* Copyright (C) 2021 MariaDB + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include <service_versions.h> +SERVICE_VERSION provider_service_lzo = (void*) VERSION_provider_lzo; diff --git a/libservices/provider_service_snappy.c b/libservices/provider_service_snappy.c new file mode 100644 index 00000000000..ac0415bad61 --- /dev/null +++ b/libservices/provider_service_snappy.c @@ -0,0 +1,17 @@ +/* Copyright (C) 2021 MariaDB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include <service_versions.h> +SERVICE_VERSION provider_service_snappy= (void*) VERSION_provider_snappy; diff --git a/mysql-test/suite/innodb/r/compression_providers_loaded,lz4.rdiff b/mysql-test/suite/innodb/r/compression_providers_loaded,lz4.rdiff new file mode 100644 index 00000000000..b729890c354 --- /dev/null +++ b/mysql-test/suite/innodb/r/compression_providers_loaded,lz4.rdiff @@ -0,0 +1,19 @@ +--- suite/innodb/r/compression_providers_loaded.result ++++ suite/innodb/r/compression_providers_loaded.reject +@@ -1,10 +1,10 @@ + # +-# Testing unloaded compression provider: bzip2 ++# Testing unloaded compression provider: lz4 + # +-# Innodb_have_bzip2 reflects that the provider is loaded +-SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_bzip2"; ++# Innodb_have_lz4 reflects that the provider is loaded ++SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_lz4"; + Variable_name Value +-Innodb_have_bzip2 ON +-# Innodb_compression_algorithm can be set to bzip2 +-SET GLOBAL Innodb_compression_algorithm = bzip2; ++Innodb_have_lz4 ON ++# Innodb_compression_algorithm can be set to lz4 ++SET GLOBAL Innodb_compression_algorithm = lz4; + SET GLOBAL Innodb_compression_algorithm = zlib; diff --git a/mysql-test/suite/innodb/r/compression_providers_loaded,lzma.rdiff b/mysql-test/suite/innodb/r/compression_providers_loaded,lzma.rdiff new file mode 100644 index 00000000000..caba4283977 --- /dev/null +++ b/mysql-test/suite/innodb/r/compression_providers_loaded,lzma.rdiff @@ -0,0 +1,19 @@ +--- suite/innodb/r/compression_providers_loaded.result ++++ suite/innodb/r/compression_providers_loaded.reject +@@ -1,10 +1,10 @@ + # +-# Testing unloaded compression provider: bzip2 ++# Testing unloaded compression provider: lzma + # +-# Innodb_have_bzip2 reflects that the provider is loaded +-SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_bzip2"; ++# Innodb_have_lzma reflects that the provider is loaded ++SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_lzma"; + Variable_name Value +-Innodb_have_bzip2 ON +-# Innodb_compression_algorithm can be set to bzip2 +-SET GLOBAL Innodb_compression_algorithm = bzip2; ++Innodb_have_lzma ON ++# Innodb_compression_algorithm can be set to lzma ++SET GLOBAL Innodb_compression_algorithm = lzma; + SET GLOBAL Innodb_compression_algorithm = zlib; diff --git a/mysql-test/suite/innodb/r/compression_providers_loaded,lzo.rdiff b/mysql-test/suite/innodb/r/compression_providers_loaded,lzo.rdiff new file mode 100644 index 00000000000..8a1a5403fc2 --- /dev/null +++ b/mysql-test/suite/innodb/r/compression_providers_loaded,lzo.rdiff @@ -0,0 +1,19 @@ +--- suite/innodb/r/compression_providers_loaded.result ++++ suite/innodb/r/compression_providers_loaded.reject +@@ -1,10 +1,10 @@ + # +-# Testing unloaded compression provider: bzip2 ++# Testing unloaded compression provider: lzo + # +-# Innodb_have_bzip2 reflects that the provider is loaded +-SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_bzip2"; ++# Innodb_have_lzo reflects that the provider is loaded ++SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_lzo"; + Variable_name Value +-Innodb_have_bzip2 ON +-# Innodb_compression_algorithm can be set to bzip2 +-SET GLOBAL Innodb_compression_algorithm = bzip2; ++Innodb_have_lzo ON ++# Innodb_compression_algorithm can be set to lzo ++SET GLOBAL Innodb_compression_algorithm = lzo; + SET GLOBAL Innodb_compression_algorithm = zlib; diff --git a/mysql-test/suite/innodb/r/compression_providers_loaded,snappy.rdiff b/mysql-test/suite/innodb/r/compression_providers_loaded,snappy.rdiff new file mode 100644 index 00000000000..4a1261d45d2 --- /dev/null +++ b/mysql-test/suite/innodb/r/compression_providers_loaded,snappy.rdiff @@ -0,0 +1,19 @@ +--- suite/innodb/r/compression_providers_loaded.result ++++ suite/innodb/r/compression_providers_loaded.reject +@@ -1,10 +1,10 @@ + # +-# Testing unloaded compression provider: bzip2 ++# Testing unloaded compression provider: snappy + # +-# Innodb_have_bzip2 reflects that the provider is loaded +-SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_bzip2"; ++# Innodb_have_snappy reflects that the provider is loaded ++SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_snappy"; + Variable_name Value +-Innodb_have_bzip2 ON +-# Innodb_compression_algorithm can be set to bzip2 +-SET GLOBAL Innodb_compression_algorithm = bzip2; ++Innodb_have_snappy ON ++# Innodb_compression_algorithm can be set to snappy ++SET GLOBAL Innodb_compression_algorithm = snappy; + SET GLOBAL Innodb_compression_algorithm = zlib; diff --git a/mysql-test/suite/innodb/r/compression_providers_loaded.result b/mysql-test/suite/innodb/r/compression_providers_loaded.result new file mode 100644 index 00000000000..2d1700c2ae2 --- /dev/null +++ b/mysql-test/suite/innodb/r/compression_providers_loaded.result @@ -0,0 +1,10 @@ +# +# Testing unloaded compression provider: bzip2 +# +# Innodb_have_bzip2 reflects that the provider is loaded +SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_bzip2"; +Variable_name Value +Innodb_have_bzip2 ON +# Innodb_compression_algorithm can be set to bzip2 +SET GLOBAL Innodb_compression_algorithm = bzip2; +SET GLOBAL Innodb_compression_algorithm = zlib; diff --git a/mysql-test/suite/innodb/r/compression_providers_unloaded,lz4.rdiff b/mysql-test/suite/innodb/r/compression_providers_unloaded,lz4.rdiff new file mode 100644 index 00000000000..e849fb5c474 --- /dev/null +++ b/mysql-test/suite/innodb/r/compression_providers_unloaded,lz4.rdiff @@ -0,0 +1,26 @@ +--- suite/innodb/r/compression_providers_unloaded.result ++++ suite/innodb/r/compression_providers_unloaded.reject +@@ -1,14 +1,14 @@ + # +-# Testing unloaded compression provider: bzip2 ++# Testing unloaded compression provider: lz4 + # +-# Innodb_have_bzip2 reflects that the provider is not loaded +-SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_bzip2"; ++# Innodb_have_lz4 reflects that the provider is not loaded ++SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_lz4"; + Variable_name Value +-Innodb_have_bzip2 OFF +-# Innodb_compression_algorithm cannot be set to bzip2 +-SET GLOBAL Innodb_compression_algorithm = bzip2; +-ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value of 'bzip2' ++Innodb_have_lz4 OFF ++# Innodb_compression_algorithm cannot be set to lz4 ++SET GLOBAL Innodb_compression_algorithm = lz4; ++ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value of 'lz4' + show warnings; + Level Code Message +-Warning 138 InnoDB: compression algorithm bzip2 (5) is not available. Please, load the corresponding provider plugin. +-Error 1231 Variable 'innodb_compression_algorithm' can't be set to the value of 'bzip2' ++Warning 138 InnoDB: compression algorithm lz4 (2) is not available. Please, load the corresponding provider plugin. ++Error 1231 Variable 'innodb_compression_algorithm' can't be set to the value of 'lz4' diff --git a/mysql-test/suite/innodb/r/compression_providers_unloaded,lzma.rdiff b/mysql-test/suite/innodb/r/compression_providers_unloaded,lzma.rdiff new file mode 100644 index 00000000000..466fb37c3fb --- /dev/null +++ b/mysql-test/suite/innodb/r/compression_providers_unloaded,lzma.rdiff @@ -0,0 +1,26 @@ +--- suite/innodb/r/compression_providers_unloaded.result ++++ suite/innodb/r/compression_providers_unloaded.reject +@@ -1,14 +1,14 @@ + # +-# Testing unloaded compression provider: bzip2 ++# Testing unloaded compression provider: lzma + # +-# Innodb_have_bzip2 reflects that the provider is not loaded +-SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_bzip2"; ++# Innodb_have_lzma reflects that the provider is not loaded ++SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_lzma"; + Variable_name Value +-Innodb_have_bzip2 OFF +-# Innodb_compression_algorithm cannot be set to bzip2 +-SET GLOBAL Innodb_compression_algorithm = bzip2; +-ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value of 'bzip2' ++Innodb_have_lzma OFF ++# Innodb_compression_algorithm cannot be set to lzma ++SET GLOBAL Innodb_compression_algorithm = lzma; ++ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value of 'lzma' + show warnings; + Level Code Message +-Warning 138 InnoDB: compression algorithm bzip2 (5) is not available. Please, load the corresponding provider plugin. +-Error 1231 Variable 'innodb_compression_algorithm' can't be set to the value of 'bzip2' ++Warning 138 InnoDB: compression algorithm lzma (4) is not available. Please, load the corresponding provider plugin. ++Error 1231 Variable 'innodb_compression_algorithm' can't be set to the value of 'lzma' diff --git a/mysql-test/suite/innodb/r/compression_providers_unloaded,lzo.rdiff b/mysql-test/suite/innodb/r/compression_providers_unloaded,lzo.rdiff new file mode 100644 index 00000000000..dec0becf71e --- /dev/null +++ b/mysql-test/suite/innodb/r/compression_providers_unloaded,lzo.rdiff @@ -0,0 +1,26 @@ +--- suite/innodb/r/compression_providers_unloaded.result ++++ suite/innodb/r/compression_providers_unloaded.reject +@@ -1,14 +1,14 @@ + # +-# Testing unloaded compression provider: bzip2 ++# Testing unloaded compression provider: lzo + # +-# Innodb_have_bzip2 reflects that the provider is not loaded +-SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_bzip2"; ++# Innodb_have_lzo reflects that the provider is not loaded ++SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_lzo"; + Variable_name Value +-Innodb_have_bzip2 OFF +-# Innodb_compression_algorithm cannot be set to bzip2 +-SET GLOBAL Innodb_compression_algorithm = bzip2; +-ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value of 'bzip2' ++Innodb_have_lzo OFF ++# Innodb_compression_algorithm cannot be set to lzo ++SET GLOBAL Innodb_compression_algorithm = lzo; ++ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value of 'lzo' + show warnings; + Level Code Message +-Warning 138 InnoDB: compression algorithm bzip2 (5) is not available. Please, load the corresponding provider plugin. +-Error 1231 Variable 'innodb_compression_algorithm' can't be set to the value of 'bzip2' ++Warning 138 InnoDB: compression algorithm lzo (3) is not available. Please, load the corresponding provider plugin. ++Error 1231 Variable 'innodb_compression_algorithm' can't be set to the value of 'lzo' diff --git a/mysql-test/suite/innodb/r/compression_providers_unloaded,snappy.rdiff b/mysql-test/suite/innodb/r/compression_providers_unloaded,snappy.rdiff new file mode 100644 index 00000000000..273ff4e2131 --- /dev/null +++ b/mysql-test/suite/innodb/r/compression_providers_unloaded,snappy.rdiff @@ -0,0 +1,26 @@ +--- suite/innodb/r/compression_providers_unloaded.result ++++ suite/innodb/r/compression_providers_unloaded.reject +@@ -1,14 +1,14 @@ + # +-# Testing unloaded compression provider: bzip2 ++# Testing unloaded compression provider: snappy + # +-# Innodb_have_bzip2 reflects that the provider is not loaded +-SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_bzip2"; ++# Innodb_have_snappy reflects that the provider is not loaded ++SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_snappy"; + Variable_name Value +-Innodb_have_bzip2 OFF +-# Innodb_compression_algorithm cannot be set to bzip2 +-SET GLOBAL Innodb_compression_algorithm = bzip2; +-ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value of 'bzip2' ++Innodb_have_snappy OFF ++# Innodb_compression_algorithm cannot be set to snappy ++SET GLOBAL Innodb_compression_algorithm = snappy; ++ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value of 'snappy' + show warnings; + Level Code Message +-Warning 138 InnoDB: compression algorithm bzip2 (5) is not available. Please, load the corresponding provider plugin. +-Error 1231 Variable 'innodb_compression_algorithm' can't be set to the value of 'bzip2' ++Warning 138 InnoDB: compression algorithm snappy (6) is not available. Please, load the corresponding provider plugin. ++Error 1231 Variable 'innodb_compression_algorithm' can't be set to the value of 'snappy' diff --git a/mysql-test/suite/innodb/r/compression_providers_unloaded.result b/mysql-test/suite/innodb/r/compression_providers_unloaded.result new file mode 100644 index 00000000000..d4ac9cdb41c --- /dev/null +++ b/mysql-test/suite/innodb/r/compression_providers_unloaded.result @@ -0,0 +1,14 @@ +# +# Testing unloaded compression provider: bzip2 +# +# Innodb_have_bzip2 reflects that the provider is not loaded +SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_bzip2"; +Variable_name Value +Innodb_have_bzip2 OFF +# Innodb_compression_algorithm cannot be set to bzip2 +SET GLOBAL Innodb_compression_algorithm = bzip2; +ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value of 'bzip2' +show warnings; +Level Code Message +Warning 138 InnoDB: compression algorithm bzip2 (5) is not available. Please, load the corresponding provider plugin. +Error 1231 Variable 'innodb_compression_algorithm' can't be set to the value of 'bzip2' diff --git a/mysql-test/suite/innodb/t/compression_providers_loaded.combinations b/mysql-test/suite/innodb/t/compression_providers_loaded.combinations new file mode 100644 index 00000000000..d2a413f3902 --- /dev/null +++ b/mysql-test/suite/innodb/t/compression_providers_loaded.combinations @@ -0,0 +1,19 @@ +[bzip2] +innodb +plugin-load-add=$PROVIDER_BZIP2_SO + +[lz4] +innodb +plugin-load-add=$PROVIDER_LZ4_SO + +[lzma] +innodb +plugin-load-add=$PROVIDER_LZMA_SO + +[lzo] +innodb +plugin-load-add=$PROVIDER_LZO_SO + +[snappy] +innodb +plugin-load-add=$PROVIDER_SNAPPY_SO diff --git a/mysql-test/suite/innodb/t/compression_providers_loaded.test b/mysql-test/suite/innodb/t/compression_providers_loaded.test new file mode 100644 index 00000000000..1b6c348ccfa --- /dev/null +++ b/mysql-test/suite/innodb/t/compression_providers_loaded.test @@ -0,0 +1,18 @@ +let $alg = $MTR_COMBINATIONS; + +if (`SELECT COUNT(*) = 0 FROM information_schema.plugins WHERE plugin_name = "provider_$alg" AND plugin_status = "active"`) +{ + skip Needs provider_$alg plugin; +} + +--echo # +--echo # Testing unloaded compression provider: $alg +--echo # + +--echo # Innodb_have_$alg reflects that the provider is loaded +eval SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_$alg"; + +--echo # Innodb_compression_algorithm can be set to $alg +let $innodb_compression_algorithm_orig = `SELECT @@Innodb_compression_algorithm`; +eval SET GLOBAL Innodb_compression_algorithm = $alg; +eval SET GLOBAL Innodb_compression_algorithm = $innodb_compression_algorithm_orig; diff --git a/mysql-test/suite/innodb/t/compression_providers_unloaded.combinations b/mysql-test/suite/innodb/t/compression_providers_unloaded.combinations new file mode 100644 index 00000000000..20c49960390 --- /dev/null +++ b/mysql-test/suite/innodb/t/compression_providers_unloaded.combinations @@ -0,0 +1,14 @@ +[bzip2] +innodb + +[lz4] +innodb + +[lzma] +innodb + +[lzo] +innodb + +[snappy] +innodb diff --git a/mysql-test/suite/innodb/t/compression_providers_unloaded.test b/mysql-test/suite/innodb/t/compression_providers_unloaded.test new file mode 100644 index 00000000000..84bcce59729 --- /dev/null +++ b/mysql-test/suite/innodb/t/compression_providers_unloaded.test @@ -0,0 +1,13 @@ +let $alg = $MTR_COMBINATIONS; + +--echo # +--echo # Testing unloaded compression provider: $alg +--echo # + +--echo # Innodb_have_$alg reflects that the provider is not loaded +eval SHOW GLOBAL STATUS WHERE Variable_name = "Innodb_have_$alg"; + +--echo # Innodb_compression_algorithm cannot be set to $alg +error ER_WRONG_VALUE_FOR_VAR; +eval SET GLOBAL Innodb_compression_algorithm = $alg; +show warnings; diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded,lz4.rdiff b/mysql-test/suite/mariabackup/compression_providers_loaded,lz4.rdiff new file mode 100644 index 00000000000..2202a51119e --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded,lz4.rdiff @@ -0,0 +1,13 @@ +--- suite/mariabackup/compression_providers_loaded.result ++++ suite/mariabackup/compression_providers_loaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lz4 compression + # + # Creating table +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = lz4; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded,lzma.rdiff b/mysql-test/suite/mariabackup/compression_providers_loaded,lzma.rdiff new file mode 100644 index 00000000000..e6b52d3ac07 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded,lzma.rdiff @@ -0,0 +1,13 @@ +--- suite/mariabackup/compression_providers_loaded.result ++++ suite/mariabackup/compression_providers_loaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lzma compression + # + # Creating table +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = lzma; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded,lzo.rdiff b/mysql-test/suite/mariabackup/compression_providers_loaded,lzo.rdiff new file mode 100644 index 00000000000..75e9519d680 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded,lzo.rdiff @@ -0,0 +1,13 @@ +--- suite/mariabackup/compression_providers_loaded.result ++++ suite/mariabackup/compression_providers_loaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lzo compression + # + # Creating table +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = lzo; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded,snappy.rdiff b/mysql-test/suite/mariabackup/compression_providers_loaded,snappy.rdiff new file mode 100644 index 00000000000..da281efffc4 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded,snappy.rdiff @@ -0,0 +1,13 @@ +--- suite/mariabackup/compression_providers_loaded.result ++++ suite/mariabackup/compression_providers_loaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with snappy compression + # + # Creating table +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = snappy; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded.combinations b/mysql-test/suite/mariabackup/compression_providers_loaded.combinations new file mode 100644 index 00000000000..3287917fd5e --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded.combinations @@ -0,0 +1,14 @@ +[bzip2] +plugin-load-add=$PROVIDER_BZIP2_SO + +[lz4] +plugin-load-add=$PROVIDER_LZ4_SO + +[lzma] +plugin-load-add=$PROVIDER_LZMA_SO + +[lzo] +plugin-load-add=$PROVIDER_LZO_SO + +[snappy] +plugin-load-add=$PROVIDER_SNAPPY_SO diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded.result b/mysql-test/suite/mariabackup/compression_providers_loaded.result new file mode 100644 index 00000000000..1a8b0594534 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded.result @@ -0,0 +1,26 @@ +# +# Testing mariabackup with bzip2 compression +# +# Creating table +set global innodb_compression_algorithm = bzip2; +create table t1 (a int, b text ) engine = innodb page_compressed = 1; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; +a left(b, 9) length(b) +0 abcabcabc 300 +1 defdefdef 3000 +2 ghighighi 30000 +# xtrabackup backup +# xtrabackup prepare; +# shutdown server +# remove datadir +# xtrabackup move back +# restart +select a, left(b, 9), length(b) from t1; +a left(b, 9) length(b) +0 abcabcabc 300 +1 defdefdef 3000 +2 ghighighi 30000 +drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_loaded.test b/mysql-test/suite/mariabackup/compression_providers_loaded.test new file mode 100644 index 00000000000..60f84fd30c4 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_loaded.test @@ -0,0 +1,36 @@ +let $alg = $MTR_COMBINATIONS; + +if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'provider_$alg' and plugin_status='active'`) +{ + skip "Needs provider_$alg plugin"; +} + +--echo # +--echo # Testing mariabackup with $alg compression +--echo # + +--echo # Creating table +eval set global innodb_compression_algorithm = $alg; +eval create table t1 (a int, b text $column_params) engine = innodb page_compressed = 1; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; + +--echo # xtrabackup backup +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +disable_result_log; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +enable_result_log; + +--echo # xtrabackup prepare; +disable_result_log; +exec $XTRABACKUP --prepare --target-dir=$targetdir; +source include/restart_and_restore.inc; +enable_result_log; + +select a, left(b, 9), length(b) from t1; + +drop table t1; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded,lz4.rdiff b/mysql-test/suite/mariabackup/compression_providers_unloaded,lz4.rdiff new file mode 100644 index 00000000000..4b874403830 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded,lz4.rdiff @@ -0,0 +1,22 @@ +--- suite/mariabackup/compression_providers_unloaded.result ++++ suite/mariabackup/compression_providers_unloaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lz4 compression + # +-# Create table with bzip2 compression +-set global innodb_compression_algorithm = bzip2; ++# Create table with lz4 compression ++set global innodb_compression_algorithm = lz4; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); +@@ -14,6 +14,6 @@ + 2 ghighighi 30000 + # Restart server without plugin + call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-lz4 + # xtrabackup backup + drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded,lzma.rdiff b/mysql-test/suite/mariabackup/compression_providers_unloaded,lzma.rdiff new file mode 100644 index 00000000000..ff57834f624 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded,lzma.rdiff @@ -0,0 +1,22 @@ +--- suite/mariabackup/compression_providers_unloaded.result ++++ suite/mariabackup/compression_providers_unloaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lzma compression + # +-# Create table with bzip2 compression +-set global innodb_compression_algorithm = bzip2; ++# Create table with lzma compression ++set global innodb_compression_algorithm = lzma; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); +@@ -14,6 +14,6 @@ + 2 ghighighi 30000 + # Restart server without plugin + call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-lzma + # xtrabackup backup + drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded,lzo.rdiff b/mysql-test/suite/mariabackup/compression_providers_unloaded,lzo.rdiff new file mode 100644 index 00000000000..5308fc4333e --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded,lzo.rdiff @@ -0,0 +1,22 @@ +--- suite/mariabackup/compression_providers_unloaded.result ++++ suite/mariabackup/compression_providers_unloaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with lzo compression + # +-# Create table with bzip2 compression +-set global innodb_compression_algorithm = bzip2; ++# Create table with lzo compression ++set global innodb_compression_algorithm = lzo; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); +@@ -14,6 +14,6 @@ + 2 ghighighi 30000 + # Restart server without plugin + call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-lzo + # xtrabackup backup + drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded,snappy.rdiff b/mysql-test/suite/mariabackup/compression_providers_unloaded,snappy.rdiff new file mode 100644 index 00000000000..b7b5e2b51c2 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded,snappy.rdiff @@ -0,0 +1,22 @@ +--- suite/mariabackup/compression_providers_unloaded.result ++++ suite/mariabackup/compression_providers_unloaded.reject +@@ -1,8 +1,8 @@ + # +-# Testing mariabackup with bzip2 compression ++# Testing mariabackup with snappy compression + # +-# Create table with bzip2 compression +-set global innodb_compression_algorithm = bzip2; ++# Create table with snappy compression ++set global innodb_compression_algorithm = snappy; + create table t1 (a int, b text ) engine = innodb page_compressed = 1; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); +@@ -14,6 +14,6 @@ + 2 ghighighi 30000 + # Restart server without plugin + call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-snappy + # xtrabackup backup + drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded.combinations b/mysql-test/suite/mariabackup/compression_providers_unloaded.combinations new file mode 100644 index 00000000000..3287917fd5e --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded.combinations @@ -0,0 +1,14 @@ +[bzip2] +plugin-load-add=$PROVIDER_BZIP2_SO + +[lz4] +plugin-load-add=$PROVIDER_LZ4_SO + +[lzma] +plugin-load-add=$PROVIDER_LZMA_SO + +[lzo] +plugin-load-add=$PROVIDER_LZO_SO + +[snappy] +plugin-load-add=$PROVIDER_SNAPPY_SO diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded.result b/mysql-test/suite/mariabackup/compression_providers_unloaded.result new file mode 100644 index 00000000000..57c856b1947 --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded.result @@ -0,0 +1,21 @@ +call mtr.add_suppression("Background Page read failed to read or decrypt"); +call mtr.add_suppression("InnoDB: Failed to read page \\d+ from file './test/t1.ibd': Table is encrypted but decrypt failed"); +# +# Testing mariabackup with bzip2 compression +# +# Create table with bzip2 compression +set global innodb_compression_algorithm = bzip2; +create table t1 (a int, b text ) engine = innodb page_compressed = 1; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; +a left(b, 9) length(b) +0 abcabcabc 300 +1 defdefdef 3000 +2 ghighighi 30000 +# Restart server without plugin +call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +# restart: --disable-provider-bzip2 +# xtrabackup backup +drop table t1; diff --git a/mysql-test/suite/mariabackup/compression_providers_unloaded.test b/mysql-test/suite/mariabackup/compression_providers_unloaded.test new file mode 100644 index 00000000000..debcf0d9e1d --- /dev/null +++ b/mysql-test/suite/mariabackup/compression_providers_unloaded.test @@ -0,0 +1,34 @@ +let $alg = $MTR_COMBINATIONS; +call mtr.add_suppression("Background Page read failed to read or decrypt"); +call mtr.add_suppression("InnoDB: Failed to read page \\d+ from file './test/t1.ibd': Table is encrypted but decrypt failed"); + +if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'provider_$alg' and plugin_status='active'`) +{ + skip "Needs provider_$alg plugin"; +} + +--echo # +--echo # Testing mariabackup with $alg compression +--echo # + +--echo # Create table with $alg compression +eval set global innodb_compression_algorithm = $alg; +eval create table t1 (a int, b text $column_params) engine = innodb page_compressed = 1; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; + +--echo # Restart server without plugin +call mtr.add_suppression("mariadbd: MariaDB tried to use the \\w+ compression, but its provider plugin is not loaded"); +let $restart_parameters = --disable-provider-$alg; +source include/restart_mysqld.inc; + +--echo # xtrabackup backup +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +error 1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; + +drop table t1; +rmdir $targetdir; diff --git a/mysql-test/suite/plugins/r/compression,innodb-lz4.rdiff b/mysql-test/suite/plugins/r/compression,innodb-lz4.rdiff new file mode 100644 index 00000000000..38e6691a3b7 --- /dev/null +++ b/mysql-test/suite/plugins/r/compression,innodb-lz4.rdiff @@ -0,0 +1,23 @@ +--- suite/plugins/r/compression.result ++++ suite/plugins/r/compression.reject +@@ -1,9 +1,9 @@ + # +-# Testing bzip2 compression provider with innodb ++# Testing lz4 compression provider with innodb + # + call mtr.add_suppression("MariaDB tried to use the .+ compression, but its provider plugin is not loaded"); +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = lz4; + call mtr.add_suppression("InnoDB: Background Page read failed to read or decrypt \\[page id: space=\\d+, page number=\\d+\\]"); + call mtr.add_suppression("InnoDB: Failed to read page \\d+ from file './test/t1.ibd': Table is encrypted but decrypt failed"); + call mtr.add_suppression("InnoDB: Table `test`.`t1` is compressed with (\\w+) \\(\\d\\), which is not currently loaded. Please load the '\\1' provider plugin to open the table."); + create table t1 (a int, b text ) engine = innodb page_compressed = 1; +@@ -14,7 +14,7 @@ + 0 abcabcabc 300 + 1 defdefdef 3000 + 2 ghighighi 30000 +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-lz4 + select a, left(b, 9), length(b) from t1; + ERROR 42S02: Table 'test.t1' doesn't exist in engine + drop table t1; diff --git a/mysql-test/suite/plugins/r/compression,innodb-lzma.rdiff b/mysql-test/suite/plugins/r/compression,innodb-lzma.rdiff new file mode 100644 index 00000000000..d12ee0e6a0a --- /dev/null +++ b/mysql-test/suite/plugins/r/compression,innodb-lzma.rdiff @@ -0,0 +1,23 @@ +--- suite/plugins/r/compression.result ++++ suite/plugins/r/compression.reject +@@ -1,9 +1,9 @@ + # +-# Testing bzip2 compression provider with innodb ++# Testing lzma compression provider with innodb + # + call mtr.add_suppression("MariaDB tried to use the .+ compression, but its provider plugin is not loaded"); +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = lzma; + call mtr.add_suppression("InnoDB: Background Page read failed to read or decrypt \\[page id: space=\\d+, page number=\\d+\\]"); + call mtr.add_suppression("InnoDB: Failed to read page \\d+ from file './test/t1.ibd': Table is encrypted but decrypt failed"); + call mtr.add_suppression("InnoDB: Table `test`.`t1` is compressed with (\\w+) \\(\\d\\), which is not currently loaded. Please load the '\\1' provider plugin to open the table."); + create table t1 (a int, b text ) engine = innodb page_compressed = 1; +@@ -14,7 +14,7 @@ + 0 abcabcabc 300 + 1 defdefdef 3000 + 2 ghighighi 30000 +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-lzma + select a, left(b, 9), length(b) from t1; + ERROR 42S02: Table 'test.t1' doesn't exist in engine + drop table t1; diff --git a/mysql-test/suite/plugins/r/compression,innodb-lzo.rdiff b/mysql-test/suite/plugins/r/compression,innodb-lzo.rdiff new file mode 100644 index 00000000000..755dbaea33f --- /dev/null +++ b/mysql-test/suite/plugins/r/compression,innodb-lzo.rdiff @@ -0,0 +1,23 @@ +--- suite/plugins/r/compression.result ++++ suite/plugins/r/compression.reject +@@ -1,9 +1,9 @@ + # +-# Testing bzip2 compression provider with innodb ++# Testing lzo compression provider with innodb + # + call mtr.add_suppression("MariaDB tried to use the .+ compression, but its provider plugin is not loaded"); +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = lzo; + call mtr.add_suppression("InnoDB: Background Page read failed to read or decrypt \\[page id: space=\\d+, page number=\\d+\\]"); + call mtr.add_suppression("InnoDB: Failed to read page \\d+ from file './test/t1.ibd': Table is encrypted but decrypt failed"); + call mtr.add_suppression("InnoDB: Table `test`.`t1` is compressed with (\\w+) \\(\\d\\), which is not currently loaded. Please load the '\\1' provider plugin to open the table."); + create table t1 (a int, b text ) engine = innodb page_compressed = 1; +@@ -14,7 +14,7 @@ + 0 abcabcabc 300 + 1 defdefdef 3000 + 2 ghighighi 30000 +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-lzo + select a, left(b, 9), length(b) from t1; + ERROR 42S02: Table 'test.t1' doesn't exist in engine + drop table t1; diff --git a/mysql-test/suite/plugins/r/compression,innodb-snappy.rdiff b/mysql-test/suite/plugins/r/compression,innodb-snappy.rdiff new file mode 100644 index 00000000000..ea4a3d3a2d9 --- /dev/null +++ b/mysql-test/suite/plugins/r/compression,innodb-snappy.rdiff @@ -0,0 +1,23 @@ +--- suite/plugins/r/compression.result ++++ suite/plugins/r/compression.reject +@@ -1,9 +1,9 @@ + # +-# Testing bzip2 compression provider with innodb ++# Testing snappy compression provider with innodb + # + call mtr.add_suppression("MariaDB tried to use the .+ compression, but its provider plugin is not loaded"); +-set global innodb_compression_algorithm = bzip2; ++set global innodb_compression_algorithm = snappy; + call mtr.add_suppression("InnoDB: Background Page read failed to read or decrypt \\[page id: space=\\d+, page number=\\d+\\]"); + call mtr.add_suppression("InnoDB: Failed to read page \\d+ from file './test/t1.ibd': Table is encrypted but decrypt failed"); + call mtr.add_suppression("InnoDB: Table `test`.`t1` is compressed with (\\w+) \\(\\d\\), which is not currently loaded. Please load the '\\1' provider plugin to open the table."); + create table t1 (a int, b text ) engine = innodb page_compressed = 1; +@@ -14,7 +14,7 @@ + 0 abcabcabc 300 + 1 defdefdef 3000 + 2 ghighighi 30000 +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-snappy + select a, left(b, 9), length(b) from t1; + ERROR 42S02: Table 'test.t1' doesn't exist in engine + drop table t1; diff --git a/mysql-test/suite/plugins/r/compression,mroonga-lz4.rdiff b/mysql-test/suite/plugins/r/compression,mroonga-lz4.rdiff new file mode 100644 index 00000000000..0aa1794603e --- /dev/null +++ b/mysql-test/suite/plugins/r/compression,mroonga-lz4.rdiff @@ -0,0 +1,40 @@ +--- suite/plugins/r/compression.result ++++ suite/plugins/r/compression.reject +@@ -1,12 +1,8 @@ + # +-# Testing bzip2 compression provider with innodb ++# Testing lz4 compression provider with mroonga + # + call mtr.add_suppression("MariaDB tried to use the .+ compression, but its provider plugin is not loaded"); +-set global innodb_compression_algorithm = bzip2; +-call mtr.add_suppression("InnoDB: Background Page read failed to read or decrypt \\[page id: space=\\d+, page number=\\d+\\]"); +-call mtr.add_suppression("InnoDB: Failed to read page \\d+ from file './test/t1.ibd': Table is encrypted but decrypt failed"); +-call mtr.add_suppression("InnoDB: Table `test`.`t1` is compressed with (\\w+), which is not currently loaded. Please load the \\1 provider plugin to open the table"); +-create table t1 (a int, b text ) engine = innodb page_compressed = 1; ++create table t1 (a int, b text COMMENT 'FLAGS "COLUMN_SCALAR|COMPRESS_LZ4"') engine = mroonga charset = utf8; + insert t1 (a, b) values (0, repeat("abc", 100)); + insert t1 (a, b) values (1, repeat("def", 1000)); + insert t1 (a, b) values (2, repeat("ghi", 10000)); +@@ -14,8 +11,20 @@ + 0 abcabcabc 300 + 1 defdefdef 3000 + 2 ghighighi 30000 +-# restart: --disable-provider-bzip2 ++# restart: --disable-provider-lz4 + select a, left(b, 9), length(b) from t1; +-ERROR 42S02: Table 'test.t1' doesn't exist in engine ++a left(b, 9) length(b) ++0 0 ++1 0 ++2 0 ++Warnings: ++Warning 4183 MariaDB tried to use the LZ4 compression, but its provider plugin is not loaded ++select a, left(b, 9), length(b) from t1; ++a left(b, 9) length(b) ++0 0 ++1 0 ++2 0 ++Warnings: ++Warning 4183 MariaDB tried to use the LZ4 compression, but its provider plugin is not loaded + drop table t1; + # restart diff --git a/mysql-test/suite/plugins/r/compression.result b/mysql-test/suite/plugins/r/compression.result new file mode 100644 index 00000000000..ea35273cb55 --- /dev/null +++ b/mysql-test/suite/plugins/r/compression.result @@ -0,0 +1,22 @@ +# +# Testing bzip2 compression provider with innodb +# +call mtr.add_suppression("MariaDB tried to use the .+ compression, but its provider plugin is not loaded"); +set global innodb_compression_algorithm = bzip2; +call mtr.add_suppression("InnoDB: Background Page read failed to read or decrypt \\[page id: space=\\d+, page number=\\d+\\]"); +call mtr.add_suppression("InnoDB: Failed to read page \\d+ from file './test/t1.ibd': Table is encrypted but decrypt failed"); +call mtr.add_suppression("InnoDB: Table `test`.`t1` is compressed with (\\w+), which is not currently loaded. Please load the \\1 provider plugin to open the table"); +create table t1 (a int, b text ) engine = innodb page_compressed = 1; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; +a left(b, 9) length(b) +0 abcabcabc 300 +1 defdefdef 3000 +2 ghighighi 30000 +# restart: --disable-provider-bzip2 +select a, left(b, 9), length(b) from t1; +ERROR 42S02: Table 'test.t1' doesn't exist in engine +drop table t1; +# restart diff --git a/mysql-test/suite/plugins/r/compression_load.result b/mysql-test/suite/plugins/r/compression_load.result new file mode 100644 index 00000000000..b5ccc396248 --- /dev/null +++ b/mysql-test/suite/plugins/r/compression_load.result @@ -0,0 +1,31 @@ +select plugin_name, plugin_status from information_schema.plugins where plugin_name='provider_lz4'; +plugin_name plugin_status +set global innodb_compression_algorithm = lz4; +ERROR 42000: Variable 'innodb_compression_algorithm' can't be set to the value of 'lz4' +install plugin provider_lz4 soname 'provider_lz4'; +select plugin_name, plugin_status from information_schema.plugins where plugin_name='provider_lz4'; +plugin_name plugin_status +provider_lz4 ACTIVE +set global innodb_compression_algorithm = lz4; +set global innodb_compression_algorithm = default; +create table t1 (a int, b text) engine=innodb; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; +a left(b, 9) length(b) +0 abcabcabc 300 +1 defdefdef 3000 +2 ghighighi 30000 +uninstall plugin provider_lz4; +select plugin_name, plugin_status from information_schema.plugins where plugin_name='provider_lz4'; +plugin_name plugin_status +provider_lz4 INACTIVE +set global innodb_compression_algorithm = lz4; +set global innodb_compression_algorithm = default; +select a, left(b, 9), length(b) from t1; +a left(b, 9) length(b) +0 abcabcabc 300 +1 defdefdef 3000 +2 ghighighi 30000 +drop table t1; diff --git a/mysql-test/suite/plugins/t/compression.combinations b/mysql-test/suite/plugins/t/compression.combinations new file mode 100644 index 00000000000..645ca60e5f0 --- /dev/null +++ b/mysql-test/suite/plugins/t/compression.combinations @@ -0,0 +1,29 @@ +[innodb-bzip2] +innodb +plugin-load-add=$PROVIDER_BZIP2_SO +loose-provider-bzip2 + +[innodb-lz4] +innodb +plugin-load-add=$PROVIDER_LZ4_SO +loose-provider-lz4 + +[innodb-lzma] +innodb +plugin-load-add=$PROVIDER_LZMA_SO +loose-provider-lzma + +[innodb-lzo] +innodb +plugin-load-add=$PROVIDER_LZO_SO +loose-provider-lzo + +[innodb-snappy] +innodb +plugin-load-add=$PROVIDER_SNAPPY_SO +loose-provider-snappy + +[mroonga-lz4] +plugin-load-add=$HA_MROONGA_SO +plugin-load-add=$PROVIDER_LZ4_SO +loose-provider-lz4 diff --git a/mysql-test/suite/plugins/t/compression.test b/mysql-test/suite/plugins/t/compression.test new file mode 100644 index 00000000000..2b3e13f0e45 --- /dev/null +++ b/mysql-test/suite/plugins/t/compression.test @@ -0,0 +1,52 @@ +let $engine=`select regexp_replace('$MTR_COMBINATIONS', '-.*', '')`; +let $alg=`select regexp_replace('$MTR_COMBINATIONS', '.*-', '')`; + +if (`select count(*) = 0 from information_schema.plugins where plugin_name = '$engine' and plugin_status='active'`) +{ + skip Needs $engine engine; +} + +if (`select count(*) = 0 from information_schema.plugins where plugin_name = 'provider_$alg' and plugin_status='active'`) +{ + skip Needs provider_$alg plugin; +} + +--echo # +--echo # Testing $alg compression provider with $engine +--echo # + +call mtr.add_suppression("MariaDB tried to use the .+ compression, but its provider plugin is not loaded"); +if ($engine == "innodb") { + eval set global innodb_compression_algorithm = $alg; + let $table_params = page_compressed = 1; + call mtr.add_suppression("InnoDB: Background Page read failed to read or decrypt \\[page id: space=\\d+, page number=\\d+\\]"); + call mtr.add_suppression("InnoDB: Failed to read page \\d+ from file './test/t1.ibd': Table is encrypted but decrypt failed"); + call mtr.add_suppression("InnoDB: Table `test`.`t1` is compressed with (\\w+), which is not currently loaded. Please load the \\1 provider plugin to open the table"); +} +if ($engine == "mroonga") { + let $column_params = `select upper('COMMENT \'flags "COLUMN_SCALAR|COMPRESS_$alg"\'')`; + let $table_params = charset = utf8; +} + +eval create table t1 (a int, b text $column_params) engine = $engine $table_params; + +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; + +let $restart_parameters = --disable-provider-$alg; +source include/restart_mysqld.inc; + +if ($engine == "innodb") { + error ER_NO_SUCH_TABLE_IN_ENGINE; + select a, left(b, 9), length(b) from t1; +} +if ($engine == "mroonga"){ + select a, left(b, 9), length(b) from t1; + select a, left(b, 9), length(b) from t1; # a warning once per statement +} +drop table t1; + +let $restart_parameters =; +source include/restart_mysqld.inc; diff --git a/mysql-test/suite/plugins/t/compression_load.test b/mysql-test/suite/plugins/t/compression_load.test new file mode 100644 index 00000000000..5fb77a5a34e --- /dev/null +++ b/mysql-test/suite/plugins/t/compression_load.test @@ -0,0 +1,24 @@ +source include/have_innodb.inc; + +if (!$PROVIDER_LZ4_SO) { + skip Requires provider_lz4 plugin; +} + +select plugin_name, plugin_status from information_schema.plugins where plugin_name='provider_lz4'; +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_compression_algorithm = lz4; +install plugin provider_lz4 soname 'provider_lz4'; +select plugin_name, plugin_status from information_schema.plugins where plugin_name='provider_lz4'; +set global innodb_compression_algorithm = lz4; +set global innodb_compression_algorithm = default; +create table t1 (a int, b text) engine=innodb; +insert t1 (a, b) values (0, repeat("abc", 100)); +insert t1 (a, b) values (1, repeat("def", 1000)); +insert t1 (a, b) values (2, repeat("ghi", 10000)); +select a, left(b, 9), length(b) from t1; +uninstall plugin provider_lz4; +select plugin_name, plugin_status from information_schema.plugins where plugin_name='provider_lz4'; +set global innodb_compression_algorithm = lz4; +set global innodb_compression_algorithm = default; +select a, left(b, 9), length(b) from t1; +drop table t1; diff --git a/plugin/provider_bzip2/CMakeLists.txt b/plugin/provider_bzip2/CMakeLists.txt new file mode 100644 index 00000000000..bb14f64f87a --- /dev/null +++ b/plugin/provider_bzip2/CMakeLists.txt @@ -0,0 +1,12 @@ +FIND_PACKAGE(BZip2) + +IF (BZIP2_FOUND) + GET_PROPERTY(dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES) + LIST(REMOVE_ITEM dirs ${CMAKE_SOURCE_DIR}/include/providers) + SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${dirs}") + + INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIRS}) + + MYSQL_ADD_PLUGIN(provider_bzip2 plugin.c COMPONENT provider-bzip2 + LINK_LIBRARIES ${BZIP2_LIBRARIES} CONFIG provider_bzip2.cnf) +ENDIF() diff --git a/plugin/provider_bzip2/plugin.c b/plugin/provider_bzip2/plugin.c new file mode 100644 index 00000000000..92978b7e888 --- /dev/null +++ b/plugin/provider_bzip2/plugin.c @@ -0,0 +1,61 @@ +/* Copyright (c) 2021, MariaDB Corporation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include <stdbool.h> +#include <mysql_version.h> +#include <mysql/plugin.h> +#include <bzlib.h> +#include <providers/bzlib.h> + +static int init(void* h) +{ + provider_service_bzip2->BZ2_bzBuffToBuffCompress_ptr= BZ2_bzBuffToBuffCompress; + provider_service_bzip2->BZ2_bzBuffToBuffDecompress_ptr= BZ2_bzBuffToBuffDecompress; + provider_service_bzip2->BZ2_bzCompress_ptr= BZ2_bzCompress; + provider_service_bzip2->BZ2_bzCompressEnd_ptr= BZ2_bzCompressEnd; + provider_service_bzip2->BZ2_bzCompressInit_ptr= BZ2_bzCompressInit; + provider_service_bzip2->BZ2_bzDecompress_ptr= BZ2_bzDecompress; + provider_service_bzip2->BZ2_bzDecompressEnd_ptr= BZ2_bzDecompressEnd; + provider_service_bzip2->BZ2_bzDecompressInit_ptr= BZ2_bzDecompressInit; + + provider_service_bzip2->is_loaded = true; + + return 0; +} + +static int deinit(void *h) +{ + return 1; /* don't unload me */ +} + +static struct st_mysql_daemon info= { MYSQL_DAEMON_INTERFACE_VERSION }; + +maria_declare_plugin(provider_bzip2) +{ + MYSQL_DAEMON_PLUGIN, + &info, + "provider_bzip2", + "Kartik Soneji", + "BZip2 compression provider", + PLUGIN_LICENSE_GPL, + init, + deinit, + 0x0100, + NULL, + NULL, + "1.0", + MariaDB_PLUGIN_MATURITY_STABLE +} +maria_declare_plugin_end; diff --git a/plugin/provider_bzip2/provider_bzip2.cnf b/plugin/provider_bzip2/provider_bzip2.cnf new file mode 100644 index 00000000000..9b855e88769 --- /dev/null +++ b/plugin/provider_bzip2/provider_bzip2.cnf @@ -0,0 +1,3 @@ +[server] +plugin_load_add=provider_bzip2 +provider_bzip2=force_plus_permanent diff --git a/plugin/provider_lz4/CMakeLists.txt b/plugin/provider_lz4/CMakeLists.txt new file mode 100644 index 00000000000..9d47ab80602 --- /dev/null +++ b/plugin/provider_lz4/CMakeLists.txt @@ -0,0 +1,12 @@ +FIND_PACKAGE(LZ4) + +IF (LZ4_FOUND) + GET_PROPERTY(dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES) + LIST(REMOVE_ITEM dirs ${CMAKE_SOURCE_DIR}/include/providers) + SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${dirs}") + + INCLUDE_DIRECTORIES(${LZ4_INCLUDE_DIRS}) + + MYSQL_ADD_PLUGIN(provider_lz4 plugin.c COMPONENT provider-lz4 + LINK_LIBRARIES ${LZ4_LIBRARIES} CONFIG provider_lz4.cnf) +ENDIF() diff --git a/plugin/provider_lz4/plugin.c b/plugin/provider_lz4/plugin.c new file mode 100644 index 00000000000..f9eab163d5a --- /dev/null +++ b/plugin/provider_lz4/plugin.c @@ -0,0 +1,56 @@ +/* Copyright (c) 2021, MariaDB Corporation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include <stdbool.h> +#include <mysql_version.h> +#include <mysql/plugin.h> +#include <lz4.h> +#include <providers/lz4.h> + +static int init(void* h) +{ + provider_service_lz4->LZ4_compressBound_ptr= LZ4_compressBound; + provider_service_lz4->LZ4_compress_default_ptr= LZ4_compress_default; + provider_service_lz4->LZ4_decompress_safe_ptr= LZ4_decompress_safe; + + provider_service_lz4->is_loaded = true; + + return 0; +} + +static int deinit(void *h) +{ + return 1; /* don't unload me */ +} + +static struct st_mysql_daemon info= { MYSQL_DAEMON_INTERFACE_VERSION }; + +maria_declare_plugin(provider_lz4) +{ + MYSQL_DAEMON_PLUGIN, + &info, + "provider_lz4", + "Kartik Soneji", + "LZ4 compression provider", + PLUGIN_LICENSE_GPL, + init, + deinit, + 0x0100, + NULL, + NULL, + "1.0", + MariaDB_PLUGIN_MATURITY_STABLE +} +maria_declare_plugin_end; diff --git a/plugin/provider_lz4/provider_lz4.cnf b/plugin/provider_lz4/provider_lz4.cnf new file mode 100644 index 00000000000..0b8a3ec5222 --- /dev/null +++ b/plugin/provider_lz4/provider_lz4.cnf @@ -0,0 +1,3 @@ +[server] +plugin_load_add=provider_lz4 +provider_lz4=force_plus_permanent diff --git a/plugin/provider_lzma/CMakeLists.txt b/plugin/provider_lzma/CMakeLists.txt new file mode 100644 index 00000000000..569038f7f45 --- /dev/null +++ b/plugin/provider_lzma/CMakeLists.txt @@ -0,0 +1,12 @@ +FIND_PACKAGE(LibLZMA) + +IF (LIBLZMA_FOUND) + GET_PROPERTY(dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES) + LIST(REMOVE_ITEM dirs ${CMAKE_SOURCE_DIR}/include/providers) + SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${dirs}") + + INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS}) + + MYSQL_ADD_PLUGIN(provider_lzma plugin.c COMPONENT provider-lzma + LINK_LIBRARIES ${LIBLZMA_LIBRARIES} CONFIG provider_lzma.cnf) +ENDIF() diff --git a/plugin/provider_lzma/plugin.c b/plugin/provider_lzma/plugin.c new file mode 100644 index 00000000000..0c18471a068 --- /dev/null +++ b/plugin/provider_lzma/plugin.c @@ -0,0 +1,55 @@ +/* Copyright (c) 2021, MariaDB Corporation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include <stdbool.h> +#include <mysql_version.h> +#include <mysql/plugin.h> +#include <lzma.h> +#include <providers/lzma.h> + +static int init(void* h) +{ + provider_service_lzma->lzma_stream_buffer_decode_ptr= lzma_stream_buffer_decode; + provider_service_lzma->lzma_easy_buffer_encode_ptr= lzma_easy_buffer_encode; + + provider_service_lzma->is_loaded = true; + + return 0; +} + +static int deinit(void *h) +{ + return 1; /* don't unload me */ +} + +static struct st_mysql_daemon info= { MYSQL_DAEMON_INTERFACE_VERSION }; + +maria_declare_plugin(provider_lzma) +{ + MYSQL_DAEMON_PLUGIN, + &info, + "provider_lzma", + "Kartik Soneji", + "LZMA compression provider", + PLUGIN_LICENSE_GPL, + init, + deinit, + 0x0100, + NULL, + NULL, + "1.0", + MariaDB_PLUGIN_MATURITY_STABLE +} +maria_declare_plugin_end; diff --git a/plugin/provider_lzma/provider_lzma.cnf b/plugin/provider_lzma/provider_lzma.cnf new file mode 100644 index 00000000000..3a05a356f7f --- /dev/null +++ b/plugin/provider_lzma/provider_lzma.cnf @@ -0,0 +1,3 @@ +[server] +plugin_load_add=provider_lzma +provider_lzma=force_plus_permanent diff --git a/plugin/provider_lzo/CMakeLists.txt b/plugin/provider_lzo/CMakeLists.txt new file mode 100644 index 00000000000..f9104b54f9d --- /dev/null +++ b/plugin/provider_lzo/CMakeLists.txt @@ -0,0 +1,12 @@ +FIND_PACKAGE(LZO) + +IF (LZO_FOUND) + GET_PROPERTY(dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES) + LIST(REMOVE_ITEM dirs ${CMAKE_SOURCE_DIR}/include/providers) + SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${dirs}") + + INCLUDE_DIRECTORIES(${LZO_INCLUDE_DIRS}) + + MYSQL_ADD_PLUGIN(provider_lzo plugin.c COMPONENT provider-lzo + LINK_LIBRARIES ${LZO_LIBRARIES} CONFIG provider_lzo.cnf) +ENDIF() diff --git a/plugin/provider_lzo/plugin.c b/plugin/provider_lzo/plugin.c new file mode 100644 index 00000000000..44c6b54111b --- /dev/null +++ b/plugin/provider_lzo/plugin.c @@ -0,0 +1,55 @@ +/* Copyright (c) 2021, MariaDB Corporation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include <stdbool.h> +#include <mysql_version.h> +#include <mysql/plugin.h> +#include <lzo/lzo1x.h> +#include <providers/lzo/lzo1x.h> + +static int init(void* h) +{ + provider_service_lzo->lzo1x_1_15_compress_ptr= lzo1x_1_15_compress; + provider_service_lzo->lzo1x_decompress_safe_ptr= lzo1x_decompress_safe; + + provider_service_lzo->is_loaded = true; + + return 0; +} + +static int deinit(void *h) +{ + return 1; /* don't unload me */ +} + +static struct st_mysql_daemon info= { MYSQL_DAEMON_INTERFACE_VERSION }; + +maria_declare_plugin(provider_lzo) +{ + MYSQL_DAEMON_PLUGIN, + &info, + "provider_lzo", + "Kartik Soneji", + "LZO compression provider", + PLUGIN_LICENSE_GPL, + init, + deinit, + 0x0100, + NULL, + NULL, + "1.0", + MariaDB_PLUGIN_MATURITY_STABLE +} +maria_declare_plugin_end; diff --git a/plugin/provider_lzo/provider_lzo.cnf b/plugin/provider_lzo/provider_lzo.cnf new file mode 100644 index 00000000000..65801983dd6 --- /dev/null +++ b/plugin/provider_lzo/provider_lzo.cnf @@ -0,0 +1,3 @@ +[server] +plugin_load_add=provider_lzo +provider_lzo=force_plus_permanent diff --git a/plugin/provider_snappy/CMakeLists.txt b/plugin/provider_snappy/CMakeLists.txt new file mode 100644 index 00000000000..af91a90138a --- /dev/null +++ b/plugin/provider_snappy/CMakeLists.txt @@ -0,0 +1,12 @@ +FIND_PACKAGE(Snappy) + +IF (SNAPPY_FOUND) + GET_PROPERTY(dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES) + LIST(REMOVE_ITEM dirs ${CMAKE_SOURCE_DIR}/include/providers) + SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${dirs}") + + INCLUDE_DIRECTORIES(${SNAPPY_INCLUDE_DIRS}) + + MYSQL_ADD_PLUGIN(provider_snappy plugin.c COMPONENT provider-snappy + LINK_LIBRARIES ${SNAPPY_LIBRARIES} CONFIG provider_snappy.cnf) +ENDIF() diff --git a/plugin/provider_snappy/plugin.c b/plugin/provider_snappy/plugin.c new file mode 100644 index 00000000000..8af7eb1b0ea --- /dev/null +++ b/plugin/provider_snappy/plugin.c @@ -0,0 +1,58 @@ +/* Copyright (c) 2021, MariaDB Corporation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +#include <stdbool.h> +#include <mysql_version.h> +#include <mysql/plugin.h> +#include <snappy-c.h> +#define SNAPPY_C +#include <providers/snappy-c.h> + +static int init(void* h) +{ + provider_service_snappy->snappy_max_compressed_length_ptr= snappy_max_compressed_length; + provider_service_snappy->snappy_compress_ptr= snappy_compress; + provider_service_snappy->snappy_uncompressed_length_ptr= snappy_uncompressed_length; + provider_service_snappy->snappy_uncompress_ptr= snappy_uncompress; + + provider_service_snappy->is_loaded = true; + + return 0; +} + +static int deinit(void *h) +{ + return 1; /* don't unload me */ +} + +static struct st_mysql_daemon info= { MYSQL_DAEMON_INTERFACE_VERSION }; + +maria_declare_plugin(provider_snappy) +{ + MYSQL_DAEMON_PLUGIN, + &info, + "provider_snappy", + "Kartik Soneji", + "SNAPPY compression provider", + PLUGIN_LICENSE_GPL, + init, + deinit, + 0x0100, + NULL, + NULL, + "1.0", + MariaDB_PLUGIN_MATURITY_STABLE +} +maria_declare_plugin_end; diff --git a/plugin/provider_snappy/provider_snappy.cnf b/plugin/provider_snappy/provider_snappy.cnf new file mode 100644 index 00000000000..da78207c3e6 --- /dev/null +++ b/plugin/provider_snappy/provider_snappy.cnf @@ -0,0 +1,3 @@ +[server] +plugin_load_add=provider_snappy +provider_snappy=force_plus_permanent diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 205f42f50a0..67750a3d524 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7992,3 +7992,5 @@ ER_REMOVED_ORPHAN_TRIGGER eng "Dropped orphan trigger '%-.64s', originally created for table: '%-.192s'" ER_STORAGE_ENGINE_DISABLED eng "Storage engine %s is disabled" +ER_PROVIDER_NOT_LOADED + eng "MariaDB tried to use the %s, but its provider plugin is not loaded" diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic index 8f2296160e6..0863ca7d65c 100644 --- a/sql/sql_plugin_services.ic +++ b/sql/sql_plugin_services.ic @@ -215,7 +215,7 @@ static struct my_print_error_service_st my_print_error_handler= my_printv_error }; -struct json_service_st json_handler= +static struct json_service_st json_handler= { json_type, json_get_array_item, @@ -230,6 +230,76 @@ static struct thd_mdl_service_st thd_mdl_handler= thd_mdl_context }; +#define DEFINE_warning_function(name, ret) { \ + static query_id_t last_query_id= -1; \ + THD *thd= current_thd; \ + if(thd && thd->query_id != last_query_id) \ + { \ + my_error(ER_PROVIDER_NOT_LOADED, MYF(ME_ERROR_LOG|ME_WARNING), name); \ + last_query_id= thd->query_id; \ + } \ + return ret; \ +} + +#include <providers/lzma.h> +static struct provider_service_lzma_st provider_handler_lzma= +{ + DEFINE_lzma_stream_buffer_decode([]) DEFINE_warning_function("LZMA compression", LZMA_PROG_ERROR), + DEFINE_lzma_easy_buffer_encode([]) DEFINE_warning_function("LZMA compression", LZMA_PROG_ERROR), + + false // .is_loaded +}; +struct provider_service_lzma_st *provider_service_lzma= &provider_handler_lzma; + +#include <providers/lzo/lzo1x.h> +static struct provider_service_lzo_st provider_handler_lzo= +{ + DEFINE_lzo1x_1_15_compress([]) DEFINE_warning_function("LZO compression", LZO_E_INTERNAL_ERROR), + DEFINE_lzo1x_decompress_safe([]) DEFINE_warning_function("LZO compression", LZO_E_INTERNAL_ERROR), + + false // .is_loaded +}; +struct provider_service_lzo_st *provider_service_lzo= &provider_handler_lzo; + +#include <providers/bzlib.h> +static struct provider_service_bzip2_st provider_handler_bzip2= +{ + DEFINE_BZ2_bzBuffToBuffCompress([]) DEFINE_warning_function("BZip2 compression", -1), + DEFINE_BZ2_bzBuffToBuffDecompress([]) DEFINE_warning_function("BZip2 compression", -1), + DEFINE_BZ2_bzCompress([]) DEFINE_warning_function("BZip2 compression", -1), + DEFINE_BZ2_bzCompressEnd([]) DEFINE_warning_function("BZip2 compression", -1), + DEFINE_BZ2_bzCompressInit([]) DEFINE_warning_function("BZip2 compression", -1), + DEFINE_BZ2_bzDecompress([]) DEFINE_warning_function("BZip2 compression", -1), + DEFINE_BZ2_bzDecompressEnd([]) DEFINE_warning_function("BZip2 compression", -1), + DEFINE_BZ2_bzDecompressInit([]) DEFINE_warning_function("BZip2 compression", -1), + + false // .is_loaded +}; +struct provider_service_bzip2_st *provider_service_bzip2= &provider_handler_bzip2; + +#include <providers/snappy-c.h> +static struct provider_service_snappy_st provider_handler_snappy= +{ + DEFINE_snappy_max_compressed_length([]) -> size_t DEFINE_warning_function("Snappy compression", 0), + DEFINE_snappy_compress([]) DEFINE_warning_function("Snappy compression", SNAPPY_INVALID_INPUT), + DEFINE_snappy_uncompressed_length([]) DEFINE_warning_function("Snappy compression", SNAPPY_INVALID_INPUT), + DEFINE_snappy_uncompress([]) DEFINE_warning_function("Snappy compression", SNAPPY_INVALID_INPUT), + + false // .is_loaded +}; +struct provider_service_snappy_st *provider_service_snappy= &provider_handler_snappy; + +#include <providers/lz4.h> +static struct provider_service_lz4_st provider_handler_lz4= +{ + DEFINE_LZ4_compressBound([]) DEFINE_warning_function("LZ4 compression", 0), + DEFINE_LZ4_compress_default([]) DEFINE_warning_function("LZ4 compression", 0), + DEFINE_LZ4_decompress_safe([]) DEFINE_warning_function("LZ4 compression", -1), + + false // .is_loaded +}; +struct provider_service_lz4_st *provider_service_lz4= &provider_handler_lz4; + static struct st_service_ref list_of_services[]= { { "base64_service", VERSION_base64, &base64_handler }, @@ -254,5 +324,10 @@ static struct st_service_ref list_of_services[]= { "thd_wait_service", VERSION_thd_wait, &thd_wait_handler }, { "wsrep_service", VERSION_wsrep, &wsrep_handler }, { "json_service", VERSION_json, &json_handler }, - { "thd_mdl_service", VERSION_thd_mdl, &thd_mdl_handler } + { "thd_mdl_service", VERSION_thd_mdl, &thd_mdl_handler }, + { "provider_service_bzip2", VERSION_provider_bzip2, &provider_handler_bzip2 }, + { "provider_service_lz4", VERSION_provider_lz4, &provider_handler_lz4 }, + { "provider_service_lzma", VERSION_provider_lzma, &provider_handler_lzma }, + { "provider_service_lzo", VERSION_provider_lzo, &provider_handler_lzo }, + { "provider_service_snappy", VERSION_provider_snappy, &provider_handler_snappy } }; diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 3187df9926a..aaca1745a6f 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -40,11 +40,8 @@ Created 11/11/1995 Heikki Tuuri #include "log0crypt.h" #include "srv0mon.h" #include "fil0pagecompress.h" -#ifdef HAVE_LZO -# include "lzo/lzo1x.h" -#elif defined HAVE_SNAPPY -# include "snappy-c.h" -#endif +#include "lzo/lzo1x.h" +#include "snappy-c.h" /** Number of pages flushed via LRU. Protected by buf_pool.mutex. Also included in buf_flush_page_count. */ @@ -576,11 +573,10 @@ static void buf_tmp_reserve_compression_buf(buf_tmp_buffer_t* slot) /* Both Snappy and LZO compression methods require that the output buffer be bigger than input buffer. Adjust the allocated size. */ ulint size= srv_page_size; -#ifdef HAVE_LZO - size+= LZO1X_1_15_MEM_COMPRESS; -#elif defined HAVE_SNAPPY - size= snappy_max_compressed_length(size); -#endif + if (provider_service_lzo->is_loaded) + size+= LZO1X_1_15_MEM_COMPRESS; + else if (provider_service_snappy->is_loaded) + size= snappy_max_compressed_length(size); slot->comp_buf= static_cast<byte*>(aligned_malloc(size, srv_page_size)); } diff --git a/storage/innobase/bzip2.cmake b/storage/innobase/bzip2.cmake deleted file mode 100644 index 91dd2bf0fcd..00000000000 --- a/storage/innobase/bzip2.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2014, SkySQL Ab. All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA - -SET(WITH_INNODB_BZIP2 AUTO CACHE STRING - "Build with bzip2. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'") - -MACRO (MYSQL_CHECK_BZIP2) - IF (WITH_INNODB_BZIP2 STREQUAL "ON" OR WITH_INNODB_BZIP2 STREQUAL "AUTO") - CHECK_INCLUDE_FILES(bzlib.h HAVE_BZLIB2_H) - CHECK_LIBRARY_EXISTS(bz2 BZ2_bzBuffToBuffCompress "" HAVE_BZLIB2_COMPRESS) - CHECK_LIBRARY_EXISTS(bz2 BZ2_bzBuffToBuffDecompress "" HAVE_BZLIB2_DECOMPRESS) - - IF (HAVE_BZLIB2_COMPRESS AND HAVE_BZLIB2_DECOMPRESS AND HAVE_BZLIB2_H) - SET(HAVE_INNODB_BZLIB2 TRUE) - ADD_DEFINITIONS(-DHAVE_BZIP2=1) - LINK_LIBRARIES(bz2) - ELSE() - IF (WITH_INNODB_BZIP2 STREQUAL "ON") - MESSAGE(FATAL_ERROR "Required bzip2 library is not found") - ENDIF() - ENDIF() - ENDIF() - ADD_FEATURE_INFO(INNODB_BZIP2 HAVE_INNODB_BZLIB2 - "BZIP2 compression in the InnoDB storage engine") -ENDMACRO() diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 6074398afd3..1f5030b1235 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1039,8 +1039,17 @@ dict_table_open_on_name( if (!(ignore_err & ~DICT_ERR_IGNORE_FK_NOKEY) && !table->is_readable() && table->corrupted) { - ib::error() << "Table " << table->name - << " is corrupted. Please drop the table and recreate."; + ulint algo = table->space->get_compression_algo(); + if (algo <= PAGE_ALGORITHM_LAST && !fil_comp_algo_loaded(algo)) { + ib::error() << "Table " << table->name << " is compressed with " + << page_compression_algorithms[algo] + << ", which is not currently loaded. Please load the " + << page_compression_algorithms[algo] + << " provider plugin to open the table"; + } else { + ib::error() << "Table " << table->name + << " is corrupted. Please drop the table and recreate."; + } dict_sys.unfreeze(); DBUG_RETURN(nullptr); } diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 121c7a5666b..c8e2c238aa9 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -54,6 +54,12 @@ Created 10/25/1995 Heikki Tuuri # include <dirent.h> #endif +#include "lz4.h" +#include "lzo/lzo1x.h" +#include "lzma.h" +#include "bzlib.h" +#include "snappy-c.h" + /** Try to close a file to adhere to the innodb_open_files limit. @param print_info whether to diagnose why a file cannot be closed @return whether a file was closed */ @@ -233,38 +239,30 @@ fil_space_t *fil_space_get(uint32_t id) return space; } -/** Validate the compression algorithm for full crc32 format. -@param[in] space tablespace object -@return whether the compression algorithm support */ -static bool fil_comp_algo_validate(const fil_space_t* space) +/** Check if the compression algorithm is loaded +@param[in] comp_algo ulint compression algorithm +@return whether the compression algorithm is loaded */ +bool fil_comp_algo_loaded(ulint comp_algo) { - if (!space->full_crc32()) { - return true; - } - - DBUG_EXECUTE_IF("fil_comp_algo_validate_fail", - return false;); - - ulint comp_algo = space->get_compression_algo(); switch (comp_algo) { case PAGE_UNCOMPRESSED: case PAGE_ZLIB_ALGORITHM: -#ifdef HAVE_LZ4 + return true; + case PAGE_LZ4_ALGORITHM: -#endif /* HAVE_LZ4 */ -#ifdef HAVE_LZO + return provider_service_lz4->is_loaded; + case PAGE_LZO_ALGORITHM: -#endif /* HAVE_LZO */ -#ifdef HAVE_LZMA + return provider_service_lzo->is_loaded; + case PAGE_LZMA_ALGORITHM: -#endif /* HAVE_LZMA */ -#ifdef HAVE_BZIP2 + return provider_service_lzma->is_loaded; + case PAGE_BZIP2_ALGORITHM: -#endif /* HAVE_BZIP2 */ -#ifdef HAVE_SNAPPY + return provider_service_bzip2->is_loaded; + case PAGE_SNAPPY_ALGORITHM: -#endif /* HAVE_SNAPPY */ - return true; + return provider_service_snappy->is_loaded; } return false; @@ -363,9 +361,26 @@ static bool fil_node_open_file_low(fil_node_t *node) return false; } + ulint comp_algo = node->space->get_compression_algo(); + bool comp_algo_invalid = false; + if (node->size); - else if (!node->read_page0() || !fil_comp_algo_validate(node->space)) + else if (!node->read_page0() || + // validate compression algorithm for full crc32 format + (node->space->full_crc32() && + (comp_algo_invalid = !fil_comp_algo_loaded(comp_algo)))) { + if (comp_algo_invalid) + { + if (comp_algo <= PAGE_ALGORITHM_LAST) + ib::warn() << "'" << node->name << "' is compressed with " + << page_compression_algorithms[comp_algo] + << ", which is not currently loaded"; + else + ib::warn() << "'" << node->name << "' is compressed with " + << "invalid algorithm: " << comp_algo; + } + os_file_close(node->handle); node->handle= OS_FILE_CLOSED; return false; diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index d9c5cfc9f3b..b6971558201 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -55,21 +55,11 @@ Updated 14/02/2015 #include <fcntl.h> #endif #include "row0mysql.h" -#ifdef HAVE_LZ4 #include "lz4.h" -#endif -#ifdef HAVE_LZO #include "lzo/lzo1x.h" -#endif -#ifdef HAVE_LZMA #include "lzma.h" -#endif -#ifdef HAVE_BZIP2 #include "bzlib.h" -#endif -#ifdef HAVE_SNAPPY #include "snappy-c.h" -#endif /** Compress a page for the given compression algorithm. @param[in] buf page to be compressed @@ -94,6 +84,7 @@ static ulint fil_page_compress_low( /* fall through */ case PAGE_UNCOMPRESSED: return 0; + case PAGE_ZLIB_ALGORITHM: { ulong len = uLong(write_size); @@ -104,23 +95,15 @@ static ulint fil_page_compress_low( } } break; -#ifdef HAVE_LZ4 + case PAGE_LZ4_ALGORITHM: -# ifdef HAVE_LZ4_COMPRESS_DEFAULT write_size = LZ4_compress_default( reinterpret_cast<const char*>(buf), reinterpret_cast<char*>(out_buf) + header_len, int(srv_page_size), int(write_size)); -# else - write_size = LZ4_compress_limitedOutput( - reinterpret_cast<const char*>(buf), - reinterpret_cast<char*>(out_buf) + header_len, - int(srv_page_size), int(write_size)); -# endif return write_size; -#endif /* HAVE_LZ4 */ -#ifdef HAVE_LZO + case PAGE_LZO_ALGORITHM: { lzo_uint len = write_size; @@ -133,8 +116,7 @@ static ulint fil_page_compress_low( } break; } -#endif /* HAVE_LZO */ -#ifdef HAVE_LZMA + case PAGE_LZMA_ALGORITHM: { size_t out_pos = 0; @@ -147,9 +129,7 @@ static ulint fil_page_compress_low( } break; } -#endif /* HAVE_LZMA */ -#ifdef HAVE_BZIP2 case PAGE_BZIP2_ALGORITHM: { unsigned len = unsigned(write_size); if (BZ_OK == BZ2_bzBuffToBuffCompress( @@ -163,9 +143,7 @@ static ulint fil_page_compress_low( } break; } -#endif /* HAVE_BZIP2 */ -#ifdef HAVE_SNAPPY case PAGE_SNAPPY_ALGORITHM: { size_t len = snappy_max_compressed_length(srv_page_size); @@ -179,7 +157,6 @@ static ulint fil_page_compress_low( } break; } -#endif /* HAVE_SNAPPY */ } return 0; @@ -432,7 +409,7 @@ static bool fil_page_decompress_low( uLong(actual_size)) && len == srv_page_size); } -#ifdef HAVE_LZ4 + case PAGE_LZ4_ALGORITHM: return LZ4_decompress_safe( reinterpret_cast<const char*>(buf) + header_len, @@ -440,8 +417,7 @@ static bool fil_page_decompress_low( static_cast<int>(actual_size), static_cast<int>(srv_page_size)) == static_cast<int>(srv_page_size); -#endif /* HAVE_LZ4 */ -#ifdef HAVE_LZO + case PAGE_LZO_ALGORITHM: { lzo_uint len_lzo = srv_page_size; @@ -450,8 +426,7 @@ static bool fil_page_decompress_low( actual_size, tmp_buf, &len_lzo, NULL) && len_lzo == srv_page_size); } -#endif /* HAVE_LZO */ -#ifdef HAVE_LZMA + case PAGE_LZMA_ALGORITHM: { size_t src_pos = 0; @@ -464,8 +439,7 @@ static bool fil_page_decompress_low( srv_page_size) && dst_pos == srv_page_size; } -#endif /* HAVE_LZMA */ -#ifdef HAVE_BZIP2 + case PAGE_BZIP2_ALGORITHM: { uint dst_pos = static_cast<uint>(srv_page_size); @@ -476,8 +450,7 @@ static bool fil_page_decompress_low( static_cast<uint>(actual_size), 1, 0) && dst_pos == srv_page_size; } -#endif /* HAVE_BZIP2 */ -#ifdef HAVE_SNAPPY + case PAGE_SNAPPY_ALGORITHM: { size_t olen = srv_page_size; @@ -489,7 +462,6 @@ static bool fil_page_decompress_low( reinterpret_cast<char*>(tmp_buf), &olen) && olen == srv_page_size; } -#endif /* HAVE_SNAPPY */ } return false; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index bd879c7c275..fb308ed5a22 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -114,6 +114,12 @@ this program; if not, write to the Free Software Foundation, Inc., #include "ut0mem.h" #include "row0ext.h" +#include "lz4.h" +#include "lzo/lzo1x.h" +#include "lzma.h" +#include "bzlib.h" +#include "snappy-c.h" + #include <limits> #define thd_get_trx_isolation(X) ((enum_tx_isolation)thd_tx_isolation(X)) @@ -833,11 +839,6 @@ innodb_compression_algorithm_validate( for update function */ struct st_mysql_value* value); /*!< in: incoming string */ -static ibool innodb_have_lzo=IF_LZO(1, 0); -static ibool innodb_have_lz4=IF_LZ4(1, 0); -static ibool innodb_have_lzma=IF_LZMA(1, 0); -static ibool innodb_have_bzip2=IF_BZIP2(1, 0); -static ibool innodb_have_snappy=IF_SNAPPY(1, 0); static ibool innodb_have_punch_hole=IF_PUNCH_HOLE(1, 0); static @@ -1029,11 +1030,11 @@ static SHOW_VAR innodb_status_variables[]= { &export_vars.innodb_pages_encrypted, SHOW_LONGLONG}, {"num_pages_decrypted", &export_vars.innodb_pages_decrypted, SHOW_LONGLONG}, - {"have_lz4", &innodb_have_lz4, SHOW_BOOL}, - {"have_lzo", &innodb_have_lzo, SHOW_BOOL}, - {"have_lzma", &innodb_have_lzma, SHOW_BOOL}, - {"have_bzip2", &innodb_have_bzip2, SHOW_BOOL}, - {"have_snappy", &innodb_have_snappy, SHOW_BOOL}, + {"have_lz4", &(provider_service_lz4->is_loaded), SHOW_BOOL}, + {"have_lzo", &(provider_service_lzo->is_loaded), SHOW_BOOL}, + {"have_lzma", &(provider_service_lzma->is_loaded), SHOW_BOOL}, + {"have_bzip2", &(provider_service_bzip2->is_loaded), SHOW_BOOL}, + {"have_snappy", &(provider_service_snappy->is_loaded), SHOW_BOOL}, {"have_punch_hole", &innodb_have_punch_hole, SHOW_BOOL}, /* Defragmentation */ @@ -3694,6 +3695,25 @@ static void innodb_buffer_pool_size_init() innobase_buffer_pool_size = srv_buf_pool_size; } + +static bool +compression_algorithm_is_not_loaded(ulong compression_algorithm, myf flags) +{ + bool is_loaded[PAGE_ALGORITHM_LAST+1]= { 1, 1, provider_service_lz4->is_loaded, + provider_service_lzo->is_loaded, provider_service_lzma->is_loaded, + provider_service_bzip2->is_loaded, provider_service_snappy->is_loaded }; + + DBUG_ASSERT(compression_algorithm <= PAGE_ALGORITHM_LAST); + + if (is_loaded[compression_algorithm]) + return 0; + + my_printf_error(HA_ERR_UNSUPPORTED, "InnoDB: compression algorithm %s (%u)" + " is not available. Please, load the corresponding provider plugin.", flags, + page_compression_algorithms[compression_algorithm], compression_algorithm); + return 1; +} + /** Initialize, validate and normalize the InnoDB startup parameters. @return failure code @retval 0 on success @@ -3726,50 +3746,8 @@ static int innodb_init_params() DBUG_RETURN(HA_ERR_INITIALIZATION); } -#ifndef HAVE_LZ4 - if (innodb_compression_algorithm == PAGE_LZ4_ALGORITHM) { - sql_print_error("InnoDB: innodb_compression_algorithm = %lu unsupported.\n" - "InnoDB: liblz4 is not installed. \n", - innodb_compression_algorithm); - DBUG_RETURN(HA_ERR_INITIALIZATION); - } -#endif - -#ifndef HAVE_LZO - if (innodb_compression_algorithm == PAGE_LZO_ALGORITHM) { - sql_print_error("InnoDB: innodb_compression_algorithm = %lu unsupported.\n" - "InnoDB: liblzo is not installed. \n", - innodb_compression_algorithm); - DBUG_RETURN(HA_ERR_INITIALIZATION); - } -#endif - -#ifndef HAVE_LZMA - if (innodb_compression_algorithm == PAGE_LZMA_ALGORITHM) { - sql_print_error("InnoDB: innodb_compression_algorithm = %lu unsupported.\n" - "InnoDB: liblzma is not installed. \n", - innodb_compression_algorithm); - DBUG_RETURN(HA_ERR_INITIALIZATION); - } -#endif - -#ifndef HAVE_BZIP2 - if (innodb_compression_algorithm == PAGE_BZIP2_ALGORITHM) { - sql_print_error("InnoDB: innodb_compression_algorithm = %lu unsupported.\n" - "InnoDB: libbz2 is not installed. \n", - innodb_compression_algorithm); - DBUG_RETURN(HA_ERR_INITIALIZATION); - } -#endif - -#ifndef HAVE_SNAPPY - if (innodb_compression_algorithm == PAGE_SNAPPY_ALGORITHM) { - sql_print_error("InnoDB: innodb_compression_algorithm = %lu unsupported.\n" - "InnoDB: libsnappy is not installed. \n", - innodb_compression_algorithm); - DBUG_RETURN(HA_ERR_INITIALIZATION); - } -#endif + if (compression_algorithm_is_not_loaded(innodb_compression_algorithm, ME_ERROR_LOG)) + DBUG_RETURN(HA_ERR_INITIALIZATION); if ((srv_encrypt_tables || srv_encrypt_log || innodb_encrypt_temporary_tables) @@ -19543,7 +19521,7 @@ static MYSQL_SYSVAR_BOOL(force_primary_key, "Do not allow creating a table without primary key (off by default)", NULL, NULL, FALSE); -static const char *page_compression_algorithms[]= { "none", "zlib", "lz4", "lzo", "lzma", "bzip2", "snappy", 0 }; +const char *page_compression_algorithms[]= { "none", "zlib", "lz4", "lzo", "lzma", "bzip2", "snappy", 0 }; static TYPELIB page_compression_algorithms_typelib= { array_elements(page_compression_algorithms) - 1, 0, @@ -20872,70 +20850,14 @@ innodb_compression_algorithm_validate( for update function */ struct st_mysql_value* value) /*!< in: incoming string */ { - ulong compression_algorithm; DBUG_ENTER("innobase_compression_algorithm_validate"); if (check_sysvar_enum(thd, var, save, value)) { DBUG_RETURN(1); } - compression_algorithm = *reinterpret_cast<ulong*>(save); - (void)compression_algorithm; - -#ifndef HAVE_LZ4 - if (compression_algorithm == PAGE_LZ4_ALGORITHM) { - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - HA_ERR_UNSUPPORTED, - "InnoDB: innodb_compression_algorithm = %lu unsupported.\n" - "InnoDB: liblz4 is not installed. \n", - compression_algorithm); - DBUG_RETURN(1); - } -#endif - -#ifndef HAVE_LZO - if (compression_algorithm == PAGE_LZO_ALGORITHM) { - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - HA_ERR_UNSUPPORTED, - "InnoDB: innodb_compression_algorithm = %lu unsupported.\n" - "InnoDB: liblzo is not installed. \n", - compression_algorithm); - DBUG_RETURN(1); - } -#endif - -#ifndef HAVE_LZMA - if (compression_algorithm == PAGE_LZMA_ALGORITHM) { - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - HA_ERR_UNSUPPORTED, - "InnoDB: innodb_compression_algorithm = %lu unsupported.\n" - "InnoDB: liblzma is not installed. \n", - compression_algorithm); - DBUG_RETURN(1); - } -#endif - -#ifndef HAVE_BZIP2 - if (compression_algorithm == PAGE_BZIP2_ALGORITHM) { - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - HA_ERR_UNSUPPORTED, - "InnoDB: innodb_compression_algorithm = %lu unsupported.\n" - "InnoDB: libbz2 is not installed. \n", - compression_algorithm); - DBUG_RETURN(1); - } -#endif - -#ifndef HAVE_SNAPPY - if (compression_algorithm == PAGE_SNAPPY_ALGORITHM) { - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, - HA_ERR_UNSUPPORTED, - "InnoDB: innodb_compression_algorithm = %lu unsupported.\n" - "InnoDB: libsnappy is not installed. \n", - compression_algorithm); - DBUG_RETURN(1); - } -#endif + if (compression_algorithm_is_not_loaded(*(ulong*)save, ME_WARNING)) + DBUG_RETURN(1); DBUG_RETURN(0); } diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 2838abde333..4c7663a0995 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -1734,6 +1734,9 @@ inline bool fil_names_write_if_was_clean(fil_space_t* space) return(was_clean); } + +bool fil_comp_algo_loaded(ulint comp_algo); + /** On a log checkpoint, reset fil_names_dirty_and_write() flags and write out FILE_MODIFY and FILE_CHECKPOINT if needed. @param[in] lsn checkpoint LSN diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h index 4f23b403050..e062ed189bd 100644 --- a/storage/innobase/include/fsp0types.h +++ b/storage/innobase/include/fsp0types.h @@ -33,14 +33,16 @@ constexpr uint32_t SRV_SPACE_ID_UPPER_BOUND= 0xFFFFFFF0U; constexpr uint32_t SRV_TMP_SPACE_ID= 0xFFFFFFFEU; /* Possible values of innodb_compression_algorithm */ -#define PAGE_UNCOMPRESSED 0 -#define PAGE_ZLIB_ALGORITHM 1 -#define PAGE_LZ4_ALGORITHM 2 -#define PAGE_LZO_ALGORITHM 3 -#define PAGE_LZMA_ALGORITHM 4 +#define PAGE_UNCOMPRESSED 0 +#define PAGE_ZLIB_ALGORITHM 1 +#define PAGE_LZ4_ALGORITHM 2 +#define PAGE_LZO_ALGORITHM 3 +#define PAGE_LZMA_ALGORITHM 4 #define PAGE_BZIP2_ALGORITHM 5 #define PAGE_SNAPPY_ALGORITHM 6 -#define PAGE_ALGORITHM_LAST PAGE_SNAPPY_ALGORITHM +#define PAGE_ALGORITHM_LAST PAGE_SNAPPY_ALGORITHM + +extern const char *page_compression_algorithms[]; /** @name Flags for inserting records in order If records are inserted in order, there are the following diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index f851db62d18..bef51549e73 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -217,36 +217,6 @@ management to ensure correct alignment for doubles etc. */ ======================== */ -#ifdef HAVE_LZO -#define IF_LZO(A,B) A -#else -#define IF_LZO(A,B) B -#endif - -#ifdef HAVE_LZ4 -#define IF_LZ4(A,B) A -#else -#define IF_LZ4(A,B) B -#endif - -#ifdef HAVE_LZMA -#define IF_LZMA(A,B) A -#else -#define IF_LZMA(A,B) B -#endif - -#ifdef HAVE_BZIP2 -#define IF_BZIP2(A,B) A -#else -#define IF_BZIP2(A,B) B -#endif - -#ifdef HAVE_SNAPPY -#define IF_SNAPPY(A,B) A -#else -#define IF_SNAPPY(A,B) B -#endif - #if defined (HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE) || defined(_WIN32) #define IF_PUNCH_HOLE(A,B) A #else diff --git a/storage/innobase/innodb.cmake b/storage/innobase/innodb.cmake index 0a276530637..5196637eed2 100644 --- a/storage/innobase/innodb.cmake +++ b/storage/innobase/innodb.cmake @@ -19,19 +19,9 @@ INCLUDE(CheckFunctionExists) INCLUDE(CheckCSourceCompiles) INCLUDE(CheckCSourceRuns) -INCLUDE(lz4.cmake) -INCLUDE(lzo.cmake) -INCLUDE(lzma.cmake) -INCLUDE(bzip2.cmake) -INCLUDE(snappy.cmake) INCLUDE(numa) INCLUDE(TestBigEndian) -MYSQL_CHECK_LZ4() -MYSQL_CHECK_LZO() -MYSQL_CHECK_LZMA() -MYSQL_CHECK_BZIP2() -MYSQL_CHECK_SNAPPY() MYSQL_CHECK_NUMA() INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake) diff --git a/storage/innobase/lz4.cmake b/storage/innobase/lz4.cmake deleted file mode 100644 index a908dd3b73e..00000000000 --- a/storage/innobase/lz4.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2014, SkySQL Ab. All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA - -SET(WITH_INNODB_LZ4 AUTO CACHE STRING - "Build with lz4. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'") - -MACRO (MYSQL_CHECK_LZ4) - IF (WITH_INNODB_LZ4 STREQUAL "ON" OR WITH_INNODB_LZ4 STREQUAL "AUTO") - CHECK_INCLUDE_FILES(lz4.h HAVE_LZ4_H) - CHECK_LIBRARY_EXISTS(lz4 LZ4_compress_limitedOutput "" HAVE_LZ4_SHARED_LIB) - CHECK_LIBRARY_EXISTS(lz4 LZ4_compress_default "" HAVE_LZ4_COMPRESS_DEFAULT) - - IF (HAVE_LZ4_SHARED_LIB AND HAVE_LZ4_H) - SET(HAVE_INNODB_LZ4 TRUE) - ADD_DEFINITIONS(-DHAVE_LZ4=1) - IF (HAVE_LZ4_COMPRESS_DEFAULT) - ADD_DEFINITIONS(-DHAVE_LZ4_COMPRESS_DEFAULT=1) - ENDIF() - LINK_LIBRARIES(lz4) - ELSE() - IF (WITH_INNODB_LZ4 STREQUAL "ON") - MESSAGE(FATAL_ERROR "Required lz4 library is not found") - ENDIF() - ENDIF() - ENDIF() - ADD_FEATURE_INFO(INNODB_LZ4 HAVE_INNODB_LZ4 "LZ4 compression in the InnoDB storage engine") -ENDMACRO() diff --git a/storage/innobase/lzma.cmake b/storage/innobase/lzma.cmake deleted file mode 100644 index 3060139c27c..00000000000 --- a/storage/innobase/lzma.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 2014, SkySQL Ab. All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA - -SET(WITH_INNODB_LZMA AUTO CACHE STRING - "Build with lzma. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'") - -MACRO (MYSQL_CHECK_LZMA) - IF (WITH_INNODB_LZMA STREQUAL "ON" OR WITH_INNODB_LZMA STREQUAL "AUTO") - CHECK_INCLUDE_FILES(lzma.h HAVE_LZMA_H) - CHECK_LIBRARY_EXISTS(lzma lzma_stream_buffer_decode "" HAVE_LZMA_DECODE) - CHECK_LIBRARY_EXISTS(lzma lzma_easy_buffer_encode "" HAVE_LZMA_ENCODE) - - IF (HAVE_LZMA_DECODE AND HAVE_LZMA_ENCODE AND HAVE_LZMA_H) - SET(HAVE_INNODB_LZMA TRUE) - ADD_DEFINITIONS(-DHAVE_LZMA=1) - LINK_LIBRARIES(lzma) - ELSE() - IF (WITH_INNODB_LZMA STREQUAL "ON") - MESSAGE(FATAL_ERROR "Required lzma library is not found") - ENDIF() - ENDIF() - ENDIF() - ADD_FEATURE_INFO(INNODB_LZMA HAVE_INNODB_LZMA "LZMA compression in the InnoDB storage engine") -ENDMACRO() diff --git a/storage/innobase/lzo.cmake b/storage/innobase/lzo.cmake deleted file mode 100644 index ca2de6ab1c5..00000000000 --- a/storage/innobase/lzo.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2014, SkySQL Ab. All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA - -SET(WITH_INNODB_LZO AUTO CACHE STRING - "Build with lzo. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'") - -MACRO (MYSQL_CHECK_LZO) - IF (WITH_INNODB_LZO STREQUAL "ON" OR WITH_INNODB_LZO STREQUAL "AUTO") - CHECK_INCLUDE_FILES(lzo/lzo1x.h HAVE_LZO_H) - CHECK_LIBRARY_EXISTS(lzo2 lzo1x_1_compress "" HAVE_LZO_SHARED_LIB) - - IF(HAVE_LZO_SHARED_LIB AND HAVE_LZO_H) - SET(HAVE_INNODB_LZO TRUE) - ADD_DEFINITIONS(-DHAVE_LZO=1) - LINK_LIBRARIES(lzo2) - ELSE() - IF (WITH_INNODB_LZO STREQUAL "ON") - MESSAGE(FATAL_ERROR "Required lzo library is not found") - ENDIF() - ENDIF() - ENDIF() - ADD_FEATURE_INFO(INNODB_LZO HAVE_INNODB_LZO "LZO compression in the InnoDB storage engine") -ENDMACRO() diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 203cbb5ceed..5ca11417439 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -41,12 +41,8 @@ Created 2012-02-08 by Sunny Bains. #include "fil0pagecompress.h" #include "trx0undo.h" #include "lock0lock.h" -#ifdef HAVE_LZO #include "lzo/lzo1x.h" -#endif -#ifdef HAVE_SNAPPY #include "snappy-c.h" -#endif #include <vector> @@ -3495,13 +3491,14 @@ static dberr_t fil_iterate( const ulint size = callback.physical_size(); ulint n_bytes = iter.n_io_buffers * size; - const ulint buf_size = srv_page_size -#ifdef HAVE_LZO - + LZO1X_1_15_MEM_COMPRESS -#elif defined HAVE_SNAPPY - + snappy_max_compressed_length(srv_page_size) -#endif - ; + const ulint buf_size = srv_page_size + + ((provider_service_lzo->is_loaded)? + LZO1X_1_15_MEM_COMPRESS + :(provider_service_snappy->is_loaded)? + snappy_max_compressed_length(srv_page_size) + :0) + ; + byte* page_compress_buf = static_cast<byte*>(malloc(buf_size)); ut_ad(!srv_read_only_mode); diff --git a/storage/innobase/snappy.cmake b/storage/innobase/snappy.cmake deleted file mode 100644 index 3a2d828ee5c..00000000000 --- a/storage/innobase/snappy.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2015, MariaDB Corporation. All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA - -SET(WITH_INNODB_SNAPPY AUTO CACHE STRING - "Build with snappy. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'") - -MACRO (MYSQL_CHECK_SNAPPY) - IF (WITH_INNODB_SNAPPY STREQUAL "ON" OR WITH_INNODB_SNAPPY STREQUAL "AUTO") - CHECK_INCLUDE_FILES(snappy-c.h HAVE_SNAPPY_H) - CHECK_LIBRARY_EXISTS(snappy snappy_uncompress "" HAVE_SNAPPY_SHARED_LIB) - - IF(HAVE_SNAPPY_SHARED_LIB AND HAVE_SNAPPY_H) - SET(HAVE_INNODB_SNAPPY TRUE) - ADD_DEFINITIONS(-DHAVE_SNAPPY=1) - LINK_LIBRARIES(snappy) - ELSE() - IF (WITH_INNODB_SNAPPY STREQUAL "ON") - MESSAGE(FATAL_ERROR "Required snappy library is not found") - ENDIF() - ENDIF() - ENDIF() - ADD_FEATURE_INFO(INNODB_SNAPPY HAVE_INNODB_SNAPPY "Snappy compression in the InnoDB storage engine") -ENDMACRO() diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 8827605f04f..cb5709f8863 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -2052,6 +2052,10 @@ void innodb_shutdown() } srv_tmp_space.shutdown(); + if (srv_stats.pages_page_compression_error) + ib::warn() << "Page compression errors: " + << srv_stats.pages_page_compression_error; + if (srv_was_started && srv_print_verbose_log) { ib::info() << "Shutdown completed; log sequence number " << srv_shutdown_lsn diff --git a/storage/mroonga/CMakeLists.txt b/storage/mroonga/CMakeLists.txt index c048b214658..bea0eecc8b7 100644 --- a/storage/mroonga/CMakeLists.txt +++ b/storage/mroonga/CMakeLists.txt @@ -110,19 +110,9 @@ if(MRN_GROONGA_BUNDLED) set(GROONGA_NORMALIZER_MYSQL_EMBED ON) endif() - file(READ "${MRN_BUNDLED_GROONGA_DIR}/bundled_lz4_version" - MRN_BUNDLED_LZ4_VERSION) - string(STRIP - "${MRN_BUNDLED_LZ4_VERSION}" - MRN_BUNDLED_LZ4_VERSION) - set(MRN_BUNDLED_LZ4_DIR - "${MRN_BUNDLED_GROONGA_DIR}/vendor/lz4-${MRN_BUNDLED_LZ4_VERSION}") - if(EXISTS ${MRN_BUNDLED_LZ4_DIR}) - set(GRN_WITH_BUNDLED_LZ4 ON) - set(GRN_WITH_LZ4 "yes") - else() - set(GRN_WITH_LZ4 "no") - endif() + set(GRN_WITH_LZ4 "yes") + set(LIBLZ4_FOUND TRUE) + set(LZ4_LIBS "" CACHE STRING "" FORCE) add_subdirectory("${MRN_BUNDLED_GROONGA_RELATIVE_DIR}") else() diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 9fd9a5d7808..0b481364d1a 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -134,8 +134,12 @@ else() SET(ATOMIC_EXTRA_LIBS) endif() +# don't use compression providers, there are standalone executables below +GET_PROPERTY(dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES) +LIST(REMOVE_ITEM dirs ${CMAKE_SOURCE_DIR}/include/providers) +SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${dirs}") + MYSQL_ADD_PLUGIN(rocksdb ${ROCKSDB_SE_SOURCES} MODULE_ONLY STORAGE_ENGINE - MODULE_OUTPUT_NAME ha_rocksdb LINK_LIBRARIES ${ATOMIC_EXTRA_LIBS} COMPONENT rocksdb-engine) @@ -144,8 +148,6 @@ IF(NOT TARGET rocksdb) RETURN() ENDIF() - - CHECK_CXX_SOURCE_COMPILES(" #if defined(_MSC_VER) && !defined(__thread) #define __thread __declspec(thread) |