~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
#
2
# Some simple test of load data
3
#
4
5
--disable_warnings
6
drop table if exists t1, t2;
7
--enable_warnings
8
9
create table t1 (a date, b date, c date not null, d date);
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
10
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
11
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata1.dat' into table t1 fields terminated by ',';
12
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
13
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
1 by brian
clean slate
14
SELECT * from t1;
15
truncate table t1;
16
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
17
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
18
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
1 by brian
clean slate
19
SELECT * from t1;
20
drop table t1;
21
22
create table t1 (a text, b text);
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
23
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
24
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
1 by brian
clean slate
25
select concat('|',a,'|'), concat('|',b,'|') from t1;
26
drop table t1;
27
28
create table t1 (a int, b char(10));
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
29
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
30
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
1 by brian
clean slate
31
select * from t1;
32
truncate table t1;
33
34
# The empty line last comes from the end line field in the file
35
select * from t1;
36
drop table t1;
37
38
#
39
# Bug #11203: LOAD DATA does not accept same characters for ESCAPED and
40
# ENCLOSED
41
#
42
create table t1 (a varchar(20), b varchar(20));
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
43
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
44
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b);
1 by brian
clean slate
45
select * from t1;
46
drop table t1;
47
48
#
49
# Bug #29294 SELECT INTO OUTFILE/LOAD DATA INFILE with special
50
# characters in the FIELDS ENCLOSED BY clause
51
#
52
53
CREATE TABLE t1 (
54
  id INT AUTO_INCREMENT PRIMARY KEY,
55
  c1 VARCHAR(255)
56
);
57
58
CREATE TABLE t2 (
59
  id INT,
60
  c2 VARCHAR(255)
61
);
62
63
INSERT INTO t1 (c1) VALUES
64
  ('r'),   ('rr'),   ('rrr'),   ('rrrr'),
65
  ('.r'),  ('.rr'),  ('.rrr'),  ('.rrrr'),
66
  ('r.'),  ('rr.'),  ('rrr.'),  ('rrrr.'),
67
  ('.r.'), ('.rr.'), ('.rrr.'), ('.rrrr.');
