Skip to content

Commit bf8b699

Browse files
KartikSonejivuvova
authored andcommitted
MDEV-12933 sort out the compression library chaos
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.
1 parent c356714 commit bf8b699

File tree

94 files changed

+1954
-451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1954
-451
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ ADD_DEFINITIONS(-DHAVE_CONFIG_H)
375375
IF(_FILE_OFFSET_BITS)
376376
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
377377
ENDIF()
378-
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)
378+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include
379+
${CMAKE_SOURCE_DIR}/include/providers)
379380

380381
# Add bundled or system zlib.
381382
MYSQL_CHECK_ZLIB_WITH_COMPRESS()

cmake/build_configurations/mysql_release.cmake

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,10 @@ ELSEIF(RPM)
108108
# not yet, SLES 12.3 doesn't provide pcre2
109109
#SET(WITH_PCRE system CACHE STRING "")
110110
IF(RPM MATCHES "fedora|centos|rhel")
111-
SET(WITH_INNODB_BZIP2 OFF CACHE STRING "")
112-
SET(WITH_INNODB_LZO OFF CACHE STRING "")
113111
SET(WITH_ROCKSDB_BZip2 OFF CACHE STRING "")
114112
ENDIF()
115113
IF(RPM MATCHES "opensuse|sles|centos|rhel")
116-
SET(WITH_INNODB_LZ4 OFF CACHE STRING "")
117114
SET(WITH_ROCKSDB_LZ4 OFF CACHE STRING "")
118-
SET(GRN_WITH_LZ4 no CACHE STRING "")
119115
ENDIF()
120116
ELSEIF(DEB)
121117
SET(WITH_SSL system CACHE STRING "")
@@ -125,9 +121,6 @@ ELSEIF(DEB)
125121
SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "")
126122
SET(WITH_EMBEDDED_SERVER ON CACHE BOOL "")
127123
SET(WITH_PCRE system CACHE STRING "")
128-
SET(WITH_INNODB_BZIP2 OFF CACHE STRING "")
129-
SET(WITH_INNODB_LZMA OFF CACHE STRING "")
130-
SET(WITH_INNODB_LZO OFF CACHE STRING "")
131124
SET(WITH_ROCKSDB_BZip2 OFF CACHE STRING "")
132125
ELSE()
133126
SET(WITH_SSL bundled CACHE STRING "")
@@ -137,12 +130,8 @@ ELSE()
137130
SET(PLUGIN_AUTH_SOCKET STATIC CACHE STRING "")
138131
SET(WITH_STRIPPED_CLIENT ON CACHE BOOL "Strip all client binaries")
139132
SET(WITH_PCRE bundled CACHE STRING "")
140-
SET(WITH_INNODB_BZIP2 OFF CACHE STRING "")
141-
SET(WITH_INNODB_LZ4 OFF CACHE STRING "")
142-
SET(WITH_INNODB_LZO OFF CACHE STRING "")
143133
SET(WITH_ROCKSDB_BZip2 OFF CACHE STRING "")
144134
SET(WITH_ROCKSDB_LZ4 OFF CACHE STRING "")
145-
SET(GRN_WITH_LZ4 no CACHE STRING "")
146135
ENDIF()
147136

148137
IF(NOT COMPILATION_COMMENT)

debian/control

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Build-Depends: bison,
1818
libboost-regex-dev [amd64],
1919
libboost-system-dev [amd64],
2020
libboost-thread-dev [amd64],
21+
libbz2-dev,
2122
libcrack2-dev (>= 2.9.0),
2223
libcurl4-openssl-dev | libcurl4-dev,
2324
libedit-dev,
@@ -26,6 +27,8 @@ Build-Depends: bison,
2627
libjudy-dev,
2728
libkrb5-dev,
2829
liblz4-dev,
30+
liblzma-dev,
31+
liblzo2-dev,
2932
libncurses5-dev (>= 5.0-6~),
3033
libncurses5-dev:native (>= 5.0-6~),
3134
libnuma-dev [linux-any],
@@ -935,6 +938,41 @@ Description: CrackLib Password Validation Plugin for MariaDB
935938
.
936939
Install and configure this to enforce stronger passwords for MariaDB users.
937940

