You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Reworked compressed and protocol implementation,
including fixes for conc-31 and conc-34 - Added win64 fixes in protocol (changed ulong to size_t) modified: include/my_sys.h include/mysql_com.h include/violite.h libmariadb/libmariadb.c libmariadb/my_compress.c libmariadb/my_stmt.c libmariadb/my_thr_init.c libmariadb/net.c libmariadb/violite.c unittest/libmariadb/basic-t.c unittest/libmariadb/charset.c unittest/libmariadb/thread.c unknown: xx libmariadb/libmariadb.so.1 mariadb_config/mariadb_config mariadb_config/mariadb_config.c unittest/libmariadb/basic-t unittest/libmariadb/charset unittest/libmariadb/connection unittest/libmariadb/cursor unittest/libmariadb/errors unittest/libmariadb/fetch unittest/libmariadb/logs unittest/libmariadb/misc unittest/libmariadb/ps unittest/libmariadb/ps_bugs unittest/libmariadb/ps_new unittest/libmariadb/result unittest/libmariadb/sp unittest/libmariadb/sqlite3 unittest/libmariadb/ssl unittest/libmariadb/thread unittest/libmariadb/view
This commit is contained in:
@@ -36,22 +36,105 @@ static int basic_connect(MYSQL *mysql)
|
||||
return OK;
|
||||
}
|
||||
|
||||
pthread_mutex_t LOCK_test;
|
||||
|
||||
#ifndef _WIN32
|
||||
int thread_conc27(void);
|
||||
#else
|
||||
DWORD WINAPI thread_conc27(void);
|
||||
#endif
|
||||
|
||||
#define THREAD_NUM 100
|
||||
|
||||
static int test_conc_27(MYSQL *mysql)
|
||||
{
|
||||
|
||||
int rc;
|
||||
int i;
|
||||
MYSQL_ROW row;
|
||||
MYSQL_RES *res;
|
||||
#ifndef _WIN32
|
||||
pthread_t threads[THREAD_NUM];
|
||||
#else
|
||||
HANDLE hthreads[THREAD_NUM];
|
||||
DWORD threads[THREAD_NUM];
|
||||
#endif
|
||||
|
||||
mysql_thread_init();
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t_conc27");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "SET @a:=1");
|
||||
rc= mysql_query(mysql, "CREATE TABLE t_conc27(a int)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(mysql, "INSERT INTO t_conc27 VALUES(0)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
pthread_mutex_init(&LOCK_test, NULL);
|
||||
for (i=0; i < THREAD_NUM; i++)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
pthread_create(&threads[i], NULL, (void *)thread_conc27, NULL);
|
||||
#else
|
||||
hthreads[i]= CreateThread(NULL, 0, thread_conc27, NULL, 0, &threads[i]);
|
||||
if (hthreads[i]==NULL)
|
||||
diag("error while starting thread");
|
||||
#endif
|
||||
}
|
||||
for (i=0; i < THREAD_NUM; i++)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
pthread_join(threads[i], NULL);
|
||||
#else
|
||||
WaitForSingleObject(hthreads[i], INFINITE);
|
||||
#endif
|
||||
}
|
||||
pthread_mutex_destroy(&LOCK_test);
|
||||
|
||||
rc= mysql_query(mysql, "SELECT a FROM t_conc27");
|
||||
check_mysql_rc(rc,mysql);
|
||||
|
||||
mysql_thread_end();
|
||||
rc= mysql_query(mysql, "SET @a:=2");
|
||||
check_mysql_rc(rc,mysql);
|
||||
mysql_thread_end();
|
||||
res= mysql_store_result(mysql);
|
||||
FAIL_IF(!res, "invalid result");
|
||||
|
||||
row= mysql_fetch_row(res);
|
||||
FAIL_IF(!row, "can't fetch row");
|
||||
|
||||
diag("row=%s", row[0]);
|
||||
FAIL_IF(atoi(row[0]) != 100, "expected value 100");
|
||||
mysql_free_result(res);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
int thread_conc27(void)
|
||||
#else
|
||||
DWORD WINAPI thread_conc27(void)
|
||||
#endif
|
||||
{
|
||||
MYSQL *mysql;
|
||||
int rc;
|
||||
mysql_thread_init();
|
||||
mysql= mysql_init(NULL);
|
||||
if(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0))
|
||||
{
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
mysql_close(mysql);
|
||||
mysql_thread_end();
|
||||
goto end;
|
||||
}
|
||||
pthread_mutex_lock(&LOCK_test);
|
||||
rc= mysql_query(mysql, "UPDATE t_conc27 SET a=a+1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
pthread_mutex_unlock(&LOCK_test);
|
||||
mysql_close(mysql);
|
||||
mysql_thread_end();
|
||||
end:
|
||||
mysql_thread_end();
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"basic_connect", basic_connect, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
{"test_conc_27", test_conc_27, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
|
Reference in New Issue
Block a user