List:Commits« Previous MessageNext Message »
From:tim Date:November 15 2007 2:02am
Subject:bk commit into 5.1 tree (tsmith:1.2608) BUG#25146
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tsmith. When tsmith does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-11-14 19:02:13-07:00, tsmith@stripped +3 -0
  Bug #25146: Some warnings/errors not shown when using --show-warnings
  
  In several cases, an error when processing the query would cause mysql to
  return to the top level without printing warnings.  Fix is to always
  print any available warnings before returning to the top level.

  client/mysql.cc@stripped, 2007-11-14 19:02:11-07:00, tsmith@stripped +21 -10
    Print warnings, even if an error occurred while processing a query.
    
    Attempt to avoid printing the warning, though, if it's a duplicate
    of mysql_error() for the connection handle.

  mysql-test/r/mysql.result@stripped, 2007-11-14 19:02:11-07:00, tsmith@stripped +7 -0
    Add test for bug 25146

  mysql-test/t/mysql.test@stripped, 2007-11-14 19:02:11-07:00, tsmith@stripped +18 -0
    Add test for bug 25146

diff -Nrup a/client/mysql.cc b/client/mysql.cc
--- a/client/mysql.cc	2007-11-13 12:30:50 -07:00
+++ b/client/mysql.cc	2007-11-14 19:02:11 -07:00
@@ -2225,11 +2225,7 @@ com_go(String *buffer,char *line __attri
 end:
 
   if (show_warnings == 1 && warnings >= 1) /* Show warnings if any */
-  {
-    init_pager();
     print_warnings();
-    end_pager();
-  }
 
   if (!error && !status.batch && 
       (mysql.server_status & SERVER_STATUS_DB_DROPPED))
@@ -2653,6 +2649,9 @@ static void print_warnings()
   MYSQL_RES    *result;
   MYSQL_ROW    cur;
   my_ulonglong num_rows;
+  
+  /* Save current error before calling "show warnings" */
+  uint error= mysql_errno(&mysql);
 
   /* Get the warnings */
   query= "show warnings";
@@ -2661,16 +2660,28 @@ static void print_warnings()
 
   /* Bail out when no warnings */
   if (!(num_rows= mysql_num_rows(result)))
-  {
-    mysql_free_result(result);
-    return;
-  }
+    goto end;
+
+  cur= mysql_fetch_row(result);
+
+  /*
+    Don't print a duplicate of the current error.  It is possible for SHOW
+    WARNINGS to return multiple errors with the same code, but different
+    messages.  To be safe, skip printing the duplicate only if it is the only
+    warning.
+  */
+  if (!cur || num_rows == 1 && error == (uint) strtoul(cur[1], NULL, 10))
+    goto end;
 
   /* Print the warnings */
-  while ((cur= mysql_fetch_row(result)))
+  init_pager();
+  do
   {
     tee_fprintf(PAGER, "%s (Code %s): %s\n", cur[0], cur[1], cur[2]);
-  }
+  } while ((cur= mysql_fetch_row(result)));
+  end_pager();
+
+end:
   mysql_free_result(result);
 }
 
diff -Nrup a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result
--- a/mysql-test/r/mysql.result	2007-09-20 02:56:25 -06:00
+++ b/mysql-test/r/mysql.result	2007-11-14 19:02:11 -07:00
@@ -180,3 +180,10 @@ ERROR at line 1: DELIMITER cannot contai
 1
 End of 5.0 tests
 WARNING: --server-arg option not supported in this configuration.
+Warning (Code 1286): Unknown table engine 'nonexistent'
+Warning (Code 1266): Using storage engine MyISAM for table 't2'
+Warning (Code 1286): Unknown table engine 'nonexistent'
+Warning (Code 1266): Using storage engine MyISAM for table 't2'
+Error (Code 1050): Table 't2' already exists
+drop tables t1, t2;
+End of tests
diff -Nrup a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test
--- a/mysql-test/t/mysql.test	2007-09-04 16:49:54 -06:00
+++ b/mysql-test/t/mysql.test	2007-11-14 19:02:11 -07:00
@@ -290,3 +290,21 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug214
 --disable_query_log
 --exec $MYSQL --server-arg=no-defaults test -e "quit"
 --enable_query_log
+
+#
+# Bug #25146: Some warnings/errors not shown when using --show-warnings
+#
+
+# This one should succeed with no warnings
+--exec $MYSQL --show-warnings test -e "create table t1 (id int)"
+
+# This should succeed, with warnings about conversion from nonexistent engine
+--exec $MYSQL --show-warnings test -e "create table t2 (id int) engine=nonexistent"
+
+# This should fail, with warnings as well
+--error 1
+--exec $MYSQL --show-warnings test -e "create table t2 (id int) engine=nonexistent"
+
+drop tables t1, t2;
+
+--echo End of tests
Thread
bk commit into 5.1 tree (tsmith:1.2608) BUG#25146tim15 Nov