|
30 | 30 |
|
31 | 31 | #include "caching_sha2_passwordopt-vars.h"
|
32 | 32 | #include "client/client_priv.h"
|
| 33 | +#include "compression.h" |
33 | 34 | #include "m_ctype.h"
|
34 | 35 | #include "my_alloc.h"
|
35 | 36 | #include "my_dbug.h"
|
@@ -69,6 +70,8 @@ static const char *default_charset = nullptr;
|
69 | 70 | static char *opt_plugin_dir = 0, *opt_default_auth = 0;
|
70 | 71 | static int first_error = 0;
|
71 | 72 | static const char *opt_skip_database = "";
|
| 73 | +static uint opt_zstd_compress_level = default_zstd_compression_level; |
| 74 | +static char *opt_compress_algorithm = nullptr; |
72 | 75 | #if defined(_WIN32)
|
73 | 76 | static char *shared_memory_base_name = 0;
|
74 | 77 | #endif
|
@@ -226,6 +229,17 @@ static struct my_option my_long_options[] = {
|
226 | 229 | GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
227 | 230 | {"version", 'V', "Output version information and exit.", 0, 0, 0,
|
228 | 231 | GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
| 232 | + {"compression-algorithms", 0, |
| 233 | + "Use compression algorithm in server/client protocol. Valid values " |
| 234 | + "are any combination of 'zstd','zlib','uncompressed'.", |
| 235 | + &opt_compress_algorithm, &opt_compress_algorithm, 0, GET_STR, REQUIRED_ARG, |
| 236 | + 0, 0, 0, 0, 0, 0}, |
| 237 | + {"zstd-compression-level", 0, |
| 238 | + "Use this compression level in the client/server protocol, in case " |
| 239 | + "--compression-algorithms=zstd. Valid range is between 1 and 22, " |
| 240 | + "inclusive. Default is 3.", |
| 241 | + &opt_zstd_compress_level, &opt_zstd_compress_level, 0, GET_UINT, |
| 242 | + REQUIRED_ARG, 3, 1, 22, 0, 0, 0}, |
229 | 243 | {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}};
|
230 | 244 |
|
231 | 245 | static const char *load_default_groups[] = {"mysqlcheck", "client", 0};
|
@@ -431,6 +445,13 @@ static int dbConnect(char *host, char *user, char *passwd) {
|
431 | 445 | }
|
432 | 446 | mysql_init(&mysql_connection);
|
433 | 447 | if (opt_compress) mysql_options(&mysql_connection, MYSQL_OPT_COMPRESS, NullS);
|
| 448 | + if (opt_compress_algorithm) |
| 449 | + mysql_options(&mysql_connection, MYSQL_OPT_COMPRESSION_ALGORITHMS, |
| 450 | + opt_compress_algorithm); |
| 451 | + |
| 452 | + mysql_options(&mysql_connection, MYSQL_OPT_ZSTD_COMPRESSION_LEVEL, |
| 453 | + &opt_zstd_compress_level); |
| 454 | + |
434 | 455 | if (SSL_SET_OPTIONS(&mysql_connection)) {
|
435 | 456 | fprintf(stderr, "%s", SSL_SET_OPTIONS_ERROR);
|
436 | 457 | return 1;
|
|
0 commit comments