~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/loaddata.test

  • Committer: Monty Taylor
  • Date: 2010-10-21 23:10:12 UTC
  • mto: (1879.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1880.
  • Revision ID: mordred@inaugust.com-20101021231012-uhsebiqo23xi0ygy
Updated AUTHORS list with everyone from bzr logs.

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
 
--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;
 
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;
14
12
SELECT * from t1;
15
13
truncate table t1;
16
14
 
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);
 
15
load data infile '../../std_data_ln/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
19
16
SELECT * from t1;
20
17
drop table t1;
21
18
 
22
19
create table t1 (a text, b text);
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 '''';
 
20
load data infile '../../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
25
21
select concat('|',a,'|'), concat('|',b,'|') from t1;
26
22
drop table t1;
27
23
 
28
24
create table t1 (a int, b char(10));
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;
 
25
load data infile '../../std_data_ln/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines;
31
26
select * from t1;
32
27
truncate table t1;
33
28
 
40
35
# ENCLOSED
41
36
#
42
37
create table t1 (a varchar(20), b varchar(20));
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);
 
38
load data infile '../../std_data_ln/loaddata_dq.dat' into table t1 fields terminated by ',' enclosed by '"' escaped by '"' (a,b);
45
39
select * from t1;
46
40
drop table t1;
47
41
 
86
80
#
87
81
create table t1 (a int default 100, b int, c varchar(60));
88
82
# we can do something like this
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);
 
83
load data infile '../../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set b=@b+10, c=concat("b=",@b);
91
84
select * from t1;
92
85
truncate table t1;
93
86
# we can use filled fields in expressions 
94
87
# we also assigning NULL value to field with non-NULL default here
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);
 
88
load data infile '../../std_data_ln/rpl_loaddata.dat' into table t1 (a, @b) set c= if(a is null,"oops",a);
97
89
select * from t1;
98
90
truncate table t1;
99
91
# we even can use variables in set clause, and missed columns will be set
100
92
# with default values
101
93
set @c:=123;
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);
 
94
load data infile '../../std_data_ln/rpl_loaddata.dat' into table t1 (@a, b) set c= if(@a is null,@c,b);
104
95
select * from t1;
105
96
# let us test side-effect of such load
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);
 
97
load data infile '../../std_data_ln/rpl_loaddata.dat' into table t1 (@a, @b);
108
98
select * from t1;
109
99
select @a, @b;
110
100
truncate table t1;
111
101
# now going to test fixed field-row file format
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";
 
102
load data infile '../../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, b) set c="Wow";
114
103
select * from t1;
115
104
truncate table t1;
116
105
# this also should work
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));
 
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));
119
107
select * from t1;
120
108
# and this should bark
121
 
--replace_result $DRIZZLETEST_VARDIR DRIZZLETEST_VARDIR
122
109
--error ER_LOAD_FROM_FIXED_SIZE_ROWS_TO_VAR 
123
 
eval load data infile '$DRIZZLETEST_VARDIR/std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
 
110
load data infile '../../std_data_ln/loaddata5.dat' into table t1 fields terminated by '' enclosed by '' (a, @b);
124
111
 
125
112
# Now let us test LOAD DATA with subselect
126
113
create table t2 (num int primary key, str varchar(10));
127
114
insert into t2 values (10,'Ten'), (15,'Fifteen');
128
115
truncate table t1;
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);
 
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);
131
117
select * from t1;
132
118
 
133
119
#