diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/client_test.c | 641 |
1 files changed, 417 insertions, 224 deletions
diff --git a/tests/client_test.c b/tests/client_test.c index bf0b69f9354..35990a521a4 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -27,7 +27,7 @@ #include <my_getopt.h> #include <m_string.h> -#define VER "2.0" +#define VER "2.1" #define MAX_TEST_QUERY_LENGTH 300 /* MAX QUERY BUFFER LENGTH */ /* set default options */ @@ -52,6 +52,12 @@ static double total_time; const char *default_dbug_option= "d:t:o,/tmp/client_test.trace"; +struct my_tests_st +{ + const char *name; + void (*function)(); +}; + #define myheader(str) \ if (opt_silent < 2) \ { \ @@ -97,11 +103,12 @@ void die(const char *file, int line, const char *expr) #define myerror(msg) print_error(msg) #define mysterror(stmt, msg) print_st_error(stmt, msg) -#define myquery(r) \ +#define myquery(RES) \ { \ -if (r) \ - myerror(NULL); \ - DIE_UNLESS(r == 0); \ + int r= (RES); \ + if (r) \ + myerror(NULL); \ + DIE_UNLESS(r == 0); \ } #define myquery_r(r) \ @@ -214,6 +221,7 @@ static void client_connect() if (!(mysql= mysql_init(NULL))) { + opt_silent= 0; myerror("mysql_init() failed"); exit(1); } @@ -222,6 +230,7 @@ static void client_connect() opt_password, opt_db ? opt_db:"test", opt_port, opt_unix_socket, 0))) { + opt_silent= 0; myerror("connection failed"); mysql_close(mysql); fprintf(stdout, "\n Check the connection options using --help or -?\n"); @@ -282,38 +291,40 @@ static void client_query() myheader("client_query"); - rc= mysql_query(mysql, "DROP TABLE IF EXISTS myclient_test"); + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); myquery(rc); - rc= mysql_query(mysql, "CREATE TABLE myclient_test(" + rc= mysql_query(mysql, "CREATE TABLE t1(" "id int primary key auto_increment, " "name varchar(20))"); myquery(rc); - rc= mysql_query(mysql, "CREATE TABLE myclient_test(id int, name varchar(20))"); + rc= mysql_query(mysql, "CREATE TABLE t1(id int, name varchar(20))"); myquery_r(rc); - rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('mysql')"); + rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('mysql')"); myquery(rc); - rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('monty')"); + rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('monty')"); myquery(rc); - rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('venu')"); + rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('venu')"); myquery(rc); - rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('deleted')"); + rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('deleted')"); myquery(rc); - rc= mysql_query(mysql, "INSERT INTO myclient_test(name) VALUES('deleted')"); + rc= mysql_query(mysql, "INSERT INTO t1(name) VALUES('deleted')"); myquery(rc); - rc= mysql_query(mysql, "UPDATE myclient_test SET name= 'updated' " + rc= mysql_query(mysql, "UPDATE t1 SET name= 'updated' " "WHERE name= 'deleted'"); myquery(rc); - rc= mysql_query(mysql, "UPDATE myclient_test SET id= 3 WHERE name= 'updated'"); + rc= mysql_query(mysql, "UPDATE t1 SET id= 3 WHERE name= 'updated'"); myquery_r(rc); + + myquery(mysql_query(mysql, "drop table t1")); } @@ -624,12 +635,15 @@ static void verify_prepare_field(MYSQL_RES *result, unsigned long length, const char *def) { MYSQL_FIELD *field; + CHARSET_INFO *cs; if (!(field= mysql_fetch_field_direct(result, no))) { fprintf(stdout, "\n *** ERROR: FAILED TO GET THE RESULT ***"); exit(1); } + cs= get_charset(field->charsetnr, 0); + DIE_UNLESS(cs); if (!opt_silent) { fprintf(stdout, "\n field[%d]:", no); @@ -643,7 +657,7 @@ static void verify_prepare_field(MYSQL_RES *result, field->org_table, org_table); fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db); fprintf(stdout, "\n length :`%ld`\t(expected: `%ld`)", - field->length, length); + field->length, length * cs->mbmaxlen); fprintf(stdout, "\n maxlength:`%ld`", field->max_length); fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr); fprintf(stdout, "\n default :`%s`\t(expected: `%s`)", @@ -652,11 +666,24 @@ static void verify_prepare_field(MYSQL_RES *result, } DIE_UNLESS(strcmp(field->name, name) == 0); DIE_UNLESS(strcmp(field->org_name, org_name) == 0); - DIE_UNLESS(field->type == type); + /* + XXX: silent column specification change works based on number of + bytes a column occupies. So CHAR -> VARCHAR upgrade is possible even + for CHAR(2) column if its character set is multibyte. + VARCHAR -> CHAR downgrade won't work for VARCHAR(3) as one would + expect. + */ + if (cs->mbmaxlen == 1) + DIE_UNLESS(field->type == type); DIE_UNLESS(strcmp(field->table, table) == 0); DIE_UNLESS(strcmp(field->org_table, org_table) == 0); DIE_UNLESS(strcmp(field->db, db) == 0); - DIE_UNLESS(field->length == length); + /* + Character set should be taken into account for multibyte encodings, such + as utf8. Field length is calculated as number of characters * maximum + number of bytes a character can occupy. + */ + DIE_UNLESS(field->length == length * cs->mbmaxlen); if (def) DIE_UNLESS(strcmp(field->def, def) == 0); } @@ -743,7 +770,7 @@ static void client_store_result() myheader("client_store_result"); - rc= mysql_query(mysql, "SELECT * FROM myclient_test"); + rc= mysql_query(mysql, "SELECT * FROM t1"); myquery(rc); /* get the result */ @@ -763,7 +790,7 @@ static void client_use_result() int rc; myheader("client_use_result"); - rc= mysql_query(mysql, "SELECT * FROM myclient_test"); + rc= mysql_query(mysql, "SELECT * FROM t1"); myquery(rc); /* get the result */ @@ -7537,17 +7564,17 @@ static void test_fetch_seek() char c2[11], c3[20]; myheader("test_fetch_seek"); + rc= mysql_query(mysql, "drop table if exists t1"); - rc= mysql_query(mysql, "drop table if exists test_seek"); myquery(rc); - rc= mysql_query(mysql, "create table test_seek(c1 int primary key auto_increment, c2 char(10), c3 timestamp(14))"); + rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10), c3 timestamp(14))"); myquery(rc); - rc= mysql_query(mysql, "insert into test_seek(c2) values('venu'), ('mysql'), ('open'), ('source')"); + rc= mysql_query(mysql, "insert into t1(c2) values('venu'), ('mysql'), ('open'), ('source')"); myquery(rc); - stmt= mysql_simple_prepare(mysql, "select * from test_seek"); + stmt= mysql_simple_prepare(mysql, "select * from t1"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7620,6 +7647,7 @@ static void test_fetch_seek() DIE_UNLESS(rc == MYSQL_NO_DATA); mysql_stmt_close(stmt); + myquery(mysql_query(mysql, "drop table t1")); } @@ -7637,16 +7665,16 @@ static void test_fetch_offset() myheader("test_fetch_offset"); - rc= mysql_query(mysql, "drop table if exists test_column"); + rc= mysql_query(mysql, "drop table if exists t1"); myquery(rc); - rc= mysql_query(mysql, "create table test_column(a char(10))"); + rc= mysql_query(mysql, "create table t1(a char(10))"); myquery(rc); - rc= mysql_query(mysql, "insert into test_column values('abcdefghij'), (null)"); + rc= mysql_query(mysql, "insert into t1 values('abcdefghij'), (null)"); myquery(rc); - stmt= mysql_simple_prepare(mysql, "select * from test_column"); + stmt= mysql_simple_prepare(mysql, "select * from t1"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7706,6 +7734,8 @@ static void test_fetch_offset() check_execute_r(stmt, rc); mysql_stmt_close(stmt); + + myquery(mysql_query(mysql, "drop table t1")); } @@ -7721,16 +7751,16 @@ static void test_fetch_column() myheader("test_fetch_column"); - rc= mysql_query(mysql, "drop table if exists test_column"); + rc= mysql_query(mysql, "drop table if exists t1"); myquery(rc); - rc= mysql_query(mysql, "create table test_column(c1 int primary key auto_increment, c2 char(10))"); + rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10))"); myquery(rc); - rc= mysql_query(mysql, "insert into test_column(c2) values('venu'), ('mysql')"); + rc= mysql_query(mysql, "insert into t1(c2) values('venu'), ('mysql')"); myquery(rc); - stmt= mysql_simple_prepare(mysql, "select * from test_column order by c2 desc"); + stmt= mysql_simple_prepare(mysql, "select * from t1 order by c2 desc"); check_stmt(stmt); bind[0].buffer_type= MYSQL_TYPE_LONG; @@ -7841,6 +7871,7 @@ static void test_fetch_column() check_execute_r(stmt, rc); mysql_stmt_close(stmt); + myquery(mysql_query(mysql, "drop table t1")); } @@ -7852,27 +7883,28 @@ static void test_list_fields() int rc; myheader("test_list_fields"); - rc= mysql_query(mysql, "drop table if exists test_list_fields"); + rc= mysql_query(mysql, "drop table if exists t1"); myquery(rc); - rc= mysql_query(mysql, "create table test_list_fields(c1 int primary key auto_increment, c2 char(10) default 'mysql')"); + rc= mysql_query(mysql, "create table t1(c1 int primary key auto_increment, c2 char(10) default 'mysql')"); myquery(rc); - result= mysql_list_fields(mysql, "test_list_fields", NULL); + result= mysql_list_fields(mysql, "t1", NULL); mytest(result); rc= my_process_result_set(result); DIE_UNLESS(rc == 0); verify_prepare_field(result, 0, "c1", "c1", MYSQL_TYPE_LONG, - "test_list_fields", "test_list_fields", + "t1", "t1", current_db, 11, "0"); verify_prepare_field(result, 1, "c2", "c2", MYSQL_TYPE_STRING, - "test_list_fields", "test_list_fields", + "t1", "t1", current_db, 10, "mysql"); mysql_free_result(result); + myquery(mysql_query(mysql, "drop table t1")); } @@ -11082,6 +11114,7 @@ static void test_bug6096() free(bind[i].buffer); mysql_stmt_close(stmt); mysql_free_result(query_result); + mysql_free_result(stmt_metadata); stmt_text= "drop table t1"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); @@ -11091,7 +11124,8 @@ static void test_bug6096() /* Test of basic checks that are performed in server for components of MYSQL_TIME parameters. - */ +*/ + static void test_datetime_ranges() { const char *stmt_text; @@ -11221,6 +11255,139 @@ static void test_datetime_ranges() } +static void test_bug4172() +{ + MYSQL_STMT *stmt; + MYSQL_BIND bind[3]; + const char *stmt_text; + MYSQL_RES *res; + MYSQL_ROW row; + int rc; + char f[100], d[100], e[100]; + long f_len, d_len, e_len; + + myheader("test_bug4172"); + + mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + mysql_query(mysql, "CREATE TABLE t1 (f float, d double, e decimal(10,4))"); + mysql_query(mysql, "INSERT INTO t1 VALUES (12345.1234, 123456.123456, " + "123456.1234)"); + + stmt= mysql_stmt_init(mysql); + stmt_text= "SELECT f, d, e FROM t1"; + + rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + check_execute(stmt, rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + bzero(bind, sizeof(bind)); + bind[0].buffer_type= MYSQL_TYPE_STRING; + bind[0].buffer= f; + bind[0].buffer_length= sizeof(f); + bind[0].length= &f_len; + bind[1].buffer_type= MYSQL_TYPE_STRING; + bind[1].buffer= d; + bind[1].buffer_length= sizeof(d); + bind[1].length= &d_len; + bind[2].buffer_type= MYSQL_TYPE_STRING; + bind[2].buffer= e; + bind[2].buffer_length= sizeof(e); + bind[2].length= &e_len; + + mysql_stmt_bind_result(stmt, bind); + + mysql_stmt_store_result(stmt); + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); + + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + res= mysql_store_result(mysql); + row= mysql_fetch_row(res); + + if (!opt_silent) + { + printf("Binary protocol: float=%s, double=%s, decimal(10,4)=%s\n", + f, d, e); + printf("Text protocol: float=%s, double=%s, decimal(10,4)=%s\n", + row[0], row[1], row[2]); + } + DIE_UNLESS(!strcmp(f, row[0]) && !strcmp(d, row[1]) && !strcmp(e, row[2])); + + mysql_free_result(res); + mysql_stmt_close(stmt); +} + + +static void test_conversion() +{ + MYSQL_STMT *stmt; + const char *stmt_text; + int rc; + MYSQL_BIND bind[1]; + char buff[4]; + ulong length; + + myheader("test_conversion"); + + stmt_text= "DROP TABLE IF EXISTS t1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + stmt_text= "CREATE TABLE t1 (a TEXT) DEFAULT CHARSET latin1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + stmt_text= "SET character_set_connection=utf8, character_set_client=utf8, " + " character_set_results=latin1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + + stmt= mysql_stmt_init(mysql); + + stmt_text= "INSERT INTO t1 (a) VALUES (?)"; + rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + check_execute(stmt, rc); + + bzero(bind, sizeof(bind)); + bind[0].buffer= buff; + bind[0].length= &length; + bind[0].buffer_type= MYSQL_TYPE_STRING; + + mysql_stmt_bind_param(stmt, bind); + + buff[0]= 0xC3; + buff[1]= 0xA0; + length= 2; + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + stmt_text= "SELECT a FROM t1"; + rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); + check_execute(stmt, rc); + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + bind[0].buffer_length= sizeof(buff); + mysql_stmt_bind_result(stmt, bind); + + rc= mysql_stmt_fetch(stmt); + DIE_UNLESS(rc == 0); + DIE_UNLESS(length == 1); + DIE_UNLESS((uchar) buff[0] == 0xE0); + rc= mysql_stmt_fetch(stmt); + DIE_UNLESS(rc == MYSQL_NO_DATA); + + mysql_stmt_close(stmt); + stmt_text= "DROP TABLE t1"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); + stmt_text= "SET NAMES DEFAULT"; + rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); + myquery(rc); +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -11230,31 +11397,35 @@ static char **defaults_argv; static struct my_option client_test_long_options[] = { - {"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_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, 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}, - {"host", 'h', "Connect to host", (char **) &opt_host, (char **) &opt_host, 0, GET_STR_ALLOC, - REQUIRED_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, + 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.", 0, 0, 0, GET_STR, OPT_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}, -#endif {"port", 'P', "Port number to use for connection", (char **) &opt_port, (char **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"show-tests", 'T', "Show all tests' names", 0, 0, 0, GET_NO_ARG, NO_ARG, + 0, 0, 0, 0, 0, 0}, {"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, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"testcase", 'c', "May disable some code when runs as mysql-test-run testcase.", + {"socket", 'S', "Socket file to use for connection", + (char **) &opt_unix_socket, (char **) &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}, - {"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}, +#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}, +#endif { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -11270,13 +11441,161 @@ static void usage(void) Copyright (C) 2002-2004 MySQL AB\n\ This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\ and you are welcome to modify and redistribute it under the GPL license\n"); - printf("Usage: %s [OPTIONS]\n", my_progname); + printf("Usage: %s [OPTIONS] [TESTNAME1 TESTNAME2...]\n", my_progname); my_print_help(client_test_long_options); print_defaults("my", client_test_load_default_groups); my_print_variables(client_test_long_options); } +static struct my_tests_st my_tests[]= { + { "client_query", client_query }, +#if NOT_YET_WORKING + { "test_drop_temp", test_drop_temp }, +#endif + { "test_fetch_seek", test_fetch_seek }, + { "test_fetch_nobuffs", test_fetch_nobuffs }, + { "test_open_direct", test_open_direct }, + { "test_fetch_null", test_fetch_null }, + { "test_ps_null_param", test_ps_null_param }, + { "test_fetch_date", test_fetch_date }, + { "test_fetch_str", test_fetch_str }, + { "test_fetch_long", test_fetch_long }, + { "test_fetch_short", test_fetch_short }, + { "test_fetch_tiny", test_fetch_tiny }, + { "test_fetch_bigint", test_fetch_bigint }, + { "test_fetch_float", test_fetch_float }, + { "test_fetch_double", test_fetch_double }, + { "test_bind_result_ext", test_bind_result_ext }, + { "test_bind_result_ext1", test_bind_result_ext1 }, + { "test_select_direct", test_select_direct }, + { "test_select_prepare", test_select_prepare }, + { "test_select", test_select }, + { "test_select_version", test_select_version }, + { "test_ps_conj_select", test_ps_conj_select }, + { "test_select_show_table", test_select_show_table }, + { "test_func_fields", test_func_fields }, + { "test_long_data", test_long_data }, + { "test_insert", test_insert }, + { "test_set_variable", test_set_variable }, + { "test_select_show", test_select_show }, + { "test_prepare_noparam", test_prepare_noparam }, + { "test_bind_result", test_bind_result }, + { "test_prepare_simple", test_prepare_simple }, + { "test_prepare", test_prepare }, + { "test_null", test_null }, + { "test_debug_example", test_debug_example }, + { "test_update", test_update }, + { "test_simple_update", test_simple_update }, + { "test_simple_delete", test_simple_delete }, + { "test_double_compare", test_double_compare }, + { "client_store_result", client_store_result }, + { "client_use_result", client_use_result }, + { "test_tran_bdb", test_tran_bdb }, + { "test_tran_innodb", test_tran_innodb }, + { "test_prepare_ext", test_prepare_ext }, + { "test_prepare_syntax", test_prepare_syntax }, + { "test_field_names", test_field_names }, + { "test_field_flags", test_field_flags }, + { "test_long_data_str", test_long_data_str }, + { "test_long_data_str1", test_long_data_str1 }, + { "test_long_data_bin", test_long_data_bin }, + { "test_warnings", test_warnings }, + { "test_errors", test_errors }, + { "test_prepare_resultset", test_prepare_resultset }, + { "test_stmt_close", test_stmt_close }, + { "test_prepare_field_result", test_prepare_field_result }, + { "test_multi_stmt", test_multi_stmt }, + { "test_multi_statements", test_multi_statements }, + { "test_prepare_multi_statements", test_prepare_multi_statements }, + { "test_store_result", test_store_result }, + { "test_store_result1", test_store_result1 }, + { "test_store_result2", test_store_result2 }, + { "test_subselect", test_subselect }, + { "test_date", test_date }, + { "test_date_date", test_date_date }, + { "test_date_time", test_date_time }, + { "test_date_ts", test_date_ts }, + { "test_date_dt", test_date_dt }, + { "test_prepare_alter", test_prepare_alter }, + { "test_manual_sample", test_manual_sample }, + { "test_pure_coverage", test_pure_coverage }, + { "test_buffers", test_buffers }, + { "test_ushort_bug", test_ushort_bug }, + { "test_sshort_bug", test_sshort_bug }, + { "test_stiny_bug", test_stiny_bug }, + { "test_field_misc", test_field_misc }, + { "test_set_option", test_set_option }, +#ifndef EMBEDDED_LIBRARY + { "test_prepare_grant", test_prepare_grant }, +#endif + { "test_frm_bug", test_frm_bug }, + { "test_explain_bug", test_explain_bug }, + { "test_decimal_bug", test_decimal_bug }, + { "test_nstmts", test_nstmts }, + { "test_logs;", test_logs }, + { "test_cuted_rows", test_cuted_rows }, + { "test_fetch_offset", test_fetch_offset }, + { "test_fetch_column", test_fetch_column }, + { "test_mem_overun", test_mem_overun }, + { "test_list_fields", test_list_fields }, + { "test_free_result", test_free_result }, + { "test_free_store_result", test_free_store_result }, + { "test_sqlmode", test_sqlmode }, + { "test_ts", test_ts }, + { "test_bug1115", test_bug1115 }, + { "test_bug1180", test_bug1180 }, + { "test_bug1500", test_bug1500 }, + { "test_bug1644", test_bug1644 }, + { "test_bug1946", test_bug1946 }, + { "test_bug2248", test_bug2248 }, + { "test_parse_error_and_bad_length", test_parse_error_and_bad_length }, + { "test_bug2247", test_bug2247 }, + { "test_subqueries", test_subqueries }, + { "test_bad_union", test_bad_union }, + { "test_distinct", test_distinct }, + { "test_subqueries_ref", test_subqueries_ref }, + { "test_union", test_union }, + { "test_bug3117", test_bug3117 }, + { "test_join", test_join }, + { "test_selecttmp", test_selecttmp }, + { "test_create_drop", test_create_drop }, + { "test_rename", test_rename }, + { "test_do_set", test_do_set }, + { "test_multi", test_multi }, + { "test_insert_select", test_insert_select }, + { "test_bind_nagative", test_bind_nagative }, + { "test_derived", test_derived }, + { "test_xjoin", test_xjoin }, + { "test_bug3035", test_bug3035 }, + { "test_union2", test_union2 }, + { "test_bug1664", test_bug1664 }, + { "test_union_param", test_union_param }, + { "test_order_param", test_order_param }, + { "test_ps_i18n", test_ps_i18n }, + { "test_bug3796", test_bug3796 }, + { "test_bug4026", test_bug4026 }, + { "test_bug4079", test_bug4079 }, + { "test_bug4236", test_bug4236 }, + { "test_bug4030", test_bug4030 }, + { "test_bug5126", test_bug5126 }, + { "test_bug4231", test_bug4231 }, + { "test_bug5399", test_bug5399 }, + { "test_bug5194", test_bug5194 }, + { "test_bug5315", test_bug5315 }, + { "test_bug6049", test_bug6049 }, + { "test_bug6058", test_bug6058 }, + { "test_bug6059", test_bug6059 }, + { "test_bug6046", test_bug6046 }, + { "test_bug6081", test_bug6081 }, + { "test_bug6096", test_bug6096 }, + { "test_datetime_ranges", test_datetime_ranges }, + { "test_bug4172", test_bug4172 }, + { "test_conversion", test_conversion }, + { 0, 0 } +}; + + static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) @@ -11307,6 +11626,16 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), else opt_silent++; break; + case 'T': + { + struct my_tests_st *fptr; + + printf("All possible test names:\n\n"); + for (fptr= my_tests; fptr->name; fptr++) + printf("%s\n", fptr->name); + exit(0); + break; + } case '?': case 'I': /* Info */ usage(); @@ -11316,11 +11645,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), return 0; } -static void get_options(int argc, char **argv) +static void get_options(int *argc, char ***argv) { int ho_error; - if ((ho_error= handle_options(&argc, &argv, client_test_long_options, + if ((ho_error= handle_options(argc, argv, client_test_long_options, get_one_option))) exit(ho_error); @@ -11353,14 +11682,17 @@ static void print_test_output() main routine ***************************************************************************/ + 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); defaults_argv= argv; - get_options(argc, argv); + get_options(&argc, &argv); client_connect(); /* connect to server */ @@ -11369,176 +11701,37 @@ int main(int argc, char **argv) { /* Start of tests */ test_count= 1; - start_time= time((time_t *)0); - client_query(); /* simple client query test */ -#if NOT_YET_WORKING - /* Used for internal new development debugging */ - test_drop_temp(); /* Test DROP TEMPORARY TABLE Access checks */ -#endif - test_fetch_seek(); /* Test stmt seek() functions */ - test_fetch_nobuffs(); /* to fecth without prior bound buffers */ - test_open_direct(); /* direct execution in the middle of open stmts */ - test_fetch_null(); /* to fetch null data */ - test_ps_null_param(); /* Fetch value of null parameter */ - test_fetch_date(); /* to fetch date, time and timestamp */ - test_fetch_str(); /* to fetch string to all types */ - test_fetch_long(); /* to fetch long to all types */ - test_fetch_short(); /* to fetch short to all types */ - test_fetch_tiny(); /* to fetch tiny to all types */ - test_fetch_bigint(); /* to fetch bigint to all types */ - test_fetch_float(); /* to fetch float to all types */ - test_fetch_double(); /* to fetch double to all types */ - test_bind_result_ext(); /* result bind test - extension */ - test_bind_result_ext1(); /* result bind test - extension */ - test_select_direct(); /* direct select - protocol_simple debug */ - test_select_prepare(); /* prepare select - protocol_prep debug */ - test_select(); /* simple select test */ - test_select_version(); /* select with variables */ - test_ps_conj_select(); /* prepare select with "where a=? or b=?" */ - test_select_show_table();/* simple show prepare */ -#if NOT_USED - /* - Enable this tests from 4.1.1 when mysql_param_result() is - supported - */ - test_select_meta(); /* select param meta information */ - test_update_meta(); /* update param meta information */ - test_insert_meta(); /* insert param meta information */ -#endif - test_func_fields(); /* test for new 4.1 MYSQL_FIELD members */ - test_long_data(); /* test for sending text data in chunks */ - test_insert(); /* simple insert test - prepare */ - test_set_variable(); /* prepare with set variables */ - test_select_show(); /* prepare - show test */ - test_prepare_noparam(); /* prepare without parameters */ - test_bind_result(); /* result bind test */ - test_prepare_simple(); /* simple prepare */ - test_prepare(); /* prepare test */ - test_null(); /* test null data handling */ - test_debug_example(); /* some debugging case */ - test_update(); /* prepare-update test */ - test_simple_update(); /* simple prepare with update */ - test_simple_delete(); /* prepare with delete */ - test_double_compare(); /* float comparision */ - client_store_result(); /* usage of mysql_store_result() */ - client_use_result(); /* usage of mysql_use_result() */ - test_tran_bdb(); /* transaction test on BDB table type */ - test_tran_innodb(); /* transaction test on InnoDB table type */ - test_prepare_ext(); /* test prepare with all types - conversion -- TODO */ - test_prepare_syntax(); /* syntax check for prepares */ - test_field_names(); /* test for field names */ - test_field_flags(); /* test to help .NET provider team */ - test_long_data_str(); /* long data handling */ - test_long_data_str1(); /* yet another long data handling */ - test_long_data_bin(); /* long binary insertion */ - test_warnings(); /* show warnings test */ - test_errors(); /* show errors test */ - test_prepare_resultset();/* prepare meta info test */ - test_stmt_close(); /* mysql_stmt_close() test -- hangs */ - test_prepare_field_result(); /* prepare meta info */ - test_multi_stmt(); /* multi stmt test */ - test_multi_statements();/* test multi statement execution */ - test_prepare_multi_statements(); /* check that multi statements are - disabled in PS */ - test_store_result(); /* test the store_result */ - test_store_result1(); /* test store result without buffers */ - test_store_result2(); /* test store result for misc case */ - test_subselect(); /* test subselect prepare -TODO*/ - test_date(); /* test the MYSQL_TIME conversion */ - test_date_date(); /* test conversion from DATE to all */ - test_date_time(); /* test conversion from TIME to all */ - test_date_ts() ; /* test conversion from TIMESTAMP to all */ - test_date_dt() ; /* test conversion from DATETIME to all */ - test_prepare_alter(); /* change table schema in middle of prepare */ - test_manual_sample(); /* sample in the manual */ - test_pure_coverage(); /* keep pure coverage happy */ - test_buffers(); /* misc buffer handling */ - test_ushort_bug(); /* test a simple conv bug from php */ - test_sshort_bug(); /* test a simple conv bug from php */ - test_stiny_bug(); /* test a simple conv bug from php */ - test_field_misc(); /* check the field info for misc case, bug: #74 */ - test_set_option(); /* test the SET OPTION feature, bug #85 */ - /*TODO HF: here should be NO_EMBEDDED_ACCESS_CHECKS*/ -#ifndef EMBEDDED_LIBRARY - test_prepare_grant(); /* Test the GRANT command, bug #89 */ -#endif - test_frm_bug(); /* test the crash when .frm is invalid, bug #93 */ - test_explain_bug(); /* test for the EXPLAIN, bug #115 */ - test_decimal_bug(); /* test for the decimal bug */ - test_nstmts(); /* test n statements */ - test_logs(); ; /* Test logs */ - test_cuted_rows(); /* Test for WARNINGS from cuted rows */ - test_fetch_offset(); /* Test mysql_stmt_fetch_column with offset */ - test_fetch_column(); /* Test mysql_stmt_fetch_column */ - test_mem_overun(); /* test DBD ovverun bug */ - test_list_fields(); /* test COM_LIST_FIELDS for DEFAULT */ - test_free_result(); /* test mysql_stmt_free_result() */ - test_free_store_result(); /* test to make sure stmt results are cleared - during stmt_free_result() */ - test_sqlmode(); /* test for SQL_MODE */ - test_ts(); /* test for timestamp BR#819 */ - test_bug1115(); /* BUG#1115 */ - test_bug1180(); /* BUG#1180 */ - test_bug1500(); /* BUG#1500 */ - test_bug1644(); /* BUG#1644 */ - test_bug1946(); /* test that placeholders are allowed only in - prepared queries */ - test_bug2248(); /* BUG#2248 */ - test_parse_error_and_bad_length(); /* test if bad length param in - mysql_stmt_prepare() triggers error */ - test_bug2247(); /* test that mysql_stmt_affected_rows() returns - number of rows affected by last prepared - statement execution */ - test_subqueries(); /* repeatable subqueries */ - test_bad_union(); /* correct setup of UNION */ - test_distinct(); /* distinct aggregate functions */ - test_subqueries_ref(); /* outer reference in subqueries converted - Item_field -> Item_ref */ - test_union(); /* test union with prepared statements */ - test_bug3117(); /* BUG#3117: LAST_INSERT_ID() */ - test_join(); /* different kinds of join, BUG#2794 */ - test_selecttmp(); /* temporary table used in select execution */ - test_create_drop(); /* some table manipulation BUG#2811 */ - test_rename(); /* rename test */ - test_do_set(); /* DO & SET commands test BUG#3393 */ - test_multi(); /* test of multi delete & update */ - test_insert_select(); /* test INSERT ... SELECT */ - test_bind_nagative(); /* bind negative to unsigned BUG#3223 */ - test_derived(); /* derived table with parameter BUG#3020 */ - test_xjoin(); /* complex join test */ - test_bug3035(); /* inserts of INT32_MAX/UINT32_MAX */ - test_union2(); /* repeatable execution of union (Bug #3577) */ - test_bug1664(); /* test for bugs in mysql_stmt_send_long_data() - call (Bug #1664) */ - test_union_param(); - test_order_param(); /* ORDER BY with parameters in select list - (Bug #3686 */ - test_ps_i18n(); /* test for i18n support in binary protocol */ - test_bug3796(); /* test for select concat(?, <string>) */ - test_bug4026(); /* test microseconds precision of time types */ - test_bug4079(); /* erroneous subquery in prepared statement */ - test_bug4236(); /* init -> execute */ - test_bug4030(); /* test conversion string -> time types in - libmysql */ - test_bug5126(); /* support for mediumint type in libmysql */ - test_bug4231(); /* proper handling of all-zero times and - dates in the server */ - test_bug5399(); /* check that statement id uniquely identifies - statement */ - test_bug5194(); /* bulk inserts in prepared mode */ - test_bug5315(); /* check that mysql_change_user closes all - prepared statements */ - test_bug6049(); /* check support for negative TIME values */ - test_bug6058(); /* check support for 0000-00-00 dates */ - test_bug6059(); /* correct metadata for SELECT ... INTO OUTFILE */ - test_bug6046(); /* NATURAL JOIN transformation works in PS */ - test_bug6081(); /* test of mysql_create_db()/mysql_rm_db() */ - test_bug6096(); /* max_length for numeric columns */ - test_datetime_ranges(); /* Test if basic checks are performed for - components of MYSQL_TIME parameters */ + if (!argc) + { + for (fptr= my_tests; fptr->name; fptr++) + (*fptr->function)(); + } + else + { + for ( ; *argv ; argv++) + { + for (fptr= my_tests; fptr->name; fptr++) + { + if (!strcmp(fptr->name, *argv)) + { + (*fptr->function)(); + break; + } + } + if (!fptr->name) + { + fprintf(stderr, "\n\nGiven test not found: '%s'\n", *argv); + fprintf(stderr, "See legal test names with %s -T\n\nAborting!\n", + my_progname); + client_disconnect(); + free_defaults(defaults_argv); + exit(1); + } + } + } + /* XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH. |