diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 9 | ||||
-rw-r--r-- | tests/bug25714.c | 3 | ||||
-rwxr-xr-x | tests/fork_big.pl | 2 | ||||
-rw-r--r-- | tests/fork_big2.pl | 2 | ||||
-rwxr-xr-x | tests/mail_to_db.pl | 2 | ||||
-rw-r--r-- | tests/mysql_client_test.c | 1510 | ||||
-rw-r--r-- | tests/thread_test.c | 28 |
7 files changed, 1405 insertions, 151 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 1c39a3630dd..fbd58b88b9c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,6 +17,13 @@ ## Process this file with automake to create Makefile.in + +if THREAD_SAFE_CLIENT +LIBMYSQLCLIENT_LA = $(top_builddir)/libmysql_r/libmysqlclient_r.la +else +LIBMYSQLCLIENT_LA = $(top_builddir)/libmysql/libmysqlclient.la +endif + EXTRA_DIST = auto_increment.res auto_increment.tst \ function.res function.tst lock_test.pl lock_test.res \ export.pl big_record.pl \ @@ -34,7 +41,7 @@ INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ $(openssl_includes) LIBS = @CLIENT_LIBS@ LDADD = @CLIENT_EXTRA_LDFLAGS@ \ - $(top_builddir)/libmysql/libmysqlclient.la + $(LIBMYSQLCLIENT_LA) mysql_client_test_LDADD= $(LDADD) $(CXXLDFLAGS) mysql_client_test_SOURCES= mysql_client_test.c\ diff --git a/tests/bug25714.c b/tests/bug25714.c index e9b2be44209..4782178e2f2 100644 --- a/tests/bug25714.c +++ b/tests/bug25714.c @@ -68,4 +68,5 @@ int main (int argc, char **argv) my_end(0); return 0; -}; +} + diff --git a/tests/fork_big.pl b/tests/fork_big.pl index c72eb59946b..5c4f11b00e2 100755 --- a/tests/fork_big.pl +++ b/tests/fork_big.pl @@ -65,7 +65,7 @@ if (!$opt_skip_create) } # Create the table we use to signal that we should end the test $dbh->do("drop table if exists $abort_table"); - $dbh->do("create table $abort_table (id int(6) not null) type=heap") || + $dbh->do("create table $abort_table (id int(6) not null) ENGINE=heap") || die $DBI::errstr; } diff --git a/tests/fork_big2.pl b/tests/fork_big2.pl index 567cfafa176..8a0c5e317a0 100644 --- a/tests/fork_big2.pl +++ b/tests/fork_big2.pl @@ -89,7 +89,7 @@ if (!$opt_skip_create) } # Create the table we use to signal that we should end the test $dbh->do("drop table if exists $abort_table"); - $dbh->do("create table $abort_table (id int(6) not null) type=heap") || + $dbh->do("create table $abort_table (id int(6) not null) ENGINE=heap") || die $DBI::errstr; } diff --git a/tests/mail_to_db.pl b/tests/mail_to_db.pl index 5ceda392313..e50415d96f3 100755 --- a/tests/mail_to_db.pl +++ b/tests/mail_to_db.pl @@ -253,7 +253,7 @@ CREATE TABLE my_mail KEY (message_id), KEY (in_reply_to), PRIMARY KEY (mail_from, date, hash)) - TYPE=MyISAM COMMENT='' + ENGINE=MyISAM COMMENT='' EOF $sth = $dbh->prepare($query) or die $DBI::errstr; $sth->execute() or die "Couldn't create table: $DBI::errstr\n"; diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 65e18da97f1..808d6fe30de 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -32,6 +32,7 @@ #include <errmsg.h> #include <my_getopt.h> #include <m_string.h> +#include <mysqld_error.h> #define VER "2.1" #define MAX_TEST_QUERY_LENGTH 300 /* MAX QUERY BUFFER LENGTH */ @@ -82,6 +83,7 @@ struct my_tests_st }; #define myheader(str) \ +DBUG_PRINT("test", ("name: %s", str)); \ if (opt_silent < 2) \ { \ fprintf(stdout, "\n\n#####################################\n"); \ @@ -89,7 +91,9 @@ if (opt_silent < 2) \ opt_count, str); \ fprintf(stdout, " \n#####################################\n"); \ } + #define myheader_r(str) \ +DBUG_PRINT("test", ("name: %s", str)); \ if (!opt_silent) \ { \ fprintf(stdout, "\n\n#####################################\n"); \ @@ -115,6 +119,8 @@ static void client_disconnect(void); #define DIE_UNLESS(expr) \ ((void) ((expr) ? 0 : (die(__FILE__, __LINE__, #expr), 0))) +#define DIE_IF(expr) \ + ((void) ((expr) ? (die(__FILE__, __LINE__, #expr), 0) : 0)) #define DIE(expr) \ die(__FILE__, __LINE__, #expr) @@ -173,8 +179,8 @@ if (stmt == 0) \ DIE_UNLESS(stmt == 0);\ } -#define mytest(x) if (!x) {myerror(NULL);DIE_UNLESS(FALSE);} -#define mytest_r(x) if (x) {myerror(NULL);DIE_UNLESS(FALSE);} +#define mytest(x) if (!(x)) {myerror(NULL);DIE_UNLESS(FALSE);} +#define mytest_r(x) if ((x)) {myerror(NULL);DIE_UNLESS(FALSE);} /* A workaround for Sun Forte 5.6 on Solaris x86 */ @@ -297,7 +303,7 @@ static void client_connect(ulong flag) mysql->reconnect= 1; if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); /* set AUTOCOMMIT to ON*/ mysql_autocommit(mysql, TRUE); @@ -320,7 +326,7 @@ static void client_connect(ulong flag) have_innodb= check_have_innodb(mysql); if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); } @@ -340,12 +346,13 @@ static void client_disconnect() mysql_query(mysql, query); if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); if (!opt_silent) fprintf(stdout, "\n closing the connection ..."); mysql_close(mysql); - fprintf(stdout, " OK\n"); + if (!opt_silent) + fprintf(stdout, "OK\n"); } } @@ -1218,7 +1225,7 @@ static void test_tran_bdb() /* create the table 'mytran_demo' of type BDB' or 'InnoDB' */ rc= mysql_query(mysql, "CREATE TABLE my_demo_transaction( " - "col1 int , col2 varchar(30)) TYPE= BDB"); + "col1 int , col2 varchar(30)) ENGINE= BDB"); myquery(rc); /* insert a row and commit the transaction */ @@ -1291,7 +1298,7 @@ static void test_tran_innodb() /* create the table 'mytran_demo' of type BDB' or 'InnoDB' */ rc= mysql_query(mysql, "CREATE TABLE my_demo_transaction(col1 int, " - "col2 varchar(30)) TYPE= InnoDB"); + "col2 varchar(30)) ENGINE= InnoDB"); myquery(rc); /* insert a row and commit the transaction */ @@ -2353,6 +2360,270 @@ static void test_ps_conj_select() } +/* reads Qcache_hits from server and returns its value */ +static uint query_cache_hits(MYSQL *conn) +{ + MYSQL_RES *res; + MYSQL_ROW row; + int rc; + uint result; + + rc= mysql_query(conn, "show status like 'qcache_hits'"); + myquery(rc); + res= mysql_use_result(conn); + DIE_UNLESS(res); + + row= mysql_fetch_row(res); + DIE_UNLESS(row); + + result= atoi(row[1]); + mysql_free_result(res); + return result; +} + + +/* + utility for the next test; expects 3 rows in the result from a SELECT, + compares each row/field with an expected value. + */ +#define test_ps_query_cache_result(i1,s1,l1,i2,s2,l2,i3,s3,l3) \ + r_metadata= mysql_stmt_result_metadata(stmt); \ + DIE_UNLESS(r_metadata != NULL); \ + rc= mysql_stmt_fetch(stmt); \ + check_execute(stmt, rc); \ + if (!opt_silent) \ + fprintf(stdout, "\n row 1: %d, %s(%lu)", r_int_data, \ + r_str_data, r_str_length); \ + DIE_UNLESS((r_int_data == i1) && (r_str_length == l1) && \ + (strcmp(r_str_data, s1) == 0)); \ + rc= mysql_stmt_fetch(stmt); \ + check_execute(stmt, rc); \ + if (!opt_silent) \ + fprintf(stdout, "\n row 2: %d, %s(%lu)", r_int_data, \ + r_str_data, r_str_length); \ + DIE_UNLESS((r_int_data == i2) && (r_str_length == l2) && \ + (strcmp(r_str_data, s2) == 0)); \ + rc= mysql_stmt_fetch(stmt); \ + check_execute(stmt, rc); \ + if (!opt_silent) \ + fprintf(stdout, "\n row 3: %d, %s(%lu)", r_int_data, \ + r_str_data, r_str_length); \ + DIE_UNLESS((r_int_data == i3) && (r_str_length == l3) && \ + (strcmp(r_str_data, s3) == 0)); \ + rc= mysql_stmt_fetch(stmt); \ + DIE_UNLESS(rc == MYSQL_NO_DATA); \ + mysql_free_result(r_metadata); + + +/* + Test that prepared statements make use of the query cache just as normal + statements (BUG#735). +*/ +static void test_ps_query_cache() +{ + MYSQL *lmysql; + MYSQL_STMT *stmt; + int rc; + MYSQL_BIND p_bind[2],r_bind[2]; /* p: param bind; r: result bind */ + int32 p_int_data, r_int_data; + char p_str_data[32], r_str_data[32]; + unsigned long p_str_length, r_str_length; + MYSQL_RES *r_metadata; + char query[MAX_TEST_QUERY_LENGTH]; + uint hits1, hits2; + enum enum_test_ps_query_cache + { + /* + We iterate the same prepare/executes block, but have iterations where + we vary the query cache conditions. + */ + /* the query cache is enabled for the duration of prep&execs: */ + TEST_QCACHE_ON= 0, + /* + same but using a new connection (to see if qcache serves results from + the previous connection as it should): + */ + TEST_QCACHE_ON_WITH_OTHER_CONN, + /* + First border case: disables the query cache before prepare and + re-enables it before execution (to test if we have no bug then): + */ + TEST_QCACHE_OFF_ON, + /* + Second border case: enables the query cache before prepare and + disables it before execution: + */ + TEST_QCACHE_ON_OFF + }; + enum enum_test_ps_query_cache iteration; + LINT_INIT(lmysql); + + myheader("test_ps_query_cache"); + + /* prepare the table */ + + rc= mysql_query(mysql, "drop table if exists t1"); + myquery(rc); + + rc= mysql_query(mysql, "create table t1 (id1 int(11) NOT NULL default '0', " + "value2 varchar(100), value1 varchar(100))"); + myquery(rc); + + rc= mysql_query(mysql, "insert into t1 values (1, 'hh', 'hh'), " + "(2, 'hh', 'hh'), (1, 'ii', 'ii'), (2, 'ii', 'ii')"); + myquery(rc); + + for (iteration= TEST_QCACHE_ON; iteration <= TEST_QCACHE_ON_OFF; iteration++) + { + + switch (iteration) + { + case TEST_QCACHE_ON: + case TEST_QCACHE_ON_OFF: + rc= mysql_query(mysql, "set global query_cache_size=1000000"); + myquery(rc); + break; + case TEST_QCACHE_OFF_ON: + rc= mysql_query(mysql, "set global query_cache_size=0"); + myquery(rc); + break; + case TEST_QCACHE_ON_WITH_OTHER_CONN: + if (!opt_silent) + fprintf(stdout, "\n Establishing a test connection ..."); + if (!(lmysql= mysql_init(NULL))) + { + myerror("mysql_init() failed"); + exit(1); + } + if (!(mysql_real_connect(lmysql, opt_host, opt_user, + opt_password, current_db, opt_port, + opt_unix_socket, 0))) + { + myerror("connection failed"); + mysql_close(lmysql); + exit(1); + } + if (!opt_silent) + fprintf(stdout, "OK"); + mysql= lmysql; + } + + strmov(query, "select id1, value1 from t1 where id1= ? or " + "CONVERT(value1 USING utf8)= ?"); + stmt= mysql_simple_prepare(mysql, query); + check_stmt(stmt); + + verify_param_count(stmt, 2); + + switch(iteration) + { + case TEST_QCACHE_OFF_ON: + rc= mysql_query(mysql, "set global query_cache_size=1000000"); + myquery(rc); + break; + case TEST_QCACHE_ON_OFF: + rc= mysql_query(mysql, "set global query_cache_size=0"); + myquery(rc); + default: + break; + } + + bzero((char*) p_bind, sizeof(p_bind)); + p_bind[0].buffer_type= MYSQL_TYPE_LONG; + p_bind[0].buffer= (void *)&p_int_data; + p_bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; + p_bind[1].buffer= (void *)p_str_data; + p_bind[1].buffer_length= array_elements(p_str_data); + p_bind[1].length= &p_str_length; + + rc= mysql_stmt_bind_param(stmt, p_bind); + check_execute(stmt, rc); + + p_int_data= 1; + strmov(p_str_data, "hh"); + p_str_length= strlen(p_str_data); + + bzero((char*) r_bind, sizeof(r_bind)); + r_bind[0].buffer_type= MYSQL_TYPE_LONG; + r_bind[0].buffer= (void *)&r_int_data; + r_bind[1].buffer_type= MYSQL_TYPE_VAR_STRING; + r_bind[1].buffer= (void *)r_str_data; + r_bind[1].buffer_length= array_elements(r_str_data); + r_bind[1].length= &r_str_length; + + rc= mysql_stmt_bind_result(stmt, r_bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + test_ps_query_cache_result(1, "hh", 2, 2, "hh", 2, 1, "ii", 2); + + /* now retry with the same parameter values and see qcache hits */ + hits1= query_cache_hits(mysql); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + test_ps_query_cache_result(1, "hh", 2, 2, "hh", 2, 1, "ii", 2); + hits2= query_cache_hits(mysql); + switch(iteration) { + case TEST_QCACHE_ON_WITH_OTHER_CONN: + case TEST_QCACHE_ON: /* should have hit */ + DIE_UNLESS(hits2-hits1 == 1); + break; + case TEST_QCACHE_OFF_ON: + case TEST_QCACHE_ON_OFF: /* should not have hit */ + DIE_UNLESS(hits2-hits1 == 0); + break; + } + + /* now modify parameter values and see qcache hits */ + strmov(p_str_data, "ii"); + p_str_length= strlen(p_str_data); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + test_ps_query_cache_result(1, "hh", 2, 1, "ii", 2, 2, "ii", 2); + hits1= query_cache_hits(mysql); + + switch(iteration) { + case TEST_QCACHE_ON: + case TEST_QCACHE_OFF_ON: + case TEST_QCACHE_ON_OFF: /* should not have hit */ + DIE_UNLESS(hits2-hits1 == 0); + break; + case TEST_QCACHE_ON_WITH_OTHER_CONN: /* should have hit */ + DIE_UNLESS(hits1-hits2 == 1); + break; + } + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + test_ps_query_cache_result(1, "hh", 2, 1, "ii", 2, 2, "ii", 2); + hits2= query_cache_hits(mysql); + + mysql_stmt_close(stmt); + + switch(iteration) { + case TEST_QCACHE_ON: /* should have hit */ + DIE_UNLESS(hits2-hits1 == 1); + break; + case TEST_QCACHE_OFF_ON: + case TEST_QCACHE_ON_OFF: /* should not have hit */ + DIE_UNLESS(hits2-hits1 == 0); + break; + case TEST_QCACHE_ON_WITH_OTHER_CONN: /* should have hit */ + DIE_UNLESS(hits2-hits1 == 1); + break; + } + + } /* for(iteration=...) */ + + rc= mysql_query(mysql, "set global query_cache_size=0"); + myquery(rc); + +} + + /* Test BUG#1115 (incorrect string parameter value allocation) */ static void test_bug1115() @@ -4674,7 +4945,7 @@ static void test_stmt_close() } lmysql->reconnect= 1; if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); /* set AUTOCOMMIT to ON*/ @@ -4721,7 +4992,7 @@ static void test_stmt_close() close statements by hand once mysql_close() had been called. Now mysql_close() doesn't free any statements, so this test doesn't serve its original designation any more. - Here we free stmt2 and stmt3 by hande to avoid memory leaks. + Here we free stmt2 and stmt3 by hand to avoid memory leaks. */ mysql_stmt_close(stmt2); mysql_stmt_close(stmt3); @@ -7205,7 +7476,7 @@ static void test_prepare_grant() } lmysql->reconnect= 1; if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); mysql= lmysql; rc= mysql_query(mysql, "INSERT INTO test_grant VALUES(NULL)"); @@ -7545,16 +7816,16 @@ static void test_explain_bug() "", "", "", 19, 0); verify_prepare_field(result, 2, "table", "", MYSQL_TYPE_VAR_STRING, - "", "", "", NAME_LEN, 0); + "", "", "", NAME_CHAR_LEN, 0); verify_prepare_field(result, 3, "type", "", MYSQL_TYPE_VAR_STRING, "", "", "", 10, 0); verify_prepare_field(result, 4, "possible_keys", "", MYSQL_TYPE_VAR_STRING, - "", "", "", NAME_LEN*MAX_KEY, 0); + "", "", "", NAME_CHAR_LEN*MAX_KEY, 0); verify_prepare_field(result, 5, "key", "", MYSQL_TYPE_VAR_STRING, - "", "", "", NAME_LEN, 0); + "", "", "", NAME_CHAR_LEN, 0); if (mysql_get_server_version(mysql) <= 50000) { @@ -7564,13 +7835,11 @@ static void test_explain_bug() else { verify_prepare_field(result, 6, "key_len", "", MYSQL_TYPE_VAR_STRING, "", - "", "", - NAME_LEN*MAX_KEY / my_charset_utf8_general_ci.mbmaxlen, - 0); + "", "", NAME_CHAR_LEN*MAX_KEY/ my_charset_utf8_general_ci.mbmaxlen, 0); } verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING, - "", "", "", NAME_LEN*16, 0); + "", "", "", NAME_CHAR_LEN*16, 0); verify_prepare_field(result, 8, "rows", "", MYSQL_TYPE_LONGLONG, "", "", "", 10, 0); @@ -7668,7 +7937,7 @@ static void test_drop_temp() } lmysql->reconnect= 1; if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); mysql= lmysql; rc= mysql_query(mysql, "INSERT INTO t1 VALUES(10, 'C')"); @@ -8699,7 +8968,7 @@ static void test_sqlmode() if (!opt_silent) fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); - check_stmt_r(stmt); + check_stmt(stmt); /* ANSI */ strmov(query, "SET SQL_MODE= \"ANSI\""); @@ -9897,7 +10166,7 @@ static void test_derived() myquery(rc); rc= mysql_query(mysql, "create table t1 (id int(8), primary key (id)) \ -TYPE=InnoDB DEFAULT CHARSET=utf8"); +ENGINE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); rc= mysql_query(mysql, "insert into t1 values (1)"); @@ -9945,16 +10214,16 @@ static void test_xjoin() rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1, t2, t3, t4"); myquery(rc); - rc= mysql_query(mysql, "create table t3 (id int(8), param1_id int(8), param2_id int(8)) TYPE=InnoDB DEFAULT CHARSET=utf8"); + rc= mysql_query(mysql, "create table t3 (id int(8), param1_id int(8), param2_id int(8)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); - rc= mysql_query(mysql, "create table t1 ( id int(8), name_id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8"); + rc= mysql_query(mysql, "create table t1 ( id int(8), name_id int(8), value varchar(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); - rc= mysql_query(mysql, "create table t2 (id int(8), name_id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8;"); + rc= mysql_query(mysql, "create table t2 (id int(8), name_id int(8), value varchar(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); myquery(rc); - rc= mysql_query(mysql, "create table t4(id int(8), value varchar(10)) TYPE=InnoDB DEFAULT CHARSET=utf8"); + rc= mysql_query(mysql, "create table t4(id int(8), value varchar(10)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); myquery(rc); rc= mysql_query(mysql, "insert into t3 values (1, 1, 1), (2, 2, null)"); @@ -11003,7 +11272,7 @@ static void test_view() strmov(str_data, "TEST"); bzero((char*) my_bind, sizeof(my_bind)); - my_bind[0].buffer_type= FIELD_TYPE_STRING; + my_bind[0].buffer_type= MYSQL_TYPE_STRING; my_bind[0].buffer= (char *)&str_data; my_bind[0].buffer_length= 50; my_bind[0].length= &length; @@ -11241,7 +11510,7 @@ static void test_view_insert() check_execute(select_stmt, rc); bzero((char*) my_bind, sizeof(my_bind)); - my_bind[0].buffer_type = FIELD_TYPE_LONG; + my_bind[0].buffer_type = MYSQL_TYPE_LONG; my_bind[0].buffer = (char *)&my_val; my_bind[0].length = &my_length; my_bind[0].is_null = (char*)&my_null; @@ -11756,16 +12025,24 @@ static void test_bug5315() stmt= mysql_stmt_init(mysql); rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); DIE_UNLESS(rc == 0); + if (!opt_silent) + printf("Excuting mysql_change_user\n"); mysql_change_user(mysql, opt_user, opt_password, current_db); + if (!opt_silent) + printf("Excuting mysql_stmt_execute\n"); rc= mysql_stmt_execute(stmt); DIE_UNLESS(rc != 0); if (rc) { if (!opt_silent) - printf("Got error (as expected):\n%s", mysql_stmt_error(stmt)); + printf("Got error (as expected): '%s'\n", mysql_stmt_error(stmt)); } /* check that connection is OK */ + if (!opt_silent) + printf("Excuting mysql_stmt_close\n"); mysql_stmt_close(stmt); + if (!opt_silent) + printf("Excuting mysql_stmt_init\n"); stmt= mysql_stmt_init(mysql); rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); DIE_UNLESS(rc == 0); @@ -12018,16 +12295,24 @@ static void test_bug6081() int rc; myheader("test_bug6081"); - rc= simple_command(mysql, COM_DROP_DB, current_db, + rc= simple_command(mysql, COM_DROP_DB, (uchar*) current_db, (ulong)strlen(current_db), 0); - myquery(rc); - rc= simple_command(mysql, COM_DROP_DB, current_db, + if (rc == 0 && mysql_errno(mysql) != ER_UNKNOWN_COM_ERROR) + { + myerror(NULL); /* purecov: inspected */ + die(__FILE__, __LINE__, "COM_DROP_DB failed"); /* purecov: inspected */ + } + rc= simple_command(mysql, COM_DROP_DB, (uchar*) current_db, (ulong)strlen(current_db), 0); myquery_r(rc); - rc= simple_command(mysql, COM_CREATE_DB, current_db, + rc= simple_command(mysql, COM_CREATE_DB, (uchar*) current_db, (ulong)strlen(current_db), 0); - myquery(rc); - rc= simple_command(mysql, COM_CREATE_DB, current_db, + if (rc == 0 && mysql_errno(mysql) != ER_UNKNOWN_COM_ERROR) + { + myerror(NULL); /* purecov: inspected */ + die(__FILE__, __LINE__, "COM_CREATE_DB failed"); /* purecov: inspected */ + } + rc= simple_command(mysql, COM_CREATE_DB, (uchar*) current_db, (ulong)strlen(current_db), 0); myquery_r(rc); rc= mysql_select_db(mysql, current_db); @@ -12446,6 +12731,7 @@ static void test_rewind(void) /* retreive all result sets till we are at the end */ while(!mysql_stmt_fetch(stmt)) + if (!opt_silent) printf("fetched result:%ld\n", Data); DIE_UNLESS(rc != MYSQL_NO_DATA); @@ -12456,6 +12742,7 @@ static void test_rewind(void) /* now we should be able to fetch the results again */ /* but mysql_stmt_fetch returns MYSQL_NO_DATA */ while(!(rc= mysql_stmt_fetch(stmt))) + if (!opt_silent) printf("fetched result after seek:%ld\n", Data); DIE_UNLESS(rc == MYSQL_NO_DATA); @@ -13006,7 +13293,7 @@ static void test_bug8378() exit(1); } if (!opt_silent) - fprintf(stdout, " OK"); + fprintf(stdout, "OK"); len= mysql_real_escape_string(mysql, out, TEST_BUG8378_IN, 4); @@ -13175,7 +13462,8 @@ static void test_bug9520() DIE_UNLESS(rc == MYSQL_NO_DATA); - printf("Fetched %d rows\n", row_count); + if (!opt_silent) + printf("Fetched %d rows\n", row_count); DBUG_ASSERT(row_count == 3); mysql_stmt_close(stmt); @@ -13248,10 +13536,11 @@ static void test_bug9478() { char buff[8]; - /* Fill in the fethc packet */ + /* Fill in the fetch packet */ int4store(buff, stmt->stmt_id); buff[4]= 1; /* prefetch rows */ - rc= ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH, buff, + rc= ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH, + (uchar*) buff, sizeof(buff), 0,0,1,NULL) || (*mysql->methods->read_query_result)(mysql)); DIE_UNLESS(rc); @@ -13428,7 +13717,7 @@ static void test_bug11111() for (i=0; i < 2; i++) { my_bind[i].buffer_type= MYSQL_TYPE_STRING; - my_bind[i].buffer= (gptr *)&buf[i]; + my_bind[i].buffer= (uchar* *)&buf[i]; my_bind[i].buffer_length= 20; my_bind[i].length= &len[i]; } @@ -13813,7 +14102,7 @@ static void test_bug11656() for (i=0; i < 2; i++) { my_bind[i].buffer_type= MYSQL_TYPE_STRING; - my_bind[i].buffer= (gptr *)&buf[i]; + my_bind[i].buffer= (uchar* *)&buf[i]; my_bind[i].buffer_length= strlen(buf[i]); } mysql_stmt_bind_param(stmt, my_bind); @@ -14596,7 +14885,7 @@ static void test_bug14210() itself is not InnoDB related. In case the table is MyISAM this test is harmless. */ - mysql_query(mysql, "create table t1 (a varchar(255)) type=InnoDB"); + mysql_query(mysql, "create table t1 (a varchar(255)) engine=InnoDB"); rc= mysql_query(mysql, "insert into t1 (a) values (repeat('a', 256))"); myquery(rc); rc= mysql_query(mysql, "set @@session.max_heap_table_size=16384"); @@ -14957,6 +15246,24 @@ static void test_bug16143() } +/* Bug #16144: mysql_stmt_attr_get type error */ + +static void test_bug16144() +{ + const my_bool flag_orig= (my_bool) 0xde; + my_bool flag= flag_orig; + MYSQL_STMT *stmt; + myheader("test_bug16144"); + + /* Check that attr_get returns correct data on little and big endian CPUs */ + stmt= mysql_stmt_init(mysql); + mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (const void*) &flag); + mysql_stmt_attr_get(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*) &flag); + DIE_UNLESS(flag == flag_orig); + + mysql_stmt_close(stmt); +} + /* Bug #15613: "libmysqlclient API function mysql_stmt_prepare returns wrong field length" @@ -15057,8 +15364,28 @@ static void test_bug17667() myheader("test_bug17667"); + master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1); + strxmov(master_log_filename, opt_vardir, "/log/master.log", NullS); + if (!opt_silent) + printf("Opening '%s'\n", master_log_filename); + log_file= my_fopen(master_log_filename, (int) (O_RDONLY | O_BINARY), MYF(0)); + free(master_log_filename); + + if (log_file == NULL) + { + if (!opt_silent) + { + printf("Could not find the log file, VARDIR/log/master.log, so " + "test_bug17667 is not run.\n" + "Run test from the mysql-test/mysql-test-run* program to set up " + "correct environment for this test.\n\n"); + } + return; + } + for (statement_cursor= statements; statement_cursor->buffer != NULL; - statement_cursor++) { + statement_cursor++) + { if (statement_cursor->qt == QT_NORMAL) { /* Run statement as normal query */ @@ -15069,10 +15396,10 @@ static void test_bug17667() else if (statement_cursor->qt == QT_PREPARED) { /* - Run as prepared statement + Run as prepared statement - NOTE! All these queries should be in the log twice, - one time for prepare and one time for execute + NOTE! All these queries should be in the log twice, + one time for prepare and one time for execute */ stmt= mysql_stmt_init(mysql); @@ -15095,66 +15422,49 @@ static void test_bug17667() rc= mysql_query(mysql, "flush logs"); myquery(rc); - master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1); - strcpy(master_log_filename, opt_vardir); - strcat(master_log_filename, "/log/master.log"); - printf("Opening '%s'\n", master_log_filename); - log_file= my_fopen(master_log_filename, (int) (O_RDONLY | O_BINARY), MYF(MY_WME)); - free(master_log_filename); + for (statement_cursor= statements; statement_cursor->buffer != NULL; + statement_cursor++) + { + int expected_hits= 1, hits= 0; + char line_buffer[MAX_TEST_QUERY_LENGTH*2]; + /* more than enough room for the query and some marginalia. */ - if (log_file != NULL) { + /* Prepared statments always occurs twice in log */ + if (statement_cursor->qt == QT_PREPARED) + expected_hits++; - for (statement_cursor= statements; statement_cursor->buffer != NULL; - statement_cursor++) { - int expected_hits= 1, hits= 0; - char line_buffer[MAX_TEST_QUERY_LENGTH*2]; - /* more than enough room for the query and some marginalia. */ + /* Loop until we found expected number of log entries */ + do { + /* Loop until statement is found in log */ + do { + memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2); - /* Prepared statments always occurs twice in log */ - if (statement_cursor->qt == QT_PREPARED) - expected_hits++; + if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL) + { + /* If fgets returned NULL, it indicates either error or EOF */ + if (feof(log_file)) + DIE("Found EOF before all statements where found"); - /* Loop until we found expected number of log entries */ - do { - /* Loop until statement is found in log */ - do { - memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2); - - if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL) - { - /* If fgets returned NULL, it indicates either error or EOF */ - if (feof(log_file)) - DIE("Found EOF before all statements where found"); - - fprintf(stderr, "Got error %d while reading from file\n", - ferror(log_file)); - DIE("Read error"); - } - - } while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2, - statement_cursor->buffer, - statement_cursor->length) == NULL); - hits++; - } while (hits < expected_hits); + fprintf(stderr, "Got error %d while reading from file\n", + ferror(log_file)); + DIE("Read error"); + } + } while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2, + statement_cursor->buffer, + statement_cursor->length) == NULL); + hits++; + } while (hits < expected_hits); + + if (!opt_silent) printf("Found statement starting with \"%s\"\n", statement_cursor->buffer); - } - - printf("success. All queries found intact in the log.\n"); - - } - else - { - fprintf(stderr, "Could not find the log file, VARDIR/log/master.log, so " - "test_bug17667 is \ninconclusive. Run test from the " - "mysql-test/mysql-test-run* program \nto set up the correct " - "environment for this test.\n\n"); } - if (log_file != NULL) - my_fclose(log_file, MYF(0)); + if (!opt_silent) + printf("success. All queries found intact in the log.\n"); + my_fclose(log_file, MYF(0)); } @@ -15198,6 +15508,189 @@ static void test_bug14169() myquery(rc); } +/* + Test that mysql_insert_id() behaves as documented in our manual +*/ + +static void test_mysql_insert_id() +{ + my_ulonglong res; + int rc; + + myheader("test_mysql_insert_id"); + + rc= mysql_query(mysql, "drop table if exists t1"); + myquery(rc); + /* table without auto_increment column */ + rc= mysql_query(mysql, "create table t1 (f1 int, f2 varchar(255), key(f1))"); + myquery(rc); + rc= mysql_query(mysql, "insert into t1 values (1,'a')"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + rc= mysql_query(mysql, "insert into t1 values (null,'b')"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + rc= mysql_query(mysql, "insert into t1 select 5,'c'"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + rc= mysql_query(mysql, "insert into t1 select null,'d'"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + rc= mysql_query(mysql, "insert into t1 values (null,last_insert_id(300))"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 300); + rc= mysql_query(mysql, "insert into t1 select null,last_insert_id(400)"); + myquery(rc); + res= mysql_insert_id(mysql); + /* + Behaviour change: old code used to return 0; but 400 is consistent + with INSERT VALUES, and the manual's section of mysql_insert_id() does not + say INSERT SELECT should be different. + */ + DIE_UNLESS(res == 400); + + /* table with auto_increment column */ + rc= mysql_query(mysql, "create table t2 (f1 int not null primary key auto_increment, f2 varchar(255))"); + myquery(rc); + rc= mysql_query(mysql, "insert into t2 values (1,'a')"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 1); + /* this should not influence next INSERT if it doesn't have auto_inc */ + rc= mysql_query(mysql, "insert into t1 values (10,'e')"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + + rc= mysql_query(mysql, "insert into t2 values (null,'b')"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 2); + rc= mysql_query(mysql, "insert into t2 select 5,'c'"); + myquery(rc); + res= mysql_insert_id(mysql); + /* + Manual says that for multirow insert this should have been 5, but does not + say for INSERT SELECT. This is a behaviour change: old code used to return + 0. We try to be consistent with INSERT VALUES. + */ + DIE_UNLESS(res == 5); + rc= mysql_query(mysql, "insert into t2 select null,'d'"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 6); + /* with more than one row */ + rc= mysql_query(mysql, "insert into t2 values (10,'a'),(11,'b')"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 11); + rc= mysql_query(mysql, "insert into t2 select 12,'a' union select 13,'b'"); + myquery(rc); + res= mysql_insert_id(mysql); + /* + Manual says that for multirow insert this should have been 13, but does + not say for INSERT SELECT. This is a behaviour change: old code used to + return 0. We try to be consistent with INSERT VALUES. + */ + DIE_UNLESS(res == 13); + rc= mysql_query(mysql, "insert into t2 values (null,'a'),(null,'b')"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 14); + rc= mysql_query(mysql, "insert into t2 select null,'a' union select null,'b'"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 16); + rc= mysql_query(mysql, "insert into t2 select 12,'a' union select 13,'b'"); + myquery_r(rc); + rc= mysql_query(mysql, "insert ignore into t2 select 12,'a' union select 13,'b'"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + rc= mysql_query(mysql, "insert into t2 values (12,'a'),(13,'b')"); + myquery_r(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + rc= mysql_query(mysql, "insert ignore into t2 values (12,'a'),(13,'b')"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + /* mixing autogenerated and explicit values */ + rc= mysql_query(mysql, "insert into t2 values (null,'e'),(12,'a'),(13,'b')"); + myquery_r(rc); + rc= mysql_query(mysql, "insert into t2 values (null,'e'),(12,'a'),(13,'b'),(25,'g')"); + myquery_r(rc); + rc= mysql_query(mysql, "insert into t2 values (null,last_insert_id(300))"); + myquery(rc); + res= mysql_insert_id(mysql); + /* + according to the manual, this might be 20 or 300, but it looks like + auto_increment column takes priority over last_insert_id(). + */ + DIE_UNLESS(res == 20); + /* If first autogenerated number fails and 2nd works: */ + rc= mysql_query(mysql, "drop table t2"); + myquery(rc); + rc= mysql_query(mysql, "create table t2 (f1 int not null primary key " + "auto_increment, f2 varchar(255), unique (f2))"); + myquery(rc); + rc= mysql_query(mysql, "insert into t2 values (null,'e')"); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 1); + rc= mysql_query(mysql, "insert ignore into t2 values (null,'e'),(null,'a'),(null,'e')"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 2); + /* If autogenerated fails and explicit works: */ + rc= mysql_query(mysql, "insert ignore into t2 values (null,'e'),(12,'c'),(null,'d')"); + myquery(rc); + res= mysql_insert_id(mysql); + /* + Behaviour change: old code returned 3 (first autogenerated, even if it + fails); we now return first successful autogenerated. + */ + DIE_UNLESS(res == 13); + /* UPDATE may update mysql_insert_id() if it uses LAST_INSERT_ID(#) */ + rc= mysql_query(mysql, "update t2 set f1=14 where f1=12"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + rc= mysql_query(mysql, "update t2 set f1=NULL where f1=14"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + rc= mysql_query(mysql, "update t2 set f2=last_insert_id(372) where f1=0"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 372); + /* check that LAST_INSERT_ID() does not update mysql_insert_id(): */ + rc= mysql_query(mysql, "insert into t2 values (null,'g')"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 15); + rc= mysql_query(mysql, "update t2 set f2=(@li:=last_insert_id()) where f1=15"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 0); + /* + Behaviour change: now if ON DUPLICATE KEY UPDATE updates a row, + mysql_insert_id() returns the id of the row, instead of not being + affected. + */ + rc= mysql_query(mysql, "insert into t2 values (null,@li) on duplicate key " + "update f2=concat('we updated ',f2)"); + myquery(rc); + res= mysql_insert_id(mysql); + DIE_UNLESS(res == 15); + + rc= mysql_query(mysql, "drop table t1,t2"); + myquery(rc); +} /* Bug#20152: mysql_stmt_execute() writes to MYSQL_TYPE_DATE buffer @@ -15353,6 +15846,24 @@ static void test_bug21206() } /* + Ensure we execute the status code while testing +*/ + +static void test_status() +{ + const char *status; + DBUG_ENTER("test_status"); + myheader("test_status"); + + if (!(status= mysql_stat(mysql))) + { + myerror("mysql_stat failed"); /* purecov: inspected */ + die(__FILE__, __LINE__, "mysql_stat failed"); /* purecov: inspected */ + } + DBUG_VOID_RETURN; +} + +/* Bug#21726: Incorrect result with multiple invocations of LAST_INSERT_ID @@ -15521,17 +16032,21 @@ static void test_bug21635() result= mysql_use_result(mysql); DIE_UNLESS(result); - field_count= mysql_field_count(mysql); - for (i= 0; i < field_count; ++i) - { - field= mysql_fetch_field_direct(result, i); - printf("%s -> %s ... ", expr[i * 2], field->name); - fflush(stdout); - DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 && - field->table[0] == 0 && field->org_name[0] == 0); - DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0); - puts("OK"); - } + field_count= mysql_field_count(mysql); + for (i= 0; i < field_count; ++i) + { + field= mysql_fetch_field_direct(result, i); + if (!opt_silent) + if (!opt_silent) + printf("%s -> %s ... ", expr[i * 2], field->name); + fflush(stdout); + DIE_UNLESS(field->db[0] == 0 && field->org_table[0] == 0 && + field->table[0] == 0 && field->org_name[0] == 0); + DIE_UNLESS(strcmp(field->name, expr[i * 2 + 1]) == 0); + if (!opt_silent) + if (!opt_silent) + puts("OK"); + } mysql_free_result(result); } @@ -15570,14 +16085,36 @@ static void test_bug24179() /* + Bug#28075 "COM_DEBUG crashes mysqld" +*/ + +static void test_bug28075() +{ + int rc; + + DBUG_ENTER("test_bug28075"); + myheader("test_bug28075"); + + rc= mysql_dump_debug_info(mysql); + DIE_UNLESS(rc == 0); + + rc= mysql_ping(mysql); + DIE_UNLESS(rc == 0); + + DBUG_VOID_RETURN; +} + + +/* Bug#27876 (SF with cyrillic variable name fails during execution (regression)) */ + static void test_bug27876() { int rc; MYSQL_RES *result; - unsigned char utf8_func[] = + uchar utf8_func[] = { 0xd1, 0x84, 0xd1, 0x83, 0xd0, 0xbd, 0xd0, 0xba, 0xd1, 0x86, 0xd0, 0xb8, 0xd0, 0xb9, 0xd0, 0xba, @@ -15585,7 +16122,7 @@ static void test_bug27876() 0x00 }; - unsigned char utf8_param[] = + uchar utf8_param[] = { 0xd0, 0xbf, 0xd0, 0xb0, 0xd1, 0x80, 0xd0, 0xb0, 0xd0, 0xbc, 0xd0, 0xb5, 0xd1, 0x82, 0xd1, 0x8a, @@ -15607,23 +16144,23 @@ static void test_bug27876() result= mysql_store_result(mysql); mytest(result); - sprintf(query, "DROP FUNCTION IF EXISTS %s", utf8_func); + sprintf(query, "DROP FUNCTION IF EXISTS %s", (char*) utf8_func); rc= mysql_query(mysql, query); myquery(rc); sprintf(query, "CREATE FUNCTION %s( %s VARCHAR(25))" " RETURNS VARCHAR(25) DETERMINISTIC RETURN %s", - utf8_func, utf8_param, utf8_param); + (char*) utf8_func, (char*) utf8_param, (char*) utf8_param); rc= mysql_query(mysql, query); myquery(rc); - sprintf(query, "SELECT %s(VERSION())", utf8_func); + sprintf(query, "SELECT %s(VERSION())", (char*) utf8_func); rc= mysql_query(mysql, query); myquery(rc); result= mysql_store_result(mysql); mytest(result); - sprintf(query, "DROP FUNCTION %s", utf8_func); + sprintf(query, "DROP FUNCTION %s", (char*) utf8_func); rc= mysql_query(mysql, query); myquery(rc); @@ -15688,6 +16225,204 @@ static void test_bug28934() myquery(mysql_query(mysql, "drop table t1")); } +/* + Test mysql_change_user() C API and COM_CHANGE_USER +*/ + +static void test_change_user() +{ + char buff[256]; + const char *user_pw= "mysqltest_pw"; + const char *user_no_pw= "mysqltest_no_pw"; + const char *pw= "password"; + const char *db= "mysqltest_user_test_database"; + int rc; + + DBUG_ENTER("test_change_user"); + myheader("test_change_user"); + + /* Prepare environment */ + sprintf(buff, "drop database if exists %s", db); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, "create database %s", db); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, + "grant select on %s.* to %s@'%%' identified by '%s'", + db, + user_pw, + pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, + "grant select on %s.* to %s@'%%'", + db, + user_no_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + + /* Try some combinations */ + rc= mysql_change_user(mysql, NULL, NULL, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + + rc= mysql_change_user(mysql, "", NULL, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", "", NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", "", ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, NULL, "", ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + + rc= mysql_change_user(mysql, NULL, NULL, ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", NULL, ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, NULL, ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, "", ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, "", NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, NULL, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, "", db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, NULL, db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_pw, pw, db); + myquery(rc); + + rc= mysql_change_user(mysql, user_pw, pw, NULL); + myquery(rc); + + rc= mysql_change_user(mysql, user_pw, pw, ""); + myquery(rc); + + rc= mysql_change_user(mysql, user_no_pw, pw, db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_no_pw, pw, ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_no_pw, pw, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, user_no_pw, "", NULL); + myquery(rc); + + rc= mysql_change_user(mysql, user_no_pw, "", ""); + myquery(rc); + + rc= mysql_change_user(mysql, user_no_pw, "", db); + myquery(rc); + + rc= mysql_change_user(mysql, user_no_pw, NULL, db); + myquery(rc); + + rc= mysql_change_user(mysql, "", pw, db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", pw, ""); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", pw, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, NULL, pw, NULL); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, NULL, NULL, db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, NULL, "", db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + rc= mysql_change_user(mysql, "", "", db); + DIE_UNLESS(rc); + if (! opt_silent) + printf("Got error (as expected): %s\n", mysql_error(mysql)); + + /* Cleanup the environment */ + + mysql_change_user(mysql, opt_user, opt_password, current_db); + + sprintf(buff, "drop database %s", db); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, "drop user %s@'%%'", user_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + sprintf(buff, "drop user %s@'%%'", user_no_pw); + rc= mysql_query(mysql, buff); + myquery(rc); + + DBUG_VOID_RETURN; +} /* Bug#27592 (stack overrun when storing datetime value using prepared statements) @@ -15741,7 +16476,6 @@ static void test_bug27592() DBUG_VOID_RETURN; } - static void test_bug29948() { MYSQL *dbc=NULL; @@ -15815,6 +16549,69 @@ static void test_bug29948() mysql_close(dbc); } + +/* + Bug#29687 mysql_stmt_store_result memory leak in libmysqld +*/ + +static void test_bug29687() +{ + const int NUM_ITERATIONS= 40; + int i; + int rc; + MYSQL_STMT *stmt= NULL; + + DBUG_ENTER("test_bug29687"); + myheader("test_bug29687"); + + stmt= mysql_simple_prepare(mysql, "SELECT 1 FROM dual WHERE 0=2"); + DIE_UNLESS(stmt); + + for (i= 0; i < NUM_ITERATIONS; i++) + { + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + mysql_stmt_store_result(stmt); + while (mysql_stmt_fetch(stmt)==0); + mysql_stmt_free_result(stmt); + } + + mysql_stmt_close(stmt); + DBUG_VOID_RETURN; +} + + +/* + Bug #29692 Single row inserts can incorrectly report a huge number of + row insertions +*/ + +static void test_bug29692() +{ + MYSQL* conn; + + if (!(conn= mysql_init(NULL))) + { + myerror("test_bug29692 init failed"); + exit(1); + } + + if (!(mysql_real_connect(conn, opt_host, opt_user, + opt_password, opt_db ? opt_db:"test", opt_port, + opt_unix_socket, CLIENT_FOUND_ROWS))) + { + myerror("test_bug29692 connection failed"); + mysql_close(mysql); + exit(1); + } + myquery(mysql_query(conn, "drop table if exists t1")); + myquery(mysql_query(conn, "create table t1(f1 int)")); + myquery(mysql_query(conn, "insert into t1 values(1)")); + DIE_UNLESS(1 == mysql_affected_rows(conn)); + myquery(mysql_query(conn, "drop table t1")); + mysql_close(conn); +} + /** Bug#29306 Truncated data in MS Access with decimal (3,1) columns in a VIEW */ @@ -15863,6 +16660,445 @@ static void test_bug29306() DBUG_VOID_RETURN; } +/* + Bug#30472: libmysql doesn't reset charset, insert_id after succ. + mysql_change_user() call row insertions. +*/ + +static void bug30472_retrieve_charset_info(MYSQL *con, + char *character_set_name, + char *character_set_client, + char *character_set_results, + char *collation_connection) +{ + MYSQL_RES *rs; + MYSQL_ROW row; + + /* Get the cached client character set name. */ + + strcpy(character_set_name, mysql_character_set_name(con)); + + /* Retrieve server character set information. */ + + DIE_IF(mysql_query(con, "SHOW VARIABLES LIKE 'character_set_client'")); + DIE_UNLESS(rs= mysql_store_result(con)); + DIE_UNLESS(row= mysql_fetch_row(rs)); + strcpy(character_set_client, row[1]); + mysql_free_result(rs); + + DIE_IF(mysql_query(con, "SHOW VARIABLES LIKE 'character_set_results'")); + DIE_UNLESS(rs= mysql_store_result(con)); + DIE_UNLESS(row= mysql_fetch_row(rs)); + strcpy(character_set_results, row[1]); + mysql_free_result(rs); + + DIE_IF(mysql_query(con, "SHOW VARIABLES LIKE 'collation_connection'")); + DIE_UNLESS(rs= mysql_store_result(con)); + DIE_UNLESS(row= mysql_fetch_row(rs)); + strcpy(collation_connection, row[1]); + mysql_free_result(rs); +} + +static void test_bug30472() +{ + MYSQL con; + + char character_set_name_1[MY_CS_NAME_SIZE]; + char character_set_client_1[MY_CS_NAME_SIZE]; + char character_set_results_1[MY_CS_NAME_SIZE]; + char collation_connnection_1[MY_CS_NAME_SIZE]; + + char character_set_name_2[MY_CS_NAME_SIZE]; + char character_set_client_2[MY_CS_NAME_SIZE]; + char character_set_results_2[MY_CS_NAME_SIZE]; + char collation_connnection_2[MY_CS_NAME_SIZE]; + + char character_set_name_3[MY_CS_NAME_SIZE]; + char character_set_client_3[MY_CS_NAME_SIZE]; + char character_set_results_3[MY_CS_NAME_SIZE]; + char collation_connnection_3[MY_CS_NAME_SIZE]; + + char character_set_name_4[MY_CS_NAME_SIZE]; + char character_set_client_4[MY_CS_NAME_SIZE]; + char character_set_results_4[MY_CS_NAME_SIZE]; + char collation_connnection_4[MY_CS_NAME_SIZE]; + + /* Create a new connection. */ + + DIE_UNLESS(mysql_init(&con)); + + DIE_UNLESS(mysql_real_connect(&con, + opt_host, + opt_user, + opt_password, + opt_db ? opt_db : "test", + opt_port, + opt_unix_socket, + CLIENT_FOUND_ROWS)); + + /* Retrieve character set information. */ + + bug30472_retrieve_charset_info(&con, + character_set_name_1, + character_set_client_1, + character_set_results_1, + collation_connnection_1); + + /* Switch client character set. */ + + DIE_IF(mysql_set_character_set(&con, "utf8")); + + /* Retrieve character set information. */ + + bug30472_retrieve_charset_info(&con, + character_set_name_2, + character_set_client_2, + character_set_results_2, + collation_connnection_2); + + /* + Check that + 1) character set has been switched and + 2) new character set is different from the original one. + */ + + DIE_UNLESS(strcmp(character_set_name_2, "utf8") == 0); + DIE_UNLESS(strcmp(character_set_client_2, "utf8") == 0); + DIE_UNLESS(strcmp(character_set_results_2, "utf8") == 0); + DIE_UNLESS(strcmp(collation_connnection_2, "utf8_general_ci") == 0); + + DIE_UNLESS(strcmp(character_set_name_1, character_set_name_2) != 0); + DIE_UNLESS(strcmp(character_set_client_1, character_set_client_2) != 0); + DIE_UNLESS(strcmp(character_set_results_1, character_set_results_2) != 0); + DIE_UNLESS(strcmp(collation_connnection_1, collation_connnection_2) != 0); + + /* Call mysql_change_user() with the same username, password, database. */ + + DIE_IF(mysql_change_user(&con, + opt_user, + opt_password, + opt_db ? opt_db : "test")); + + /* Retrieve character set information. */ + + bug30472_retrieve_charset_info(&con, + character_set_name_3, + character_set_client_3, + character_set_results_3, + collation_connnection_3); + + /* Check that character set information has been reset. */ + + DIE_UNLESS(strcmp(character_set_name_1, character_set_name_3) == 0); + DIE_UNLESS(strcmp(character_set_client_1, character_set_client_3) == 0); + DIE_UNLESS(strcmp(character_set_results_1, character_set_results_3) == 0); + DIE_UNLESS(strcmp(collation_connnection_1, collation_connnection_3) == 0); + + /* Change connection-default character set in the client. */ + + con.options.charset_name= my_strdup("utf8", MYF(MY_FAE)); + + /* + Call mysql_change_user() in order to check that new connection will + have UTF8 character set on the client and on the server. + */ + + DIE_IF(mysql_change_user(&con, + opt_user, + opt_password, + opt_db ? opt_db : "test")); + + /* Retrieve character set information. */ + + bug30472_retrieve_charset_info(&con, + character_set_name_4, + character_set_client_4, + character_set_results_4, + collation_connnection_4); + + /* Check that we have UTF8 on the server and on the client. */ + + DIE_UNLESS(strcmp(character_set_name_4, "utf8") == 0); + DIE_UNLESS(strcmp(character_set_client_4, "utf8") == 0); + DIE_UNLESS(strcmp(character_set_results_4, "utf8") == 0); + DIE_UNLESS(strcmp(collation_connnection_4, "utf8_general_ci") == 0); + + /* That's it. Cleanup. */ + + mysql_close(&con); +} + +static void bug20023_change_user(MYSQL *con) +{ + DIE_IF(mysql_change_user(con, + opt_user, + opt_password, + opt_db ? opt_db : "test")); +} + +static bool query_int_variable(MYSQL *con, + const char *var_name, + int *var_value) +{ + MYSQL_RES *rs; + MYSQL_ROW row; + + char query_buffer[MAX_TEST_QUERY_LENGTH]; + + bool is_null; + + my_snprintf(query_buffer, + sizeof (query_buffer), + "SELECT %s", + (const char *) var_name); + + DIE_IF(mysql_query(con, query_buffer)); + DIE_UNLESS(rs= mysql_store_result(con)); + DIE_UNLESS(row= mysql_fetch_row(rs)); + + is_null= row[0] == NULL; + + if (!is_null) + *var_value= atoi(row[0]); + + mysql_free_result(rs); + + return is_null; +} + +static void test_bug20023() +{ + MYSQL con; + + int sql_big_selects_orig; + int max_join_size_orig; + + int sql_big_selects_2; + int sql_big_selects_3; + int sql_big_selects_4; + int sql_big_selects_5; + + char query_buffer[MAX_TEST_QUERY_LENGTH]; + + /* Create a new connection. */ + + DIE_UNLESS(mysql_init(&con)); + + DIE_UNLESS(mysql_real_connect(&con, + opt_host, + opt_user, + opt_password, + opt_db ? opt_db : "test", + opt_port, + opt_unix_socket, + CLIENT_FOUND_ROWS)); + + /*********************************************************************** + Remember original SQL_BIG_SELECTS, MAX_JOIN_SIZE values. + ***********************************************************************/ + + query_int_variable(&con, + "@@session.sql_big_selects", + &sql_big_selects_orig); + + query_int_variable(&con, + "@@global.max_join_size", + &max_join_size_orig); + + /*********************************************************************** + Test that COM_CHANGE_USER resets the SQL_BIG_SELECTS to the initial value. + ***********************************************************************/ + + /* Issue COM_CHANGE_USER. */ + + bug20023_change_user(&con); + + /* Query SQL_BIG_SELECTS. */ + + query_int_variable(&con, + "@@session.sql_big_selects", + &sql_big_selects_2); + + /* Check that SQL_BIG_SELECTS is reset properly. */ + + DIE_UNLESS(sql_big_selects_orig == sql_big_selects_2); + + /*********************************************************************** + Test that if MAX_JOIN_SIZE set to non-default value, + SQL_BIG_SELECTS will be 0. + ***********************************************************************/ + + /* Set MAX_JOIN_SIZE to some non-default value. */ + + DIE_IF(mysql_query(&con, "SET @@global.max_join_size = 10000")); + DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default")); + + /* Issue COM_CHANGE_USER. */ + + bug20023_change_user(&con); + + /* Query SQL_BIG_SELECTS. */ + + query_int_variable(&con, + "@@session.sql_big_selects", + &sql_big_selects_3); + + /* Check that SQL_BIG_SELECTS is 0. */ + + DIE_UNLESS(sql_big_selects_3 == 0); + + /*********************************************************************** + Test that if MAX_JOIN_SIZE set to default value, + SQL_BIG_SELECTS will be 1. + ***********************************************************************/ + + /* Set MAX_JOIN_SIZE to the default value (-1). */ + + DIE_IF(mysql_query(&con, "SET @@global.max_join_size = -1")); + DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default")); + + /* Issue COM_CHANGE_USER. */ + + bug20023_change_user(&con); + + /* Query SQL_BIG_SELECTS. */ + + query_int_variable(&con, + "@@session.sql_big_selects", + &sql_big_selects_4); + + /* Check that SQL_BIG_SELECTS is 1. */ + + DIE_UNLESS(sql_big_selects_4 == 1); + + /*********************************************************************** + Restore MAX_JOIN_SIZE. + Check that SQL_BIG_SELECTS will be the original one. + ***********************************************************************/ + + /* Restore MAX_JOIN_SIZE. */ + + my_snprintf(query_buffer, + sizeof (query_buffer), + "SET @@global.max_join_size = %d", + (int) max_join_size_orig); + + DIE_IF(mysql_query(&con, query_buffer)); + DIE_IF(mysql_query(&con, "SET @@session.max_join_size = default")); + + /* Issue COM_CHANGE_USER. */ + + bug20023_change_user(&con); + + /* Query SQL_BIG_SELECTS. */ + + query_int_variable(&con, + "@@session.sql_big_selects", + &sql_big_selects_5); + + /* Check that SQL_BIG_SELECTS is 1. */ + + DIE_UNLESS(sql_big_selects_5 == sql_big_selects_orig); + + /*********************************************************************** + That's it. Cleanup. + ***********************************************************************/ + + mysql_close(&con); +} + +static void bug31418_impl() +{ + MYSQL con; + + bool is_null; + int rc; + + /* Create a new connection. */ + + DIE_UNLESS(mysql_init(&con)); + + DIE_UNLESS(mysql_real_connect(&con, + opt_host, + opt_user, + opt_password, + opt_db ? opt_db : "test", + opt_port, + opt_unix_socket, + CLIENT_FOUND_ROWS)); + + /*********************************************************************** + Check that lock is free: + - IS_FREE_LOCK() should return 1; + - IS_USED_LOCK() should return NULL; + ***********************************************************************/ + + is_null= query_int_variable(&con, + "IS_FREE_LOCK('bug31418')", + &rc); + DIE_UNLESS(!is_null && rc); + + is_null= query_int_variable(&con, + "IS_USED_LOCK('bug31418')", + &rc); + DIE_UNLESS(is_null); + + /*********************************************************************** + Acquire lock and check the lock status (the lock must be in use): + - IS_FREE_LOCK() should return 0; + - IS_USED_LOCK() should return non-zero thread id; + ***********************************************************************/ + + query_int_variable(&con, "GET_LOCK('bug31418', 1)", &rc); + DIE_UNLESS(rc); + + is_null= query_int_variable(&con, + "IS_FREE_LOCK('bug31418')", + &rc); + DIE_UNLESS(!is_null && !rc); + + is_null= query_int_variable(&con, + "IS_USED_LOCK('bug31418')", + &rc); + DIE_UNLESS(!is_null && rc); + + /*********************************************************************** + Issue COM_CHANGE_USER command and check the lock status + (the lock must be free): + - IS_FREE_LOCK() should return 1; + - IS_USED_LOCK() should return NULL; + **********************************************************************/ + + bug20023_change_user(&con); + + is_null= query_int_variable(&con, + "IS_FREE_LOCK('bug31418')", + &rc); + DIE_UNLESS(!is_null && rc); + + is_null= query_int_variable(&con, + "IS_USED_LOCK('bug31418')", + &rc); + DIE_UNLESS(is_null); + + /*********************************************************************** + That's it. Cleanup. + ***********************************************************************/ + + mysql_close(&con); +} + +static void test_bug31418() +{ + /* Run test case for BUG#31418 for three different connections. */ + + bug31418_impl(); + + bug31418_impl(); + + bug31418_impl(); +} + /** @@ -15966,17 +17202,17 @@ static char **defaults_argv; static struct my_option client_test_long_options[] = { - {"basedir", 'b', "Basedir for tests.", (gptr*) &opt_basedir, - (gptr*) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"count", 't', "Number of times test to be executed", (char **) &opt_count, - (char **) &opt_count, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, - {"database", 'D', "Database to use", (char **) &opt_db, (char **) &opt_db, + {"basedir", 'b', "Basedir for tests.", (uchar**) &opt_basedir, + (uchar**) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"count", 't', "Number of times test to be executed", (uchar **) &opt_count, + (uchar **) &opt_count, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, + {"database", 'D', "Database to use", (uchar **) &opt_db, (uchar **) &opt_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"debug", '#', "Output debug log", (gptr*) &default_dbug_option, - (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, + (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host", (char **) &opt_host, (char **) &opt_host, + {"host", 'h', "Connect to host", (uchar **) &opt_host, (uchar **) &opt_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", @@ -15987,8 +17223,8 @@ static struct my_option client_test_long_options[] = "/etc/services, " #endif "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", - (char **) &opt_port, - (char **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (uchar **) &opt_port, + (uchar **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-arg", 'A', "Send embedded server this as a parameter.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"show-tests", 'T', "Show all tests' names", 0, 0, 0, GET_NO_ARG, NO_ARG, @@ -15996,19 +17232,19 @@ static struct my_option client_test_long_options[] = {"silent", 's', "Be more silent", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection", - (char **) &opt_unix_socket, (char **) &opt_unix_socket, 0, GET_STR, + (uchar **) &opt_unix_socket, (uchar **) &opt_unix_socket, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"testcase", 'c', "May disable some code when runs as mysql-test-run testcase.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE - {"user", 'u', "User for login if not current user", (char **) &opt_user, - (char **) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user", (uchar **) &opt_user, + (uchar **) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"vardir", 'v', "Data dir for tests.", (gptr*) &opt_vardir, - (gptr*) &opt_vardir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"vardir", 'v', "Data dir for tests.", (uchar**) &opt_vardir, + (uchar**) &opt_vardir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"getopt-ll-test", 'g', "Option for testing bug in getopt library", - (char **) &opt_getopt_ll_test, (char **) &opt_getopt_ll_test, 0, + (uchar **) &opt_getopt_ll_test, (uchar **) &opt_getopt_ll_test, 0, GET_LL, REQUIRED_ARG, 0, 0, LONGLONG_MAX, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -16225,30 +17461,41 @@ static struct my_tests_st my_tests[]= { { "test_bug13488", test_bug13488 }, { "test_bug13524", test_bug13524 }, { "test_bug14845", test_bug14845 }, - { "test_bug15510", test_bug15510 }, { "test_opt_reconnect", test_opt_reconnect }, + { "test_bug15510", test_bug15510}, #ifndef EMBEDDED_LIBRARY { "test_bug12744", test_bug12744 }, #endif { "test_bug16143", test_bug16143 }, + { "test_bug16144", test_bug16144 }, { "test_bug15613", test_bug15613 }, { "test_bug20152", test_bug20152 }, { "test_bug14169", test_bug14169 }, { "test_bug17667", test_bug17667 }, - { "test_bug19671", test_bug19671 }, { "test_bug15752", test_bug15752 }, + { "test_mysql_insert_id", test_mysql_insert_id }, + { "test_bug19671", test_bug19671 }, { "test_bug21206", test_bug21206 }, { "test_bug21726", test_bug21726 }, { "test_bug15518", test_bug15518 }, { "test_bug23383", test_bug23383 }, { "test_bug21635", test_bug21635 }, + { "test_status", test_status }, { "test_bug24179", test_bug24179 }, + { "test_ps_query_cache", test_ps_query_cache }, + { "test_bug28075", test_bug28075 }, { "test_bug27876", test_bug27876 }, { "test_bug28505", test_bug28505 }, { "test_bug28934", test_bug28934 }, { "test_bug27592", test_bug27592 }, { "test_bug29948", test_bug29948 }, + { "test_bug29687", test_bug29687 }, + { "test_bug29692", test_bug29692 }, { "test_bug29306", test_bug29306 }, + { "test_change_user", test_change_user }, + { "test_bug30472", test_bug30472 }, + { "test_bug20023", test_bug20023 }, + { "test_bug31418", test_bug31418 }, { "test_bug31669", test_bug31669 }, { 0, 0 } }; @@ -16363,7 +17610,6 @@ int main(int argc, char **argv) { struct my_tests_st *fptr; - DEBUGGER_OFF; MY_INIT(argv[0]); load_defaults("my", client_test_load_default_groups, &argc, &argv); diff --git a/tests/thread_test.c b/tests/thread_test.c index 0ba03694893..8e1c58ebbec 100644 --- a/tests/thread_test.c +++ b/tests/thread_test.c @@ -88,36 +88,36 @@ static struct my_option my_long_options[] = { {"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"database", 'D', "Database to use", (gptr*) &database, (gptr*) &database, + {"database", 'D', "Database to use", (uchar**) &database, (uchar**) &database, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host", (gptr*) &host, (gptr*) &host, 0, GET_STR, + {"host", 'h', "Connect to host", (uchar**) &host, (uchar**) &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"user", 'u', "User for login if not current user", (gptr*) &user, - (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user", (uchar**) &user, + (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"verbose", 'v', "Write some progress indicators", (gptr*) &verbose, - (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"query", 'Q', "Query to execute in each threads", (gptr*) &query, - (gptr*) &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"verbose", 'v', "Write some progress indicators", (uchar**) &verbose, + (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"query", 'Q', "Query to execute in each threads", (uchar**) &query, + (uchar**) &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Port number to use for connection or 0 for default to, in " "order of preference, my.cnf, $MYSQL_TCP_PORT, " #if MYSQL_PORT_DEFAULT == 0 "/etc/services, " #endif "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", - (gptr*) &tcp_port, - (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection", (gptr*) &unix_socket, - (gptr*) &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &tcp_port, + (uchar**) &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, + {"socket", 'S', "Socket file to use for connection", (uchar**) &unix_socket, + (uchar**) &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"test-count", 'c', "Run test count times (default %d)", - (gptr*) &number_of_tests, (gptr*) &number_of_tests, 0, GET_UINT, + (uchar**) &number_of_tests, (uchar**) &number_of_tests, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0}, {"thread-count", 't', "Number of threads to start", - (gptr*) &number_of_threads, (gptr*) &number_of_threads, 0, GET_UINT, + (uchar**) &number_of_threads, (uchar**) &number_of_threads, 0, GET_UINT, REQUIRED_ARG, 2, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; |