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

Fix dbug crash in mysql_server_end

This commit is contained in:
Georg Richter
2013-03-07 13:56:14 +01:00
parent de21c953e9
commit 5726b74cbd
4 changed files with 63 additions and 7 deletions

View File

@@ -707,8 +707,8 @@ char ***_sframep_ __attribute__((unused)))
int save_errno=errno; int save_errno=errno;
if (!init_done) if (!init_done)
_db_push_ (_DBUG_START_CONDITION_); _db_push_ (_DBUG_START_CONDITION_);
state=code_state(); if(!(state=code_state()))
return;
*_sfunc_ = state->func; *_sfunc_ = state->func;
*_sfile_ = state->file; *_sfile_ = state->file;
state->func =(char*) _func_; state->func =(char*) _func_;

View File

@@ -3052,10 +3052,6 @@ void STDCALL mysql_server_end()
if (my_init_done) if (my_init_done)
my_end(0); my_end(0);
#ifdef THREAD
else
mysql_thread_end();
#endif
mysql_client_init= 0; mysql_client_init= 0;
my_init_done= 0; my_init_done= 0;
} }

View File

@@ -21,7 +21,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/unittest/mytap) ${CMAKE_SOURCE_DIR}/unittest/mytap)
SET(API_TESTS "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs" SET(API_TESTS "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs"
"sp" "result" "connection" "misc" "ssl" "ps_new" "sqlite3") "sp" "result" "connection" "misc" "ssl" "ps_new" "sqlite3" "thread")
FOREACH(API_TEST ${API_TESTS}) FOREACH(API_TEST ${API_TESTS})
ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c) ADD_EXECUTABLE(${API_TEST} ${API_TEST}.c)

View File

@@ -0,0 +1,60 @@
/*
*/
#include "my_test.h"
static int basic_connect(MYSQL *mysql)
{
MYSQL_ROW row;
MYSQL_RES *res;
MYSQL_FIELD *field;
int rc;
MYSQL *my= mysql_init(NULL);
FAIL_IF(!my, "mysql_init() failed");
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(my, "SELECT @@version");
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)
{
FAIL_IF(mysql_num_fields(res) != 1, "Got the wrong number of fields");
}
FAIL_IF(mysql_errno(my), mysql_error(my));
mysql_free_result(res);
mysql_close(my);
return OK;
}
struct my_tests_st my_tests[] = {
{"basic_connect", basic_connect, TEST_CONNECTION_NONE, 0, NULL, NULL},
{NULL, NULL, 0, 0, NULL, NULL}
};
int main(int argc, char **argv)
{
mysql_library_init(0,0,NULL);
mysql_thread_init();
mysql_thread_end();
mysql_library_end();
if (argc > 1)
get_options(argc, argv);
get_envvars();
run_tests(my_tests);
return(exit_status());
}