List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:March 28 2008 9:02pm
Subject:bk commit into 5.1 tree (anozdrin:1.2579) BUG#26704
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of anozdrin.  When anozdrin does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-03-28 23:02:36+03:00, anozdrin@stripped +3 -0
  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.

  mysql-test/r/drop-no_root.result@stripped, 2008-03-28 23:02:35+03:00, anozdrin@stripped +27
-0
    Result file.

  mysql-test/r/drop-no_root.result@stripped, 2008-03-28 23:02:35+03:00, anozdrin@stripped +0
-0

  mysql-test/t/drop-no_root.test@stripped, 2008-03-28 23:02:35+03:00, anozdrin@stripped +47
-0
    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).

  mysql-test/t/drop-no_root.test@stripped, 2008-03-28 23:02:35+03:00, anozdrin@stripped +0 -0

  sql/sql_db.cc@stripped, 2008-03-28 23:02:35+03:00, anozdrin@stripped +1 -1
    Do not change current database if we failed to drop it.

diff -Nrup a/mysql-test/r/drop-no_root.result b/mysql-test/r/drop-no_root.result
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/r/drop-no_root.result	2008-03-28 23:02:35 +03:00
@@ -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.
diff -Nrup a/mysql-test/t/drop-no_root.test b/mysql-test/t/drop-no_root.test
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/t/drop-no_root.test	2008-03-28 23:02:35 +03:00
@@ -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.
+
+###########################################################################
diff -Nrup a/sql/sql_db.cc b/sql/sql_db.cc
--- a/sql/sql_db.cc	2008-03-28 01:34:08 +03:00
+++ b/sql/sql_db.cc	2008-03-28 23:02:35 +03:00
@@ -1008,7 +1008,7 @@ exit:
     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);
   VOID(pthread_mutex_unlock(&LOCK_mysql_create_db));
   start_waiting_global_read_lock(thd);
Thread
bk commit into 5.1 tree (anozdrin:1.2579) BUG#26704Alexander Nozdrin28 Mar 2008