From 4a013e295d5fffcee7af6b6e33c2bb87c1de9a27 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.(none)" <> Date: Tue, 28 Aug 2007 15:32:13 +0200 Subject: [PATCH 1/2] Move "analyze_testcase_failure" to mysqltest(since it knows best when to perform this analyzis) --- client/mysqltest.c | 69 ++++++++++++++++++++++++++++++++++++ mysql-test/mysql-test-run.pl | 54 ---------------------------- 2 files changed, 69 insertions(+), 54 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 693c6d0fb65..23a23dc5719 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -604,6 +604,71 @@ void do_eval(DYNAMIC_STRING *query_eval, const char *query, } +/* + Run query and dump the result to stdout in vertical format + + NOTE! This function should be safe to call when an error + has occured and thus any further errors will be ignored(although logged) + + SYNOPSIS + show_query + mysql - connection to use + query - query to run + +*/ + +static void show_query(MYSQL* mysql, const char* query) +{ + MYSQL_RES* res; + DBUG_ENTER("show_query"); + + if (!mysql) + DBUG_VOID_RETURN; + + if (mysql_query(mysql, query)) + { + log_msg("Error running query '%s': %d %s", + query, mysql_errno(mysql), mysql_error(mysql)); + DBUG_VOID_RETURN; + } + + if ((res= mysql_store_result(mysql)) == NULL) + { + /* No result set returned */ + DBUG_VOID_RETURN; + } + + { + MYSQL_ROW row; + unsigned int i; + unsigned int row_num= 0; + unsigned int num_fields= mysql_num_fields(res); + MYSQL_FIELD *fields= mysql_fetch_fields(res); + + fprintf(stderr, "=== %s ===\n", query); + while ((row= mysql_fetch_row(res))) + { + unsigned long *lengths= mysql_fetch_lengths(res); + row_num++; + + fprintf(stderr, "---- %d. ----\n", row_num); + for(i= 0; i < num_fields; i++) + { + fprintf(stderr, "%s\t%.*s\n", + fields[i].name, + (int)lengths[i], row[i] ? row[i] : "NULL"); + } + } + for (i= 0; i < strlen(query)+8; i++) + fprintf(stderr, "="); + fprintf(stderr, "\n\n"); + } + mysql_free_result(res); + + DBUG_VOID_RETURN; +} + + /* Show any warnings just before the error. Since the last error is added to the warning stack, only print @@warning_count-1 warnings. @@ -3150,7 +3215,11 @@ wait_for_position: SLAVE has been issued ? */ if (tries++ == 30) + { + show_query(mysql, "SHOW MASTER STATUS"); + show_query(mysql, "SHOW SLAVE STATUS"); die("could not sync with master ('%s' returned NULL)", query_buf); + } sleep(1); /* So at most we will wait 30 seconds and make 31 tries */ mysql_free_result(res); goto wait_for_position; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 269bfbcb40f..48a85f020ae 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3361,56 +3361,6 @@ sub find_testcase_skipped_reason($) } -sub analyze_testcase_failure_sync_with_master($) -{ - my ($tinfo)= @_; - - my $args; - mtr_init_args(\$args); - - mtr_add_arg($args, "--no-defaults"); - mtr_add_arg($args, "--silent"); - mtr_add_arg($args, "--skip-safemalloc"); - mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir); - mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir); - - mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_sock'}); - mtr_add_arg($args, "--port=%d", $master->[0]->{'port'}); - mtr_add_arg($args, "--database=test"); - mtr_add_arg($args, "--user=%s", $opt_user); - mtr_add_arg($args, "--password="); - - # Run the test file and append output to log file - mtr_run_test($exe_mysqltest,$args, - "include/analyze_failure_sync_with_master.test", - "$path_timefile", "$path_timefile","", - { append_log_file => 1 }); - -} - -sub analyze_testcase_failure($) -{ - my ($tinfo)= @_; - - # Open mysqltest.log - my $F= IO::File->new($path_timefile) - or return; - - while ( my $line= <$F> ) - { - # Look for "mysqltest: At line nnn: - if ( $line =~ /mysqltest: At line [0-9]*: (.*)/ ) - { - my $error= $1; - # Look for "could not sync with master" - if ( $error =~ /could not sync with master/ ) - { - analyze_testcase_failure_sync_with_master($tinfo); - } - } - } -} - ############################################################################## # # Run a single test case @@ -3503,10 +3453,6 @@ sub run_testcase ($) { } elsif ( $res == 1 ) { - if ( $opt_force ) - { - analyze_testcase_failure($tinfo); - } # Test case failure reported by mysqltest report_failure_and_restart($tinfo); } From 440caf3e10c6564c9d24d879f4508b5da4233520 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.(none)" <> Date: Tue, 28 Aug 2007 15:32:44 +0200 Subject: [PATCH 2/2] Remove unportable constructs in loaddata.test --- mysql-test/r/bdb_notembedded.result | 35 -------------------------- mysql-test/t/bdb_notembedded.test | 38 ----------------------------- mysql-test/t/loaddata.test | 22 ++++++++--------- 3 files changed, 10 insertions(+), 85 deletions(-) delete mode 100644 mysql-test/r/bdb_notembedded.result delete mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result deleted file mode 100644 index 14cb5fad915..00000000000 --- a/mysql-test/r/bdb_notembedded.result +++ /dev/null @@ -1,35 +0,0 @@ -set autocommit=1; -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 -f n Query 1 n use `test`; create table bug16206 (a int) -f n Query 1 n use `test`; insert into bug16206 values(1) -f n Query 1 n use `test`; insert into bug16206 values(2) -drop table bug16206; -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 -f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb -f n Query 1 n use `test`; insert into bug16206 values(0) -f n Query 1 n use `test`; insert into bug16206 values(1) -f n Query 1 n use `test`; BEGIN -f n Query 1 n use `test`; insert into bug16206 values(2) -f n Query 1 n use `test`; COMMIT -f n Query 1 n use `test`; insert into bug16206 values(3) -drop table bug16206; -set autocommit=0; -End of 5.0 tests diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test deleted file mode 100644 index 24e64ebbfb2..00000000000 --- a/mysql-test/t/bdb_notembedded.test +++ /dev/null @@ -1,38 +0,0 @@ --- source include/not_embedded.inc --- source include/have_bdb.inc - -# -# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode -# -set autocommit=1; - -let $VERSION=`select version()`; - -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -set autocommit=0; - - ---echo End of 5.0 tests diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 260e760e7b3..9eb92015399 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -43,7 +43,7 @@ delete from t1; eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t1; enable_query_log; select * from t1; ---exec rm $MYSQLTEST_VARDIR/tmp/t1 +remove_file $MYSQLTEST_VARDIR/tmp/t1; disable_query_log; eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' @@ -54,7 +54,7 @@ eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t1 FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'; enable_query_log; select * from t1; ---exec rm $MYSQLTEST_VARDIR/tmp/t1 +remove_file $MYSQLTEST_VARDIR/tmp/t1; SET @@SQL_MODE=@OLD_SQL_MODE; drop table t1; @@ -89,17 +89,16 @@ INSERT INTO t1 (c1) VALUES ('.r.'), ('.rr.'), ('.rrr.'), ('.rrrr.'); SELECT * FROM t1; ---exec rm -f $MYSQLTEST_VARDIR/tmp/t1 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY 'r' FROM t1; ---exec cat $MYSQLTEST_VARDIR/tmp/t1 +cat_file $MYSQLTEST_VARDIR/tmp/t1; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1' INTO TABLE t2 FIELDS ENCLOSED BY 'r'; SELECT t1.id, c1, c2 FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE c1 != c2; SELECT t1.id, c1, c2 FROM t1 RIGHT JOIN t2 ON t1.id=t2.id WHERE c1 != c2; ---exec rm $MYSQLTEST_VARDIR/tmp/t1 +remove_file $MYSQLTEST_VARDIR/tmp/t1; DROP TABLE t1,t2; # End of 4.1 tests @@ -184,7 +183,7 @@ SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=NO_AUTO_VALUE_ON_ZERO; eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t2; enable_query_log; select * from t2; ---exec rm $MYSQLTEST_VARDIR/tmp/t1 +remove_file $MYSQLTEST_VARDIR/tmp/t1; SET @@SQL_MODE=@OLD_SQL_MODE; drop table t1,t2; @@ -200,7 +199,7 @@ eval select * into outfile '$MYSQLTEST_VARDIR/tmp/t2' from t2; eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1; enable_query_log; select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1; ---exec rm $MYSQLTEST_VARDIR/tmp/t2 +remove_file $MYSQLTEST_VARDIR/tmp/t2; delete from t1; disable_query_log; eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t2' @@ -210,7 +209,7 @@ eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1 FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'; enable_query_log; select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1; ---exec rm $MYSQLTEST_VARDIR/tmp/t2 +remove_file $MYSQLTEST_VARDIR/tmp/t2; drop table t1,t2; # @@ -223,11 +222,10 @@ CREATE TABLE t1 (c1 INT, c2 TIMESTAMP, c3 REAL, c4 DOUBLE); INSERT INTO t1 (c1, c2, c3, c4) VALUES (10, '1970-02-01 01:02:03', 1.1E-100, 1.1E+100); SELECT * FROM t1; ---exec rm -f $MYSQLTEST_VARDIR/tmp/t1 --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY '-' FROM t1; ---exec cat $MYSQLTEST_VARDIR/tmp/t1 ---exec echo EOF +cat_file $MYSQLTEST_VARDIR/tmp/t1; +echo EOF; TRUNCATE t1; @@ -235,7 +233,7 @@ TRUNCATE t1; eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/t1' INTO TABLE t1 FIELDS ENCLOSED BY '-'; SELECT * FROM t1; ---exec rm $MYSQLTEST_VARDIR/tmp/t1 +remove_file $MYSQLTEST_VARDIR/tmp/t1; DROP TABLE t1; # End of 5.0 tests