FLUSH TABLES; DROP USER 'mysql_user1'; DROP DATABASE IF EXISTS mysql_db1; DROP DATABASE IF EXISTS mysql_db2; DROP TABLE IF EXISTS test.t1; # # Bug#39277 - symlink.test fails on Debian # # Test #1 - Drop test.t1 with CREATE|DROP privileges on another DB. # CREATE USER 'mysql_user1'; # # Create a database for mysql_user1 user's tables. # CREATE DATABASE mysql_db1; # # Grant mysql_user1 to create and drop tables in mysql_db1. # GRANT CREATE, DROP ON mysql_db1.* TO 'mysql_user1'; # # Connection con1 - mysql_user1 # # Make a symlink from 'test' database to MYSQL_TMP_DIR/bug39277. # # Create table mysql_db1.t1, with its files in test. # CREATE TABLE mysql_db1.t1 (c1 INT) ENGINE=MyISAM DATA DIRECTORY='MYSQL_TMP_DIR/bug39277' INDEX DIRECTORY='MYSQL_TMP_DIR/bug39277'; # # Connection default - root # # root can create test.t1 without problems in spite of existing files. # CREATE TABLE test.t1 (c1 INT) ENGINE=MyISAM; INSERT INTO test.t1 VALUES (1), (2), (3); FLUSH TABLE test.t1; SELECT * FROM t1; c1 1 2 3 # # Connection con1 - mysql_user1 # # Drop table mysql_db1.t1, with its files in test. # DROP TABLE mysql_db1.t1; # # Connection default - root # # Show what we have in table test.t1. # This does work as the table is still open in the table cache. # SELECT * FROM t1; c1 1 2 3 # # Close table . # FLUSH TABLE test.t1; # # Show that the table files have gone. # SELECT * FROM t1; ERROR HY000: Can't find file: 't1' (errno: 2) # # Drop table works, but throws error. # DROP TABLE test.t1; ERROR HY000: Error on delete of './test/t1.MYI' (Errcode: 2) # # Cleanup. # DROP DATABASE mysql_db1; DROP USER 'mysql_user1'; # # Test #2 - Drop mysql.user with CREATE|DROP privileges on another DB. # CREATE USER 'mysql_user1'; # # Create a database for mysql_user1 user's tables. # CREATE DATABASE mysql_db1; # # Grant mysql_user1 to create and drop tables in mysql_db1. # GRANT CREATE, DROP ON mysql_db1.* TO 'mysql_user1'; # # Show which users we have in the table mysql.user. # SELECT User FROM mysql.user; User mysql_user1 root root root # # Connection con1 - mysql_user1 # # Make a directory bug39277 somewhere, for example in MYSQL_TMP_DIR. # # Create table mysql_db1.user, with its files in bug39277. # CREATE TABLE mysql_db1.user (c1 INT) ENGINE=MyISAM DATA DIRECTORY='MYSQL_TMP_DIR/bug39277' INDEX DIRECTORY='MYSQL_TMP_DIR/bug39277'; # # Remove the table files and the directory bug39277. # # Make a symlink from 'mysql' database to MYSQL_TMP_DIR/bug39277. # # Drop table mysql_db1.mysql with the files from mysql.user. DROP TABLE mysql_db1.user; # # Connection default - root # # Show which users we have in table mysql.user. # This does work as the table is still open in the table cache. # SELECT User FROM mysql.user; User mysql_user1 root root root # # Close table mysql.user. # FLUSH TABLE mysql.user; # # Show which users we have in the table mysql.user. Bummer! # SELECT User FROM mysql.user; ERROR HY000: Can't find file: 'user' (errno: 2) # # Due to missing table files, we cannot drop the user any more. # DROP USER 'mysql_user1'; ERROR HY000: Can't find file: 'user' (errno: 2) # # Cleanup. # DROP DATABASE mysql_db1; # # Test #3 - Two tables cannot share their files via symlinks. # # Create two databases for the tables. # CREATE DATABASE mysql_db1; CREATE DATABASE mysql_db2; # # Make directory MYSQL_TMP_DIR/bug39277. # # Create table mysql_db1.t1, with its files in bug39277. # CREATE TABLE mysql_db1.t1 (c1 INT) ENGINE=MyISAM DATA DIRECTORY='MYSQL_TMP_DIR/bug39277' INDEX DIRECTORY='MYSQL_TMP_DIR/bug39277'; # # Create table mysql_db2.t1, with its files also in bug39277, fails. # CREATE TABLE mysql_db2.t1 (c1 INT) ENGINE=MyISAM DATA DIRECTORY='/home2/mydev/bzrroot/mysql-5.1-bug39277/mysql-test/var/tmp/bug39277' INDEX DIRECTORY='/home2/mydev/bzrroot/mysql-5.1-bug39277/mysql-test/var/tmp/bug39277'; ERROR HY000: Can't create/write to file '/home2/mydev/bzrroot/mysql-5.1-bug39277/mysql-test/var/tmp/bug39277/t1.MYI' (Errcode: 17) # # Cleanup. # DROP TABLE mysql_db1.t1; DROP DATABASE mysql_db1; DROP DATABASE mysql_db2;