diff options
author | unknown <monty@mysql.com> | 2004-11-02 20:13:27 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-11-02 20:13:27 +0200 |
commit | 505caa28796f0fe13a0a4eb004fe70a084d64c85 (patch) | |
tree | e98dace641bd58871866d0d787418defc800bc9f /client | |
parent | 3200d66f8544dad77dc7ba8448550f3a15fa8eac (diff) | |
download | mariadb-git-505caa28796f0fe13a0a4eb004fe70a084d64c85.tar.gz |
Remove usage of !$ from mysql-tests
Added protocol::flush() for easier embedded-server code
Increase block allocation variables a bit as they where a bit too small for MySQL 4.1
Added option --silent to client_test
client/mysqltest.c:
Removed compiler warning
Fixed identation & comments from earlier push
Renamed variable 'disable_abort_on_error' to 'abort_on_error'
Ensure that '$mysql_errno' also with --ps-protocol
include/mysql_com.h:
Removed special handling of net_flush for embedded server
mysql-test/r/mysqltest.result:
Remove usage of !$ in tests
mysql-test/t/client_test.test:
Use --silent
mysql-test/t/comments.test:
Remove usage of !$ in tests
mysql-test/t/join_outer.test:
Remove usage of !$ in tests
mysql-test/t/key.test:
Remove usage of !$ in tests
mysql-test/t/mysqltest.test:
Remove usage of !$ in tests
mysql-test/t/show_check.test:
Remove usage of !$ in tests
mysql-test/t/temp_table.test:
Remove usage of !$ in tests
mysql-test/t/type_ranges.test:
Remove usage of !$ in tests
sql/mysqld.cc:
Increase block allocation variables a bit as they where a bit too small for MySQL 4.1
sql/net_serv.cc:
Remove special usage of net_flush in embedded server
sql/protocol.cc:
Added protocol::flush() for easier embedded-server code
sql/protocol.h:
Added protocol::flush() for easier embedded-server code
sql/sql_prepare.cc:
Added protocol::flush() for easier embedded-server code
Remove one extra flush() for prepared statements
sql/sql_show.cc:
Added protocol::flush() for easier embedded-server code
tests/client_test.c:
Added option --silent
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqltest.c | 90 |
1 files changed, 53 insertions, 37 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c index 21f93b1fc6a..aef36823dfc 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -42,7 +42,7 @@ **********************************************************************/ -#define MTEST_VERSION "2.3" +#define MTEST_VERSION "2.4" #include <my_global.h> #include <mysql_embed.h> @@ -243,8 +243,7 @@ VAR var_reg[10]; HASH var_hash; my_bool disable_query_log=0, disable_result_log=0, disable_warnings=0; my_bool disable_info= 1; /* By default off */ -/* default for disable_abort_on_error: false = abort on unmasked error */ -my_bool disable_abort_on_error= 0; +my_bool abort_on_error= 1; struct connection cons[MAX_CONS]; struct connection* cur_con, *next_con, *cons_end; @@ -370,7 +369,7 @@ const char *command_names[]= }; TYPELIB command_typelib= {array_elements(command_names),"", - command_names}; + command_names, 0}; DYNAMIC_STRING ds_res; static void die(const char *fmt, ...); @@ -744,7 +743,7 @@ err: DBUG_RETURN(0); } -static VAR* var_obtain(char* name, int len) +static VAR *var_obtain(const char* name, int len) { VAR* v; if ((v = (VAR*)hash_search(&var_hash, name, len))) @@ -754,28 +753,33 @@ static VAR* var_obtain(char* name, int len) return v; } -int var_set(char* var_name, char* var_name_end, char* var_val, - char* var_val_end) +int var_set(const char *var_name, const char *var_name_end, + const char *var_val, const char *var_val_end) { int digit; VAR* v; + DBUG_ENTER("var_set"); + DBUG_PRINT("enter", ("var_name: '%.*s' = '%.*s' (length: %d)", + (int) (var_name_end - var_name), var_name, + (int) (var_val_end - var_val), var_val, + (int) (var_val_end - var_val))); + if (*var_name++ != '$') - { - --var_name; - *var_name_end = 0; - die("Variable name in %s does not start with '$'", var_name); - } + { + var_name--; + die("Variable name in %s does not start with '$'", var_name); + } digit = *var_name - '0'; if (!(digit < 10 && digit >= 0)) - { - v = var_obtain(var_name, var_name_end - var_name); - } + { + v = var_obtain(var_name, (uint) (var_name_end - var_name)); + } else - v = var_reg + digit; - + v = var_reg + digit; return eval_expr(v, var_val, (const char**)&var_val_end); } + int open_file(const char* name) { char buff[FN_REFLEN]; @@ -1244,18 +1248,22 @@ int do_let(struct st_query* q) return var_set(var_name, var_name_end, var_val_start, q->end); } -/* Store an integer (typically the returncode of the last SQL) */ -/* statement in the mysqltest builtin variable $mysql_errno, by */ -/* simulating of a user statement "let $mysql_errno= <integer>" */ -int var_set_errno(int sql_errno ) + +/* + Store an integer (typically the returncode of the last SQL) + statement in the mysqltest builtin variable $mysql_errno, by + simulating of a user statement "let $mysql_errno= <integer>" +*/ + +int var_set_errno(int sql_errno) { - char var_name[] = "$mysql_errno", var_val[30]; - sprintf(var_val, "%d", sql_errno); - /* On some odd systems, the return value from sprintf() isn't */ - /* always the length of the string, so we use strlen() */ - return var_set(var_name, var_name + 12, var_val, var_val + strlen(var_val)); + const char *var_name= "$mysql_errno"; + char var_val[21]; + uint length= my_sprintf(var_val, (var_val, "%d", sql_errno)); + return var_set(var_name, var_name + 12, var_val, var_val + length); } + int do_rpl_probe(struct st_query* q __attribute__((unused))) { DBUG_ENTER("do_rpl_probe"); @@ -1264,12 +1272,14 @@ int do_rpl_probe(struct st_query* q __attribute__((unused))) DBUG_RETURN(0); } + int do_enable_rpl_parse(struct st_query* q __attribute__((unused))) { mysql_enable_rpl_parse(&cur_con->mysql); return 0; } + int do_disable_rpl_parse(struct st_query* q __attribute__((unused))) { mysql_disable_rpl_parse(&cur_con->mysql); @@ -2013,7 +2023,7 @@ int read_query(struct st_query** q_ptr) memcpy((gptr) q->expected_errno, (gptr) global_expected_errno, sizeof(global_expected_errno)); q->expected_errors= global_expected_errors; - q->abort_on_error= (global_expected_errors == 0 && !disable_abort_on_error); + q->abort_on_error= (global_expected_errors == 0 && abort_on_error); bzero((gptr) global_expected_errno, sizeof(global_expected_errno)); global_expected_errors=0; if (p[0] == '-' && p[1] == '-') @@ -2422,7 +2432,7 @@ static int run_query(MYSQL *mysql, struct st_query *q, int flags) if (ps_protocol_enabled && disable_info && (flags & QUERY_SEND) && (flags & QUERY_REAP) && ps_match_re(q->query)) - return run_query_stmt (mysql, q, flags); + return run_query_stmt(mysql, q, flags); return run_query_normal(mysql, q, flags); } @@ -2659,9 +2669,12 @@ end: dynstr_free(&ds_tmp); if (q->type == Q_EVAL) dynstr_free(&eval_query); - /* We save the return code (mysql_errno(mysql)) from the last call sent */ - /* to the server into the mysqltest builtin variable $mysql_errno. This */ - /* variable then can be used from the test case itself. */ + + /* + We save the return code (mysql_errno(mysql)) from the last call sent + to the server into the mysqltest builtin variable $mysql_errno. This + variable then can be used from the test case itself. + */ var_set_errno(mysql_errno(mysql)); DBUG_RETURN(error); } @@ -3012,6 +3025,7 @@ end: dynstr_free(&ds_tmp); if (q->type == Q_EVAL) dynstr_free(&eval_query); + var_set_errno(mysql_stmt_errno(stmt)); mysql_stmt_close(stmt); DBUG_RETURN(error); } @@ -3319,7 +3333,7 @@ static VAR* var_from_env(const char *name, const char *def_val) if (!(tmp = getenv(name))) tmp = def_val; - v = var_init(0, name, 0, tmp, 0); + v = var_init(0, name, strlen(name), tmp, strlen(tmp)); my_hash_insert(&var_hash, (byte*)v); return v; } @@ -3416,9 +3430,11 @@ int main(int argc, char **argv) init_var_hash(&cur_con->mysql); - /* Initialize $mysql_errno with -1, so we can */ - /* - distinguish it from valid values ( >= 0 ) and */ - /* - detect if there was never a command sent to the server */ + /* + Initialize $mysql_errno with -1, so we can + - distinguish it from valid values ( >= 0 ) and + - detect if there was never a command sent to the server + */ var_set_errno(-1); while (!read_query(&q)) @@ -3440,8 +3456,8 @@ int main(int argc, char **argv) case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break; case Q_ENABLE_QUERY_LOG: disable_query_log=0; break; case Q_DISABLE_QUERY_LOG: disable_query_log=1; break; - case Q_ENABLE_ABORT_ON_ERROR: disable_abort_on_error=0; break; - case Q_DISABLE_ABORT_ON_ERROR: disable_abort_on_error=1; break; + case Q_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break; + case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break; case Q_ENABLE_RESULT_LOG: disable_result_log=0; break; case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; case Q_ENABLE_WARNINGS: disable_warnings=0; break; |