1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

Merge branch '3.3' into 3.4

This commit is contained in:
Georg Richter
2024-12-10 05:50:11 +01:00
5 changed files with 33 additions and 1 deletions

View File

@@ -89,6 +89,7 @@ struct st_mysql_options_extension {
void *status_data;
my_bool tls_allow_invalid_server_cert;
int (*tls_verification_callback)(MARIADB_TLS *ctls, unsigned int flags);
unsigned char zstd_compression_level;
};
typedef struct st_connection_handler

View File

@@ -224,6 +224,7 @@ extern const char *SQLSTATE_UNKNOWN;
MYSQL_OPT_MAX_ALLOWED_PACKET,
MYSQL_OPT_NET_BUFFER_LENGTH,
MYSQL_OPT_TLS_VERSION,
MYSQL_OPT_ZSTD_COMPRESSION_LEVEL,
/* MariaDB specific */
MYSQL_PROGRESS_CALLBACK=5999,

View File

@@ -711,6 +711,7 @@ struct st_default_options mariadb_defaults[] =
{{MYSQL_OPT_SSL_ENFORCE}, MARIADB_OPTION_BOOL, "tls-enforce"},
{{MYSQL_OPT_SSL_VERIFY_SERVER_CERT}, MARIADB_OPTION_BOOL,"tls-verify-peer"},
{{MARIADB_OPT_RESTRICTED_AUTH}, MARIADB_OPTION_STR, "restricted-auth"},
{{MYSQL_OPT_ZSTD_COMPRESSION_LEVEL}, MARIADB_OPTION_INT, "zstd-compression-level"},
{{0}, 0, NULL}
};
@@ -3872,6 +3873,9 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
OPT_SET_EXTENDED_VALUE(&mysql->options, tls_verification_callback, arg1);
}
break;
case MYSQL_OPT_ZSTD_COMPRESSION_LEVEL:
OPT_SET_EXTENDED_VALUE(&mysql->options, zstd_compression_level, *((unsigned char *)arg1));
break;
default:
va_end(ap);
SET_CLIENT_ERROR(mysql, CR_NOT_IMPLEMENTED, SQLSTATE_UNKNOWN, 0);
@@ -3898,6 +3902,9 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...)
case MYSQL_OPT_COMPRESS:
*((my_bool *)arg)= mysql->options.compress;
break;
case MYSQL_OPT_ZSTD_COMPRESSION_LEVEL:
*((unsigned char *)arg)= mysql->options.extension->zstd_compression_level;
break;
case MYSQL_OPT_NAMED_PIPE:
*((my_bool *)arg)= mysql->options.named_pipe;
break;

View File

@@ -508,7 +508,14 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
*/
if (mysql->client_flag & CLIENT_ZSTD_COMPRESSION)
{
*end++= 3;
uchar compression_level= 3;
if (mysql->options.extension &&
mysql->options.extension->zstd_compression_level >= 1 &&
mysql->options.extension->zstd_compression_level <= 20)
{
compression_level= mysql->options.extension->zstd_compression_level;
}
*end++= compression_level;
}
/* Write authentication package */

View File

@@ -1705,8 +1705,24 @@ static int test_null_handles(MYSQL *mysql __attribute__((unused)))
}
static int test_comp_level(MYSQL *my __attribute__((unused)))
{
unsigned char clevel= 5;
unsigned char clevel1= 0;
MYSQL *mysql= mysql_init(NULL);
mysql_optionsv(mysql, MYSQL_OPT_ZSTD_COMPRESSION_LEVEL, &clevel);
mysql_get_optionv(mysql, MYSQL_OPT_ZSTD_COMPRESSION_LEVEL, &clevel1);
FAIL_IF(clevel != clevel1, "Different compression levels");
mysql_close(mysql);
return OK;
}
struct my_tests_st my_tests[] = {
{"test_disable_tls1_0", test_disable_tls1_0, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_comp_level", test_comp_level, TEST_CONNECTION_NONE, 0, NULL, NULL},
{"test_ext_field_attr", test_ext_field_attr, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc533", test_conc533, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc163", test_conc163, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},