2
-- source include/test_outfile.inc
3
# Server are started in "var/master-data", so "../../tmp" will be "var/tmp"
4
eval set @tmpdir="../../tmp";
6
-- source include/have_outfile.inc
8
# Save the initial number of concurrent sessions
9
--source include/count_sessions.inc
13
# test of into outfile|dumpfile
17
drop table if exists t1;
20
create table t1 (`a` blob);
21
insert into t1 values("hello world"),("Hello mars"),(NULL);
23
eval select * into outfile "../../tmp/outfile-test.1" from t1;
25
select load_file(concat(@tmpdir,"/outfile-test.1"));
27
eval select * into dumpfile "../../tmp/outfile-test.2" from t1 limit 1;
29
select load_file(concat(@tmpdir,"/outfile-test.2"));
31
eval select * into dumpfile "../../tmp/outfile-test.3" from t1 where a is null;
33
select load_file(concat(@tmpdir,"/outfile-test.3"));
35
# the following should give errors
38
--error ER_FILE_EXISTS_ERROR
39
eval select * into outfile "../../tmp/outfile-test.1" from t1;
41
--error ER_FILE_EXISTS_ERROR
42
eval select * into dumpfile "../../tmp/outfile-test.2" from t1;
44
--error ER_FILE_EXISTS_ERROR
45
eval select * into dumpfile "../../tmp/outfile-test.3" from t1;
47
select load_file(concat(@tmpdir,"/outfile-test.not-exist"));
48
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.1
49
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.2
50
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.3
53
# Bug#8191 SELECT INTO OUTFILE insists on FROM clause
55
eval select 1 into outfile "../../tmp/outfile-test.4";
57
select load_file(concat(@tmpdir,"/outfile-test.4"));
58
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
61
# Bug#5382 'explain select into outfile' crashes the server
64
CREATE TABLE t1 (a INT);
67
INTO OUTFILE '/tmp/t1.txt'
68
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
75
# Bug#13202 SELECT * INTO OUTFILE ... FROM information_schema.schemata now fails
78
eval SELECT * INTO OUTFILE "../../tmp/outfile-test.4"
79
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
80
FROM information_schema.schemata LIMIT 0, 5;
82
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
84
use information_schema;
86
eval SELECT * INTO OUTFILE "../../tmp/outfile-test.4"
87
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
88
FROM schemata LIMIT 0, 5;
90
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
94
# Bug#18628 mysql-test-run: security problem
96
# It should not be possible to write to a file outside of vardir
97
create table t1(a int);
98
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
99
--error ER_OPTION_PREVENTS_STATEMENT
100
eval select * into outfile "$MYSQL_TEST_DIR/outfile-test1" from t1;
104
# Bug#28181 Access denied to 'information_schema when
105
# select into out file (regression)
107
create database mysqltest;
108
create user user_1@localhost;
109
grant all on mysqltest.* to user_1@localhost;
110
connect (con28181_1,localhost,user_1,,mysqltest);
112
--error ER_DBACCESS_DENIED_ERROR
113
eval select schema_name
114
into outfile "../../tmp/outfile-test.4"
115
fields terminated by ',' optionally enclosed by '"'
116
lines terminated by '\n'
117
from information_schema.schemata
118
where schema_name like 'mysqltest';
121
disconnect con28181_1;
122
grant file on *.* to user_1@localhost;
124
connect (con28181_2,localhost,user_1,,mysqltest);
125
eval select schema_name
126
into outfile "../../tmp/outfile-test.4"
127
fields terminated by ',' optionally enclosed by '"'
128
lines terminated by '\n'
129
from information_schema.schemata
130
where schema_name like 'mysqltest';
133
disconnect con28181_2;
134
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
136
revoke all privileges on *.* from user_1@localhost;
137
drop user user_1@localhost;
138
drop database mysqltest;
140
# Wait till we reached the initial number of concurrent sessions
141
--source include/wait_until_count_sessions.inc