68
SELECT * FROM t1;
69
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
70
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
71
eval SELECT * INTO OUTFILE '$DRIZZLETEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY 'r' FROM t1;
72
cat_file $DRIZZLETEST_VARDIR/tmp/t1;
1 by brian
clean slate
73
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
74
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
75
eval LOAD DATA INFILE '$DRIZZLETEST_VARDIR/tmp/t1' INTO TABLE t2 FIELDS ENCLOSED BY 'r';
1 by brian
clean slate
76
SELECT t1.id, c1, c2 FROM t1 LEFT  JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
77
SELECT t1.id, c1, c2 FROM t1 RIGHT JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
78
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
79
remove_file $DRIZZLETEST_VARDIR/tmp/t1;
1 by brian
clean slate
80
DROP TABLE t1,t2;
81
82
# End of 4.1 tests
83
84
#
85
# Let us test extended LOAD DATA features
86
#
87
create table t1 (a int default 100, b int, c varchar(60));
88
# we can do something like this
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
89
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
90
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
1 by brian
clean slate
91
select * from t1;
92
truncate table t1;
93
# we can use filled fields in expressions 
94
# we also assigning NULL value to field with non-NULL default here
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
95
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
96
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a);
1 by brian
clean slate
97
select * from t1;
98
truncate table t1;
99
# we even can use variables in set clause, and missed columns will be set
100
# with default values
101
set @c:=123;
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
102
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
103
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b);
1 by brian
clean slate
104
select * from t1;
105
# let us test side-effect of such load
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
106
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
107
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b);
1 by brian
clean slate
108
select * from t1;
109
select @a, @b;
110
truncate table t1;
111
# now going to test fixed field-row file format
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
112
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
113
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow";
1 by brian
clean slate
114
select * from t1;
115
truncate table t1;
116
# this also should work
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
117
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
118
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c=concat(a,"+",b,"+",@c,"+",b,"+",if(c is null,"NIL",c));
1 by brian
clean slate
119
select * from t1;
120
# and this should bark
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
121
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
122
--error ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR 
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
123
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
1 by brian
clean slate
124
125
# Now let us test LOAD DATA with subselect
126
create table t2 (num int primary key, str varchar(10));
127
insert into t2 values (10,'Ten'), (15,'Fifteen');
128
truncate table t1;
1878.7.1 by patrick crews
Updated tests to use variable vardir rather than a hard-coded one
129
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
130
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n);
1 by brian
clean slate
131
select * from t1;
132
133
#
134
# Bug#18628 mysql-test-run: security problem
135
#
136
# It should not be possible to load from a file outside of vardir
137
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
138
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
1 by brian
clean slate
139
show variables like "secure_file_pri%";
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
140
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
1 by brian
clean slate
141
select @@secure_file_priv;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
142
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
1 by brian
clean slate
143
set @@secure_file_priv= 0;
144
145
# Test "load data"
146
truncate table t1;
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
147
--replace_result $DRIZZLE_TEST_DIR DRIZZLE_TEST_DIR
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
148
--error ER_OPTION_PREVENTS_STATEMENT
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
149
eval load data infile '$DRIZZLE_TEST_DIR/t/loaddata.test' into table t1;
1 by brian
clean slate
150
select * from t1;
151
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
152
--replace_result $DRIZZLE_TEST_DIR DRIZZLE_TEST_DIR
1813.2.11 by Monty Taylor
Throw an error on load_file() from outside the secure_file_priv locaiton.
153
--error ER_OPTION_PREVENTS_STATEMENT
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
154
eval select load_file("$DRIZZLE_TEST_DIR/t/loaddata.test");
1 by brian
clean slate
155
156
# cleanup
157
drop table t1, t2;
158
159
#
160
# Bug#27670: LOAD DATA does not set CURRENT_TIMESTAMP default value for a
161
#            TIMESTAMP field when no value has been provided.
162
#
163
create table t1(f1 int, f2 timestamp not null default current_timestamp);
164
create table t2(f1 int);
165
insert into t2 values(1),(2);
166
disable_query_log;
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
167
eval select * into outfile '$DRIZZLETEST_VARDIR/tmp/t2' from t2;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
168
--error ER_WARN_TOO_FEW_RECORDS
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
169
eval load data infile '$DRIZZLETEST_VARDIR/tmp/t2' into table t1;
1 by brian
clean slate
170
enable_query_log;
873.1.8 by Jay Pipes
Fixes Arg_comparator::can_compare_as_dates to never, ever allow bad
171
select f1 from t1 where f2 IS NOT NULL order by f1;
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
172
remove_file $DRIZZLETEST_VARDIR/tmp/t2;
1 by brian
clean slate
173
delete from t1;
174
disable_query_log;
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
175
eval SELECT * INTO OUTFILE '$DRIZZLETEST_VARDIR/tmp/t2'
1 by brian
clean slate
176
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'
177
FROM t2;
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
178
--error ER_WARN_TOO_FEW_RECORDS
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
179
eval load data infile '$DRIZZLETEST_VARDIR/tmp/t2' into table t1
1 by brian
clean slate
180
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n';
181
enable_query_log;
873.1.8 by Jay Pipes
Fixes Arg_comparator::can_compare_as_dates to never, ever allow bad
182
select f1 from t1 where f2 IS NOT NULL order by f1;
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
183
remove_file $DRIZZLETEST_VARDIR/tmp/t2;
1 by brian
clean slate
184
drop table t1,t2;
185
186
#
187
# Bug#29442: SELECT INTO OUTFILE FIELDS ENCLOSED BY digit, minus sign etc
188
#            corrupts non-string fields containing this character.
189
#
190
191
CREATE TABLE t1 (c1 INT, c2 TIMESTAMP, c3 REAL, c4 DOUBLE);
192
193
INSERT INTO t1 (c1, c2, c3, c4) VALUES (10, '1970-02-01 01:02:03', 1.1E-100, 1.1E+100);
194
SELECT * FROM t1;
195
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
196
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
197
eval SELECT * INTO OUTFILE '$DRIZZLETEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY '-' FROM t1;
198
#cat_file $DRIZZLETEST_VARDIR/tmp/t1;
1 by brian
clean slate
199
echo EOF;
200
201
TRUNCATE t1;
202
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
203
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
204
eval LOAD DATA INFILE '$DRIZZLETEST_VARDIR/tmp/t1' INTO TABLE t1 FIELDS ENCLOSED BY '-';
1 by brian
clean slate
205
SELECT * FROM t1;
206
1819.2.2 by patrick crews
Adjustments to tests to deal with the name changes. Also fixed passed/failed reporting post-run in test-run.pl
207
remove_file $DRIZZLETEST_VARDIR/tmp/t1;
1 by brian
clean slate
208
DROP TABLE t1;