[Commits] Rev 2966: Fix bug that warnings that were pushed after we call set_ok_status() were in http://bazaar.launchpad.net/~maria-captains/maria/5.1

knielsen at knielsen-hq.org knielsen at knielsen-hq.org
Wed Nov 3 15:43:29 EET 2010


At http://bazaar.launchpad.net/~maria-captains/maria/5.1

------------------------------------------------------------
revno: 2966
revision-id: knielsen at knielsen-hq.org-20101103134329-ds07b8m7bnjm1gs2
parent: knielsen at knielsen-hq.org-20101103122257-5ig9sgijzln0xzb4
committer: knielsen at knielsen-hq.org
branch nick: work-5.1-mysqltest
timestamp: Wed 2010-11-03 14:43:29 +0100
message:
  Fix bug that warnings that were pushed after we call set_ok_status() were
  not included in the waning count sent to the client in the result packet.
=== added file 'mysql-test/r/warnings_debug.result'
--- a/mysql-test/r/warnings_debug.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/warnings_debug.result	2010-11-03 13:43:29 +0000
@@ -0,0 +1,10 @@
+drop table if exists t1;
+create table t1 (a int primary key) engine=innodb;
+SET SESSION debug="+d,warn_during_ha_commit_trans";
+INSERT INTO t1 VALUES (1);
+Warnings:
+Warning 1196    Some non-transactional changed tables couldn't be rolled back
+SHOW WARNINGS;
+Level   Code    Message
+Warning 1196    Some non-transactional changed tables couldn't be rolled back
+drop table t1;

=== added file 'mysql-test/t/warnings_debug.test'
--- a/mysql-test/t/warnings_debug.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/warnings_debug.test	2010-11-03 13:43:29 +0000
@@ -0,0 +1,19 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int primary key) engine=innodb;
+
+# Test that warnings produced during autocommit (after calling
+# set_ok_status()) are still reported to the client.
+SET SESSION debug="+d,warn_during_ha_commit_trans";
+INSERT INTO t1 VALUES (1);
+# The warning will be shown automatically by mysqltest; there was a bug where
+# this didn't happen because the warning was not counted when sending result
+# packet. Show the warnings manually also.
+SHOW WARNINGS;
+
+drop table t1;

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2010-10-20 10:58:43 +0000
+++ b/sql/handler.cc	2010-11-03 13:43:29 +0000
@@ -1093,6 +1093,12 @@ int ha_commit_trans(THD *thd, bool all)
   my_xid xid= thd->transaction.xid_state.xid.get_my_xid();
   DBUG_ENTER("ha_commit_trans");
 
+  /* Just a random warning to test warnings pushed during autocommit. */
+  DBUG_EXECUTE_IF("warn_during_ha_commit_trans",
+    push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                 ER_WARNING_NOT_COMPLETE_ROLLBACK,
+                 ER(ER_WARNING_NOT_COMPLETE_ROLLBACK)););
+
   /*
     We must not commit the normal transaction if a statement
     transaction is pending. Otherwise statement transaction

=== modified file 'sql/protocol.cc'
--- a/sql/protocol.cc	2010-08-27 14:12:44 +0000
+++ b/sql/protocol.cc	2010-11-03 13:43:29 +0000
@@ -203,7 +203,7 @@ net_send_ok(THD *thd,
   NET *net= &thd->net;
   uchar buff[MYSQL_ERRMSG_SIZE+10],*pos;
   bool error= FALSE;
-  DBUG_ENTER("my_ok");
+  DBUG_ENTER("net_send_ok");
 
   if (! net->vio)       // hack for re-parsing queries
   {

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-10-19 13:58:35 +0000
+++ b/sql/sql_class.h	2010-11-03 13:43:29 +0000
@@ -1211,6 +1211,13 @@ public:
     return m_total_warn_count;
   }
 
+  /* Used to count any warnings pushed after calling set_ok_status(). */
+  void increment_warning()
+  {
+    if (m_status != DA_EMPTY)
+      m_total_warn_count++;
+  }
+
   Diagnostics_area() { reset_diagnostics_area(); }
 
 private:

=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc	2009-02-13 16:41:47 +0000
+++ b/sql/sql_error.cc	2010-11-03 13:43:29 +0000
@@ -159,6 +159,8 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQ
   }
   thd->warn_count[(uint) level]++;
   thd->total_warn_count++;
+  /* Make sure we also count warnings pushed after calling set_ok_status(). */
+  thd->main_da.increment_warning();
   DBUG_RETURN(err);
 }
 



More information about the commits mailing list