~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/loaddata.test

  • Committer: patrick crews
  • Date: 2010-10-26 01:31:08 UTC
  • mfrom: (1878.7.1 drizzle)
  • mto: (1902.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1903.
  • Revision ID: gleebix@gmail.com-20101026013108-t2c3nokk4k8a7sxk
Updated tests to use variable vardir rather than a hard-coded one

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