List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:April 15 2008 10:29pm
Subject:bk commit into 6.0 tree (davi:1.2642) BUG#36004
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of davi.  When davi 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, 2008-04-15 17:29:42-03:00, davi@stripped +2 -0
  Bug#36004 mysql_stmt_prepare resets the list of warnings
  
  Although the manual says that "the list of messages is reset
  for each new statement that uses a table", the list of messages
  is being unconditionally reset for prepare commands.
  
  The solution is to enforce that the prepare command will only
  reset the message list if the statement being prepared uses
  a table or a warning is pushed.

  sql/sql_prepare.cc@stripped, 2008-04-15 17:29:39-03:00, davi@stripped +4 -2
    When preparing a statement, only reset the previous
    warnings if the statement uses a table.

  tests/mysql_client_test.c@stripped, 2008-04-15 17:29:39-03:00, davi@stripped +46 -0
    Add test case for Bug#36004

diff -Nrup a/sql/sql_prepare.cc b/sql/sql_prepare.cc
--- a/sql/sql_prepare.cc	2008-04-14 07:10:02 -03:00
+++ b/sql/sql_prepare.cc	2008-04-15 17:29:39 -03:00
@@ -1729,6 +1729,10 @@ static bool check_prepared_statement(Pre
   lex->select_lex.context.resolve_in_table_list_only(select_lex->
                                                      get_table_list());
 
+  /* Reset warning count for each query that uses tables */
+  if ((tables || !lex->is_single_level_stmt()) && !thd->spcont)
+    mysql_reset_errors(thd, 0);
+
   switch (sql_command) {
   case SQLCOM_REPLACE:
   case SQLCOM_INSERT:
@@ -1959,8 +1963,6 @@ void mysql_stmt_prepare(THD *thd, const 
     DBUG_VOID_RETURN;
   }
 
-  /* Reset warnings from previous command */
-  mysql_reset_errors(thd, 0);
   sp_cache_flush_obsolete(&thd->sp_proc_cache);
   sp_cache_flush_obsolete(&thd->sp_func_cache);
 
diff -Nrup a/tests/mysql_client_test.c b/tests/mysql_client_test.c
--- a/tests/mysql_client_test.c	2008-04-14 07:10:05 -03:00
+++ b/tests/mysql_client_test.c	2008-04-15 17:29:39 -03:00
@@ -17387,6 +17387,51 @@ static void test_bug28386()
   DBUG_VOID_RETURN;
 }
 
+
+/**
+  Bug#36004 mysql_stmt_prepare resets the list of warnings
+*/
+
+static void test_bug36004()
+{
+  int rc, warning_count= 0;
+  MYSQL_STMT *stmt;
+
+  DBUG_ENTER("test_bug36004");
+  myheader("test_bug36004");
+
+  rc= mysql_query(mysql, "drop table if exists inexistant");
+  myquery(rc);
+
+  DIE_UNLESS(mysql_warning_count(mysql) == 1);
+  query_int_variable(mysql, "@@warning_count", &warning_count);
+  DIE_UNLESS(warning_count);
+
+  stmt= mysql_simple_prepare(mysql, "select 1");
+  check_stmt(stmt);
+
+  DIE_UNLESS(mysql_warning_count(mysql) == 0);
+  query_int_variable(mysql, "@@warning_count", &warning_count);
+  DIE_UNLESS(warning_count);
+
+  rc= mysql_stmt_execute(stmt);
+  check_execute(stmt, rc);
+
+  DIE_UNLESS(mysql_warning_count(mysql) == 0);
+  mysql_stmt_close(stmt);
+
+  query_int_variable(mysql, "@@warning_count", &warning_count);
+  DIE_UNLESS(warning_count);
+
+  stmt= mysql_simple_prepare(mysql, "drop table if exists inexistant");
+  check_stmt(stmt);
+
+  query_int_variable(mysql, "@@warning_count", &warning_count);
+  DIE_UNLESS(warning_count == 0);
+
+  DBUG_VOID_RETURN;
+}
+
 /*
   Read and parse arguments and MySQL options from my.cnf
 */
@@ -17693,6 +17738,7 @@ static struct my_tests_st my_tests[]= {
   { "test_bug31418", test_bug31418 },
   { "test_bug31669", test_bug31669 },
   { "test_bug28386", test_bug28386 },
+  { "test_bug36004", test_bug36004 },
   { 0, 0 }
 };
 
Thread
bk commit into 6.0 tree (davi:1.2642) BUG#36004Davi Arnaut15 Apr
  • Re: bk commit into 6.0 tree (davi:1.2642) BUG#36004Konstantin Osipov15 Apr