summaryrefslogtreecommitdiff
path: root/client/mysqltest.c
diff options
context:
space:
mode:
authorunknown <msvensson@pilot.(none)>2007-08-28 15:33:14 +0200
committerunknown <msvensson@pilot.(none)>2007-08-28 15:33:14 +0200
commit5d3da0bb4b38bd77b99bcb47b52f56834b7df11a (patch)
tree37c7b1f85d9ef0b8400954d3d3a5a4cd79a01bdd /client/mysqltest.c
parent7edc7d63569d12ed02c1739361bc389dd2dfc902 (diff)
parent93665e88990904335f5097aaec94de46f67fa9b2 (diff)
downloadmariadb-git-5d3da0bb4b38bd77b99bcb47b52f56834b7df11a.tar.gz
Merge pilot.(none):/data/msvensson/mysql/mysql-5.0-maint
into pilot.(none):/data/msvensson/mysql/mysql-5.1-new-maint client/mysqltest.c: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/t/loaddata.test: Auto merged
Diffstat (limited to 'client/mysqltest.c')
-rw-r--r--client/mysqltest.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index e851c9dac89..00480cd6f17 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -591,6 +591,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.
@@ -3147,7 +3212,11 @@ wait_for_position:
*/
mysql_free_result(res);
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 */
goto wait_for_position;
}