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

MYSQL_OPT_ZSTD_COMPRESSION_LEVEL fixes:

Follow up for commit e633858c9e:
- Fixed ASAN bug (int to char conversion)
- Allow to retrieve zstd compression level via mysql_get_optionv()
This commit is contained in:
Georg Richter
2024-12-10 05:18:08 +01:00
parent e633858c9e
commit 16e5b88bab
3 changed files with 21 additions and 2 deletions

View File

@@ -87,7 +87,7 @@ struct st_mysql_options_extension {
void (*status_callback)(void *ptr, enum enum_mariadb_status_info type, ...); void (*status_callback)(void *ptr, enum enum_mariadb_status_info type, ...);
void *status_data; void *status_data;
my_bool tls_verify_server_cert; my_bool tls_verify_server_cert;
char zstd_compression_level; unsigned char zstd_compression_level;
}; };
typedef struct st_connection_handler typedef struct st_connection_handler

View File

@@ -3844,7 +3844,7 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
} }
break; break;
case MYSQL_OPT_ZSTD_COMPRESSION_LEVEL: case MYSQL_OPT_ZSTD_COMPRESSION_LEVEL:
OPT_SET_EXTENDED_VALUE_INT(&mysql->options, zstd_compression_level, *((unsigned int *)arg1)); OPT_SET_EXTENDED_VALUE(&mysql->options, zstd_compression_level, *((unsigned char *)arg1));
break; break;
default: default:
va_end(ap); va_end(ap);
@@ -3872,6 +3872,9 @@ mysql_get_optionv(MYSQL *mysql, enum mysql_option option, void *arg, ...)
case MYSQL_OPT_COMPRESS: case MYSQL_OPT_COMPRESS:
*((my_bool *)arg)= mysql->options.compress; *((my_bool *)arg)= mysql->options.compress;
break; break;
case MYSQL_OPT_ZSTD_COMPRESSION_LEVEL:
*((unsigned char *)arg)= mysql->options.extension->zstd_compression_level;
break;
case MYSQL_OPT_NAMED_PIPE: case MYSQL_OPT_NAMED_PIPE:
*((my_bool *)arg)= mysql->options.named_pipe; *((my_bool *)arg)= mysql->options.named_pipe;
break; break;

View File

@@ -1663,7 +1663,23 @@ static int test_ext_field_attr(MYSQL *mysql)
return OK; return OK;
} }
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[] = { struct my_tests_st my_tests[] = {
{"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_ext_field_attr", test_ext_field_attr, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc533", test_conc533, TEST_CONNECTION_NEW, 0, NULL, NULL}, {"test_conc533", test_conc533, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc163", test_conc163, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc163", test_conc163, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},