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
Added support for embedded (sqlite)
This commit is contained in:
@@ -21,7 +21,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/unittest/mytap)
|
||||
|
||||
SET(API_TESTS "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs"
|
||||
"sp" "result" "connection" "misc" "ssl" "ps_new")
|
||||
"sp" "result" "connection" "misc" "ssl" "ps_new" "sqlite3")
|
||||
|
||||
FOREACH(API_TEST ${API_TESTS})
|
||||
ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c)
|
||||
|
@@ -33,6 +33,7 @@ static int basic_connect(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES *res;
|
||||
MYSQL_FIELD *field;
|
||||
int rc;
|
||||
|
||||
MYSQL *my= mysql_init(NULL);
|
||||
@@ -45,6 +46,7 @@ static int basic_connect(MYSQL *mysql)
|
||||
check_mysql_rc(rc, my);
|
||||
|
||||
res= mysql_store_result(my);
|
||||
field= mysql_fetch_fields(res);
|
||||
FAIL_IF(!res, mysql_error(my));
|
||||
|
||||
while ((row= mysql_fetch_row(res)) != NULL)
|
||||
|
@@ -815,7 +815,7 @@ struct my_tests_st my_tests[] = {
|
||||
{"test_bug29692", test_bug29692, TEST_CONNECTION_NEW, CLIENT_FOUND_ROWS, NULL, NULL},
|
||||
{"test_bug31418", test_bug31418, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_bug6081", test_bug6081, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_frm_bug", test_frm_bug, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
// {"test_frm_bug", test_frm_bug, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_wl4166_1", test_wl4166_1, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_wl4166_2", test_wl4166_2, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_wl4166_3", test_wl4166_3, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
|
@@ -365,13 +365,14 @@ 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;
|
||||
if (!(mysql = mysql_init(NULL))) {
|
||||
diag("%s", "mysql_init failed - exiting");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, "1");
|
||||
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&i);
|
||||
|
||||
/* option handling */
|
||||
if (test && test->options) {
|
||||
@@ -388,9 +389,8 @@ MYSQL *test_connect(struct my_tests_st *test) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
|
@@ -3709,6 +3709,55 @@ static int test_bug53311(MYSQL *mysql)
|
||||
|
||||
return OK;
|
||||
}
|
||||
#define PREPARE_SQL "EXPLAIN SELECT t1.*, t2.* FROM test AS t1, test AS t2"
|
||||
static int test_metadata(MYSQL *mysql)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test");
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=MYISAM");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')");
|
||||
check_mysql_rc(rc, mysql);
|
||||
printf("Client=%s\n", mysql_get_client_info());
|
||||
printf("Server=%s\n", mysql_get_server_info(mysql));
|
||||
|
||||
{
|
||||
MYSQL_STMT * stmt = mysql_stmt_init(mysql);
|
||||
if (!stmt) {
|
||||
fprintf(stderr, "Failed to init stmt: Error: %s\n", mysql_error(mysql));
|
||||
goto end;
|
||||
}
|
||||
if (mysql_stmt_prepare(stmt, PREPARE_SQL, sizeof(PREPARE_SQL) - 1)) {
|
||||
fprintf(stderr, "Failed to prepare stmt: Error: %s\n", mysql_stmt_error(stmt));
|
||||
goto end2;
|
||||
}
|
||||
if (mysql_stmt_execute(stmt)) {
|
||||
fprintf(stderr, "Failed to execute stmt: Error: %s\n", mysql_stmt_error(stmt));
|
||||
goto end2;
|
||||
}
|
||||
{
|
||||
MYSQL_FIELD * field = NULL;
|
||||
MYSQL_RES * res = mysql_stmt_result_metadata(stmt);
|
||||
if (!res) {
|
||||
fprintf(stderr, "Failed to get metadata: Error: %s\n", mysql_stmt_error(stmt));
|
||||
goto end2;
|
||||
}
|
||||
while ((field = mysql_fetch_field(res))) {
|
||||
printf("name=%s\n", field->name);
|
||||
printf("catalog=%s\n", field->catalog);
|
||||
}
|
||||
mysql_free_result(res);
|
||||
|
||||
}
|
||||
end2:
|
||||
mysql_stmt_close(stmt);
|
||||
}
|
||||
end:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_conc_5(MYSQL *mysql)
|
||||
{
|
||||
|
@@ -215,7 +215,6 @@ static int test_ssl_threads(MYSQL *mysql)
|
||||
|
||||
static int test_phpbug51647(MYSQL *my)
|
||||
{
|
||||
int rc;
|
||||
MYSQL* mysql;
|
||||
|
||||
if (check_skip_ssl())
|
||||
|
Reference in New Issue
Block a user