You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
Merge https://github.com/MariaDB/mariadb-connector-c into 10.2-georg
This commit is contained in:
@@ -21,11 +21,11 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/unittest/mytap)
|
||||
ADD_DEFINITIONS(-DLIBMARIADB)
|
||||
|
||||
SET(API_TESTS "t_aurora" "async" "basic-t" "fetch" "charset" "logs"
|
||||
"cursor" "errors" "view" "ps" "ps_bugs"
|
||||
"sp" "result" "connection" "misc" "ps_new" "sqlite3" "thread"
|
||||
"dyncol" "features-10_2")
|
||||
SET(API_TESTS "async" "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs"
|
||||
"sp" "result" "connection" "misc" "ps_new" "sqlite3" "thread" "dyncol" "features-10_2")
|
||||
|
||||
#exclude following tests from ctests, since we need to run them maually with different credentials
|
||||
SET(MANUAL_TESTS "t_aurora")
|
||||
# Get finger print from server certificate
|
||||
IF(WITH_SSL)
|
||||
|
||||
@@ -64,3 +64,8 @@ FOREACH(API_TEST ${API_TESTS})
|
||||
ADD_TEST(${API_TEST} ${EXECUTABLE_OUTPUT_PATH}/${API_TEST})
|
||||
SET_TESTS_PROPERTIES(${API_TEST} PROPERTIES TIMEOUT 120)
|
||||
ENDFOREACH(API_TEST)
|
||||
|
||||
FOREACH(API_TEST ${MANUAL_TESTS})
|
||||
ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c ${CMAKE_SOURCE_DIR}/libmariadb/getopt.c)
|
||||
TARGET_LINK_LIBRARIES(${API_TEST} mytap libmariadb)
|
||||
ENDFOREACH()
|
||||
|
@@ -35,11 +35,11 @@ static int test_conc75(MYSQL *my)
|
||||
int rc;
|
||||
MYSQL *mysql;
|
||||
int i;
|
||||
my_bool reconnect= 1;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
|
||||
mysql->reconnect= 1;
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS);
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS a");
|
||||
@@ -55,7 +55,7 @@ static int test_conc75(MYSQL *my)
|
||||
{
|
||||
ulong thread_id= mysql_thread_id(mysql);
|
||||
/* force reconnect */
|
||||
mysql->reconnect= 1;
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
diag("killing connection");
|
||||
mysql_kill(my, thread_id);
|
||||
sleep(2);
|
||||
@@ -700,6 +700,10 @@ static int test_reconnect_maxpackage(MYSQL *my)
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
char *query;
|
||||
my_bool reconnect= 1;
|
||||
|
||||
SKIP_CONNECTION_HANDLER;
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
SKIP_CONNECTION_HANDLER;
|
||||
mysql= mysql_init(NULL);
|
||||
@@ -707,7 +711,7 @@ static int test_reconnect_maxpackage(MYSQL *my)
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname,
|
||||
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS), mysql_error(mysql));
|
||||
mysql->reconnect= 1;
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
rc= mysql_query(mysql, "SELECT @@max_allowed_packet");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -753,12 +757,13 @@ static int test_compressed(MYSQL *my)
|
||||
int rc;
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
MYSQL_RES *res;
|
||||
my_bool reconnect= 1;
|
||||
|
||||
mysql_options(mysql, MYSQL_OPT_COMPRESS, (void *)1);
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname,
|
||||
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS), mysql_error(mysql));
|
||||
mysql->reconnect= 1;
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
rc= mysql_query(mysql, "SHOW VARIABLES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
@@ -455,16 +455,21 @@ static int test_opt_reconnect(MYSQL *mysql)
|
||||
{
|
||||
my_bool my_true= TRUE;
|
||||
int rc;
|
||||
my_bool reconnect;
|
||||
|
||||
printf("true: %d\n", TRUE);
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
FAIL_IF(!mysql, "not enough memory");
|
||||
|
||||
FAIL_UNLESS(mysql->reconnect == 0, "reconnect != 0");
|
||||
mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
FAIL_UNLESS(reconnect == 0, "reconnect != 0");
|
||||
|
||||
rc= mysql_options(mysql, MYSQL_OPT_RECONNECT, &my_true);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
FAIL_UNLESS(mysql->reconnect == 1, "reconnect != 1");
|
||||
mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
FAIL_UNLESS(reconnect == 1, "reconnect != 1");
|
||||
|
||||
if (!(mysql_real_connect(mysql, hostname, username,
|
||||
password, schema, port,
|
||||
@@ -475,14 +480,16 @@ static int test_opt_reconnect(MYSQL *mysql)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FAIL_UNLESS(mysql->reconnect == 1, "reconnect != 1");
|
||||
mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
FAIL_UNLESS(reconnect == 1, "reconnect != 1");
|
||||
|
||||
mysql_close(mysql);
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
FAIL_IF(!mysql, "not enough memory");
|
||||
|
||||
FAIL_UNLESS(mysql->reconnect == 0, "reconnect != 0");
|
||||
mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
FAIL_UNLESS(reconnect == 0, "reconnect != 0");
|
||||
|
||||
if (!(mysql_real_connect(mysql, hostname, username,
|
||||
password, schema, port,
|
||||
@@ -493,7 +500,8 @@ static int test_opt_reconnect(MYSQL *mysql)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FAIL_UNLESS(mysql->reconnect == 0, "reconnect != 0");
|
||||
mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
FAIL_UNLESS(reconnect == 0, "reconnect != 0");
|
||||
|
||||
mysql_close(mysql);
|
||||
return OK;
|
||||
@@ -538,16 +546,19 @@ static int test_reconnect(MYSQL *mysql)
|
||||
my_bool my_true= TRUE;
|
||||
MYSQL *mysql1;
|
||||
int rc;
|
||||
my_bool reconnect;
|
||||
|
||||
mysql1= mysql_init(NULL);
|
||||
FAIL_IF(!mysql1, "not enough memory");
|
||||
|
||||
FAIL_UNLESS(mysql1->reconnect == 0, "reconnect != 0");
|
||||
mysql_get_option(mysql1, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
FAIL_UNLESS(reconnect == 0, "reconnect != 0");
|
||||
|
||||
rc= mysql_options(mysql1, MYSQL_OPT_RECONNECT, &my_true);
|
||||
check_mysql_rc(rc, mysql1);
|
||||
|
||||
FAIL_UNLESS(mysql1->reconnect == 1, "reconnect != 1");
|
||||
mysql_get_option(mysql1, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
FAIL_UNLESS(reconnect == 1, "reconnect != 1");
|
||||
|
||||
if (!(mysql_real_connect(mysql1, hostname, username,
|
||||
password, schema, port,
|
||||
@@ -558,7 +569,8 @@ static int test_reconnect(MYSQL *mysql)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FAIL_UNLESS(mysql1->reconnect == 1, "reconnect != 1");
|
||||
mysql_get_option(mysql1, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
FAIL_UNLESS(reconnect == 1, "reconnect != 1");
|
||||
|
||||
diag("Thread_id before kill: %lu", mysql_thread_id(mysql1));
|
||||
mysql_kill(mysql, mysql_thread_id(mysql1));
|
||||
@@ -570,7 +582,8 @@ static int test_reconnect(MYSQL *mysql)
|
||||
check_mysql_rc(rc, mysql1);
|
||||
diag("Thread_id after kill: %lu", mysql_thread_id(mysql1));
|
||||
|
||||
FAIL_UNLESS(mysql1->reconnect == 1, "reconnect != 1");
|
||||
mysql_get_option(mysql1, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
FAIL_UNLESS(reconnect == 1, "reconnect != 1");
|
||||
mysql_close(mysql1);
|
||||
return OK;
|
||||
}
|
||||
@@ -647,8 +660,10 @@ int test_connection_timeout(MYSQL *my)
|
||||
static int test_conc118(MYSQL *mysql)
|
||||
{
|
||||
int rc;
|
||||
my_bool reconnect= 1;
|
||||
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
mysql->reconnect= 1;
|
||||
mysql->options.unused_1= 1;
|
||||
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
@@ -745,9 +760,10 @@ static int test_bind_address(MYSQL *my)
|
||||
static int test_get_options(MYSQL *my)
|
||||
{
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
int options_int[]= {MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_LOCAL_INFILE,
|
||||
MYSQL_OPT_RECONNECT, MYSQL_OPT_PROTOCOL, MYSQL_OPT_READ_TIMEOUT, MYSQL_OPT_WRITE_TIMEOUT, 0};
|
||||
my_bool options_bool[]= {MYSQL_OPT_COMPRESS, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_SECURE_AUTH,
|
||||
int options_int[]= {MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_LOCAL_INFILE,
|
||||
MYSQL_OPT_PROTOCOL, MYSQL_OPT_READ_TIMEOUT, MYSQL_OPT_WRITE_TIMEOUT, 0};
|
||||
my_bool options_bool[]= {MYSQL_OPT_RECONNECT, MYSQL_REPORT_DATA_TRUNCATION,
|
||||
MYSQL_OPT_COMPRESS, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_SECURE_AUTH,
|
||||
#ifdef _WIN32
|
||||
MYSQL_OPT_NAMED_PIPE,
|
||||
#endif
|
||||
@@ -755,7 +771,7 @@ static int test_get_options(MYSQL *my)
|
||||
int options_char[]= {MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP, MYSQL_SET_CHARSET_NAME,
|
||||
MYSQL_OPT_SSL_KEY, MYSQL_OPT_SSL_CA, MYSQL_OPT_SSL_CERT, MYSQL_OPT_SSL_CAPATH,
|
||||
MYSQL_OPT_SSL_CIPHER, MYSQL_OPT_BIND, MARIADB_OPT_SSL_FP, MARIADB_OPT_SSL_FP_LIST,
|
||||
MARIADB_OPT_SSL_PASSWORD, 0};
|
||||
MARIADB_OPT_SSL_PASSPHRASE, 0};
|
||||
|
||||
char *init_command[3]= {"SET @a:=1", "SET @b:=2", "SET @c:=3"};
|
||||
int elements= 0;
|
||||
|
@@ -957,6 +957,7 @@ static int test_conc_114(MYSQL *mysql)
|
||||
/* run with valgrind */
|
||||
static int test_conc117(MYSQL *mysql)
|
||||
{
|
||||
my_bool reconnect= 1;
|
||||
MYSQL *my= mysql_init(NULL);
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
@@ -964,7 +965,7 @@ static int test_conc117(MYSQL *mysql)
|
||||
mysql_kill(my, mysql_thread_id(my));
|
||||
sleep(5);
|
||||
|
||||
my->reconnect= 1;
|
||||
mysql_options(my, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
mysql_query(my, "SET @a:=1");
|
||||
mysql_close(my);
|
||||
@@ -982,6 +983,7 @@ static int test_remote1(MYSQL *mysql)
|
||||
if (!remote_plugin)
|
||||
{
|
||||
diag("skip - no remote io plugin available");
|
||||
diag("error: %s", mysql_error(mysql));
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
@@ -1043,7 +1045,7 @@ static int test_get_info(MYSQL *mysql)
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_SERVER_VERSION_ID, &sval);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("server_version_id: %d", sval);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CHARSET_INFO, &cs);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_CHARSET_INFO, &cs);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("charset name: %s", cs.csname);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_PVIO_TYPE, &ival);
|
||||
|
@@ -29,6 +29,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include <memory.h>
|
||||
#include <errmsg.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifndef OK
|
||||
# define OK 0
|
||||
#endif
|
||||
@@ -374,7 +378,6 @@ int check_variable(MYSQL *mysql, char *variable, char *value)
|
||||
*/
|
||||
MYSQL *test_connect(struct my_tests_st *test) {
|
||||
MYSQL *mysql;
|
||||
char query[255];
|
||||
int i= 0;
|
||||
int timeout= 10;
|
||||
int truncation_report= 1;
|
||||
@@ -401,32 +404,13 @@ MYSQL *test_connect(struct my_tests_st *test) {
|
||||
}
|
||||
}
|
||||
if (!(mysql_real_connect(mysql, hostname, username, password,
|
||||
NULL, port, socketname, (test) ? test->connect_flags:0)))
|
||||
schema, port, socketname, (test) ? test->connect_flags:0)))
|
||||
{
|
||||
diag("Couldn't establish connection to server %s. Error (%d): %s",
|
||||
hostname, mysql_errno(mysql), mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* change database or create if it doesn't exist */
|
||||
if (mysql_select_db(mysql, schema)) {
|
||||
diag("Error number: %d", mysql_errno(mysql));
|
||||
|
||||
if(mysql_errno(mysql) == 1049) {
|
||||
sprintf(query, "CREATE DATABASE %s", schema);
|
||||
if (mysql_query(mysql, query)) {
|
||||
diag("Can't create database %s", schema);
|
||||
mysql_close(mysql);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
diag("Error (%d): %s", mysql_errno(mysql), mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return(mysql);
|
||||
}
|
||||
|
||||
@@ -526,6 +510,7 @@ void run_tests(struct my_tests_st *test) {
|
||||
}
|
||||
}
|
||||
if (mysql_default) {
|
||||
diag("close default");
|
||||
mysql_close(mysql_default);
|
||||
}
|
||||
mysql_server_end();
|
||||
|
@@ -52,12 +52,13 @@ static int test_conc83(MYSQL *my)
|
||||
MYSQL_STMT *stmt;
|
||||
int rc;
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
my_bool reconnect= 1;
|
||||
|
||||
char *query= "SELECT 1,2,3 FROM DUAL";
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
|
||||
mysql->reconnect= 1;
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
FAIL_IF(!(mysql_real_connect(mysql, hostname, username, password,
|
||||
schema, port, socketname, 0)), "mysql_real_connect failed");
|
||||
|
||||
@@ -69,7 +70,7 @@ static int test_conc83(MYSQL *my)
|
||||
rc= mysql_ping(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_stmt_prepare(stmt, query, strlen(query));
|
||||
rc= mysql_stmt_prepare(stmt, query, -1);
|
||||
check_stmt_rc(rc, stmt);
|
||||
diag("Ok");
|
||||
|
||||
@@ -77,7 +78,7 @@ static int test_conc83(MYSQL *my)
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(2);
|
||||
|
||||
rc= mysql_stmt_prepare(stmt, query, strlen(query));
|
||||
rc= mysql_stmt_prepare(stmt, query, -1);
|
||||
FAIL_IF(!rc, "Error expected");
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
@@ -97,7 +98,7 @@ static int test_conc60(MYSQL *mysql)
|
||||
|
||||
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void *)&x);
|
||||
|
||||
rc= mysql_stmt_prepare(stmt, query, strlen(query));
|
||||
rc= mysql_stmt_prepare(stmt, query, -1);
|
||||
if (rc && mysql_stmt_errno(stmt) == 1146) {
|
||||
diag("Internal test - customer data not available");
|
||||
mysql_stmt_close(stmt);
|
||||
@@ -4544,9 +4545,9 @@ static int test_stmt_close(MYSQL *mysql)
|
||||
unsigned int count;
|
||||
int rc;
|
||||
char query[MAX_TEST_QUERY_LENGTH];
|
||||
my_bool reconnect= 1;
|
||||
|
||||
|
||||
mysql->reconnect= 1;
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
/* set AUTOCOMMIT to ON*/
|
||||
mysql_autocommit(mysql, TRUE);
|
||||
@@ -4644,9 +4645,8 @@ static int test_new_date(MYSQL *mysql)
|
||||
MYSQL_BIND bind[1];
|
||||
int rc;
|
||||
char buffer[50];
|
||||
|
||||
|
||||
mysql->reconnect= 1;
|
||||
my_bool reconnect= 1;
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
/* set AUTOCOMMIT to ON*/
|
||||
mysql_autocommit(mysql, TRUE);
|
||||
|
@@ -3909,7 +3909,111 @@ static int test_conc141(MYSQL *mysql)
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int test_conc154(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_STMT *stmt;
|
||||
const char *stmtstr= "SELECT * FROM t1";
|
||||
int rc;
|
||||
|
||||
/* 1st: empty result set without free_result */
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "CREATE TABLE t1 (a varchar(20))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
rc= mysql_stmt_prepare(stmt, stmtstr, strlen(stmtstr));
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_store_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_store_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
/* 2nd: empty result set with free_result */
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
rc= mysql_stmt_prepare(stmt, stmtstr, strlen(stmtstr));
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_store_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_free_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_store_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
rc= mysql_stmt_free_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
/* 3rd: non empty result without free_result */
|
||||
rc= mysql_query(mysql, "INSERT INTO t1 VALUES ('test_conc154')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
rc= mysql_stmt_prepare(stmt, stmtstr, strlen(stmtstr));
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_store_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_store_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
/* 4th non empty result set with free_result */
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
rc= mysql_stmt_prepare(stmt, stmtstr, strlen(stmtstr));
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_store_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_free_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_store_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
rc= mysql_stmt_free_result(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"test_conc154", test_conc154, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
|
||||
{"test_conc141", test_conc141, TEST_CONNECTION_NEW, 0, NULL , NULL},
|
||||
{"test_conc67", test_conc67, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
|
||||
{"test_conc_5", test_conc_5, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
|
||||
|
@@ -932,6 +932,7 @@ select 1;\
|
||||
DROP TABLE IF EXISTS test_multi_tab";
|
||||
uint count, exp_value;
|
||||
uint rows[]= {0, 0, 2, 1, 3, 2, 2, 1, 1, 0, 0, 1, 0};
|
||||
my_bool reconnect= 1;
|
||||
|
||||
/*
|
||||
First test that we get an error for multi statements
|
||||
@@ -950,7 +951,7 @@ DROP TABLE IF EXISTS test_multi_tab";
|
||||
mysql_close(mysql);
|
||||
mysql= mysql_local;
|
||||
|
||||
mysql_local->reconnect= 1;
|
||||
mysql_options(mysql_local, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
rc= mysql_query(mysql_local, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
@@ -53,18 +53,7 @@ static int check_cipher(MYSQL *mysql)
|
||||
return 1;
|
||||
diag("cipher: %s", cipher);
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
{
|
||||
return strcmp(cipher, "AES-128-GCM");
|
||||
}
|
||||
#elif HAVE_OPENSSL
|
||||
if (!strcmp(cipher, "DHE-RSA-AES256-SHA") ||
|
||||
!strcmp(cipher, "DHE-RSA-AES256-GCM-SHA384"))
|
||||
return 0;
|
||||
#elif HAVE_SCHANNEL
|
||||
return strcmp(cipher, "CALG_AES_256");
|
||||
#endif
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int create_ssl_user(const char *ssluser, my_bool is_X509)
|
||||
@@ -90,6 +79,8 @@ static int create_ssl_user(const char *ssluser, my_bool is_X509)
|
||||
rc= mysql_query(mysql, "FLUSH PRIVILEGES");
|
||||
check_mysql_rc(rc,mysql);
|
||||
|
||||
mysql_close(mysql);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -388,7 +379,7 @@ static int test_password_protected(MYSQL *my)
|
||||
"@CMAKE_SOURCE_DIR@/unittest/libmariadb/certs/client-cert.pem",
|
||||
"@CMAKE_SOURCE_DIR@/unittest/libmariadb/certs/ca-cert.pem", 0, 0);
|
||||
|
||||
mysql_options(mysql, MARIADB_OPT_SSL_PASSWORD, "qwerty");
|
||||
mysql_options(mysql, MARIADB_OPT_SSL_PASSPHRASE, "qwerty");
|
||||
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
@@ -775,7 +766,7 @@ static int test_ssl_fp_list(MYSQL *unused)
|
||||
static int test_ssl_version(MYSQL *mysql)
|
||||
{
|
||||
unsigned int iversion;
|
||||
char *version;
|
||||
const char *version, *library;
|
||||
MYSQL *my;
|
||||
|
||||
if (check_skip_ssl())
|
||||
@@ -794,6 +785,9 @@ static int test_ssl_version(MYSQL *mysql)
|
||||
mariadb_get_infov(my, MARIADB_CONNECTION_SSL_VERSION, &version);
|
||||
diag("protocol: %s", version);
|
||||
|
||||
mariadb_get_infov(my, MARIADB_SSL_LIBRARY, &library);
|
||||
diag("library: %s", library);
|
||||
|
||||
mysql_close(my);
|
||||
|
||||
return OK;
|
||||
|
@@ -2,13 +2,22 @@
|
||||
*/
|
||||
|
||||
#include "my_test.h"
|
||||
#include "ma_pvio.h"
|
||||
|
||||
static int aurora1(MYSQL *mysql)
|
||||
static int aurora1(MYSQL *my)
|
||||
{
|
||||
int rc;
|
||||
my_bool read_only= 1;
|
||||
char *primary, *replica;
|
||||
const char *primary, *my_schema;
|
||||
MYSQL_RES *res;
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
|
||||
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, NULL, 0))
|
||||
{
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -19,7 +28,7 @@ static int aurora1(MYSQL *mysql)
|
||||
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1, 'foo'), (2, 'bar')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
primary= mysql->host;
|
||||
mariadb_get_infov(mysql, MARIADB_CONNECTION_HOST, &primary);
|
||||
diag("primary: %s", primary);
|
||||
|
||||
mysql_options(mysql, MARIADB_OPT_CONNECTION_READ_ONLY, &read_only);
|
||||
@@ -37,22 +46,108 @@ static int aurora1(MYSQL *mysql)
|
||||
diag("Num_rows: %d", mysql_num_rows(res));
|
||||
mysql_free_result(res);
|
||||
|
||||
replica= mysql->host;
|
||||
diag("replica: %s", replica);
|
||||
diag("db: %s", mysql->db);
|
||||
mariadb_get_infov(mysql, MARIADB_CONNECTION_SCHEMA, &my_schema);
|
||||
diag("db: %s", my_schema);
|
||||
|
||||
mysql_close(mysql);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int test_wrong_user(MYSQL *my)
|
||||
{
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
|
||||
if (mysql_real_connect(mysql, hostname, "wrong_user", NULL, NULL, 0, NULL, 0))
|
||||
{
|
||||
diag("Error expected");
|
||||
mysql_close(mysql);
|
||||
return FAIL;
|
||||
}
|
||||
mysql_close(mysql);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int test_reconnect(MYSQL *my)
|
||||
{
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
MYSQL_RES *res;
|
||||
my_bool read_only= 1;
|
||||
int rc;
|
||||
my_bool reconnect= 1;
|
||||
const char *aurora_host;
|
||||
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, NULL, 0))
|
||||
{
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
mariadb_get_infov(mysql, MARIADB_CONNECTION_HOST, &aurora_host);
|
||||
diag("host: %s", aurora_host);
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS tx01");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "CREATE TABLE tx01 (a int)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
/* we force cluster restart and promoting new primary:
|
||||
* we wait for 50 seconds - however there is no guarantee that
|
||||
* cluster was restarted already - so this test might fail */
|
||||
system("/usr/local/aws/bin/aws rds failover-db-cluster --db-cluster-identifier instance-1-cluster");
|
||||
|
||||
sleep(50);
|
||||
diag("Q1");
|
||||
rc= mysql_query(mysql, "INSERT INTO tx01 VALUES (1)");
|
||||
if (!rc)
|
||||
diag("error expected!");
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
|
||||
diag("Q2");
|
||||
rc= mysql_query(mysql, "INSERT INTO tx01 VALUES (1)");
|
||||
if (rc)
|
||||
{
|
||||
diag("no error expected!");
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
diag("host: %s", mysql->host);
|
||||
}
|
||||
else
|
||||
{
|
||||
mariadb_get_infov(mysql, MARIADB_CONNECTION_HOST, &aurora_host);
|
||||
diag("host: %s", aurora_host);
|
||||
}
|
||||
|
||||
mysql_options(mysql, MARIADB_OPT_CONNECTION_READ_ONLY, &read_only);
|
||||
|
||||
rc= mysql_query(mysql, "SELECT * from tx01");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
if ((res= mysql_store_result(mysql)))
|
||||
{
|
||||
diag("num_rows: %d", mysql_num_rows(res));
|
||||
mysql_free_result(res);
|
||||
}
|
||||
|
||||
mariadb_get_infov(mysql, MARIADB_CONNECTION_HOST, &aurora_host);
|
||||
diag("host: %s", aurora_host);
|
||||
|
||||
mysql_close(mysql);
|
||||
return OK;
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"aurora1", aurora1, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"aurora1", aurora1, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_wrong_user", test_wrong_user, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_reconnect", test_reconnect, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
mysql_library_init(0,0,NULL);
|
||||
|
||||
if (argc > 1)
|
||||
|
Reference in New Issue
Block a user