Commit 79a3f961 authored by Sergei Golubchik's avatar Sergei Golubchik

rewrite bug#26704 test case

drop-no_root needs DROP DATABASE to fail.
But `chmod 000` is not reliable after drop table force anymore.

Make DROP DATABASE to fail by creating an extra file in the db dir
parent 529b6dff
# --
# -- 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;
SELECT DATABASE();
DATABASE()
mysql_test
rm -f mysql_test/t1.MYD mysql_test/t1.MYI
chmod 666 mysql_test/t1.frm
rm -f mysql_test/t1.frm
DROP DATABASE mysql_test;
use test;
# -- End of Bug#26704.
# 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
# NOTE: For the DROP DATABASE below we need:
# - disable result log because ER_DB_DROP_RMDIR contains errno, which can be
# different on different platforms.
# - expect different error codes, because Windows and UNIX behaves
# differently (see below).
#
# NOTE: Windows and UNIX behaves differently in this test case:
#
# - on UNIX when t1.frm is chmoded to 000, it is perfectly deleted
# by the first DROP DATABASE, but some other files (t1.MYI and t1.MYD) left
# in the directory. So, we have to explicitly removes them before the
# second DROP DATABASE.
#
# - on Windows when t1.frm is chmoded to 000, it is not deleted by the first
# DROP DATABASE, but all other files in the database directory are deleted.
# Thus, we have to change the t1.frm permissions again and delete it
# explicitly before the second DROP DATABASE.
#
# All those differences do not really matter for the idea of this test case:
# checking that if DROP DATABASE failed, the client is Ok.
--echo
--disable_result_log
--error ER_DB_DROP_RMDIR,6
DROP DATABASE mysql_test;
--enable_result_log
--echo
SELECT DATABASE();
# Remove t1.MYI and t1.MYD. On UNIX it should succeed. On Windows, it fails.
--echo
--echo rm -f mysql_test/t1.MYD mysql_test/t1.MYI
--error 0, 1
--remove_file $MYSQLD_DATADIR/mysql_test/t1.MYD
--error 0, 1
--remove_file $MYSQLD_DATADIR/mysql_test/t1.MYI
# Make t1.frm removable: fail on UNIX, succeed on Windows.
--echo chmod 666 mysql_test/t1.frm
--error 0, 1
--chmod 0666 $MYSQLD_DATADIR/mysql_test/t1.frm
# Remove t1.frm: fail on UNIX, succeed on Windows.
--echo rm -f mysql_test/t1.frm
--error 0, 1
--remove_file $MYSQLD_DATADIR/mysql_test/t1.frm
--echo
DROP DATABASE mysql_test;
--echo
use test;
--echo
--echo # -- End of Bug#26704.
###########################################################################
...@@ -131,6 +131,19 @@ create table mysql_test.`#sql-347f_7` (f1 int); ...@@ -131,6 +131,19 @@ create table mysql_test.`#sql-347f_7` (f1 int);
create table mysql_test.`#sql-347f_8` (f1 int); create table mysql_test.`#sql-347f_8` (f1 int);
drop table mysql_test.`#sql-347f_8`; drop table mysql_test.`#sql-347f_8`;
drop database mysql_test; drop database mysql_test;
create database mysql_test;
use mysql_test;
create table t1(c int);
drop database mysql_test;
ERROR HY000: Error dropping database (can't rmdir './mysql_test', errno: 39 "Directory not empty")
select database();
database()
mysql_test
drop database mysql_test;
select database();
database()
NULL
use test;
# -- # --
# -- Bug#29958: Weird message on DROP DATABASE if mysql.proc does not # -- Bug#29958: Weird message on DROP DATABASE if mysql.proc does not
......
...@@ -175,6 +175,27 @@ let $MYSQLD_DATADIR= `select @@datadir`; ...@@ -175,6 +175,27 @@ let $MYSQLD_DATADIR= `select @@datadir`;
copy_file $MYSQLD_DATADIR/mysql_test/t1.frm $MYSQLD_DATADIR/mysql_test/#sql-347f_6.frm; copy_file $MYSQLD_DATADIR/mysql_test/t1.frm $MYSQLD_DATADIR/mysql_test/#sql-347f_6.frm;
drop database mysql_test; drop database mysql_test;
#
# Bug#26704: Failing DROP DATABASE brings mysql-client out of sync.
#
create database mysql_test;
use mysql_test;
create table t1(c int);
write_file $MYSQLD_DATADIR/mysql_test/do_not_delete;
do_not_delete
EOF
replace_result $MYSQLD_DATADIR ./ \\ / 41 39;
error ER_DB_DROP_RMDIR;
drop database mysql_test;
select database();
remove_file $MYSQLD_DATADIR/mysql_test/do_not_delete;
drop database mysql_test;
select database();
use test;
########################################################################### ###########################################################################
--echo --echo
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment