@@ -3003,6 +3003,14 @@ TEST_F(xapi, compression_algorithms)
3003
3003
{" ZSTD_STREAM" , " ZsTd" ," zStD_sTReaM" ," lz4" ," DEFLATE" },
3004
3004
};
3005
3005
3006
+ // Reading the value of mysqlx_compression_algorithms at the beginning
3007
+ mysqlx_result_t *res = exec_sql (" SHOW GLOBAL VARIABLES LIKE 'mysqlx_compression_algorithms';" );
3008
+ mysqlx_row_t *row=mysqlx_row_fetch_one (res);
3009
+ char buffer[50 ];
3010
+ size_t buflen = sizeof (buffer);
3011
+ mysqlx_get_bytes (row, 1 , 0 , buffer, &buflen);
3012
+ std::string var_value=buffer;
3013
+ mysqlx_result_free (res);
3006
3014
3007
3015
// By Default, it should use ZTSD compression
3008
3016
@@ -3344,6 +3352,31 @@ TEST_F(xapi, compression_algorithms)
3344
3352
EXPECT_EQ (nullptr , mysqlx_get_session_from_options (opt, &error));
3345
3353
mysqlx_free (opt);
3346
3354
3355
+ // In these cases, algorithm set on the server side is different from the algorithms in connection
3356
+ // and compression is REQUIRED, no session should be created
3357
+
3358
+ std::string qry = " Set global mysqlx_compression_algorithms=" + d.expected + " ;" ;
3359
+ exec_sql (qry.c_str ());
3360
+ tmp = std::string (d.second ) + " ," + d.third ;
3361
+
3362
+ opt = mysqlx_session_options_new ();
3363
+ EXPECT_EQ (RESULT_OK, mysqlx_session_option_set (opt,
3364
+ OPT_HOST (get_host ()),
3365
+ OPT_PORT (get_port ()),
3366
+ OPT_USER (get_user ()),
3367
+ OPT_PWD (get_password ()),
3368
+ OPT_COMPRESSION (MYSQLX_COMPRESSION_REQUIRED),
3369
+ OPT_COMPRESSION_ALGORITHMS (tmp.c_str ()),
3370
+ PARAM_END));
3371
+ EXPECT_EQ (nullptr , mysqlx_get_session_from_options (opt, & error));
3372
+ mysqlx_free (opt);
3373
+
3374
+ tmp = uri + " compression=required&compression-algorithms=[" + d.second + " ," + d.third + " ]" ;
3375
+ EXPECT_EQ (nullptr , mysqlx_get_session_from_url (tmp.c_str (), & error));
3376
+
3377
+ // Restoring to the original value of mysqlx_compression_algorithms
3378
+ qry =" Set global mysqlx_compression_algorithms='" +var_value+" ';" ;
3379
+ exec_sql (qry.c_str ());
3347
3380
3348
3381
std::cout << d.expected << " : " <<
3349
3382
std::chrono::duration_cast<std::chrono::milliseconds>(
0 commit comments