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 from 3.0.0 fixes
This commit is contained in:
@@ -21,7 +21,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/unittest/mytap)
|
||||
ADD_DEFINITIONS(-DLIBMARIADB)
|
||||
|
||||
SET(API_TESTS "features-10_2" "async" "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs"
|
||||
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")
|
||||
|
||||
# Get finger print from server certificate
|
||||
@@ -31,18 +31,15 @@ IF(WITH_SSL)
|
||||
IF(EXISTS "${CMAKE_SOURCE_DIR}/unittest/libmariadb/certs/server-cert.pem")
|
||||
MESSAGE(STATUS "certificates already exist")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "cerating certificates")
|
||||
EXECUTE_PROCESS(COMMAND openssl req -x509 -newkey rsa:1024 -keyout server-key-enc.pem -out server-cert.pem -subj "/DC=com/DC=example/CN=server" -passout pass:qwerty
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/unittest/libmariadb/certs)
|
||||
EXECUTE_PROCESS(COMMAND openssl rsa -in server-key-enc.pem -out server-key.pem -passin pass:qwerty -passout pass:
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/unittest/libmariadb/certs)
|
||||
EXECUTE_PROCESS(COMMAND openssl req -x509 -newkey rsa:1024 -keyout client-key-enc.pem -out client-cert.pem -subj "/DC=com/DC=example/CN=client" -passout pass:qwerty
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/unittest/libmariadb/certs)
|
||||
EXECUTE_PROCESS(COMMAND openssl rsa -in client-key-enc.pem -out client-key.pem -passin pass:qwerty -passout pass:
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/unittest/libmariadb/certs)
|
||||
FILE(READ ${CMAKE_SOURCE_DIR}/unittest/libmariadb/certs/server-cert.pem F1)
|
||||
FILE(READ ${CMAKE_SOURCE_DIR}/unittest/libmariadb/certs/client-cert.pem F2)
|
||||
FILE(WRITE ${CMAKE_SOURCE_DIR}/unittest/libmariadb/certs/ca-cert.pem ${F1} ${F2})
|
||||
MESSAGE(STATUS "creating certificates")
|
||||
IF(WIN32)
|
||||
EXECUTE_PROCESS(COMMAND create_certs.bat
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/unittest/libmariadb/certs
|
||||
OUTPUT_FILE x.1 ERROR_FILE x.2)
|
||||
ELSE()
|
||||
EXECUTE_PROCESS(COMMAND ./create_certs.sh
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/unittest/libmariadb/certs)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
EXECUTE_PROCESS(COMMAND openssl x509 -in server-cert.pem -sha1 -fingerprint -noout
|
||||
@@ -60,8 +57,8 @@ IF(WITH_SSL)
|
||||
ENDIF()
|
||||
|
||||
FOREACH(API_TEST ${API_TESTS})
|
||||
ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c)
|
||||
TARGET_LINK_LIBRARIES(${API_TEST} mytap mariadbclient )
|
||||
ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c ${CMAKE_SOURCE_DIR}/libmariadb/getopt.c)
|
||||
TARGET_LINK_LIBRARIES(${API_TEST} mytap libmariadb)
|
||||
ADD_TEST(${API_TEST} ${EXECUTABLE_OUTPUT_PATH}/${API_TEST})
|
||||
SET_TESTS_PROPERTIES(${API_TEST} PROPERTIES TIMEOUT 120)
|
||||
ENDFOREACH(API_TEST)
|
||||
|
@@ -30,6 +30,20 @@
|
||||
|
||||
#define SL(s) (s), sizeof(s)
|
||||
|
||||
my_bool skip_async= 0;
|
||||
|
||||
static int test_async(MYSQL *mysql)
|
||||
{
|
||||
int type;
|
||||
mariadb_get_info(mysql, MARIADB_CONNECTION_PVIO_TYPE, &type);
|
||||
if (type > MARIADB_CONNECTION_TCP)
|
||||
{
|
||||
skip_async= 1;
|
||||
diag("Asnyc IO not supported");
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int
|
||||
wait_for_mysql(MYSQL *mysql, int status)
|
||||
{
|
||||
@@ -126,6 +140,9 @@ static int async1(MYSQL *my)
|
||||
uint default_timeout;
|
||||
int i;
|
||||
|
||||
if (skip_async)
|
||||
return SKIP;
|
||||
|
||||
for (i=0; i < 100; i++)
|
||||
{
|
||||
|
||||
@@ -196,7 +213,12 @@ static int test_conc131(MYSQL *my)
|
||||
{
|
||||
int rc;
|
||||
/* this test needs to run under valgrind */
|
||||
MYSQL *mysql=mysql_init(NULL);
|
||||
MYSQL *mysql;
|
||||
|
||||
if (skip_async)
|
||||
return SKIP;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
rc= mysql_options(mysql, MYSQL_OPT_NONBLOCK, 0);
|
||||
check_mysql_rc(rc, mysql);
|
||||
mysql_close(mysql);
|
||||
@@ -205,13 +227,19 @@ static int test_conc131(MYSQL *my)
|
||||
|
||||
static int test_conc129(MYSQL *my)
|
||||
{
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
MYSQL *mysql;
|
||||
|
||||
if (skip_async)
|
||||
return SKIP;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
FAIL_IF(mysql_close_start(mysql), "No error expected");
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"test_async", test_async, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"async1", async1, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc131", test_conc131, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_conc129", test_conc129, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
|
@@ -55,13 +55,17 @@ static int test_conc75(MYSQL *my)
|
||||
{
|
||||
ulong thread_id= mysql_thread_id(mysql);
|
||||
/* force reconnect */
|
||||
mysql->reconnect= 1;
|
||||
diag("killing connection");
|
||||
mysql_kill(my, thread_id);
|
||||
sleep(1);
|
||||
sleep(2);
|
||||
mysql_ping(mysql);
|
||||
rc= mysql_query(mysql, "load data local infile './nonexistingfile.csv' into table a (`a`)");
|
||||
FAIL_IF(!test(mysql->options.client_flag | CLIENT_LOCAL_FILES), "client_flags not correct");
|
||||
diag("thread1: %d %d", thread_id, mysql_thread_id(mysql));
|
||||
FAIL_IF(thread_id == mysql_thread_id(mysql), "new thread id expected");
|
||||
diag("cs: %s", mysql->charset->csname);
|
||||
FAIL_IF(strcmp(mysql->charset->csname, "utf8"), "wrong character set");
|
||||
//diag("cs: %s", mysql->charset->csname);
|
||||
//FAIL_IF(strcmp(mysql->charset->csname, "utf8"), "wrong character set");
|
||||
}
|
||||
mysql_close(mysql);
|
||||
return OK;
|
||||
@@ -76,7 +80,12 @@ static int test_conc74(MYSQL *my)
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
|
||||
mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS);
|
||||
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS))
|
||||
{
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS a");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -128,7 +137,11 @@ static int test_conc70(MYSQL *my)
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
MYSQL *mysql;
|
||||
|
||||
SKIP_CONNECTION_HANDLER;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
rc= mysql_query(my, "SET @a:=@@max_allowed_packet");
|
||||
check_mysql_rc(rc, my);
|
||||
@@ -148,6 +161,14 @@ static int test_conc70(MYSQL *my)
|
||||
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (REPEAT('A', 1024 * 1024 * 20))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
if (mysql_warning_count(mysql))
|
||||
{
|
||||
diag("server doesn't accept package size");
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
sleep(20);
|
||||
|
||||
rc= mysql_query(mysql, "SELECT a FROM t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -175,7 +196,11 @@ static int test_conc68(MYSQL *my)
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
MYSQL *mysql;
|
||||
|
||||
SKIP_CONNECTION_HANDLER;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
rc= mysql_query(my, "SET @a:=@@max_allowed_packet");
|
||||
check_mysql_rc(rc, my);
|
||||
@@ -193,6 +218,11 @@ static int test_conc68(MYSQL *my)
|
||||
|
||||
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (REPEAT('A', 1024 * 1024 * 20))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
if (mysql_warning_count(mysql))
|
||||
{
|
||||
diag("server doesn't accept package size");
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
rc= mysql_query(mysql, "SELECT a FROM t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -427,7 +457,7 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
FAIL_UNLESS(res == 400, "");
|
||||
|
||||
/* table with auto_increment column */
|
||||
rc= mysql_query(mysql, "create table t2 (f1 int not null primary key auto_increment, f2 varchar(255))");
|
||||
rc= mysql_query(mysql, "create table t2 (f1 int not null primary key auto_increment, f2 varchar(255)) engine=MyISAM");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "insert into t2 values (1,'a')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -504,12 +534,13 @@ static int test_mysql_insert_id(MYSQL *mysql)
|
||||
according to the manual, this might be 20 or 300, but it looks like
|
||||
auto_increment column takes priority over last_insert_id().
|
||||
*/
|
||||
diag("res: %d", res);
|
||||
FAIL_UNLESS(res == 20, "");
|
||||
/* If first autogenerated number fails and 2nd works: */
|
||||
rc= mysql_query(mysql, "drop table t2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "create table t2 (f1 int not null primary key "
|
||||
"auto_increment, f2 varchar(255), unique (f2))");
|
||||
"auto_increment, f2 varchar(255), unique (f2)) engine=MyISAM");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "insert into t2 values (null,'e')");
|
||||
res= mysql_insert_id(mysql);
|
||||
@@ -618,12 +649,9 @@ static int bug_conc1(MYSQL *mysql)
|
||||
{
|
||||
mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0);
|
||||
diag("errno: %d", mysql_errno(mysql));
|
||||
FAIL_IF(mysql_errno(mysql) != CR_ALREADY_CONNECTED,
|
||||
"Expected errno=CR_ALREADY_CONNECTED");
|
||||
FAIL_IF(strcmp(mysql_error(mysql), ER(CR_ALREADY_CONNECTED)) != 0,
|
||||
"Wrong error message");
|
||||
FAIL_IF(strcmp(ER(CR_ALREADY_CONNECTED), "Can't connect twice. Already connected") != 0,
|
||||
"wrong error message");
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -668,11 +696,14 @@ static int test_reconnect_maxpackage(MYSQL *my)
|
||||
{
|
||||
int rc;
|
||||
ulong max_packet= 0;
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
MYSQL *mysql;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
char *query;
|
||||
|
||||
SKIP_CONNECTION_HANDLER;
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname,
|
||||
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS), mysql_error(mysql));
|
||||
@@ -770,6 +801,8 @@ int main(int argc, char **argv)
|
||||
|
||||
get_envvars();
|
||||
|
||||
diag("user: %s", username);
|
||||
|
||||
run_tests(my_tests);
|
||||
|
||||
return(exit_status());
|
||||
|
@@ -1,15 +0,0 @@
|
||||
openssl req -x509 -newkey rsa:1024 \
|
||||
-keyout server-key-enc.pem -out server-cert.pem \
|
||||
-subj '/DC=com/DC=example/CN=server' -passout pass:qwerty
|
||||
|
||||
openssl rsa -in server-key-enc.pem -out server-key.pem \
|
||||
-passin pass:qwerty -passout pass:
|
||||
|
||||
openssl req -x509 -newkey rsa:1024 \
|
||||
-keyout client-key-enc.pem -out client-cert.pem \
|
||||
-subj '/DC=com/DC=example/CN=client' -passout pass:qwerty
|
||||
|
||||
openssl rsa -in client-key-enc.pem -out client-key.pem \
|
||||
-passin pass:qwerty -passout pass:
|
||||
|
||||
cat server-cert.pem client-cert.pem > ca-cert.pem
|
@@ -1,21 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDXTCCAkWgAwIBAgIJAL4tmDe5DR0sMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
|
||||
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
|
||||
aWRnaXRzIFB0eSBMdGQwHhcNMTUwMzEwMjAyMDI4WhcNMTYwMzA5MjAyMDI4WjBF
|
||||
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
|
||||
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
|
||||
CgKCAQEApV9UfWmeXYdexOEn+adOm6FdJUhKMrjTiycwETmDXRVpY4wl+LNGsANp
|
||||
ohSRovDjFiFO+Ti0bUhpf552oE23wYw+P6f0UY0KkV/PgSght1Ezfffe0BaEjI0X
|
||||
tA5zdNmxzL3OUWJVcg+I4UE3rbYFHUgymu72P0IRXjmJv1tToNxUxbTBLxU/KAlq
|
||||
Uy49upB3q3/IPOdP9UzAZDHnRv1gjwUzNgumfcc5d5lSsGpwLDYCQs4I539fCkBD
|
||||
MfU2BN/qpmPhb/nm5ZUdFUFYGN+XxVPVpJLmeWVRwMSQR2LN5CkqnK9e2Q/QaJ53
|
||||
G3AAng+fpfEGPpjQdFWuhFjQozOD0wIDAQABo1AwTjAdBgNVHQ4EFgQUyg6WfzL2
|
||||
JhhjKm1Ex28s4Y3vNGQwHwYDVR0jBBgwFoAUyg6WfzL2JhhjKm1Ex28s4Y3vNGQw
|
||||
DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAIrj/bHiRf8UJIfv8hyZ1
|
||||
dXEqvqjxUMXtJ/QhhCQs42p9pHv+mPTkeXh0K18Oj6k/Vp4J1/0mp/kqiQUHt9yO
|
||||
/3pJPc+JordTjlVLgb95cfBIs4yiPT9biGaA7j0Dh9EcDBOCT4v56Z9BLqGMfBUK
|
||||
YeZ7ZecWmZCZOYk/X+CPB30GxLy5Wm9D50qEUXXBPZ9Bie6FYaQYOFlQlqxYuLX0
|
||||
NVqLDvX6zz6FMsgqoyDJ1BMuMsjPDUUUrwGY+R3YqiqkPRbDkr8zvzpqiYvjTZi0
|
||||
LTJO7GRfwzfhkeEPL/hl/TYdB1GZHixMrAKx1HGKHAa0sgWTWxQGYhfclH8DI7AR
|
||||
Tw==
|
||||
-----END CERTIFICATE-----
|
@@ -679,7 +679,7 @@ static int test_utf16_utf32_noboms(MYSQL *mysql)
|
||||
|
||||
for (i= 0; i < sizeof(csname)/sizeof(char*); ++i)
|
||||
{
|
||||
csinfo[i]= mysql_find_charset_name(csname[i]);
|
||||
csinfo[i]= mariadb_get_charset_by_name(csname[i]);
|
||||
|
||||
if (csinfo[i] == NULL)
|
||||
{
|
||||
|
@@ -32,6 +32,7 @@ static int test_conc66(MYSQL *my)
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
int rc;
|
||||
FILE *fp;
|
||||
char query[1024];
|
||||
|
||||
if (!(fp= fopen("./my.cnf", "w")))
|
||||
return FAIL;
|
||||
@@ -47,7 +48,8 @@ static int test_conc66(MYSQL *my)
|
||||
rc= mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "./my.cnf");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(my, "GRANT ALL ON test.* TO 'conc66'@'localhost' IDENTIFIED BY 'test\";#test'");
|
||||
sprintf(query, "GRANT ALL ON %s.* TO 'conc66'@'%s' IDENTIFIED BY 'test\";#test'", schema, hostname);
|
||||
rc= mysql_query(my, query);
|
||||
check_mysql_rc(rc, my);
|
||||
rc= mysql_query(my, "FLUSH PRIVILEGES");
|
||||
check_mysql_rc(rc, my);
|
||||
@@ -57,7 +59,8 @@ static int test_conc66(MYSQL *my)
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
return FAIL;
|
||||
}
|
||||
rc= mysql_query(my, "DROP USER conc66@localhost");
|
||||
sprintf(query, "DROP user conc66@%s", hostname);
|
||||
rc= mysql_query(my, query);
|
||||
|
||||
check_mysql_rc(rc, my);
|
||||
mysql_close(mysql);
|
||||
@@ -561,6 +564,8 @@ static int test_reconnect(MYSQL *mysql)
|
||||
mysql_kill(mysql, mysql_thread_id(mysql1));
|
||||
sleep(4);
|
||||
|
||||
mysql_ping(mysql1);
|
||||
|
||||
rc= mysql_query(mysql1, "SELECT 1 FROM DUAL LIMIT 0");
|
||||
check_mysql_rc(rc, mysql1);
|
||||
diag("Thread_id after kill: %lu", mysql_thread_id(mysql1));
|
||||
@@ -649,6 +654,8 @@ static int test_conc118(MYSQL *mysql)
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(2);
|
||||
|
||||
mysql_ping(mysql);
|
||||
|
||||
rc= mysql_query(mysql, "SET @a:=1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -657,12 +664,7 @@ static int test_conc118(MYSQL *mysql)
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(2);
|
||||
|
||||
mysql->host= "foo";
|
||||
|
||||
rc= mysql_query(mysql, "SET @a:=1");
|
||||
FAIL_IF(!rc, "error expected");
|
||||
|
||||
mysql->host= hostname;
|
||||
mysql_ping(mysql);
|
||||
rc= mysql_query(mysql, "SET @a:=1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -740,7 +742,92 @@ static int test_bind_address(MYSQL *my)
|
||||
return OK;
|
||||
}
|
||||
|
||||
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,
|
||||
#ifdef _WIN32
|
||||
MYSQL_OPT_NAMED_PIPE,
|
||||
#endif
|
||||
0};
|
||||
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};
|
||||
|
||||
char *init_command[3]= {"SET @a:=1", "SET @b:=2", "SET @c:=3"};
|
||||
int elements= 0;
|
||||
char **command;
|
||||
|
||||
|
||||
int intval[2]= {1, 0};
|
||||
my_bool boolval[2]= {1, 0};
|
||||
char *char1= "test", *char2;
|
||||
int i;
|
||||
MYSQL *userdata;
|
||||
char *attr_key[] = {"foo1", "foo2", "foo3"};
|
||||
char *attr_val[] = {"bar1", "bar2", "bar3"};
|
||||
char **key, **val;
|
||||
|
||||
for (i=0; options_int[i]; i++)
|
||||
{
|
||||
mysql_options(mysql, options_int[i], &intval[0]);
|
||||
intval[1]= 0;
|
||||
mysql_get_optionv(mysql, options_int[i], &intval[1]);
|
||||
FAIL_IF(intval[0] != intval[1], "mysql_get_optionv (int) failed");
|
||||
}
|
||||
for (i=0; options_bool[i]; i++)
|
||||
{
|
||||
mysql_options(mysql, options_bool[i], &boolval[0]);
|
||||
intval[1]= 0;
|
||||
mysql_get_optionv(mysql, options_bool[i], &boolval[1]);
|
||||
FAIL_IF(boolval[0] != boolval[1], "mysql_get_optionv (my_bool) failed");
|
||||
}
|
||||
for (i=0; options_char[i]; i++)
|
||||
{
|
||||
mysql_options(mysql, options_char[i], char1);
|
||||
char2= NULL;
|
||||
mysql_get_optionv(mysql, options_char[i], (void *)&char2);
|
||||
FAIL_IF(strcmp(char1, char2), "mysql_get_optionv (char) failed");
|
||||
}
|
||||
|
||||
for (i=0; i < 3; i++)
|
||||
mysql_options(mysql, MYSQL_INIT_COMMAND, init_command[i]);
|
||||
|
||||
mysql_get_optionv(mysql, MYSQL_INIT_COMMAND, &command, &elements);
|
||||
FAIL_IF(elements != 3, "expected 3 elements");
|
||||
for (i=0; i < 3; i++)
|
||||
FAIL_IF(strcmp(init_command[i], command[i]), "wrong init command");
|
||||
for (i=0; i < 3; i++)
|
||||
mysql_optionsv(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, attr_key[i], attr_val[i]);
|
||||
|
||||
mysql_get_optionv(mysql, MYSQL_OPT_CONNECT_ATTRS, NULL, NULL, &elements);
|
||||
FAIL_IF(elements != 3, "expected 3 connection attributes");
|
||||
|
||||
key= (char **)malloc(sizeof(char *) * elements);
|
||||
val= (char **)malloc(sizeof(char *) * elements);
|
||||
|
||||
mysql_get_optionv(mysql, MYSQL_OPT_CONNECT_ATTRS, &key, &val, &elements);
|
||||
for (i=0; i < elements; i++)
|
||||
{
|
||||
diag("%s => %s", key[i], val[i]);
|
||||
}
|
||||
|
||||
free(key);
|
||||
free(val);
|
||||
|
||||
mysql_optionsv(mysql, MARIADB_OPT_USERDATA, "my_app", (void *)mysql);
|
||||
mysql_get_optionv(mysql, MARIADB_OPT_USERDATA, "my_app", &userdata);
|
||||
|
||||
FAIL_IF(mysql != userdata, "wrong userdata");
|
||||
mysql_close(mysql);
|
||||
return OK;
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"test_get_options", test_get_options, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_wrong_bind_address", test_wrong_bind_address, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_bind_address", test_bind_address, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc118", test_conc118, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
|
@@ -59,12 +59,12 @@ MYSQL_STMT *open_cursor(MYSQL *mysql, const char *query)
|
||||
fetch buffers.
|
||||
*/
|
||||
|
||||
int stmt_fetch_init(MYSQL *mysql, Stmt_fetch *fetch, unsigned stmt_no_arg,
|
||||
int stmt_fetch_init(MYSQL *mysql, Stmt_fetch *fetch, unsigned int stmt_no_arg,
|
||||
const char *query_arg)
|
||||
{
|
||||
unsigned long type= CURSOR_TYPE_READ_ONLY;
|
||||
int rc;
|
||||
unsigned i;
|
||||
unsigned int i;
|
||||
MYSQL_RES *metadata;
|
||||
|
||||
/* Save query and statement number for error messages */
|
||||
@@ -180,7 +180,7 @@ int fetch_n(MYSQL *mysql, const char **query_list, unsigned query_count,
|
||||
|
||||
for (fetch= fetch_array; fetch < fetch_array + query_count; ++fetch)
|
||||
{
|
||||
if (stmt_fetch_init(mysql, fetch, fetch - fetch_array,
|
||||
if (stmt_fetch_init(mysql, fetch, (unsigned int)(fetch - fetch_array),
|
||||
query_list[fetch - fetch_array]))
|
||||
return FAIL;
|
||||
}
|
||||
@@ -322,7 +322,7 @@ static int test_bug21206(MYSQL *mysql)
|
||||
|
||||
for (fetch= fetch_array; fetch < fetch_array + cursor_count; ++fetch)
|
||||
{
|
||||
if ((retcode= stmt_fetch_init(mysql, fetch, fetch - fetch_array, query)))
|
||||
if ((retcode= stmt_fetch_init(mysql, fetch, (unsigned int)(fetch - fetch_array), query)))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -89,7 +89,7 @@ static int test_logs(MYSQL *mysql)
|
||||
my_bind[1].buffer_type= MYSQL_TYPE_STRING;
|
||||
my_bind[1].buffer= (void *)&data;
|
||||
my_bind[1].buffer_length= 255;
|
||||
my_bind[1].length= &length;
|
||||
my_bind[1].length= (unsigned long *)&length;
|
||||
|
||||
id= 9876;
|
||||
strcpy((char *)data, "MySQL - Open Source Database");
|
||||
|
@@ -266,7 +266,7 @@ static int test_frm_bug(MYSQL *mysql)
|
||||
sprintf(test_frm, "%s/%s/test_frm_bug.frm", data_dir, schema);
|
||||
|
||||
|
||||
if (!(test_file= my_fopen(test_frm, (int) (O_RDWR | O_CREAT), MYF(MY_WME))))
|
||||
if (!(test_file= fopen(test_frm, "rw")))
|
||||
{
|
||||
mysql_stmt_close(stmt);
|
||||
diag("Can't write to file %s -> SKIP", test_frm);
|
||||
@@ -294,7 +294,7 @@ static int test_frm_bug(MYSQL *mysql)
|
||||
mysql_free_result(result);
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
my_fclose(test_file, MYF(0));
|
||||
fclose(test_file);
|
||||
mysql_query(mysql, "drop table if exists test_frm_bug");
|
||||
return OK;
|
||||
}
|
||||
@@ -1021,11 +1021,74 @@ static int test_remote2(MYSQL *my)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int test_get_info(MYSQL *mysql)
|
||||
{
|
||||
size_t sval;
|
||||
unsigned int ival;
|
||||
char *cval;
|
||||
int rc;
|
||||
MY_CHARSET_INFO cs;
|
||||
CHARSET_INFO *ci;
|
||||
char **errors;
|
||||
|
||||
rc= mariadb_get_infov(mysql, MARIADB_MAX_ALLOWED_PACKET, &sval);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("max_allowed_packet: %d", sval);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_NET_BUFFER_LENGTH, &sval);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("net_buffer_length: %d", sval);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CLIENT_VERSION_ID, &sval);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("client_version_id: %d", sval);
|
||||
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);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("charset name: %s", cs.csname);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_PVIO_TYPE, &ival);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("connection type: %d", ival);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_PROTOCOL_VERSION_ID, &ival);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("protocol_version: %d", ival);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_SERVER_TYPE, &cval);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("server_type: %s", cval);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_SERVER_VERSION, &cval);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("server_version: %s", cval);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CLIENT_VERSION, &cval);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("client_version: %s", cval);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CHARSET_NAME, &ci, "utf8");
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("charset_name: %s", ci->csname);
|
||||
diag("charset_nr: %d", ci->nr);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CHARSET_ID, &ci, 63);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("charset_name: %s", ci->csname);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CLIENT_ERRORS, &errors);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("error[0]: %s", errors[0]);
|
||||
rc= mysql_query(mysql, "DROP TABLE IF exists t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1),(2)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_INFO, &cval);
|
||||
FAIL_IF(rc, "mysql_get_info failed");
|
||||
diag("mariadb_info: %s", cval);
|
||||
return OK;
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
#ifdef HAVE_REMOTEIO
|
||||
{"test_remote1", test_remote1, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_remote2", test_remote2, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
#endif
|
||||
{"test_get_info", test_get_info, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc117", test_conc117, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc_114", test_conc_114, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_connect_attrs", test_connect_attrs, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
|
@@ -82,6 +82,13 @@ if (!(expr))\
|
||||
return FAIL;\
|
||||
}
|
||||
|
||||
#define SKIP_CONNECTION_HANDLER \
|
||||
if (hostname && strstr(hostname, "://"))\
|
||||
{\
|
||||
diag("Test skipped (connection handler)");\
|
||||
return SKIP;\
|
||||
}
|
||||
|
||||
/* connection options */
|
||||
#define TEST_CONNECTION_DEFAULT 1 /* default connection */
|
||||
#define TEST_CONNECTION_NONE 2 /* tests creates own connection */
|
||||
@@ -104,7 +111,7 @@ struct my_tests_st
|
||||
char *skipmsg;
|
||||
};
|
||||
|
||||
static char *schema = "test_c";
|
||||
static char *schema = 0;
|
||||
static char *hostname = 0;
|
||||
static char *password = 0;
|
||||
static unsigned int port = 0;
|
||||
@@ -368,18 +375,19 @@ int check_variable(MYSQL *mysql, char *variable, char *value)
|
||||
MYSQL *test_connect(struct my_tests_st *test) {
|
||||
MYSQL *mysql;
|
||||
char query[255];
|
||||
int i= 1;
|
||||
int i= 0;
|
||||
int timeout= 10;
|
||||
int truncation_report= 1;
|
||||
if (!(mysql = mysql_init(NULL))) {
|
||||
diag("%s", "mysql_init failed - exiting");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, &i);
|
||||
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&i);
|
||||
mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, &truncation_report);
|
||||
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
|
||||
|
||||
/* option handling */
|
||||
if (test && test->options) {
|
||||
int i=0;
|
||||
|
||||
while (test->options[i].option)
|
||||
{
|
||||
@@ -403,6 +411,8 @@ MYSQL *test_connect(struct my_tests_st *test) {
|
||||
|
||||
/* 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)) {
|
||||
@@ -425,11 +435,6 @@ static int reset_connection(MYSQL *mysql) {
|
||||
|
||||
rc= mysql_change_user(mysql, username, password, schema);
|
||||
check_mysql_rc(rc, mysql);
|
||||
if (mysql_get_server_version(mysql) < 50400)
|
||||
rc= mysql_query(mysql, "SET table_type='MyISAM'");
|
||||
else
|
||||
rc= mysql_query(mysql, "SET storage_engine='MyISAM'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "SET sql_mode=''");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -452,6 +457,8 @@ void get_envvars() {
|
||||
password= envvar;
|
||||
if (!schema && (envvar= getenv("MYSQL_TEST_DB")))
|
||||
schema= envvar;
|
||||
if (!schema)
|
||||
schema= "testc";
|
||||
if (!port && (envvar= getenv("MYSQL_TEST_PORT")))
|
||||
port= atoi(envvar);
|
||||
if (!socketname && (envvar= getenv("MYSQL_TEST_SOCKET")))
|
||||
@@ -470,7 +477,8 @@ void run_tests(struct my_tests_st *test) {
|
||||
if ((mysql_default= test_connect(NULL)))
|
||||
{
|
||||
diag("Testing against MySQL Server %s", mysql_get_server_info(mysql_default));
|
||||
diag("Host %s", mysql_get_host_info(mysql_default));
|
||||
diag("Host: %s", mysql_get_host_info(mysql_default));
|
||||
diag("Client library: %s", mysql_get_client_info());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -64,7 +64,10 @@ static int test_conc83(MYSQL *my)
|
||||
/* 1. Status is inited, so prepare should work */
|
||||
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(2);
|
||||
sleep(5);
|
||||
|
||||
rc= mysql_ping(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_stmt_prepare(stmt, query, strlen(query));
|
||||
check_stmt_rc(rc, stmt);
|
||||
@@ -1383,7 +1386,7 @@ static int test_long_data_str1(MYSQL *mysql)
|
||||
|
||||
my_bind[0].buffer= data; /* string data */
|
||||
my_bind[0].buffer_length= sizeof(data);
|
||||
my_bind[0].length= &length1;
|
||||
my_bind[0].length= (unsigned long *)&length1;
|
||||
my_bind[0].buffer_type= MYSQL_TYPE_STRING;
|
||||
length1= 0;
|
||||
|
||||
@@ -1482,7 +1485,7 @@ static int test_long_data_str1(MYSQL *mysql)
|
||||
my_bind[0].buffer_type= MYSQL_TYPE_BLOB;
|
||||
my_bind[0].buffer= (void *) &data; /* this buffer won't be altered */
|
||||
my_bind[0].buffer_length= 16;
|
||||
my_bind[0].length= &blob_length;
|
||||
my_bind[0].length= (unsigned long *)&blob_length;
|
||||
my_bind[0].error= &my_bind[0].error_value;
|
||||
rc= mysql_stmt_bind_result(stmt, my_bind);
|
||||
data[16]= 0;
|
||||
@@ -1498,7 +1501,7 @@ static int test_long_data_str1(MYSQL *mysql)
|
||||
my_bind[1].buffer_type= MYSQL_TYPE_BLOB;
|
||||
my_bind[1].buffer= (void *) &data; /* this buffer won't be altered */
|
||||
my_bind[1].buffer_length= sizeof(data);
|
||||
my_bind[1].length= &blob_length;
|
||||
my_bind[1].length= (unsigned long *)&blob_length;
|
||||
memset(data, '\0', sizeof(data));
|
||||
mysql_stmt_fetch_column(stmt, my_bind+1, 0, 0);
|
||||
FAIL_UNLESS(strlen(data) == max_blob_length, "strlen(data) != max_blob_length");
|
||||
|
@@ -528,9 +528,8 @@ static int test_bug12744(MYSQL *mysql)
|
||||
rc= mysql_options(mysql, MYSQL_OPT_RECONNECT, "1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
sleep(2);
|
||||
sleep(4);
|
||||
rc= mysql_ping(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -644,7 +643,7 @@ static int test_bug1500(MYSQL *mysql)
|
||||
data= "Grave";
|
||||
my_bind[0].buffer_type= MYSQL_TYPE_STRING;
|
||||
my_bind[0].buffer= (void *) data;
|
||||
my_bind[0].buffer_length= strlen(data);
|
||||
my_bind[0].buffer_length= (unsigned long)strlen(data);
|
||||
|
||||
rc= mysql_stmt_bind_param(stmt, my_bind);
|
||||
check_stmt_rc(rc, stmt);
|
||||
@@ -2652,7 +2651,7 @@ static int test_bug5194(MYSQL *mysql)
|
||||
for (i= 1; i < COLUMN_COUNT; ++i)
|
||||
strcat(param_str, "?, ");
|
||||
strcat(param_str, "?)");
|
||||
param_str_length= strlen(param_str);
|
||||
param_str_length= (int)strlen(param_str);
|
||||
|
||||
/* setup bind array */
|
||||
memset(my_bind, '\0', MAX_PARAM_COUNT * sizeof(MYSQL_BIND));
|
||||
@@ -3230,7 +3229,7 @@ static int test_mem_overun(MYSQL *mysql)
|
||||
sprintf(field, "c%d int, ", i);
|
||||
strcat(buffer, field);
|
||||
}
|
||||
length= strlen(buffer);
|
||||
length= (int)strlen(buffer);
|
||||
buffer[length-2]= ')';
|
||||
buffer[--length]= '\0';
|
||||
|
||||
@@ -3242,7 +3241,7 @@ static int test_mem_overun(MYSQL *mysql)
|
||||
{
|
||||
strcat(buffer, "1, ");
|
||||
}
|
||||
length= strlen(buffer);
|
||||
length= (int)strlen(buffer);
|
||||
buffer[length-2]= ')';
|
||||
buffer[--length]= '\0';
|
||||
|
||||
|
@@ -51,12 +51,20 @@ static int check_cipher(MYSQL *mysql)
|
||||
char *cipher= (char *)mysql_get_ssl_cipher(mysql);
|
||||
if (!cipher)
|
||||
return 1;
|
||||
diag("cipher: %s", cipher);
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
return strcmp(cipher, "AES-128-GCM");
|
||||
#endif
|
||||
#ifdef HAVE_OPENSSL
|
||||
return strcmp(cipher, "DHE-RSA-AES256-SHA");
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static int create_ssl_user(const char *ssluser, my_bool is_X509)
|
||||
@@ -105,6 +113,14 @@ static int test_ssl(MYSQL *mysql)
|
||||
}
|
||||
mysql_free_result(res);
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
diag("SSL library: GNUTLS");
|
||||
#elif HAVE_OPENSSL
|
||||
diag("SSL library: OPENSSL");
|
||||
#elif HAVE_SCHANNEL
|
||||
diag("SSL library: SCHANNEL");
|
||||
#endif
|
||||
|
||||
sslhost[0]= 0;
|
||||
|
||||
if (!skip_ssl)
|
||||
@@ -127,6 +143,9 @@ static int test_ssl(MYSQL *mysql)
|
||||
static int test_ssl_cipher(MYSQL *unused)
|
||||
{
|
||||
MYSQL *my;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
int rc;
|
||||
|
||||
if (check_skip_ssl())
|
||||
return SKIP;
|
||||
@@ -139,6 +158,14 @@ static int test_ssl_cipher(MYSQL *unused)
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
rc= mysql_query(my, "SHOW session status like 'Ssl_version'");
|
||||
check_mysql_rc(rc, my);
|
||||
res= mysql_store_result(my);
|
||||
row= mysql_fetch_row(res);
|
||||
diag("%s: %s", row[0], row[1]);
|
||||
diag("cipher: %s", mysql_get_ssl_cipher(my));
|
||||
mysql_free_result(res);
|
||||
|
||||
FAIL_IF(check_cipher(my) != 0, "Invalid cipher");
|
||||
mysql_close(my);
|
||||
return OK;
|
||||
@@ -268,6 +295,7 @@ DWORD WINAPI ssl_thread(void *dummy)
|
||||
mysql_close(mysql);
|
||||
mysql_thread_end();
|
||||
pthread_exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
static int test_ssl_threads(MYSQL *mysql)
|
||||
@@ -291,6 +319,7 @@ static int test_ssl_threads(MYSQL *mysql)
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "INSERT into ssltest VALUES (0)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
pthread_mutex_init(&LOCK_test, NULL);
|
||||
|
||||
pthread_mutex_init(&LOCK_test, NULL);
|
||||
|
||||
@@ -478,7 +507,7 @@ static int test_conc50_3(MYSQL *my)
|
||||
|
||||
mysql_ssl_set(mysql, NULL, NULL, "@CMAKE_SOURCE_DIR@/unittest/libmariadb/certs/ca-cert.pem", NULL, NULL);
|
||||
|
||||
mysql_real_connect(mysql, hostname, "ssltest", NULL, schema,
|
||||
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0);
|
||||
diag("Error: %s<", mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql), "No error expected");
|
||||
@@ -640,12 +669,16 @@ static int test_conc_102(MYSQL *mysql)
|
||||
DWORD threads[50];
|
||||
#endif
|
||||
|
||||
if (check_skip_ssl())
|
||||
return SKIP;
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t_conc102");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "CREATE TABLE t_conc102 ( a int)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "INSERT INTO t_conc102 VALUES (0)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
pthread_mutex_init(&LOCK_test, NULL);
|
||||
|
||||
for (i=0; i < 50; i++)
|
||||
{
|
||||
@@ -665,6 +698,7 @@ static int test_conc_102(MYSQL *mysql)
|
||||
WaitForSingleObject(hthreads[i], INFINITE);
|
||||
#endif
|
||||
}
|
||||
pthread_mutex_destroy(&LOCK_test);
|
||||
rc= mysql_query(mysql, "SELECT a FROM t_conc102");
|
||||
check_mysql_rc(rc, mysql);
|
||||
res= mysql_store_result(mysql);
|
||||
@@ -699,10 +733,10 @@ static int test_ssl_fp(MYSQL *unused)
|
||||
|
||||
FAIL_IF(check_cipher(my) != 0, "Invalid cipher");
|
||||
|
||||
mysql_query(my, "SET @a:=1");
|
||||
rc= mysql_query(my, "SET @a:=1");
|
||||
check_mysql_rc(rc, my);
|
||||
|
||||
mysql_query(my, "SELECT @a");
|
||||
rc= mysql_query(my, "SELECT @a");
|
||||
check_mysql_rc(rc, my);
|
||||
|
||||
if ((res= mysql_store_result(my)))
|
||||
@@ -738,7 +772,33 @@ static int test_ssl_fp_list(MYSQL *unused)
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int test_ssl_version(MYSQL *mysql)
|
||||
{
|
||||
unsigned int iversion;
|
||||
char *version;
|
||||
MYSQL *my;
|
||||
|
||||
if (check_skip_ssl())
|
||||
return SKIP;
|
||||
|
||||
my= mysql_init(NULL);
|
||||
FAIL_IF(!my, "mysql_init() failed");
|
||||
|
||||
mysql_ssl_set(my,0, 0, "@CMAKE_SOURCE_DIR@/unittest/libmariadb/certs/ca-cert.pem", 0, 0);
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, ssluser, sslpw, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
diag("cipher: %s", mysql_get_ssl_cipher(my));
|
||||
mariadb_get_infov(my, MARIADB_CONNECTION_SSL_VERSION_ID, &iversion);
|
||||
diag("protocol: %d", iversion);
|
||||
mariadb_get_infov(my, MARIADB_CONNECTION_SSL_VERSION, &version);
|
||||
diag("protocol: %s", version);
|
||||
|
||||
mysql_close(my);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"test_ssl", test_ssl, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
@@ -757,9 +817,11 @@ struct my_tests_st my_tests[] = {
|
||||
{"test_ssl_cipher", test_ssl_cipher, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_multi_ssl_connections", test_multi_ssl_connections, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_conc_102", test_conc_102, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_ssl_version", test_ssl_version, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_ssl_threads", test_ssl_threads, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
#ifndef HAVE_SCHANNEL
|
||||
{"test_password_protected", test_password_protected, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
|
||||
#endif
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
67
unittest/libmariadb/t_aurora.c
Normal file
67
unittest/libmariadb/t_aurora.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
*/
|
||||
|
||||
#include "my_test.h"
|
||||
|
||||
static int aurora1(MYSQL *mysql)
|
||||
{
|
||||
int rc;
|
||||
my_bool read_only= 1;
|
||||
char *primary, *replica;
|
||||
MYSQL_RES *res;
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "CREATE TABLE t1 (a int, b varchar(20))");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1, 'foo'), (2, 'bar')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
primary= mysql->host;
|
||||
diag("primary: %s", primary);
|
||||
|
||||
mysql_options(mysql, MARIADB_OPT_CONNECTION_READ_ONLY, &read_only);
|
||||
|
||||
/* ensure, that this is a replica, so INSERT should fail */
|
||||
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (3, 'error')");
|
||||
if (rc)
|
||||
diag("Expected error: %s", mysql_error(mysql));
|
||||
|
||||
rc= mysql_query(mysql, "SELECT a, b FROM t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
res= mysql_store_result(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);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"aurora1", aurora1, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
mysql_library_init(0,0,NULL);
|
||||
|
||||
if (argc > 1)
|
||||
get_options(argc, argv);
|
||||
|
||||
get_envvars();
|
||||
|
||||
run_tests(my_tests);
|
||||
|
||||
mysql_server_end();
|
||||
return(exit_status());
|
||||
}
|
Reference in New Issue
Block a user