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

Merge branch 'master' into serg-integr

This commit is contained in:
Vladislav Vaintroub
2016-09-12 11:47:14 +00:00
55 changed files with 772 additions and 587 deletions

View File

@@ -132,7 +132,7 @@ wait_for_mysql(MYSQL *mysql, int status)
#endif
}
static int async1(MYSQL *my)
static int async1(MYSQL *unused __attribute__((unused)))
{
int err= 0, rc;
MYSQL mysql, *ret;
@@ -211,7 +211,7 @@ static int async1(MYSQL *my)
return OK;
}
static int test_conc131(MYSQL *my)
static int test_conc131(MYSQL *unused __attribute__((unused)))
{
int rc;
/* this test needs to run under valgrind */
@@ -227,7 +227,7 @@ static int test_conc131(MYSQL *my)
return OK;
}
static int test_conc129(MYSQL *my)
static int test_conc129(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;

View File

@@ -40,7 +40,7 @@ static int test_conc75(MYSQL *my)
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS);
my_test_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS);
rc= mysql_query(mysql, "DROP TABLE IF EXISTS a");
check_mysql_rc(rc, mysql);
@@ -72,7 +72,7 @@ static int test_conc75(MYSQL *my)
}
static int test_conc74(MYSQL *my)
static int test_conc74(MYSQL *unused __attribute__((unused)))
{
int rc;
MYSQL *mysql;
@@ -80,7 +80,7 @@ static int test_conc74(MYSQL *my)
mysql= mysql_init(NULL);
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS))
if (!my_test_connect(mysql, hostname, username, password, schema, port, socketname, 0| CLIENT_MULTI_RESULTS | CLIENT_REMEMBER_OPTIONS))
{
diag("Error: %s", mysql_error(mysql));
mysql_close(mysql);
@@ -119,7 +119,7 @@ static int test_conc71(MYSQL *my)
mysql_options(mysql, MYSQL_INIT_COMMAND, "/*!40101 SET SQL_MODE='' */");
mysql_options(mysql, MYSQL_INIT_COMMAND, "/*!40101 set @@session.wait_timeout=28800 */");
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
diag("kill server");
@@ -149,7 +149,7 @@ static int test_conc70(MYSQL *my)
mysql_query(my, "SET global max_allowed_packet=1024*1024*22");
mysql_options(mysql, MYSQL_OPT_COMPRESS, (void *)1);
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
@@ -207,7 +207,7 @@ static int test_conc68(MYSQL *my)
mysql_query(my, "SET global max_allowed_packet=1024*1024*22");
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
@@ -247,7 +247,7 @@ static int test_conc68(MYSQL *my)
}
static int basic_connect(MYSQL *mysql)
static int basic_connect(MYSQL *unused __attribute__((unused)))
{
MYSQL_ROW row;
MYSQL_RES *res;
@@ -257,7 +257,7 @@ static int basic_connect(MYSQL *mysql)
MYSQL *my= mysql_init(NULL);
FAIL_IF(!my, "mysql_init() failed");
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
FAIL_IF(!my_test_connect(my, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(my, "SELECT @@version");
@@ -371,7 +371,7 @@ static int test_bug12001(MYSQL *mysql)
/* connection options */
struct my_option_st opt_utf8[] = {
{MYSQL_SET_CHARSET_NAME, "utf8"},
{MYSQL_SET_CHARSET_NAME, (char *)"utf8"},
{0, NULL}
};
@@ -647,7 +647,7 @@ static int test_status(MYSQL *mysql)
static int bug_conc1(MYSQL *mysql)
{
mysql_real_connect(mysql, hostname, username, password, schema,
my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0);
diag("errno: %d", mysql_errno(mysql));
FAIL_IF(mysql_errno(mysql) != CR_ALREADY_CONNECTED,
@@ -655,7 +655,7 @@ static int bug_conc1(MYSQL *mysql)
return OK;
}
static int test_options_initcmd(MYSQL *my)
static int test_options_initcmd(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
MYSQL_RES *res;
@@ -663,7 +663,7 @@ static int test_options_initcmd(MYSQL *my)
mysql_options(mysql, MYSQL_INIT_COMMAND, "DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a int)");
mysql_options(mysql, MYSQL_INIT_COMMAND, "INSERT INTO t1 VALUES (1),(2),(3)");
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname,
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS), mysql_error(mysql));
@@ -678,7 +678,7 @@ static int test_options_initcmd(MYSQL *my)
return OK;
}
static int test_extended_init_values(MYSQL *my)
static int test_extended_init_values(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
@@ -692,7 +692,7 @@ static int test_extended_init_values(MYSQL *my)
return OK;
}
static int test_reconnect_maxpackage(MYSQL *my)
static int test_reconnect_maxpackage(MYSQL *unused __attribute__((unused)))
{
int rc;
ulong max_packet= 0;
@@ -708,7 +708,7 @@ static int test_reconnect_maxpackage(MYSQL *my)
SKIP_CONNECTION_HANDLER;
mysql= mysql_init(NULL);
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname,
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS), mysql_error(mysql));
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
@@ -752,7 +752,7 @@ static int test_reconnect_maxpackage(MYSQL *my)
return OK;
}
static int test_compressed(MYSQL *my)
static int test_compressed(MYSQL *unused __attribute__((unused)))
{
int rc;
MYSQL *mysql= mysql_init(NULL);
@@ -760,7 +760,7 @@ static int test_compressed(MYSQL *my)
my_bool reconnect= 1;
mysql_options(mysql, MYSQL_OPT_COMPRESS, (void *)1);
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname,
CLIENT_MULTI_STATEMENTS | CLIENT_MULTI_RESULTS), mysql_error(mysql));
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);

View File

