~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
disable_query_log;
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";
5
enable_query_log;
6
-- source include/have_outfile.inc
7
8
#
9
# test of into outfile|dumpfile
10
#
11
12
--disable_warnings
13
drop table if exists t1;
14
--enable_warnings
15
16
create table t1 (`a` blob);
17
insert into t1 values("hello world"),("Hello mars"),(NULL);
18
disable_query_log;
19
eval select * into outfile "../tmp/outfile-test.1" from t1;
20
enable_query_log;
21
select load_file(concat(@tmpdir,"/outfile-test.1"));
22
disable_query_log;
23
eval select * into dumpfile "../tmp/outfile-test.2" from t1 limit 1;
24
enable_query_log;
25
select load_file(concat(@tmpdir,"/outfile-test.2"));
26
disable_query_log;
27
eval select * into dumpfile "../tmp/outfile-test.3" from t1 where a is null;
28
enable_query_log;
29
select load_file(concat(@tmpdir,"/outfile-test.3"));
30
31
# the following should give errors
32
33
disable_query_log;
34
--error 1086
35
eval select * into outfile "../tmp/outfile-test.1" from t1;
36
37
--error 1086
38
eval select * into dumpfile "../tmp/outfile-test.2" from t1;
39
40
--error 1086
41
eval select * into dumpfile "../tmp/outfile-test.3" from t1;
42
enable_query_log;
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
47
drop table t1;
48
49
# Bug#8191
50
disable_query_log;
51
eval select 1 into outfile "../tmp/outfile-test.4";
52
enable_query_log;
53
select load_file(concat(@tmpdir,"/outfile-test.4"));
54
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
55
56
#
57
# Bug #5382: 'explain select into outfile' crashes the server
58
#
59
60
CREATE TABLE t1 (a INT);
61
EXPLAIN 
62
  SELECT *
63
  INTO OUTFILE '/tmp/t1.txt'
64
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
65
  FROM t1;
66
DROP TABLE t1;
67
68
# End of 4.1 tests
69
70
#
71
# Bug#13202  SELECT * INTO OUTFILE ... FROM information_schema.schemata now fails
72
#
73
disable_query_log;
74
eval SELECT * INTO OUTFILE "../tmp/outfile-test.4"
75
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
76
FROM information_schema.schemata LIMIT 0, 5;
77
# enable_query_log;
78
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
79
80
use information_schema;
81
# disable_query_log;
82
eval SELECT * INTO OUTFILE "../tmp/outfile-test.4"
83
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
84
FROM schemata LIMIT 0, 5;
85
enable_query_log;
86
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
87
use test;
88
89
#
90
# Bug#18628 mysql-test-run: security problem
91
#
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
95
--error 1290
96
eval select * into outfile "$MYSQL_TEST_DIR/outfile-test1" from t1;
97
drop table t1;
98
99
#
100
# Bug#28181 Access denied to 'information_schema when
101
# select into out file (regression)
102
#
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);
107
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';
115
116
connection default;
117
grant file on *.* to user_1@localhost;
118
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';
126
127
connection default;
128
--exec rm $MYSQLTEST_VARDIR/tmp/outfile-test.4
129
use test;
130
revoke all privileges on *.* from user_1@localhost;
131
drop user user_1@localhost;
132
drop database mysqltest;
133