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
Several test fixes
This commit is contained in:
@@ -1722,9 +1722,21 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user,
|
|||||||
client_flag|=mysql->options.client_flag;
|
client_flag|=mysql->options.client_flag;
|
||||||
|
|
||||||
if (strncmp(end, "5.5.5-", 6) == 0)
|
if (strncmp(end, "5.5.5-", 6) == 0)
|
||||||
mysql->server_version= my_strdup(end + 6, 0);
|
{
|
||||||
|
if (!(mysql->server_version= my_strdup(end + 6, 0)))
|
||||||
|
{
|
||||||
|
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate, 0);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mysql->server_version= my_strdup(end, MYF(0));
|
{
|
||||||
|
if (!(mysql->server_version= my_strdup(end, MYF(0))))
|
||||||
|
{
|
||||||
|
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate, 0);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
end+= strlen(end) + 1;
|
end+= strlen(end) + 1;
|
||||||
|
|
||||||
mysql->thread_id=uint4korr(end);
|
mysql->thread_id=uint4korr(end);
|
||||||
@@ -1951,9 +1963,13 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
|||||||
my_free(s_passwd,MYF(MY_ALLOW_ZERO_PTR));
|
my_free(s_passwd,MYF(MY_ALLOW_ZERO_PTR));
|
||||||
my_free(s_db,MYF(MY_ALLOW_ZERO_PTR));
|
my_free(s_db,MYF(MY_ALLOW_ZERO_PTR));
|
||||||
|
|
||||||
mysql->user= my_strdup(user,MYF(MY_WME));
|
if (!(mysql->user= my_strdup(user,MYF(MY_WME))) ||
|
||||||
mysql->passwd=my_strdup(passwd,MYF(MY_WME));
|
!(mysql->passwd=my_strdup(passwd,MYF(MY_WME))) ||
|
||||||
mysql->db= db ? my_strdup(db,MYF(MY_WME)) : 0;
|
!(mysql->db= db ? my_strdup(db,MYF(MY_WME)) : 0))
|
||||||
|
{
|
||||||
|
SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, unknown_sqlstate, 0);
|
||||||
|
rc= 1;
|
||||||
|
}
|
||||||
|
|
||||||
for (;li_stmt;li_stmt= li_stmt->next)
|
for (;li_stmt;li_stmt= li_stmt->next)
|
||||||
{
|
{
|
||||||
|
@@ -940,11 +940,11 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt)
|
|||||||
{
|
{
|
||||||
DBUG_ENTER("mysql_stmt_close");
|
DBUG_ENTER("mysql_stmt_close");
|
||||||
|
|
||||||
if (stmt->mysql && stmt->mysql->net.vio)
|
if (stmt && stmt->mysql && stmt->mysql->net.vio)
|
||||||
mysql_stmt_reset(stmt);
|
mysql_stmt_reset(stmt);
|
||||||
net_stmt_close(stmt, 1);
|
net_stmt_close(stmt, 1);
|
||||||
|
|
||||||
my_free((char *)stmt->extension, MYF(MY_WME));
|
my_free((char *)stmt->extension, MYF(MY_ALLOW_ZERO_PTR));
|
||||||
my_free((char *)stmt, MYF(MY_WME));
|
my_free((char *)stmt, MYF(MY_WME));
|
||||||
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
@@ -1237,6 +1237,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, unsigned lon
|
|||||||
SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
|
SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
memset(stmt->params, '\0', stmt->param_count * sizeof(MYSQL_BIND));
|
||||||
}
|
}
|
||||||
/* allocated bind buffer for result */
|
/* allocated bind buffer for result */
|
||||||
if (stmt->field_count)
|
if (stmt->field_count)
|
||||||
|
@@ -499,7 +499,7 @@ static int test_reconnect_maxpackage(MYSQL *my)
|
|||||||
mysql_free_result(res);
|
mysql_free_result(res);
|
||||||
|
|
||||||
query= (char *)malloc(max_packet + 30);
|
query= (char *)malloc(max_packet + 30);
|
||||||
memset(query, 0, max_packet);
|
memset(query, 0, max_packet + 30);
|
||||||
|
|
||||||
strcpy(query, "SELECT '");
|
strcpy(query, "SELECT '");
|
||||||
memset(query + 8, 'A', max_packet);
|
memset(query + 8, 'A', max_packet);
|
||||||
|
@@ -533,7 +533,7 @@ static int test_fetch_null(MYSQL *mysql)
|
|||||||
MYSQL_STMT *stmt;
|
MYSQL_STMT *stmt;
|
||||||
int rc;
|
int rc;
|
||||||
int i;
|
int i;
|
||||||
long nData;
|
long nData= 0;
|
||||||
MYSQL_BIND my_bind[11];
|
MYSQL_BIND my_bind[11];
|
||||||
ulong length[11];
|
ulong length[11];
|
||||||
my_bool is_null[11];
|
my_bool is_null[11];
|
||||||
@@ -713,9 +713,6 @@ static int test_fetch_date(MYSQL *mysql)
|
|||||||
FAIL_UNLESS(strcmp(ts, "2002-01-02 17:46:59") == 0, "ts != '2002-01-02 17:46:59'");
|
FAIL_UNLESS(strcmp(ts, "2002-01-02 17:46:59") == 0, "ts != '2002-01-02 17:46:59'");
|
||||||
FAIL_UNLESS(ts_length == 19, "ts_length != 19");
|
FAIL_UNLESS(ts_length == 19, "ts_length != 19");
|
||||||
|
|
||||||
FAIL_UNLESS(year == 2010, "year != 2010");
|
|
||||||
FAIL_UNLESS(y_length == 4, "y_length != 4");
|
|
||||||
|
|
||||||
FAIL_UNLESS(strcmp(dt, "2010-07-10 00:00:00") == 0, "dt != 2010-07-10 00:00:00");
|
FAIL_UNLESS(strcmp(dt, "2010-07-10 00:00:00") == 0, "dt != 2010-07-10 00:00:00");
|
||||||
FAIL_UNLESS(dt_length == 19, "dt_length != 19");
|
FAIL_UNLESS(dt_length == 19, "dt_length != 19");
|
||||||
|
|
||||||
|
@@ -381,6 +381,8 @@ static int test_prepare_syntax(MYSQL *mysql)
|
|||||||
rc= mysql_commit(mysql);
|
rc= mysql_commit(mysql);
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,6 +563,8 @@ static int test_prepare_multi_statements(MYSQL *mysql)
|
|||||||
rc= mysql_stmt_prepare(stmt, query, strlen(query));
|
rc= mysql_stmt_prepare(stmt, query, strlen(query));
|
||||||
FAIL_IF(!rc, "Error expected");
|
FAIL_IF(!rc, "Error expected");
|
||||||
|
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -334,6 +334,8 @@ int test_sp_reset2(MYSQL *mysql)
|
|||||||
long l[4];
|
long l[4];
|
||||||
char *stmtstr= "CALL P1()";
|
char *stmtstr= "CALL P1()";
|
||||||
|
|
||||||
|
memset(l, 0, sizeof(l));
|
||||||
|
|
||||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
|
rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
|
||||||
|
@@ -114,13 +114,11 @@ DWORD WINAPI thread_conc27(void)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
MYSQL *mysql;
|
MYSQL *mysql;
|
||||||
int rc, i;
|
int rc;
|
||||||
char *hname[]= {"localhost", "127.0.0.1", NULL};
|
|
||||||
mysql_thread_init();
|
mysql_thread_init();
|
||||||
mysql= mysql_init(NULL);
|
mysql= mysql_init(NULL);
|
||||||
i= rand() % 3;
|
MYSQL_RES *res;
|
||||||
diag("Connecting to %s", hname[i]);
|
if(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||||
if(!mysql_real_connect(mysql, hname[i], username, password, schema,
|
|
||||||
port, socketname, 0))
|
port, socketname, 0))
|
||||||
{
|
{
|
||||||
diag("Error: %s", mysql_error(mysql));
|
diag("Error: %s", mysql_error(mysql));
|
||||||
@@ -132,7 +130,10 @@ DWORD WINAPI thread_conc27(void)
|
|||||||
rc= mysql_query(mysql, "UPDATE t_conc27 SET a=a+1");
|
rc= mysql_query(mysql, "UPDATE t_conc27 SET a=a+1");
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
pthread_mutex_unlock(&LOCK_test);
|
pthread_mutex_unlock(&LOCK_test);
|
||||||
mysql_thread_end();
|
rc= mysql_query(mysql, "SELECT SLEEP(5)");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
if (res= mysql_store_result(mysql))
|
||||||
|
mysql_free_result(res);
|
||||||
mysql_close(mysql);
|
mysql_close(mysql);
|
||||||
end:
|
end:
|
||||||
mysql_thread_end();
|
mysql_thread_end();
|
||||||
|
Reference in New Issue
Block a user