List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:May 29 2008 5:04pm
Subject:commit into mysql-6.0 branch (alik:2645) Bug#26704
View as plain text  
#At file:///mnt/raid/alik/MySQL/devel/6.0-rt-bug26704/

 2645 Alexander Nozdrin	2008-05-29
      A fix for Bug#26704: Failing DROP DATABASE brings
      mysql-client out of sync.
      
      The problem was that we changed current database w/o caring
      whether it was dropped successfully or not.
      
      The fix is not to change current database if we failed to drop it.
added:
  mysql-test/r/drop-no_root.result
  mysql-test/t/drop-no_root.test
modified:
  sql/sql_db.cc

per-file comments:
  mysql-test/r/drop-no_root.result
    Result file.
  mysql-test/t/drop-no_root.test
    A test case for Bug#26704: Failing DROP DATABASE brings
    mysql-client out of sync.
    
    A new test file (drop.test can not be used) is required
    because the test case uses 'chmod' directive, which should
    not be used when the test suite is running under super
    user account (root).
  sql/sql_db.cc
    Do not change current database if we failed to drop it.

=== added file 'mysql-test/r/drop-no_root.result'
--- a/mysql-test/r/drop-no_root.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/drop-no_root.result	2008-05-29 17:04:06 +0000
@@ -0,0 +1,27 @@
+
+# --
+# -- Bug#26704: Failing DROP DATABASE brings mysql-client out of sync.
+# --
+
+DROP DATABASE IF EXISTS mysql_test;
+
+CREATE DATABASE mysql_test;
+CREATE TABLE mysql_test.t1(c INT);
+use mysql_test;
+
+chmod 000 mysql_test/t1.frm
+
+DROP DATABASE mysql_test;
+ERROR HY000: Error dropping database (can't rmdir './mysql_test', errno: 39)
+
+SELECT DATABASE();
+DATABASE()
+mysql_test
+
+rm mysql_test/t1.MYD mysql_test/t1.MYI
+
+DROP DATABASE mysql_test;
+
+use test;
+
+# -- End of Bug#26704.

=== added file 'mysql-test/t/drop-no_root.test'
--- a/mysql-test/t/drop-no_root.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/drop-no_root.test	2008-05-29 17:04:06 +0000
@@ -0,0 +1,47 @@
+# This test uses chmod, can't be run with root permissions
+--source include/not_as_root.inc
+
+###########################################################################
+
+--echo
+--echo # --
+--echo # -- Bug#26704: Failing DROP DATABASE brings mysql-client out of sync.
+--echo # --
+
+--echo
+--disable_warnings
+DROP DATABASE IF EXISTS mysql_test;
+--enable_warnings
+
+--echo
+CREATE DATABASE mysql_test;
+CREATE TABLE mysql_test.t1(c INT);
+
+use mysql_test;
+
+--echo
+--echo chmod 000 mysql_test/t1.frm
+--chmod 0000 $MYSQLTEST_VARDIR/master-data/mysql_test/t1.frm
+
+--echo
+--error ER_DB_DROP_RMDIR
+DROP DATABASE mysql_test;
+
+--echo
+SELECT DATABASE();
+
+--echo
+--echo rm mysql_test/t1.MYD mysql_test/t1.MYI
+--exec rm $MYSQLTEST_VARDIR/master-data/mysql_test/t1.MYD
+--exec rm $MYSQLTEST_VARDIR/master-data/mysql_test/t1.MYI
+
+--echo
+DROP DATABASE mysql_test;
+
+--echo
+use test;
+
+--echo
+--echo # -- End of Bug#26704.
+
+###########################################################################

=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc	2008-05-14 13:49:41 +0000
+++ b/sql/sql_db.cc	2008-05-29 17:04:06 +0000
@@ -1010,7 +1010,7 @@
     SELECT DATABASE() in the future). For this we free() thd->db and set
     it to 0.
   */
-  if (thd->db && !strcmp(thd->db, db))
+  if (thd->db && !strcmp(thd->db, db) && error == 0)
     mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
   pthread_mutex_unlock(&LOCK_mysql_create_db);
   start_waiting_global_read_lock(thd);

Thread
commit into mysql-6.0 branch (alik:2645) Bug#26704Alexander Nozdrin29 May