Commit 934c8966 authored by unknown's avatar unknown

Merge mleich@bk-internal.mysql.com:/home/bk/mysql-4.1

into three.local.lan:/home/matthias/Arbeit/mysql-4.1/src


BitKeeper/etc/logging_ok:
  Logging to logging@openlogging.org accepted
parents d46c7366 c24a6280
......@@ -101,6 +101,7 @@ magnus@neptunus.(none)
magnus@shellback.(none)
marko@hundin.mysql.fi
matt@mysql.com
matthias@three.local.lan
miguel@hegel.(none)
miguel@hegel.br
miguel@hegel.local
......
......@@ -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;
......
select -1 as "before_use_test" ;
before_use_test
-1
select otto from (select 1 as otto) as t1;
otto
1
......@@ -21,3 +24,128 @@ select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
select friedrich from (select 1 as otto) as t1;
ERROR 42S22: Unknown column 'friedrich' in 'field list'
select otto from (select 1 as otto) as t1;
otto
1
select 0 as "after_successful_stmt_errno" ;
after_successful_stmt_errno
0
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
select 1064 as "after_wrong_syntax_errno" ;
after_wrong_syntax_errno
1064
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
select 1064 as "after_let_var_equal_value" ;
after_let_var_equal_value
1064
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
set @my_var= 'abc' ;
select 0 as "after_set_var_equal_value" ;
after_set_var_equal_value
0
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
select 1064 as "after_disable_warnings_command" ;
after_disable_warnings_command
1064
drop table if exists t1 ;
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
drop table if exists t1 ;
select 0 as "after_disable_warnings" ;
after_disable_warnings
0
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
select 1146 as "after_minus_masked" ;
after_minus_masked
1146
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
select 1146 as "after_!_masked" ;
after_!_masked
1146
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
select -1 as "after_let_errno_equal_value" ;
after_let_errno_equal_value
-1
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
prepare stmt from "select 3 from t1" ;
ERROR 42S02: Table 'test.t1' doesn't exist
select 1146 as "after_failing_prepare" ;
after_failing_prepare
1146
create table t1 ( f1 char(10));
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
prepare stmt from "select 3 from t1" ;
select 0 as "after_successful_prepare" ;
after_successful_prepare
0
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
execute stmt;
3
select 0 as "after_successful_execute" ;
after_successful_execute
0
drop table t1;
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
execute stmt;
ERROR 42S02: Table 'test.t1' doesn't exist
select 1146 as "after_failing_execute" ;
after_failing_execute
1146
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
execute __stmt_;
ERROR HY000: Unknown prepared statement handler (__stmt_) given to EXECUTE
select 1243 as "after_failing_execute" ;
after_failing_execute
1243
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
deallocate prepare stmt;
select 0 as "after_successful_deallocate" ;
after_successful_deallocate
0
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
deallocate prepare __stmt_;
ERROR HY000: Unknown prepared statement handler (__stmt_) given to DEALLOCATE PREPARE
select 1243 as "after_failing_deallocate" ;
after_failing_deallocate
1243
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
select 1064 as "after_--disable_abort_on_error" ;
after_--disable_abort_on_error
1064
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
select 1146 as "after_!errno_masked_error" ;
after_!errno_masked_error
1146
garbage ;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'garbage' at line 1
select 1064 as "after_--enable_abort_on_error" ;
after_--enable_abort_on_error
1064
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
select 3 from t1 ;
ERROR 42S02: Table 'test.t1' doesn't exist
......@@ -5,6 +5,15 @@
#
# ============================================================================
# ----------------------------------------------------------------------------
# $mysql_errno contains the return code of the last command
# send to the server.
# ----------------------------------------------------------------------------
# get $mysql_errno before the first statement
# $mysql_errno should be -1
eval select $mysql_errno as "before_use_test" ;
# ----------------------------------------------------------------------------
# Positive case(statement)
# ----------------------------------------------------------------------------
......@@ -76,3 +85,213 @@ select friedrich from (select 1 as otto) as t1;
#--error S00000
#select friedrich from (select 1 as otto) as t1;
# ----------------------------------------------------------------------------
# test cases for $mysql_errno
#
# $mysql_errno is a builtin variable of mysqltest and contains the return code
# of the last command send to the server.
#
# The following test cases often initialize $mysql_errno to 1064 by
# a command with wrong syntax.
# Example: !$1064 To prevent the abort after the error.
# garbage ;
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# 1. check mysql_errno = 0 after successful statement
# ----------------------------------------------------------------------------
select otto from (select 1 as otto) as t1;
eval select $mysql_errno as "after_successful_stmt_errno" ;
#----------------------------------------------------------------------------
# 2. check mysql_errno = 1064 after statement with wrong syntax
# ----------------------------------------------------------------------------
!$1064
garbage ;
eval select $mysql_errno as "after_wrong_syntax_errno" ;
# ----------------------------------------------------------------------------
# 3. check if let $my_var= 'abc' ; affects $mysql_errno
# ----------------------------------------------------------------------------
!$1064
garbage ;
let $my_var= 'abc' ;
eval select $mysql_errno as "after_let_var_equal_value" ;
# ----------------------------------------------------------------------------
# 4. check if set @my_var= 'abc' ; affects $mysql_errno
# ----------------------------------------------------------------------------
!$1064
garbage ;
set @my_var= 'abc' ;
eval select $mysql_errno as "after_set_var_equal_value" ;
# ----------------------------------------------------------------------------
# 5. check if the setting of --disable-warnings itself affects $mysql_errno
# (May be --<whatever> modifies $mysql_errno.)
# ----------------------------------------------------------------------------
!$1064
garbage ;
--disable_warnings
eval select $mysql_errno as "after_disable_warnings_command" ;
# ----------------------------------------------------------------------------
# 6. check if --disable-warnings + command with warning affects the errno
# stored within $mysql_errno
# (May be disabled warnings affect $mysql_errno.)
# ----------------------------------------------------------------------------
drop table if exists t1 ;
!$1064
garbage ;
drop table if exists t1 ;
eval select $mysql_errno as "after_disable_warnings" ;
--enable_warnings
# ----------------------------------------------------------------------------
# 7. check if masked errors affect $mysql_errno
# ----------------------------------------------------------------------------
!$1064
garbage ;
--error 1146
select 3 from t1 ;
eval select $mysql_errno as "after_minus_masked" ;
!$1064
garbage ;
!$1146
select 3 from t1 ;
eval select $mysql_errno as "after_!_masked" ;
# ----------------------------------------------------------------------------
# 8. Will manipulations of $mysql_errno be possible and visible ?
# ----------------------------------------------------------------------------
!$1064
garbage ;
let $mysql_errno= -1;
eval select $mysql_errno as "after_let_errno_equal_value" ;
# ----------------------------------------------------------------------------
# 9. How affect actions on prepared statements $mysql_errno ?
# ----------------------------------------------------------------------------
# failing prepare
!$1064
garbage ;
!$1146
prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_failing_prepare" ;
create table t1 ( f1 char(10));
# successful prepare
!$1064
garbage ;
prepare stmt from "select 3 from t1" ;
eval select $mysql_errno as "after_successful_prepare" ;
# successful execute
!$1064
garbage ;
execute stmt;
eval select $mysql_errno as "after_successful_execute" ;
# failing execute (table dropped)
drop table t1;
!$1064
garbage ;
!$1146
execute stmt;
eval select $mysql_errno as "after_failing_execute" ;
# failing execute (unknown statement)
!$1064
garbage ;
!$1243
execute __stmt_;
eval select $mysql_errno as "after_failing_execute" ;
# successful deallocate
!$1064
garbage ;
deallocate prepare stmt;
eval select $mysql_errno as "after_successful_deallocate" ;
# failing deallocate ( statement handle does not exist )
!$1064
garbage ;
!$1243
deallocate prepare __stmt_;
eval select $mysql_errno as "after_failing_deallocate" ;
# ----------------------------------------------------------------------------
# test cases for "--disable_abort_on_error"
#
# "--disable_abort_on_error" switches the abort of mysqltest
# after "unmasked" failing statements off.
#
# The default is "--enable_abort_on_error".
#
# "Maskings" are
# !$<error number> and --error <error number>
# in the line before the failing statement.
#
# There are some additional test case for $mysql_errno
# because "--disable_abort_on_error" enables a new situation.
# Example: "unmasked" statement fails + analysis of $mysql_errno
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# 1. Switch the abort on error off and check the effect on $mysql_errno
# ----------------------------------------------------------------------------
!$1064
garbage ;
--disable_abort_on_error
eval select $mysql_errno as "after_--disable_abort_on_error" ;
# ----------------------------------------------------------------------------
# 2. "unmasked" failing statement should not cause an abort
# ----------------------------------------------------------------------------
select 3 from t1 ;
# ----------------------------------------------------------------------------
# 3. masked failing statements
# ----------------------------------------------------------------------------
# expected error = response
--error 1146
select 3 from t1 ;
!$1146
select 3 from t1 ;
eval select $mysql_errno as "after_!errno_masked_error" ;
# expected error <> response
# --error 1000
# select 3 from t1 ;
# !$1000
# select 3 from t1 ;
# ----------------------------------------------------------------------------
# 4. Switch the abort on error on and check the effect on $mysql_errno
# ----------------------------------------------------------------------------
!$1064
garbage ;
--enable_abort_on_error
eval select $mysql_errno as "after_--enable_abort_on_error" ;
# ----------------------------------------------------------------------------
# 5. masked failing statements
# ----------------------------------------------------------------------------
# expected error = response
--error 1146
select 3 from t1 ;
!$1146
select 3 from t1 ;
# ----------------------------------------------------------------------------
# 6. check that the old default behaviour is not changed
# Please remove the '#' to get the abort on error
# ----------------------------------------------------------------------------
#--error 1064
#select 3 from t1 ;
#
#!$1064
#select 3 from t1 ;
#
#select 3 from t1 ;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment