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 remote-tracking branch 'origin/3.4' into 3.4-serg
This commit is contained in:
@@ -31,7 +31,9 @@ IF(WITH_DYNCOL)
|
||||
SET(API_TESTS ${API_TESTS} "dyncol")
|
||||
ENDIF()
|
||||
|
||||
SET(API_TESTS ${API_TESTS} "async")
|
||||
IF(NOT WIN32)
|
||||
SET(API_TESTS ${API_TESTS} "async")
|
||||
ENDIF()
|
||||
|
||||
#exclude following tests from ctests, since we need to run them manually with different credentials
|
||||
SET(MANUAL_TESTS "t_conc173" "rpl_api")
|
||||
|
@@ -83,8 +83,8 @@ static int bulk1(MYSQL *mysql)
|
||||
|
||||
/* allocate memory */
|
||||
buffer= calloc(TEST_ARRAY_SIZE, sizeof(char *));
|
||||
lengths= (unsigned long *)calloc(sizeof(long), TEST_ARRAY_SIZE);
|
||||
vals= (unsigned int *)calloc(sizeof(int), TEST_ARRAY_SIZE);
|
||||
lengths= calloc(TEST_ARRAY_SIZE, sizeof *lengths);
|
||||
vals= calloc(TEST_ARRAY_SIZE, sizeof *vals);
|
||||
|
||||
for (i=0; i < TEST_ARRAY_SIZE; i++)
|
||||
{
|
||||
|
@@ -1380,7 +1380,6 @@ static int test_conc276(MYSQL *unused __attribute__((unused)))
|
||||
return FAIL;
|
||||
}
|
||||
diag("Cipher in use: %s", mysql_get_ssl_cipher(mysql));
|
||||
|
||||
rc= mariadb_reconnect(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -2309,7 +2308,77 @@ static int test_conc632(MYSQL *my __attribute__((unused)))
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int test_x509(MYSQL *my __attribute__((unused)))
|
||||
{
|
||||
MYSQL *mysql1, *mysql2;
|
||||
my_bool val= 1;
|
||||
my_bool verify= 0;
|
||||
char fp[65];
|
||||
MARIADB_X509_INFO *info;
|
||||
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
mysql1= mysql_init(NULL);
|
||||
mysql2= mysql_init(NULL);
|
||||
|
||||
mysql_options(mysql1, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||
mysql_options(mysql2, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||
|
||||
mysql_options(mysql1, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &verify);
|
||||
if (!(my_test_connect(mysql1, hostname, username,
|
||||
password, schema, port,
|
||||
socketname, 0)))
|
||||
{
|
||||
diag("connection failed");
|
||||
return FAIL;
|
||||
}
|
||||
mariadb_get_infov(mysql1, MARIADB_TLS_PEER_CERT_INFO, &info);
|
||||
memset(fp, 0, 65);
|
||||
diag("fingerprint: %s", info->fingerprint);
|
||||
mysql_options(mysql2, MARIADB_OPT_TLS_PEER_FP, info->fingerprint);
|
||||
if (!(my_test_connect(mysql2, hostname, username,
|
||||
password, schema, port,
|
||||
socketname, 0)))
|
||||
{
|
||||
diag("connection failed");
|
||||
return FAIL;
|
||||
}
|
||||
mariadb_get_infov(mysql2, MARIADB_TLS_PEER_CERT_INFO, &info);
|
||||
FAIL_IF(info->verify_mode != MARIADB_VERIFY_FINGERPRINT, "Fingerprint verification expected");
|
||||
|
||||
mysql_close(mysql1);
|
||||
mysql_close(mysql2);
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int test_conc505(MYSQL *my __attribute__((unused)))
|
||||
{
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
|
||||
#define CLIENT_DEPRECATE_EOF (1ULL << 24)
|
||||
|
||||
if (my_test_connect(mysql, hostname, username, password, schema, port, socketname, CLIENT_DEPRECATE_EOF))
|
||||
{
|
||||
diag("Error expected: Invalid client flag");
|
||||
mysql_close(mysql);
|
||||
return FAIL;
|
||||
}
|
||||
diag("Error (expected): %s", mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql) != CR_INVALID_CLIENT_FLAG, "Wrong error number");
|
||||
if (!my_test_connect(mysql, hostname, username, password, schema, port, socketname, CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS))
|
||||
{
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
mysql_close(mysql);
|
||||
return OK;
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"test_x509", test_x509, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_conc505", test_conc505, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_conc632", test_conc632, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_status_callback", test_status_callback, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_conc365", test_conc365, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
|
@@ -76,7 +76,7 @@ if (IS_SKYSQL(hostname)) \
|
||||
#endif
|
||||
|
||||
#define SKIP_TLS \
|
||||
if (force_tls)\
|
||||
if (force_tls || fingerprint[0])\
|
||||
{\
|
||||
diag("Test doesn't work with TLS");\
|
||||
return SKIP;\
|
||||
@@ -224,6 +224,7 @@ MYSQL *my_test_connect(MYSQL *mysql,
|
||||
static const char *schema = 0;
|
||||
static char *hostname = 0;
|
||||
static char *password = 0;
|
||||
static char fingerprint[65];
|
||||
static unsigned int port = 0;
|
||||
static unsigned int ssl_port = 0;
|
||||
static char *socketname = 0;
|
||||
@@ -656,7 +657,9 @@ MYSQL *my_test_connect(MYSQL *mysql,
|
||||
unsigned long clientflag)
|
||||
{
|
||||
if (force_tls)
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &force_tls);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &force_tls);
|
||||
if (fingerprint[0])
|
||||
mysql_options(mysql, MARIADB_OPT_SSL_FP, fingerprint);
|
||||
if (!mysql_real_connect(mysql, host, user, passwd, db, port, unix_socket, clientflag))
|
||||
{
|
||||
diag("error: %s", mysql_error(mysql));
|
||||
@@ -677,6 +680,8 @@ MYSQL *my_test_connect(MYSQL *mysql,
|
||||
void run_tests(struct my_tests_st *test) {
|
||||
int i, rc, total=0;
|
||||
MYSQL *mysql;
|
||||
my_bool verify= 0;
|
||||
MARIADB_X509_INFO *info= NULL;
|
||||
|
||||
while (test[total].function)
|
||||
total++;
|
||||
@@ -684,6 +689,7 @@ void run_tests(struct my_tests_st *test) {
|
||||
|
||||
/* display TLS stats */
|
||||
mysql= mysql_init(NULL);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &verify);
|
||||
mysql_ssl_set(mysql, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0))
|
||||
@@ -691,7 +697,7 @@ void run_tests(struct my_tests_st *test) {
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
BAIL_OUT("Can't establish TLS connection to server.");
|
||||
}
|
||||
|
||||
fingerprint[0]= 0;
|
||||
if (!mysql_query(mysql, "SHOW VARIABLES LIKE '%ssl%'"))
|
||||
{
|
||||
MYSQL_RES *res;
|
||||
@@ -704,8 +710,15 @@ void run_tests(struct my_tests_st *test) {
|
||||
while ((row= mysql_fetch_row(res)))
|
||||
diag("%s: %s", row[0], row[1]);
|
||||
mysql_free_result(res);
|
||||
diag("Cipher in use: %s", mysql_get_ssl_cipher(mysql));
|
||||
diag("--------------------");
|
||||
if (mysql_get_ssl_cipher(mysql))
|
||||
diag("Cipher in use: %s", mysql_get_ssl_cipher(mysql));
|
||||
mariadb_get_infov(mysql, MARIADB_TLS_PEER_CERT_INFO, &info);
|
||||
if (info)
|
||||
{
|
||||
strcpy(fingerprint, info->fingerprint);
|
||||
diag("Peer certificate fingerprint: %s", fingerprint);
|
||||
diag("--------------------");
|
||||
}
|
||||
}
|
||||
mysql_close(mysql);
|
||||
|
||||
|
@@ -5159,7 +5159,7 @@ static int test_maxparam(MYSQL *mysql)
|
||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||
MYSQL_BIND* bind;
|
||||
|
||||
bind = calloc(sizeof(MYSQL_BIND), 65535);
|
||||
bind = calloc(65535, sizeof *bind);
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -5741,7 +5741,77 @@ end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_conc667(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_STMT *stmt1, *stmt2;
|
||||
int rc;
|
||||
|
||||
stmt1= mysql_stmt_init(mysql);
|
||||
stmt2= mysql_stmt_init(mysql);
|
||||
|
||||
rc= mysql_stmt_prepare(stmt1, "SELECT 1", -1);
|
||||
check_stmt_rc(rc, stmt1);
|
||||
|
||||
rc= mysql_stmt_prepare(stmt2, "SELECT 2", -1);
|
||||
check_stmt_rc(rc, stmt2);
|
||||
|
||||
rc= mysql_stmt_execute(stmt1);
|
||||
check_stmt_rc(rc, stmt1);
|
||||
|
||||
rc= mysql_stmt_free_result(stmt2);
|
||||
FAIL_IF(!rc || mysql_stmt_errno(stmt2) != CR_STMT_NO_RESULT,
|
||||
"Expected CR_STMT_NO_RESULT");
|
||||
diag("Error (expected) %s", mysql_stmt_error(stmt2));
|
||||
|
||||
rc= mysql_stmt_reset(stmt2);
|
||||
FAIL_IF(!rc || mysql_stmt_errno(stmt2) != CR_COMMANDS_OUT_OF_SYNC,
|
||||
"Expected commands out of sync error");
|
||||
|
||||
rc= mysql_stmt_fetch(stmt1);
|
||||
check_stmt_rc(rc, stmt1);
|
||||
|
||||
mysql_stmt_free_result(stmt1);
|
||||
|
||||
rc= mysql_stmt_close(stmt1);
|
||||
check_stmt_rc(rc, stmt1);
|
||||
rc= mysql_stmt_close(stmt2);
|
||||
check_stmt_rc(rc, stmt2);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int test_conc683(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_STMT *stmt1, *stmt2;
|
||||
int rc;
|
||||
|
||||
stmt1= mysql_stmt_init(mysql);
|
||||
stmt2= mysql_stmt_init(mysql);
|
||||
|
||||
rc= mysql_stmt_prepare(stmt1, "SELECT 1 UNION SELECT 2", -1);
|
||||
check_stmt_rc(rc, stmt1);
|
||||
|
||||
rc= mysql_stmt_prepare(stmt2, "SELECT 1", -1);
|
||||
check_stmt_rc(rc, stmt2);
|
||||
|
||||
rc= mysql_stmt_execute(stmt1);
|
||||
check_stmt_rc(rc, stmt1);
|
||||
|
||||
rc= mysql_stmt_close(stmt2);
|
||||
FAIL_IF(!rc || mysql_stmt_errno(stmt2) != CR_COMMANDS_OUT_OF_SYNC,
|
||||
"Expected commands out of sync error");
|
||||
|
||||
rc= mysql_stmt_close(stmt1);
|
||||
check_stmt_rc(rc, stmt1);
|
||||
rc= mysql_stmt_close(stmt2);
|
||||
check_stmt_rc(rc, stmt2);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"test_conc683", test_conc683, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc667", test_conc667, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc633", test_conc633, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc623", test_conc623, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_conc627", test_conc627, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
|
@@ -72,6 +72,7 @@ static int test_rpl_async(MYSQL *my __attribute__((unused)))
|
||||
mysql_query(mysql, "SET @mariadb_slave_capability=4");
|
||||
mysql_query(mysql, "SET NAMES latin1");
|
||||
mysql_query(mysql, "SET @slave_gtid_strict_mode=1");
|
||||
mysql_query(mysql, "SET @master_heartbeat_period=10");
|
||||
mysql_query(mysql, "SET @slave_gtid_ignore_duplicates=1");
|
||||
mysql_query(mysql, "SET NAMES utf8");
|
||||
mysql_query(mysql, "SET @master_binlog_checksum= @@global.binlog_checksum");
|
||||
@@ -85,7 +86,7 @@ static int test_rpl_async(MYSQL *my __attribute__((unused)))
|
||||
/* We run rpl_api as very last test, too make sure
|
||||
binary log contains > 10000 events.
|
||||
*/
|
||||
while((event= mariadb_rpl_fetch(rpl, event)) && events < 10000)
|
||||
while((event= mariadb_rpl_fetch(rpl, event)) && event->event_type != HEARTBEAT_LOG_EVENT)
|
||||
{
|
||||
events++;
|
||||
}
|
||||
@@ -142,6 +143,7 @@ static int test_rpl_semisync(MYSQL *my __attribute__((unused)))
|
||||
mysql_query(mysql, "SET NAMES latin1");
|
||||
mysql_query(mysql, "SET @slave_gtid_strict_mode=1");
|
||||
mysql_query(mysql, "SET @slave_gtid_ignore_duplicates=1");
|
||||
mysql_query(mysql, "SET @master_heartbeat_period=10");
|
||||
mysql_query(mysql, "SET NAMES utf8");
|
||||
mysql_query(mysql, "SET @master_binlog_checksum= @@global.binlog_checksum");
|
||||
rpl->server_id= 12;
|
||||
@@ -161,10 +163,7 @@ static int test_rpl_semisync(MYSQL *my __attribute__((unused)))
|
||||
if (mariadb_rpl_open(rpl))
|
||||
return FAIL;
|
||||
|
||||
/* We run rpl_api as very last test, too make sure
|
||||
binary log contains > 10000 events.
|
||||
*/
|
||||
while((event= mariadb_rpl_fetch(rpl, event)) && events < 10000)
|
||||
while((event= mariadb_rpl_fetch(rpl, event)) && event->event_type != HEARTBEAT_LOG_EVENT)
|
||||
{
|
||||
events++;
|
||||
}
|
||||
@@ -341,7 +340,78 @@ static int test_conc592(MYSQL *my __attribute__((unused)))
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int test_conc689(MYSQL *my __attribute__((unused)))
|
||||
{
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
MARIADB_RPL_EVENT *event= NULL;
|
||||
MARIADB_RPL *rpl;
|
||||
int events= 0, rc;
|
||||
|
||||
SKIP_SKYSQL;
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
if (!my_test_connect(mysql, hostname, username,
|
||||
password, schema, port, socketname, 0))
|
||||
{
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
rc= mysql_query(mysql, "SELECT @@log_bin");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
result= mysql_store_result(mysql);
|
||||
row= mysql_fetch_row(result);
|
||||
if (!atoi(row[0]))
|
||||
rc= SKIP;
|
||||
mysql_free_result(result);
|
||||
|
||||
if (rc == SKIP)
|
||||
{
|
||||
diag("binary log disabled -> skip");
|
||||
mysql_close(mysql);
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
rpl = mariadb_rpl_init(mysql);
|
||||
|
||||
mysql_query(mysql, "SET @mariadb_slave_capability=4");
|
||||
mysql_query(mysql, "SET NAMES latin1");
|
||||
mysql_query(mysql, "SET @slave_gtid_strict_mode=1");
|
||||
mysql_query(mysql, "SET @master_heartbeat_period=10");
|
||||
mysql_query(mysql, "SET @slave_gtid_ignore_duplicates=1");
|
||||
mysql_query(mysql, "SET NAMES utf8");
|
||||
mysql_query(mysql, "SET @master_binlog_checksum= @@global.binlog_checksum");
|
||||
rpl->server_id= 12;
|
||||
rpl->start_position= 4;
|
||||
rpl->flags= MARIADB_RPL_BINLOG_SEND_ANNOTATE_ROWS;
|
||||
|
||||
if (mariadb_rpl_open(rpl))
|
||||
return FAIL;
|
||||
|
||||
/* We run rpl_api as very last test, too make sure
|
||||
binary log contains > 10000 events.
|
||||
*/
|
||||
while((event= mariadb_rpl_fetch(rpl, event)) && event->event_type != HEARTBEAT_LOG_EVENT)
|
||||
{
|
||||
events++;
|
||||
}
|
||||
FAIL_IF(event->event.heartbeat.filename.length == 0, "Invalid filename");
|
||||
mariadb_free_rpl_event(event);
|
||||
mariadb_rpl_close(rpl);
|
||||
mysql_close(mysql);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"test_conc689", test_conc689, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_conc592", test_conc592, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_rpl_async", test_rpl_async, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_rpl_semisync", test_rpl_semisync, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
|
Reference in New Issue
Block a user