~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/t/outfile.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
# Save the initial number of concurrent sessions
 
9
--source include/count_sessions.inc
 
10
 
 
11
 
 
12
#
 
13
# test of into outfile|dumpfile
 
14
#
 
15
 
 
16
--disable_warnings
 
17
drop table if exists t1;
 
18
--enable_warnings
 
19
 
 
20
create table t1 (`a` blob);
 
21
insert into t1 values("hello world"),("Hello mars"),(NULL);
 
22
disable_query_log;
 
23
eval select * into outfile "../../tmp/outfile-test.1" from t1;
 
24
enable_query_log;
 
25
select load_file(concat(@tmpdir,"/outfile-test.1"));
 
26
disable_query_log;
 
27
eval select * into dumpfile "../../tmp/outfile-test.2" from t1 limit 1;
 
28
enable_query_log;
 
29
select load_file(concat(@tmpdir,"/outfile-test.2"));
 
30
disable_query_log;
 
31
eval select * into dumpfile "../../tmp/outfile-test.3" from t1 where a is null;
 
32
enable_query_log;
 
33
select load_file(concat(@tmpdir,"/outfile-test.3"));
 
34
 
 
35
# the following should give errors
 
36
 
 
37
disable_query_log;
 
38
--error ER_FILE_EXISTS_ERROR
 
39
eval select * into outfile "../../tmp/outfile-test.1" from t1;
 
40
 
 
41
--error ER_FILE_EXISTS_ERROR
 
42
eval select * into dumpfile "../../tmp/outfile-test.2" from t1;
 
43
 
 
44
--error ER_FILE_EXISTS_ERROR
 
45
eval select * into dumpfile "../../tmp/outfile-test.3" from t1;
 
46
enable_query_log;
 
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
 
51
drop table t1;
 
52
 
 
53
# Bug#8191 SELECT INTO OUTFILE insists on FROM clause
 
54
disable_query_log;
 
55
eval select 1 into outfile "../../tmp/outfile-test.4";
 
56
enable_query_log;
 
57
select load_file(concat(@tmpdir,"/outfile-test.4"));
 
58
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
 
59
 
 
60
#
 
61
# Bug#5382 'explain select into outfile' crashes the server
 
62
#
 
63
 
 
64
CREATE TABLE t1 (a INT);
 
65
EXPLAIN
 
66
  SELECT *
 
67
  INTO OUTFILE '/tmp/t1.txt'
 
68
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
 
69
  FROM t1;
 
70
DROP TABLE t1;
 
71
 
 
72
# End of 4.1 tests
 
73
 
 
74
#
 
75
# Bug#13202 SELECT * INTO OUTFILE ... FROM information_schema.schemata now fails
 
76
#
 
77
disable_query_log;
 
78
eval SELECT * INTO OUTFILE "../../tmp/outfile-test.4"
 
79
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
 
80
FROM information_schema.schemata LIMIT 0, 5;
 
81
# enable_query_log;
 
82
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
 
83
 
 
84
use information_schema;
 
85
# disable_query_log;
 
86
eval SELECT * INTO OUTFILE "../../tmp/outfile-test.4"
 
87
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
 
88
FROM schemata LIMIT 0, 5;
 
89
enable_query_log;
 
90
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
 
91
use test;
 
92
 
 
93
#
 
94
# Bug#18628 mysql-test-run: security problem
 
95
#
 
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;
 
101
drop table t1;
 
102
 
 
103
#
 
104
# Bug#28181 Access denied to 'information_schema when
 
105
# select into out file (regression)
 
106
#
 
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);
 
111
 
 
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';
 
119
 
 
120
connection default;
 
121
disconnect con28181_1;
 
122
grant file on *.* to user_1@localhost;
 
123
 
 
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';
 
131
 
 
132
connection default;
 
133
disconnect con28181_2;
 
134
--remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4
 
135
use test;
 
136
revoke all privileges on *.* from user_1@localhost;
 
137
drop user user_1@localhost;
 
138
drop database mysqltest;
 
139
 
 
140
# Wait till we reached the initial number of concurrent sessions
 
141
--source include/wait_until_count_sessions.inc