summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <msvensson@pilot.(none)>2007-08-28 15:32:13 +0200
committerunknown <msvensson@pilot.(none)>2007-08-28 15:32:13 +0200
commit345c18e4e18c27eb387c6cec2e252c8b91bfc302 (patch)
treead3426b253ec3392b5b91f5d4bd54a2875253ae2
parent484069cf00ea15e3b690228ddf81752704fac390 (diff)
downloadmariadb-git-345c18e4e18c27eb387c6cec2e252c8b91bfc302.tar.gz
Move "analyze_testcase_failure" to mysqltest(since it knows best when
to perform this analyzis) client/mysqltest.c: Add function 'show_query' and use it to output some debug queries when "sync_with_master" has failed. mysql-test/mysql-test-run.pl: Move "analyze_testcase_failure" to mysqltest
-rw-r--r--client/mysqltest.c69
-rwxr-xr-xmysql-test/mysql-test-run.pl54
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
@@ -605,6 +605,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: <error>
- 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);
}