1
by brian
clean slate |
1 |
--source include/have_symlink.inc
|
2 |
--source include/not_windows.inc
|
|
3 |
||
4 |
--disable_warnings
|
|
5 |
drop table if exists t1,t2,t7,t8,t9; |
|
6 |
drop database if exists mysqltest; |
|
7 |
--enable_warnings
|
|
8 |
||
9 |
#
|
|
10 |
# First create little data to play with |
|
11 |
#
|
|
12 |
||
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; |
|
34 |
drop table t2; |
|
35 |
||
36 |
#
|
|
37 |
# Start the test |
|
38 |
# We use t9 here to not crash with tables generated by the backup test |
|
39 |
#
|
|
40 |
||
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"; |
|
43 |
||
44 |
insert into t9 select * from t1; |
|
45 |
check table t9; |
|
46 |
optimize table t9; |
|
47 |
repair table t9; |
|
48 |
alter table t9 add column c int not null; |
|
49 |
||
50 |
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
51 |
show create table t9; |
|
52 |
||
53 |
# Test renames |
|
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 |
|
58 |
drop table t1; |
|
59 |
||
60 |
#
|
|
61 |
# Test error handling |
|
62 |
# Note that we are using the above table t9 here! |
|
63 |
#
|
|
64 |
||
65 |
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
66 |
SHOW CREATE TABLE t9; |
|
67 |
||
68 |
--error 1103,1103
|
|
69 |
create table t1 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="tmp"; |
|
70 |
||
71 |
# Check that we cannot link over a table from another database. |
|
72 |
||
73 |
create database mysqltest; |
|
74 |
||
75 |
--error 1,1
|
|
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"; |
|
77 |
||
78 |
--error 1103,1103
|
|
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"; |
|
80 |
||
81 |
# Should fail becasue the file t9.MYI already exist in 'run' |
|
82 |
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
|
83 |
--error 1,1,1105
|
|
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"; |
|
85 |
||
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"; |
|
90 |
||
91 |
# Check moving table t9 from default database to mysqltest; |
|
92 |
# In this case the symlinks should be removed. |
|
93 |
||
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; |
|
99 |
||
100 |
#
|
|
101 |
# Test changing data dir (Bug #1662) |
|
102 |
#
|
|
103 |
||
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; |
|
117 |
drop table t1; |
|
118 |
||
119 |
#
|
|
120 |
# BUG#32111 - Security Breach via DATA/INDEX DIRECORY and RENAME TABLE |
|
121 |
#
|
|
122 |
--write_file $MYSQLTEST_VARDIR/tmp/t1.MYI
|
|
123 |
EOF
|
|
124 |
||
125 |
--replace_result $MYSQLTEST_VARDIR TEST_DIR $MYSQLTEST_VARDIR TEST_DIR
|
|
126 |
--error 1,1
|
|
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
|
|
135 |
--error 1
|
|
136 |
RENAME TABLE t2 TO t1; |
|
137 |
DROP TABLE t2; |
|
138 |
--remove_file $MYSQLTEST_VARDIR/tmp/t1.MYI
|
|
139 |
||
140 |
#
|
|
141 |
# Bug#8706 - temporary table with data directory option fails |
|
142 |
#
|
|
143 |
connect (session1,localhost,root,,); |
|
144 |
connect (session2,localhost,root,,); |
|
145 |
||
146 |
connection session1; |
|
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; |
|
153 |
||
154 |
connection session2; |
|
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; |
|
161 |
||
162 |
connection default; |
|
163 |
create table t1 (a int) engine=myisam select 42 a; |
|
164 |
||
165 |
connection session1; |
|
166 |
select * from t1; |
|
167 |
disconnect session1; |
|
168 |
connection session2; |
|
169 |
select * from t1; |
|
170 |
disconnect session2; |
|
171 |
connection default; |
|
172 |
select * from t1; |
|
173 |
drop table t1; |
|
174 |
||
175 |
--echo End of 4.1 tests
|
|
176 |
||
177 |
#
|
|
178 |
# Bug #29325: create table overwrites .MYD file of other table (datadir) |
|
179 |
#
|
|
180 |
SET SESSION keep_files_on_create = TRUE; |
|
181 |
--write_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD
|
|
182 |
EOF
|
|
183 |
--disable_abort_on_error
|
|
184 |
--error 1,1,ER_TABLE_EXISTS_ERROR
|
|
185 |
CREATE TABLE t1 (a INT) ENGINE MYISAM; |
|
186 |
--error 0,1
|
|
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; |
|
191 |
DROP TABLE t1; |
|
192 |
||
193 |
--echo End of 5.0 tests
|
|
194 |
||
195 |
#
|
|
196 |
# Bug#32167: another privilege bypass with DATA/INDEX DIRECTORY |
|
197 |
#
|
|
198 |
--replace_result $MYSQLTEST_VARDIR TEST_DIR
|
|
199 |
--error 1210
|
|
200 |
eval CREATE TABLE t1(a INT) |
|
201 |
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data/mysql'; |
|
202 |
--replace_result $MYSQLTEST_VARDIR TEST_DIR
|
|
203 |
--error 1210
|
|
204 |
eval CREATE TABLE t1(a INT) |
|
205 |
DATA DIRECTORY='$MYSQLTEST_VARDIR/master-data/test'; |
|
206 |
--replace_result $MYSQLTEST_VARDIR TEST_DIR
|
|
207 |
--error 1210
|
|
208 |
eval CREATE TABLE t1(a INT) |
|
209 |
DATA DIRECTORY='$MYSQLTEST_VARDIR/master-data/'; |
|
210 |
--replace_result $MYSQLTEST_VARDIR TEST_DIR
|
|
211 |
--error 1210
|
|
212 |
eval CREATE TABLE t1(a INT) |
|
213 |
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data'; |
|
214 |
--replace_result $MYSQLTEST_VARDIR TEST_DIR
|
|
215 |
--error 1
|
|
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 |
|
219 |
# silently ignored |
|
220 |
#
|
|
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'; |
|
224 |
DROP TABLE t1; |
|
225 |
SET @@SQL_MODE=@OLD_SQL_MODE; |
|
226 |
||
227 |
--echo End of 5.1 tests
|