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;
47
SET GLOBAL myisam_sort_buffer_size=1024;
49
alter table t9 add column c int not null;
51
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
55
alter table t9 rename t8, add column d int not null;
56
alter table t8 rename t7;
57
rename table t7 to t9;
58
# Drop old t1 table, keep t9
63
# Note that we are using the above table t9 here!
66
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
70
create table t1 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="tmp";
72
# Check that we cannot link over a table from another database.
74
create database mysqltest;
77
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";
80
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";
82
# Should fail becasue the file t9.MYI already exist in 'run'
83
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
85
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";
87
# Should fail becasue the file t9.MYD already exist in 'tmp'
88
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
89
--error 1,1,ER_TABLE_EXISTS_ERROR
90
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";
92
# Check moving table t9 from default database to mysqltest;
93
# In this case the symlinks should be removed.
95
alter table t9 rename mysqltest.t9;
96
select count(*) from mysqltest.t9;
97
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
98
show create table mysqltest.t9;
99
drop database mysqltest;
102
# Test changing data dir (Bug #1662)
105
create table t1 (a int not null) engine=myisam;
106
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
107
eval alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
108
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
109
show create table t1;
110
alter table t1 add b int;
111
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
112
eval alter table t1 data directory="$MYSQLTEST_VARDIR/log";
113
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
114
show create table t1;
115
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
116
eval alter table t1 index directory="$MYSQLTEST_VARDIR/log";
117
show create table t1;
121
# BUG#32111 - Security Breach via DATA/INDEX DIRECTORY and RENAME TABLE
123
--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' ENGINE=MyISAM;
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' ENGINE=MyISAM;
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';
215
--replace_result $MYSQLTEST_VARDIR TEST_DIR
216
# Bug 311013 - specifying not existent directory does not give an error
218
#eval CREATE TABLE t1(a INT)
219
#INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data_var';
221
# BUG#25677 - With --skip-symbolic-links option on, DATA DIRECTORY clause is
224
# sql_mode not supported in Drizzle
225
#SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='NO_DIR_IN_CREATE';
226
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
227
eval CREATE TABLE t1(a INT) DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp' INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
229
#SET @@SQL_MODE=@OLD_SQL_MODE;
231
--echo End of 5.1 tests
232
SET GLOBAL myisam_sort_buffer_size=DEFAULT;