symlink.test 7.36 KB
Newer Older
1
--source include/have_symlink.inc
unknown's avatar
unknown committed
2 3
--source include/not_windows.inc

4 5
--disable_warnings
drop table if exists t1,t2,t7,t8,t9;
6
drop database if exists mysqltest;
7 8
--enable_warnings

9 10 11
#
# First create little data to play with
#
12

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
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
# 

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";
unknown's avatar
unknown committed
43

44 45 46 47 48
insert into t9 select * from t1;
check table t9;
optimize table t9;
repair table t9;
alter table t9 add column c int not null;
unknown's avatar
unknown committed
49

50
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
51
show create table t9;
52 53 54 55 56 57 58 59 60 61 62 63 64

# 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!
#

65
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
unknown's avatar
unknown committed
66 67
SHOW CREATE TABLE t9;

68 69 70

# Check that we cannot link over a table from another database.

71
create database mysqltest;
72

unknown's avatar
unknown committed
73
--error 1,1
unknown's avatar
unknown committed
74
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";
75

Alexey Botchkov's avatar
Alexey Botchkov committed
76
# temporarily disabled as it returns different result in the embedded server
Patrick Crews's avatar
Patrick Crews committed
77
# --error ER_WRONG_ARGUMENTS, ER_WRONG_ARGUMENTS
Alexey Botchkov's avatar
Alexey Botchkov committed
78
# 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";
79

unknown's avatar
unknown committed
80
# Should fail becasue the file t9.MYI already exist in 'run'
81
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
Patrick Crews's avatar
Patrick Crews committed
82
--error 1,1,ER_UNKNOWN_ERROR
83
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";
84

unknown's avatar
unknown committed
85
# Should fail becasue the file t9.MYD already exist in 'tmp'
86
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
unknown's avatar
unknown committed
87
--error 1,1
88
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";
89

90
# Check moving table t9 from default database to mysqltest;
91 92
# In this case the symlinks should be removed.

93 94
alter table t9 rename mysqltest.t9;
select count(*) from mysqltest.t9;
95
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
96 97
show create table mysqltest.t9;
drop database mysqltest;
98 99 100 101 102

#
# Test changing data dir (Bug #1662)
#

103
create table t1 (a int not null) engine=myisam;
104
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
105 106
eval alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
107 108
show create table t1;
alter table t1 add b int;
109
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
110 111
eval alter table t1 data directory="$MYSQLTEST_VARDIR/log";
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
112
show create table t1;
113
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
114
eval alter table t1 index directory="$MYSQLTEST_VARDIR/log";
115 116
show create table t1;
drop table t1;
117

118 119 120
#
# BUG#32111 - Security Breach via DATA/INDEX DIRECORY and RENAME TABLE
#
121 122
--write_file $MYSQLTEST_VARDIR/tmp/t1.MYI
EOF
123 124 125

--replace_result $MYSQLTEST_VARDIR TEST_DIR $MYSQLTEST_VARDIR TEST_DIR
--error 1,1
126
eval CREATE TABLE t1(a INT)
127 128 129 130 131 132
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';
unknown's avatar
unknown committed
133
--replace_result $MYSQLTEST_VARDIR TEST_DIR
134
--error 1
135 136 137
RENAME TABLE t2 TO t1;
DROP TABLE t2;
--remove_file $MYSQLTEST_VARDIR/tmp/t1.MYI
138

139 140 141 142 143 144 145
#
# Bug#8706 - temporary table with data directory option fails
#
connect (session1,localhost,root,,);
connect (session2,localhost,root,,);

connection session1;
146
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
unknown's avatar
unknown committed
147
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 9 a;
148 149
# 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
unknown's avatar
unknown committed
150
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
151 152 153
show create table t1;

connection session2;
154
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
unknown's avatar
unknown committed
155
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 99 a;
156 157
# 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
unknown's avatar
unknown committed
158
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
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;

174
--echo End of 4.1 tests
175

176 177 178 179
#
# Bug #29325: create table overwrites .MYD file of other table (datadir)
#
SET SESSION keep_files_on_create = TRUE;
180 181
--write_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD
EOF
182
--disable_abort_on_error
unknown's avatar
unknown committed
183
--error 1,1,ER_TABLE_EXISTS_ERROR
184
CREATE TABLE t1 (a INT) ENGINE MYISAM;
185 186
--error 0,1
--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD;
187
--enable_abort_on_error
188 189 190
SET SESSION keep_files_on_create = FALSE;
CREATE TABLE t1 (a INT) ENGINE MYISAM;
DROP TABLE t1;
191

192
--echo End of 5.0 tests
193 194

#
195 196 197
# Bug#32167: another privilege bypass with DATA/INDEX DIRECTORY
#
--replace_result $MYSQLTEST_VARDIR TEST_DIR
Patrick Crews's avatar
Patrick Crews committed
198
--error ER_WRONG_ARGUMENTS
199 200 201
eval CREATE TABLE t1(a INT)
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data/mysql';
--replace_result $MYSQLTEST_VARDIR TEST_DIR
Patrick Crews's avatar
Patrick Crews committed
202
--error ER_WRONG_ARGUMENTS
203 204 205
eval CREATE TABLE t1(a INT)
DATA DIRECTORY='$MYSQLTEST_VARDIR/master-data/test';
--replace_result $MYSQLTEST_VARDIR TEST_DIR
Patrick Crews's avatar
Patrick Crews committed
206
--error ER_WRONG_ARGUMENTS
207 208 209
eval CREATE TABLE t1(a INT)
DATA DIRECTORY='$MYSQLTEST_VARDIR/master-data/';
--replace_result $MYSQLTEST_VARDIR TEST_DIR
Patrick Crews's avatar
Patrick Crews committed
210
--error ER_WRONG_ARGUMENTS
211 212 213 214 215 216
eval CREATE TABLE t1(a INT)
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data';
--replace_result $MYSQLTEST_VARDIR TEST_DIR
--error 1
eval CREATE TABLE t1(a INT)
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data_var';
217 218 219 220 221 222 223 224 225 226
# BUG#25677 - With --skip-symbolic-links option on, DATA DIRECTORY clause is
#             silently ignored
#
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