1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

Added support for indicator variables

Fixed windows compilation bug
This commit is contained in:
Georg Richter
2016-07-08 12:51:26 +02:00
parent ba0ed073fd
commit ecf26f7e6f
10 changed files with 133 additions and 74 deletions

View File

@@ -26,7 +26,8 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include
ADD_DEFINITIONS(-DLIBMARIADB)
SET(API_TESTS "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs"
"sp" "result" "connection" "misc" "ps_new" "sqlite3" "thread" "features-10_2" )
"sp" "result" "connection" "misc" "ps_new" "sqlite3" "thread" "features-10_2"
"bulk1" )
IF(WITH_DYNCOL)
SET(API_TESTS ${API_TESTS} "dyncol")
ENDIF()

View File

@@ -534,7 +534,7 @@ 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: %ld", res);
diag("res: %lld", res);
FAIL_UNLESS(res == 20, "");
/* If first autogenerated number fails and 2nd works: */
rc= mysql_query(mysql, "drop table t2");

View File

@@ -712,7 +712,7 @@ static int test_utf16_utf32_noboms(MYSQL *mysql)
rc= mariadb_convert_string(in_string[UTF8], &in_len, csinfo[UTF8], buffer, &out_len, csinfo[i], &error);
FAIL_IF(rc==-1, "Conversion failed");
diag("rc=%d oct_len: %d", rc, in_oct_len[i]);
diag("rc=%lu oct_len: %lu", rc, in_oct_len[i]);
FAIL_IF(rc != in_oct_len[i], "Incorrect number of written bytes");
if (memcmp(buffer, in_string[i], rc) != 0)

View File

@@ -921,7 +921,7 @@ static int test_sess_track_db(MYSQL *mysql)
if (!(mysql->server_capabilities & CLIENT_SESSION_TRACKING))
{
diag("Server doesn't support session tracking (cap=%u)", mysql->server_capabilities);
diag("Server doesn't support session tracking (cap=%llu)", mysql->server_capabilities);
return SKIP;
}
@@ -946,7 +946,7 @@ static int test_sess_track_db(MYSQL *mysql)
FAIL_IF(strcmp(mysql->charset->csname, "utf8"), "Expected charset 'utf8'");
if (!mysql_session_track_get_first(mysql, SESSION_TRACK_SYSTEM_VARIABLES, &data, &len))
do {
printf("# SESSION_TRACK_VARIABLES: %*.*s\n", len, len, data);
printf("# SESSION_TRACK_VARIABLES: %*.*s\n", (int)len, (int)len, data);
} while (!mysql_session_track_get_next(mysql, SESSION_TRACK_SYSTEM_VARIABLES, &data, &len));
rc= mysql_query(mysql, "SET NAMES latin1");
@@ -969,7 +969,7 @@ static int test_sess_track_db(MYSQL *mysql)
if (!mysql_session_track_get_first(mysql, SESSION_TRACK_SYSTEM_VARIABLES, &data, &len))
do {
printf("# SESSION_TRACK_VARIABLES: %*.*s\n", len, len, data);
printf("# SESSION_TRACK_VARIABLES: %*.*s\n", (int)len, (int)len, data);
} while (!mysql_session_track_get_next(mysql, SESSION_TRACK_SYSTEM_VARIABLES, &data, &len));
return OK;

View File

@@ -61,7 +61,7 @@ static int com_multi_1(MYSQL *mysql)
rc= mysql_query(mysql, "select 1");
check_mysql_rc(rc, mysql);
res= mysql_store_result(mysql);
FAIL_UNLESS(res, "2 simple query no result");
FAIL_UNLESS(res != NULL, "2 simple query no result");
mysql_free_result(res);
/* question: how will result sets look like ? */
@@ -211,9 +211,12 @@ static int com_multi_ps2(MYSQL *mysql)
return OK;
}
static int execute_direct(MYSQL *mysql)
{
long rc= 0, i= 0;
int rc= 0;
long i= 0;
MYSQL_STMT *stmt;
MYSQL_BIND bind;
unsigned int param_count= 1;
@@ -261,12 +264,53 @@ static int execute_direct(MYSQL *mysql)
return OK;
}
static int execute_direct_example(MYSQL *mysql)
{
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
MYSQL_BIND bind[2];
int intval= 1;
int param_count= 2;
char *strval= "execute_direct_example";
/* Direct execution without parameters */
if (mariadb_stmt_execute_direct(stmt, "DROP TABLE IF EXISTS execute_direct", -1))
goto error;
if (mariadb_stmt_execute_direct(stmt, "CREATE TABLE execute_direct (a int, b varchar(20))", -1))
goto error;
memset(bind, 0, sizeof(MYSQL_BIND) * 2);
bind[0].buffer_type= MYSQL_TYPE_SHORT;
bind[0].buffer= &intval;
bind[1].buffer_type= MYSQL_TYPE_STRING;
bind[1].buffer= strval;
bind[1].buffer_length= strlen(strval);
/* set number of parameters */
if (mysql_stmt_attr_set(stmt, STMT_ATTR_PREBIND_PARAMS, &param_count))
goto error;
/* bind parameters */
if (mysql_stmt_bind_param(stmt, bind))
goto error;
if (mariadb_stmt_execute_direct(stmt, "INSERT INTO execute_direct VALUES (?,?)", -1))
goto error;
mysql_stmt_close(stmt);
return OK;
error:
printf("Error: %s\n", mysql_stmt_error(stmt));
mysql_stmt_close(stmt);
return FAIL;
}
struct my_tests_st my_tests[] = {
{"com_multi_1", com_multi_1, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"com_multi_2", com_multi_2, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"com_multi_ps1", com_multi_ps1, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"com_multi_ps2", com_multi_ps2, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"execute_direct", execute_direct, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"execute_direct_example", execute_direct_example, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{NULL, NULL, 0, 0, NULL, NULL}
};

View File

@@ -1054,16 +1054,16 @@ static int test_get_info(MYSQL *mysql)
rc= mariadb_get_infov(mysql, MARIADB_MAX_ALLOWED_PACKET, &sval);
FAIL_IF(rc, "mysql_get_info failed");
diag("max_allowed_packet: %d", sval);
diag("max_allowed_packet: %lu", sval);
rc= mariadb_get_infov(mysql, MARIADB_NET_BUFFER_LENGTH, &sval);
FAIL_IF(rc, "mysql_get_info failed");
diag("net_buffer_length: %d", sval);
diag("net_buffer_length: %lu", sval);
rc= mariadb_get_infov(mysql, MARIADB_CLIENT_VERSION_ID, &sval);
FAIL_IF(rc, "mysql_get_info failed");
diag("client_version_id: %d", sval);
diag("client_version_id: %lu", 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);
diag("server_version_id: %lu", sval);
rc= mariadb_get_infov(mysql, MARIADB_CONNECTION_MARIADB_CHARSET_INFO, &cs);
FAIL_IF(rc, "mysql_get_info failed");
diag("charset name: %s", cs.csname);

View File

@@ -43,7 +43,7 @@ static int aurora1(MYSQL *my)
res= mysql_store_result(mysql);
diag("Num_rows: %d", mysql_num_rows(res));
diag("Num_rows: %lld", mysql_num_rows(res));
mysql_free_result(res);
mariadb_get_infov(mysql, MARIADB_CONNECTION_SCHEMA, &my_schema);
@@ -127,7 +127,7 @@ static int test_reconnect(MYSQL *my)
if ((res= mysql_store_result(mysql)))
{
diag("num_rows: %d", mysql_num_rows(res));
diag("num_rows: %lld", mysql_num_rows(res));
mysql_free_result(res);
}