symlink.test 5.42 KB
Newer Older
1
--source include/have_symlink.inc
kent@mysql.com's avatar
kent@mysql.com 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
# 

monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
41
disable_query_log;
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";
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
43 44
enable_query_log;

45 46 47 48 49
insert into t9 select * from t1;
check table t9;
optimize table t9;
repair table t9;
alter table t9 add column c int not null;
monty@mysql.com's avatar
monty@mysql.com committed
50

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

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

66
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
monty@mysql.com's avatar
monty@mysql.com committed
67 68
SHOW CREATE TABLE t9;

monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
69
disable_query_log;
70
--error 1103,1103
71
create table t1 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="tmp";
72 73 74

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

75
create database mysqltest;
76

monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
77
--error 1,1
78
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

80
--error 1103,1103
81
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

monty@mysql.com's avatar
monty@mysql.com committed
83
# Should fail becasue the file t9.MYI already exist in 'run'
84
--error 1,1,1105
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";
86

monty@mysql.com's avatar
monty@mysql.com committed
87
# Should fail becasue the file t9.MYD already exist in 'tmp'
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
88
--error 1,1
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";
monty@hundin.mysql.fi's avatar
monty@hundin.mysql.fi committed
90
enable_query_log;
91

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

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

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

105
create table t1 (a int not null) engine=myisam;
106
disable_query_log;
107
eval alter table t1 data directory="$MYSQLTEST_VARDIR/tmp";
108
enable_query_log;
109
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
110 111 112
show create table t1;
alter table t1 add b int;
disable_query_log;
113
eval alter table t1 data directory="$MYSQLTEST_VARDIR/log";
114
enable_query_log;
115
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
116 117
show create table t1;
disable_query_log;
118
eval alter table t1 index directory="$MYSQLTEST_VARDIR/log";
119 120 121
enable_query_log;
show create table t1;
drop table t1;
122 123 124 125 126

#
# Test specifying DATA DIRECTORY that is the same as what would normally
# have been chosen. (Bug #8707)
#
127
disable_query_log;
128
eval create table t1 (i int) data directory = "$MYSQLTEST_VARDIR/master-data/test/";
129
enable_query_log;
130 131
show create table t1;
drop table t1;
132
disable_query_log;
133
eval create table t1 (i int) index directory = "$MYSQLTEST_VARDIR/master-data/test/";
134
enable_query_log;
135 136
show create table t1;
drop table t1;
137

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

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

175
--echo End of 4.1 tests
176 177

--echo End of 5.0 tests