2007-04-25 20:21:55 +02:00
--source include/have_symlink.inc
2005-12-08 16:13:53 +01:00
--source include/not_windows.inc
2003-01-06 00:48:59 +01:00
--disable_warnings
drop table if exists t1,t2,t7,t8,t9;
2003-07-03 10:55:36 +02:00
drop database if exists mysqltest;
2003-01-06 00:48:59 +01:00
--enable_warnings
2001-06-05 02:38:10 +02:00
#
# First create little data to play with
#
2003-01-06 00:48:59 +01:00
2001-06-05 02:38:10 +02:00
create table t1 (a int not null auto_increment, b char(16) not null, primary key (a));
create table t2 (a int not null auto_increment, b char(16) not null, primary key (a));
insert into t1 (b) values ("test"),("test1"),("test2"),("test3");
insert into t2 (b) select b from t1;
insert into t1 (b) select b from t2;
insert into t2 (b) select b from t1;
insert into t1 (b) select b from t2;
insert into t2 (b) select b from t1;
insert into t1 (b) select b from t2;
insert into t2 (b) select b from t1;
insert into t1 (b) select b from t2;
insert into t2 (b) select b from t1;
insert into t1 (b) select b from t2;
insert into t2 (b) select b from t1;
insert into t1 (b) select b from t2;
insert into t2 (b) select b from t1;
insert into t1 (b) select b from t2;
insert into t2 (b) select b from t1;
insert into t1 (b) select b from t2;
insert into t2 (b) select b from t1;
insert into t1 (b) select b from t2;
drop table t2;
#
# Start the test
# We use t9 here to not crash with tables generated by the backup test
#
2008-03-17 16:11:26 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2006-01-24 08:30:54 +01:00
eval create table t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp" index directory="$MYSQLTEST_VARDIR/run";
2001-11-28 02:47:15 +01:00
2001-06-05 02:38:10 +02:00
insert into t9 select * from t1;
check table t9;
optimize table t9;
repair table t9;
alter table t9 add column c int not null;
2005-01-18 04:07:22 +01:00
2006-01-24 08:30:54 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2005-01-19 00:05:16 +01:00
show create table t9;
2001-06-05 02:38:10 +02:00
# Test renames
alter table t9 rename t8, add column d int not null;
alter table t8 rename t7;
rename table t7 to t9;
# Drop old t1 table, keep t9
drop table t1;
#
# Test error handling
# Note that we are using the above table t9 here!
#
2006-01-24 08:30:54 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2005-01-18 04:07:22 +01:00
SHOW CREATE TABLE t9;
2001-06-05 02:38:10 +02:00
# Check that we cannot link over a table from another database.
2003-07-03 10:55:36 +02:00
create database mysqltest;
2001-06-05 02:38:10 +02:00
2001-11-28 02:47:15 +01:00
--error 1,1
2003-12-10 05:31:42 +01:00
create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="/this-dir-does-not-exist";
2001-06-05 02:38:10 +02:00
2008-08-26 11:21:07 +02:00
# temporarily disabled as it returns different result in the embedded server
2008-09-30 21:32:35 +02:00
# --error ER_WRONG_ARGUMENTS, ER_WRONG_ARGUMENTS
2008-08-26 11:21:07 +02:00
# create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="not-hard-path";
2001-06-05 02:38:10 +02:00
2005-01-18 04:07:22 +01:00
# Should fail becasue the file t9.MYI already exist in 'run'
2008-03-17 16:11:26 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2008-09-30 21:32:35 +02:00
--error 1,1,ER_UNKNOWN_ERROR
2006-01-24 08:30:54 +01:00
eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="$MYSQLTEST_VARDIR/run";
2001-06-05 02:38:10 +02:00
2005-01-18 04:07:22 +01:00
# Should fail becasue the file t9.MYD already exist in 'tmp'
2008-03-17 16:11:26 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2001-11-28 02:47:15 +01:00
--error 1,1
2006-01-24 08:30:54 +01:00
eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp";
2001-06-05 02:38:10 +02:00
2003-07-03 10:55:36 +02:00
# Check moving table t9 from default database to mysqltest;
2001-06-05 02:38:10 +02:00
# In this case the symlinks should be removed.
2003-07-03 10:55:36 +02:00
alter table t9 rename mysqltest.t9;
select count(*) from mysqltest.t9;
2006-01-24 08:30:54 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2003-07-03 10:55:36 +02:00
show create table mysqltest.t9;
drop database mysqltest;
2003-12-12 21:26:58 +01:00
#
# Test changing data dir (Bug #1662)
#
2004-02-17 01:26:35 +01:00
create table t1 (a int not null) engine=myisam;
2008-03-17 16:11:26 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2006-01-24 08:30:54 +01:00
eval alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2003-12-12 21:26:58 +01:00
show create table t1;
alter table t1 add b int;
2008-03-17 16:11:26 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2006-01-24 08:30:54 +01:00
eval alter table t1 data directory="$MYSQLTEST_VARDIR/log";
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2003-12-12 21:26:58 +01:00
show create table t1;
2008-03-17 16:11:26 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2006-01-24 08:30:54 +01:00
eval alter table t1 index directory="$MYSQLTEST_VARDIR/log";
2003-12-12 21:26:58 +01:00
show create table t1;
drop table t1;
2005-02-23 22:59:04 +01:00
2007-11-06 15:09:33 +01:00
#
# BUG#32111 - Security Breach via DATA/INDEX DIRECORY and RENAME TABLE
#
2008-02-28 13:46:52 +01:00
--write_file $MYSQLTEST_VARDIR/tmp/t1.MYI
EOF
2008-03-17 16:11:26 +01:00
--replace_result $MYSQLTEST_VARDIR TEST_DIR $MYSQLTEST_VARDIR TEST_DIR
--error 1,1
2007-11-06 15:09:33 +01:00
eval CREATE TABLE t1(a INT)
2008-02-28 13:46:52 +01:00
DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp'
INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
--replace_result $MYSQLTEST_VARDIR TEST_DIR
eval CREATE TABLE t2(a INT)
DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp'
INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
2007-11-12 18:52:30 +01:00
--replace_result $MYSQLTEST_VARDIR TEST_DIR
2007-11-06 15:09:33 +01:00
--error 1
2008-02-28 13:46:52 +01:00
RENAME TABLE t2 TO t1;
DROP TABLE t2;
--remove_file $MYSQLTEST_VARDIR/tmp/t1.MYI
2005-07-28 02:22:47 +02:00
2006-12-14 13:23:31 +01:00
#
# Bug#8706 - temporary table with data directory option fails
#
connect (session1,localhost,root,,);
connect (session2,localhost,root,,);
connection session1;
2008-03-17 16:11:26 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2006-12-18 10:22:48 +01:00
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 9 a;
2006-12-14 13:23:31 +01:00
# If running test suite with a non standard tmp dir, the "show create table"
# will print "DATA_DIRECTORY=". Use replace_result to mask it out
2006-12-18 10:22:48 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2006-12-14 13:23:31 +01:00
show create table t1;
connection session2;
2008-03-17 16:11:26 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2006-12-18 10:22:48 +01:00
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 99 a;
2006-12-14 13:23:31 +01:00
# If running test suite with a non standard tmp dir, the "show create table"
# will print "DATA_DIRECTORY=". Use replace_result to mask it out
2006-12-18 10:22:48 +01:00
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
2006-12-14 13:23:31 +01:00
show create table t1;
connection default;
create table t1 (a int) engine=myisam select 42 a;
connection session1;
select * from t1;
disconnect session1;
connection session2;
select * from t1;
disconnect session2;
connection default;
select * from t1;
drop table t1;
2006-12-15 00:23:54 +01:00
--echo End of 4.1 tests
2006-12-15 00:51:12 +01:00
2007-07-13 12:56:22 +02:00
#
# Bug #29325: create table overwrites .MYD file of other table (datadir)
#
2008-04-03 21:40:10 +02:00
let $MYSQLD_DATADIR= `select @@datadir`;
2007-07-13 12:56:22 +02:00
SET SESSION keep_files_on_create = TRUE;
2008-04-03 21:40:10 +02:00
--write_file $MYSQLD_DATADIR/test/t1.MYD
2008-02-28 13:46:52 +01:00
EOF
2007-07-13 12:56:22 +02:00
--disable_abort_on_error
2008-02-29 14:58:35 +01:00
--error 1,1,ER_TABLE_EXISTS_ERROR
2007-07-13 12:56:22 +02:00
CREATE TABLE t1 (a INT) ENGINE MYISAM;
2008-02-28 13:46:52 +01:00
--error 0,1
2008-04-03 21:40:10 +02:00
--remove_file $MYSQLD_DATADIR/test/t1.MYD;
2007-07-13 12:56:22 +02:00
--enable_abort_on_error
2008-02-28 13:46:52 +01:00
SET SESSION keep_files_on_create = FALSE;
CREATE TABLE t1 (a INT) ENGINE MYISAM;
DROP TABLE t1;
2007-07-13 12:56:22 +02:00
2006-12-15 00:51:12 +01:00
--echo End of 5.0 tests
2007-12-07 14:40:42 +01:00
#
2008-02-28 13:46:52 +01:00
# Bug#32167: another privilege bypass with DATA/INDEX DIRECTORY
#
2008-11-25 15:06:31 +01:00
# With Bug#41002 (symlink.test fails on symlinked datadir) it was
# decided that the below statements may also succeed if the data
# home directory is symlinked, e.g. mysql-test-run --mem.
# This will be fixed in 6.0 only.
#
2008-04-03 21:40:10 +02:00
let $MYSQLD_DATADIR= `select @@datadir`;
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
2008-11-25 15:06:31 +01:00
--error 0,ER_WRONG_ARGUMENTS
2008-02-28 13:46:52 +01:00
eval CREATE TABLE t1(a INT)
2008-04-03 21:40:10 +02:00
INDEX DIRECTORY='$MYSQLD_DATADIR/mysql';
2008-11-25 15:06:31 +01:00
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#
2008-04-03 21:40:10 +02:00
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
2008-11-25 15:06:31 +01:00
--error 0,ER_WRONG_ARGUMENTS
2008-02-28 13:46:52 +01:00
eval CREATE TABLE t1(a INT)
2008-04-03 21:40:10 +02:00
DATA DIRECTORY='$MYSQLD_DATADIR/test';
2008-11-25 15:06:31 +01:00
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#
2008-04-03 21:40:10 +02:00
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
2008-11-25 15:06:31 +01:00
--error 0,ER_WRONG_ARGUMENTS
2008-02-28 13:46:52 +01:00
eval CREATE TABLE t1(a INT)
2008-04-03 21:40:10 +02:00
DATA DIRECTORY='$MYSQLD_DATADIR/';
2008-11-25 15:06:31 +01:00
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#
2008-04-03 21:40:10 +02:00
--replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
2008-11-25 15:06:31 +01:00
--error 0,ER_WRONG_ARGUMENTS
2008-02-28 13:46:52 +01:00
eval CREATE TABLE t1(a INT)
2008-04-03 21:40:10 +02:00
INDEX DIRECTORY='$MYSQLD_DATADIR';
2008-11-25 15:06:31 +01:00
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#
2008-02-28 13:46:52 +01:00
--replace_result $MYSQLTEST_VARDIR TEST_DIR
--error 1
eval CREATE TABLE t1(a INT)
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data_var';
2008-10-23 21:27:09 +02:00
2008-11-25 15:06:31 +01:00
#
2007-12-07 14:40:42 +01:00
# BUG#25677 - With --skip-symbolic-links option on, DATA DIRECTORY clause is
# silently ignored
#
2008-04-03 21:40:10 +02:00
2007-12-07 14:40:42 +01:00
SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='NO_DIR_IN_CREATE';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval CREATE TABLE t1(a INT) DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp' INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
DROP TABLE t1;
SET @@SQL_MODE=@OLD_SQL_MODE;
--echo End of 5.1 tests