1
--source include/have_symlink.inc
2
--source include/not_windows.inc
5
drop table if exists t1,t2,t7,t8,t9;
6
drop database if exists mysqltest;
10
# First create little data to play with
13
create table t1 (a int not null auto_increment, b char(16) not null, primary key (a));
14
create table t2 (a int not null auto_increment, b char(16) not null, primary key (a));
15
insert into t1 (b) values ("test"),("test1"),("test2"),("test3");
16
insert into t2 (b) select b from t1;
17
insert into t1 (b) select b from t2;
18
insert into t2 (b) select b from t1;
19
insert into t1 (b) select b from t2;
20
insert into t2 (b) select b from t1;
21
insert into t1 (b) select b from t2;
22
insert into t2 (b) select b from t1;
23
insert into t1 (b) select b from t2;
24
insert into t2 (b) select b from t1;
25
insert into t1 (b) select b from t2;
26
insert into t2 (b) select b from t1;
27
insert into t1 (b) select b from t2;
28
insert into t2 (b) select b from t1;
29
insert into t1 (b) select b from t2;
30
insert into t2 (b) select b from t1;
31
insert into t1 (b) select b from t2;
32
insert into t2 (b) select b from t1;
33
insert into t1 (b) select b from t2;
38
# We use t9 here to not crash with tables generated by the backup test
41
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
42
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";
44
insert into t9 select * from t1;
48
alter table t9 add column c int not null;
50
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
54
alter table t9 rename t8, add column d int not null;
55
alter table t8 rename t7;
56
rename table t7 to t9;
57
# Drop old t1 table, keep t9
62
# Note that we are using the above table t9 here!
65
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
69
create table t1 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="tmp";
71
# Check that we cannot link over a table from another database.
73
create database mysqltest;
76
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";
79
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";
81
# Should fail becasue the file t9.MYI already exist in 'run'
82
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
84
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";
86
# Should fail becasue the file t9.MYD already exist in 'tmp'
87
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
88
--error 1,1,ER_TABLE_EXISTS_ERROR
89
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";
91
# Check moving table t9 from default database to mysqltest;
92
# In this case the symlinks should be removed.
94
alter table t9 rename mysqltest.t9;
95
select count(*) from mysqltest.t9;
96
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
97
show create table mysqltest.t9;
98
drop database mysqltest;
101
# Test changing data dir (Bug #1662)
104
create table t1 (a int not null) engine=myisam;
105
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
106
eval alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
107
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
108
show create table t1;
109
alter table t1 add b int;
110
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
111
eval alter table t1 data directory="$MYSQLTEST_VARDIR/log";
112
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
113
show create table t1;
114
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
115
eval alter table t1 index directory="$MYSQLTEST_VARDIR/log";
116
show create table t1;
120
# BUG#32111 - Security Breach via DATA/INDEX DIRECORY and RENAME TABLE
122
--write_file $MYSQLTEST_VARDIR/tmp/t1.MYI
125
--replace_result $MYSQLTEST_VARDIR TEST_DIR $MYSQLTEST_VARDIR TEST_DIR
127
eval CREATE TABLE t1(a INT)
128
DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp'
129
INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
130
--replace_result $MYSQLTEST_VARDIR TEST_DIR
131
eval CREATE TABLE t2(a INT)
132
DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp'
133
INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
134
--replace_result $MYSQLTEST_VARDIR TEST_DIR
136
RENAME TABLE t2 TO t1;
138
--remove_file $MYSQLTEST_VARDIR/tmp/t1.MYI
141
# Bug#8706 - temporary table with data directory option fails
143
connect (session1,localhost,root,,);
144
connect (session2,localhost,root,,);
147
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
148
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 9 a;
149
# If running test suite with a non standard tmp dir, the "show create table"
150
# will print "DATA_DIRECTORY=". Use replace_result to mask it out
151
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
152
show create table t1;
155
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
156
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 99 a;
157
# If running test suite with a non standard tmp dir, the "show create table"
158
# will print "DATA_DIRECTORY=". Use replace_result to mask it out
159
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
160
show create table t1;
163
create table t1 (a int) engine=myisam select 42 a;
175
--echo End of 4.1 tests
178
# Bug #29325: create table overwrites .MYD file of other table (datadir)
180
SET SESSION keep_files_on_create = TRUE;
181
--write_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD
183
--disable_abort_on_error
184
--error 1,1,ER_TABLE_EXISTS_ERROR
185
CREATE TABLE t1 (a INT) ENGINE MYISAM;
187
--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD;
188
--enable_abort_on_error
189
SET SESSION keep_files_on_create = FALSE;
190
CREATE TABLE t1 (a INT) ENGINE MYISAM;
193
--echo End of 5.0 tests
196
# Bug#32167: another privilege bypass with DATA/INDEX DIRECTORY
198
--replace_result $MYSQLTEST_VARDIR TEST_DIR
200
eval CREATE TABLE t1(a INT)
201
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data/mysql';
202
--replace_result $MYSQLTEST_VARDIR TEST_DIR
204
eval CREATE TABLE t1(a INT)
205
DATA DIRECTORY='$MYSQLTEST_VARDIR/master-data/test';
206
--replace_result $MYSQLTEST_VARDIR TEST_DIR
208
eval CREATE TABLE t1(a INT)
209
DATA DIRECTORY='$MYSQLTEST_VARDIR/master-data/';
210
--replace_result $MYSQLTEST_VARDIR TEST_DIR
212
eval CREATE TABLE t1(a INT)
213
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data';
214
--replace_result $MYSQLTEST_VARDIR TEST_DIR
216
eval CREATE TABLE t1(a INT)
217
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data_var';
218
# BUG#25677 - With --skip-symbolic-links option on, DATA DIRECTORY clause is
221
SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='NO_DIR_IN_CREATE';
222
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
223
eval CREATE TABLE t1(a INT) DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp' INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
225
SET @@SQL_MODE=@OLD_SQL_MODE;
227
--echo End of 5.1 tests