@@ -20,7 +20,7 @@
#define TEST_ARRAY_SIZE 1024
char *rand_str(size_t length) {
char charset[] = "0123456789"
const char charset[] = "0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char *dest= (char *)malloc(length+1);
@@ -36,17 +36,17 @@ char *rand_str(size_t length) {
static int bulk1(MYSQL *mysql)
{
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
char *stmt_str= "INSERT INTO bulk1 VALUES (?,?)";
unsigned long array_size= TEST_ARRAY_SIZE;
const char *stmt_str= "INSERT INTO bulk1 VALUES (?,?)";
unsigned int array_size= TEST_ARRAY_SIZE;
int rc;
int i;
unsigned int i;
char **buffer;
unsigned long *lengths;
unsigned int *vals;
MYSQL_BIND bind[2];
MYSQL_RES *res;
MYSQL_ROW row;
int intval;
unsigned int intval;
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk1");
check_mysql_rc(rc, mysql);
@@ -60,7 +60,7 @@ static int bulk1(MYSQL *mysql)
/* allocate memory */
buffer= calloc(TEST_ARRAY_SIZE, sizeof(char *));
lengths= (unsigned long *)calloc(sizeof(long), TEST_ARRAY_SIZE);
vals= (int *)calloc(sizeof(int), TEST_ARRAY_SIZE);
vals= (unsigned int *)calloc(sizeof(int), TEST_ARRAY_SIZE);
for (i=0; i < TEST_ARRAY_SIZE; i++)
{
@@ -74,7 +74,7 @@ static int bulk1(MYSQL *mysql)
bind[0].buffer= (int *)&vals[0];
bind[1].buffer_type= MYSQL_TYPE_STRING;
bind[1].buffer= (void *)buffer;
bind[1].length= (long *)lengths;
bind[1].length= (unsigned long *)lengths;
rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &array_size);
check_stmt_rc(rc, stmt);
@@ -130,9 +130,9 @@ static int bulk2(MYSQL *mysql)
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
int rc;
MYSQL_BIND bind;
int i;
unsigned long array_size=1024;
uchar indicator[1024];
unsigned int i;
unsigned int array_size=1024;
char indicator[1024];
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk2");
check_mysql_rc(rc, mysql);
@@ -159,6 +159,8 @@ static int bulk2(MYSQL *mysql)
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
mysql_stmt_close(stmt);
return OK;
}

View File

@@ -37,7 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/* set connection options */
struct my_option_st opt_bug8378[] = {
{MYSQL_SET_CHARSET_NAME, "gbk"},
{MYSQL_SET_CHARSET_NAME, (char *) "gbk"},
{0, NULL}
};
@@ -120,7 +120,7 @@ int test_escaping(MYSQL *mysql)
{
int i= 0, rc, len;
char out[20];
char *escape_chars[] = {"'", "\x0", "\n", "\r", "\\", "\0", NULL};
const char *escape_chars[] = {"'", "\x0", "\n", "\r", "\\", "\0", NULL};
/* reset sql_mode, mysql_change_user call doesn't reset it */
rc= mysql_query(mysql, "SET sql_mode=''");
@@ -659,9 +659,9 @@ static int test_bug_54100(MYSQL *mysql)
/* We need this internal function for the test */
static int test_utf16_utf32_noboms(MYSQL *mysql)
static int test_utf16_utf32_noboms(MYSQL *mysql __attribute__((unused)))
{
char *csname[]= {"utf16", "utf16le", "utf32", "utf8"};
const char *csname[]= {"utf16", "utf16le", "utf32", "utf8"};
MARIADB_CHARSET_INFO *csinfo[sizeof(csname)/sizeof(char*)];
const int UTF8= sizeof(csname)/sizeof(char*) - 1;
@@ -676,7 +676,7 @@ static int test_utf16_utf32_noboms(MYSQL *mysql)
int i, error;
size_t rc, in_len, out_len;
for (i= 0; i < sizeof(csname)/sizeof(char*); ++i)
for (i= 0; i < (int)(sizeof(csname)/sizeof(char*)); ++i)
{
csinfo[i]= mariadb_get_charset_by_name(csname[i]);
@@ -693,9 +693,9 @@ static int test_utf16_utf32_noboms(MYSQL *mysql)
out_len= sizeof(buffer);
diag("Converting %s->%s", csname[i], csname[UTF8]);
rc= mariadb_convert_string(in_string[i], &in_len, csinfo[i], buffer, &out_len, csinfo[UTF8], &error);
rc= mariadb_convert_string((char *)in_string[i], &in_len, csinfo[i], buffer, &out_len, csinfo[UTF8], &error);
FAIL_IF(rc == -1, "Conversion failed");
FAIL_IF(rc == (size_t)-1, "Conversion failed");
FAIL_IF(rc != in_oct_len[UTF8], "Incorrect number of written bytes");
if (memcmp(buffer, in_string[UTF8], rc) != 0)
@@ -709,9 +709,9 @@ static int test_utf16_utf32_noboms(MYSQL *mysql)
out_len= sizeof(buffer);
diag("Converting %s->%s", csname[UTF8], csname[i]);
rc= mariadb_convert_string(in_string[UTF8], &in_len, csinfo[UTF8], buffer, &out_len, csinfo[i], &error);
rc= mariadb_convert_string((char *)in_string[UTF8], &in_len, csinfo[UTF8], buffer, &out_len, csinfo[i], &error);
FAIL_IF(rc==-1, "Conversion failed");
FAIL_IF(rc == (size_t)-1, "Conversion failed");
diag("rc=%lu oct_len: %lu", rc, in_oct_len[i]);
FAIL_IF(rc != in_oct_len[i], "Incorrect number of written bytes");
@@ -726,10 +726,10 @@ static int test_utf16_utf32_noboms(MYSQL *mysql)
return OK;
}
static int charset_auto(MYSQL *my)
static int charset_auto(MYSQL *my __attribute__((unused)))
{
const char *csname1, *csname2;
char *osname;
const char *osname;
MYSQL *mysql= mysql_init(NULL);
int rc;
@@ -737,7 +737,7 @@ static int charset_auto(MYSQL *my)
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, "auto");
FAIL_IF(!mysql_real_connect(mysql, hostname, username,
FAIL_IF(!my_test_connect(mysql, hostname, username,
password, schema, port, socketname, 0),
mysql_error(mysql));

View File

@@ -57,7 +57,7 @@ static int test_conc66(MYSQL *my)
check_mysql_rc(rc, my);
rc= mysql_query(my, "FLUSH PRIVILEGES");
check_mysql_rc(rc, my);
if (!mysql_real_connect(mysql, hostname, NULL,
if (!my_test_connect(mysql, hostname, NULL,
NULL, schema, port, socketname, 0))
{
diag("Error: %s", mysql_error(mysql));
@@ -441,13 +441,13 @@ static int test_bug31669(MYSQL *mysql)
}
/**
Bug# 33831 mysql_real_connect() should fail if
Bug# 33831 my_test_connect() should fail if
given an already connected MYSQL handle.
*/
static int test_bug33831(MYSQL *mysql)
{
FAIL_IF(mysql_real_connect(mysql, hostname, username,
FAIL_IF(my_test_connect(mysql, hostname, username,
password, schema, port, socketname, 0),
"Error expected");
@@ -476,7 +476,7 @@ static int test_opt_reconnect(MYSQL *mysql)
mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
FAIL_UNLESS(reconnect == 1, "reconnect != 1");
if (!(mysql_real_connect(mysql, hostname, username,
if (!(my_test_connect(mysql, hostname, username,
password, schema, port,
socketname, 0)))
{
@@ -496,7 +496,7 @@ static int test_opt_reconnect(MYSQL *mysql)
mysql_get_option(mysql, MYSQL_OPT_RECONNECT, &reconnect);
FAIL_UNLESS(reconnect == 0, "reconnect != 0");
if (!(mysql_real_connect(mysql, hostname, username,
if (!(my_test_connect(mysql, hostname, username,
password, schema, port,
socketname, 0)))
{
@@ -527,7 +527,7 @@ static int test_compress(MYSQL *mysql)
if (!(mysql_real_connect(mysql, hostname, username,
if (!(my_test_connect(mysql, hostname, username,
password, schema, port,
socketname, 0)))
{
@@ -565,7 +565,7 @@ static int test_reconnect(MYSQL *mysql)
mysql_get_option(mysql1, MYSQL_OPT_RECONNECT, &reconnect);
FAIL_UNLESS(reconnect == 1, "reconnect != 1");
if (!(mysql_real_connect(mysql1, hostname, username,
if (!(my_test_connect(mysql1, hostname, username,
password, schema, port,
socketname, 0)))
{
@@ -599,7 +599,7 @@ int test_conc21(MYSQL *mysql)
MYSQL_RES *res= NULL;
MYSQL_ROW row;
char tmp[256];
int check_server_version= 0;
unsigned int check_server_version= 0;
int major=0, minor= 0, patch=0;
rc= mysql_query(mysql, "SELECT @@version");
@@ -621,12 +621,12 @@ int test_conc21(MYSQL *mysql)
return OK;
}
int test_conc26(MYSQL *my)
int test_conc26(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, "utf8");
FAIL_IF(mysql_real_connect(mysql, hostname, "notexistinguser", "password", schema, port, NULL, CLIENT_REMEMBER_OPTIONS),
FAIL_IF(my_test_connect(mysql, hostname, "notexistinguser", "password", schema, port, NULL, CLIENT_REMEMBER_OPTIONS),
"Error expected");
FAIL_IF(!mysql->options.charset_name || strcmp(mysql->options.charset_name, "utf8") != 0,
@@ -634,7 +634,7 @@ int test_conc26(MYSQL *my)
mysql_close(mysql);
mysql= mysql_init(NULL);
FAIL_IF(mysql_real_connect(mysql, hostname, "notexistinguser", "password", schema, port, NULL, 0),
FAIL_IF(my_test_connect(mysql, hostname, "notexistinguser", "password", schema, port, NULL, 0),
"Error expected");
FAIL_IF(mysql->options.charset_name, "Error: options not freed");
mysql_close(mysql);
@@ -642,14 +642,14 @@ int test_conc26(MYSQL *my)
return OK;
}
int test_connection_timeout(MYSQL *my)
int test_connection_timeout(MYSQL *unused __attribute__((unused)))
{
unsigned int timeout= 5;
time_t start, elapsed;
MYSQL *mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (unsigned int *)&timeout);
start= time(NULL);
if (mysql_real_connect(mysql, "192.168.1.101", "notexistinguser", "password", schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
if (my_test_connect(mysql, "192.168.1.101", "notexistinguser", "password", schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
{
diag("Error expected - maybe you have to change hostname");
return FAIL;
@@ -661,7 +661,7 @@ int test_connection_timeout(MYSQL *my)
return OK;
}
int test_connection_timeout2(MYSQL *my)
int test_connection_timeout2(MYSQL *unused __attribute__((unused)))
{
unsigned int timeout= 5;
time_t start, elapsed;
@@ -669,7 +669,7 @@ int test_connection_timeout2(MYSQL *my)
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (unsigned int *)&timeout);
mysql_options(mysql, MYSQL_INIT_COMMAND, "set @a:=SLEEP(6)");
start= time(NULL);
if (mysql_real_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
if (my_test_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
{
diag("timeout error expected");
return FAIL;
@@ -681,7 +681,7 @@ int test_connection_timeout2(MYSQL *my)
return OK;
}
int test_connection_timeout3(MYSQL *my)
int test_connection_timeout3(MYSQL *unused __attribute__((unused)))
{
unsigned int timeout= 5;
unsigned int read_write_timeout= 10;
@@ -693,7 +693,7 @@ int test_connection_timeout3(MYSQL *my)
mysql_options(mysql, MYSQL_OPT_WRITE_TIMEOUT, (unsigned int *)&read_write_timeout);
mysql_options(mysql, MYSQL_INIT_COMMAND, "set @a:=SLEEP(6)");
start= time(NULL);
if (mysql_real_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
if (my_test_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
{
diag("timeout error expected");
elapsed= time(NULL) - start;
@@ -710,7 +710,7 @@ int test_connection_timeout3(MYSQL *my)
mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, (unsigned int *)&read_write_timeout);
mysql_options(mysql, MYSQL_OPT_WRITE_TIMEOUT, (unsigned int *)&read_write_timeout);
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
if (!my_test_connect(mysql, hostname, username, password, schema, port, NULL, CLIENT_REMEMBER_OPTIONS))
{
diag("Error: %s", mysql_error(mysql));
return FAIL;
@@ -756,9 +756,9 @@ static int test_conc118(MYSQL *mysql)
return OK;
}
static int test_wrong_bind_address(MYSQL *my)
static int test_wrong_bind_address(MYSQL *unused __attribute__((unused)))
{
char *bind_addr= "100.188.111.112";
const char *bind_addr= "100.188.111.112";
MYSQL *mysql;
if (!hostname || !strcmp(hostname, "localhost"))
@@ -770,7 +770,7 @@ static int test_wrong_bind_address(MYSQL *my)
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_BIND, bind_addr);
if (mysql_real_connect(mysql, hostname, username,
if (my_test_connect(mysql, hostname, username,
password, schema, port, socketname, 0))
{
diag("Error expected");
@@ -815,7 +815,7 @@ static int test_bind_address(MYSQL *my)
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_BIND, bind_addr);
if (!mysql_real_connect(mysql, bind_addr, username,
if (!my_test_connect(mysql, bind_addr, username,
password, schema, port, socketname, 0))
{
diag("Error: %s\n", mysql_error(mysql));
@@ -827,7 +827,7 @@ static int test_bind_address(MYSQL *my)
return OK;
}
static int test_get_options(MYSQL *my)
static int test_get_options(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
int options_int[]= {MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_LOCAL_INFILE,
@@ -843,18 +843,19 @@ static int test_get_options(MYSQL *my)
MYSQL_OPT_SSL_CIPHER, MYSQL_OPT_BIND, MARIADB_OPT_SSL_FP, MARIADB_OPT_SSL_FP_LIST,
MARIADB_OPT_TLS_PASSPHRASE, 0};
char *init_command[3]= {"SET @a:=1", "SET @b:=2", "SET @c:=3"};
const char *init_command[3]= {"SET @a:=1", "SET @b:=2", "SET @c:=3"};
int elements= 0;
char **command;
int intval[2]= {1, 0};
my_bool boolval[2]= {1, 0};
char *char1= "test", *char2;
const char *char1= "test";
char *char2;
int i;
MYSQL *userdata;
char *attr_key[] = {"foo1", "foo2", "foo3"};
char *attr_val[] = {"bar1", "bar2", "bar3"};
const char *attr_key[] = {"foo1", "foo2", "foo3"};
const char *attr_val[] = {"bar1", "bar2", "bar3"};
char **key, **val;
for (i=0; options_int[i]; i++)
@@ -906,7 +907,7 @@ static int test_get_options(MYSQL *my)
free(val);
mysql_optionsv(mysql, MARIADB_OPT_USERDATA, "my_app", (void *)mysql);
mysql_get_optionv(mysql, MARIADB_OPT_USERDATA, "my_app", &userdata);
mysql_get_optionv(mysql, MARIADB_OPT_USERDATA, (char *)"my_app", &userdata);
FAIL_IF(mysql != userdata, "wrong userdata");
mysql_close(mysql);
@@ -941,13 +942,15 @@ static int test_sess_track_db(MYSQL *mysql)
"session_track_get_first failed");
FAIL_IF(strncmp(data, "testc", len), "Expected new schema 'testc'");
diag("charset: %s", mysql->charset->csname);
rc= mysql_query(mysql, "SET NAMES utf8");
check_mysql_rc(rc, 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", (int)len, (int)len, data);
} while (!mysql_session_track_get_next(mysql, SESSION_TRACK_SYSTEM_VARIABLES, &data, &len));
diag("charset: %s", mysql->charset->csname);
FAIL_IF(strcmp(mysql->charset->csname, "utf8"), "Expected charset 'utf8'");
rc= mysql_query(mysql, "SET NAMES latin1");
check_mysql_rc(rc, mysql);

View File

@@ -24,11 +24,21 @@ static int create_dyncol_named(MYSQL *mysql)
DYNAMIC_COLUMN_VALUE *vals;
uint i, column_count= 6;
int rc;
char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5", "Val6"};
MYSQL_LEX_STRING keys1[]= {{"key1", 4}, {"key2", 4}, {"key3", 4}, {"key4", 4}, {"key5", 4}, {"key6", 4}},
keys2[]= {{"key1", 4}, {"key1", 4}, {"key3", 4}, {"key4", 4}, {"key5", 4}, {"key6", 4}},
keys3[]= {{"\x70\x61\x72\x61\x00\x30", 6}, {"\x70\x61\x72\x61\x00\x31", 6}, {"\x70\x61\x72\x61\x00\x32", 6},
{"\x70\x61\x72\x61\x00\x33", 6}, {"\x70\x61\x72\x61\x00\x34", 6}, {"\x70\x61\x72\x61\x00\x35", 6}};
const char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5", "Val6"};
MYSQL_LEX_STRING keys1[]= {{(char *)"key1", 4}, {(char *)"key2", 4},
{(char *)"key3", 4}, {(char *)"key4", 4},
{(char *)"key5", 4}, {(char *)"key6", 4}},
keys2[]= {{(char *)"key1", 4}, {(char *)"key1", 4},
{(char *)"key3", 4}, {(char *)"key4", 4},
{(char *)"key5", 4}, {(char *)"key6", 4}},
keys3[]= {{(char *)"\x70\x61\x72\x61\x00\x30", 6},
{(char *)"\x70\x61\x72\x61\x00\x31", 6},
{(char *)"\x70\x61\x72\x61\x00\x32", 6},
{(char *)"\x70\x61\x72\x61\x00\x33", 6},
{(char *)"\x70\x61\x72\x61\x00\x34", 6},
{(char *)"\x70\x61\x72\x61\x00\x35", 6}};
MYSQL_LEX_STRING *my_keys;
uint my_count;
@@ -37,7 +47,7 @@ static int create_dyncol_named(MYSQL *mysql)
for (i=0; i < column_count; i++)
{
vals[i].type= DYN_COL_STRING;
vals[i].x.string.value.str= strval[i];
vals[i].x.string.value.str= (char *)strval[i];
vals[i].x.string.value.length= strlen(strval[i]);
vals[i].x.string.charset= (MARIADB_CHARSET_INFO *)mysql->charset;
diag("%s", keys3[i].str);
@@ -87,7 +97,7 @@ static int create_dyncol_named(MYSQL *mysql)
FAIL_IF(rc < 0, "update failed");
mariadb_dyncol_free(&dyncol);
keys3[0].str= "test";
keys3[0].str= (char *)"test";
for (i=0; i < column_count; i++)
diag("%s", my_keys[i].str);
@@ -96,7 +106,7 @@ static int create_dyncol_named(MYSQL *mysql)
return OK;
}
static int mdev_4994(MYSQL *mysql)
static int mdev_4994(MYSQL *unused __attribute__((unused)))
{
DYNAMIC_COLUMN dyncol;
uint key= 1;
@@ -121,22 +131,22 @@ static int create_dyncol_num(MYSQL *mysql)
MYSQL_LEX_STRING *my_keys;
DYNAMIC_COLUMN_VALUE *my_vals;
int rc;
char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"};
const char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"};
uint keys1[5]= {1,2,3,4,5},
keys2[5]= {1,2,2,4,5};
MYSQL_LEX_STRING key1= {"1",1};
MYSQL_LEX_STRING key1= {(char *)"1",1};
for (i=0; i < column_count; i++)
{
vals[i].type= DYN_COL_STRING;
vals[i].x.string.value.str= strval[i];
vals[i].x.string.value.str= (char *)strval[i];
vals[i].x.string.value.length= strlen(strval[i]);
vals[i].x.string.charset= (MARIADB_CHARSET_INFO *)mysql->charset;
}
FAIL_IF(mariadb_dyncol_create_many_num(&dyncol, column_count, keys1, vals, 1) <0, "Error (keys1)");
vals[0].x.string.value.str= strval[1];
vals[0].x.string.value.str= (char *)strval[1];
rc= mariadb_dyncol_update_many_named(&dyncol,1, &key1, vals);
diag("update: %d", rc);
@@ -163,10 +173,10 @@ static int mdev_x1(MYSQL *mysql)
int rc;
uint i;
uint num_keys[5]= {1,2,3,4,5};
char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"};
const char *strval[]= {"Val1", "Val2", "Val3", "Val4", "Val5"};
DYNAMIC_COLUMN_VALUE vals[5];
DYNAMIC_COLUMN dynstr;
MYSQL_LEX_STRING my_key= {"1", 2};
MYSQL_LEX_STRING my_key= {(char *)"1", 2};
uint unpack_columns;
MYSQL_LEX_STRING *unpack_keys;
DYNAMIC_COLUMN_VALUE *unpack_vals;
@@ -174,7 +184,7 @@ static int mdev_x1(MYSQL *mysql)
for (i=0; i < 5; i++)
{
vals[i].type= DYN_COL_STRING;
vals[i].x.string.value.str= strval[i];
vals[i].x.string.value.str= (char *)strval[i];
vals[i].x.string.value.length= strlen(strval[i]);
vals[i].x.string.charset= (MARIADB_CHARSET_INFO *)mysql->charset;
}
@@ -233,7 +243,7 @@ static int mdev_x1(MYSQL *mysql)
return OK;
}
static int dyncol_column_count(MYSQL *mysql)
static int dyncol_column_count(MYSQL *unused __attribute__((unused)))
{
DYNAMIC_COLUMN dyncol;
uint column_count= 5;

View File

@@ -44,7 +44,7 @@ static int test_ps_client_warnings(MYSQL *mysql)
{
int rc;
MYSQL_STMT *stmt;
char *query= "DROP TABLE IF EXISTS test_non_exists";
const char *query= "DROP TABLE IF EXISTS test_non_exists";
rc= mysql_query(mysql, "DROP TABLE if exists test_non_exists");
check_mysql_rc(rc, mysql);
@@ -109,7 +109,7 @@ static int test_ps_client_errors(MYSQL *mysql)
{
int rc;
MYSQL_STMT *stmt;
char *query= "DROP TABLE test_non_exists";
const char *query= "DROP TABLE test_non_exists";
rc= mysql_query(mysql, "DROP TABLE if exists test_non_exists");
check_mysql_rc(rc, mysql);

View File

@@ -175,7 +175,7 @@ static int com_multi_ps2(MYSQL *mysql)
MYSQL_BIND bind[2];
int intval= 3, rc;
int i;
char *varval= "com_multi_ps2";
const char *varval= "com_multi_ps2";
unsigned int param_count= 2;
if (!have_com_multi)
@@ -189,7 +189,7 @@ static int com_multi_ps2(MYSQL *mysql)
bind[0].buffer_type= MYSQL_TYPE_SHORT;
bind[0].buffer= &intval;
bind[1].buffer_type= MYSQL_TYPE_STRING;
bind[1].buffer= varval;
bind[1].buffer= (char *)varval;
bind[1].buffer_length= strlen(varval);
stmt= mysql_stmt_init(mysql);
@@ -271,7 +271,7 @@ static int execute_direct_example(MYSQL *mysql)
MYSQL_BIND bind[2];
int intval= 1;
int param_count= 2;
char *strval= "execute_direct_example";
const char *strval= "execute_direct_example";
/* Direct execution without parameters */
if (mariadb_stmt_execute_direct(stmt, "DROP TABLE IF EXISTS execute_direct", -1))
@@ -283,7 +283,7 @@ static int execute_direct_example(MYSQL *mysql)
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= (char *)strval;
bind[1].buffer_length= strlen(strval);
/* set number of parameters */

View File

@@ -187,7 +187,7 @@ static int test_fetch_seek(MYSQL *mysql)
int rc;
int32 c1;
char c2[11], c3[20];
char *query = "SELECT * FROM t1";
const char *query = "SELECT * FROM t1";
rc= mysql_query(mysql, "drop table if exists t1");
check_mysql_rc(rc, mysql);
@@ -273,7 +273,7 @@ static int test_fetch_offset(MYSQL *mysql)
ulong length[2];
int rc;
my_bool is_null[2];
char *query = "SELECT * FROM t1";
const char *query = "SELECT * FROM t1";
rc= mysql_query(mysql, "drop table if exists t1");
@@ -396,7 +396,7 @@ static int test_fetch_column(MYSQL *mysql)
char c2[20], bc2[20];
ulong l1, l2, bl1, bl2;
int rc, c1, bc1;
char *query= "SELECT * FROM t1 ORDER BY c2 DESC";
const char *query= "SELECT * FROM t1 ORDER BY c2 DESC";
rc= mysql_query(mysql, "drop table if exists t1");
check_mysql_rc(rc, mysql);
@@ -516,7 +516,7 @@ static int test_fetch_nobuffs(MYSQL *mysql)
MYSQL_BIND my_bind[4];
char str[4][50];
int rc;
char *query = "SELECT DATABASE(), CURRENT_USER(), \
const char *query = "SELECT DATABASE(), CURRENT_USER(), \
CURRENT_DATE(), CURRENT_TIME()";
stmt = mysql_stmt_init(mysql);
@@ -653,7 +653,7 @@ static int test_fetch_date(MYSQL *mysql)
MYSQL_BIND my_bind[8];
my_bool is_null[8];
ulong length[8];
char *query= "SELECT * FROM test_bind_result";
const char *query= "SELECT * FROM test_bind_result";
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result");
check_mysql_rc(rc, mysql);

View File

@@ -164,7 +164,7 @@ static int bug31418_impl()
return OK;
}
static int test_bug31418(MYSQL *mysql)
static int test_bug31418(MYSQL *unused __attribute__((unused)))
{
int i;
/* Run test case for BUG#31418 for three different connections. */
@@ -312,7 +312,7 @@ static int test_wl4166_1(MYSQL *mysql)
ulong length[7];
my_bool is_null[7];
MYSQL_BIND my_bind[7];
static char *query;
const char *query;
int rc;
int i;
@@ -910,7 +910,7 @@ static int test_connect_attrs(MYSQL *my)
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "foo1", "bar1");
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "foo2", "bar2");
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
if (!(mysql->server_capabilities & CLIENT_CONNECT_ATTRS))
@@ -955,11 +955,11 @@ static int test_conc_114(MYSQL *mysql)
}
/* run with valgrind */
static int test_conc117(MYSQL *mysql)
static int test_conc117(MYSQL *unused __attribute__((unused)))
{
my_bool reconnect= 1;
MYSQL *my= mysql_init(NULL);
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
FAIL_IF(!my_test_connect(my, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
mysql_kill(my, mysql_thread_id(my));
@@ -973,12 +973,12 @@ static int test_conc117(MYSQL *mysql)
return OK;
}
static int test_read_timeout(MYSQL *mysql)
static int test_read_timeout(MYSQL *unused __attribute__((unused)))
{
int timeout= 5, rc;
MYSQL *my= mysql_init(NULL);
mysql_options(my, MYSQL_OPT_READ_TIMEOUT, &timeout);
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
FAIL_IF(!my_test_connect(my, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(my, "SELECT SLEEP(50)");
@@ -1034,7 +1034,7 @@ static int test_remote2(MYSQL *my)
mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "http://localhost/test.cnf");
mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "test");
mysql_real_connect(mysql, hostname, username, password, schema,
my_test_connect(mysql, hostname, username, password, schema,
0, socketname, 0), mysql_error(my);
diag("port: %d", mysql->port);
mysql_close(mysql);
@@ -1122,7 +1122,7 @@ static int test_zerofill(MYSQL *mysql)
rc= mysql_query(mysql, "SELECT a FROM t1");
check_mysql_rc(rc, mysql);
if (res= mysql_store_result(mysql))
if ((res= mysql_store_result(mysql)))
{
row= mysql_fetch_row(res);
diag("zerofill: %s", row[0]);

View File

@@ -114,15 +114,25 @@ struct my_tests_st
int connection;
ulong connect_flags;
struct my_option_st *options;
char *skipmsg;
const char *skipmsg;
};
static char *schema = 0;
MYSQL *my_test_connect(MYSQL *mysql,
const char *host,
const char *user,
const char *passwd,
const char *db,
unsigned int port,
const char *unix_socket,
unsigned long clientflag);
static const char *schema = 0;
static char *hostname = 0;
static char *password = 0;
static unsigned int port = 0;
static char *socketname = 0;
static char *username = 0;
static int force_tls= 0;
/*
static struct my_option test_options[] =
{
@@ -160,11 +170,13 @@ static struct my_option test_options[] =
int do_verify_prepare_field(MYSQL_RES *result,
unsigned int no, const char *name,
const char *org_name,
enum enum_field_types type,
enum enum_field_types type __attribute__((unused)),
const char *table,
const char *org_table, const char *db,
unsigned long length, const char *def,
const char *file, int line)
unsigned long length __attribute__((unused)),
const char *def __attribute__((unused)),
const char *file __attribute__((unused)),
int line __attribute__((unused)))
{
MYSQL_FIELD *field;
/* MARIADB_CHARSET_INFO *cs; */
@@ -312,6 +324,7 @@ static void usage()
printf("-p password\n");
printf("-d database\n");
printf("-S socketname\n");
printf("-t force use of TLS\n");
printf("-P port number\n");
printf("? displays this help and exits\n");
}
@@ -320,7 +333,7 @@ void get_options(int argc, char **argv)
{
int c= 0;
while ((c=getopt(argc,argv, "h:u:p:d:P:S:?")) >= 0)
while ((c=getopt(argc,argv, "h:u:p:d:w:P:S:t:?")) >= 0)
{
switch(c) {
case 'h':
@@ -341,6 +354,9 @@ void get_options(int argc, char **argv)
case 'S':
socketname= optarg;
break;
case 't':
force_tls= 1;
break;
case '?':
usage();
exit(0);
@@ -354,7 +370,7 @@ void get_options(int argc, char **argv)
}
int check_variable(MYSQL *mysql, char *variable, char *value)
int check_variable(MYSQL *mysql, const char *variable, const char *value)
{
char query[MAX_TEST_QUERY_LENGTH];
MYSQL_RES *result;
@@ -380,7 +396,8 @@ int check_variable(MYSQL *mysql, char *variable, char *value)
* returns a new connection. This function will be called, if the test doesn't
* use default_connection.
*/
MYSQL *test_connect(struct my_tests_st *test) {
MYSQL *test_connect(struct my_tests_st *test)
{
MYSQL *mysql;
int i= 0;
int timeout= 10;
@@ -389,7 +406,6 @@ MYSQL *test_connect(struct my_tests_st *test) {
diag("%s", "mysql_init failed - exiting");
return(NULL);
}
mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, &truncation_report);
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
@@ -407,7 +423,7 @@ MYSQL *test_connect(struct my_tests_st *test) {
i++;
}
}
if (!(mysql_real_connect(mysql, hostname, username, password,
if (!(my_test_connect(mysql, hostname, username, password,
schema, port, socketname, (test) ? test->connect_flags:0)))
{
diag("Couldn't establish connection to server %s. Error (%d): %s",
@@ -449,10 +465,33 @@ void get_envvars() {
schema= "testc";
if (!port && (envvar= getenv("MYSQL_TEST_PORT")))
port= atoi(envvar);
if (!force_tls && (envvar= getenv("MYSQL_TEST_TLS")))
force_tls= atoi(envvar);
if (!socketname && (envvar= getenv("MYSQL_TEST_SOCKET")))
socketname= envvar;
}
MYSQL *my_test_connect(MYSQL *mysql,
const char *host,
const char *user,
const char *passwd,
const char *db,
unsigned int port,
const char *unix_socket,
unsigned long clientflag)
{
if (force_tls)
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &force_tls);
mysql= mysql_real_connect(mysql, host, user, passwd, db, port, unix_socket, clientflag);
if (mysql && force_tls && !mysql_get_ssl_cipher(mysql))
{
diag("Error: TLS connection not established");
return NULL;
}
return mysql;
}
void run_tests(struct my_tests_st *test) {
int i, rc, total=0;
MYSQL *mysql, *mysql_default= NULL; /* default connection */

View File

@@ -27,7 +27,7 @@ static int perf1(MYSQL *mysql)
{
int rc;
MYSQL_STMT *stmt;
char *stmtstr= "SELECT s.emp_no, s.salary, e.emp_no, e.first_name, e.last_name, e.gender FROM salaries s, employees e WHERE s.emp_no = e.emp_no";
const char *stmtstr= "SELECT s.emp_no, s.salary, e.emp_no, e.first_name, e.last_name, e.gender FROM salaries s, employees e WHERE s.emp_no = e.emp_no";
rc= mysql_select_db(mysql, "employees");
if (rc)

View File

@@ -47,20 +47,20 @@ static int test_conc97(MYSQL *mysql)
return OK;
}
static int test_conc83(MYSQL *my)
static int test_conc83(MYSQL *unused __attribute__((unused)))
{
MYSQL_STMT *stmt;
int rc;
MYSQL *mysql= mysql_init(NULL);
my_bool reconnect= 1;
char *query= "SELECT 1,2,3 FROM DUAL";
const char *query= "SELECT 1,2,3 FROM DUAL";
stmt= mysql_stmt_init(mysql);
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
FAIL_IF(!(mysql_real_connect(mysql, hostname, username, password,
schema, port, socketname, 0)), "mysql_real_connect failed");
FAIL_IF(!(my_test_connect(mysql, hostname, username, password,
schema, port, socketname, 0)), "my_test_connect failed");
/* 1. Status is inited, so prepare should work */
@@ -91,7 +91,7 @@ static int test_conc60(MYSQL *mysql)
{
MYSQL_STMT *stmt;
int rc;
char *query= "SELECT * FROM agendas";
const char *query= "SELECT * FROM agendas";
my_bool x= 1;
stmt= mysql_stmt_init(mysql);
@@ -184,7 +184,6 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
{
MYSQL_STMT *stmt= 0;
uint rc, i, count= row_count;
ulong length[4]= {0,0,0,0};
MYSQL_BIND my_bind[4];
my_bool is_null[4]= {0,0,0,0};
MYSQL_TIME tm[4];
@@ -203,7 +202,6 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
its members.
*/
memset(my_bind, '\0', sizeof(my_bind));
memset(tm, 0, sizeof(tm));
my_bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP;
my_bind[1].buffer_type= MYSQL_TYPE_TIME;
@@ -214,9 +212,7 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
{
my_bind[i].buffer= (void *) &tm[i];
my_bind[i].is_null= &is_null[i];
my_bind[i].length= &length[i];
my_bind[i].buffer_length= 30;
length[i]= 20;
my_bind[i].buffer_length= sizeof(MYSQL_TIME);
}
second_part= 0;
@@ -236,6 +232,7 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
{
for (i= 0; i < (int) array_elements(my_bind); i++)
{
memset(&tm[i], 0, sizeof(MYSQL_TIME));
tm[i].neg= 0;
tm[i].second_part= second_part+count;
if (my_bind[i].buffer_type != MYSQL_TYPE_TIME)
@@ -828,8 +825,8 @@ static int test_prepare_alter(MYSQL *mysql)
mysql_new= mysql_init(NULL);
FAIL_IF(!mysql_new, "mysql_init failed");
FAIL_IF(!(mysql_real_connect(mysql_new, hostname, username, password,
schema, port, socketname, 0)), "mysql_real_connect failed");
FAIL_IF(!(my_test_connect(mysql_new, hostname, username, password,
schema, port, socketname, 0)), "my_test_connect failed");
rc= mysql_query(mysql_new, "ALTER TABLE test_prep_alter change id id_new varchar(20)");
diag("Error: %d %s", mysql_errno(mysql_new), mysql_error(mysql_new));
check_mysql_rc(rc, mysql_new);
@@ -3414,7 +3411,6 @@ static int test_double_compare(MYSQL *mysql)
my_bind[1].buffer= (void *)&real_data;
my_bind[1].buffer_length= sizeof(real_data);
my_bind[1].length= &length[1];
length[1]= 10;
/* double */
my_bind[2].buffer_type= MYSQL_TYPE_DOUBLE;
@@ -3422,6 +3418,7 @@ static int test_double_compare(MYSQL *mysql)
tiny_data= 1;
strcpy(real_data, "10.2");
length[1]= strlen(real_data);
double_data= 34.5;
rc= mysql_stmt_bind_param(stmt, my_bind);
check_stmt_rc(rc, stmt);
@@ -3561,7 +3558,7 @@ static int test_multi_stmt(MYSQL *mysql)
MYSQL_BIND my_bind[2];
ulong length[2];
my_bool is_null[2];
static char *query;
const char *query;
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_multi_table");
check_mysql_rc(rc, mysql);
@@ -3850,7 +3847,7 @@ static int test_order_param(MYSQL *mysql)
{
MYSQL_STMT *stmt;
int rc;
static char *query;
const char *query;
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
check_mysql_rc(rc, mysql);
@@ -4680,7 +4677,7 @@ static int test_long_data1(MYSQL *mysql)
int rc;
MYSQL_BIND bind[1];
char query[MAX_TEST_QUERY_LENGTH];
char *data= "12345";
const char *data= "12345";
rc= mysql_autocommit(mysql, TRUE);
check_mysql_rc(rc, mysql);
@@ -4718,7 +4715,7 @@ int test_blob_9000(MYSQL *mysql)
MYSQL_STMT *stmt;
int rc;
char buffer[9200];
char *query= "INSERT INTO tb9000 VALUES (?)";
const char *query= "INSERT INTO tb9000 VALUES (?)";
rc= mysql_query(mysql, "DROP TABLE IF EXISTS tb9000");
check_mysql_rc(rc, mysql);
@@ -4746,7 +4743,7 @@ int test_fracseconds(MYSQL *mysql)
{
MYSQL_STMT *stmt;
int rc;
char *str= "SELECT NOW(6)";
const char *str= "SELECT NOW(6)";
char buffer[60], buffer1[60];
MYSQL_BIND bind[2];
@@ -4821,7 +4818,7 @@ int test_notrunc(MYSQL *mysql)
my_bool error= 0;
unsigned long len= 1;
char *query= "SELECT '1234567890', 'foo' FROM DUAL";
const char *query= "SELECT '1234567890', 'foo' FROM DUAL";
mysql_options(mysql, MYSQL_REPORT_DATA_TRUNCATION, &trunc);
@@ -4860,7 +4857,53 @@ int test_notrunc(MYSQL *mysql)
return OK;
}
static int test_bit2tiny(MYSQL *mysql)
{
MYSQL_BIND bind[2];
char data[11];
unsigned long length[2];
my_bool is_null[2], error[2];
const char *query = "SELECT val FROM justbit";
MYSQL_STMT *stmt;
int rc;
mysql_query(mysql, "DROP TABLE IF EXISTS justbit");
mysql_query(mysql, "CREATE TABLE justbit(val bit(1) not null)");
mysql_query(mysql, "INSERT INTO justbit values (1)");
stmt= mysql_stmt_init(mysql);
rc= mysql_stmt_prepare(stmt, query, strlen(query));
check_stmt_rc(rc, stmt);
memset(bind, '\0', sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_TINY;
bind[0].buffer= &data[0];
bind[0].buffer_length= 1;
bind[0].is_null= &is_null[0];
bind[0].length= &length[0];
bind[0].error= &error[0];
rc= mysql_stmt_execute(stmt);
check_stmt_rc(rc, stmt);
rc= mysql_stmt_bind_result(stmt, bind);
check_stmt_rc(rc, stmt);
rc= mysql_stmt_store_result(stmt);
check_stmt_rc(rc, stmt);
mysql_stmt_fetch(stmt);
FAIL_IF(data[0] != 1, "Value should be 1");
mysql_stmt_free_result(stmt);
mysql_stmt_close(stmt);
return OK;
}
struct my_tests_st my_tests[] = {
{"test_bit2tiny", test_bit2tiny, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc97", test_conc97, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc83", test_conc83, TEST_CONNECTION_NONE, 0, NULL, NULL},
{"test_conc60", test_conc60, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},

View File

@@ -39,7 +39,7 @@ static int cmp_double(double *a, double *b)
static int test_conc67(MYSQL *mysql)
{
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
char *query= "SELECT a,b FROM conc67 WHERE a=?";
const char *query= "SELECT a,b FROM conc67 WHERE a=?";
int rc, i;
MYSQL_BIND bind[2];
char val[20];
@@ -545,8 +545,8 @@ static int test_bug1500(MYSQL *mysql)
MYSQL_BIND my_bind[3];
int rc= 0;
int32 int_data[3]= {2, 3, 4};
char *data;
char *query;
const char *data;
const char *query;
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bg1500");
@@ -3028,7 +3028,7 @@ static int test_bug8330(MYSQL *mysql)
int i, rc;
const char *query= "select a,b from t1 where a=?";
MYSQL_BIND my_bind[2];
long lval[2];
long lval[2]= {1,2};
stmt_text= "drop table if exists t1";
/* in case some previos test failed */
@@ -3354,6 +3354,7 @@ static int test_decimal_bug(MYSQL *mysql)
*/
memset(my_bind, '\0', sizeof(my_bind));
memset(data, 0, sizeof(data));
my_bind[0].buffer_type= MYSQL_TYPE_NEWDECIMAL;
my_bind[0].buffer= (void *)data;
my_bind[0].buffer_length= 25;
@@ -3748,7 +3749,7 @@ static int test_bug53311(MYSQL *mysql)
int rc;
MYSQL_STMT *stmt;
int i;
char *query= "INSERT INTO bug53311 VALUES (1)";
const char *query= "INSERT INTO bug53311 VALUES (1)";
rc= mysql_options(mysql, MYSQL_OPT_RECONNECT, "1");
check_mysql_rc(rc, mysql);
@@ -3836,7 +3837,7 @@ end:
static int test_conc_5(MYSQL *mysql)
{
char *query= "SELECT a FROM t1";
const char *query= "SELECT a FROM t1";
MYSQL_RES *res;
MYSQL_STMT *stmt;
MYSQL_FIELD *fields;
@@ -3873,7 +3874,7 @@ static int test_conc_5(MYSQL *mysql)
static int test_conc141(MYSQL *mysql)
{
int rc;
char *query= "CALL p_conc141";
const char *query= "CALL p_conc141";
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
rc= mysql_query(mysql, "DROP TABLE IF EXISTS conc141");
@@ -4107,7 +4108,7 @@ static int test_conc167(MYSQL *mysql)
char buffer[100];
int bit1=0, bit2=0;
int rc;
char *stmt_str= "SELECT a,b,c FROM conc168";
const char *stmt_str= "SELECT a,b,c FROM conc168";
rc= mysql_query(mysql, "DROP TABLE IF EXISTS conc168");
check_mysql_rc(rc, mysql);
@@ -4153,7 +4154,7 @@ static int test_conc177(MYSQL *mysql)
MYSQL_STMT *stmt;
int rc;
MYSQL_BIND bind[2];
char *stmt_str= "SELECT a,b FROM t1";
const char *stmt_str= "SELECT a,b FROM t1";
char buf1[128], buf2[128];
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
@@ -4228,7 +4229,7 @@ static int test_conc179(MYSQL *mysql)
{
MYSQL_STMT *stmt;
int rc;
char *stmtstr= "CREATE TABLE t1 (`blurb_id` int NOT NULL DEFAULT 0, `blurb` text default '', PRIMARY KEY (blurb_id)) ENGINE='FEDERATED' DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'";
const char *stmtstr= "CREATE TABLE t1 (`blurb_id` int NOT NULL DEFAULT 0, `blurb` text default '', PRIMARY KEY (blurb_id)) ENGINE='FEDERATED' DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'";
rc= mysql_query(mysql, "set sql_mode=''");
check_mysql_rc(rc, mysql);
@@ -4300,7 +4301,7 @@ static int test_conc181(MYSQL *mysql)
MYSQL_STMT *stmt;
int rc;
MYSQL_BIND bind;
char *stmt_str= "SELECT a FROM t1";
const char *stmt_str= "SELECT a FROM t1";
float f=1;
my_bool err= 0;

View File

@@ -135,7 +135,7 @@ int test_sp_params(MYSQL *mysql)
MYSQL_STMT *stmt;
int a[] = {10,20,30};
MYSQL_BIND bind[3];
char *stmtstr= "CALL P1(?,?,?)";
const char *stmtstr= "CALL P1(?,?,?)";
char res[3][20];
rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
@@ -219,7 +219,7 @@ int test_sp_reset(MYSQL *mysql)
MYSQL_STMT *stmt;
int a[] = {10,20,30};
MYSQL_BIND bind[3];
char *stmtstr= "CALL P1(?,?,?)";
const char *stmtstr= "CALL P1(?,?,?)";
rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
check_mysql_rc(rc, mysql);
@@ -274,7 +274,7 @@ int test_sp_reset1(MYSQL *mysql)
MYSQL_BIND bind[1];
char tmp[20];
char *stmtstr= "CALL P1(?)";
const char *stmtstr= "CALL P1(?)";
rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
check_mysql_rc(rc, mysql);
@@ -332,7 +332,7 @@ int test_sp_reset2(MYSQL *mysql)
MYSQL_STMT *stmt;
MYSQL_BIND bind[4];
long l[4];
char *stmtstr= "CALL P1()";
const char *stmtstr= "CALL P1()";
memset(l, 0, sizeof(l));
@@ -425,7 +425,7 @@ int test_query(MYSQL *mysql)
MYSQL_BIND bind[1];
char tmp[20];
char *stmtstr= "CALL P1(?)";
const char *stmtstr= "CALL P1(?)";
rc= mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
check_mysql_rc(rc, mysql);

View File

@@ -123,7 +123,7 @@ static int test_ssl(MYSQL *mysql)
res= mysql_store_result(mysql);
row= mysql_fetch_row(res);
diag("user: %s", row[0]);
if (p= strchr(row[0], '@'))
if ((p= strchr(row[0], '@')))
strcpy(sslhost, p+1);
mysql_free_result(res);
}
@@ -131,7 +131,7 @@ static int test_ssl(MYSQL *mysql)
return OK;
}
static int test_ssl_cipher(MYSQL *unused)
static int test_ssl_cipher(MYSQL *unused __attribute__((unused)))
{
MYSQL *my;
MYSQL_RES *res;
@@ -162,7 +162,7 @@ static int test_ssl_cipher(MYSQL *unused)
return OK;
}
static int test_conc95(MYSQL *my)
static int test_conc95(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -180,7 +180,7 @@ static int test_conc95(MYSQL *my)
NULL);
if (!mysql_real_connect(mysql, hostname, "ssluser1", sslpw, schema,
port, socketname, 0))
port, socketname, 0))
{
diag("could not establish x509 connection. Error: %s", mysql_error(mysql));
mysql_close(mysql);
@@ -190,7 +190,7 @@ static int test_conc95(MYSQL *my)
return OK;
}
static int test_multi_ssl_connections(MYSQL *unused)
static int test_multi_ssl_connections(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql[50], *my;
int i, rc;
@@ -255,7 +255,7 @@ static int test_multi_ssl_connections(MYSQL *unused)
}
#ifndef WIN32
static void ssl_thread(void *dummy)
static void ssl_thread(void *unused __attribute__((unused)))
#else
DWORD WINAPI ssl_thread(void *dummy)
#endif
@@ -343,7 +343,7 @@ static int test_ssl_threads(MYSQL *mysql)
return OK;
}
static int test_phpbug51647(MYSQL *my)
static int test_phpbug51647(MYSQL *unused __attribute__((unused)))
{
MYSQL* mysql;
@@ -365,7 +365,7 @@ static int test_phpbug51647(MYSQL *my)
return OK;
}
static int test_password_protected(MYSQL *my)
static int test_password_protected(MYSQL *unused __attribute__((unused)))
{
MYSQL* mysql;
@@ -390,7 +390,7 @@ static int test_password_protected(MYSQL *my)
}
static int test_conc50(MYSQL *my)
static int test_conc50(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -411,7 +411,7 @@ static int test_conc50(MYSQL *my)
return OK;
}
static int test_conc50_1(MYSQL *my)
static int test_conc50_1(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -433,7 +433,7 @@ static int test_conc50_1(MYSQL *my)
return OK;
}
static int test_conc50_2(MYSQL *my)
static int test_conc50_2(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -453,10 +453,13 @@ static int test_conc50_2(MYSQL *my)
return OK;
}
static int test_conc127(MYSQL *my)
static int test_conc127(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
diag("test disabled - for testing disable other tests or run this test as first test");
return SKIP;
if (check_skip_ssl())
return SKIP;
@@ -474,7 +477,7 @@ static int test_conc127(MYSQL *my)
return OK;
}
static int test_conc50_3(MYSQL *my)
static int test_conc50_3(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -507,7 +510,7 @@ static int test_conc50_3(MYSQL *my)
return OK;
}
static int test_conc50_4(MYSQL *my)
static int test_conc50_4(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -527,7 +530,7 @@ static int test_conc50_4(MYSQL *my)
return OK;
}
static int verify_ssl_server_cert(MYSQL *my)
static int verify_ssl_server_cert(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
uint verify= 1;
@@ -550,7 +553,7 @@ static int verify_ssl_server_cert(MYSQL *my)
return OK;
}
static int test_bug62743(MYSQL *my)
static int test_bug62743(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql;
@@ -638,7 +641,7 @@ DWORD WINAPI thread_conc102(void)
check_mysql_rc(rc, mysql);
pthread_mutex_unlock(&LOCK_test);
check_mysql_rc(rc, mysql);
if (res= mysql_store_result(mysql))
if ((res= mysql_store_result(mysql)))
mysql_free_result(res);
end:
mysql_close(mysql);
@@ -702,7 +705,7 @@ static int test_conc_102(MYSQL *mysql)
const char *ssl_cert_finger_print= "@SSL_CERT_FINGER_PRINT@";
static int test_ssl_fp(MYSQL *unused)
static int test_ssl_fp(MYSQL *unused __attribute__((unused)))
{
MYSQL *my;
MYSQL_RES *res;
@@ -741,7 +744,7 @@ static int test_ssl_fp(MYSQL *unused)
return OK;
}
static int test_ssl_fp_list(MYSQL *unused)
static int test_ssl_fp_list(MYSQL *unused __attribute__((unused)))
{
MYSQL *my;
@@ -763,7 +766,7 @@ static int test_ssl_fp_list(MYSQL *unused)
return OK;
}
static int test_ssl_version(MYSQL *mysql)
static int test_ssl_version(MYSQL *unused __attribute__((unused)))
{
unsigned int iversion;
const char *version, *library;
@@ -794,7 +797,7 @@ static int test_ssl_version(MYSQL *mysql)
}
#ifdef HAVE_SCHANNEL
static int test_schannel_cipher(MYSQL *mysql)
static int test_schannel_cipher(MYSQL *unused __attribute__((unused)))
{
MYSQL *my;
unsigned int cipher_strength= 256;
@@ -819,11 +822,67 @@ static int test_schannel_cipher(MYSQL *mysql)
}
#endif
#ifdef HAVE_GNUTLS
static int test_cipher_mapping(MYSQL *unused __attribute__((unused)))
{
unsigned int i=0;
const char *ciphers[]= { "DHE-RSA-AES256-GCM-SHA384", "DHE-RSA-AES256-SHA256", "DHE-RSA-AES256-SHA",
"DHE-RSA-CAMELLIA256-SHA", "AES256-GCM-SHA384", "AES256-SHA256",
"AES256-SHA", "CAMELLIA256-SHA", "DHE-RSA-AES128-GCM-SHA256",
"DHE-RSA-AES128-SHA256", "DHE-RSA-AES128-SHA", "DHE-RSA-CAMELLIA128-SHA",
"AES128-GCM-SHA256", "AES128-SHA256", "AES128-SHA", "CAMELLIA128-SHA",
"EDH-RSA-DES-CBC3-SHA", "DES-CBC3-SHA", "DHE-RSA-AES256-SHA",
"DHE-RSA-CAMELLIA256-SHA", "AES256-SHA", "CAMELLIA256-SHA",
NULL };
if (check_skip_ssl())
return SKIP;
while (ciphers[i] != NULL)
{
MYSQL *mysql= mysql_init(NULL);
MYSQL_ROW row;
MYSQL_RES *res;
char c[100];
int rc;
mysql_options(mysql, MYSQL_OPT_SSL_CIPHER, ciphers[i]);
diag("%s", ciphers[i]);
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
port, socketname, 0), mysql_error(mysql));
if (strcmp(ciphers[i], mysql_get_ssl_cipher(mysql)) != 0)
{
diag("expected: %s instead of %s", ciphers[i], mysql_get_ssl_cipher(mysql));
mysql_close(mysql);
return FAIL;
}
rc= mysql_query(mysql, "SHOW STATUS LIKE 'ssl_cipher'");
check_mysql_rc(rc, mysql);
res= mysql_store_result(mysql);
row= mysql_fetch_row(res);
strcpy(c, row[1]);
mysql_free_result(res);
mysql_close(mysql);
if (strcmp(ciphers[i], c) != 0)
{
diag("expected: %s instead of %s", ciphers[i], c);
return FAIL;
}
i++;
}
return OK;
}
#endif
struct my_tests_st my_tests[] = {
{"test_ssl", test_ssl, TEST_CONNECTION_NEW, 0, NULL, NULL},
// {"test_conc127", test_conc127, TEST_CONNECTION_NEW, 0, NULL, NULL},
#ifdef HAVE_GNUTLS
{"test_cipher_mapping", test_cipher_mapping, TEST_CONNECTION_NONE, 0, NULL, NULL},
#endif
{"test_conc127", test_conc127, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_ssl_fp", test_ssl_fp, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_ssl_fp_list", test_ssl_fp_list, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc50", test_conc50, TEST_CONNECTION_NEW, 0, NULL, NULL},

View File

@@ -4,7 +4,7 @@
#include "my_test.h"
#include "ma_pvio.h"
static int aurora1(MYSQL *my)
static int aurora1(MYSQL *unused __attribute__((unused)))
{
int rc;
my_bool read_only= 1;
@@ -54,7 +54,7 @@ static int aurora1(MYSQL *my)
return OK;
}
static int test_wrong_user(MYSQL *my)
static int test_wrong_user(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
@@ -68,7 +68,7 @@ static int test_wrong_user(MYSQL *my)
return OK;
}
static int test_reconnect(MYSQL *my)
static int test_reconnect(MYSQL *unused __attribute__((unused)))
{
MYSQL *mysql= mysql_init(NULL);
MYSQL_RES *res;

View File

@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "my_test.h"
static int test_conc_173(MYSQL *my)
static int test_conc_173(MYSQL *unused __attribute__((unused)))
{
MYSQL mysql;
int arg;

View File

@@ -4,7 +4,7 @@
#include "my_test.h"
#include <ma_pthread.h>
static int basic_connect(MYSQL *mysql)
static int basic_connect(MYSQL *unused __attribute__((unused)))
{
MYSQL_ROW row;
MYSQL_RES *res;
@@ -14,7 +14,7 @@ static int basic_connect(MYSQL *mysql)
MYSQL *my= mysql_init(NULL);
FAIL_IF(!my, "mysql_init() failed");
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
FAIL_IF(!my_test_connect(my, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
rc= mysql_query(my, "SELECT @@version");
@@ -123,7 +123,7 @@ DWORD WINAPI thread_conc27(void)
MYSQL_RES *res;
mysql_thread_init();
mysql= mysql_init(NULL);
if(!mysql_real_connect(mysql, hostname, username, password, schema,
if(!my_test_connect(mysql, hostname, username, password, schema,
port, socketname, 0))
{
diag(">Error: %s", mysql_error(mysql));