Merge branch '2.2' into develop
This commit is contained in:
@ -681,6 +681,14 @@ add_test_executable(mxs1786_statistics.cpp mxs1786_statistics replication LABELS
|
||||
# https://jira.mariadb.org/browse/MXS-1787
|
||||
add_test_executable(mxs1787_call_ps.cpp mxs1787_call_ps replication LABELS readwritesplit REPL_BACKEND)
|
||||
|
||||
# MXS-1804: request 16M-1 stmt_prepare command packet connect hang
|
||||
# https://jira.mariadb.org/browse/MXS-1804
|
||||
add_test_executable(mxs1804_long_ps_hang.cpp mxs1804_long_ps_hang replication LABELS readwritesplit REPL_BACKEND)
|
||||
|
||||
# MXS-1808: Crash with mysql_stmt_send_long_data
|
||||
# https://jira.mariadb.org/browse/MXS-1808
|
||||
add_test_executable(mxs1808_long_data.cpp mxs1808_long_data replication LABELS readwritesplit REPL_BACKEND)
|
||||
|
||||
# 'namedserverfilter' test
|
||||
add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND)
|
||||
|
||||
|
41
maxscale-system-test/mxs1804_long_ps_hang.cpp
Normal file
41
maxscale-system-test/mxs1804_long_ps_hang.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* MXS-1804: request 16M-1 stmt_prepare command packet connect hang
|
||||
*
|
||||
* https://jira.mariadb.org/browse/MXS-1804
|
||||
*/
|
||||
|
||||
#include "testconnections.h"
|
||||
|
||||
int sql_str_size(int sqlsize)
|
||||
{
|
||||
char prefx[] = "select ''";
|
||||
return sqlsize - strlen(prefx) - 1;
|
||||
}
|
||||
|
||||
void gen_select_sqlstr(char *sqlstr, unsigned int strsize, int sqlsize)
|
||||
{
|
||||
strcpy(sqlstr, "select '");
|
||||
memset(sqlstr + strlen("select '"), 'f', strsize);
|
||||
sqlstr[sqlsize - 2] = '\'';
|
||||
sqlstr[sqlsize - 1] = '\0';
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
int sqlsize = 16777215;
|
||||
int strsize = sql_str_size(sqlsize);
|
||||
|
||||
char* sqlstr = (char *)malloc(sqlsize);
|
||||
gen_select_sqlstr(sqlstr, strsize, sqlsize);
|
||||
|
||||
test.set_timeout(30);
|
||||
test.maxscales->connect();
|
||||
|
||||
MYSQL_STMT* stmt = mysql_stmt_init(test.maxscales->conn_rwsplit[0]);
|
||||
test.assert(mysql_stmt_prepare(stmt, sqlstr, strlen(sqlstr)) != 0, "Prepare should fail in 2.2 but not hang",
|
||||
mysql_stmt_error(stmt));
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
return test.global_result;
|
||||
}
|
86
maxscale-system-test/mxs1808_long_data.cpp
Normal file
86
maxscale-system-test/mxs1808_long_data.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
#include "testconnections.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void print_stmt_error(MYSQL_STMT *stmt, const char* msg)
|
||||
{
|
||||
cout << "Error: " << msg << ": " << mysql_stmt_error(stmt) << endl;
|
||||
}
|
||||
|
||||
static int test_long_data(MYSQL *conn, int sqlsize)
|
||||
{
|
||||
int data1size = sqlsize / 2;
|
||||
|
||||
char * data1 = (char*) malloc(data1size);
|
||||
memset(data1, 97, data1size);
|
||||
char * data3 = (char*) malloc(sqlsize);
|
||||
memset(data3, 99, sqlsize);
|
||||
|
||||
MYSQL_STMT *stmt;
|
||||
stmt = mysql_stmt_init(conn);
|
||||
int rc, int_data;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_BIND my_bind[1];
|
||||
|
||||
rc = mysql_autocommit(conn, 1);
|
||||
|
||||
if (NULL == stmt)
|
||||
{
|
||||
fprintf(stderr, "%s", mysql_error(conn));
|
||||
return 0;
|
||||
}
|
||||
if (mysql_stmt_prepare(stmt, "select ?", strlen("select ?")) != 0)
|
||||
{
|
||||
print_stmt_error(stmt, "stmt prepare fail");
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset((char*) my_bind, 0, sizeof(my_bind));
|
||||
|
||||
my_bind[0].buffer = (void *)&int_data;
|
||||
my_bind[0].buffer_type = MYSQL_TYPE_STRING;
|
||||
|
||||
if (mysql_stmt_bind_param(stmt, my_bind) != 0)
|
||||
{
|
||||
print_stmt_error(stmt, "bind param error");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* supply data in pieces */
|
||||
if (mysql_stmt_send_long_data(stmt, 0, data1, data1size) != 0)
|
||||
{
|
||||
print_stmt_error(stmt, "send long data1 failed");
|
||||
return 0;
|
||||
}
|
||||
if (mysql_stmt_send_long_data(stmt, 0, data3, sqlsize) != 0)
|
||||
{
|
||||
print_stmt_error(stmt, "send long data3 failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* execute */
|
||||
if (mysql_stmt_execute(stmt) != 0)
|
||||
{
|
||||
print_stmt_error(stmt, "execute prepare stmt failed");
|
||||
return 0;
|
||||
}
|
||||
/* get the result */
|
||||
result = mysql_store_result(conn);
|
||||
mysql_free_result(result);
|
||||
mysql_stmt_close(stmt);
|
||||
free(data1);
|
||||
free(data3);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
|
||||
test.maxscales->connect();
|
||||
test.assert(test_long_data(test.maxscales->conn_rwsplit[0], 123456), "Test should work");
|
||||
test.maxscales->disconnect();
|
||||
|
||||
return test.global_result;
|
||||
}
|
Reference in New Issue
Block a user