diff options
author | unknown <mleich@mysql.com> | 2004-10-29 14:51:56 +0200 |
---|---|---|
committer | unknown <mleich@mysql.com> | 2004-10-29 14:51:56 +0200 |
commit | c24a6280860b89853597a3c95e8c86356c664a18 (patch) | |
tree | 4a3072612ee9b816b89b68db5abe5ca5e70785ce /client | |
parent | facda8f3ef9cbc7ca3aecd06c2477f8de27d166c (diff) | |
download | mariadb-git-c24a6280860b89853597a3c95e8c86356c664a18.tar.gz |
These modifications are the result of
WL#2067 add features to mysqltest: "disable_error_abort" + "$mysql_errno"
$mysql_errno is a new builtin variable of mysqltest and contains the
return code of the last command send to the server.
"--disable_abort_on_error" switches the abort of mysqltest
after "unmasked" failing statements off.
"--enable_abort_on_error" switches the abort of mysqltest
after "unmasked" failing statements on. (default)
"Maskings" are
!$<error number> and --error <error number>
in the line before the statement to be checked.
The benefit of the option "--disable_abort_on_error" is that
- all statements after the failing statement are executed
- a r/<test>.reject will be produced
- it is possible to write test cases, which perform
code sequences depending on the return code of a single
statement
client/mysqltest.c:
Implementation of the features
- "--disable_abort_on_error"/"--enable_abort_on_error" switch
- "$mysql_errno" variable
mysql-test/r/mysqltest.result:
test cases for the features added
mysql-test/t/mysqltest.test:
updated results
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqltest.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c index 4c87561ab84..21f93b1fc6a 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -243,6 +243,8 @@ 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; struct connection cons[MAX_CONS]; struct connection* cur_con, *next_con, *cons_end; @@ -274,6 +276,7 @@ Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS, Q_ENABLE_INFO, Q_DISABLE_INFO, Q_ENABLE_METADATA, Q_DISABLE_METADATA, Q_EXEC, Q_DELIMITER, +Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR, Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS, Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_START_TIMER, Q_END_TIMER, @@ -352,6 +355,8 @@ const char *command_names[]= "disable_metadata", "exec", "delimiter", + "disable_abort_on_error", + "enable_abort_on_error", "vertical_results", "horizontal_results", "query_vertical", @@ -1239,6 +1244,18 @@ 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 ) +{ + 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)); +} + int do_rpl_probe(struct st_query* q __attribute__((unused))) { DBUG_ENTER("do_rpl_probe"); @@ -1996,7 +2013,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; + q->abort_on_error= (global_expected_errors == 0 && !disable_abort_on_error); bzero((gptr) global_expected_errno, sizeof(global_expected_errno)); global_expected_errors=0; if (p[0] == '-' && p[1] == '-') @@ -2642,6 +2659,10 @@ 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. */ + var_set_errno(mysql_errno(mysql)); DBUG_RETURN(error); } @@ -3395,6 +3416,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 */ + var_set_errno(-1); + while (!read_query(&q)) { int current_line_inc = 1, processed = 0; @@ -3414,6 +3440,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_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; |