~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/t/loaddata.test

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
--enable_warnings
8
8
 
9
9
create table t1 (a date, b date, c date not null, d date);
10
 
load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',';
11
 
load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
 
10
load data infile '../../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',';
 
11
load data infile '../../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
12
12
SELECT * from t1;
13
13
truncate table t1;
14
14
 
15
 
load data infile '../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
 
15
load data infile '../../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
16
16
SELECT * from t1;
17
17
drop table t1;
18
18
 
19
19
create table t1 (a text, b text);
20
 
load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
 
20
load data infile '../../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
21
21
select concat('|',a,'|'), concat('|',b,'|') from t1;
22
22
drop table t1;
23
23
 
24
24
create table t1 (a int, b char(10));
25
 
load data infile '../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
 
25
load data infile '../../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
26
26
select * from t1;
27
27
truncate table t1;
28
28
 
35
35
# ENCLOSED
36
36
#
37
37
create table t1 (a varchar(20), b varchar(20));
38
 
load data infile '../std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b);
 
38
load data infile '../../std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b);
39
39
select * from t1;
40
40
drop table t1;
41
41
 
80
80
#
81
81
create table t1 (a int default 100, b int, c varchar(60));
82
82
# we can do something like this
83
 
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
 
83
load data infile '../../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
84
84
select * from t1;
85
85
truncate table t1;
86
86
# we can use filled fields in expressions 
87
87
# we also assigning NULL value to field with non-NULL default here
88
 
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a);
 
88
load data infile '../../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a);
89
89
select * from t1;
90
90
truncate table t1;
91
91
# we even can use variables in set clause, and missed columns will be set
92
92
# with default values
93
93
set @c:=123;
94
 
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b);
 
94
load data infile '../../std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b);
95
95
select * from t1;
96
96
# let us test side-effect of such load
97
 
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b);
 
97
load data infile '../../std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b);
98
98
select * from t1;
99
99
select @a, @b;
100
100
truncate table t1;
101
101
# now going to test fixed field-row file format
102
 
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow";
 
102
load data infile '../../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow";
103
103
select * from t1;
104
104
truncate table t1;
105
105
# this also should work
106
 
load data infile '../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));
 
106
load data infile '../../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));
107
107
select * from t1;
108
108
# and this should bark
109
 
--error 1409 
110
 
load data infile '../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
 
109
--error ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR 
 
110
load data infile '../../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
111
111
 
112
112
# Now let us test LOAD DATA with subselect
113
113
create table t2 (num int primary key, str varchar(10));
114
114
insert into t2 values (10,'Ten'), (15,'Fifteen');
115
115
truncate table t1;
116
 
load data infile '../std_data_ln/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n);
 
116
load data infile '../../std_data_ln/rpl_loaddata.dat' into table t1 (@dummy,@n) set a= @n, c= (select str from t2 where num=@n);
117
117
select * from t1;
118
118
 
119
119
#
125
125
show variables like "secure_file_pri%";
126
126
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
127
127
select @@secure_file_priv;
128
 
--error 1238
 
128
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
129
129
set @@secure_file_priv= 0;
130
130
 
131
131
# Test "load data"
132
132
truncate table t1;
133
133
--replace_result $DRIZZLE_TEST_DIR DRIZZLE_TEST_DIR
134
 
--error 1290
 
134
--error ER_OPTION_PREVENTS_STATEMENT
135
135
eval load data infile '$DRIZZLE_TEST_DIR/t/loaddata.test' into table t1;
136
136
select * from t1;
137
137
 
151
151
insert into t2 values(1),(2);
152
152
disable_query_log;
153
153
eval select * into outfile '$MYSQLTEST_VARDIR/tmp/t2' from t2;
154
 
--error 1261
 
154
--error ER_WARN_TOO_FEW_RECORDS
155
155
eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1;
156
156
enable_query_log;
157
157
select f1 from t1 where f2 IS NOT NULL order by f1;
161
161
eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t2'
162
162
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'
163
163
FROM t2;
164
 
--error 1261
 
164
--error ER_WARN_TOO_FEW_RECORDS
165
165
eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' into table t1
166
166
FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n';
167
167
enable_query_log;