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-68: SELECT fails with "Got packet bigger than 'max_allowed_packet'" on a table with longblob column with fields greater than 15MB
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
See bug conc-57
|
See bug conc-57
|
||||||
*/
|
*/
|
||||||
#undef net_buffer_length
|
#undef net_buffer_length
|
||||||
|
|
||||||
#undef max_allowed_packet
|
#undef max_allowed_packet
|
||||||
ulong max_allowed_packet=1024L * 1024L * 1024L;
|
ulong max_allowed_packet=1024L * 1024L * 1024L;
|
||||||
ulong net_read_timeout= NET_READ_TIMEOUT;
|
ulong net_read_timeout= NET_READ_TIMEOUT;
|
||||||
@@ -113,9 +114,9 @@ int my_net_init(NET *net, Vio* vio)
|
|||||||
{
|
{
|
||||||
if (!(net->buff=(uchar*) my_malloc(net_buffer_length,MYF(MY_WME | MY_ZEROFILL))))
|
if (!(net->buff=(uchar*) my_malloc(net_buffer_length,MYF(MY_WME | MY_ZEROFILL))))
|
||||||
return 1;
|
return 1;
|
||||||
if (net_buffer_length > max_allowed_packet)
|
// if (net_buffer_length > max_allowed_packet)
|
||||||
max_allowed_packet=net_buffer_length;
|
// max_allowed_packet=net_buffer_length;
|
||||||
net->max_packet_size= 0xFFFFFF;
|
max_allowed_packet= net->max_packet_size= MAX(net_buffer_length, max_allowed_packet);
|
||||||
net->buff_end=net->buff+(net->max_packet=net_buffer_length);
|
net->buff_end=net->buff+(net->max_packet=net_buffer_length);
|
||||||
net->vio = vio;
|
net->vio = vio;
|
||||||
net->error=0; net->return_status=0;
|
net->error=0; net->return_status=0;
|
||||||
@@ -654,8 +655,7 @@ my_real_read(NET *net, size_t *complen)
|
|||||||
/* The necessary size of net->buff */
|
/* The necessary size of net->buff */
|
||||||
if (helping >= net->max_packet)
|
if (helping >= net->max_packet)
|
||||||
{
|
{
|
||||||
/* We must allocate one extra byte for the end null */
|
if (net_realloc(net,helping))
|
||||||
if (net_realloc(net,helping + 1))
|
|
||||||
{
|
{
|
||||||
#ifdef MYSQL_SERVER
|
#ifdef MYSQL_SERVER
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
@@ -699,6 +699,7 @@ ulong my_net_read(NET *net)
|
|||||||
{
|
{
|
||||||
length+= len;
|
length+= len;
|
||||||
net->where_b+= (unsigned long)len;
|
net->where_b+= (unsigned long)len;
|
||||||
|
len= my_real_read(net, &complen);
|
||||||
} while (len == MAX_PACKET_LENGTH);
|
} while (len == MAX_PACKET_LENGTH);
|
||||||
net->where_b= last_pos;
|
net->where_b= last_pos;
|
||||||
if (len != packet_error)
|
if (len != packet_error)
|
||||||
|
@@ -30,6 +30,72 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "my_test.h"
|
#include "my_test.h"
|
||||||
#include "ma_common.h"
|
#include "ma_common.h"
|
||||||
|
|
||||||
|
static int test_conc68(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
MYSQL_RES *res;
|
||||||
|
MYSQL_ROW row;
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "CREATE TABLE t1 (a LONGBLOB)");
|
||||||
|
check_mysql_rc(rc, 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);
|
||||||
|
FAIL_IF(strlen(row[0]) != 1024 * 1024 * 20, "Wrong length");
|
||||||
|
mysql_free_result(res);
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int test_conc66(MYSQL *my)
|
||||||
|
{
|
||||||
|
MYSQL *mysql= mysql_init(NULL);
|
||||||
|
int rc;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
fp= fopen("./my.cnf", "w");
|
||||||
|
fprintf(fp, "[conc-66]\nuser=conc-66\npassword=\"my#pass;word\"");
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
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");
|
||||||
|
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");
|
||||||
|
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);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
mysql_close(mysql);
|
||||||
|
|
||||||
|
rc= mysql_query(my, "DROP USER 'conc-66'");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
static int basic_connect(MYSQL *mysql)
|
static int basic_connect(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
@@ -555,6 +621,8 @@ static int test_compressed(MYSQL *my)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
{"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_compressed", test_compressed, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
{"test_reconnect_maxpackage", test_reconnect_maxpackage, 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},
|
{"basic_connect", basic_connect, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
|
Reference in New Issue
Block a user