941+
Package: mariadb-plugin-provider-bzip2
942+
Architecture: any
943+
Depends: mariadb-server-10.7,
944+
${misc:Depends},
945+
${shlibs:Depends}
946+
Description: BZip2 compression support in the server and storage engines
947+
948+
Package: mariadb-plugin-provider-lz4
949+
Architecture: any
950+
Depends: mariadb-server-10.7,
951+
${misc:Depends},
952+
${shlibs:Depends}
953+
Description: LZ4 compression support in the server and storage engines
954+
955+
Package: mariadb-plugin-provider-lzma
956+
Architecture: any
957+
Depends: mariadb-server-10.7,
958+
${misc:Depends},
959+
${shlibs:Depends}
960+
Description: LZMA compression support in the server and storage engines
961+
962+
Package: mariadb-plugin-provider-lzo
963+
Architecture: any
964+
Depends: mariadb-server-10.7,
965+
${misc:Depends},
966+
${shlibs:Depends}
967+
Description: LZO compression support in the server and storage engines
968+
969+
Package: mariadb-plugin-provider-snappy
970+
Architecture: any
971+
Depends: mariadb-server-10.7,
972+
${misc:Depends},
973+
${shlibs:Depends}
974+
Description: Snappy compression support in the server and storage engines
975+
938976
Package: mariadb-test
939977
Architecture: any
940978
Depends: mariadb-client-10.7 (= ${binary:Version}),
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
etc/mysql/mariadb.conf.d/provider_bzip2.cnf
2+
usr/lib/mysql/plugin/provider_bzip2.so
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
etc/mysql/mariadb.conf.d/provider_lz4.cnf
2+
usr/lib/mysql/plugin/provider_lz4.so
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
etc/mysql/mariadb.conf.d/provider_lzma.cnf
2+
usr/lib/mysql/plugin/provider_lzma.so
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
etc/mysql/mariadb.conf.d/provider_lzo.cnf
2+
usr/lib/mysql/plugin/provider_lzo.so
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
etc/mysql/mariadb.conf.d/provider_snappy.cnf
2+
usr/lib/mysql/plugin/provider_snappy.so

extra/mariabackup/xtrabackup.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3309,7 +3309,8 @@ static void xb_load_single_table_tablespace(const char *dirname,
33093309
0, false, false);
33103310
node->deferred= defer;
33113311
mysql_mutex_lock(&fil_system.mutex);
3312-
space->read_page0();
3312+
if (!space->read_page0())
3313+
err= DB_CANNOT_OPEN_FILE;
33133314
mysql_mutex_unlock(&fil_system.mutex);
33143315

