You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Fix for CONC-70: Unknown error when reading large packets via conpressed protocol
This commit is contained in:
@@ -30,11 +30,21 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "my_test.h"
|
||||
#include "ma_common.h"
|
||||
|
||||
static int test_conc68(MYSQL *mysql)
|
||||
static int test_conc70(MYSQL *my)
|
||||
{
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
|
||||
mysql_query(my, "SET @a:=@@max_allowed_packet");
|
||||
check_mysql_rc(rc, my);
|
||||
|
||||
mysql_query(my, "SET global max_allowed_packet=1024*1024*22");
|
||||
|
||||
mysql_options(mysql, MYSQL_OPT_COMPRESS, (void *)1);
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -43,7 +53,7 @@ static int test_conc68(MYSQL *mysql)
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (REPEAT('A', 1024 * 1024 * 20))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "SELECT a FROM t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -55,47 +65,65 @@ static int test_conc68(MYSQL *mysql)
|
||||
}
|
||||
|
||||
row= mysql_fetch_row(res);
|
||||
diag("Length: %ld", strlen(row[0]));
|
||||
FAIL_IF(strlen(row[0]) != 1024 * 1024 * 20, "Wrong length");
|
||||
|
||||
mysql_free_result(res);
|
||||
mysql_close(mysql);
|
||||
|
||||
rc= mysql_query(my, "SET global max_allowed_packet=@a");
|
||||
check_mysql_rc(rc, my);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int test_conc66(MYSQL *my)
|
||||
static int test_conc68(MYSQL *my)
|
||||
{
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
int rc;
|
||||
FILE *fp;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
|
||||
fp= fopen("./my.cnf", "w");
|
||||
fprintf(fp, "[conc-66]\nuser=conc-66\npassword=\"my#pass;word\"");
|
||||
fclose(fp);
|
||||
mysql_query(my, "SET @a:=@@max_allowed_packet");
|
||||
check_mysql_rc(rc, my);
|
||||
|
||||
rc= mysql_query(my, "GRANT ALL ON test.* to 'conc-66'@'%' identified by 'my#pass;word'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(my, "FLUSH PRIVILEGES");
|
||||
mysql_query(my, "SET global max_allowed_packet=1024*1024*22");
|
||||
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "conc-66");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "./my.cnf");
|
||||
rc= mysql_query(mysql, "CREATE TABLE t1 (a LONGBLOB)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_real_connect(mysql, hostname, NULL, NULL, schema,
|
||||
port, socketname, 0);
|
||||
if (!rc) {
|
||||
diag("Error: %s\n", mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (REPEAT('A', 1024 * 1024 * 20))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "SELECT a FROM t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
if (!(res= mysql_store_result(mysql)))
|
||||
{
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
row= mysql_fetch_row(res);
|
||||
diag("Length: %ld", strlen(row[0]));
|
||||
FAIL_IF(strlen(row[0]) != 1024 * 1024 * 20, "Wrong length");
|
||||
|
||||
mysql_free_result(res);
|
||||
mysql_close(mysql);
|
||||
|
||||
rc= mysql_query(my, "DROP USER 'conc-66'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(my, "SET global max_allowed_packet=@a");
|
||||
check_mysql_rc(rc, my);
|
||||
|
||||
return OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
static int basic_connect(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
@@ -572,7 +600,6 @@ static int test_reconnect_maxpackage(MYSQL *my)
|
||||
memset(query + 8, 'A', max_packet);
|
||||
strcat(query, "' FROM DUAL");
|
||||
|
||||
|
||||
rc= mysql_query(mysql, query);
|
||||
free(query);
|
||||
if (!rc)
|
||||
@@ -621,8 +648,8 @@ static int test_compressed(MYSQL *my)
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"test_conc70", test_conc70, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc68", test_conc68, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc66", test_conc66, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_compressed", test_compressed, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_reconnect_maxpackage", test_reconnect_maxpackage, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"basic_connect", basic_connect, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
|
Reference in New Issue
Block a user