# Windows doesn't have symbolic links. --source include/not_windows.inc # Grants work differently on embedded server. --source include/not_embedded.inc FLUSH TABLES; --disable_warnings --error 0, ER_CANNOT_USER DROP USER 'mysql_user1'; DROP DATABASE IF EXISTS mysql_db1; DROP DATABASE IF EXISTS mysql_db2; DROP TABLE IF EXISTS test.t1; --enable_warnings --echo # --echo # Bug#39277 - symlink.test fails on Debian --echo # --echo # Test #1 - Drop test.t1 with CREATE|DROP privileges on another DB. --echo # CREATE USER 'mysql_user1'; --echo # --echo # Create a database for mysql_user1 user's tables. --echo # CREATE DATABASE mysql_db1; --echo # --echo # Grant mysql_user1 to create and drop tables in mysql_db1. --echo # GRANT CREATE, DROP ON mysql_db1.* TO 'mysql_user1'; # --echo # --echo # Connection con1 - mysql_user1 --connect (con1, localhost, mysql_user1,,) --echo # --echo # Make a symlink from 'test' database to MYSQL_TMP_DIR/bug39277. --exec ln -s $MYSQLTEST_VARDIR/master-data/test $MYSQL_TMP_DIR/bug39277 --echo # --echo # Create table mysql_db1.t1, with its files in test. --echo # --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR eval CREATE TABLE mysql_db1.t1 (c1 INT) ENGINE=MyISAM DATA DIRECTORY='$MYSQL_TMP_DIR/bug39277' INDEX DIRECTORY='$MYSQL_TMP_DIR/bug39277'; # --echo # --echo # Connection default - root connection default; --echo # --echo # root can create test.t1 without problems in spite of existing files. --echo # CREATE TABLE test.t1 (c1 INT) ENGINE=MyISAM; INSERT INTO test.t1 VALUES (1), (2), (3); FLUSH TABLE test.t1; SELECT * FROM t1; # --echo # --echo # Connection con1 - mysql_user1 --connection con1 --echo # --echo # Drop table mysql_db1.t1, with its files in test. --echo # DROP TABLE mysql_db1.t1; --remove_file $MYSQL_TMP_DIR/bug39277 --disconnect con1 # --echo # --echo # Connection default - root connection default; --echo # --echo # Show what we have in table test.t1. --echo # This does work as the table is still open in the table cache. --echo # SELECT * FROM t1; --echo # --echo # Close table . --echo # FLUSH TABLE test.t1; --echo # --echo # Show that the table files have gone. --echo # --error ER_FILE_NOT_FOUND SELECT * FROM t1; --echo # --echo # Drop table works, but throws error. --echo # --error 6 DROP TABLE test.t1; --echo # --echo # Cleanup. --echo # DROP DATABASE mysql_db1; DROP USER 'mysql_user1'; # # --echo # --echo # Test #2 - Drop mysql.user with CREATE|DROP privileges on another DB. --echo # CREATE USER 'mysql_user1'; --echo # --echo # Create a database for mysql_user1 user's tables. --echo # CREATE DATABASE mysql_db1; --echo # --echo # Grant mysql_user1 to create and drop tables in mysql_db1. --echo # GRANT CREATE, DROP ON mysql_db1.* TO 'mysql_user1'; --echo # --echo # Show which users we have in the table mysql.user. --echo # SELECT User FROM mysql.user; # --echo # --echo # Connection con1 - mysql_user1 --connect (con1, localhost, mysql_user1,,) --echo # --echo # Make a directory bug39277 somewhere, for example in MYSQL_TMP_DIR. --mkdir $MYSQL_TMP_DIR/bug39277 --echo # --echo # Create table mysql_db1.user, with its files in bug39277. --echo # --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR eval CREATE TABLE mysql_db1.user (c1 INT) ENGINE=MyISAM DATA DIRECTORY='$MYSQL_TMP_DIR/bug39277' INDEX DIRECTORY='$MYSQL_TMP_DIR/bug39277'; --echo # --echo # Remove the table files and the directory bug39277. --remove_file $MYSQL_TMP_DIR/bug39277/user.MYD --remove_file $MYSQL_TMP_DIR/bug39277/user.MYI --rmdir $MYSQL_TMP_DIR/bug39277 --echo # --echo # Make a symlink from 'mysql' database to MYSQL_TMP_DIR/bug39277. --exec ln -s $MYSQLTEST_VARDIR/master-data/mysql $MYSQL_TMP_DIR/bug39277 --echo # --echo # Drop table mysql_db1.mysql with the files from mysql.user. DROP TABLE mysql_db1.user; --remove_file $MYSQL_TMP_DIR/bug39277 --disconnect con1 # --echo # --echo # Connection default - root connection default; --echo # --echo # Show which users we have in table mysql.user. --echo # This does work as the table is still open in the table cache. --echo # SELECT User FROM mysql.user; --echo # --echo # Close table mysql.user. --echo # FLUSH TABLE mysql.user; --echo # --echo # Show which users we have in the table mysql.user. Bummer! --echo # --error ER_FILE_NOT_FOUND SELECT User FROM mysql.user; --echo # --echo # Due to missing table files, we cannot drop the user any more. --echo # --error ER_FILE_NOT_FOUND DROP USER 'mysql_user1'; --echo # --echo # Cleanup. --echo # DROP DATABASE mysql_db1; # # --echo # --echo # Test #3 - Two tables cannot share their files via symlinks. --echo # --echo # Create two databases for the tables. --echo # CREATE DATABASE mysql_db1; CREATE DATABASE mysql_db2; --echo # --echo # Make directory MYSQL_TMP_DIR/bug39277. --mkdir $MYSQL_TMP_DIR/bug39277 --echo # --echo # Create table mysql_db1.t1, with its files in bug39277. --echo # --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR eval CREATE TABLE mysql_db1.t1 (c1 INT) ENGINE=MyISAM DATA DIRECTORY='$MYSQL_TMP_DIR/bug39277' INDEX DIRECTORY='$MYSQL_TMP_DIR/bug39277'; --echo # --echo # Create table mysql_db2.t1, with its files also in bug39277, fails. --echo # --error 1 eval CREATE TABLE mysql_db2.t1 (c1 INT) ENGINE=MyISAM DATA DIRECTORY='$MYSQL_TMP_DIR/bug39277' INDEX DIRECTORY='$MYSQL_TMP_DIR/bug39277'; --echo # --echo # Cleanup. --echo # DROP TABLE mysql_db1.t1; --rmdir $MYSQL_TMP_DIR/bug39277 DROP DATABASE mysql_db1; DROP DATABASE mysql_db2; #