mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
A backport of patch for Bug#26704.
Original revision is from mysql-6.0-codebase: revno: 2630.3.1 committer: Alexander Nozdrin <alik@mysql.com> branch nick: 6.0-rt-bug26704 timestamp: Thu 2008-05-29 21:04:06 +0400 message: 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.
This commit is contained in:
parent
1733a974b4
commit
9384835087
3 changed files with 77 additions and 1 deletions
27
mysql-test/r/drop-no_root.result
Normal file
27
mysql-test/r/drop-no_root.result
Normal file
|
@ -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.
|
49
mysql-test/t/drop-no_root.test
Normal file
49
mysql-test/t/drop-no_root.test
Normal file
|
@ -0,0 +1,49 @@
|
|||
# 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;
|
||||
|
||||
let $MYSQLD_DATADIR= `select @@datadir`;
|
||||
|
||||
--echo
|
||||
--echo chmod 000 mysql_test/t1.frm
|
||||
--chmod 0000 $MYSQLD_DATADIR/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 $MYSQLD_DATADIR/mysql_test/t1.MYD
|
||||
--exec rm $MYSQLD_DATADIR/mysql_test/t1.MYI
|
||||
|
||||
--echo
|
||||
DROP DATABASE mysql_test;
|
||||
|
||||
--echo
|
||||
use test;
|
||||
|
||||
--echo
|
||||
--echo # -- End of Bug#26704.
|
||||
|
||||
###########################################################################
|
|
@ -1027,7 +1027,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);
|
||||
|
|
Loading…
Reference in a new issue