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
9
# test of into outfile|dumpfile
13
drop table if exists t1;
16
create table t1 (`a` blob);
17
insert into t1 values("hello world"),("Hello mars"),(NULL);
19
eval select * into outfile "../tmp/outfile-test.1" from t1;
21
select load_file(concat(@tmpdir,"/outfile-test.1"));
23
eval select * into dumpfile "../tmp/outfile-test.2" from t1 limit 1;
25
select load_file(concat(@tmpdir,"/outfile-test.2"));
27
eval select * into dumpfile "../tmp/outfile-test.3" from t1 where a is null;
29
select load_file(concat(@tmpdir,"/outfile-test.3"));
31
# the following should give errors
35
eval select * into outfile "../tmp/outfile-test.1" from t1;
38
eval select * into dumpfile "../tmp/outfile-test.2" from t1;
41
eval select * into dumpfile "../tmp/outfile-test.3" from t1;
43
select load_file(concat(@tmpdir,"/outfile-test.not-exist"));
44
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.1
45
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.2
46
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.3
51
eval select 1 into outfile "../tmp/outfile-test.4";
53
select load_file(concat(@tmpdir,"/outfile-test.4"));
54
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
57
# Bug #5382: 'explain select into outfile' crashes the server
60
CREATE TABLE t1 (a INT);
63
INTO OUTFILE '/tmp/t1.txt'
64
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
71
# Bug#13202 SELECT * INTO OUTFILE ... FROM information_schema.schemata now fails
74
eval SELECT * INTO OUTFILE "../tmp/outfile-test.4"
75
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
76
FROM information_schema.schemata LIMIT 0, 5;
78
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
80
use information_schema;
82
eval SELECT * INTO OUTFILE "../tmp/outfile-test.4"
83
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
84
FROM schemata LIMIT 0, 5;
86
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
90
# Bug#18628 mysql-test-run: security problem
92
# It should not be possible to write to a file outside of vardir
93
create table t1(a int);
94
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
96
eval select * into outfile "$MYSQL_TEST_DIR/outfile-test1" from t1;
100
# Bug#28181 Access denied to 'information_schema when
101
# select into out file (regression)
103
create database mysqltest;
104
create user user_1@localhost;
105
grant all on mysqltest.* to user_1@localhost;
106
connect (con28181_1,localhost,user_1,,mysqltest);
108
--error ER_ACCESS_DENIED_ERROR
109
eval select schema_name
110
into outfile "../tmp/outfile-test.4"
111
fields terminated by ',' optionally enclosed by '"'
112
lines terminated by '\n'
113
from information_schema.schemata
114
where schema_name like 'mysqltest';
117
grant file on *.* to user_1@localhost;
119
connect (con28181_2,localhost,user_1,,mysqltest);
120
eval select schema_name
121
into outfile "../tmp/outfile-test.4"
122
fields terminated by ',' optionally enclosed by '"'
123
lines terminated by '\n'
124
from information_schema.schemata
125
where schema_name like 'mysqltest';
128
--exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.4
130
revoke all privileges on *.* from user_1@localhost;
131
drop user user_1@localhost;
132
drop database mysqltest;