List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:June 23 2011 6:16pm
Subject:bzr push into mysql-trunk branch (Dmitry.Shulga:3234 to 3235) Bug#11756013
View as plain text  
 3235 Dmitry Shulga	2011-06-24 [merge]
      Auto-merge of patch for bug#11756013 from mysql-5.5 tree.

    modified:
      mysql-test/r/sp_sync.result
      mysql-test/t/sp_sync.test
      sql/sp.cc
      sql/sql_db.cc
 3234 Vasil Dimov	2011-06-23
      Do not check that the number of pages for the test table
      is small in innodb_buffer_pool_load.test
      
      The number of pages is nondeterministic and we can safely assume that
      it is small (table not loaded in BP) after
      "-- source include/restart_mysqld.inc".

    modified:
      mysql-test/suite/innodb/r/innodb_buffer_pool_load.result
      mysql-test/suite/innodb/t/innodb_buffer_pool_load.test
=== modified file 'mysql-test/r/sp_sync.result'
--- a/mysql-test/r/sp_sync.result	2010-06-07 07:06:55 +0000
+++ b/mysql-test/r/sp_sync.result	2011-06-23 17:02:58 +0000
@@ -1,4 +1,4 @@
-Tests of syncronization of stored procedure execution.
+Tests of synchronization of stored procedure execution.
 SET DEBUG_SYNC= 'RESET';
 #
 # Bug #30977 Concurrent statement using stored function and
@@ -92,4 +92,16 @@ COUNT(f1(a))
 DROP PROCEDURE p1;
 DROP FUNCTION f1;
 DROP TABLES t0, t1;
-SET DEBUG_SYNC= 'RESET';
+#
+# test for bug#11756013
+#
+DROP SCHEMA IF EXISTS s1;
+CREATE SCHEMA s1;
+CREATE PROCEDURE s1.p1() BEGIN END;
+SET DEBUG_SYNC='before_db_dir_check SIGNAL check_db WAIT_FOR dropped_schema';
+CALL s1.p1;
+SET DEBUG_SYNC='now WAIT_FOR check_db';
+DROP SCHEMA s1;
+SET DEBUG_SYNC='now SIGNAL dropped_schema';
+ERROR 42000: Unknown database 's1'
+SET DEBUG_SYNC = 'RESET';

=== modified file 'mysql-test/t/sp_sync.test'
--- a/mysql-test/t/sp_sync.test	2010-08-06 11:29:37 +0000
+++ b/mysql-test/t/sp_sync.test	2011-06-23 17:02:58 +0000
@@ -1,7 +1,7 @@
 # This test should work in embedded server after mysqltest is fixed
 -- source include/not_embedded.inc
 
---echo Tests of syncronization of stored procedure execution.
+--echo Tests of synchronization of stored procedure execution.
 
 --source include/have_debug_sync.inc
 
@@ -149,9 +149,34 @@ disconnect con2;
 DROP PROCEDURE p1;
 DROP FUNCTION f1;
 DROP TABLES t0, t1;
-SET DEBUG_SYNC= 'RESET';
 
 
+--echo #
+--echo # test for bug#11756013
+--echo #
+--disable_warnings
+DROP SCHEMA IF EXISTS s1;
+--enable_warnings
+CREATE SCHEMA s1;
+CREATE PROCEDURE s1.p1() BEGIN END;
+
+connect (con3, localhost, root);
+SET DEBUG_SYNC='before_db_dir_check SIGNAL check_db WAIT_FOR dropped_schema';
+--send CALL s1.p1
+
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR check_db';
+DROP SCHEMA s1;
+SET DEBUG_SYNC='now SIGNAL dropped_schema';
+
+connection con3;
+--error ER_BAD_DB_ERROR
+--reap
+connection default;
+disconnect con3;
+
+SET DEBUG_SYNC = 'RESET';
+
 # Check that all connections opened by test cases in this file are really
 # gone so execution of other tests won't be affected by their presence.
 --source include/wait_until_count_sessions.inc

=== modified file 'sql/sp.cc'
--- a/sql/sp.cc	2011-06-10 16:57:01 +0000
+++ b/sql/sp.cc	2011-06-23 17:34:08 +0000
@@ -756,6 +756,43 @@ static sp_head *sp_compile(THD *thd, Str
 }
 
 
+class Bad_db_error_handler : public Internal_error_handler
+{
+public:
+  Bad_db_error_handler()
+    :m_error_caught(false)
+  {}
+
+  virtual bool handle_condition(THD *thd,
+                                uint sql_errno,
+                                const char* sqlstate,
+                                MYSQL_ERROR::enum_warning_level level,
+                                const char* message,
+                                MYSQL_ERROR ** cond_hdl);
+
+  bool error_caught() const { return m_error_caught; }
+
+private:
+  bool m_error_caught;
+};
+
+bool
+Bad_db_error_handler::handle_condition(THD *thd,
+                                       uint sql_errno,
+                                       const char* sqlstate,
+                                       MYSQL_ERROR::enum_warning_level level,
+                                       const char* message,
+                                       MYSQL_ERROR ** cond_hdl)
+{
+  if (sql_errno == ER_BAD_DB_ERROR)
+  {
+    m_error_caught= true;
+    return true;
+  }
+  return false;
+}
+
+
 static int
 db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
                 sql_mode_t sql_mode, const char *params, const char *returns,
@@ -769,7 +806,7 @@ db_load_routine(THD *thd, int type, sp_n
   LEX_STRING saved_cur_db_name=
     { saved_cur_db_name_buf, sizeof(saved_cur_db_name_buf) };
   bool cur_db_changed;
-  
+  Bad_db_error_handler db_not_exists_handler;
   char definer_user_name_holder[USERNAME_LENGTH + 1];
   LEX_STRING definer_user_name= { definer_user_name_holder,
                                   USERNAME_LENGTH };
@@ -808,6 +845,7 @@ db_load_routine(THD *thd, int type, sp_n
     goto end;
   }
 
+  thd->push_internal_handler(&db_not_exists_handler);
   /*
     Change the current database (if needed).
 
@@ -818,6 +856,15 @@ db_load_routine(THD *thd, int type, sp_n
                           &cur_db_changed))
   {
     ret= SP_INTERNAL_ERROR;
+    thd->pop_internal_handler();
+    goto end;
+  }
+  thd->pop_internal_handler();
+  if (db_not_exists_handler.error_caught())
+  {
+    ret= SP_INTERNAL_ERROR;
+    my_error(ER_BAD_DB_ERROR, MYF(0), name->m_db.str);
+
     goto end;
   }
 

=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sql_db.cc	2011-06-23 17:34:08 +0000
@@ -40,6 +40,7 @@
 #ifdef __WIN__
 #include <direct.h>
 #endif
+#include "debug_sync.h"
 
 #define MAX_DROP_TABLE_Q_LEN      1024
 
@@ -1533,6 +1534,8 @@ bool mysql_change_db(THD *thd, const LEX
   }
 #endif
 
+  DEBUG_SYNC(thd, "before_db_dir_check");
+
   if (check_db_dir_existence(new_db_file_name.str))
   {
     if (force_switch)


Attachment: [text/bzr-bundle] bzr/dmitry.shulga@oracle.com-20110623173408-mmu678f32403knsn.bundle
Thread
bzr push into mysql-trunk branch (Dmitry.Shulga:3234 to 3235) Bug#11756013Dmitry Shulga23 Jun