List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:June 21 2011 7:58am
Subject:bzr push into mysql-trunk branch (jon.hauglid:3223 to 3224) Bug#12661349
View as plain text  
 3224 Jon Olav Hauglid	2011-06-21
      Bug#12661349 Assert in protocol::end_statement
      
      The triggered assert checks that either OK or an error
      is sent to the client after a command has been processed
      by the server. It was triggered in this case if the client
      used binary protocol and the connection was killed during
      prepare. On release builds, the consequence of the bug was
      that OK was sent to the client even if the prepare failed.
      
      When processing a SQL command, a check towards end of
      processing makes sure to report KILL_QUERY error to the
      client if the connection/command was killed. This check
      was however not done for binary protocol processing
      (COM_STMT_PREPARE in this case).
      
      This patch fixes the problem by making sure that the 
      KILL_QUERY error is sent to the client in these cases
      as well.
      
      Test case added to ps.test.

    modified:
      mysql-test/r/ps.result
      mysql-test/t/ps.test
      sql/sql_class.h
      sql/sql_parse.cc
 3223 Dmitry Lenev	2011-06-20
      A follow-up for patch that fixed bug #12652385 - "61493:
      REORDERING COLUMNS TO POSITION FIRST CAN CAUSE DATA TO
      BE CORRUPTED".
      
      Moved code which is responsible for detecting that ALTER
      TABLE can't be carried out using in-place algorithm because
      it reorders some columns or replaces some old columns with
      a newly added to one place. Introduced a new auxiliary
      function for performing this check.
      
      Note that we cannot easily make this check part of
      mysql_compare_tables() call as this check is specific to 
      normal ALTER TABLE (i.e. assumes that there are old columns 
      and new columns). While mysql_compare_tables() is also
      used by ALTER TABLE EXCHANGE PARTITION implementation for 
      checking that table and partitioned table has identical
      structure (i.e. in situation when there are no old and
      new columns).

    modified:
      sql/sql_table.cc
=== modified file 'mysql-test/r/ps.result'
--- a/mysql-test/r/ps.result	2011-03-22 12:06:52 +0000
+++ b/mysql-test/r/ps.result	2011-06-21 07:57:31 +0000
@@ -3721,3 +3721,17 @@ FROM (SELECT 1 UNION SELECT 2) t;
 2
 #
 # End of 5.5 tests.
+#
+# Bug#12661349 assert in protocol::end_statement
+#
+# Note: This test case should be run with --ps-protocol
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (col1 INT);
+# Connection con1
+# Connection default
+KILL QUERY <con1_id>;
+# Connection con1
+SELECT * FROM t1;
+ERROR 70100: Query execution was interrupted
+# Connection default
+DROP TABLE t1;

=== modified file 'mysql-test/t/ps.test'
--- a/mysql-test/t/ps.test	2011-03-22 12:06:52 +0000
+++ b/mysql-test/t/ps.test	2011-06-21 07:57:31 +0000
@@ -3328,3 +3328,37 @@ FROM (SELECT 1 UNION SELECT 2) t;
 --echo # End of 5.5 tests.
 
 ###########################################################################
+
+
+--echo #
+--echo # Bug#12661349 assert in protocol::end_statement
+--echo #
+
+--echo # Note: This test case should be run with --ps-protocol
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (col1 INT);
+
+--echo # Connection con1
+connect(con1, localhost, root);
+let $con1_id= `SELECT CONNECTION_ID()`;
+
+--echo # Connection default
+connection default;
+--replace_result $con1_id <con1_id>
+eval KILL QUERY $con1_id;
+
+--echo # Connection con1
+connection con1;
+# Here the server asserts when running with "--ps-protocol"
+--error ER_QUERY_INTERRUPTED
+SELECT * FROM t1;
+disconnect con1;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection default
+connection default;
+DROP TABLE t1;

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2011-06-16 16:06:32 +0000
+++ b/sql/sql_class.h	2011-06-21 07:57:31 +0000
@@ -2891,7 +2891,7 @@ public:
   inline void send_kill_message() const
   {
     int err= killed_errno();
-    if (err)
+    if (err && !get_stmt_da()->is_set())
     {
       if ((err == KILL_CONNECTION) && !shutdown_in_progress)
         err = KILL_QUERY;

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-06-16 16:06:32 +0000
+++ b/sql/sql_parse.cc	2011-06-21 07:57:31 +0000
@@ -1527,6 +1527,8 @@ bool dispatch_command(enum enum_server_c
 
   /* Finalize server status flags after executing a command. */
   thd->update_server_status();
+  if (thd->killed)
+    thd->send_kill_message();
   thd->protocol->end_statement();
   query_cache_end_of_result(thd);
 
@@ -4531,10 +4533,7 @@ finish:
   {
     /* report error issued during command execution */
     if (thd->killed_errno())
-    {
-      if (! thd->get_stmt_da()->is_set())
-        thd->send_kill_message();
-    }
+      thd->send_kill_message();
     if (thd->killed == THD::KILL_QUERY || thd->killed == THD::KILL_BAD_DATA)
     {
       thd->killed= THD::NOT_KILLED;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (jon.hauglid:3223 to 3224) Bug#12661349Jon Olav Hauglid21 Jun