33153316
if (srv_operation == SRV_OPERATION_RESTORE_DELTA

include/providers/bzlib.h

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/**
2+
@file bzlib.h
3+
This service provides dynamic access to BZip2.
4+
*/
5+
6+
#ifndef BZIP2_INCLUDED
7+
#ifdef __cplusplus
8+
extern "C" {
9+
#endif
10+
11+
#ifndef MYSQL_ABI_CHECK
12+
#include <stdbool.h>
13+
#endif
14+
15+
#ifndef BZ_RUN
16+
#define BZ_RUN 0
17+
#define BZ_FINISH 2
18+
19+
#define BZ_OK 0
20+
#define BZ_RUN_OK 1
21+
#define BZ_FINISH_OK 3
22+
#define BZ_STREAM_END 4
23+
24+
typedef struct
25+
{
26+
char *next_in;
27+
unsigned int avail_in;
28+
unsigned int total_in_lo32;
29+
unsigned int total_in_hi32;
30+
31+
char *next_out;
32+
unsigned int avail_out;
33+
unsigned int total_out_lo32;
34+
unsigned int total_out_hi32;
35+
36+
void *state;
37+
38+
void *(*bzalloc)(void *, int, int);
39+
void (*bzfree)(void *, void *);
40+
void *opaque;
41+
} bz_stream;
42+
43+
#define BZ2_bzBuffToBuffCompress(...) provider_service_bzip2->BZ2_bzBuffToBuffCompress_ptr (__VA_ARGS__)
44+
#define BZ2_bzBuffToBuffDecompress(...) provider_service_bzip2->BZ2_bzBuffToBuffDecompress_ptr (__VA_ARGS__)
45+
#define BZ2_bzCompress(...) provider_service_bzip2->BZ2_bzCompress_ptr (__VA_ARGS__)
46+
#define BZ2_bzCompressEnd(...) provider_service_bzip2->BZ2_bzCompressEnd_ptr (__VA_ARGS__)
47+
#define BZ2_bzCompressInit(...) provider_service_bzip2->BZ2_bzCompressInit_ptr (__VA_ARGS__)
48+
#define BZ2_bzDecompress(...) provider_service_bzip2->BZ2_bzDecompress_ptr (__VA_ARGS__)
49+
#define BZ2_bzDecompressEnd(...) provider_service_bzip2->BZ2_bzDecompressEnd_ptr (__VA_ARGS__)
50+
#define BZ2_bzDecompressInit(...) provider_service_bzip2->BZ2_bzDecompressInit_ptr (__VA_ARGS__)
51+
#endif
52+
53+
#define DEFINE_BZ2_bzBuffToBuffCompress(NAME) NAME( \
54+
char *dest, \
55+
unsigned int *destLen, \
56+
char *source, \
57+
unsigned int sourceLen, \
58+
int blockSize100k, \
59+
int verbosity, \
60+
int workFactor \
61+
)
62+
63+
#define DEFINE_BZ2_bzBuffToBuffDecompress(NAME) NAME( \
64+
char *dest, \
65+
unsigned int *destLen, \
66+
char *source, \
67+
unsigned int sourceLen, \
68+
int small, \
69+
int verbosity \
70+
)
71+
72+
#define DEFINE_BZ2_bzCompress(NAME) NAME( \
73+
bz_stream *strm, \
74+
int action \
75+
)
76+
77+
#define DEFINE_BZ2_bzCompressEnd(NAME) NAME( \
78+
bz_stream *strm \
79+
)
80+
81+
#define DEFINE_BZ2_bzCompressInit(NAME) NAME( \
82+
bz_stream *strm, \
83+
int blockSize100k, \
84+
int verbosity, \
85+
int workFactor \
86+
)
87+
88+
#define DEFINE_BZ2_bzDecompress(NAME) NAME( \
89+
bz_stream *strm \
90+
)
91+
92+
#define DEFINE_BZ2_bzDecompressEnd(NAME) NAME( \
93+
bz_stream *strm \
94+
)
95+
96+
#define DEFINE_BZ2_bzDecompressInit(NAME) NAME( \
97+
bz_stream *strm, \
98+
int verbosity, \
99+
int small \
100+
)
101+
102+
struct provider_service_bzip2_st{
103+
int DEFINE_BZ2_bzBuffToBuffCompress((*BZ2_bzBuffToBuffCompress_ptr));
104+
int DEFINE_BZ2_bzBuffToBuffDecompress((*BZ2_bzBuffToBuffDecompress_ptr));
105+
int DEFINE_BZ2_bzCompress((*BZ2_bzCompress_ptr));
106+
int DEFINE_BZ2_bzCompressEnd((*BZ2_bzCompressEnd_ptr));
107+
int DEFINE_BZ2_bzCompressInit((*BZ2_bzCompressInit_ptr));
108+
int DEFINE_BZ2_bzDecompress((*BZ2_bzDecompress_ptr));
109+
int DEFINE_BZ2_bzDecompressEnd((*BZ2_bzDecompressEnd_ptr));
110+
int DEFINE_BZ2_bzDecompressInit((*BZ2_bzDecompressInit_ptr));
111+
112+
bool is_loaded;
113+
};
114+
115+
extern struct provider_service_bzip2_st *provider_service_bzip2;
116+
117+
#ifdef __cplusplus
118+
}
119+
#endif
120+
121+
#define BZIP2_INCLUDED
122+
#endif

0 commit comments

Comments
 (0)