List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:November 11 2010 5:26am
Subject:bzr push into mysql-5.1-bugteam branch (Dmitry.Shulga:3502 to 3503) Bug#54375
View as plain text  
 3503 Dmitry Shulga	2010-11-11
      Fixed bug#54375 - Error in stored procedure leaves connection
      in different default schema.
      
      In strict mode, when data truncation or conversion happens,
      THD::killed is set to THD::KILL_BAD_DATA.
      
      This is abuse of KILL mechanism to guarantee that execution
      of statement is aborted.
      
      The stored procedures execution, on the other hand,
      upon detection that a connection was killed, would
      terminate immediately, without trying to restore the caller's
      context, in particular, restore the caller's current schema.
      
      The fix is, when terminating a stored procedure execution,
      to only bypass cleanup if the entire connection was killed,
      not in case of other forms of KILL.
     @ mysql-test/r/sp-bugs.result
        Added result for a test case for bug#54375.
     @ mysql-test/t/sp-bugs.test
        Added test case for bug#54375.
     @ sql/sp_head.cc
        sp_head::execute modified: restore saved current db if
        connection is not killed.

    modified:
      mysql-test/r/sp-bugs.result
      mysql-test/t/sp-bugs.test
      sql/sp_head.cc
 3502 Dmitry Shulga	2010-11-10
      Fixed bug#56619 - Assertion failed during
      ALTER TABLE RENAME, DISABLE KEYS.
      
      The code of ALTER TABLE RENAME, DISABLE KEYS could
      issue a commit while holding LOCK_open mutex.
      This is a regression introduced by the fix for
      Bug 54453.
      This failed an assert guarding us against a potential
      deadlock with connections trying to execute
      FLUSH TABLES WITH READ LOCK.
      
      The fix is to move acquisition of LOCK_open outside
      the section that issues ha_autocommit_or_rollback().
      LOCK_open is taken to protect against concurrent
      operations with .frms and the table definition
      cache, and doesn't need to cover the call to commit.
      
      A test case added to innodb_mysql.test.
      
      The patch is to be null-merged to 5.5, which
      already has 54453 null-merged to it.
     @ mysql-test/suite/innodb/r/innodb_mysql.result
        Added test results for test for bug#56619.
     @ mysql-test/suite/innodb/t/innodb_mysql.test
        Added test for bug#56619.
     @ sql/sql_table.cc
        mysql_alter_table() modified: moved acquisition of LOCK_open
        after call to ha_autocommit_or_rollback.

    modified:
      mysql-test/suite/innodb/r/innodb_mysql.result
      mysql-test/suite/innodb/t/innodb_mysql.test
      sql/sql_table.cc
=== modified file 'mysql-test/r/sp-bugs.result'
--- a/mysql-test/r/sp-bugs.result	2010-02-13 10:35:14 +0000
+++ b/mysql-test/r/sp-bugs.result	2010-11-11 04:52:51 +0000
@@ -73,4 +73,40 @@ CALL p1 ();
 ERROR HY000: Trigger does not exist
 DROP TABLE t1;
 DROP PROCEDURE p1;
+#
+# Bug#54375: Error in stored procedure leaves connection
+# in different default schema
+#
+SET @@SQL_MODE = 'STRICT_ALL_TABLES';
+DROP DATABASE IF EXISTS db1;
+CREATE DATABASE db1;
+USE db1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 int NOT NULL PRIMARY KEY);
+INSERT INTO t1 VALUES (1);
+CREATE FUNCTION f1 (
+some_value int
+)
+RETURNS smallint
+DETERMINISTIC
+BEGIN
+INSERT INTO t1 SET c1 = some_value;
+RETURN(LAST_INSERT_ID());
+END$$
+DROP DATABASE IF EXISTS db2;
+CREATE DATABASE db2;
+USE db2;
+SELECT DATABASE();
+DATABASE()
+db2
+SELECT db1.f1(1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+SELECT DATABASE();
+DATABASE()
+db2
+USE test;
+DROP FUNCTION db1.f1;
+DROP TABLE db1.t1;
+DROP DATABASE db1;
+DROP DATABASE db2;
 End of 5.1 tests

=== modified file 'mysql-test/t/sp-bugs.test'
--- a/mysql-test/t/sp-bugs.test	2010-02-13 10:35:14 +0000
+++ b/mysql-test/t/sp-bugs.test	2010-11-11 04:52:51 +0000
@@ -101,4 +101,41 @@ CALL p1 ();
 DROP TABLE t1;
 DROP PROCEDURE p1;
 
+--echo #
+--echo # Bug#54375: Error in stored procedure leaves connection
+--echo # in different default schema
+--echo #
+
+--disable_warnings
+SET @@SQL_MODE = 'STRICT_ALL_TABLES';
+DROP DATABASE IF EXISTS db1;
+CREATE DATABASE db1;
+USE db1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c1 int NOT NULL PRIMARY KEY);
+INSERT INTO t1 VALUES (1);
+DELIMITER $$;
+CREATE FUNCTION f1 (
+	some_value int
+)
+RETURNS smallint
+DETERMINISTIC
+BEGIN
+	INSERT INTO t1 SET c1 = some_value;
+        RETURN(LAST_INSERT_ID());
+END$$
+DELIMITER ;$$
+DROP DATABASE IF EXISTS db2;
+CREATE DATABASE db2;
+--enable_warnings
+USE db2;
+SELECT DATABASE();
+--error ER_DUP_ENTRY
+SELECT db1.f1(1);
+SELECT DATABASE();
+USE test;
+DROP FUNCTION db1.f1;
+DROP TABLE db1.t1;
+DROP DATABASE db1;
+DROP DATABASE db2;
 --echo End of 5.1 tests

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2010-07-19 14:30:34 +0000
+++ b/sql/sp_head.cc	2010-11-11 04:52:51 +0000
@@ -1372,7 +1372,7 @@ sp_head::execute(THD *thd)
     If the DB has changed, the pointer has changed too, but the
     original thd->db will then have been freed
   */
-  if (cur_db_changed && !thd->killed)
+  if (cur_db_changed && thd->killed != THD::KILL_CONNECTION)
   {
     /*
       Force switching back to the saved current database, because it may be


Attachment: [text/bzr-bundle] bzr/dmitry.shulga@oracle.com-20101111045251-jl1spfh3xjti1sll.bundle
Thread
bzr push into mysql-5.1-bugteam branch (Dmitry.Shulga:3502 to 3503) Bug#54375Dmitry Shulga11 Nov