symlink.test 5.24 KB
Newer Older
1
-- require r/have_symlink.require
unknown's avatar
unknown committed
2
disable_query_log;
3
show variables like "have_symlink";
unknown's avatar
unknown committed
4
enable_query_log;
5

unknown's avatar
unknown committed
6 7
--source include/not_windows.inc

8 9
--disable_warnings
drop table if exists t1,t2,t7,t8,t9;
10
drop database if exists mysqltest;
11 12
--enable_warnings

13 14 15
#
# First create little data to play with
#
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 41 42 43 44
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
# 

unknown's avatar
unknown committed
45
disable_query_log;
unknown's avatar
unknown committed
46
eval create table t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQL_TEST_DIR/var/tmp" index directory="$MYSQL_TEST_DIR/var/run";
unknown's avatar
unknown committed
47 48
enable_query_log;

49 50 51 52 53
insert into t9 select * from t1;
check table t9;
optimize table t9;
repair table t9;
alter table t9 add column c int not null;
54
--replace_result $MYSQL_TEST_DIR TEST_DIR
55 56 57 58 59 60 61 62 63 64 65 66 67 68
show create table t9;

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

unknown's avatar
unknown committed
69
disable_query_log;
unknown's avatar
unknown committed
70
--error 1103,1103
unknown's avatar
unknown committed
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

unknown's avatar
unknown committed
77
--error 1,1
unknown's avatar
unknown committed
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

unknown's avatar
unknown committed
80
--error 1103,1103
unknown's avatar
unknown committed
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

unknown's avatar
unknown committed
83
--error 1,1
unknown's avatar
unknown committed
84
eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam index directory="$MYSQL_TEST_DIR/var/run";
85

unknown's avatar
unknown committed
86
--error 1,1
unknown's avatar
unknown committed
87
eval create table mysqltest.t9 (a int not null auto_increment, b char(16) not null, primary key (a)) engine=myisam data directory="$MYSQL_TEST_DIR/var/tmp";
unknown's avatar
unknown committed
88
enable_query_log;
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 $MYSQL_TEST_DIR TEST_DIR
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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
disable_query_log;
eval alter table t1 data directory="$MYSQL_TEST_DIR/var/tmp";
enable_query_log;
--replace_result $MYSQL_TEST_DIR TEST_DIR
show create table t1;
alter table t1 add b int;
disable_query_log;
eval alter table t1 data directory="$MYSQL_TEST_DIR/var/log";
enable_query_log;
--replace_result $MYSQL_TEST_DIR TEST_DIR
show create table t1;
disable_query_log;
eval alter table t1 index directory="$MYSQL_TEST_DIR/var/log";
enable_query_log;
show create table t1;
drop table t1;
120 121 122 123 124

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

136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
#
# Bug#8706 - temporary table with data directory option fails
#
connect (session1,localhost,root,,);
connect (session2,localhost,root,,);

connection session1;
disable_query_log;
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 9 a;
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
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
show create table t1;

connection session2;
disable_query_log;
eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 99 a;
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
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
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;

173
# End of 4.1 tests